Merge CV, ver=5.1; ops/methods from HV, and interface from CV where possible
[goodguy/history.git] / cinelerra-5.1 / guicast / bcfilebox.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #ifndef BCFILEBOX_H
23 #define BCFILEBOX_H
24
25 #include "bcbutton.h"
26 #include "bcdelete.inc"
27 #include "bcfilebox.inc"
28 #include "bclistbox.inc"
29 #include "bclistboxitem.inc"
30 #include "bcnewfolder.inc"
31 #include "bcrename.inc"
32 #include "bcresources.inc"
33 #include "bctextbox.h"
34 #include "bcwindow.h"
35 #include "condition.inc"
36 #include "filesystem.inc"
37 #include "mutex.inc"
38 #include "thread.h"
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55 class BC_FileBoxListBox : public BC_ListBox
56 {
57 public:
58         BC_FileBoxListBox(int x, int y, BC_FileBox *filebox);
59         virtual ~BC_FileBoxListBox();
60
61         int handle_event();
62         int selection_changed();
63         int column_resize_event();
64         int sort_order_event();
65         int move_column_event();
66         int evaluate_query(char *string);
67
68         BC_FileBox *filebox;
69 };
70
71 class BC_FileBoxTextBox : public BC_TextBox
72 {
73 public:
74         BC_FileBoxTextBox(int x, int y, BC_FileBox *filebox);
75         ~BC_FileBoxTextBox();
76
77         int handle_event();
78         BC_FileBox *filebox;
79 };
80
81 class BC_FileBoxOK : public BC_OKButton
82 {
83 public:
84         BC_FileBoxOK(BC_FileBox *filebox);
85         ~BC_FileBoxOK();
86
87         int handle_event();
88
89         BC_FileBox *filebox;
90 };
91
92 class BC_FileBoxUseThis : public BC_Button
93 {
94 public:
95         BC_FileBoxUseThis(BC_FileBox *filebox);
96         ~BC_FileBoxUseThis();
97         int handle_event();
98
99         BC_FileBox *filebox;
100 };
101
102 class BC_FileBoxCancel : public BC_CancelButton
103 {
104 public:
105         BC_FileBoxCancel(BC_FileBox *filebox);
106         ~BC_FileBoxCancel();
107
108         int handle_event();
109
110         BC_FileBox *filebox;
111 };
112
113 class BC_FileBoxText : public BC_Button
114 {
115 public:
116         BC_FileBoxText(int x, int y, BC_FileBox *filebox);
117         int handle_event();
118         BC_FileBox *filebox;
119 };
120
121 class BC_FileBoxDirectoryText : public BC_TextBox
122 {
123 public:
124         BC_FileBoxDirectoryText(int x, int y, BC_FileBox *filebox);
125         int handle_event();
126         BC_FileBox *filebox;
127 };
128
129 class BC_FileBoxFilterText : public BC_TextBox
130 {
131 public:
132         BC_FileBoxFilterText(int x, int y, BC_FileBox *filebox);
133         int handle_event();
134         BC_FileBox *filebox;
135 };
136
137 class BC_FileBoxFilterMenu : public BC_ListBox
138 {
139 public:
140         BC_FileBoxFilterMenu(int x, int y, BC_FileBox *filebox);
141         int handle_event();
142         BC_FileBox *filebox;
143 };
144
145 class BC_FileBoxIcons : public BC_Button
146 {
147 public:
148         BC_FileBoxIcons(int x, int y, BC_FileBox *filebox);
149         int handle_event();
150         BC_FileBox *filebox;
151 };
152
153 class BC_FileBoxNewfolder : public BC_Button
154 {
155 public:
156         BC_FileBoxNewfolder(int x, int y, BC_FileBox *filebox);
157         int handle_event();
158         BC_FileBox *filebox;
159 };
160
161 class BC_FileBoxRename : public BC_Button
162 {
163 public:
164         BC_FileBoxRename(int x, int y, BC_FileBox *filebox);
165         int handle_event();
166         BC_FileBox *filebox;
167 };
168
169 class BC_FileBoxUpdir : public BC_Button
170 {
171 public:
172         BC_FileBoxUpdir(int x, int y, BC_FileBox *filebox);
173         int handle_event();
174         BC_FileBox *filebox;
175         char string[BCTEXTLEN];
176 };
177
178 class BC_FileBoxDelete : public BC_Button
179 {
180 public:
181         BC_FileBoxDelete(int x, int y, BC_FileBox *filebox);
182         int handle_event();
183         BC_FileBox *filebox;
184 };
185
186 class BC_FileBoxReload : public BC_Button
187 {
188 public:
189         BC_FileBoxReload(int x, int y, BC_FileBox *filebox);
190         int handle_event();
191         BC_FileBox *filebox;
192 };
193
194
195
196 class BC_FileBoxRecent : public BC_ListBox
197 {
198 public:
199         BC_FileBoxRecent(BC_FileBox *filebox, int x, int y);
200         int handle_event();
201         BC_FileBox *filebox;
202 };
203
204
205
206
207 class BC_FileBox : public BC_Window
208 {
209 public:
210         BC_FileBox(int x,
211                 int y,
212                 const char *init_path,
213                 const char *title,
214                 const char *caption,
215 // Set to 1 to get hidden files.
216                 int show_all_files = 0,
217 // Want only directories
218                 int want_directory = 0,
219                 int multiple_files = 0,
220                 int h_padding = -1);
221         virtual ~BC_FileBox();
222
223         friend class BC_FileBoxCancel;
224         friend class BC_FileBoxDirectoryText;
225         friend class BC_FileBoxListBox;
226         friend class BC_FileBoxTextBox;
227         friend class BC_FileBoxText;
228         friend class BC_FileBoxIcons;
229         friend class BC_FileBoxNewfolder;
230         friend class BC_NewFolderThread;
231         friend class BC_FileBoxRename;
232         friend class BC_RenameThread;
233         friend class BC_FileBoxOK;
234         friend class BC_FileBoxUpdir;
235         friend class BC_FileBoxFilterText;
236         friend class BC_FileBoxFilterMenu;
237         friend class BC_FileBoxUseThis;
238         friend class BC_DeleteThread;
239         friend class BC_FileBoxDelete;
240         friend class BC_FileBoxReload;
241         friend class BC_FileBoxRecent;
242
243         virtual void create_objects();
244         virtual int keypress_event();
245         virtual int close_event();
246 // When file is submitted this is called for the user to retrieve it before the
247 // window is deleted.
248         virtual int handle_event();
249
250         void create_history();
251         void update_history();
252         int refresh(int zscroll=0);
253
254 // The OK and Use This button submits a path.
255 // The cancel button has a current path highlighted but possibly different from the
256 // path actually submitted.
257 // Give the most recently submitted path
258         char* get_submitted_path();
259 // Give the path currently highlighted
260         char* get_current_path();
261
262 // Give the path of any selected item or 0.  Used when many items are
263 // selected in the list.  Should only be called when OK is pressed.
264         char* get_path(int selection);
265         int update_filter(const char *filter);
266         virtual int resize_event(int w, int h);
267         char* get_newfolder_title();
268         char* get_rename_title();
269         char* get_delete_title();
270         void delete_files();
271         BC_Button* get_ok_button();
272         BC_Button* get_cancel_button();
273         FileSystem *fs;
274
275 private:
276         int create_icons();
277         int extract_extension(char *out, const char *in);
278         int create_tables();
279         int delete_tables();
280 // Called by directory history menu to change directories but leave
281 // filename untouched.
282         int submit_dir(char *dir);
283         int submit_file(const char *path, int use_this = 0);
284 // Called by move_column_event
285         void move_column(int src, int dst);
286         int get_display_mode();
287         int get_listbox_w();
288         int get_listbox_h(int y);
289         void create_listbox(int x, int y, int mode);
290 // Get the icon number for a listbox
291         BC_Pixmap* get_icon(char *path, int is_dir);
292         static const char* columntype_to_text(int type);
293 // Get the column whose type matches type.
294         int column_of_type(int type);
295
296         BC_Pixmap *icons[TOTAL_ICONS];
297         BC_FileBoxRecent *recent_popup;
298         BC_FileBoxTextBox *textbox;
299         BC_FileBoxListBox *listbox;
300         BC_FileBoxFilterText *filter_text;
301         BC_FileBoxFilterMenu *filter_popup;
302         BC_TextBox *directory_title;
303         BC_Button *icon_button;
304         BC_Button *text_button;
305         BC_Button *folder_button;
306         BC_Button *rename_button;
307         BC_Button *updir_button;
308         BC_Button *delete_button;
309         BC_Button *reload_button;
310         BC_Button *ok_button, *cancel_button;
311         BC_FileBoxUseThis *usethis_button;
312         char caption[BCTEXTLEN];
313         char current_path[BCTEXTLEN];
314         char submitted_path[BCTEXTLEN];
315         char directory[BCTEXTLEN];
316         char filename[BCTEXTLEN];
317         char string[BCTEXTLEN];
318         int want_directory;
319         int select_multiple;
320
321         int sort_column;
322         int sort_order;
323
324         const char *column_titles[FILEBOX_COLUMNS];
325         ArrayList<BC_ListBoxItem*> filter_list;
326         ArrayList<BC_ListBoxItem*> *list_column;
327         int *column_type;
328         int *column_width;
329 // Calculated based on directory or regular file searching
330         int columns;
331
332         char new_folder_title[BCTEXTLEN];
333         char rename_title[BCTEXTLEN];
334         BC_NewFolderThread *newfolder_thread;
335         BC_RenameThread *rename_thread;
336         BC_DeleteThread *delete_thread;
337         int h_padding;
338         ArrayList<BC_ListBoxItem*> recent_dirs;
339 };
340
341
342
343
344 #endif
345
346
347
348
349
350