4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
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"
35 #include "condition.inc"
36 #include "filesystem.inc"
55 class BC_FileBoxListBox : public BC_ListBox
58 BC_FileBoxListBox(int x, int y, BC_FileBox *filebox);
59 virtual ~BC_FileBoxListBox();
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);
71 class BC_FileBoxTextBox : public BC_TextBox
74 BC_FileBoxTextBox(int x, int y, BC_FileBox *filebox);
81 class BC_FileBoxUseThis : public BC_Button
84 BC_FileBoxUseThis(BC_FileBox *filebox);
91 class BC_FileBoxOK : public BC_OKButton
94 BC_FileBoxOK(BC_FileBox *filebox);
102 class BC_FileBoxCancel : public BC_CancelButton
105 BC_FileBoxCancel(BC_FileBox *filebox);
113 class BC_FileBoxText : public BC_Button
116 BC_FileBoxText(int x, int y, BC_FileBox *filebox);
121 class BC_FileBoxDirectoryText : public BC_TextBox
124 BC_FileBoxDirectoryText(int x, int y, BC_FileBox *filebox);
129 class BC_FileBoxFilterText : public BC_TextBox
132 BC_FileBoxFilterText(int x, int y, BC_FileBox *filebox);
137 class BC_FileBoxFilterMenu : public BC_ListBox
140 BC_FileBoxFilterMenu(int x, int y, BC_FileBox *filebox);
145 class BC_FileBoxIcons : public BC_Button
148 BC_FileBoxIcons(int x, int y, BC_FileBox *filebox);
153 class BC_FileBoxNewfolder : public BC_Button
156 BC_FileBoxNewfolder(int x, int y, BC_FileBox *filebox);
161 class BC_FileBoxRename : public BC_Button
164 BC_FileBoxRename(int x, int y, BC_FileBox *filebox);
169 class BC_FileBoxUpdir : public BC_Button
172 BC_FileBoxUpdir(int x, int y, BC_FileBox *filebox);
175 char string[BCTEXTLEN];
178 class BC_FileBoxDelete : public BC_Button
181 BC_FileBoxDelete(int x, int y, BC_FileBox *filebox);
186 class BC_FileBoxReload : public BC_Button
189 BC_FileBoxReload(int x, int y, BC_FileBox *filebox);
194 class BC_FileBoxSizeFormat : public BC_Button
197 BC_FileBoxSizeFormat(int x, int y, BC_FileBox *file_box);
198 ~BC_FileBoxSizeFormat();
201 BC_FileBox *file_box;
205 class BC_FileBoxRecent : public BC_ListBox
208 BC_FileBoxRecent(BC_FileBox *filebox, int x, int y);
216 class BC_FileBox : public BC_Window
221 const char *init_path,
224 // Set to 1 to get hidden files.
225 int show_all_files = 0,
226 // Want only directories
227 int want_directory = 0,
228 int multiple_files = 0,
230 virtual ~BC_FileBox();
232 friend class BC_FileBoxCancel;
233 friend class BC_FileBoxDirectoryText;
234 friend class BC_FileBoxListBox;
235 friend class BC_FileBoxTextBox;
236 friend class BC_FileBoxText;
237 friend class BC_FileBoxIcons;
238 friend class BC_FileBoxNewfolder;
239 friend class BC_NewFolderThread;
240 friend class BC_FileBoxRename;
241 friend class BC_RenameThread;
242 friend class BC_FileBoxOK;
243 friend class BC_FileBoxUpdir;
244 friend class BC_FileBoxFilterText;
245 friend class BC_FileBoxFilterMenu;
246 friend class BC_FileBoxUseThis;
247 friend class BC_DeleteThread;
248 friend class BC_FileBoxDelete;
249 friend class BC_FileBoxReload;
250 friend class BC_FileBoxRecent;
251 friend class BC_FileBoxSizeFormat;
253 virtual void create_objects();
254 virtual int keypress_event();
255 virtual int close_event();
256 // When file is submitted this is called for the user to retrieve it before the
257 // window is deleted.
258 virtual int handle_event();
260 void create_history();
261 void update_history();
262 int refresh(int reset=0, int select_all=0);
264 // The OK and Use This button submits a path.
265 // The cancel button has a current path highlighted but possibly different from the
266 // path actually submitted.
267 // Give the most recently submitted path
268 char* get_submitted_path();
269 // Give the path currently highlighted
270 char* get_current_path();
272 // Give the path of any selected item or 0. Used when many items are
273 // selected in the list. Should only be called when OK is pressed.
274 char* get_path(int selection);
275 int update_filter(const char *filter);
276 virtual int resize_event(int w, int h);
277 char* get_newfolder_title();
278 char* get_rename_title();
279 char* get_delete_title();
281 BC_Button* get_ok_button();
282 BC_Button* get_cancel_button();
287 int extract_extension(char *out, const char *in);
288 int create_tables(int select_all);
290 // Called by directory history menu to change directories but leave
291 // filename untouched.
292 int submit_dir(char *dir);
293 int submit_file(const char *path, int use_this = 0);
294 // Called by move_column_event
295 void move_column(int src, int dst);
296 int get_display_mode();
298 int get_listbox_h(int y);
299 void create_listbox(int x, int y, int mode);
300 // Get the icon number for a listbox
301 BC_Pixmap* get_icon(char *path, int is_dir);
302 static const char* columntype_to_text(int type);
303 // Get the column whose type matches type.
304 int column_of_type(int type);
306 BC_Pixmap *icons[TOTAL_ICONS];
307 BC_FileBoxRecent *recent_popup;
308 BC_FileBoxTextBox *textbox;
309 BC_FileBoxListBox *listbox;
310 BC_Title *filter_title;
311 BC_FileBoxFilterText *filter_text;
312 BC_FileBoxFilterMenu *filter_popup;
313 BC_TextBox *directory_title;
314 BC_Button *icon_button;
315 BC_Button *text_button;
316 BC_Button *folder_button;
317 BC_Button *rename_button;
318 BC_Button *updir_button;
319 BC_Button *delete_button;
320 BC_Button *reload_button;
321 BC_FileBoxSizeFormat *szfmt_button;
322 BC_Button *ok_button, *cancel_button;
323 BC_FileBoxUseThis *usethis_button;
324 char caption[BCTEXTLEN];
325 char current_path[BCTEXTLEN];
326 char submitted_path[BCTEXTLEN];
327 char directory[BCTEXTLEN];
328 char filename[BCTEXTLEN];
329 char string[BCTEXTLEN];
337 const char *column_titles[FILEBOX_COLUMNS];
338 ArrayList<BC_ListBoxItem*> filter_list;
339 ArrayList<BC_ListBoxItem*> *list_column;
342 // Calculated based on directory or regular file searching
345 char new_folder_title[BCTEXTLEN];
346 char rename_title[BCTEXTLEN];
347 BC_NewFolderThread *newfolder_thread;
348 BC_RenameThread *rename_thread;
349 BC_DeleteThread *delete_thread;
351 ArrayList<BC_ListBoxItem*> recent_dirs;