3 #include "bclistboxitem.h"
4 #include "bcnewfolder.h"
6 #include "bcresources.h"
10 #include "filesystem.h"
22 BC_FileBoxRecent::BC_FileBoxRecent(BC_FileBox *filebox, int x, int y)
26 filebox->get_text_height(MEDIUMFONT) * FILEBOX_HISTORY_SIZE +
27 BC_ScrollBar::get_span(SCROLL_HORIZ) +
30 &filebox->recent_dirs,
37 this->filebox = filebox;
40 int BC_FileBoxRecent::handle_event()
42 if(get_selection(0, 0) >= 0)
44 filebox->submit_dir(get_selection(0, 0)->get_text());
59 BC_FileBoxListBox::BC_FileBoxListBox(int x, int y, BC_FileBox *filebox)
62 filebox->get_listbox_w(),
63 filebox->get_listbox_h(y),
64 filebox->get_display_mode(),
66 filebox->column_titles,
67 filebox->column_width,
71 filebox->select_multiple ? LISTBOX_MULTIPLE : LISTBOX_SINGLE,
75 this->filebox = filebox;
76 set_sort_column(filebox->sort_column);
77 set_sort_order(filebox->sort_order);
78 set_allow_drag_column(1);
81 BC_FileBoxListBox::~BC_FileBoxListBox()
85 int BC_FileBoxListBox::handle_event()
87 filebox->submit_file(filebox->textbox->get_text());
91 int BC_FileBoxListBox::selection_changed()
93 BC_ListBoxItem *item = get_selection(
94 filebox->column_of_type(FILEBOX_NAME), 0);
99 strcpy(path, item->get_text());
100 filebox->textbox->update(path);
101 filebox->fs->extract_dir(filebox->directory, path);
102 filebox->fs->extract_name(filebox->filename, path);
103 filebox->fs->complete_path(path);
104 strcpy(filebox->current_path, path);
105 strcpy(filebox->submitted_path, path);
110 int BC_FileBoxListBox::column_resize_event()
112 for(int i = 0; i < filebox->columns; i++)
113 BC_WindowBase::get_resources()->filebox_columnwidth[i] =
114 filebox->column_width[i] =
119 int BC_FileBoxListBox::sort_order_event()
121 get_resources()->filebox_sortcolumn = filebox->sort_column = get_sort_column();
122 get_resources()->filebox_sortorder = filebox->sort_order = get_sort_order();
127 int BC_FileBoxListBox::move_column_event()
129 filebox->move_column(get_from_column(), get_to_column());
133 int BC_FileBoxListBox::evaluate_query(int list_item, char *string)
135 ArrayList<BC_ListBoxItem*> *column =
136 &filebox->list_column[filebox->column_of_type(FILEBOX_NAME)];
137 return(column->values[list_item]->get_color() != get_resources()->directory_color &&
138 strcmp(string, column->values[list_item]->get_text()) <= 0);
144 BC_FileBoxTextBox::BC_FileBoxTextBox(int x, int y, BC_FileBox *filebox)
145 : BC_TextBox(x, y, filebox->get_w() - 50, 1, filebox->filename)
147 this->filebox = filebox;
150 BC_FileBoxTextBox::~BC_FileBoxTextBox()
154 int BC_FileBoxTextBox::handle_event()
156 // filebox->handle_event();
163 BC_FileBoxDirectoryText::BC_FileBoxDirectoryText(int x, int y, BC_FileBox *filebox)
164 : BC_TextBox(x, y, filebox->get_w() - 40, 1, filebox->fs->get_current_dir())
166 this->filebox = filebox;
169 int BC_FileBoxDirectoryText::handle_event()
173 // is a directory, change directories
174 if(filebox->fs->is_dir(path))
176 filebox->fs->change_dir(path);
178 update(strcat(filebox->fs->get_current_dir(),"/"));
187 BC_FileBoxFilterText::BC_FileBoxFilterText(int x, int y, BC_FileBox *filebox)
188 : BC_TextBox(x, y, filebox->get_w() - 50, 1, filebox->get_resources()->filebox_filter)
190 this->filebox = filebox;
193 int BC_FileBoxFilterText::handle_event()
195 filebox->update_filter(get_text());
202 BC_FileBoxFilterMenu::BC_FileBoxFilterMenu(int x, int y, BC_FileBox *filebox)
205 filebox->get_w() - 30,
208 &filebox->filter_list,
215 this->filebox = filebox;
216 set_tooltip(_("Change the filter"));
219 int BC_FileBoxFilterMenu::handle_event()
221 filebox->filter_text->update(
222 get_selection(filebox->column_of_type(FILEBOX_NAME), 0)->get_text());
223 filebox->update_filter(
224 get_selection(filebox->column_of_type(FILEBOX_NAME), 0)->get_text());
237 BC_FileBoxCancel::BC_FileBoxCancel(BC_FileBox *filebox)
238 : BC_CancelButton(filebox)
240 this->filebox = filebox;
241 set_tooltip(_("Cancel the operation"));
244 BC_FileBoxCancel::~BC_FileBoxCancel()
248 int BC_FileBoxCancel::handle_event()
250 // filebox->submit_file(filebox->textbox->get_text());
251 filebox->newfolder_thread->interrupt();
252 filebox->set_done(1);
262 BC_FileBoxUseThis::BC_FileBoxUseThis(BC_FileBox *filebox)
263 : BC_Button(filebox->get_w() / 2 -
264 BC_WindowBase::get_resources()->usethis_button_images[0]->get_w() / 2,
265 filebox->ok_button->get_y(),
266 BC_WindowBase::get_resources()->usethis_button_images)
268 this->filebox = filebox;
269 set_tooltip(_("Submit the directory"));
272 BC_FileBoxUseThis::~BC_FileBoxUseThis()
276 int BC_FileBoxUseThis::handle_event()
278 filebox->submit_file(filebox->textbox->get_text(), 1);
286 BC_FileBoxOK::BC_FileBoxOK(BC_FileBox *filebox)
287 : BC_OKButton(filebox,
288 !filebox->want_directory ?
289 BC_WindowBase::get_resources()->ok_images :
290 BC_WindowBase::get_resources()->filebox_descend_images)
292 this->filebox = filebox;
293 if(filebox->want_directory)
294 set_tooltip(_("Descend directory"));
296 set_tooltip(_("Submit the file"));
299 BC_FileBoxOK::~BC_FileBoxOK()
303 int BC_FileBoxOK::handle_event()
305 filebox->submit_file(filebox->textbox->get_text());
314 BC_FileBoxText::BC_FileBoxText(int x, int y, BC_FileBox *filebox)
315 : BC_Button(x, y, BC_WindowBase::get_resources()->filebox_text_images)
317 this->filebox = filebox;
318 set_tooltip(_("Display text"));
320 int BC_FileBoxText::handle_event()
322 filebox->create_listbox(filebox->listbox->get_x(), filebox->listbox->get_y(), LISTBOX_TEXT);
327 BC_FileBoxIcons::BC_FileBoxIcons(int x, int y, BC_FileBox *filebox)
328 : BC_Button(x, y, BC_WindowBase::get_resources()->filebox_icons_images)
330 this->filebox = filebox;
331 set_tooltip(_("Display icons"));
333 int BC_FileBoxIcons::handle_event()
335 filebox->create_listbox(filebox->listbox->get_x(), filebox->listbox->get_y(), LISTBOX_ICONS);
340 BC_FileBoxNewfolder::BC_FileBoxNewfolder(int x, int y, BC_FileBox *filebox)
341 : BC_Button(x, y, BC_WindowBase::get_resources()->filebox_newfolder_images)
343 this->filebox = filebox;
344 set_tooltip(_("Create new folder"));
346 int BC_FileBoxNewfolder::handle_event()
348 filebox->newfolder_thread->start_new_folder();
352 BC_FileBoxUpdir::BC_FileBoxUpdir(int x, int y, BC_FileBox *filebox)
353 : BC_Button(x, y, BC_WindowBase::get_resources()->filebox_updir_images)
355 this->filebox = filebox;
356 set_tooltip(_("Up a directory"));
358 int BC_FileBoxUpdir::handle_event()
360 // Need a temp so submit_file can expand it
361 sprintf(string, _(".."));
362 filebox->submit_file(string);
366 BC_FileBoxDelete::BC_FileBoxDelete(int x, int y, BC_FileBox *filebox)
367 : BC_Button(x, y, BC_WindowBase::get_resources()->filebox_delete_images)
369 this->filebox = filebox;
370 set_tooltip(_("Delete files"));
372 int BC_FileBoxDelete::handle_event()
374 filebox->unlock_window();
375 filebox->delete_thread->start();
376 filebox->lock_window("BC_FileBoxDelete::handle_event");
380 BC_FileBoxReload::BC_FileBoxReload(int x, int y, BC_FileBox *filebox)
381 : BC_Button(x, y, BC_WindowBase::get_resources()->filebox_reload_images)
383 this->filebox = filebox;
384 set_tooltip(_("Refresh"));
386 int BC_FileBoxReload::handle_event()
401 BC_FileBox::BC_FileBox(int x,
413 BC_WindowBase::get_resources()->filebox_w,
414 BC_WindowBase::get_resources()->filebox_h,
422 // if(want_directory)
424 // fs->set_want_directory();
425 // columns = DIRBOX_COLUMNS;
426 // columns = FILEBOX_COLUMNS;
430 columns = FILEBOX_COLUMNS;
433 list_column = new ArrayList<BC_ListBoxItem*>[columns];
434 column_type = new int[columns];
435 column_width = new int[columns];
441 strcpy(this->caption, caption);
442 strcpy(this->current_path, init_path);
443 strcpy(this->submitted_path, init_path);
444 select_multiple = multiple_files;
445 this->want_directory = want_directory;
446 if(show_all_files) fs->set_show_all();
447 fs->complete_path(this->current_path);
448 fs->complete_path(this->submitted_path);
449 fs->extract_dir(directory, this->current_path);
450 fs->extract_name(filename, this->current_path);
453 // if(want_directory)
455 // for(int i = 0; i < columns; i++)
457 // column_type[i] = get_resources()->dirbox_columntype[i];
458 // column_width[i] = get_resources()->dirbox_columnwidth[i];
459 // column_titles[i] = BC_FileBox::columntype_to_text(column_type[i]);
461 // sort_column = get_resources()->dirbox_sortcolumn;
462 // sort_order = get_resources()->dirbox_sortorder;
466 for(int i = 0; i < columns; i++)
468 column_type[i] = get_resources()->filebox_columntype[i];
469 column_width[i] = get_resources()->filebox_columnwidth[i];
470 column_titles[i] = BC_FileBox::columntype_to_text(column_type[i]);
472 sort_column = get_resources()->filebox_sortcolumn;
473 sort_order = get_resources()->filebox_sortorder;
479 if(fs->update(directory))
481 sprintf(this->current_path, "~");
482 fs->complete_path(this->current_path);
483 fs->update(this->current_path);
484 strcpy(directory, fs->get_current_dir());
485 sprintf(filename, "");
491 h_padding = BC_WindowBase::get_resources()->ok_images[0]->get_h() -
494 this->h_padding = h_padding;
495 delete_thread = new BC_DeleteThread(this);
498 BC_FileBox::~BC_FileBox()
500 // this has to be destroyed before tables, because it can call for an update!
501 delete newfolder_thread;
504 for(int i = 0; i < TOTAL_ICONS; i++)
506 filter_list.remove_all_objects();
507 delete [] list_column;
508 delete [] column_type;
509 delete [] column_width;
510 delete delete_thread;
511 recent_dirs.remove_all_objects();
514 int BC_FileBox::create_objects()
517 BC_Resources *resources = BC_WindowBase::get_resources();
518 int directory_title_margin = MAX(20,
519 resources->filebox_text_images[0]->get_h());
521 // Create recent dir list
524 // Directories aren't filtered in FileSystem so skip this
527 filter_list.append(new BC_ListBoxItem("*"));
528 filter_list.append(new BC_ListBoxItem("[*.ifo][*.vob]"));
529 filter_list.append(new BC_ListBoxItem("[*.mp2][*.mp3][*.wav]"));
530 filter_list.append(new BC_ListBoxItem("[*.avi][*.mpg][*.m2v][*.m1v][*.mov]"));
531 filter_list.append(new BC_ListBoxItem("heroine*"));
532 filter_list.append(new BC_ListBoxItem("*.xml"));
533 fs->set_filter(get_resources()->filebox_filter);
536 fs->update(directory);
540 add_subwindow(ok_button = new BC_FileBoxOK(this));
542 add_subwindow(usethis_button = new BC_FileBoxUseThis(this));
543 add_subwindow(cancel_button = new BC_FileBoxCancel(this));
545 add_subwindow(new BC_Title(x, y, caption));
547 x = get_w() - resources->filebox_icons_images[0]->get_w() - 10;
548 add_subwindow(icon_button = new BC_FileBoxIcons(x, y, this));
549 x -= resources->filebox_text_images[0]->get_w() + 5;
550 add_subwindow(text_button = new BC_FileBoxText(x, y, this));
551 x -= resources->filebox_newfolder_images[0]->get_w() + 5;
552 add_subwindow(folder_button = new BC_FileBoxNewfolder(x, y, this));
553 x -= resources->filebox_delete_images[0]->get_w() + 5;
554 add_subwindow(delete_button = new BC_FileBoxDelete(x, y, this));
555 x -= resources->filebox_reload_images[0]->get_w() + 5;
556 add_subwindow(reload_button = new BC_FileBoxReload(x, y, this));
557 x -= resources->filebox_updir_images[0]->get_w() + 5;
558 add_subwindow(updir_button = new BC_FileBoxUpdir(x, y, this));
561 y += directory_title_margin + 3;
563 add_subwindow(recent_popup = new BC_FileBoxRecent(this,
566 add_subwindow(directory_title = new BC_FileBoxDirectoryText(x, y, this));
567 directory_title->reposition_window(
570 get_w() - recent_popup->get_w() - 20,
572 recent_popup->reposition_window(
573 x + directory_title->get_w(),
575 directory_title->get_w(),
579 y += directory_title->get_h() + 5;
582 create_listbox(x, y, get_display_mode());
583 y += listbox->get_h() + 10;
584 add_subwindow(textbox = new BC_FileBoxTextBox(x, y, this));
585 y += textbox->get_h() + 10;
590 add_subwindow(filter_text = new BC_FileBoxFilterText(x, y, this));
591 add_subwindow(filter_popup =
592 new BC_FileBoxFilterMenu(x + filter_text->get_w(), y, this));;
595 // listbox has to be active because refresh might be called from newfolder_thread
597 newfolder_thread = new BC_NewFolderThread(this);
603 int BC_FileBox::get_listbox_w()
608 int BC_FileBox::get_listbox_h(int y)
610 int result = get_h() -
614 result -= BC_WindowBase::get_resources()->dirbox_margin;
616 result -= BC_WindowBase::get_resources()->filebox_margin;
621 int BC_FileBox::create_icons()
623 for(int i = 0; i < TOTAL_ICONS; i++)
625 icons[i] = new BC_Pixmap(this,
626 BC_WindowBase::get_resources()->type_to_icon[i],
632 int BC_FileBox::resize_event(int w, int h)
634 draw_background(0, 0, w, h);
637 // OK button handles resize event itself
638 // ok_button->reposition_window(ok_button->get_x(),
639 // h - (get_h() - ok_button->get_y()));
640 // cancel_button->reposition_window(w - (get_w() - cancel_button->get_x()),
641 // h - (get_h() - cancel_button->get_y()));
643 usethis_button->reposition_window(w / 2 - 50, h - (get_h() - usethis_button->get_y()));
646 if(filter_popup) filter_popup->reposition_window(w - (get_w() - filter_popup->get_x()),
647 h - (get_h() - filter_popup->get_y()),
651 if(filter_text) filter_text->reposition_window(filter_text->get_x(),
652 h - (get_h() - filter_text->get_y()),
653 w - (get_w() - filter_text->get_w()),
655 directory_title->reposition_window(
656 directory_title->get_x(),
657 directory_title->get_y(),
658 get_w() - recent_popup->get_w() - 20,
660 recent_popup->reposition_window(
661 directory_title->get_x() + directory_title->get_w(),
662 directory_title->get_y(),
663 directory_title->get_w() + recent_popup->get_w(),
664 recent_popup->get_h());
665 textbox->reposition_window(textbox->get_x(),
666 h - (get_h() - textbox->get_y()),
667 w - (get_w() - textbox->get_w()),
669 listbox->reposition_window(listbox->get_x(),
671 w - (get_w() - listbox->get_w()),
672 h - (get_h() - listbox->get_h()));
673 icon_button->reposition_window(w - (get_w() - icon_button->get_x()),
674 icon_button->get_y());
675 text_button->reposition_window(w - (get_w() - text_button->get_x()),
676 text_button->get_y());
677 folder_button->reposition_window(w - (get_w() - folder_button->get_x()),
678 folder_button->get_y());
679 reload_button->reposition_window(w - (get_w() - reload_button->get_x()),
680 reload_button->get_y());
681 delete_button->reposition_window(w - (get_w() - delete_button->get_x()),
682 delete_button->get_y());
683 updir_button->reposition_window(w - (get_w() - updir_button->get_x()),
684 updir_button->get_y());
687 get_resources()->filebox_w = get_w();
688 get_resources()->filebox_h = get_h();
692 int BC_FileBox::keypress_event()
694 switch(get_keypress())
697 if(ctrl_down()) set_done(1);
704 int BC_FileBox::close_event()
710 int BC_FileBox::handle_event()
715 int BC_FileBox::extract_extension(char *out, const char *in)
719 for(i = strlen(in)-1; i > 0 && in[i] != '.'; i--)
732 int BC_FileBox::create_tables()
735 char string[BCTEXTLEN];
736 BC_ListBoxItem *new_item;
738 fs->set_sort_order(sort_order);
739 fs->set_sort_field(column_type[sort_column]);
741 // Directory is entered before this from a random source
743 for(int i = 0; i < fs->total_files(); i++)
745 FileItem *file_item = fs->get_entry(i);
746 int is_dir = file_item->is_dir;
747 BC_Pixmap* icon = get_icon(file_item->name, is_dir);
750 new_item = new BC_ListBoxItem(file_item->name,
752 is_dir ? get_resources()->directory_color : get_resources()->file_color);
753 if(is_dir) new_item->set_searchable(0);
754 list_column[column_of_type(FILEBOX_NAME)].append(new_item);
757 // if(!want_directory)
761 sprintf(string, "%lld", file_item->size);
762 new_item = new BC_ListBoxItem(string, get_resources()->file_color);
766 new_item = new BC_ListBoxItem("", get_resources()->directory_color);
769 list_column[column_of_type(FILEBOX_SIZE)].append(new_item);
775 static char *month_text[13] =
793 month_text[file_item->month],
796 new_item = new BC_ListBoxItem(string, get_resources()->file_color);
800 new_item = new BC_ListBoxItem("", get_resources()->directory_color);
803 list_column[column_of_type(FILEBOX_DATE)].append(new_item);
806 // if(!want_directory)
810 extract_extension(string, file_item->name);
811 new_item = new BC_ListBoxItem(string, get_resources()->file_color);
815 new_item = new BC_ListBoxItem("", get_resources()->directory_color);
817 list_column[column_of_type(FILEBOX_EXTENSION)].append(new_item);
824 int BC_FileBox::delete_tables()
826 for(int j = 0; j < columns; j++)
828 list_column[j].remove_all_objects();
833 BC_Pixmap* BC_FileBox::get_icon(char *path, int is_dir)
835 char *suffix = strrchr(path, '.');
836 int icon_type = ICON_UNKNOWN;
838 if(is_dir) return icons[ICON_FOLDER];
845 for(int i = 0; i < TOTAL_SUFFIXES; i++)
847 if(!strcasecmp(suffix, BC_WindowBase::get_resources()->suffix_to_type[i].suffix))
849 icon_type = BC_WindowBase::get_resources()->suffix_to_type[i].icon_type;
856 return icons[icon_type];
859 char* BC_FileBox::columntype_to_text(int type)
864 return FILEBOX_NAME_TEXT;
867 return FILEBOX_SIZE_TEXT;
870 return FILEBOX_DATE_TEXT;
872 case FILEBOX_EXTENSION:
873 return FILEBOX_EXTENSION_TEXT;
879 int BC_FileBox::column_of_type(int type)
881 for(int i = 0; i < columns; i++)
882 if(column_type[i] == type) return i;
888 int BC_FileBox::refresh()
891 listbox->set_master_column(column_of_type(FILEBOX_NAME), 0);
892 listbox->update(list_column,
904 int BC_FileBox::update_filter(char *filter)
906 fs->set_filter(filter);
909 strcpy(get_resources()->filebox_filter, filter);
915 void BC_FileBox::move_column(int src, int dst)
917 ArrayList<BC_ListBoxItem*> *new_columns =
918 new ArrayList<BC_ListBoxItem*>[columns];
919 int *new_types = new int[columns];
920 int *new_widths = new int[columns];
922 // Fill in remaining columns with consecutive data
923 for(int out_column = 0, in_column = 0;
924 out_column < columns;
928 // Copy destination column from src column
929 if(out_column == dst)
931 for(int i = 0; i < list_column[src].total; i++)
933 new_columns[out_column].append(list_column[src].values[i]);
935 new_types[out_column] = column_type[src];
936 new_widths[out_column] = column_width[src];
941 // Skip source column
942 if(in_column == src) in_column++;
943 for(int i = 0; i < list_column[src].total; i++)
945 new_columns[out_column].append(list_column[in_column].values[i]);
947 new_types[out_column] = column_type[in_column];
948 new_widths[out_column] = column_width[in_column];
953 delete [] list_column;
954 delete [] column_type;
955 delete [] column_width;
956 list_column = new_columns;
957 column_type = new_types;
958 column_width = new_widths;
960 for(int i = 0; i < columns; i++)
962 get_resources()->filebox_columntype[i] = column_type[i];
963 get_resources()->filebox_columnwidth[i] = column_width[i];
964 column_titles[i] = BC_FileBox::columntype_to_text(column_type[i]);
972 int BC_FileBox::submit_dir(char *dir)
974 strcpy(directory, dir);
975 fs->join_names(current_path, directory, filename);
976 strcpy(submitted_path, current_path);
979 directory_title->update(fs->get_current_dir());
981 textbox->update(fs->get_current_dir());
983 textbox->update(filename);
984 listbox->reset_query();
988 int BC_FileBox::submit_file(char *path, int use_this)
991 // If file wanted, take the current directory as the desired file.
992 // If directory wanted, ignore it.
993 if(!path[0] && !want_directory)
995 // save complete path
996 strcpy(this->current_path, directory);
997 // save complete path
998 strcpy(this->submitted_path, directory);
1000 // Zero out filename
1006 // is a directory, change directories
1007 if(fs->is_dir(path) && !use_this)
1009 fs->change_dir(path);
1011 directory_title->update(fs->get_current_dir());
1012 strcpy(this->current_path, fs->get_current_dir());
1013 strcpy(this->submitted_path, fs->get_current_dir());
1014 strcpy(this->directory, fs->get_current_dir());
1017 textbox->update(fs->get_current_dir());
1019 textbox->update("");
1020 listbox->reset_query();
1024 // Is a file or desired directory. Quit the operation.
1026 // save directory for defaults
1027 fs->extract_dir(directory, path);
1029 // Just take the directory
1033 strcpy(path, directory);
1036 // Take the complete path
1038 fs->extract_name(filename, path); // save filename
1041 fs->complete_path(path);
1042 strcpy(this->current_path, path); // save complete path
1043 strcpy(this->submitted_path, path); // save complete path
1045 newfolder_thread->interrupt();
1052 void BC_FileBox::update_history()
1054 // Look for path already in history
1055 BC_Resources *resources = get_resources();
1056 int new_slot = FILEBOX_HISTORY_SIZE - 1;
1057 for(int i = FILEBOX_HISTORY_SIZE - 1; i >= 0; i--)
1059 if(!strcmp(resources->filebox_history[i], directory))
1061 // Shift down from this point
1064 strcpy(resources->filebox_history[i],
1065 resources->filebox_history[i - 1]);
1066 if(resources->filebox_history[i][0]) new_slot--;
1072 if(resources->filebox_history[i][0])
1080 for(int i = FILEBOX_HISTORY_SIZE - 1; i > 0; i--)
1082 strcpy(resources->filebox_history[i],
1083 resources->filebox_history[i - 1]);
1087 strcpy(resources->filebox_history[new_slot], directory);
1090 recent_popup->update(&recent_dirs,
1096 void BC_FileBox::create_history()
1098 BC_Resources *resources = get_resources();
1099 recent_dirs.remove_all_objects();
1100 for(int i = 0; i < FILEBOX_HISTORY_SIZE; i++)
1102 if(resources->filebox_history[i][0])
1104 recent_dirs.append(new BC_ListBoxItem(resources->filebox_history[i]));
1110 int BC_FileBox::get_display_mode()
1112 return top_level->get_resources()->filebox_mode;
1115 void BC_FileBox::create_listbox(int x, int y, int mode)
1117 if(listbox && listbox->get_display_mode() != mode)
1121 top_level->get_resources()->filebox_mode = mode;
1125 add_subwindow(listbox = new BC_FileBoxListBox(x, y, this));
1128 char* BC_FileBox::get_path(int selection)
1132 return get_submitted_path();
1136 BC_ListBoxItem *item = listbox->get_selection(
1137 column_of_type(FILEBOX_NAME), selection - 1);
1140 fs->join_names(string, directory, item->get_text());
1147 char* BC_FileBox::get_submitted_path()
1149 return submitted_path;
1152 char* BC_FileBox::get_current_path()
1154 //printf("BC_FileBox::get_current_path 1 %s\n", current_path);
1155 return current_path;
1158 char* BC_FileBox::get_newfolder_title()
1160 char *letter2 = strchr(title, ':');
1161 new_folder_title[0] = 0;
1164 memcpy(new_folder_title, title, letter2 - title);
1165 new_folder_title[letter2 - title] = 0;
1168 strcat(new_folder_title, _(": New folder"));
1170 return new_folder_title;
1173 char* BC_FileBox::get_delete_title()
1175 char *letter2 = strchr(title, ':');
1176 new_folder_title[0] = 0;
1179 memcpy(new_folder_title, title, letter2 - title);
1180 new_folder_title[letter2 - title] = 0;
1183 strcat(new_folder_title, _(": Delete"));
1185 return new_folder_title;
1188 void BC_FileBox::delete_files()
1190 // Starting at 1 causes it to ignore what's in the textbox.
1194 while((path = get_path(i)))
1196 // Not directory. Remove it.
1197 if(!fs.is_dir(path))
1199 printf("BC_FileBox::delete_files: removing \"%s\"\n", path);
1207 BC_Button* BC_FileBox::get_ok_button()
1212 BC_Button* BC_FileBox::get_cancel_button()
1214 return cancel_button;