back by popular demand: load mode icons, tweak shapewipe layout
[goodguy/cinelerra.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_FileBoxUseThis : public BC_Button
82 {
83 public:
84         BC_FileBoxUseThis(BC_FileBox *filebox);
85         ~BC_FileBoxUseThis();
86         int handle_event();
87
88         BC_FileBox *filebox;
89 };
90
91 class BC_FileBoxOK : public BC_OKButton
92 {
93 public:
94         BC_FileBoxOK(BC_FileBox *filebox);
95         ~BC_FileBoxOK();
96
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, int w, BC_FileBox *filebox);
125         int handle_event();
126         BC_FileBox *filebox;
127 };
128
129 class BC_FileBoxSearchText : public BC_TextBox
130 {
131 public:
132         BC_FileBoxSearchText(int x, int y, BC_FileBox *filebox);
133         int handle_event();
134         BC_FileBox *filebox;
135 };
136
137 class BC_FileBoxFilterText : public BC_TextBox
138 {
139 public:
140         BC_FileBoxFilterText(int x, int y, BC_FileBox *filebox);
141         int handle_event();
142         BC_FileBox *filebox;
143 };
144
145 class BC_FileBoxFilterMenu : public BC_ListBox
146 {
147 public:
148         BC_FileBoxFilterMenu(int x, int y, BC_FileBox *filebox);
149         int handle_event();
150         BC_FileBox *filebox;
151 };
152
153 class BC_FileBoxIcons : public BC_Button
154 {
155 public:
156         BC_FileBoxIcons(int x, int y, BC_FileBox *filebox);
157         int handle_event();
158         BC_FileBox *filebox;
159 };
160
161 class BC_FileBoxNewfolder : public BC_Button
162 {
163 public:
164         BC_FileBoxNewfolder(int x, int y, BC_FileBox *filebox);
165         int handle_event();
166         BC_FileBox *filebox;
167 };
168
169 class BC_FileBoxRename : public BC_Button
170 {
171 public:
172         BC_FileBoxRename(int x, int y, BC_FileBox *filebox);
173         int handle_event();
174         BC_FileBox *filebox;
175 };
176
177 class BC_FileBoxUpdir : public BC_Button
178 {
179 public:
180         BC_FileBoxUpdir(int x, int y, BC_FileBox *filebox);
181         int handle_event();
182         BC_FileBox *filebox;
183         char string[BCTEXTLEN];
184 };
185
186 class BC_FileBoxDelete : public BC_Button
187 {
188 public:
189         BC_FileBoxDelete(int x, int y, BC_FileBox *filebox);
190         int handle_event();
191         BC_FileBox *filebox;
192 };
193
194 class BC_FileBoxReload : public BC_Button
195 {
196 public:
197         BC_FileBoxReload(int x, int y, BC_FileBox *filebox);
198         int handle_event();
199         BC_FileBox *filebox;
200 };
201
202 class BC_FileBoxSizeFormat : public BC_Button
203 {
204 public:
205         BC_FileBoxSizeFormat(int x, int y, BC_FileBox *file_box);
206         ~BC_FileBoxSizeFormat();
207
208         int handle_event();
209         BC_FileBox *file_box;
210 };
211
212
213 class BC_FileBoxRecent : public BC_ListBox
214 {
215 public:
216         BC_FileBoxRecent(BC_FileBox *filebox, int x, int y);
217         int handle_event();
218         BC_FileBox *filebox;
219 };
220
221
222
223
224 class BC_FileBox : public BC_Window
225 {
226 public:
227         BC_FileBox(int x,
228                 int y,
229                 const char *init_path,
230                 const char *title,
231                 const char *caption,
232 // Set to 1 to get hidden files.
233                 int show_all_files = 0,
234 // Want only directories
235                 int want_directory = 0,
236                 int multiple_files = 0,
237                 int h_padding = -1);
238         virtual ~BC_FileBox();
239
240         friend class BC_FileBoxCancel;
241         friend class BC_FileBoxDirectoryText;
242         friend class BC_FileBoxSearchText;
243         friend class BC_FileBoxListBox;
244         friend class BC_FileBoxTextBox;
245         friend class BC_FileBoxText;
246         friend class BC_FileBoxIcons;
247         friend class BC_FileBoxNewfolder;
248         friend class BC_NewFolderThread;
249         friend class BC_FileBoxRename;
250         friend class BC_RenameThread;
251         friend class BC_FileBoxOK;
252         friend class BC_FileBoxUpdir;
253         friend class BC_FileBoxFilterText;
254         friend class BC_FileBoxFilterMenu;
255         friend class BC_FileBoxUseThis;
256         friend class BC_DeleteThread;
257         friend class BC_FileBoxDelete;
258         friend class BC_FileBoxReload;
259         friend class BC_FileBoxRecent;
260         friend class BC_FileBoxSizeFormat;
261
262         virtual void create_objects();
263         virtual int keypress_event();
264         virtual int close_event();
265 // When file is submitted this is called for the user to retrieve it before the
266 // window is deleted.
267         virtual int handle_event();
268
269         void create_history();
270         void update_history();
271         int refresh(int reset=0, int select_all=0);
272
273 // The OK and Use This button submits a path.
274 // The cancel button has a current path highlighted but possibly different from the
275 // path actually submitted.
276 // Give the most recently submitted path
277         char* get_submitted_path();
278 // Give the path currently highlighted
279         char* get_current_path();
280
281 // Give the path of any selected item or 0.  Used when many items are
282 // selected in the list.  Should only be called when OK is pressed.
283         char* get_path(int selection);
284         int update_filter(const char *filter);
285         virtual int resize_event(int w, int h);
286         char* get_newfolder_title();
287         char* get_rename_title();
288         char* get_delete_title();
289         int get_y_margin();
290         void delete_files();
291         BC_Button* get_ok_button();
292         BC_Button* get_cancel_button();
293         FileSystem *fs;
294
295 private:
296         int create_icons();
297         int extract_extension(char *out, const char *in);
298         int create_tables(int select_all);
299         int delete_tables();
300 // Called by directory history menu to change directories but leave
301 // filename untouched.
302         int submit_dir(char *dir);
303         int submit_file(const char *path, int use_this = 0);
304 // Called by move_column_event
305         void move_column(int src, int dst);
306         int get_display_mode();
307         int get_listbox_w();
308         int get_listbox_h(int y);
309         void create_listbox(int x, int y, int mode);
310 // Get the icon number for a listbox
311         BC_Pixmap* get_icon(char *path, int is_dir);
312         static const char* columntype_to_text(int type);
313 // Get the column whose type matches type.
314         int column_of_type(int type);
315
316         BC_Pixmap *icons[TOTAL_ICONS];
317         BC_FileBoxRecent *recent_popup;
318         BC_Title *file_title;
319         BC_FileBoxTextBox *textbox;
320         BC_FileBoxListBox *listbox;
321         BC_Title *filter_title;
322         BC_FileBoxFilterText *filter_text;
323         BC_FileBoxFilterMenu *filter_popup;
324         BC_FileBoxDirectoryText *directory_title;
325         BC_FileBoxSearchText *search_text;
326         BC_Button *icon_button;
327         BC_Button *text_button;
328         BC_Button *folder_button;
329         BC_Button *rename_button;
330         BC_Button *updir_button;
331         BC_Button *delete_button;
332         BC_Button *reload_button;
333         BC_FileBoxSizeFormat *szfmt_button;
334         BC_Button *ok_button, *cancel_button;
335         BC_FileBoxUseThis *usethis_button;
336         char caption[BCTEXTLEN];
337         char current_path[BCTEXTLEN];
338         char submitted_path[BCTEXTLEN];
339         char directory[BCTEXTLEN];
340         char filename[BCTEXTLEN];
341         char string[BCTEXTLEN];
342         int want_directory;
343         int select_multiple;
344
345         int sort_column;
346         int sort_order;
347         int size_format;
348
349         const char *column_titles[FILEBOX_COLUMNS];
350         ArrayList<BC_ListBoxItem*> filter_list;
351         ArrayList<BC_ListBoxItem*> *list_column;
352         int *column_type;
353         int *column_width;
354 // Calculated based on directory or regular file searching
355         int columns;
356
357         char new_folder_title[BCTEXTLEN];
358         char rename_title[BCTEXTLEN];
359         BC_NewFolderThread *newfolder_thread;
360         BC_RenameThread *rename_thread;
361         BC_DeleteThread *delete_thread;
362         int h_padding, y_margin;
363         ArrayList<BC_ListBoxItem*> recent_dirs;
364 };
365
366
367
368
369 #endif
370
371
372
373
374
375