00001 #include "bcdelete.h"
00002 #include "bcfilebox.h"
00003 #include "bclistboxitem.h"
00004 #include "bcnewfolder.h"
00005 #include "bcpixmap.h"
00006 #include "bcresources.h"
00007 #include "bctitle.h"
00008 #include "clip.h"
00009 #include "condition.h"
00010 #include "filesystem.h"
00011 #include "language.h"
00012 #include "mutex.h"
00013 #include <string.h>
00014 #include <sys/stat.h>
00015
00016
00017
00018
00019
00020
00021
00022 BC_FileBoxRecent::BC_FileBoxRecent(BC_FileBox *filebox, int x, int y)
00023 : BC_ListBox(x,
00024 y,
00025 250,
00026 filebox->get_text_height(MEDIUMFONT) * FILEBOX_HISTORY_SIZE +
00027 BC_ScrollBar::get_span(SCROLL_HORIZ) +
00028 LISTBOX_MARGIN * 2,
00029 LISTBOX_TEXT,
00030 &filebox->recent_dirs,
00031 0,
00032 0,
00033 1,
00034 0,
00035 1)
00036 {
00037 this->filebox = filebox;
00038 }
00039
00040 int BC_FileBoxRecent::handle_event()
00041 {
00042 if(get_selection(0, 0) >= 0)
00043 {
00044 filebox->submit_dir(get_selection(0, 0)->get_text());
00045 }
00046 return 1;
00047 }
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 BC_FileBoxListBox::BC_FileBoxListBox(int x, int y, BC_FileBox *filebox)
00060 : BC_ListBox(x,
00061 y,
00062 filebox->get_listbox_w(),
00063 filebox->get_listbox_h(y),
00064 filebox->get_display_mode(),
00065 filebox->list_column,
00066 filebox->column_titles,
00067 filebox->column_width,
00068 filebox->columns,
00069 0,
00070 0,
00071 filebox->select_multiple ? LISTBOX_MULTIPLE : LISTBOX_SINGLE,
00072 ICON_LEFT,
00073 0)
00074 {
00075 this->filebox = filebox;
00076 set_sort_column(filebox->sort_column);
00077 set_sort_order(filebox->sort_order);
00078 set_allow_drag_column(1);
00079 }
00080
00081 BC_FileBoxListBox::~BC_FileBoxListBox()
00082 {
00083 }
00084
00085 int BC_FileBoxListBox::handle_event()
00086 {
00087 filebox->submit_file(filebox->textbox->get_text());
00088 return 1;
00089 }
00090
00091 int BC_FileBoxListBox::selection_changed()
00092 {
00093 BC_ListBoxItem *item = get_selection(
00094 filebox->column_of_type(FILEBOX_NAME), 0);
00095
00096 if(item)
00097 {
00098 char path[BCTEXTLEN];
00099 strcpy(path, item->get_text());
00100 filebox->textbox->update(path);
00101 filebox->fs->extract_dir(filebox->directory, path);
00102 filebox->fs->extract_name(filebox->filename, path);
00103 filebox->fs->complete_path(path);
00104 strcpy(filebox->current_path, path);
00105 strcpy(filebox->submitted_path, path);
00106 }
00107 return 1;
00108 }
00109
00110 int BC_FileBoxListBox::column_resize_event()
00111 {
00112 for(int i = 0; i < filebox->columns; i++)
00113 BC_WindowBase::get_resources()->filebox_columnwidth[i] =
00114 filebox->column_width[i] =
00115 get_column_width(i);
00116 return 1;
00117 }
00118
00119 int BC_FileBoxListBox::sort_order_event()
00120 {
00121 get_resources()->filebox_sortcolumn = filebox->sort_column = get_sort_column();
00122 get_resources()->filebox_sortorder = filebox->sort_order = get_sort_order();
00123 filebox->refresh();
00124 return 1;
00125 }
00126
00127 int BC_FileBoxListBox::move_column_event()
00128 {
00129 filebox->move_column(get_from_column(), get_to_column());
00130 return 1;
00131 }
00132
00133 int BC_FileBoxListBox::evaluate_query(int list_item, char *string)
00134 {
00135 ArrayList<BC_ListBoxItem*> *column =
00136 &filebox->list_column[filebox->column_of_type(FILEBOX_NAME)];
00137 return(column->values[list_item]->get_color() != get_resources()->directory_color &&
00138 strcmp(string, column->values[list_item]->get_text()) <= 0);
00139 }
00140
00141
00142
00143
00144 BC_FileBoxTextBox::BC_FileBoxTextBox(int x, int y, BC_FileBox *filebox)
00145 : BC_TextBox(x, y, filebox->get_w() - 50, 1, filebox->filename)
00146 {
00147 this->filebox = filebox;
00148 }
00149
00150 BC_FileBoxTextBox::~BC_FileBoxTextBox()
00151 {
00152 }
00153
00154 int BC_FileBoxTextBox::handle_event()
00155 {
00156
00157 return 1;
00158 }
00159
00160
00161
00162
00163 BC_FileBoxDirectoryText::BC_FileBoxDirectoryText(int x, int y, BC_FileBox *filebox)
00164 : BC_TextBox(x, y, filebox->get_w() - 40, 1, filebox->fs->get_current_dir())
00165 {
00166 this->filebox = filebox;
00167 }
00168
00169 int BC_FileBoxDirectoryText::handle_event()
00170 {
00171 char *path;
00172 path = get_text();
00173
00174 if(filebox->fs->is_dir(path))
00175 {
00176 filebox->fs->change_dir(path);
00177 filebox->refresh();
00178 update(strcat(filebox->fs->get_current_dir(),"/"));
00179 }
00180 return 0;
00181 }
00182
00183
00184
00185
00186
00187 BC_FileBoxFilterText::BC_FileBoxFilterText(int x, int y, BC_FileBox *filebox)
00188 : BC_TextBox(x, y, filebox->get_w() - 50, 1, filebox->get_resources()->filebox_filter)
00189 {
00190 this->filebox = filebox;
00191 }
00192
00193 int BC_FileBoxFilterText::handle_event()
00194 {
00195 filebox->update_filter(get_text());
00196 return 0;
00197 }
00198
00199
00200
00201
00202 BC_FileBoxFilterMenu::BC_FileBoxFilterMenu(int x, int y, BC_FileBox *filebox)
00203 : BC_ListBox(x,
00204 y,
00205 filebox->get_w() - 30,
00206 120,
00207 LISTBOX_TEXT,
00208 &filebox->filter_list,
00209 0,
00210 0,
00211 1,
00212 0,
00213 1)
00214 {
00215 this->filebox = filebox;
00216 set_tooltip(_("Change the filter"));
00217 }
00218
00219 int BC_FileBoxFilterMenu::handle_event()
00220 {
00221 filebox->filter_text->update(
00222 get_selection(filebox->column_of_type(FILEBOX_NAME), 0)->get_text());
00223 filebox->update_filter(
00224 get_selection(filebox->column_of_type(FILEBOX_NAME), 0)->get_text());
00225 return 0;
00226 }
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237 BC_FileBoxCancel::BC_FileBoxCancel(BC_FileBox *filebox)
00238 : BC_CancelButton(filebox)
00239 {
00240 this->filebox = filebox;
00241 set_tooltip(_("Cancel the operation"));
00242 }
00243
00244 BC_FileBoxCancel::~BC_FileBoxCancel()
00245 {
00246 }
00247
00248 int BC_FileBoxCancel::handle_event()
00249 {
00250
00251 filebox->newfolder_thread->interrupt();
00252 filebox->set_done(1);
00253 return 1;
00254 }
00255
00256
00257
00258
00259
00260
00261
00262 BC_FileBoxUseThis::BC_FileBoxUseThis(BC_FileBox *filebox)
00263 : BC_Button(filebox->get_w() / 2 -
00264 BC_WindowBase::get_resources()->usethis_button_images[0]->get_w() / 2,
00265 filebox->ok_button->get_y(),
00266 BC_WindowBase::get_resources()->usethis_button_images)
00267 {
00268 this->filebox = filebox;
00269 set_tooltip(_("Submit the directory"));
00270 }
00271
00272 BC_FileBoxUseThis::~BC_FileBoxUseThis()
00273 {
00274 }
00275
00276 int BC_FileBoxUseThis::handle_event()
00277 {
00278 filebox->submit_file(filebox->textbox->get_text(), 1);
00279 return 1;
00280 }
00281
00282
00283
00284
00285
00286 BC_FileBoxOK::BC_FileBoxOK(BC_FileBox *filebox)
00287 : BC_OKButton(filebox,
00288 !filebox->want_directory ?
00289 BC_WindowBase::get_resources()->ok_images :
00290 BC_WindowBase::get_resources()->filebox_descend_images)
00291 {
00292 this->filebox = filebox;
00293 if(filebox->want_directory)
00294 set_tooltip(_("Descend directory"));
00295 else
00296 set_tooltip(_("Submit the file"));
00297 }
00298
00299 BC_FileBoxOK::~BC_FileBoxOK()
00300 {
00301 }
00302
00303 int BC_FileBoxOK::handle_event()
00304 {
00305 filebox->submit_file(filebox->textbox->get_text());
00306 return 1;
00307 }
00308
00309
00310
00311
00312
00313
00314 BC_FileBoxText::BC_FileBoxText(int x, int y, BC_FileBox *filebox)
00315 : BC_Button(x, y, BC_WindowBase::get_resources()->filebox_text_images)
00316 {
00317 this->filebox = filebox;
00318 set_tooltip(_("Display text"));
00319 }
00320 int BC_FileBoxText::handle_event()
00321 {
00322 filebox->create_listbox(filebox->listbox->get_x(), filebox->listbox->get_y(), LISTBOX_TEXT);
00323 return 1;
00324 }
00325
00326
00327 BC_FileBoxIcons::BC_FileBoxIcons(int x, int y, BC_FileBox *filebox)
00328 : BC_Button(x, y, BC_WindowBase::get_resources()->filebox_icons_images)
00329 {
00330 this->filebox = filebox;
00331 set_tooltip(_("Display icons"));
00332 }
00333 int BC_FileBoxIcons::handle_event()
00334 {
00335 filebox->create_listbox(filebox->listbox->get_x(), filebox->listbox->get_y(), LISTBOX_ICONS);
00336 return 1;
00337 }
00338
00339
00340 BC_FileBoxNewfolder::BC_FileBoxNewfolder(int x, int y, BC_FileBox *filebox)
00341 : BC_Button(x, y, BC_WindowBase::get_resources()->filebox_newfolder_images)
00342 {
00343 this->filebox = filebox;
00344 set_tooltip(_("Create new folder"));
00345 }
00346 int BC_FileBoxNewfolder::handle_event()
00347 {
00348 filebox->newfolder_thread->start_new_folder();
00349 return 1;
00350 }
00351
00352 BC_FileBoxUpdir::BC_FileBoxUpdir(int x, int y, BC_FileBox *filebox)
00353 : BC_Button(x, y, BC_WindowBase::get_resources()->filebox_updir_images)
00354 {
00355 this->filebox = filebox;
00356 set_tooltip(_("Up a directory"));
00357 }
00358 int BC_FileBoxUpdir::handle_event()
00359 {
00360
00361 sprintf(string, _(".."));
00362 filebox->submit_file(string);
00363 return 1;
00364 }
00365
00366 BC_FileBoxDelete::BC_FileBoxDelete(int x, int y, BC_FileBox *filebox)
00367 : BC_Button(x, y, BC_WindowBase::get_resources()->filebox_delete_images)
00368 {
00369 this->filebox = filebox;
00370 set_tooltip(_("Delete files"));
00371 }
00372 int BC_FileBoxDelete::handle_event()
00373 {
00374 filebox->unlock_window();
00375 filebox->delete_thread->start();
00376 filebox->lock_window("BC_FileBoxDelete::handle_event");
00377 return 1;
00378 }
00379
00380 BC_FileBoxReload::BC_FileBoxReload(int x, int y, BC_FileBox *filebox)
00381 : BC_Button(x, y, BC_WindowBase::get_resources()->filebox_reload_images)
00382 {
00383 this->filebox = filebox;
00384 set_tooltip(_("Refresh"));
00385 }
00386 int BC_FileBoxReload::handle_event()
00387 {
00388 filebox->refresh();
00389 return 1;
00390 }
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401 BC_FileBox::BC_FileBox(int x,
00402 int y,
00403 char *init_path,
00404 char *title,
00405 char *caption,
00406 int show_all_files,
00407 int want_directory,
00408 int multiple_files,
00409 int h_padding)
00410 : BC_Window(title,
00411 x,
00412 y,
00413 BC_WindowBase::get_resources()->filebox_w,
00414 BC_WindowBase::get_resources()->filebox_h,
00415 10,
00416 10,
00417 1,
00418 0,
00419 1)
00420 {
00421 fs = new FileSystem;
00422
00423
00424
00425
00426
00427
00428
00429 {
00430 columns = FILEBOX_COLUMNS;
00431 }
00432
00433 list_column = new ArrayList<BC_ListBoxItem*>[columns];
00434 column_type = new int[columns];
00435 column_width = new int[columns];
00436
00437 filter_text = 0;
00438 filter_popup = 0;
00439 usethis_button = 0;
00440
00441 strcpy(this->caption, caption);
00442 strcpy(this->current_path, init_path);
00443 strcpy(this->submitted_path, init_path);
00444 select_multiple = multiple_files;
00445 this->want_directory = want_directory;
00446 if(show_all_files) fs->set_show_all();
00447 fs->complete_path(this->current_path);
00448 fs->complete_path(this->submitted_path);
00449 fs->extract_dir(directory, this->current_path);
00450 fs->extract_name(filename, this->current_path);
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465 {
00466 for(int i = 0; i < columns; i++)
00467 {
00468 column_type[i] = get_resources()->filebox_columntype[i];
00469 column_width[i] = get_resources()->filebox_columnwidth[i];
00470 column_titles[i] = BC_FileBox::columntype_to_text(column_type[i]);
00471 }
00472 sort_column = get_resources()->filebox_sortcolumn;
00473 sort_order = get_resources()->filebox_sortorder;
00474 }
00475
00476
00477
00478
00479 if(fs->update(directory))
00480 {
00481 sprintf(this->current_path, "~");
00482 fs->complete_path(this->current_path);
00483 fs->update(this->current_path);
00484 strcpy(directory, fs->get_current_dir());
00485 sprintf(filename, "");
00486 }
00487
00488
00489 if(h_padding == -1)
00490 {
00491 h_padding = BC_WindowBase::get_resources()->ok_images[0]->get_h() -
00492 20;
00493 }
00494 this->h_padding = h_padding;
00495 delete_thread = new BC_DeleteThread(this);
00496 }
00497
00498 BC_FileBox::~BC_FileBox()
00499 {
00500
00501 delete newfolder_thread;
00502 delete fs;
00503 delete_tables();
00504 for(int i = 0; i < TOTAL_ICONS; i++)
00505 delete icons[i];
00506 filter_list.remove_all_objects();
00507 delete [] list_column;
00508 delete [] column_type;
00509 delete [] column_width;
00510 delete delete_thread;
00511 recent_dirs.remove_all_objects();
00512 }
00513
00514 int BC_FileBox::create_objects()
00515 {
00516 int x = 10, y = 10;
00517 BC_Resources *resources = BC_WindowBase::get_resources();
00518 int directory_title_margin = MAX(20,
00519 resources->filebox_text_images[0]->get_h());
00520
00521
00522 create_history();
00523
00524
00525 if(!want_directory)
00526 {
00527 filter_list.append(new BC_ListBoxItem("*"));
00528 filter_list.append(new BC_ListBoxItem("[*.ifo][*.vob]"));
00529 filter_list.append(new BC_ListBoxItem("[*.mp2][*.mp3][*.wav]"));
00530 filter_list.append(new BC_ListBoxItem("[*.avi][*.mpg][*.m2v][*.m1v][*.mov]"));
00531 filter_list.append(new BC_ListBoxItem("heroine*"));
00532 filter_list.append(new BC_ListBoxItem("*.xml"));
00533 fs->set_filter(get_resources()->filebox_filter);
00534 }
00535
00536 fs->update(directory);
00537 create_icons();
00538 create_tables();
00539
00540 add_subwindow(ok_button = new BC_FileBoxOK(this));
00541 if(want_directory)
00542 add_subwindow(usethis_button = new BC_FileBoxUseThis(this));
00543 add_subwindow(cancel_button = new BC_FileBoxCancel(this));
00544
00545 add_subwindow(new BC_Title(x, y, caption));
00546
00547 x = get_w() - resources->filebox_icons_images[0]->get_w() - 10;
00548 add_subwindow(icon_button = new BC_FileBoxIcons(x, y, this));
00549 x -= resources->filebox_text_images[0]->get_w() + 5;
00550 add_subwindow(text_button = new BC_FileBoxText(x, y, this));
00551 x -= resources->filebox_newfolder_images[0]->get_w() + 5;
00552 add_subwindow(folder_button = new BC_FileBoxNewfolder(x, y, this));
00553 x -= resources->filebox_delete_images[0]->get_w() + 5;
00554 add_subwindow(delete_button = new BC_FileBoxDelete(x, y, this));
00555 x -= resources->filebox_reload_images[0]->get_w() + 5;
00556 add_subwindow(reload_button = new BC_FileBoxReload(x, y, this));
00557 x -= resources->filebox_updir_images[0]->get_w() + 5;
00558 add_subwindow(updir_button = new BC_FileBoxUpdir(x, y, this));
00559
00560 x = 10;
00561 y += directory_title_margin + 3;
00562
00563 add_subwindow(recent_popup = new BC_FileBoxRecent(this,
00564 x,
00565 y));
00566 add_subwindow(directory_title = new BC_FileBoxDirectoryText(x, y, this));
00567 directory_title->reposition_window(
00568 x,
00569 y,
00570 get_w() - recent_popup->get_w() - 20,
00571 1);
00572 recent_popup->reposition_window(
00573 x + directory_title->get_w(),
00574 y,
00575 directory_title->get_w(),
00576 200);
00577
00578 x = 10;
00579 y += directory_title->get_h() + 5;
00580 listbox = 0;
00581
00582 create_listbox(x, y, get_display_mode());
00583 y += listbox->get_h() + 10;
00584 add_subwindow(textbox = new BC_FileBoxTextBox(x, y, this));
00585 y += textbox->get_h() + 10;
00586
00587
00588 if(!want_directory)
00589 {
00590 add_subwindow(filter_text = new BC_FileBoxFilterText(x, y, this));
00591 add_subwindow(filter_popup =
00592 new BC_FileBoxFilterMenu(x + filter_text->get_w(), y, this));;
00593 }
00594
00595
00596 listbox->activate();
00597 newfolder_thread = new BC_NewFolderThread(this);
00598
00599 show_window();
00600 return 0;
00601 }
00602
00603 int BC_FileBox::get_listbox_w()
00604 {
00605 return get_w() - 20;
00606 }
00607
00608 int BC_FileBox::get_listbox_h(int y)
00609 {
00610 int result = get_h() -
00611 y -
00612 h_padding;
00613 if(want_directory)
00614 result -= BC_WindowBase::get_resources()->dirbox_margin;
00615 else
00616 result -= BC_WindowBase::get_resources()->filebox_margin;
00617
00618 return result;
00619 }
00620
00621 int BC_FileBox::create_icons()
00622 {
00623 for(int i = 0; i < TOTAL_ICONS; i++)
00624 {
00625 icons[i] = new BC_Pixmap(this,
00626 BC_WindowBase::get_resources()->type_to_icon[i],
00627 PIXMAP_ALPHA);
00628 }
00629 return 0;
00630 }
00631
00632 int BC_FileBox::resize_event(int w, int h)
00633 {
00634 draw_background(0, 0, w, h);
00635 flash();
00636
00637
00638
00639
00640
00641
00642 if(usethis_button)
00643 usethis_button->reposition_window(w / 2 - 50, h - (get_h() - usethis_button->get_y()));
00644
00645
00646 if(filter_popup) filter_popup->reposition_window(w - (get_w() - filter_popup->get_x()),
00647 h - (get_h() - filter_popup->get_y()),
00648 w - 30);
00649
00650
00651 if(filter_text) filter_text->reposition_window(filter_text->get_x(),
00652 h - (get_h() - filter_text->get_y()),
00653 w - (get_w() - filter_text->get_w()),
00654 1);
00655 directory_title->reposition_window(
00656 directory_title->get_x(),
00657 directory_title->get_y(),
00658 get_w() - recent_popup->get_w() - 20,
00659 1);
00660 recent_popup->reposition_window(
00661 directory_title->get_x() + directory_title->get_w(),
00662 directory_title->get_y(),
00663 directory_title->get_w() + recent_popup->get_w(),
00664 recent_popup->get_h());
00665 textbox->reposition_window(textbox->get_x(),
00666 h - (get_h() - textbox->get_y()),
00667 w - (get_w() - textbox->get_w()),
00668 1);
00669 listbox->reposition_window(listbox->get_x(),
00670 listbox->get_y(),
00671 w - (get_w() - listbox->get_w()),
00672 h - (get_h() - listbox->get_h()));
00673 icon_button->reposition_window(w - (get_w() - icon_button->get_x()),
00674 icon_button->get_y());
00675 text_button->reposition_window(w - (get_w() - text_button->get_x()),
00676 text_button->get_y());
00677 folder_button->reposition_window(w - (get_w() - folder_button->get_x()),
00678 folder_button->get_y());
00679 reload_button->reposition_window(w - (get_w() - reload_button->get_x()),
00680 reload_button->get_y());
00681 delete_button->reposition_window(w - (get_w() - delete_button->get_x()),
00682 delete_button->get_y());
00683 updir_button->reposition_window(w - (get_w() - updir_button->get_x()),
00684 updir_button->get_y());
00685 set_w(w);
00686 set_h(h);
00687 get_resources()->filebox_w = get_w();
00688 get_resources()->filebox_h = get_h();
00689 return 1;
00690 }
00691
00692 int BC_FileBox::keypress_event()
00693 {
00694 switch(get_keypress())
00695 {
00696 case 'w':
00697 if(ctrl_down()) set_done(1);
00698 return 1;
00699 break;
00700 }
00701 return 0;
00702 }
00703
00704 int BC_FileBox::close_event()
00705 {
00706 set_done(1);
00707 return 1;
00708 }
00709
00710 int BC_FileBox::handle_event()
00711 {
00712 return 0;
00713 }
00714
00715 int BC_FileBox::extract_extension(char *out, const char *in)
00716 {
00717 int i;
00718
00719 for(i = strlen(in)-1; i > 0 && in[i] != '.'; i--)
00720 {
00721 ;
00722 }
00723 if(in[i] == '.') {
00724 i++;
00725 strcpy(out, &in[i]);
00726 }
00727 else
00728 out[0] = '\0';
00729 return 0;
00730 }
00731
00732 int BC_FileBox::create_tables()
00733 {
00734 delete_tables();
00735 char string[BCTEXTLEN];
00736 BC_ListBoxItem *new_item;
00737
00738 fs->set_sort_order(sort_order);
00739 fs->set_sort_field(column_type[sort_column]);
00740
00741
00742 fs->update(0);
00743 for(int i = 0; i < fs->total_files(); i++)
00744 {
00745 FileItem *file_item = fs->get_entry(i);
00746 int is_dir = file_item->is_dir;
00747 BC_Pixmap* icon = get_icon(file_item->name, is_dir);
00748
00749
00750 new_item = new BC_ListBoxItem(file_item->name,
00751 icon,
00752 is_dir ? get_resources()->directory_color : get_resources()->file_color);
00753 if(is_dir) new_item->set_searchable(0);
00754 list_column[column_of_type(FILEBOX_NAME)].append(new_item);
00755
00756
00757
00758
00759 if(!is_dir)
00760 {
00761 sprintf(string, "%lld", file_item->size);
00762 new_item = new BC_ListBoxItem(string, get_resources()->file_color);
00763 }
00764 else
00765 {
00766 new_item = new BC_ListBoxItem("", get_resources()->directory_color);
00767 }
00768
00769 list_column[column_of_type(FILEBOX_SIZE)].append(new_item);
00770
00771
00772
00773 if(!is_dir || 1)
00774 {
00775 static char *month_text[13] =
00776 {
00777 "Null",
00778 "Jan",
00779 "Feb",
00780 "Mar",
00781 "Apr",
00782 "May",
00783 "Jun",
00784 "Jul",
00785 "Aug",
00786 "Sep",
00787 "Oct",
00788 "Nov",
00789 "Dec"
00790 };
00791 sprintf(string,
00792 "%s %d, %d",
00793 month_text[file_item->month],
00794 file_item->day,
00795 file_item->year);
00796 new_item = new BC_ListBoxItem(string, get_resources()->file_color);
00797 }
00798 else
00799 {
00800 new_item = new BC_ListBoxItem("", get_resources()->directory_color);
00801 }
00802
00803 list_column[column_of_type(FILEBOX_DATE)].append(new_item);
00804
00805
00806
00807
00808 if(!is_dir)
00809 {
00810 extract_extension(string, file_item->name);
00811 new_item = new BC_ListBoxItem(string, get_resources()->file_color);
00812 }
00813 else
00814 {
00815 new_item = new BC_ListBoxItem("", get_resources()->directory_color);
00816 }
00817 list_column[column_of_type(FILEBOX_EXTENSION)].append(new_item);
00818
00819 }
00820
00821 return 0;
00822 }
00823
00824 int BC_FileBox::delete_tables()
00825 {
00826 for(int j = 0; j < columns; j++)
00827 {
00828 list_column[j].remove_all_objects();
00829 }
00830 return 0;
00831 }
00832
00833 BC_Pixmap* BC_FileBox::get_icon(char *path, int is_dir)
00834 {
00835 char *suffix = strrchr(path, '.');
00836 int icon_type = ICON_UNKNOWN;
00837
00838 if(is_dir) return icons[ICON_FOLDER];
00839
00840 if(suffix)
00841 {
00842 suffix++;
00843 if(*suffix != 0)
00844 {
00845 for(int i = 0; i < TOTAL_SUFFIXES; i++)
00846 {
00847 if(!strcasecmp(suffix, BC_WindowBase::get_resources()->suffix_to_type[i].suffix))
00848 {
00849 icon_type = BC_WindowBase::get_resources()->suffix_to_type[i].icon_type;
00850 break;
00851 }
00852 }
00853 }
00854 }
00855
00856 return icons[icon_type];
00857 }
00858
00859 char* BC_FileBox::columntype_to_text(int type)
00860 {
00861 switch(type)
00862 {
00863 case FILEBOX_NAME:
00864 return FILEBOX_NAME_TEXT;
00865 break;
00866 case FILEBOX_SIZE:
00867 return FILEBOX_SIZE_TEXT;
00868 break;
00869 case FILEBOX_DATE:
00870 return FILEBOX_DATE_TEXT;
00871 break;
00872 case FILEBOX_EXTENSION:
00873 return FILEBOX_EXTENSION_TEXT;
00874 break;
00875 }
00876 return "";
00877 }
00878
00879 int BC_FileBox::column_of_type(int type)
00880 {
00881 for(int i = 0; i < columns; i++)
00882 if(column_type[i] == type) return i;
00883 return 0;
00884 }
00885
00886
00887
00888 int