#include <sys/stat.h>
-
-
-
-
-
BC_FileBoxRecent::BC_FileBoxRecent(BC_FileBox *filebox, int x, int y)
- : BC_ListBox(x, y, 250,
+ : BC_ListBox(x, y, xS(250),
filebox->get_text_height(MEDIUMFONT) * FILEBOX_HISTORY_SIZE +
BC_ScrollBar::get_span(SCROLL_HORIZ) +
LISTBOX_MARGIN * 2, LISTBOX_TEXT, &filebox->recent_dirs,
}
-
-
-
-
-
-
-
-
-
BC_FileBoxListBox::BC_FileBoxListBox(int x, int y, BC_FileBox *filebox)
: BC_ListBox(x, y, filebox->get_listbox_w(), filebox->get_listbox_h(y),
filebox->get_display_mode(), filebox->list_column,
filebox->column_of_type(FILEBOX_NAME), 0);
if(item) {
- char path[BCTEXTLEN];
- strcpy(path, item->get_text());
- filebox->textbox->update(path);
- filebox->fs->extract_dir(filebox->directory, path);
- filebox->fs->extract_name(filebox->filename, path);
- filebox->fs->complete_path(path);
- strcpy(filebox->current_path, path);
- strcpy(filebox->submitted_path, path);
+ filebox->textbox->update(item->get_text());
+ filebox->update_paths(item->get_text());
}
return 1;
}
BC_FileBoxTextBox::BC_FileBoxTextBox(int x, int y, BC_FileBox *filebox)
- : BC_TextBox(x, y, filebox->get_w() - x - 20, 1,
+ : BC_TextBox(x, y, filebox->get_w() - x - xS(20), 1,
filebox->want_directory ? filebox->directory : filebox->filename)
{
this->filebox = filebox;
int BC_FileBoxTextBox::handle_event()
{
- int result = 0;
- if(get_keypress() != RETURN)
- {
+ int key = get_keypress(), result = 1;
+ if( !key || key == RETURN ) // not a text update
+ filebox->update_paths(filebox->textbox->get_text());
+ else
result = calculate_suggestions(&filebox->list_column[0]);
- }
return result;
}
BC_FileBoxSearchText::BC_FileBoxSearchText(int x, int y, BC_FileBox *filebox)
- : BC_TextBox(x, y, filebox->get_w() - x - 40, 1, "")
+ : BC_TextBox(x, y, filebox->get_w() - x - xS(40), 1, "")
{
this->filebox = filebox;
}
BC_FileBoxFilterText::BC_FileBoxFilterText(int x, int y, BC_FileBox *filebox)
- : BC_TextBox(x, y, filebox->get_w() - x - 50, 1, filebox->get_resources()->filebox_filter)
+ : BC_TextBox(x, y, filebox->get_w() - x - xS(50), 1, filebox->get_resources()->filebox_filter)
{
this->filebox = filebox;
}
BC_FileBoxFilterMenu::BC_FileBoxFilterMenu(int x, int y, BC_FileBox *filebox)
- : BC_ListBox(x, y, filebox->get_w() - 30, 120,
+ : BC_ListBox(x, y, filebox->get_w() - xS(30), yS(120),
LISTBOX_TEXT, &filebox->filter_list, 0, 0, 1, 0, 1)
{
this->filebox = filebox;
: BC_Window(title, x, y,
BC_WindowBase::get_resources()->filebox_w,
BC_WindowBase::get_resources()->filebox_h,
- 400, 300, 1, 0, 1)
+ xS(450), yS(350), 1, 0, 1)
{
fs = new FileSystem;
// if(want_directory)
if(h_padding == -1)
{
- h_padding = BC_WindowBase::get_resources()->ok_images[0]->get_h() -
- 20;
+ h_padding = BC_WindowBase::get_resources()->ok_images[0]->get_h() - yS(20);
}
this->h_padding = h_padding;
delete_thread = new BC_DeleteThread(this);
void BC_FileBox::create_objects()
{
+ int xs5 = xS(5), xs10 = xS(10), xs20 = xS(20);
+ int ys5 = yS(5), ys10 = yS(10);
lock_window("BC_FileBox::create_objects");
- int x = 10, y = 10;
+ int x = xs10, y = ys10;
BC_Resources *resources = BC_WindowBase::get_resources();
- int directory_title_margin = MAX(20,
+ int directory_title_margin = MAX(xs20,
resources->filebox_text_images[0]->get_h());
// Directories aren't filtered in FileSystem so skip this
add_subwindow(new BC_Title(x, y, caption));
- x = get_w() - resources->filebox_icons_images[0]->get_w() - 10;
+ x = get_w() - resources->filebox_icons_images[0]->get_w() - xs10;
add_subwindow(icon_button = new BC_FileBoxIcons(x, y, this));
- x -= resources->filebox_text_images[0]->get_w() + 5;
+ x -= resources->filebox_text_images[0]->get_w() + xs5;
add_subwindow(text_button = new BC_FileBoxText(x, y, this));
- x -= resources->filebox_newfolder_images[0]->get_w() + 5;
+ x -= resources->filebox_newfolder_images[0]->get_w() + xs5;
add_subwindow(folder_button = new BC_FileBoxNewfolder(x, y, this));
- x -= resources->filebox_delete_images[0]->get_w() + 5;
+ x -= resources->filebox_delete_images[0]->get_w() + xs5;
add_subwindow(rename_button = new BC_FileBoxRename(x, y, this));
- x -= resources->filebox_delete_images[0]->get_w() + 5;
+ x -= resources->filebox_delete_images[0]->get_w() + xs5;
add_subwindow(delete_button = new BC_FileBoxDelete(x, y, this));
- x -= resources->filebox_reload_images[0]->get_w() + 5;
+ x -= resources->filebox_reload_images[0]->get_w() + xs5;
add_subwindow(reload_button = new BC_FileBoxReload(x, y, this));
- x -= resources->filebox_updir_images[0]->get_w() + 5;
+ x -= resources->filebox_updir_images[0]->get_w() + xs5;
add_subwindow(updir_button = new BC_FileBoxUpdir(x, y, this));
- x -= resources->filebox_szfmt_images[0]->get_w() + 5;
+ x -= resources->filebox_szfmt_images[0]->get_w() + xs5;
add_subwindow(szfmt_button = new BC_FileBoxSizeFormat(x, y, this));
- x = 10;
- y += directory_title_margin + 3;
+ x = xs10;
+ y += directory_title_margin + yS(3);
add_subwindow(recent_popup = new BC_FileBoxRecent(this, x, y));
BC_Title *dir_title;
add_subwindow(dir_title = new BC_Title(x, y, _("Directory:")));
- int x1 = x + dir_title->get_w() + 10, w1 = get_w()-x1 - recent_popup->get_w()-20;
+ int x1 = x + dir_title->get_w() + xs10, w1 = get_w()-x1 - recent_popup->get_w()-xs20;
add_subwindow(directory_title = new BC_FileBoxDirectoryText(x1, y, w1, this));
- x1 += directory_title->get_w() + 8;
- recent_popup->reposition_window(x1, y, directory_title->get_w(), 200);
+ x1 += directory_title->get_w() + xS(8);
+ recent_popup->reposition_window(x1, y, directory_title->get_w(), yS(200));
- x = 10;
- y += directory_title->get_h() + 5;
+ x = xs10;
+ y += directory_title->get_h() + ys5;
BC_Title *search_title;
add_subwindow(search_title = new BC_Title(x, y, _("Search:")));
- x += search_title->get_w() + 10;
+ x += search_title->get_w() + xs10;
add_subwindow(search_text = new BC_FileBoxSearchText(x, y, this));
- x = 10;
- y += search_text->get_h() + 5;
+ x = xs10;
+ y += search_text->get_h() + ys5;
int newest_id = 0, newest = -1;
for(int i = 0; i < FILEBOX_HISTORY_SIZE; i++) {
listbox = 0;
create_listbox(x, y, get_display_mode());
- y += listbox->get_h() + 10;
+ y += listbox->get_h() + ys10;
add_subwindow(file_title = new BC_Title(x, y, _("File:")));
- x1 = x + file_title->get_w() + 10;
+ x1 = x + file_title->get_w() + xs10;
add_subwindow(textbox = new BC_FileBoxTextBox(x1, y, this));
- y += textbox->get_h() + 10;
+ y += textbox->get_h() + ys10;
if(!want_directory) {
add_subwindow(filter_title = new BC_Title(x, y, _("Specify filter:")));
- int x1 = x + filter_title->get_w() + 10;
+ int x1 = x + filter_title->get_w() + xs10;
add_subwindow(filter_text = new BC_FileBoxFilterText(x1, y, this));
add_subwindow(filter_popup =
new BC_FileBoxFilterMenu(x1 + filter_text->get_w(), y, this));
- y += filter_text->get_h() + 10;
+ y += filter_text->get_h() + ys10;
}
y_margin = y;
int BC_FileBox::get_listbox_w()
{
- return get_w() - 20;
+ return get_w() - xS(20);
}
int BC_FileBox::get_listbox_h(int y)
{
- int result = get_h() - y - h_padding - 10;
+ int result = get_h() - y - h_padding - yS(10);
if(want_directory)
result -= BC_WindowBase::get_resources()->dirbox_margin;
else
{
draw_background(0, 0, w, h);
flash(0);
+ int dw = w - get_w();
+ int dh = h - get_h();
// OK button handles resize event itself
// ok_button->reposition_window(ok_button->get_x(),
-// h - (get_h() - ok_button->get_y()));
-// cancel_button->reposition_window(w - (get_w() - cancel_button->get_x()),
-// h - (get_h() - cancel_button->get_y()));
+// ok_button->get_y() + dh);
+// cancel_button->reposition_window(cancel_button->get_x() + dw,
+// cancel_button->get_y() + dh);
if(usethis_button)
- usethis_button->reposition_window(w / 2 - 50,
- h - (get_h() - usethis_button->get_y()));
+ usethis_button->reposition_window(w / 2 - xS(50),
+ usethis_button->get_y() + dh);
- if(filter_popup) filter_popup->reposition_window(w - (get_w() - filter_popup->get_x()),
- h - (get_h() - filter_popup->get_y()),
- w - 30,
- 0);
+ if(filter_popup)
+ filter_popup->reposition_window(filter_popup->get_x() + dw,
+ filter_popup->get_y() + dh, w - xS(30), 0);
- if(filter_title) filter_title->reposition_window(filter_title->get_x(),
- h - (get_h() - filter_title->get_y()));
+ if(filter_title)
+ filter_title->reposition_window(filter_title->get_x(),
+ filter_title->get_y() + dh);
if(filter_text) filter_text->reposition_window(filter_text->get_x(),
- h - (get_h() - filter_text->get_y()),
- w - (get_w() - filter_text->get_w()),
- 1);
+ filter_text->get_y() + dh, filter_text->get_w() + dw, 1);
directory_title->reposition_window(
directory_title->get_x(), directory_title->get_y(),
- get_w()-directory_title->get_x() - recent_popup->get_w()-20, 1);
+ get_w()-directory_title->get_x() - recent_popup->get_w()-xS(20), 1);
recent_popup->reposition_window(
- directory_title->get_x() + directory_title->get_w() + 8,
+ directory_title->get_x() + directory_title->get_w() + xS(8),
directory_title->get_y(),
- directory_title->get_w() + recent_popup->get_w(), 200);
+ directory_title->get_w() + recent_popup->get_w(), xS(200));
search_text->reposition_window(
- search_text->get_x(),
- search_text->get_y(),
- get_w() - search_text->get_x() - 40,
- 1);
+ search_text->get_x(), search_text->get_y(),
+ get_w() - search_text->get_x() - xS(40), 1);
file_title->reposition_window(file_title->get_x(),
- h - (get_h() - file_title->get_y()));
+ file_title->get_y() + dh);
textbox->reposition_window(textbox->get_x(),
- h - (get_h() - textbox->get_y()),
- w - (get_w() - textbox->get_w()),
- 1);
- listbox->reposition_window(listbox->get_x(),
- listbox->get_y(),
- w - (get_w() - listbox->get_w()),
- h - (get_h() - listbox->get_h()),
- 0);
- int dx = w - get_w();
- icon_button->reposition_window(icon_button->get_x()+dx, icon_button->get_y());
- text_button->reposition_window(text_button->get_x()+dx, text_button->get_y());
- folder_button->reposition_window(folder_button->get_x()+dx, folder_button->get_y());
- rename_button->reposition_window(rename_button->get_x()+dx, rename_button->get_y());
- reload_button->reposition_window(reload_button->get_x()+dx, reload_button->get_y());
- delete_button->reposition_window(delete_button->get_x()+dx, delete_button->get_y());
- updir_button->reposition_window(updir_button->get_x()+dx, updir_button->get_y());
- szfmt_button->reposition_window(szfmt_button->get_x()+dx, szfmt_button->get_y());
+ textbox->get_y() + dh, textbox->get_w() + dw, 1);
+ listbox->reposition_window(listbox->get_x(), listbox->get_y(),
+ listbox->get_w() + dw, listbox->get_h() + dh, 0);
+ icon_button->reposition_window(icon_button->get_x()+dw, icon_button->get_y());
+ text_button->reposition_window(text_button->get_x()+dw, text_button->get_y());
+ folder_button->reposition_window(folder_button->get_x()+dw, folder_button->get_y());
+ rename_button->reposition_window(rename_button->get_x()+dw, rename_button->get_y());
+ reload_button->reposition_window(reload_button->get_x()+dw, reload_button->get_y());
+ delete_button->reposition_window(delete_button->get_x()+dw, delete_button->get_y());
+ updir_button->reposition_window(updir_button->get_x()+dw, updir_button->get_y());
+ szfmt_button->reposition_window(szfmt_button->get_x()+dw, szfmt_button->get_y());
set_w(w); set_h(h);
get_resources()->filebox_w = get_w();
get_resources()->filebox_h = get_h();
y_margin = filter_text ?
- filter_text->get_y() + filter_text->get_h() + 10 :
- textbox->get_y() + textbox->get_h() + 10 ;
+ filter_text->get_y() + filter_text->get_h() + yS(10) :
+ textbox->get_y() + textbox->get_h() + yS(10) ;
flush();
return 1;
}
}
+void BC_FileBox::update_paths(const char *text)
+{
+ char path[BCTEXTLEN];
+ strncpy(path, text, sizeof(path)-1);
+ fs->extract_dir(directory, path);
+ fs->extract_name(filename, path);
+ fs->complete_path(path);
+ strcpy(current_path, path);
+ strcpy(submitted_path, path);
+}
+
void BC_FileBox::move_column(int src, int dst)
{
if(src != dst)
char* BC_FileBox::get_path(int selection)
{
if(selection == 0)
- {
return get_submitted_path();
- }
- else
- {
- BC_ListBoxItem *item = listbox->get_selection(
- column_of_type(FILEBOX_NAME), selection - 1);
- if(item)
- {
- fs->join_names(string, directory, item->get_text());
- return string;
- }
+ BC_ListBoxItem *item = listbox->get_selection(
+ column_of_type(FILEBOX_NAME), selection - 1);
+ if( item ) {
+ fs->join_names(string, directory, item->get_text());
+ return string;
}
return 0;
}
char* BC_FileBox::get_submitted_path()
{
+ update_paths(textbox->get_text());
return submitted_path;
}