From: Good Guy Date: Sat, 21 Oct 2017 17:49:04 +0000 (-0600) Subject: clean up bclistbox, listbox shift drag fix, plugin info X-Git-Url: https://git.cinelerra-gg.org/git/?a=commitdiff_plain;h=55ccff122957ddfaa871cf8f251cfe866732c870;p=goodguy%2Fhistory.git clean up bclistbox, listbox shift drag fix, plugin info --- diff --git a/cinelerra-5.1/cinelerra/assetedit.C b/cinelerra-5.1/cinelerra/assetedit.C index 7275070e..51fa34fa 100644 --- a/cinelerra-5.1/cinelerra/assetedit.C +++ b/cinelerra-5.1/cinelerra/assetedit.C @@ -561,7 +561,7 @@ void AssetEditWindow::create_objects() void AssetEditWindow::show_info_detail() { int cur_x, cur_y; - get_abs_cursor_xy(cur_x, cur_y, 0); + get_abs_cursor(cur_x, cur_y, 0); detail_dialog->start((Asset*)asset_edit->indexable, cur_x, cur_y); } diff --git a/cinelerra-5.1/cinelerra/assetpopup.C b/cinelerra-5.1/cinelerra/assetpopup.C index 75c1bfa2..24304c72 100644 --- a/cinelerra-5.1/cinelerra/assetpopup.C +++ b/cinelerra-5.1/cinelerra/assetpopup.C @@ -145,7 +145,7 @@ AssetPopupInfo::~AssetPopupInfo() int AssetPopupInfo::handle_event() { int cur_x, cur_y; - popup->gui->get_abs_cursor_xy(cur_x, cur_y); + popup->gui->get_abs_cursor(cur_x, cur_y); if( mwindow->session->drag_assets->size() ) { AssetEdit *asset_edit = mwindow->awindow->get_asset_editor(); asset_edit->edit_asset( @@ -413,7 +413,7 @@ int AssetListCopy::handle_event() } *cp = 0; int cur_x, cur_y; - gui->get_abs_cursor_xy(cur_x, cur_y, 0); + gui->get_abs_cursor(cur_x, cur_y, 0); gui->unlock_window(); if( n ) { @@ -527,7 +527,7 @@ int AssetListPaste::handle_event() else paste_dialog->close_window(); int cur_x, cur_y; - gui->get_abs_cursor_xy(cur_x, cur_y, 0); + gui->get_abs_cursor(cur_x, cur_y, 0); paste_dialog->start(cur_x, cur_y); return 1; } diff --git a/cinelerra-5.1/cinelerra/awindowgui.C b/cinelerra-5.1/cinelerra/awindowgui.C index 7b717fee..e64adff9 100644 --- a/cinelerra-5.1/cinelerra/awindowgui.C +++ b/cinelerra-5.1/cinelerra/awindowgui.C @@ -1844,7 +1844,7 @@ int AWindowDeleteProject::handle_event() // int AWindowInfo::handle_event() // { // int cur_x, cur_y; -// gui->get_abs_cursor_xy(cur_x, cur_y, 0); +// gui->get_abs_cursor(cur_x, cur_y, 0); // gui->awindow->asset_edit->edit_asset(gui->selected_asset(), cur_x, cur_y); // return 1; // } diff --git a/cinelerra-5.1/cinelerra/clippopup.C b/cinelerra-5.1/cinelerra/clippopup.C index 2f9df23c..0eeee34e 100644 --- a/cinelerra-5.1/cinelerra/clippopup.C +++ b/cinelerra-5.1/cinelerra/clippopup.C @@ -138,7 +138,7 @@ ClipPopupInfo::~ClipPopupInfo() int ClipPopupInfo::handle_event() { int cur_x, cur_y; - popup->gui->get_abs_cursor_xy(cur_x, cur_y, 0); + popup->gui->get_abs_cursor(cur_x, cur_y, 0); if( mwindow->session->drag_assets->total ) { AssetEdit *asset_edit = mwindow->awindow->get_asset_editor(); diff --git a/cinelerra-5.1/cinelerra/colorpicker.C b/cinelerra-5.1/cinelerra/colorpicker.C index 924d989b..a99896dd 100644 --- a/cinelerra-5.1/cinelerra/colorpicker.C +++ b/cinelerra-5.1/cinelerra/colorpicker.C @@ -313,7 +313,7 @@ int ColorWindow::handle_event() void ColorWindow::get_screen_sample() { int cx, cy; - get_abs_cursor_xy(cx, cy); + get_abs_cursor(cx, cy); BC_Capture capture_bitmap(1, 1, 0); VFrame vframe(1,1,BC_RGB888); capture_bitmap.capture_frame(&vframe, cx,cy); diff --git a/cinelerra-5.1/cinelerra/effectlist.C b/cinelerra-5.1/cinelerra/effectlist.C index 11354a06..bc7e5e3f 100644 --- a/cinelerra-5.1/cinelerra/effectlist.C +++ b/cinelerra-5.1/cinelerra/effectlist.C @@ -111,7 +111,7 @@ int EffectTipItem::handle_event() const char *info = result->plugin->tip; if( !info ) info = _("No info available"); int cur_x, cur_y; - gui->get_abs_cursor_xy(cur_x, cur_y, 0); + gui->get_abs_cursor(cur_x, cur_y, 0); gui->awindow->effect_tip->start(cur_x, cur_y, result->plugin->title, info); } diff --git a/cinelerra-5.1/cinelerra/labelpopup.C b/cinelerra-5.1/cinelerra/labelpopup.C index 65128cf7..ab63a226 100644 --- a/cinelerra-5.1/cinelerra/labelpopup.C +++ b/cinelerra-5.1/cinelerra/labelpopup.C @@ -77,7 +77,7 @@ int LabelPopupEdit::handle_event() AssetPicon *result = (AssetPicon*)gui->asset_list->get_selection(0,0); if( result && result->label ) { int cur_x, cur_y; - gui->get_abs_cursor_xy(cur_x, cur_y, 0); + gui->get_abs_cursor(cur_x, cur_y, 0); gui->awindow->label_edit->start(result->label, cur_x, cur_y); } return 1; diff --git a/cinelerra-5.1/cinelerra/mwindowedit.C b/cinelerra-5.1/cinelerra/mwindowedit.C index 4e1c5c74..a149b275 100644 --- a/cinelerra-5.1/cinelerra/mwindowedit.C +++ b/cinelerra-5.1/cinelerra/mwindowedit.C @@ -2074,7 +2074,7 @@ void MWindow::save_clip(EDL *new_edl, const char *txt) edl->update_assets(new_edl); int cur_x, cur_y; - gui->get_abs_cursor_xy(cur_x, cur_y, 0); + gui->get_abs_cursor(cur_x, cur_y, 0); gui->unlock_window(); awindow->clip_edit->create_clip(new_edl, cur_x, cur_y); diff --git a/cinelerra-5.1/cinelerra/proxy.C b/cinelerra-5.1/cinelerra/proxy.C index 7f729f37..4774ecde 100644 --- a/cinelerra-5.1/cinelerra/proxy.C +++ b/cinelerra-5.1/cinelerra/proxy.C @@ -99,7 +99,7 @@ BC_Window* ProxyDialog::new_gui() asset->load_defaults(mwindow->defaults, "PROXY_", 1, 1, 0, 0, 0); mwindow->gui->lock_window("ProxyDialog::new_gui"); int cx, cy; - mwindow->gui->get_abs_cursor_xy(cx, cy); + mwindow->gui->get_abs_cursor(cx, cy); gui = new ProxyWindow(mwindow, this, cx - WIDTH/2, cy - HEIGHT/2); gui->create_objects(); mwindow->gui->unlock_window(); diff --git a/cinelerra-5.1/cinelerra/render.C b/cinelerra-5.1/cinelerra/render.C index 702ffbd4..433876bb 100644 --- a/cinelerra-5.1/cinelerra/render.C +++ b/cinelerra-5.1/cinelerra/render.C @@ -271,7 +271,7 @@ void Render::start_interactive() } else if( in_progress ) { int cx, cy; - mwindow->gui->get_abs_cursor_xy(cx, cy, 1); + mwindow->gui->get_abs_cursor(cx, cy, 1); ErrorBox error_box(_(PROGRAM_NAME ": Error"), cx, cy); error_box.create_objects(_("Already rendering")); error_box.raise_window(); @@ -295,7 +295,7 @@ void Render::start_batches(ArrayList *jobs) } else if( in_progress ) { int cx, cy; - mwindow->gui->get_abs_cursor_xy(cx, cy, 1); + mwindow->gui->get_abs_cursor(cx, cy, 1); ErrorBox error_box(_(PROGRAM_NAME ": Error"), cx, cy); error_box.create_objects("Already rendering"); error_box.raise_window(); @@ -394,7 +394,7 @@ void Render::handle_close_event(int result) } if( err_msg ) { int cx, cy; - mwindow->gui->get_abs_cursor_xy(cx, cy, 1); + mwindow->gui->get_abs_cursor(cx, cy, 1); ErrorBox error_box(_(PROGRAM_NAME ": Error"),cx, cy); error_box.create_objects(err_msg); error_box.raise_window(); @@ -930,7 +930,7 @@ if(debug) printf("Render::render %d\n", __LINE__); { if(debug) printf("Render::render %d\n", __LINE__); int cx, cy; - mwindow->gui->get_abs_cursor_xy(cx, cy, 1); + mwindow->gui->get_abs_cursor(cx, cy, 1); ErrorBox error_box(_(PROGRAM_NAME ": Error"), cx, cy); error_box.create_objects(_("Error rendering data.")); error_box.raise_window(); diff --git a/cinelerra-5.1/cinelerra/timebar.C b/cinelerra-5.1/cinelerra/timebar.C index 5325a264..d33d4ea3 100644 --- a/cinelerra-5.1/cinelerra/timebar.C +++ b/cinelerra-5.1/cinelerra/timebar.C @@ -97,7 +97,7 @@ int LabelGUI::button_press_event() if( this->is_event_win() && get_buttonpress() == 3 ) { if( label ) { int cur_x, cur_y; - get_abs_cursor_xy(cur_x, cur_y, 0); + get_abs_cursor(cur_x, cur_y, 0); timebar->label_edit->start(label, cur_x, cur_y); } result = 1; diff --git a/cinelerra-5.1/cinelerra/trackcanvas.C b/cinelerra-5.1/cinelerra/trackcanvas.C index 0e3ebc03..5d925e6e 100644 --- a/cinelerra-5.1/cinelerra/trackcanvas.C +++ b/cinelerra-5.1/cinelerra/trackcanvas.C @@ -4508,7 +4508,7 @@ int TrackCanvas::do_edits(int cursor_x, int cursor_y, int button_press, int drag mwindow->edl->session->sample_rate; int cx, cy; - get_abs_cursor_xy(cx, cy); + get_abs_cursor(cx, cy); cx -= mwindow->theme->get_image("clip_icon")->get_w() / 2, cy -= mwindow->theme->get_image("clip_icon")->get_h() / 2; gui->drag_popup = new BC_DragWindow(gui, @@ -4622,7 +4622,7 @@ int TrackCanvas::do_plugins(int cursor_x, int cursor_y, int drag_start, } } int cx, cy; - get_abs_cursor_xy(cx, cy); + get_abs_cursor(cx, cy); cx -= frame->get_w() / 2; cy -= frame->get_h() / 2; gui->drag_popup = new BC_DragWindow(gui, frame, cx, cy); @@ -4632,7 +4632,7 @@ int TrackCanvas::do_plugins(int cursor_x, int cursor_y, int drag_start, case PLUGIN_SHAREDMODULE: { VFrame *frame = mwindow->theme->get_image("clip_icon"); int cx, cy; - get_abs_cursor_xy(cx, cy); + get_abs_cursor(cx, cy); cx -= frame->get_w() / 2; cy -= frame->get_h() / 2; gui->drag_popup = new BC_DragWindow(gui, frame, cx, cy); diff --git a/cinelerra-5.1/guicast/bcdragwindow.C b/cinelerra-5.1/guicast/bcdragwindow.C index 355315bc..795b6d65 100644 --- a/cinelerra-5.1/guicast/bcdragwindow.C +++ b/cinelerra-5.1/guicast/bcdragwindow.C @@ -85,7 +85,7 @@ int BC_DragWindow::get_init_y(BC_WindowBase *parent_window, int icon_y) int BC_DragWindow::cursor_motion_event() { int cx, cy; - get_abs_cursor_xy(cx, cy); + get_abs_cursor(cx, cy); reposition_window(cx + icon_offset_x, cy + icon_offset_y, get_w(), get_h()); flush(); return 1; diff --git a/cinelerra-5.1/guicast/bclistbox.C b/cinelerra-5.1/guicast/bclistbox.C index fb57b17d..0285fd39 100644 --- a/cinelerra-5.1/guicast/bclistbox.C +++ b/cinelerra-5.1/guicast/bclistbox.C @@ -85,7 +85,7 @@ BC_ListBoxToggle::BC_ListBoxToggle(BC_ListBox *listbox, this->x = x; this->y = y; this->value = item->get_expand(); - if(this->value) + if( this->value ) state = BC_Toggle::TOGGLE_CHECKED; else state = BC_Toggle::TOGGLE_UP; @@ -102,33 +102,32 @@ void BC_ListBoxToggle::update(BC_ListBoxItem *item, this->y = y; // update state - switch(state) - { - case TOGGLE_UP: - if(value) - state = TOGGLE_CHECKED; - break; + switch( state ) { + case TOGGLE_UP: + if( value ) + state = TOGGLE_CHECKED; + break; - case TOGGLE_UPHI: - if(value) - state = TOGGLE_CHECKEDHI; - break; + case TOGGLE_UPHI: + if( value ) + state = TOGGLE_CHECKEDHI; + break; - case TOGGLE_CHECKED: - if(!value) - state = TOGGLE_UP; - break; + case TOGGLE_CHECKED: + if( !value ) + state = TOGGLE_UP; + break; - case TOGGLE_DOWN: - break; + case TOGGLE_DOWN: + break; - case TOGGLE_CHECKEDHI: - if(!value) - state = TOGGLE_UPHI; - break; + case TOGGLE_CHECKEDHI: + if( !value ) + state = TOGGLE_UPHI; + break; - case TOGGLE_DOWN_EXIT: - break; + case TOGGLE_DOWN_EXIT: + break; } @@ -145,59 +144,53 @@ int BC_ListBoxToggle::cursor_motion_event(int *redraw_toggles) listbox->get_cursor_y() < y + h; int result = 0; - switch(state) - { - case BC_ListBoxToggle::TOGGLE_UPHI: - if(!cursor_inside) - { - state = BC_ListBoxToggle::TOGGLE_UP; - *redraw_toggles = 1; - } - break; + switch( state ) { + case BC_ListBoxToggle::TOGGLE_UPHI: + if( !cursor_inside ) { + state = BC_ListBoxToggle::TOGGLE_UP; + *redraw_toggles = 1; + } + break; - case BC_ListBoxToggle::TOGGLE_CHECKEDHI: - if(!cursor_inside) - { - state = BC_ListBoxToggle::TOGGLE_CHECKED; - *redraw_toggles = 1; - } - break; + case BC_ListBoxToggle::TOGGLE_CHECKEDHI: + if( !cursor_inside ) { + state = BC_ListBoxToggle::TOGGLE_CHECKED; + *redraw_toggles = 1; + } + break; - case BC_ListBoxToggle::TOGGLE_DOWN: - if(!cursor_inside) - { - state = BC_ListBoxToggle::TOGGLE_DOWN_EXIT; - *redraw_toggles = 1; - } - result = 1; - break; + case BC_ListBoxToggle::TOGGLE_DOWN: + if( !cursor_inside ) { + state = BC_ListBoxToggle::TOGGLE_DOWN_EXIT; + *redraw_toggles = 1; + } + result = 1; + break; - case BC_ListBoxToggle::TOGGLE_DOWN_EXIT: - if(cursor_inside) - { - state = BC_ListBoxToggle::TOGGLE_DOWN; - *redraw_toggles = 1; - } - result = 1; - break; + case BC_ListBoxToggle::TOGGLE_DOWN_EXIT: + if( cursor_inside ) { + state = BC_ListBoxToggle::TOGGLE_DOWN; + *redraw_toggles = 1; + } + result = 1; + break; - default: - if(cursor_inside) - { - if(value) - state = BC_ListBoxToggle::TOGGLE_CHECKEDHI; - else - state = BC_ListBoxToggle::TOGGLE_UPHI; - *redraw_toggles = 1; - } - break; + default: + if( cursor_inside ) { + if( value ) + state = BC_ListBoxToggle::TOGGLE_CHECKEDHI; + else + state = BC_ListBoxToggle::TOGGLE_UPHI; + *redraw_toggles = 1; + } + break; } return result; } int BC_ListBoxToggle::cursor_leave_event(int *redraw_toggles) { - if(value) + if( value ) state = BC_ListBoxToggle::TOGGLE_CHECKED; else state = BC_ListBoxToggle::TOGGLE_UP; @@ -209,11 +202,10 @@ int BC_ListBoxToggle::button_press_event() int w = listbox->toggle_images[0]->get_w(); int h = listbox->toggle_images[0]->get_h(); - if(listbox->gui->get_cursor_x() >= x && - listbox->gui->get_cursor_x() < x + w && - listbox->gui->get_cursor_y() >= y && - listbox->gui->get_cursor_y() < y + h) - { + if( listbox->gui->get_cursor_x() >= x && + listbox->gui->get_cursor_x() < x + w && + listbox->gui->get_cursor_y() >= y && + listbox->gui->get_cursor_y() < y + h ) { state = BC_ListBoxToggle::TOGGLE_DOWN; return 1; } @@ -224,61 +216,51 @@ int BC_ListBoxToggle::button_release_event(int *redraw_toggles) { int result = 0; - switch(state) - { - case BC_ListBoxToggle::TOGGLE_DOWN: - value = !value; - if(value) - state = BC_ListBoxToggle::TOGGLE_CHECKEDHI; - else - state = BC_ListBoxToggle::TOGGLE_UPHI; - listbox->expand_item(item, value); - result = 1; - break; + switch( state ) { + case BC_ListBoxToggle::TOGGLE_DOWN: + value = !value; + if( value ) + state = BC_ListBoxToggle::TOGGLE_CHECKEDHI; + else + state = BC_ListBoxToggle::TOGGLE_UPHI; + listbox->expand_item(item, value); + result = 1; + break; - case BC_ListBoxToggle::TOGGLE_DOWN_EXIT: - if(value) - state = BC_ListBoxToggle::TOGGLE_CHECKED; - else - state = BC_ListBoxToggle::TOGGLE_UP; - *redraw_toggles = 1; - result = 1; - break; + case BC_ListBoxToggle::TOGGLE_DOWN_EXIT: + if( value ) + state = BC_ListBoxToggle::TOGGLE_CHECKED; + else + state = BC_ListBoxToggle::TOGGLE_UP; + *redraw_toggles = 1; + result = 1; + break; } return result; } void BC_ListBoxToggle::draw(int flash) { - if(listbox->gui) - { + if( listbox->gui ) { int image_number = 0; int w = listbox->toggle_images[0]->get_w(); int h = listbox->toggle_images[0]->get_h(); - switch(state) - { - case BC_ListBoxToggle::TOGGLE_UP: image_number = 0; break; - case BC_ListBoxToggle::TOGGLE_UPHI: image_number = 1; break; - case BC_ListBoxToggle::TOGGLE_CHECKED: image_number = 2; break; - case BC_ListBoxToggle::TOGGLE_DOWN: image_number = 3; break; - case BC_ListBoxToggle::TOGGLE_CHECKEDHI: image_number = 4; break; - case BC_ListBoxToggle::TOGGLE_DOWN_EXIT: - if(value) - image_number = 2; - else - image_number = 0; - break; + switch( state ) { + case BC_ListBoxToggle::TOGGLE_UP: image_number = 0; break; + case BC_ListBoxToggle::TOGGLE_UPHI: image_number = 1; break; + case BC_ListBoxToggle::TOGGLE_CHECKED: image_number = 2; break; + case BC_ListBoxToggle::TOGGLE_DOWN: image_number = 3; break; + case BC_ListBoxToggle::TOGGLE_CHECKEDHI: image_number = 4; break; + case BC_ListBoxToggle::TOGGLE_DOWN_EXIT: + image_number = value ? 2 : 0; + break; } //printf("BC_ListBoxToggle::draw 1 %d\n", state); - listbox->gui->draw_pixmap(listbox->toggle_images[image_number], - x, - y); - + listbox->gui->draw_pixmap(listbox->toggle_images[image_number], x, y); - if(flash) - { + if( flash ) { listbox->gui->flash(x, y, w, h); listbox->gui->flush(); } @@ -286,34 +268,13 @@ void BC_ListBoxToggle::draw(int flash) } - - - - - - - - - - - - // ====================================================== box -BC_ListBox::BC_ListBox(int x, - int y, - int w, - int h, - int display_format, - ArrayList *data, - const char **column_titles, - int *column_width, - int columns, - int yposition, - int is_popup, - int selection_mode, - int icon_position, - int allow_drag) +BC_ListBox::BC_ListBox(int x, int y, int w, int h, + int display_format, ArrayList *data, + const char **column_titles, int *column_width, int columns, + int yposition, int is_popup, int selection_mode, + int icon_position, int allow_drag) : BC_SubWindow(x, y, w, h, -1) { justify = LISTBOX_RIGHT; @@ -345,7 +306,6 @@ BC_ListBox::BC_ListBox(int x, bg_pixmap = 0; row_height = row_ascent = row_descent = 0; - current_operation = NO_OPERATION; button_highlighted = 0; list_highlighted = 0; @@ -364,9 +324,9 @@ BC_ListBox::BC_ListBox(int x, popup_w = w; popup_h = h; - for(int i = 0; i < 3; i++) column_bg[i] = 0; - for(int i = 0; i < 4; i++) button_images[i] = 0; - for(int i = 0; i < 5; i++) toggle_images[i] = 0; + for( int i = 0; i < 3; i++ ) column_bg[i] = 0; + for( int i = 0; i < 4; i++ ) button_images[i] = 0; + for( int i = 0; i < 5; i++ ) toggle_images[i] = 0; column_sort_up = 0; column_sort_dn = 0; @@ -387,16 +347,13 @@ BC_ListBox::BC_ListBox(int x, this->last_in_view = 0; //printf("BC_ListBox::BC_ListBox 1\n"); - if((!column_titles && column_width) || - (column_titles && !column_width)) - { + if( (!column_titles && column_width) || + (column_titles && !column_width) ) { printf("BC_ListBox::BC_ListBox either column_titles or column_widths == NULL but not both.\n"); } //printf("BC_ListBox::BC_ListBox 2 %p %p\n", column_titles, column_width); - set_columns(column_titles, - column_width, - columns); + set_columns(column_titles, column_width, columns); //printf("BC_ListBox::BC_ListBox 3\n"); @@ -415,18 +372,18 @@ BC_ListBox::BC_ListBox(int x, BC_ListBox::~BC_ListBox() { expanders.remove_all_objects(); - if(bg_surface) delete bg_surface; - if(bg_pixmap) delete bg_pixmap; - if(xscrollbar) delete xscrollbar; - if(yscrollbar) delete yscrollbar; - for(int i = 0; i < 3; i++) delete column_bg[i]; - for(int i = 0; i < 4; i++) delete button_images[i]; - for(int i = 0; i < 5; i++) delete toggle_images[i]; - if(column_sort_up) delete column_sort_up; - if(column_sort_dn) delete column_sort_dn; + if( bg_surface ) delete bg_surface; + if( bg_pixmap ) delete bg_pixmap; + if( xscrollbar ) delete xscrollbar; + if( yscrollbar ) delete yscrollbar; + for( int i = 0; i < 3; i++ ) delete column_bg[i]; + for( int i = 0; i < 4; i++ ) delete button_images[i]; + for( int i = 0; i < 5; i++ ) delete toggle_images[i]; + if( column_sort_up ) delete column_sort_up; + if( column_sort_dn ) delete column_sort_dn; delete_columns(); - if(drag_popup) delete drag_popup; + if( drag_popup ) delete drag_popup; } int BC_ListBox::enable() @@ -450,11 +407,9 @@ void BC_ListBox::reset_query() int BC_ListBox::evaluate_query(char *string) { - for(int i = 0; i < data[search_column].size(); i++) - { - if(strcmp(string, data[search_column].get(i)->text) <= 0 && - data[search_column].get(i)->searchable) - { + for( int i = 0; i < data[search_column].size(); i++ ) { + if( strcmp(string, data[search_column].get(i)->text) <= 0 && + data[search_column].get(i)->searchable ) { return i; } } @@ -464,32 +419,28 @@ int BC_ListBox::evaluate_query(char *string) int BC_ListBox::query_list() { - if(query[0] == 0) return 0; + if( query[0] == 0 ) return 0; int done = 0; int result; int selection_changed = 0; int prev_selection = -1; result = evaluate_query(query); - if(result >= 0) done = 1; + if( result >= 0 ) done = 1; - if(done) - { + if( done ) { // Deselect all - for(int i = 0; i < data[0].total; i++) - { - for(int j = 0; j < columns; j++) - { - if(data[j].values[i]->selected) prev_selection = i; + for( int i = 0; i < data[0].total; i++ ) { + for( int j = 0; j < columns; j++ ) { + if( data[j].values[i]->selected ) prev_selection = i; data[j].values[i]->selected = 0; } } // Select one - if(prev_selection != result) + if( prev_selection != result ) selection_changed = 1; - for(int j = 0; j < columns; j++) - { + for( int j = 0; j < columns; j++ ) { data[j].values[result]->selected = 1; } center_selection(result); @@ -500,11 +451,9 @@ int BC_ListBox::query_list() void BC_ListBox::init_column_width() { - if(!column_width && data) - { + if( !column_width && data ) { int widest = 5, wd; - for(int i = 0; i < data[0].total; i++) - { + for( int i = 0; i < data[0].total; i++ ) { wd = get_text_w(data[0].values[i]); if( wd > widest ) widest = wd; } @@ -514,12 +463,9 @@ void BC_ListBox::init_column_width() int BC_ListBox::initialize() { - if(is_popup) - { - if(use_button) - { - for( int i = 0; i < 4; ++i ) - { + if( is_popup ) { + if( use_button ) { + for( int i = 0; i < 4; ++i ) { button_images[i] = new BC_Pixmap(parent_window, BC_WindowBase::get_resources()->listbox_button[i], PIXMAP_ALPHA); @@ -532,20 +478,17 @@ int BC_ListBox::initialize() current_operation = NO_OPERATION; } - else - { + else { gui = this; current_operation = NO_OPERATION; } - for(int i = 0; i < 3; i++) - { + for( int i = 0; i < 3; i++ ) { column_bg[i] = new BC_Pixmap(parent_window, get_resources()->listbox_column[i], PIXMAP_ALPHA); } - for(int i = 0; i < 5; i++) - { + for( int i = 0; i < 5; i++ ) { toggle_images[i] = new BC_Pixmap(parent_window, get_resources()->listbox_expand[i], PIXMAP_ALPHA); @@ -571,7 +514,7 @@ int BC_ListBox::initialize() init_column_width(); - if(top_level->get_resources()->listbox_bg) + if( top_level->get_resources()->listbox_bg ) bg_pixmap = new BC_Pixmap(this, get_resources()->listbox_bg, PIXMAP_OPAQUE); @@ -579,8 +522,7 @@ int BC_ListBox::initialize() draw_button(0); draw_items(0); - if(!use_button && is_popup) - { + if( !use_button && is_popup ) { hide_window(1); } @@ -596,27 +538,20 @@ void BC_ListBox::deactivate_selection() int BC_ListBox::draw_button(int flush) { // Draw the button for a popup listbox - if(use_button && is_popup) - { + if( use_button && is_popup ) { int image_number = 0; draw_top_background(parent_window, 0, 0, w, h); - if(button_highlighted) + if( button_highlighted ) image_number = 1; - if(current_operation == BUTTON_DN) + if( current_operation == BUTTON_DN ) image_number = 2; - if(disabled) + if( disabled ) image_number = 3; - pixmap->draw_pixmap(button_images[image_number], - 0, - 0, - w, - h, - 0, - 0); + 0, 0, w, h, 0, 0); flash(flush); } return 0; @@ -624,7 +559,7 @@ int BC_ListBox::draw_button(int flush) int BC_ListBox::calculate_item_coords() { - if(!data) return 0; + if( !data ) return 0; int icon_x = 0; int next_icon_x = 0; @@ -638,22 +573,11 @@ int BC_ListBox::calculate_item_coords() // Scan the first column for lowest y coord of all text // and lowest right x and y coord for all icons which aren't auto placable calculate_last_coords_recursive(data, - &icon_x, - &next_icon_x, - &next_icon_y, - &next_text_y, - 1); + &icon_x, &next_icon_x, &next_icon_y, &next_text_y, 1); // Reset last column width. It's recalculated based on text width. - calculate_item_coords_recursive(data, - &icon_x, - &next_icon_x, - &next_icon_y, - &next_text_y, - 1); - - + &icon_x, &next_icon_x, &next_icon_y, &next_text_y, 1); display_format = temp_display_format; @@ -668,52 +592,42 @@ void BC_ListBox::calculate_last_coords_recursive( int *next_text_y, int top_level) { - for(int i = 0; i < data[0].size(); i++) - { + for( int i = 0; i < data[0].size(); i++ ) { int current_text_y = 0; int current_icon_x = 0; int current_icon_y = 0; BC_ListBoxItem *item = data[0].get(i); // Get next_text_y - if(!item->autoplace_text) - { + if( !item->autoplace_text ) { // Lowest text coordinate display_format = LISTBOX_TEXT; current_text_y = item->text_y + get_text_h(item); - if(current_text_y > *next_text_y) + if( current_text_y > *next_text_y ) *next_text_y = current_text_y; // Add sublist depth if it is expanded - if(item->get_sublist() && - item->get_columns() && - item->get_expand()) - { + if( item->get_sublist() && item->get_columns() && + item->get_expand() ) { calculate_last_coords_recursive(item->get_sublist(), - icon_x, - next_icon_x, - next_icon_y, - next_text_y, - 0); + icon_x, next_icon_x, next_icon_y, next_text_y, 0); } } // Get next_icon coordinate - if(top_level) - { + if( top_level ) { BC_ListBoxItem *item = data[master_column].get(i); - if(!item->autoplace_icon) - { + if( !item->autoplace_icon ) { display_format = LISTBOX_ICONS; // Lowest right icon coordinate. current_icon_x = item->icon_x; - if(current_icon_x > *icon_x) *icon_x = current_icon_x; - if(current_icon_x + get_item_w(item) > *next_icon_x) { + if( current_icon_x > *icon_x ) *icon_x = current_icon_x; + if( current_icon_x + get_item_w(item) > *next_icon_x ) { *next_icon_x = current_icon_x + get_item_w(item); *next_icon_y = 0; } current_icon_y = item->icon_y + get_item_h(item); - if(current_icon_y > *next_icon_y) + if( current_icon_y > *next_icon_y ) *next_icon_y = current_icon_y; } } @@ -723,21 +637,15 @@ void BC_ListBox::calculate_last_coords_recursive( void BC_ListBox::calculate_item_coords_recursive( ArrayList *data, - int *icon_x, - int *next_icon_x, - int *next_icon_y, - int *next_text_y, + int *icon_x, int *next_icon_x, int *next_icon_y, int *next_text_y, int top_level) { // get maximum height of an icon row_height = get_text_height(MEDIUMFONT); - if(temp_display_format == LISTBOX_ICON_LIST) - { - for(int i = 0; i < data[0].size(); i++) - { - if(data[0].get(i)->icon) - { - if(data[0].get(i)->icon->get_h() > row_height) + if( temp_display_format == LISTBOX_ICON_LIST ) { + for( int i = 0; i < data[0].size(); i++ ) { + if( data[0].get(i)->icon ) { + if( data[0].get(i)->icon->get_h() > row_height ) row_height = data[0].get(i)->icon->get_h(); } } @@ -746,29 +654,25 @@ void BC_ListBox::calculate_item_coords_recursive( // Set up items which need autoplacement. // Should fill icons down and then across - for(int i = 0; i < data[0].size(); i++) - { + for( int i = 0; i < data[0].size(); i++ ) { // Don't increase y unless the row requires autoplacing. int total_autoplaced_columns = 0; // Set up icons in first column - if(top_level) - { + if( top_level ) { BC_ListBoxItem *item = data[master_column].get(i); - if(item->autoplace_icon) - { + if( item->autoplace_icon ) { // 1 column only if icons are used display_format = LISTBOX_ICONS; // Test row height // Start new column. - if(*next_icon_y + get_item_h(item) >= get_h() && - *next_icon_y > 0) - { + if( *next_icon_y + get_item_h(item) >= get_h() && + *next_icon_y > 0 ) { *icon_x = *next_icon_x; *next_icon_y = 0; } - if(*icon_x + get_item_w(item) > *next_icon_x) + if( *icon_x + get_item_w(item) > *next_icon_x ) *next_icon_x = *icon_x + get_item_w(item); @@ -779,17 +683,13 @@ void BC_ListBox::calculate_item_coords_recursive( } } - - // Set up a text row int next_text_x = 0; row_ascent = row_descent = 0; // row_height still holds icon max height - for(int j = 0; j < columns; j++) - { + for( int j = 0; j < columns; j++ ) { BC_ListBoxItem *item = data[j].get(i); - if(item->autoplace_text) - { + if( item->autoplace_text ) { display_format = LISTBOX_TEXT; item->set_text_x(next_text_x); item->set_text_y(*next_text_y); @@ -801,28 +701,22 @@ void BC_ListBox::calculate_item_coords_recursive( if( dt > row_descent ) row_ascent = bl; // printf("BC_ListBox::calculate_item_coords_recursive %p %d %d %d %d %s \n", -// item->get_sublist(), -// item->get_columns(), -// item->get_expand(), -// next_text_x, -// *next_text_y, -// item->get_text()); +// item->get_sublist(), item->get_columns(), item->get_expand(), +// next_text_x, *next_text_y, item->get_text()); // Increment position of next column - if(j < columns - 1) - { + if( j < columns - 1 ) { next_text_x += (column_width ? column_width[j] : default_column_width[j]); } - else // Set last column width based on text width - { + else { int new_w = get_item_w(item); int *previous_w = (column_width ? &column_width[j] : &default_column_width[j]); - if(new_w > *previous_w) + if( new_w > *previous_w ) *previous_w = new_w; //printf("BC_ListBox::calculate_item_coords_recursive 1 %d\n", new_w); } @@ -831,25 +725,17 @@ void BC_ListBox::calculate_item_coords_recursive( } // Increase the text vertical position - if(total_autoplaced_columns) - { + if( total_autoplaced_columns ) { display_format = LISTBOX_TEXT; *next_text_y += row_height; } // Set up a sublist BC_ListBoxItem *item = data[master_column].values[i]; - if(item->get_sublist() && - item->get_columns() && - item->get_expand()) - { - calculate_item_coords_recursive( - item->get_sublist(), - icon_x, - next_icon_x, - next_icon_y, - next_text_y, - 0); + if( item->get_sublist() && item->get_columns() && + item->get_expand() ) { + calculate_item_coords_recursive( item->get_sublist(), + icon_x, next_icon_x, next_icon_y, next_text_y, 0); } } } @@ -882,8 +768,7 @@ void BC_ListBox::set_process_drag(int value) void BC_ListBox::set_master_column(int value, int redraw) { this->master_column = value; - if(redraw) - { + if( redraw ) { draw_items(1); } } @@ -901,8 +786,7 @@ int BC_ListBox::get_sort_column() void BC_ListBox::set_sort_column(int value, int redraw) { sort_column = value; - if(redraw) - { + if( redraw ) { draw_titles(1); } } @@ -915,16 +799,12 @@ int BC_ListBox::get_sort_order() void BC_ListBox::set_sort_order(int value, int redraw) { sort_order = value; - if(redraw) - { + if( redraw ) { draw_titles(1); } } - - - int BC_ListBox::get_display_mode() { return display_format; @@ -948,45 +828,25 @@ int BC_ListBox::get_highlighted_item() int BC_ListBox::get_item_x(BC_ListBoxItem *item) { - if(display_format == LISTBOX_TEXT) - { + if( display_format == LISTBOX_TEXT ) return item->text_x - xposition + 2; - } - else - if(display_format == LISTBOX_ICON_LIST) - { + if( display_format == LISTBOX_ICON_LIST ) return item->text_x - xposition + 2; - } - else - { - return item->icon_x - xposition + 2; - } + return item->icon_x - xposition + 2; } int BC_ListBox::get_item_y(BC_ListBoxItem *item) { - int result; - if(display_format == LISTBOX_TEXT) - { - result = item->text_y - yposition + title_h + 2; - } - else - if(display_format == LISTBOX_ICON_LIST) - { - result = item->text_y - yposition + title_h + 2; - } - else - { - result = item->icon_y - yposition + title_h + 2; - } - - return result; + if( display_format == LISTBOX_TEXT ) + return item->text_y - yposition + title_h + 2; + if( display_format == LISTBOX_ICON_LIST ) + return item->text_y - yposition + title_h + 2; + return item->icon_y - yposition + title_h + 2; } int BC_ListBox::get_item_w(BC_ListBoxItem *item) { - if(display_format == LISTBOX_ICONS) - { + if( display_format == LISTBOX_ICONS ) { int x, y, w, h; get_icon_mask(item, x, y, w, h); int icon_w = w; @@ -1001,8 +861,7 @@ int BC_ListBox::get_item_w(BC_ListBoxItem *item) int BC_ListBox::get_item_h(BC_ListBoxItem *item) { - if(display_format == LISTBOX_ICONS) - { + if( display_format == LISTBOX_ICONS ) { int x, y, w, h; get_icon_mask(item, x, y, w, h); int icon_h = h; @@ -1051,77 +910,62 @@ int BC_ListBox::get_items_width() { int widest = 0; - if(display_format == LISTBOX_ICONS) - { - for(int i = 0; i < columns; i++) - { - for(int j = 0; j < data[i].total; j++) - { + if( display_format == LISTBOX_ICONS ) { + for( int i = 0; i < columns; i++ ) { + for( int j = 0; j < data[i].total; j++ ) { int x1, x, y, w, h; BC_ListBoxItem *item = data[i].values[j]; x1 = item->icon_x; get_icon_mask(item, x, y, w, h); - if(x1 + w > widest) widest = x1 + w; + if( x1 + w > widest ) widest = x1 + w; - if(display_format == LISTBOX_ICONS && icon_position == ICON_LEFT) + if( display_format == LISTBOX_ICONS && icon_position == ICON_LEFT ) x1 += w; get_text_mask(item, x, y, w, h); - if(x1 + w > widest) widest = x1 + w; + if( x1 + w > widest ) widest = x1 + w; } } } else - if(display_format == LISTBOX_TEXT) - { + if( display_format == LISTBOX_TEXT ) { return get_column_offset(columns); } - else - { + else { return get_column_offset(columns); } return widest; } -int BC_ListBox::get_items_height(ArrayList *data, - int columns, - int *result) +int BC_ListBox::get_items_height(ArrayList *data, int columns, + int *result) { int temp = 0; int top_level = 0; int highest = 0; - if(!result) - { + if( !result ) { result = &temp; top_level = 1; } - - - - - for(int j = 0; j < (data ? data[master_column].total : 0); j++) - { + for( int j = 0; j < (data ? data[master_column].total : 0); j++ ) { int x, y, w, h; BC_ListBoxItem *item = data[master_column].values[j]; if( display_format == LISTBOX_ICONS || display_format == LISTBOX_ICON_LIST ) { get_icon_mask(item, x, y, w, h); - if(y + h + yposition > highest) highest = y + h + yposition; + if( y + h + yposition > highest ) highest = y + h + yposition; get_text_mask(item, x, y, w, h); - if(y + h + yposition > highest) highest = y + h + yposition; + if( y + h + yposition > highest ) highest = y + h + yposition; } - else - { + else { get_text_mask(item, x, y, w, h); *result += h; // Descend into sublist - if(item->get_sublist() && - item->get_expand()) - { + if( item->get_sublist() && item->get_expand() ) { get_items_height(item->get_sublist(), item->get_columns(), result); @@ -1129,20 +973,17 @@ int BC_ListBox::get_items_height(ArrayList *data, } } - if( display_format == LISTBOX_TEXT && top_level ) - { + if( display_format == LISTBOX_TEXT && top_level ) { highest = LISTBOX_MARGIN + *result; } - return highest; } int BC_ListBox::set_yposition(int position, int draw_items) { this->yposition = position; - if(draw_items) - { + if( draw_items ) { this->draw_items(1); } return 0; @@ -1157,19 +998,15 @@ int BC_ListBox::set_xposition(int position) void BC_ListBox::expand_item(BC_ListBoxItem *item, int expand) { - if(item) - { + if( item ) { item->expand = expand; // Collapse sublists if this is collapsed to make it easier to calculate // coordinates - if(item->get_sublist()) + if( item->get_sublist() ) collapse_recursive(item->get_sublist(), master_column); - // Set everything for autoplacement - set_autoplacement(data, 0, 1); - draw_items(1); } } @@ -1177,11 +1014,9 @@ void BC_ListBox::expand_item(BC_ListBoxItem *item, int expand) void BC_ListBox::collapse_recursive(ArrayList *data, int master_column) { - for(int i = 0; i < data[master_column].total; i++) - { + for( int i = 0; i < data[master_column].total; i++ ) { BC_ListBoxItem *item = data[master_column].values[i]; - if(item->get_sublist() && item->expand) - { + if( item->get_sublist() && item->expand ) { item->expand = 0; collapse_recursive(item->get_sublist(), master_column); } @@ -1192,17 +1027,14 @@ void BC_ListBox::set_autoplacement(ArrayList *data, int do_icons, int do_text) { - for(int i = 0; i < data[0].total; i++) - { - for(int j = 0; j < columns; j++) - { - if(do_icons) data[j].values[i]->autoplace_icon = 1; - if(do_text) data[j].values[i]->autoplace_text = 1; + for( int i = 0; i < data[0].total; i++ ) { + for( int j = 0; j < columns; j++ ) { + if( do_icons ) data[j].values[i]->autoplace_icon = 1; + if( do_text ) data[j].values[i]->autoplace_text = 1; } BC_ListBoxItem *item = data[master_column].values[i]; - if(item->get_sublist()) - { + if( item->get_sublist() ) { set_autoplacement(item->get_sublist(), do_icons, do_text); } } @@ -1219,20 +1051,16 @@ void BC_ListBox::set_scroll_stretch(int xv, int yv) int BC_ListBox::get_yscroll_x() { - if(is_popup) + if( is_popup ) return popup_w - get_resources()->vscroll_data[SCROLL_HANDLE_UP]->get_w(); else - return get_x() + - popup_w - + return get_x() + popup_w - get_resources()->vscroll_data[SCROLL_HANDLE_UP]->get_w(); } int BC_ListBox::get_yscroll_y() { - if(is_popup) - return 0; - else - return get_y(); + return is_popup ? 0 : get_y(); } int BC_ListBox::get_yscroll_height() @@ -1244,35 +1072,25 @@ int BC_ListBox::get_yscroll_height() int BC_ListBox::get_xscroll_x() { - if(is_popup) - return 0; - else - return get_x(); + return is_popup ? 0 : get_x(); } int BC_ListBox::get_xscroll_y() { - if(is_popup) - return popup_h - - get_resources()->hscroll_data[SCROLL_HANDLE_UP]->get_h(); - else - return get_y() + - popup_h - - get_resources()->hscroll_data[SCROLL_HANDLE_UP]->get_h(); + return (is_popup ? popup_h : get_y() + popup_h) - + get_resources()->hscroll_data[SCROLL_HANDLE_UP]->get_h(); } int BC_ListBox::get_xscroll_width() { return popup_w - (need_yscroll ? - get_resources()->vscroll_data[SCROLL_HANDLE_UP]->get_w() : - 0); + get_resources()->vscroll_data[SCROLL_HANDLE_UP]->get_w() : 0); } int BC_ListBox::get_column_offset(int column) { int x = 0; - while(column > 0) - { + while( column > 0 ) { x += column_width ? column_width[--column] : default_column_width[--column]; @@ -1282,15 +1100,15 @@ int BC_ListBox::get_column_offset(int column) void BC_ListBox::column_width_boundaries() { - if(column_width) { - for(int i = 0; i < columns; i++) { - if(column_width[i] < MIN_COLUMN_WIDTH) + if( column_width ) { + for( int i = 0; i < columns; i++ ) { + if( column_width[i] < MIN_COLUMN_WIDTH ) column_width[i] = MIN_COLUMN_WIDTH; } } else { - for(int i = 0; i < columns; i++) { - if(default_column_width[i] < MIN_COLUMN_WIDTH) + for( int i = 0; i < columns; i++ ) { + if( default_column_width[i] < MIN_COLUMN_WIDTH ) default_column_width[i] = MIN_COLUMN_WIDTH; } } @@ -1298,7 +1116,7 @@ void BC_ListBox::column_width_boundaries() int BC_ListBox::get_column_width(int column, int clamp_right) { - if(column < columns - 1 || !clamp_right) + if( column < columns - 1 || !clamp_right ) return column_width ? column_width[column] : default_column_width[column]; return popup_w + xposition - get_column_offset(column); } @@ -1323,8 +1141,8 @@ int BC_ListBox::get_text_mask(BC_ListBoxItem *item, x = get_item_x(item); y = get_item_y(item); - if(display_format == LISTBOX_ICONS) { - if(icon_position == ICON_LEFT) { + if( display_format == LISTBOX_ICONS ) { + if( icon_position == ICON_LEFT ) { x += get_icon_w(item) + ICON_MARGIN * 2; y += get_icon_h(item) - get_text_h(item); } @@ -1336,12 +1154,11 @@ int BC_ListBox::get_text_mask(BC_ListBoxItem *item, h = get_text_h(item) + ICON_MARGIN * 2; } else - if(display_format == LISTBOX_TEXT) { + if( display_format == LISTBOX_TEXT ) { w = get_text_w(item) + LISTBOX_MARGIN * 2; h = get_text_h(item); } - else - { + else { w = get_text_width(MEDIUMFONT, item->text) + LISTBOX_MARGIN * 2; h = row_height; int ih = get_icon_h(item); @@ -1351,21 +1168,19 @@ int BC_ListBox::get_text_mask(BC_ListBoxItem *item, } int BC_ListBox::get_item_highlight(ArrayList *data, - int column, - int item) + int column, int item) { BC_Resources *resources = get_resources(); - if(data[column].values[item]->selected) + if( data[column].values[item]->selected ) return resources->listbox_selected; - else if(highlighted_item >= 0 && - highlighted_ptr == data[master_column].values[item]) + if( highlighted_item >= 0 && + highlighted_ptr == data[master_column].values[item] ) return resources->listbox_highlighted; return resources->listbox_inactive; } int BC_ListBox::get_item_color(ArrayList *data, - int column, - int item) + int column, int item) { int color = data[column].values[item]->color; if( color == -1 ) color = get_resources()->listbox_text; @@ -1385,41 +1200,34 @@ int BC_ListBox::get_to_column() } -BC_ListBoxItem* BC_ListBox::get_selection(int column, - int selection_number) +BC_ListBoxItem* BC_ListBox::get_selection(int column, int selection_number) { return get_selection_recursive(data, column, selection_number); } -BC_ListBoxItem* BC_ListBox::get_selection_recursive( - ArrayList *data, - int column, - int selection_number) +BC_ListBoxItem* BC_ListBox::get_selection_recursive(ArrayList *data, + int column, int selection_number) { - if(!data) return 0; + if( !data ) return 0; - for(int i = 0; i < data[master_column].total; i++) - { + for( int i = 0; i < data[master_column].total; i++ ) { BC_ListBoxItem *item = data[master_column].values[i]; - if(item->selected) - { + if( item->selected ) { //printf("BC_ListBox::get_selection_recursive %d\n", __LINE__); selection_number--; - if(selection_number < 0) - { + if( selection_number < 0 ) { return data[column].values[i]; } } - if(item->get_sublist()) - { + if( item->get_sublist() ) { BC_ListBoxItem *result = get_selection_recursive(item->get_sublist(), column, selection_number); - if(result) return result; + if( result ) return result; } } @@ -1427,44 +1235,31 @@ BC_ListBoxItem* BC_ListBox::get_selection_recursive( } -int BC_ListBox::get_selection_number(int column, - int selection_number) +int BC_ListBox::get_selection_number(int column, int selection_number) { - return get_selection_number_recursive(data, - column, - selection_number); + return get_selection_number_recursive(data, column, selection_number); } -int BC_ListBox::get_selection_number_recursive( - ArrayList *data, - int column, - int selection_number, - int *counter) +int BC_ListBox::get_selection_number_recursive(ArrayList *data, + int column, int selection_number, int *counter) { int temp = -1; - if(!data) return 0; - if(!counter) counter = &temp; + if( !data ) return 0; + if( !counter ) counter = &temp; - for(int i = 0; i < data[master_column].total; i++) - { + for( int i = 0; i < data[master_column].total; i++ ) { (*counter)++; BC_ListBoxItem *item = data[master_column].values[i]; - if(item->selected) - { + if( item->selected ) { selection_number--; - if(selection_number < 0) - { + if( selection_number < 0 ) { return (*counter); } } - if(item->get_sublist()) - { - int result = get_selection_number_recursive( - item->get_sublist(), - column, - selection_number, - counter); - if(result >= 0) return result; + if( item->get_sublist() ) { + int result = get_selection_number_recursive(item->get_sublist(), + column, selection_number, counter); + if( result >= 0 ) return result; } } return -1; @@ -1479,51 +1274,39 @@ int BC_ListBox::set_selection_mode(int mode) void BC_ListBox::delete_columns() { - if(column_titles) - { - for(int i = 0; i < columns; i++) - { + if( column_titles ) { + for( int i = 0; i < columns; i++ ) { delete [] column_titles[i]; } delete [] column_titles; } - if(column_width) delete [] column_width; + if( column_width ) delete [] column_width; column_titles = 0; column_width = 0; } // Need to copy titles so EDL can change -void BC_ListBox::set_columns(const char **column_titles, - int *column_width, - int columns) +void BC_ListBox::set_columns(const char **column_titles, int *column_width, int columns) { - if((!column_titles && column_width) || - (column_titles && !column_width)) - { + if( (!column_titles && column_width) || + (column_titles && !column_width) ) { printf("BC_ListBox::set_columns either column_titles or column_width == NULL but not both.\n"); return; } - delete_columns(); - - if(column_titles) - { + if( column_titles ) { this->column_titles = new char*[columns]; - for(int i = 0; i < columns; i++) - { + for( int i = 0; i < columns; i++ ) { this->column_titles[i] = new char[strlen(column_titles[i]) + 1]; strcpy(this->column_titles[i], column_titles[i]); } } - - if(column_width) - { + if( column_width ) { this->column_width = new int[columns]; - for(int i = 0; i < columns; i++) - { + for( int i = 0; i < columns; i++ ) { this->column_width[i] = column_width[i]; } } @@ -1534,33 +1317,23 @@ void BC_ListBox::set_columns(const char **column_titles, int BC_ListBox::update(ArrayList *data, - const char **column_titles, - int *column_widths, - int columns, - int xposition, - int yposition, - int highlighted_number, - int recalc_positions, - int draw) -{ - set_columns(column_titles, - column_widths, - columns); - + const char **column_titles, int *column_widths, int columns, + int xposition, int yposition, int highlighted_number, + int recalc_positions, int draw) +{ + set_columns(column_titles, column_widths, columns); this->data = data; - this->yposition = yposition; this->xposition = xposition; this->highlighted_item = highlighted_number; this->highlighted_ptr = index_to_item(data, highlighted_number, 0); - if(recalc_positions) + if( recalc_positions ) set_autoplacement(data, 1, 1); init_column_width(); - if(gui && draw) - { + if( gui && draw ) { draw_items(0, 1); update_scrollbars(1); } @@ -1571,13 +1344,10 @@ int BC_ListBox::update(ArrayList *data, void BC_ListBox::center_selection() { int selection = get_selection_number(0, 0); - calculate_item_coords(); center_selection(selection); - - if(gui) - { + if( gui ) { draw_items(1, 1); update_scrollbars(0); gui->show_window(1); @@ -1592,69 +1362,51 @@ void BC_ListBox::move_horizontal(int pixels) { } -int BC_ListBox::select_previous(int skip, - BC_ListBoxItem *selected_item, - int *counter, - ArrayList *data, - int *got_first, - int *got_second) +int BC_ListBox::select_previous(int skip, BC_ListBoxItem *selected_item, int *counter, + ArrayList *data, int *got_first, int *got_second) { int top_level = 0; - if(!selected_item) + if( !selected_item ) selected_item = get_selection(0, 0); int temp = -1; - if(!counter) + if( !counter ) counter = &temp; int temp2 = 0; - if(!got_first) - { + if( !got_first ) { got_first = &temp2; top_level = 1; } int temp3 = 0; - if(!got_second) + if( !got_second ) got_second = &temp3; - if(!data) + if( !data ) data = this->data; // Scan backwards to item pointer. Then count visible items to get // destination. No wraparound. - do - { - for(int i = data[master_column].total - 1; i >= 0; i--) - { + do { + for( int i = data[master_column].total - 1; i >= 0; i-- ) { BC_ListBoxItem *current_item = data[master_column].values[i]; - if(current_item->get_sublist() && - current_item->get_expand()) - { - int result = select_previous(skip, - selected_item, - counter, - current_item->get_sublist(), - got_first, - got_second); - if(*got_second) - { + if( current_item->get_sublist() && + current_item->get_expand() ) { + int result = select_previous(skip, selected_item, counter, + current_item->get_sublist(), got_first, got_second); + if( *got_second ) return result; - } } - if(*got_first) - { + if( *got_first ) { (*counter)++; - if((*counter) >= skip) - { - for(int j = 0; j < columns; j++) + if( (*counter) >= skip ) { + for( int j = 0; j < columns; j++ ) data[j].values[i]->selected = 1; (*got_second) = 1; return item_to_index(this->data, current_item); } } - else - { - if(current_item->selected) - { - for(int j = 0; j < columns; j++) + else { + if( current_item->selected ) { + for( int j = 0; j < columns; j++ ) data[j].values[i]->selected = 0; (*got_first) = 1; (*counter)++; @@ -1663,74 +1415,63 @@ int BC_ListBox::select_previous(int skip, } // Hit top of top level without finding a selected item. - if(top_level) - { + if( top_level ) { // Select first item in top level and quit BC_ListBoxItem *current_item; (*got_first) = 1; current_item = data[master_column].values[0]; - for(int j = 0; j < columns; j++) + for( int j = 0; j < columns; j++ ) data[j].values[0]->selected = 1; (*got_second) = 1; return item_to_index(this->data, current_item); } - }while(top_level && data[master_column].total); + } while( top_level && data[master_column].total ); + return -1; } -int BC_ListBox::select_next(int skip, - BC_ListBoxItem *selected_item, - int *counter, - ArrayList *data, - int *got_first, - int *got_second) +int BC_ListBox::select_next(int skip, BC_ListBoxItem *selected_item, int *counter, + ArrayList *data, int *got_first, int *got_second) { int top_level = 0; - if(!selected_item) + if( !selected_item ) selected_item = get_selection(0, 0); int temp = -1; - if(!counter) + if( !counter ) counter = &temp; int temp2 = 0; - if(!got_first) - { + if( !got_first ) { got_first = &temp2; top_level = 1; } int temp3 = 0; - if(!got_second) + if( !got_second ) got_second = &temp3; - if(!data) + if( !data ) data = this->data; // Scan forwards to currently selected item pointer. // Then count visible items to get destination. No wraparound. - do - { - for(int i = 0; i < data[master_column].total; i++) - { + do { + for( int i = 0; i < data[master_column].total; i++ ) { BC_ListBoxItem *current_item = data[master_column].values[i]; // Select next item once the number items after the currently selected item // have been passed. - if(*got_first) - { + if( *got_first ) { (*counter)++; - if((*counter) >= skip) - { - for(int j = 0; j < columns; j++) + if( (*counter) >= skip ) { + for( int j = 0; j < columns; j++ ) data[j].values[i]->selected = 1; (*got_second) = 1; return item_to_index(this->data, current_item); } } - else - { + else { // Got currently selected item. Deselect it. - if(current_item->selected) - { - for(int j = 0; j < columns; j++) + if( current_item->selected ) { + for( int j = 0; j < columns; j++ ) data[j].values[i]->selected = 0; (*got_first) = 1; (*counter)++; @@ -1738,51 +1479,42 @@ int BC_ListBox::select_next(int skip, } // Descend into expanded level - if(current_item->get_sublist() && - current_item->get_expand()) - { - int result = select_next(skip, - selected_item, - counter, - current_item->get_sublist(), - got_first, - got_second); - if(*got_second) - { + if( current_item->get_sublist() && + current_item->get_expand() ) { + int result = select_next(skip, selected_item, counter, + current_item->get_sublist(), got_first, got_second); + if( *got_second ) { return result; } } } // Hit bottom of top level without finding the next item. - if(top_level) - { + if( top_level ) { BC_ListBoxItem *current_item; // Select first item in top level and quit - if(!(*got_first)) - { + if( !(*got_first) ) { (*got_first) = 1; current_item = data[master_column].values[0]; - for(int j = 0; j < columns; j++) + for( int j = 0; j < columns; j++ ) data[j].values[0]->selected = 1; (*got_second) = 1; } - else - { + else { // Select last item in top level and quit (*got_first) = 1; int current_row = data[master_column].total - 1; current_item = data[master_column].values[current_row]; - for(int j = 0; j < columns; j++) + for( int j = 0; j < columns; j++ ) data[j].values[current_row]->selected = 1; (*got_second) = 1; } return item_to_index(this->data, current_item); } - }while(top_level && data[master_column].total); + } while( top_level && data[master_column].total ); return -1; } @@ -1797,59 +1529,53 @@ void BC_ListBox::clamp_positions() if( yscroll_orientation & SCROLL_STRETCH ) items_h += view_h / 4; - if(yposition < 0) yposition = 0; + if( yposition < 0 ) yposition = 0; else - if(yposition > items_h - view_h) + if( yposition > items_h - view_h ) yposition = items_h - view_h; - if(yposition < 0) yposition = 0; + if( yposition < 0 ) yposition = 0; - if(xposition < 0) xposition = 0; + if( xposition < 0 ) xposition = 0; else - if(xposition >= items_w - view_w) + if( xposition >= items_w - view_w ) xposition = items_w - view_w; - if(xposition < 0) xposition = 0; + if( xposition < 0 ) xposition = 0; } int BC_ListBox::center_selection(int selection, - ArrayList *data, - int *counter) + ArrayList *data, int *counter) { int temp = -1; - if(!data) data = this->data; - if(!counter) counter = &temp; + if( !data ) data = this->data; + if( !counter ) counter = &temp; - for(int i = 0; i < data[master_column].total; i++) - { + for( int i = 0; i < data[master_column].total; i++ ) { (*counter)++; // Got it BC_ListBoxItem *item = data[master_column].values[i]; - if((*counter) == selection) - { + if( (*counter) == selection ) { BC_ListBoxItem *top_item = this->data[master_column].values[0]; - if(display_format == LISTBOX_ICONS) - { + if( display_format == LISTBOX_ICONS ) { // Icon is out of window if( item->icon_y-yposition > view_h-get_text_h(item) || - item->icon_y-yposition < 0 ) { + item->icon_y-yposition < 0 ) { yposition = item->icon_y - view_h / 2; } - if(data[master_column].values[selection]->icon_x - xposition > view_w || - data[master_column].values[selection]->icon_x - xposition < 0) - { + if( data[master_column].values[selection]->icon_x - xposition > view_w || + data[master_column].values[selection]->icon_x - xposition < 0 ) { xposition = item->icon_x - view_w / 2; } } - else - { + else { // Text coordinate is out of window if( item->text_y-yposition > view_h-get_text_h(item) || - item->text_y-yposition < 0 ) { + item->text_y-yposition < 0 ) { yposition = item->text_y - top_item->text_y - view_h / 2; @@ -1859,12 +1585,11 @@ int BC_ListBox::center_selection(int selection, } // Descend - if(item->get_sublist()) - { + if( item->get_sublist() ) { int result = center_selection(selection, item->get_sublist(), counter); - if(result) return result; + if( result ) return result; } } return 0; @@ -1875,29 +1600,27 @@ void BC_ListBox::update_scrollbars(int flush) int h_needed = items_h = get_items_height(data, columns); int w_needed = items_w = get_items_width(); -// if(columns > 0 && column_width) +// if( columns > 0 && column_width ) // printf("BC_ListBox::update_scrollbars 1 %d %d\n", column_width[columns - 1], w_needed); - if(xscrollbar) - { - if(xposition != xscrollbar->get_value()) + if( xscrollbar ) { + if( xposition != xscrollbar->get_value() ) xscrollbar->update_value(xposition); - if(w_needed != xscrollbar->get_length() || - view_w != xscrollbar->get_handlelength()) + if( w_needed != xscrollbar->get_length() || + view_w != xscrollbar->get_handlelength() ) xscrollbar->update_length(w_needed, xposition, view_w, 0); } - if(yscrollbar) - { - if(yposition != yscrollbar->get_value()) + if( yscrollbar ) { + if( yposition != yscrollbar->get_value() ) yscrollbar->update_value(yposition); - if(h_needed != yscrollbar->get_length() || view_h != yscrollbar->get_handlelength()) + if( h_needed != yscrollbar->get_length() || view_h != yscrollbar->get_handlelength() ) yscrollbar->update_length(h_needed, yposition, view_h, 0); } - if(flush) this->flush(); + if( flush ) this->flush(); } int BC_ListBox::get_scrollbars() @@ -1906,37 +1629,30 @@ int BC_ListBox::get_scrollbars() int w_needed = items_w = get_items_width(); int flush = 0; - title_h = get_title_h(); - view_h = popup_h - title_h - 4; view_w = popup_w - 4; // Create scrollbars as needed - for(int i = 0; i < 2; i++) - { - if(w_needed > view_w) - { + for( int i = 0; i < 2; i++ ) { + if( w_needed > view_w ) { need_xscroll = 1; view_h = popup_h - title_h - get_resources()->hscroll_data[SCROLL_HANDLE_UP]->get_h() - 4; } - else - { + else { need_xscroll = 0; } - if(h_needed > view_h) - { + if( h_needed > view_h ) { need_yscroll = 1; view_w = popup_w - get_resources()->vscroll_data[SCROLL_HANDLE_UP]->get_w() - 4; } - else - { + else { need_yscroll = 0; } } @@ -1944,67 +1660,58 @@ int BC_ListBox::get_scrollbars() // Update subwindow size int new_w = popup_w; int new_h = popup_h; - if(need_xscroll) new_h -= get_resources()->hscroll_data[SCROLL_HANDLE_UP]->get_h(); - if(need_yscroll) new_w -= get_resources()->vscroll_data[SCROLL_HANDLE_UP]->get_w(); + if( need_xscroll ) new_h -= get_resources()->hscroll_data[SCROLL_HANDLE_UP]->get_h(); + if( need_yscroll ) new_w -= get_resources()->vscroll_data[SCROLL_HANDLE_UP]->get_w(); - if(!is_popup) - if(new_w != BC_WindowBase::get_w() || new_h != BC_WindowBase::get_h()) + if( !is_popup ) + if( new_w != BC_WindowBase::get_w() || new_h != BC_WindowBase::get_h() ) gui->resize_window(new_w, new_h); BC_WindowBase *destination = (is_popup ? gui : parent_window); - if(need_xscroll) - { - if(!xscrollbar) - { + if( need_xscroll ) { + if( !xscrollbar ) { xscrollbar = new BC_ListBoxXScroll(this); destination->add_subwindow(xscrollbar); xscrollbar->show_window(0); xscrollbar->bound_to = this; } - else - { + else { xscrollbar->update_length(w_needed, xposition, view_w, flush); xscrollbar->reposition_window(get_xscroll_x(), get_xscroll_y(), get_xscroll_width()); } } - else - { - if(xscrollbar) delete xscrollbar; + else { + if( xscrollbar ) delete xscrollbar; xscrollbar = 0; xposition = 0; } - if(need_yscroll) - { - if(!yscrollbar) - { + if( need_yscroll ) { + if( !yscrollbar ) { yscrollbar = new BC_ListBoxYScroll(this); destination->add_subwindow(yscrollbar); yscrollbar->show_window(0); yscrollbar->bound_to = this; } - else - { + else { yscrollbar->update_length(h_needed, yposition, view_h, flush); yscrollbar->reposition_window(get_yscroll_x(), get_yscroll_y(), get_yscroll_height()); } } - else - { - if(yscrollbar) delete yscrollbar; + else { + if( yscrollbar ) delete yscrollbar; yscrollbar = 0; yposition = 0; } - if(!bg_surface || - view_w + 4 != bg_surface->get_w() || - view_h + 4 != bg_surface->get_h()) - { - if(bg_surface) delete bg_surface; + if( !bg_surface || + view_w + 4 != bg_surface->get_w() || + view_h + 4 != bg_surface->get_h() ) { + if( bg_surface ) delete bg_surface; bg_surface = new BC_Pixmap(gui, view_w + 4, view_h + 4); bg_draw = 1; } @@ -2014,29 +1721,25 @@ int BC_ListBox::get_scrollbars() } - void BC_ListBox::set_drag_scroll(int value) { allow_drag_scroll = value; } - // Test for scrolling by dragging int BC_ListBox::test_drag_scroll(int cursor_x, int cursor_y) { int result = 0; - if(allow_drag_scroll || - current_operation == SELECT_RECT) - { + if( allow_drag_scroll || + current_operation == SELECT_RECT ) { int top_boundary = get_title_h(); - if(cursor_y < top_boundary || - cursor_y >= view_h + title_h + LISTBOX_BORDER * 2 || - cursor_x < LISTBOX_BORDER || - cursor_x >= view_w + LISTBOX_BORDER) - { + if( cursor_y < top_boundary || + cursor_y >= view_h + title_h + LISTBOX_BORDER * 2 || + cursor_x < LISTBOX_BORDER || + cursor_x >= view_w + LISTBOX_BORDER ) { result = 1; } } @@ -2048,30 +1751,29 @@ int BC_ListBox::drag_scroll_event() int top_boundary = get_title_h(); int result = 0; - if(get_cursor_y() < top_boundary) - { + if( get_cursor_y() < top_boundary ) { yposition -= top_boundary - get_cursor_y(); result = 1; } else - if(get_cursor_y() >= view_h + title_h + 4) - { + if( get_cursor_y() >= view_h + title_h + 4 ) { yposition += get_cursor_y() - (view_h + title_h + 4); result = 1; } - if(get_cursor_x() < 2) - { + if( get_cursor_x() < 2 ) { xposition -= 2 - get_cursor_x(); result = 1; } else - if(get_cursor_x() >= view_w + 2) - { + if( get_cursor_x() >= view_w + 2 ) { xposition += get_cursor_x() - (view_w + 2); result = 1; } - if(result) clamp_positions(); + + if( result ) + clamp_positions(); + return result; } @@ -2081,8 +1783,7 @@ int BC_ListBox::rectangle_scroll_event() int old_yposition = yposition; int result = drag_scroll_event(); - if(result) - { + if( result ) { rect_x1 += old_xposition - xposition; rect_y1 += old_yposition - yposition; rect_x2 = get_cursor_x(); @@ -2093,12 +1794,7 @@ int BC_ListBox::rectangle_scroll_event() int y1 = MIN(rect_y1, rect_y2); int y2 = MAX(rect_y1, rect_y2); - if(select_rectangle(data, - x1, - y1, - x2, - y2)) - { + if( select_rectangle(data, x1, y1, x2, y2) ) { selection_changed(); } @@ -2112,13 +1808,9 @@ int BC_ListBox::rectangle_scroll_event() int BC_ListBox::select_scroll_event() { int result = drag_scroll_event(); - - if(result) - { + if( result ) { highlighted_item = selection_number = get_cursor_item(data, - get_cursor_x(), - get_cursor_y(), - &highlighted_ptr); + get_cursor_x(), get_cursor_y(), &highlighted_ptr); clamp_positions(); draw_items(0); update_scrollbars(1); @@ -2128,65 +1820,48 @@ int BC_ListBox::select_scroll_event() } int BC_ListBox::select_rectangle(ArrayList *data, - int x1, - int y1, - int x2, - int y2) + int x1, int y1, int x2, int y2) { int result = 0; - for(int i = 0; i < data[master_column].total; i++) - { - for(int j = 0; j < columns; j++) - { + for( int i = 0; i < data[master_column].total; i++ ) { + for( int j = 0; j < columns; j++ ) { BC_ListBoxItem *item = data[j].values[i]; - if(display_format == LISTBOX_ICONS) - { + if( display_format == LISTBOX_ICONS ) { int icon_x, icon_y, icon_w, icon_h; int text_x, text_y, text_w, text_h; get_icon_mask(item, icon_x, icon_y, icon_w, icon_h); get_text_mask(item, text_x, text_y, text_w, text_h); - if((x2 >= icon_x && x1 < icon_x + icon_w && - y2 >= icon_y && y1 < icon_y + icon_h) || - (x2 >= text_x && x1 < text_x + text_w && - y2 >= text_y && y1 < text_y + text_h)) - { - if(!item->selected) - { + if( (x2 >= icon_x && x1 < icon_x + icon_w && + y2 >= icon_y && y1 < icon_y + icon_h) || + (x2 >= text_x && x1 < text_x + text_w && + y2 >= text_y && y1 < text_y + text_h) ) { + if( !item->selected ) { item->selected = 1; result = 1; } } - else - { - if(item->selected) - { + else { + if( item->selected ) { item->selected = 0; result = 1; } } } - else - { - if(x2 >= 0 && - x1 < (yscrollbar ? - gui->get_w() - get_resources()->vscroll_data[SCROLL_HANDLE_UP]->get_w() : - gui->get_w()) && - y2 > 0 && - y1 < gui->get_h() && - y2 >= get_item_y(item) && - y1 < get_item_y(item) + get_item_h(item)) - { - if(!item->selected) - { + else { + if( x2 >= 0 && + x1 < (yscrollbar ? + gui->get_w() - get_resources()->vscroll_data[SCROLL_HANDLE_UP]->get_w() : + gui->get_w()) && y2 > 0 && + y1 < gui->get_h() && y2 >= get_item_y(item) && + y1 < get_item_y(item) + get_item_h(item) ) { + if( !item->selected ) { item->selected = 1; result = 1; } } - else - { - if(item->selected) - { + else { + if( item->selected ) { item->selected = 0; result = 1; } @@ -2195,33 +1870,24 @@ int BC_ListBox::select_rectangle(ArrayList *data, } BC_ListBoxItem *item = data[master_column].values[i]; - if(item->get_sublist() && - item->get_expand()) + if( item->get_sublist() && + item->get_expand() ) result |= select_rectangle(item->get_sublist(), - x1, - y1, - x2, - y2); + x1, y1, x2, y2); } return result; } int BC_ListBox::reposition_item(ArrayList *data, - int selection_number, - int x, - int y, - int *counter) + int selection_number, int x, int y, int *counter) { int temp = -1; - if(!counter) counter = &temp; - + if( !counter ) counter = &temp; - for(int i = 0; i < data[master_column].total; i++) - { + for( int i = 0; i < data[master_column].total; i++ ) { BC_ListBoxItem *item = data[master_column].values[i]; (*counter)++; - if((*counter) == selection_number) - { + if( (*counter) == selection_number ) { item->icon_x = x; item->icon_y = y; return 1; @@ -2234,23 +1900,19 @@ int BC_ListBox::reposition_item(ArrayList *data, void BC_ListBox::move_selection(ArrayList *dst, ArrayList *src) { - for(int i = 0; i < src[master_column].total; ) - { + for( int i = 0; i < src[master_column].total; ) { BC_ListBoxItem *item = src[master_column].values[i]; // Move item to dst - if(item->selected) - { - for(int j = 0; j < columns; j++) - { + if( item->selected ) { + for( int j = 0; j < columns; j++ ) { dst[j].append(src[j].values[i]); src[j].remove_number(i); } continue; } // Descend into sublist - if(item->get_sublist()) - { + if( item->get_sublist() ) { move_selection(dst, item->get_sublist()); } @@ -2259,34 +1921,25 @@ void BC_ListBox::move_selection(ArrayList *dst, } int BC_ListBox::put_selection(ArrayList *data, - ArrayList *src, - int destination, - int *counter) + ArrayList *src, int destination, int *counter) { int temp = -1; - if(!counter) counter = &temp; + if( !counter ) counter = &temp; - if(destination < 0 || destination >= data[master_column].total) - { - for(int j = 0; j < columns; j++) - { - for(int i = 0; i < src[j].total; i++) - { + if( destination < 0 || destination >= data[master_column].total ) { + for( int j = 0; j < columns; j++ ) { + for( int i = 0; i < src[j].total; i++ ) { data[j].append(src[j].values[i]); } } return 1; } else - for(int i = 0; i < data[master_column].total; i++) - { + for( int i = 0; i < data[master_column].total; i++ ) { (*counter)++; - if((*counter) == destination) - { - for(int j = 0; j < columns; j++) - { - for(int k = 0; k < src[j].total; k++) - { + if( (*counter) == destination ) { + for( int j = 0; j < columns; j++ ) { + for( int k = 0; k < src[j].total; k++ ) { data[j].insert(src[j].values[k], destination + k); } } @@ -2294,12 +1947,11 @@ int BC_ListBox::put_selection(ArrayList *data, } BC_ListBoxItem *item = data[master_column].values[i]; - if(item->get_sublist()) - { - if(put_selection(item->get_sublist(), + if( item->get_sublist() ) { + if( put_selection(item->get_sublist(), src, destination, - counter)) + counter) ) return 1; } } @@ -2309,31 +1961,26 @@ int BC_ListBox::put_selection(ArrayList *data, int BC_ListBox::item_to_index(ArrayList *data, - BC_ListBoxItem *item, - int *counter) + BC_ListBoxItem *item, int *counter) { int temp = -1; - if(!counter) counter = &temp; + if( !counter ) counter = &temp; - for(int i = 0; i < data[master_column].total; i++) - { + for( int i = 0; i < data[master_column].total; i++ ) { (*counter)++; - for(int j = 0; j < columns; j++) - { + for( int j = 0; j < columns; j++ ) { BC_ListBoxItem *new_item = data[j].values[i]; //printf("BC_ListBox::item_to_index 1 %d %d %p\n", j, i, new_item); - if(new_item == item) - { + if( new_item == item ) { return (*counter); } } BC_ListBoxItem *new_item = data[master_column].values[i]; - if(new_item->get_sublist()) - { - if(item_to_index(new_item->get_sublist(), + if( new_item->get_sublist() ) { + if( item_to_index(new_item->get_sublist(), item, - counter) >= 0) + counter) >= 0 ) return (*counter); } } @@ -2342,60 +1989,46 @@ int BC_ListBox::item_to_index(ArrayList *data, } BC_ListBoxItem* BC_ListBox::index_to_item(ArrayList *data, - int number, - int column, - int *counter) + int number, int column, int *counter) { int temp = -1; - if(!counter) counter = &temp; - for(int i = 0; i < data[master_column].total; i++) - { + if( !counter ) counter = &temp; + for( int i = 0; i < data[master_column].total; i++ ) { (*counter)++; - if((*counter) == number) - { + if( (*counter) == number ) { return data[column].values[i]; } BC_ListBoxItem *item = data[master_column].values[i]; - if(item->get_sublist()) - { + if( item->get_sublist() ) { BC_ListBoxItem *result = index_to_item(item->get_sublist(), - number, - column, - counter); - if(result) return result; + number, column, counter); + if( result ) return result; } } return 0; } -int BC_ListBox::get_cursor_item(ArrayList *data, - int cursor_x, - int cursor_y, - BC_ListBoxItem **item_return, - int *counter, - int expanded) +int BC_ListBox::get_cursor_item(ArrayList *data, int cursor_x, int cursor_y, + BC_ListBoxItem **item_return, int *counter, int expanded) { int temp = -1; - if(!data) return -1; - if(!counter) counter = &temp; + if( !data ) return -1; + if( !counter ) counter = &temp; // Icons are not treed - if(display_format == LISTBOX_ICONS) - { - for(int j = data[master_column].total - 1; j >= 0; j--) - { + if( display_format == LISTBOX_ICONS ) { + for( int j = data[master_column].total - 1; j >= 0; j-- ) { int icon_x, icon_y, icon_w, icon_h; int text_x, text_y, text_w, text_h; BC_ListBoxItem *item = data[master_column].values[j]; get_icon_mask(item, icon_x, icon_y, icon_w, icon_h); get_text_mask(item, text_x, text_y, text_w, text_h); - if((cursor_x >= icon_x && cursor_x < icon_x + icon_w && - cursor_y >= icon_y && cursor_y < icon_y + icon_h) || - (cursor_x >= text_x && cursor_x < text_x + text_w && - cursor_y >= text_y && cursor_y < text_y + text_h)) - { - if(item_return) (*item_return) = item; + if( (cursor_x >= icon_x && cursor_x < icon_x + icon_w && + cursor_y >= icon_y && cursor_y < icon_y + icon_h) || + (cursor_x >= text_x && cursor_x < text_x + text_w && + cursor_y >= text_y && cursor_y < text_y + text_h) ) { + if( item_return ) (*item_return) = item; return j; } } @@ -2403,75 +2036,69 @@ int BC_ListBox::get_cursor_item(ArrayList *data, else if( gui ) { // Text is treed // Cursor is inside items rectangle - if(cursor_x >= 0 && - cursor_x < (yscrollbar ? + if( cursor_x >= 0 && + cursor_x < (yscrollbar ? gui->get_w() - get_resources()->vscroll_data[SCROLL_HANDLE_UP]->get_w() : gui->get_w()) && // Only clamp y if we're not in a SELECT operation. - (current_operation == BC_ListBox::SELECT || - (cursor_y > get_title_h() + LISTBOX_BORDER && - cursor_y < gui->get_h()))) - { + (current_operation == BC_ListBox::SELECT || + (cursor_y > get_title_h() + LISTBOX_BORDER && + cursor_y < gui->get_h())) ) { // Search table for cursor obstruction - for(int i = 0; i < data[master_column].total; i++) - { + for( int i = 0; i < data[master_column].total; i++ ) { BC_ListBoxItem *item = data[master_column].values[i]; (*counter)++; // Cursor is inside item on current level - if(expanded && - item->selectable && - cursor_y >= get_item_y(item) && - cursor_y < get_item_y(item) + get_item_h(item)) - { + if( expanded && item->selectable && + cursor_y >= get_item_y(item) && + cursor_y < get_item_y(item) + get_item_h(item) ) { //printf("BC_ListBox::get_cursor_item %d %d %p\n", master_column, i, item); - if(item_return) (*item_return) = item; + if( item_return ) (*item_return) = item; return (*counter); } // Descend into sublist - if(item->get_sublist()) - { - if(get_cursor_item(item->get_sublist(), - cursor_x, - cursor_y, - item_return, - counter, - item->get_expand()) >= 0) + if( item->get_sublist() ) { + if( get_cursor_item(item->get_sublist(), + cursor_x, cursor_y, item_return, counter, + item->get_expand()) >= 0 ) return (*counter); } } } } + return -1; } int BC_ListBox::repeat_event(int64_t duration) { - switch(current_operation) - { + switch( current_operation ) { // Repeat out of bounds selection - case SELECT_RECT: - if(duration == get_resources()->scroll_repeat) - return rectangle_scroll_event(); - break; + case SELECT_RECT: + if( duration != get_resources()->scroll_repeat ) break; + return rectangle_scroll_event(); - case DRAG_ITEM: - case SELECT: - if(duration == get_resources()->scroll_repeat) - return select_scroll_event(); - break; + case DRAG_ITEM: + if( duration != get_resources()->scroll_repeat ) break; + if( !drag_scroll_event() ) break; + clamp_positions(); + draw_items(0); + update_scrollbars(1); + return 1; - case NO_OPERATION: + case SELECT: + if( duration != get_resources()->scroll_repeat ) break; + return select_scroll_event(); + + case NO_OPERATION: // Show tooltip - if(button_highlighted && is_popup && - tooltip_text && tooltip_text[0] != 0 && - duration == get_resources()->tooltip_delay) - { - show_tooltip(); - return 1; - } - break; + if( duration != get_resources()->tooltip_delay ) break; + if( !button_highlighted || !is_popup ) break; + if( !tooltip_text || !tooltip_text[0] ) break; + show_tooltip(); + return 1; } return 0; } @@ -2481,36 +2108,32 @@ int BC_ListBox::cursor_enter_event() { int result = 0; - switch(current_operation) - { + switch( current_operation ) { // Cursor moved over button, pressed, and exited. - case BUTTON_DOWN_SELECT: - if(top_level->event_win == win) - { - current_operation = BUTTON_DN; - result = 1; - button_highlighted = 1; - draw_button(1); - } - break; + case BUTTON_DOWN_SELECT: + if( top_level->event_win == win ) { + current_operation = BUTTON_DN; + result = 1; + button_highlighted = 1; + draw_button(1); + } + break; - case NO_OPERATION: + case NO_OPERATION: // Cursor entered button - if(is_popup && top_level->event_win == win) - { - button_highlighted = 1; - result = 1; - draw_button(1); - } - else + if( is_popup && top_level->event_win == win ) { + button_highlighted = 1; + result = 1; + draw_button(1); + } + else // TODO: Need to get the highlighted column title or item - if(gui && top_level->event_win == gui->win) - { - list_highlighted = 1; - draw_border(1); - result = 1; - } - break; + if( gui && top_level->event_win == gui->win ) { + list_highlighted = 1; + draw_border(1); + result = 1; + } + break; } return result; @@ -2518,24 +2141,22 @@ int BC_ListBox::cursor_enter_event() int BC_ListBox::cursor_leave_event() { - if(current_operation == COLUMN_DRAG) return 0; + if( current_operation == COLUMN_DRAG ) return 0; // Left button area - if(button_highlighted) - { + if( button_highlighted ) { button_highlighted = 0; hide_tooltip(); draw_button(1); } - if(list_highlighted) - { + if( list_highlighted ) { list_highlighted = 0; highlighted_item = -1; highlighted_ptr = 0; highlighted_title = -1; int redraw_toggles = 0; - for(int i = 0; i < expanders.total; i++) + for( int i = 0; i < expanders.total; i++ ) expanders.values[i]->cursor_leave_event(&redraw_toggles); draw_items(1); @@ -2547,16 +2168,14 @@ int BC_ListBox::cursor_leave_event() int BC_ListBox::get_first_selection(ArrayList *data, int *result) { int temp = -1; - if(!result) result = &temp; + if( !result ) result = &temp; - for(int i = 0; i < data[master_column].total; i++) - { + for( int i = 0; i < data[master_column].total; i++ ) { BC_ListBoxItem *item = data[master_column].values[i]; (*result)++; - if(item->selected) return (*result); - if(item->get_sublist()) - { - if(get_first_selection(item->get_sublist(), result) >= 0) + if( item->selected ) return (*result); + if( item->get_sublist() ) { + if( get_first_selection(item->get_sublist(), result) >= 0 ) return (*result); } } @@ -2568,12 +2187,11 @@ int BC_ListBox::get_total_items(ArrayList *data, int master_column) { int temp = 0; - if(!result) result = &temp; + if( !result ) result = &temp; - for(int i = 0; i < data[master_column].total; i++) - { + for( int i = 0; i < data[master_column].total; i++ ) { (*result)++; - if(data[master_column].values[i]->get_sublist()) + if( data[master_column].values[i]->get_sublist() ) get_total_items(data[master_column].values[i]->get_sublist(), result, master_column); @@ -2588,29 +2206,24 @@ int BC_ListBox::get_last_selection(ArrayList *data, { int temp = -1; int top_level = 0; - if(!result) - { + if( !result ) { result = &temp; top_level = 1; } - for(int i = data[master_column].total - 1; i >= 0; i--) - { + for( int i = data[master_column].total - 1; i >= 0; i-- ) { BC_ListBoxItem *item = data[master_column].values[i]; (*result)++; - if(item->selected) - { - if(top_level) + if( item->selected ) { + if( top_level ) return get_total_items(data, 0, master_column) - (*result) /* - 1 */; else return (*result); } - if(item->get_sublist()) - { - if(get_last_selection(item->get_sublist(), result) >= 0) - { - if(top_level) + if( item->get_sublist() ) { + if( get_last_selection(item->get_sublist(), result) >= 0 ) { + if( top_level ) return get_total_items(data, 0, master_column) - (*result) /* - 1 */; else return (*result); @@ -2621,27 +2234,20 @@ int BC_ListBox::get_last_selection(ArrayList *data, } void BC_ListBox::select_range(ArrayList *data, - int start, - int end, - int *current) + int start, int end, int *current) { int temp = -1; - if(!current) current = &temp; + if( !current ) current = &temp; - for(int i = 0; i < data[master_column].total; i++) - { + for( int i = 0; i < data[master_column].total; i++ ) { (*current)++; - if((*current) >= start && (*current) < end) - { - for(int j = 0; j < columns; j++) + if( (*current) >= start && (*current) < end ) { + for( int j = 0; j < columns; j++ ) data[j].values[i]->selected = 1; } BC_ListBoxItem *item = data[master_column].values[i]; - if(item->get_sublist()) - select_range(item->get_sublist(), - start, - end, - current); + if( item->get_sublist() ) + select_range(item->get_sublist(), start, end, current); } } @@ -2657,12 +2263,10 @@ int BC_ListBox::expand_selection(int button_press, int selection_number) // selection_number); // Calculate the range to select based on selection_center and selection_number - if(selection_number < selection_center) - { + if( selection_number < selection_center ) { selection_start = selection_number; } - else - { + else { selection_end = selection_number + 1; } @@ -2676,32 +2280,27 @@ int BC_ListBox::expand_selection(int button_press, int selection_number) } int BC_ListBox::toggle_item_selection(ArrayList *data, - int selection_number, - int *counter) + int selection_number, int *counter) { int temp = -1; - if(!counter) counter = &temp; + if( !counter ) counter = &temp; - for(int i = 0; i < data[master_column].total; i++) - { + for( int i = 0; i < data[master_column].total; i++ ) { BC_ListBoxItem *item = data[master_column].values[i]; (*counter)++; - if((*counter) == selection_number) - { + if( (*counter) == selection_number ) { // Get new value for selection int selected = !item->selected; // Set row - for(int j = 0; j < columns; j++) + for( int j = 0; j < columns; j++ ) data[j].values[i]->selected = selected; return 1; } // Descend into sublist - if(item->get_sublist()) - { - if(toggle_item_selection(item->get_sublist(), - selection_number, - counter)) + if( item->get_sublist() ) { + if( toggle_item_selection(item->get_sublist(), + selection_number, counter) ) return 1; } } @@ -2712,35 +2311,27 @@ int BC_ListBox::toggle_item_selection(ArrayList *data, void BC_ListBox::set_all_selected(ArrayList *data, int value) { - for(int i = 0; i < data[master_column].total; i++) - { - for(int j = 0; j < columns; j++) - { + for( int i = 0; i < data[master_column].total; i++ ) { + for( int j = 0; j < columns; j++ ) { BC_ListBoxItem *item = data[j].values[i]; item->selected = value; } BC_ListBoxItem *item = data[master_column].values[i]; - if(item->get_sublist()) - { + if( item->get_sublist() ) { set_all_selected(item->get_sublist(), value); } } } void BC_ListBox::set_selected(ArrayList *data, - int item_number, - int value, - int *counter) + int item_number, int value, int *counter) { int temp = -1; - if(!counter) counter = &temp; - for(int i = 0; i < data[master_column].total && (*counter) != item_number; i++) - { + if( !counter ) counter = &temp; + for( int i = 0; i < data[master_column].total && (*counter) != item_number; i++ ) { (*counter)++; - if((*counter) == item_number) - { - for(int j = 0; j < columns; j++) - { + if( (*counter) == item_number ) { + for( int j = 0; j < columns; j++ ) { BC_ListBoxItem *item = data[j].values[i]; item->selected = value; } @@ -2748,42 +2339,34 @@ void BC_ListBox::set_selected(ArrayList *data, } BC_ListBoxItem *item = data[master_column].values[i]; - if(item->get_sublist()) - { - set_selected(item->get_sublist(), - item_number, - value, - counter); + if( item->get_sublist() ) { + set_selected(item->get_sublist(), item_number, value, counter); } } } int BC_ListBox::update_selection(ArrayList *data, - int selection_number, - int *counter) + int selection_number, int *counter) { int temp = -1; int result = 0; - if(!counter) counter = &temp; + if( !counter ) counter = &temp; - for(int i = 0; i < data[master_column].total; i++) - { + for( int i = 0; i < data[master_column].total; i++ ) { BC_ListBoxItem *item = data[master_column].values[i]; (*counter)++; - if((*counter) == selection_number && !item->selected) - { + if( (*counter) == selection_number && !item->selected ) { result = 1; - for(int j = 0; j < columns; j++) + for( int j = 0; j < columns; j++ ) data[j].values[i]->selected = 1; } else - if((*counter) != selection_number && item->selected) - { + if( (*counter) != selection_number && item->selected ) { result = 1; - for(int j = 0; j < columns; j++) + for( int j = 0; j < columns; j++ ) data[j].values[i]->selected = 0; } - if(item->get_sublist()) + if( item->get_sublist() ) result |= update_selection(item->get_sublist(), selection_number, counter); @@ -2792,18 +2375,15 @@ int BC_ListBox::update_selection(ArrayList *data, } void BC_ListBox::promote_selections(ArrayList *data, - int old_value, - int new_value) + int old_value, int new_value) { - for(int i = 0; i < data[master_column].total; i++) - { - for(int j = 0; j < columns; j++) - { + for( int i = 0; i < data[master_column].total; i++ ) { + for( int j = 0; j < columns; j++ ) { BC_ListBoxItem *item = data[j].values[i]; - if(item->selected == old_value) item->selected = new_value; + if( item->selected == old_value ) item->selected = new_value; } BC_ListBoxItem *item = data[master_column].values[i]; - if(item->get_sublist()) + if( item->get_sublist() ) promote_selections(item->get_sublist(), old_value, new_value); } } @@ -2823,24 +2403,18 @@ int BC_ListBox::button_press_event() const int debug = 0; hide_tooltip(); - if(debug) printf("BC_ListBox::button_press_event %d this=%p event_win=%p %p %p %p\n", - __LINE__, - this, - (void*)top_level->event_win, - (void*)(gui ? gui->win : 0), - (void*)win, - (void*)parent_window->win); + if( debug ) printf("BC_ListBox::button_press_event %d this=%p event_win=%p %p %p %p\n", + __LINE__, this, (void*)top_level->event_win, + (void*)(gui ? gui->win : 0), (void*)win, (void*)parent_window->win); // Pressed in button - if(is_popup && top_level->event_win == win) - { - if(debug) printf("BC_ListBox::button_press_event %d\n", __LINE__); + if( is_popup && top_level->event_win == win ) { + if( debug ) printf("BC_ListBox::button_press_event %d\n", __LINE__); current_operation = BUTTON_DN; draw_button(1); // Deploy listbox - if(!active && !disabled) - { + if( !active && !disabled ) { top_level->deactivate(); activate(); } @@ -2849,44 +2423,37 @@ int BC_ListBox::button_press_event() } else // Pressed in scrollbar - if((xscrollbar && top_level->event_win == xscrollbar->win) || - (yscrollbar && top_level->event_win == yscrollbar->win)) - { - if(debug) printf("BC_ListBox::button_press_event %d\n", __LINE__); + if( (xscrollbar && top_level->event_win == xscrollbar->win) || + (yscrollbar && top_level->event_win == yscrollbar->win) ) { + if( debug ) printf("BC_ListBox::button_press_event %d\n", __LINE__); result = 0; } else // Pressed in items - if(gui && top_level->event_win == gui->win) - { - if(debug) printf("BC_ListBox::button_press_event %d\n", __LINE__); + if( gui && top_level->event_win == gui->win ) { + if( debug ) printf("BC_ListBox::button_press_event %d\n", __LINE__); // Activate list items // If it is a suggestion popup, it is visible without being active - if(!active) - { - if(debug) printf("BC_ListBox::button_press_event %d\n", __LINE__); - if(!is_suggestions) top_level->deactivate(); - if(debug) printf("BC_ListBox::button_press_event %d\n", __LINE__); + if( !active ) { + if( debug ) printf("BC_ListBox::button_press_event %d\n", __LINE__); + if( !is_suggestions ) top_level->deactivate(); + if( debug ) printf("BC_ListBox::button_press_event %d\n", __LINE__); activate(); - if(debug) printf("BC_ListBox::button_press_event %d\n", __LINE__); + if( debug ) printf("BC_ListBox::button_press_event %d\n", __LINE__); } // Wheel mouse pressed - if(get_buttonpress() == 4) - { - if(current_operation == NO_OPERATION) - { + if( get_buttonpress() == 4 ) { + if( current_operation == NO_OPERATION ) { current_operation = WHEEL; - if(yscrollbar) - { + if( yscrollbar ) { set_yposition(yposition - gui->get_h() / 10, 0); clamp_positions(); update_scrollbars(0); highlighted_ptr = 0; highlighted_item = get_cursor_item(data, - top_level->cursor_x, - top_level->cursor_y, + top_level->cursor_x, top_level->cursor_y, &highlighted_ptr); draw_items(1); result = 1; @@ -2894,20 +2461,16 @@ int BC_ListBox::button_press_event() } } else - if(get_buttonpress() == 5) - { - if(current_operation == NO_OPERATION) - { + if( get_buttonpress() == 5 ) { + if( current_operation == NO_OPERATION ) { current_operation = WHEEL; - if(yscrollbar) - { + if( yscrollbar ) { set_yposition(yposition + gui->get_h() / 10, 0); clamp_positions(); update_scrollbars(0); highlighted_ptr = 0; highlighted_item = get_cursor_item(data, - top_level->cursor_x, - top_level->cursor_y, + top_level->cursor_x, top_level->cursor_y, &highlighted_ptr); draw_items(1); result = 1; @@ -2916,12 +2479,11 @@ int BC_ListBox::button_press_event() } else // Pressed over column title division - if(test_column_divisions(gui->get_cursor_x(), + if( test_column_divisions(gui->get_cursor_x(), gui->get_cursor_y(), - new_cursor)) - { + new_cursor) ) { drag_cursor_x = gui->get_cursor_x() + xposition; - if(column_width) + if( column_width ) drag_column_w = column_width[highlighted_division - 1]; else drag_column_w = default_column_width[highlighted_division - 1]; @@ -2931,8 +2493,7 @@ int BC_ListBox::button_press_event() } else // Pressed in column title - if(test_column_titles(gui->get_cursor_x(), gui->get_cursor_y())) - { + if( test_column_titles(gui->get_cursor_x(), gui->get_cursor_y()) ) { current_operation = COLUMN_DN; button_highlighted = 0; list_highlighted = 1; @@ -2941,8 +2502,7 @@ int BC_ListBox::button_press_event() } else // Pressed in expander - if(test_expanders()) - { + if( test_expanders() ) { current_operation = EXPAND_DN; // Need to redraw items because of alpha draw_items(1); @@ -2950,12 +2510,10 @@ int BC_ListBox::button_press_event() } else // Pressed over item - if((selection_number = get_cursor_item(data, - gui->get_cursor_x(), - gui->get_cursor_y(), - ¤t_item)) >= 0) - { - if(debug) printf("BC_ListBox::button_press_event %d\n", __LINE__); + if( (selection_number = get_cursor_item(data, + gui->get_cursor_x(), gui->get_cursor_y(), + ¤t_item)) >= 0 ) { + if( debug ) printf("BC_ListBox::button_press_event %d\n", __LINE__); // Get item button was pressed over selection_number2 = selection_number1; @@ -2966,48 +2524,39 @@ int BC_ListBox::button_press_event() // Multiple item selection is possible - if(selection_mode == LISTBOX_MULTIPLE && - (ctrl_down() || shift_down())) - { + if( selection_mode == LISTBOX_MULTIPLE && + (ctrl_down() || shift_down()) ) { // Expand text selection. // Fill items between selected region and current item. - if(shift_down() && - (display_format == LISTBOX_TEXT || - display_format == LISTBOX_ICON_LIST)) - { + if( shift_down() && + (display_format == LISTBOX_TEXT || + display_format == LISTBOX_ICON_LIST) ) { // Get first item selected selection_start = get_first_selection(data); // Get last item selected selection_end = get_last_selection(data); // Get center of selected region - if(selection_end > selection_start) - { + if( selection_end > selection_start ) { selection_center = (selection_end + selection_start) >> 1; } - else - { + else { selection_center = selection_number; } - - // Deselect everything. set_all_selected(data, 0); // Select just the items expand_selection(1, selection_number); new_value = 1; } - else // Toggle a single item on or off - { + else { toggle_item_selection(data, selection_number); new_value = current_item->selected; } } - else // Select single item - { - if(!current_item->selected) - { + else { + if( !current_item->selected ) { set_all_selected(data, 0); set_selected(data, selection_number, @@ -3028,25 +2577,20 @@ int BC_ListBox::button_press_event() result = 1; } else - if(data) // Pressed over nothing. Start rectangle selection. - { - if(get_buttonpress() == 1 && - selection_mode == LISTBOX_MULTIPLE) - { - if(!shift_down()) - { + if( data ) { + if( get_buttonpress() == 1 && + selection_mode == LISTBOX_MULTIPLE ) { + if( !shift_down() ) { // Deselect all and redraw if anything was selected - if(get_selection_number(0, 0) >= 0) - { + if( get_selection_number(0, 0) >= 0 ) { set_all_selected(data, 0); draw_items(1); do_selection_change = 1; result = 1; } } - else - { + else { // Promote selections to protect from a rectangle selection promote_selections(data, 1, 2); } @@ -3063,19 +2607,16 @@ int BC_ListBox::button_press_event() } else // Suggestion box is not active but visible, so lie to get it to deactivate - if(is_popup && (active || (is_suggestions && gui))) - { + if( is_popup && (active || (is_suggestions && gui)) ) { active = 1; - if(debug) printf("BC_ListBox::button_press_event %d\n", __LINE__); + if( debug ) printf("BC_ListBox::button_press_event %d\n", __LINE__); deactivate(); result = 1; } - if(do_selection_change) selection_changed(); - if(debug) printf("BC_ListBox::button_press_event %d %d\n", - __LINE__, - result); + if( do_selection_change ) selection_changed(); + if( debug ) printf("BC_ListBox::button_press_event %d %d\n", __LINE__, result); return result; } @@ -3088,141 +2629,124 @@ int BC_ListBox::button_release_event() new_value = 0; //printf("BC_ListBox::button_release_event 1 %d\n", current_operation); - switch(current_operation) - { - case DRAG_DIVISION: - current_operation = NO_OPERATION; - result = 1; - break; + switch( current_operation ) { + case DRAG_DIVISION: + current_operation = NO_OPERATION; + result = 1; + break; - case WHEEL: - current_operation = NO_OPERATION; - result = 1; - break; + case WHEEL: + current_operation = NO_OPERATION; + result = 1; + break; // Release item selection - case BUTTON_DOWN_SELECT: - case SELECT: + case BUTTON_DOWN_SELECT: + case SELECT: //printf("BC_ListBox::button_release_event 10\n"); - unset_repeat(get_resources()->scroll_repeat); - current_operation = NO_OPERATION; - if( gui ) { - translate_coordinates(top_level->event_win, gui->win, - gui->get_cursor_x(), gui->get_cursor_y(), - &cursor_x, &cursor_y); - selection_number1 = selection_number = - get_cursor_item(data, cursor_x, cursor_y); + unset_repeat(get_resources()->scroll_repeat); + current_operation = NO_OPERATION; + if( gui ) { + translate_coordinates(top_level->event_win, gui->win, + gui->get_cursor_x(), gui->get_cursor_y(), + &cursor_x, &cursor_y); + selection_number1 = selection_number = + get_cursor_item(data, cursor_x, cursor_y); //printf("BC_ListBox::button_release_event %d %d\n", selection_number2, selection_number1); - } + } - if(is_popup) - { - button_releases++; - if(selection_number >= 0) - { - deactivate(); - do_event = 1; - } - else -// Second button release outside button - if(button_releases > 1) - { - deactivate(); - } + if( is_popup ) { + button_releases++; + if( selection_number >= 0 ) { + deactivate(); + do_event = 1; } else - { - if(top_level->get_double_click() && - selection_number2 == selection_number1 && - selection_number2 >= 0 && - selection_number1 >= 0) - { - do_event = 1; - } - result = 1; +// Second button release outside button + if( button_releases > 1 ) { + deactivate(); } - break; + } + else { + if( top_level->get_double_click() && + selection_number2 == selection_number1 && + selection_number2 >= 0 && selection_number1 >= 0 ) { + do_event = 1; + } + result = 1; + } + break; - case SELECT_RECT: - unset_repeat(get_resources()->scroll_repeat); - if(data) - { + case SELECT_RECT: + unset_repeat(get_resources()->scroll_repeat); + if( data ) { // Demote selections from rectangle selection - promote_selections(data, 2, 1); - } + promote_selections(data, 2, 1); + } // Hide rectangle overlay - draw_rectangle(1); - current_operation = NO_OPERATION; - result = 1; - break; + draw_rectangle(1); + current_operation = NO_OPERATION; + result = 1; + break; // Release popup button - case BUTTON_DN: - hide_tooltip(); - current_operation = NO_OPERATION; - button_releases++; - draw_button(1); + case BUTTON_DN: + hide_tooltip(); + current_operation = NO_OPERATION; + button_releases++; + draw_button(1); // Second button release inside button - if(button_releases > 1) - { - deactivate(); - } - result = 1; - break; + if( button_releases > 1 ) { + deactivate(); + } + result = 1; + break; - case COLUMN_DN: - current_operation = NO_OPERATION; + case COLUMN_DN: + current_operation = NO_OPERATION; // Update the sort column and the sort order for the user only if the existing // sort column is valid. - if(sort_column >= 0) - { + if( sort_column >= 0 ) { // Invert order only if column is the same - if(highlighted_title == sort_column) - sort_order = - (sort_order == SORT_ASCENDING) ? - SORT_DESCENDING : - SORT_ASCENDING; + if( highlighted_title == sort_column ) + sort_order = sort_order == SORT_ASCENDING ? + SORT_DESCENDING : SORT_ASCENDING; // Set the new sort column - sort_column = highlighted_title; - if(!sort_order_event()) - { - draw_titles(1); - } - } - else -// Sorting not enabled. Redraw the title state. - { + sort_column = highlighted_title; + if( !sort_order_event() ) { draw_titles(1); } - result = 1; - break; - - case EXPAND_DN: + } + else +// Sorting not enabled. Redraw the title state. { - int redraw_toggles = 0; - for(int i = 0; i < expanders.total && !result; i++) - { - if(expanders.values[i]->button_release_event(&redraw_toggles)) - { - result = 1; - } + draw_titles(1); + } + result = 1; + break; + + case EXPAND_DN: { + int redraw_toggles = 0; + for( int i = 0; i < expanders.total && !result; i++ ) { + if( expanders.values[i]->button_release_event(&redraw_toggles) ) { + result = 1; } -// Need to redraw items because of alpha - if(redraw_toggles) draw_items(1); - current_operation = NO_OPERATION; - break; } +// Need to redraw items because of alpha + if( redraw_toggles ) draw_items(1); + current_operation = NO_OPERATION; + break; } - default: + default: // Can't default to NO_OPERATION because it may be used in a drag event. - break; + break; } - if(do_event) handle_event(); + if( do_event ) handle_event(); //printf("BC_ListBox::button_release_event %d %d\n", __LINE__, get_window_lock()); return result; @@ -3230,44 +2754,34 @@ int BC_ListBox::button_release_event() int BC_ListBox::get_title_h() { - if(display_format == LISTBOX_TEXT || - display_format == LISTBOX_ICON_LIST) + if( display_format == LISTBOX_TEXT || + display_format == LISTBOX_ICON_LIST ) return column_titles ? column_bg[0]->get_h() : 0; - else - return 0; + return 0; } void BC_ListBox::reset_cursor(int new_cursor) { - if(is_popup) - { - if(gui->get_cursor() != new_cursor) - { + if( is_popup ) { + if( gui->get_cursor() != new_cursor ) { gui->set_cursor(new_cursor, 0, 0); } } else - if(get_cursor() != new_cursor) - { + if( get_cursor() != new_cursor ) { set_cursor(new_cursor, 0, 0); } } int BC_ListBox::test_column_divisions(int cursor_x, int cursor_y, int &new_cursor) { - if(gui && - column_titles && - cursor_y >= 0 && - cursor_y < get_title_h() && - cursor_x >= 0 && - cursor_x < gui->get_w()) - { - for(int i = 1; i < columns; i++) - { - if(cursor_x >= -xposition + get_column_offset(i) - 5 && - cursor_x < -xposition + get_column_offset(i) + - get_resources()->listbox_title_hotspot) - { + if( gui && column_titles && + cursor_y >= 0 && cursor_y < get_title_h() && + cursor_x >= 0 && cursor_x < gui->get_w() ) { + for( int i = 1; i < columns; i++ ) { + if( cursor_x >= -xposition + get_column_offset(i) - 5 && + cursor_x < -xposition + get_column_offset(i) + + get_resources()->listbox_title_hotspot ) { highlighted_item = -1; highlighted_ptr = 0; highlighted_division = i; @@ -3284,19 +2798,13 @@ int BC_ListBox::test_column_divisions(int cursor_x, int cursor_y, int &new_curso int BC_ListBox::test_column_titles(int cursor_x, int cursor_y) { - if(gui && - column_titles && - cursor_y >= 0 && - cursor_y < get_title_h() && - cursor_x >= 0 && - cursor_x < gui->get_w()) - { - for(int i = 0; i < columns; i++) - { - if(cursor_x >= -xposition + get_column_offset(i) && + if( gui && column_titles && + cursor_y >= 0 && cursor_y < get_title_h() && + cursor_x >= 0 && cursor_x < gui->get_w() ) { + for( int i = 0; i < columns; i++ ) { + if( cursor_x >= -xposition + get_column_offset(i) && (cursor_x < -xposition + get_column_offset(i + 1) || - i == columns - 1)) - { + i == columns - 1) ) { highlighted_item = -1; highlighted_ptr = 0; highlighted_division = -1; @@ -3312,10 +2820,8 @@ int BC_ListBox::test_column_titles(int cursor_x, int cursor_y) int BC_ListBox::test_expanders() { - for(int i = 0; i < expanders.total; i++) - { - if(expanders.values[i]->button_press_event()) - { + for( int i = 0; i < expanders.total; i++ ) { + if( expanders.values[i]->button_press_event() ) { current_operation = EXPAND_DN; draw_toggles(1); return 1; @@ -3332,406 +2838,336 @@ int BC_ListBox::cursor_motion_event() selection_number = -1; - switch(current_operation) - { - case BUTTON_DN: + switch( current_operation ) { + case BUTTON_DN: // Button pressed and slid off button - if(!cursor_inside()) - { - current_operation = BUTTON_DOWN_SELECT; - draw_button(1); - result = 1; - } - break; + if( !cursor_inside() ) { + current_operation = BUTTON_DOWN_SELECT; + draw_button(1); + result = 1; + } + break; - case DRAG_DIVISION: - { -// int new_w = get_cursor_x() + -// xposition - -// get_column_offset(highlighted_division - 1); - int difference = get_cursor_x() + xposition - drag_cursor_x; - int new_w = drag_column_w + difference; + case DRAG_DIVISION: { +// int new_w = get_cursor_x() + +// xposition - +// get_column_offset(highlighted_division - 1); + int difference = get_cursor_x() + xposition - drag_cursor_x; + int new_w = drag_column_w + difference; - new_cursor = HSEPARATE_CURSOR; + new_cursor = HSEPARATE_CURSOR; - if(column_width) - { - column_width[highlighted_division - 1] = new_w; - } - else - { - default_column_width[highlighted_division - 1] = new_w; - } + if( column_width ) { + column_width[highlighted_division - 1] = new_w; + } + else { + default_column_width[highlighted_division - 1] = new_w; + } - column_width_boundaries(); + column_width_boundaries(); // Force update of coords - set_autoplacement(data, 0, 1); - column_resize_event(); + set_autoplacement(data, 0, 1); + column_resize_event(); - clamp_positions(); - draw_items(0); - update_scrollbars(1); - result = 1; - break; - } + clamp_positions(); + draw_items(0); + update_scrollbars(1); + result = 1; + break; } - case SELECT_RECT: - { - if(test_drag_scroll(get_cursor_x(), get_cursor_y())) - { - set_repeat(get_resources()->scroll_repeat); - } + case SELECT_RECT: { + if( test_drag_scroll(get_cursor_x(), get_cursor_y()) ) { + set_repeat(get_resources()->scroll_repeat); + } - int old_x1 = MIN(rect_x1, rect_x2); - int old_x2 = MAX(rect_x1, rect_x2); - int old_y1 = MIN(rect_y1, rect_y2); - int old_y2 = MAX(rect_y1, rect_y2); + int old_x1 = MIN(rect_x1, rect_x2); + int old_x2 = MAX(rect_x1, rect_x2); + int old_y1 = MIN(rect_y1, rect_y2); + int old_y2 = MAX(rect_y1, rect_y2); - int new_rect_x2 = get_cursor_x(); - int new_rect_y2 = get_cursor_y(); + int new_rect_x2 = get_cursor_x(); + int new_rect_y2 = get_cursor_y(); - int x1 = MIN(rect_x1, new_rect_x2); - int x2 = MAX(rect_x1, new_rect_x2); - int y1 = MIN(rect_y1, new_rect_y2); - int y2 = MAX(rect_y1, new_rect_y2); + int x1 = MIN(rect_x1, new_rect_x2); + int x2 = MAX(rect_x1, new_rect_x2); + int y1 = MIN(rect_y1, new_rect_y2); + int y2 = MAX(rect_y1, new_rect_y2); // Adjust rectangle coverage - if(old_x1 != x1 || - old_x2 != x2 || - old_y1 != y1 || - old_y2 != y2) - { - if(data) - { - redraw = select_rectangle(data, - x1, - y1, - x2, - y2); - } + if( old_x1 != x1 || old_x2 != x2 || + old_y1 != y1 || old_y2 != y2 ) { + if( data ) { + redraw = select_rectangle(data, x1, y1, x2, y2); + } // hide rectangle - if(!redraw) - { + if( !redraw ) { //printf("BC_ListBox::cursor_motion_event %d\n", __LINE__); - draw_rectangle(0); - } + draw_rectangle(0); } + } - rect_x2 = get_cursor_x(); - rect_y2 = get_cursor_y(); - if(redraw) - { - clamp_positions(); - draw_items(0); - update_scrollbars(1); - selection_changed(); + rect_x2 = get_cursor_x(); + rect_y2 = get_cursor_y(); + if( redraw ) { + clamp_positions(); + draw_items(0); + update_scrollbars(1); + selection_changed(); //printf("BC_ListBox::cursor_motion_event %d\n", __LINE__); - } - else - if(old_x1 != x1 || - old_x2 != x2 || - old_y1 != y1 || - old_y2 != y2) - { + } + else + if( old_x1 != x1 || old_x2 != x2 || + old_y1 != y1 || old_y2 != y2 ) { //printf("BC_ListBox::cursor_motion_event %d\n", __LINE__); - draw_rectangle(1); - } - - result = 1; - break; + draw_rectangle(1); } - case SELECT: - { - int old_highlighted_item = highlighted_item; + result = 1; + break; } - if(test_drag_scroll(get_cursor_x(), - get_cursor_y())) - { - set_repeat(get_resources()->scroll_repeat); - } + case SELECT: { + int old_highlighted_item = highlighted_item; + if( test_drag_scroll(get_cursor_x(), + get_cursor_y()) ) { + set_repeat(get_resources()->scroll_repeat); + } - highlighted_item = selection_number = get_cursor_item(data, - get_cursor_x(), - get_cursor_y(), - &highlighted_ptr); - result = 1; + + highlighted_item = selection_number = get_cursor_item(data, + get_cursor_x(), get_cursor_y(), &highlighted_ptr); + result = 1; // Deselect all items and select just the one we're over - if(selection_number >= 0 && - !allow_drag && - ((!shift_down() && - !ctrl_down()) || - selection_mode == LISTBOX_SINGLE)) - { - redraw = update_selection(data, selection_number); - } - else - if(selection_mode == LISTBOX_MULTIPLE && - (shift_down() || ctrl_down())) + if( selection_number >= 0 && !allow_drag && + ((!shift_down() && !ctrl_down()) || + selection_mode == LISTBOX_SINGLE) ) { + redraw = update_selection(data, selection_number); + } + else // Expand multiple selection - { + if( selection_mode == LISTBOX_MULTIPLE && + (shift_down() || ctrl_down()) ) { // Expand selected region in text mode centered around initial range - if((display_format == LISTBOX_TEXT || - display_format == LISTBOX_ICON_LIST) && - shift_down()) - { + if( (display_format == LISTBOX_TEXT || + display_format == LISTBOX_ICON_LIST) && + shift_down() ) { // Deselect everything. - set_all_selected(data, 0); + set_all_selected(data, 0); // Select just the items - redraw = expand_selection(0, selection_number); - } - else + redraw = expand_selection(0, selection_number); + } // Set the one item we're over to the selection value determined in // button_press_event. - { - set_selected(data, - selection_number, - new_value); - } + else { + set_selected(data, selection_number, new_value); } + } - if(highlighted_item != old_highlighted_item) - { - clamp_positions(); - draw_items(0); - update_scrollbars(1); + if( highlighted_item != old_highlighted_item ) { + clamp_positions(); + draw_items(0); + update_scrollbars(1); //printf("BC_ListBox::cursor_motion_event %d %d\n", highlighted_item, old_highlighted_item); - selection_changed(); - } - break; + selection_changed(); } + break; } - case BUTTON_DOWN_SELECT: + case BUTTON_DOWN_SELECT: // Went back into button area - if(cursor_inside()) - { - current_operation = BUTTON_DN; - draw_button(1); - result = 1; - } - else + if( cursor_inside() ) { + current_operation = BUTTON_DN; + draw_button(1); + result = 1; + } + else // Went into item area - if(gui) - { - int cursor_x = 0, cursor_y = 0; - translate_coordinates(top_level->event_win, - gui->win, - top_level->cursor_x, - top_level->cursor_y, - &cursor_x, - &cursor_y); - int old_highlighted_item = highlighted_item; - highlighted_item = selection_number = get_cursor_item(data, - cursor_x, - cursor_y, - &highlighted_ptr); - - if(highlighted_item != old_highlighted_item) - { - update_selection(data, selection_number); - draw_items(1); - selection_changed(); - } - } - break; + if( gui ) { + int cursor_x = 0, cursor_y = 0; + translate_coordinates(top_level->event_win, gui->win, + top_level->cursor_x, top_level->cursor_y, + &cursor_x, &cursor_y); + int old_highlighted_item = highlighted_item; + highlighted_item = selection_number = get_cursor_item(data, + cursor_x, + cursor_y, + &highlighted_ptr); - case EXPAND_DN: - { - int redraw_toggles = 0; - for(int i = 0; i < expanders.total && !result; i++) - { - result = expanders.values[i]->cursor_motion_event( - &redraw_toggles); - } - if(redraw_toggles) - { -// Need to redraw items because of the alpha + if( highlighted_item != old_highlighted_item ) { + update_selection(data, selection_number); draw_items(1); + selection_changed(); } - break; } + break; - case NO_OPERATION: - { - int cursor_x = get_cursor_x(), cursor_y = get_cursor_y(); - if(gui && top_level->event_win == gui->win) - { - int old_highlighted_title = highlighted_title; - int old_list_highlighted = list_highlighted; - int old_highlighted_item = highlighted_item; - int redraw_titles = 0; - int redraw_border = 0; - int redraw_items = 0; - int redraw_toggles = 0; - result = 1; + case EXPAND_DN: { + int redraw_toggles = 0; + for( int i = 0; i < expanders.total && !result; i++ ) { + result = expanders.values[i]->cursor_motion_event( + &redraw_toggles); + } + if( redraw_toggles ) { +// Need to redraw items because of the alpha + draw_items(1); + } + break; } + case NO_OPERATION: { + int cursor_x = get_cursor_x(), cursor_y = get_cursor_y(); + if( gui && top_level->event_win == gui->win ) { + int old_highlighted_title = highlighted_title; + int old_list_highlighted = list_highlighted; + int old_highlighted_item = highlighted_item; + int redraw_titles = 0; + int redraw_border = 0; + int redraw_items = 0; + int redraw_toggles = 0; + result = 1; // Test if cursor moved over a title division - test_column_divisions(cursor_x, cursor_y, new_cursor); + test_column_divisions(cursor_x, cursor_y, new_cursor); // Test if cursor moved over a title - if(highlighted_division < 0) - { - test_column_titles(cursor_x, cursor_y); - } + if( highlighted_division < 0 ) { + test_column_titles(cursor_x, cursor_y); + } // Test if cursor moved over expander - if(highlighted_division < 0 && - highlighted_title < 0 && - (display_format == LISTBOX_TEXT || - display_format == LISTBOX_ICON_LIST)) - { - for(int i = 0; i < expanders.total; i++) - { - expanders.values[i]->cursor_motion_event( - &redraw_toggles); - } -//printf("BC_ListBox::cursor_motion_event %d\n", redraw_toggles); + if( highlighted_division < 0 && highlighted_title < 0 && + (display_format == LISTBOX_TEXT || + display_format == LISTBOX_ICON_LIST) ) { + for( int i = 0; i < expanders.total; i++ ) { + expanders.values[i]->cursor_motion_event( + &redraw_toggles); } +//printf("BC_ListBox::cursor_motion_event %d\n", redraw_toggles); + } // Test if cursor moved over an item - if(highlighted_division < 0 && - highlighted_title < 0) - { - highlighted_item = get_cursor_item(data, - cursor_x, - cursor_y, - &highlighted_ptr); - } + if( highlighted_division < 0 && highlighted_title < 0 ) { + highlighted_item = get_cursor_item(data, + cursor_x, + cursor_y, + &highlighted_ptr); + } // Clear title highlighting if moved over division - if(old_highlighted_title != highlighted_title) - { - redraw_titles = 1; - } + if( old_highlighted_title != highlighted_title ) { + redraw_titles = 1; + } // Highlight list border - if(old_list_highlighted != list_highlighted) - { - redraw_border = 1; - } + if( old_list_highlighted != list_highlighted ) { + redraw_border = 1; + } // Moved out of item area - if(old_highlighted_item != highlighted_item) - { - redraw_items = 1; - } + if( old_highlighted_item != highlighted_item ) { + redraw_items = 1; + } //printf("BC_ListBox::cursor_motion_event 1 %d\n", highlighted_item); // Change cursor to title division adjustment - reset_cursor(new_cursor); + reset_cursor(new_cursor); - if(redraw_items) - { - draw_items(0); - } - else - { - if(redraw_titles) - draw_titles(0); - if(redraw_border) - draw_border(0); - if(redraw_toggles) - draw_toggles(0); - } + if( redraw_items ) { + draw_items(0); + } + else { + if( redraw_titles ) + draw_titles(0); + if( redraw_border ) + draw_border(0); + if( redraw_toggles ) + draw_toggles(0); + } - if(redraw_items || - redraw_titles || - redraw_border || - redraw_toggles) - { - gui->flash(); - gui->flush(); - } + if( redraw_items || redraw_titles || + redraw_border || redraw_toggles ) { + gui->flash(); + gui->flush(); } + } - if(!result && list_highlighted) - { - list_highlighted = 0; - highlighted_item = -1; - highlighted_ptr = 0; - highlighted_title = -1; - highlighted_division = -1; - draw_items(1); - result = 0; - } - break; + if( !result && list_highlighted ) { + list_highlighted = 0; + highlighted_item = -1; + highlighted_ptr = 0; + highlighted_title = -1; + highlighted_division = -1; + draw_items(1); + result = 0; } + break; } } - return result; } int BC_ListBox::drag_start_event() { - switch(current_operation) - { - case SELECT: - if( gui && gui->is_event_win() && allow_drag ) - { - BC_ListBoxItem *item_return = 0; - selection_number = get_cursor_item(data, - top_level->cursor_x, - top_level->cursor_y, - &item_return); - - if(selection_number >= 0) - { - int cx, cy; - get_abs_cursor_xy(cx, cy); - if( item_return->icon_vframe ) { - cx -= item_return->icon_vframe->get_w() / 2, - cy -= item_return->icon_vframe->get_h() / 2; - drag_popup = new BC_DragWindow(this, - item_return->icon_vframe, cx, cy); - } - else -// this probably works not! - if( item_return->icon ) { - cx -= item_return->icon->get_w() / 2, - cy -= item_return->icon->get_h() / 2; - drag_popup = new BC_DragWindow(this, - item_return->icon, cx, cy); - } - else { - cx -= drag_icon_vframe->get_w() / 2, - cy -= drag_icon_vframe->get_h() / 2; - drag_popup = new BC_DragWindow(this, - drag_icon_vframe, cx, cy); - } - current_operation = DRAG_ITEM; -// require shift down for scrolling - if( allow_drag < 0 && shift_down() ) - set_repeat(get_resources()->scroll_repeat); - return 1; - } - } - break; + switch( current_operation ) { + case SELECT: + if( gui && gui->is_event_win() && allow_drag ) { + BC_ListBoxItem *item_return = 0; + selection_number = get_cursor_item(data, + top_level->cursor_x, + top_level->cursor_y, + &item_return); - case COLUMN_DN: - if(gui && gui->is_event_win() && allow_drag_column) - { + if( selection_number >= 0 ) { int cx, cy; - get_abs_cursor_xy(cx, cy); - cx -= drag_column_icon_vframe->get_w() / 2, - cy -= drag_column_icon_vframe->get_h() / 2; - drag_popup = new BC_DragWindow(this, - drag_column_icon_vframe, cx, cy); - dragged_title = highlighted_title; - current_operation = COLUMN_DRAG; - draw_titles(1); + get_abs_cursor(cx, cy); + if( item_return->icon_vframe ) { + cx -= item_return->icon_vframe->get_w() / 2, + cy -= item_return->icon_vframe->get_h() / 2; + drag_popup = new BC_DragWindow(this, + item_return->icon_vframe, cx, cy); + } + else +// this probably works not! + if( item_return->icon ) { + cx -= item_return->icon->get_w() / 2, + cy -= item_return->icon->get_h() / 2; + drag_popup = new BC_DragWindow(this, + item_return->icon, cx, cy); + } + else { + cx -= drag_icon_vframe->get_w() / 2, + cy -= drag_icon_vframe->get_h() / 2; + drag_popup = new BC_DragWindow(this, + drag_icon_vframe, cx, cy); + } + current_operation = DRAG_ITEM; +// require shift down for scrolling + if( allow_drag < 0 && shift_down() ) + set_repeat(get_resources()->scroll_repeat); return 1; } - break; + } + break; + + case COLUMN_DN: + if( gui && gui->is_event_win() && allow_drag_column ) { + int cx, cy; + get_abs_cursor(cx, cy); + cx -= drag_column_icon_vframe->get_w() / 2, + cy -= drag_column_icon_vframe->get_h() / 2; + drag_popup = new BC_DragWindow(this, + drag_column_icon_vframe, cx, cy); + dragged_title = highlighted_title; + current_operation = COLUMN_DRAG; + draw_titles(1); + return 1; + } + break; } return 0; @@ -3740,122 +3176,106 @@ int BC_ListBox::drag_start_event() int BC_ListBox::drag_motion_event() { //printf("BC_ListBox::drag_motion_event 1 %d\n", current_operation); - switch(current_operation) - { - case DRAG_ITEM: - { - int redraw = 0; - int new_highlighted_item = -1; - BC_ListBoxItem *new_highlighted_ptr = 0; - new_highlighted_item = get_cursor_item(data, - top_level->cursor_x, top_level->cursor_y, - &new_highlighted_ptr); - - if(new_highlighted_item != highlighted_item) - { - redraw = 1; - } + switch( current_operation ) { + case DRAG_ITEM: { + int redraw = 0; + int new_highlighted_item = -1; + BC_ListBoxItem *new_highlighted_ptr = 0; + new_highlighted_item = get_cursor_item(data, + top_level->cursor_x, top_level->cursor_y, + &new_highlighted_ptr); + + if( new_highlighted_item != highlighted_item ) { + redraw = 1; + } // Always update highlighted value for drag_stop - highlighted_item = new_highlighted_item; - highlighted_ptr = new_highlighted_ptr; + highlighted_item = new_highlighted_item; + highlighted_ptr = new_highlighted_ptr; //printf("BC_ListBox::drag_motion_event 1 %p\n", highlighted_ptr); - if(redraw) - { - clamp_positions(); - draw_items(0); - update_scrollbars(1); - } - - return drag_popup->cursor_motion_event(); + if( redraw ) { + clamp_positions(); + draw_items(0); + update_scrollbars(1); } - case COLUMN_DRAG: - { - int old_highlighted_title = highlighted_title; - test_column_titles(get_cursor_x(), get_cursor_y()); - if(old_highlighted_title != highlighted_title) - { - draw_titles(1); - } - return drag_popup->cursor_motion_event(); + return drag_popup->cursor_motion_event(); } + + case COLUMN_DRAG: { + int old_highlighted_title = highlighted_title; + test_column_titles(get_cursor_x(), get_cursor_y()); + if( old_highlighted_title != highlighted_title ) { + draw_titles(1); } + return drag_popup->cursor_motion_event(); } } + return 0; } int BC_ListBox::drag_stop_event() { - switch(current_operation) - { - case DRAG_ITEM: - unset_repeat(get_resources()->scroll_repeat); + switch( current_operation ) { + case DRAG_ITEM: + unset_repeat(get_resources()->scroll_repeat); // Inside window boundary - if(top_level->cursor_x > 0 && - top_level->cursor_x < gui->get_w() - drag_popup->get_w() / 2 && - top_level->cursor_y > 0 && - top_level->cursor_y < gui->get_h() - drag_popup->get_h() / 2) - { + if( top_level->cursor_x > 0 && + top_level->cursor_x < gui->get_w() - drag_popup->get_w() / 2 && + top_level->cursor_y > 0 && + top_level->cursor_y < gui->get_h() - drag_popup->get_h() / 2 ) { // Move icon - if(display_format == LISTBOX_ICONS) - { - reposition_item(data, - selection_number, - top_level->cursor_x + drag_popup->get_offset_x() - - LISTBOX_MARGIN - 2 + xposition, - top_level->cursor_y + drag_popup->get_offset_y() - - LISTBOX_MARGIN - 2 + yposition); - } - else + if( display_format == LISTBOX_ICONS ) { + reposition_item(data, + selection_number, + top_level->cursor_x + drag_popup->get_offset_x() - + LISTBOX_MARGIN - 2 + xposition, + top_level->cursor_y + drag_popup->get_offset_y() - + LISTBOX_MARGIN - 2 + yposition); + } + else // Move rows - if(process_drag) - { + if( process_drag ) { // Move selected items from data to temporary - ArrayList *src_items = - new ArrayList[columns]; - move_selection(src_items, data); + ArrayList *src_items = + new ArrayList[columns]; + move_selection(src_items, data); // Get destination - int destination = highlighted_item = item_to_index(data, - highlighted_ptr); + int destination = highlighted_item = item_to_index(data, + highlighted_ptr); // Insert items from temporary to data - put_selection(data, src_items, destination); + put_selection(data, src_items, destination); - delete [] src_items; - set_autoplacement(data, 0, 1); - } + delete [] src_items; + set_autoplacement(data, 0, 1); + } + draw_items(1); + } + else + drag_popup->drag_failure_event(); - draw_items(1); + delete drag_popup; + flush(); + drag_popup = 0; + current_operation = NO_OPERATION; + new_value = 0; + return 1; + + case COLUMN_DRAG: + if( dragged_title != highlighted_title ) { + if( highlighted_title >= 0 ) { + if( !move_column_event() ) draw_titles(1); } else drag_popup->drag_failure_event(); - - delete drag_popup; - flush(); - drag_popup = 0; - current_operation = NO_OPERATION; - new_value = 0; - return 1; - break; - - case COLUMN_DRAG: - if(dragged_title != highlighted_title) - { - if(highlighted_title >= 0) - { - if(!move_column_event()) draw_titles(1); - } - else - drag_popup->drag_failure_event(); - } - current_operation = NO_OPERATION; - delete drag_popup; - flush(); - drag_popup = 0; - return 1; - break; + } + current_operation = NO_OPERATION; + delete drag_popup; + flush(); + drag_popup = 0; + return 1; } return 0; } @@ -3867,8 +3287,7 @@ BC_DragWindow* BC_ListBox::get_drag_popup() int BC_ListBox::translation_event() { - if(is_popup && gui) - { + if( is_popup && gui ) { int new_x = gui->get_x() + (top_level->last_translate_x - top_level->prev_x - BC_DisplayInfo::get_left_border()); @@ -3884,26 +3303,23 @@ int BC_ListBox::translation_event() int BC_ListBox::reposition_window(int x, int y, int w, int h, int flush) { - if(w != -1) - { - if(w != -1) popup_w = w; - if(h != -1) popup_h = h; + if( w != -1 ) { + popup_w = w; + if( h != -1 ) popup_h = h; //printf("BC_ListBox::reposition_window %d %d\n", popup_w, popup_h); - if(!is_popup) - { - if(xscrollbar) + if( !is_popup ) { + if( xscrollbar ) xscrollbar->reposition_window(get_xscroll_x(), get_xscroll_y(), get_xscroll_width()); - if(yscrollbar) + if( yscrollbar ) yscrollbar->reposition_window(get_yscroll_x(), get_yscroll_y(), get_yscroll_height()); } } - BC_WindowBase::reposition_window(x, y, w, h); draw_button(0); draw_items(flush); @@ -3914,30 +3330,20 @@ int BC_ListBox::deactivate() { hide_tooltip(); // printf("BC_ListBox::deactivate %d this=%p gui=%p active=%d\n", -// __LINE__, -// this, -// gui, -// active); - if(active) - { - - if(is_popup) - { +// __LINE__, this, gui, active); + if( active ) { + if( is_popup ) { //printf("BC_ListBox::deactivate %d this=%p gui=%p\n", __LINE__, this, gui); - if(gui) - { - delete gui; + if( gui ) { + delete gui; gui = 0; flush(); } - gui = 0; xscrollbar = 0; yscrollbar = 0; highlighted_item = -1; highlighted_ptr = 0; //sleep(1); } - - //printf("BC_ListBox::deactivate %d this=%p\n", __LINE__, this); active = 0; top_level->active_subwindow = 0; @@ -3970,8 +3376,8 @@ int BC_ListBox::activate(int x, int y, int w, int h) { if( !is_popup || gui ) return 0; active = 1; - if(w != -1) popup_w = w; - if(h != -1) popup_h = h; + if( w != -1 ) popup_w = w; + if( h != -1 ) popup_h = h; reset_query(); if( y + popup_h > top_level->get_root_h(0) ) y -= get_h() + popup_h; @@ -3989,7 +3395,7 @@ int BC_ListBox::is_active() int BC_ListBox::keypress_event() { - if(!active) return 0; + if( !active ) return 0; //printf("BC_ListBox::keypress_event %d\n", __LINE__); @@ -3998,132 +3404,121 @@ int BC_ListBox::keypress_event() if( view_items <= 0 ) view_items = view_h / get_text_height(MEDIUMFONT); int new_item = -1, new_selection = -1; - switch(top_level->get_keypress()) - { - case ESC: - case RETURN: - top_level->deactivate(); + switch( top_level->get_keypress() ) { + case ESC: + case RETURN: + top_level->deactivate(); // If user is manipulating popup with keyboard, don't pass on event. - if(is_popup) - { + if( is_popup ) { //printf("BC_ListBox::keypress_event %d %p\n", __LINE__, get_selection(0, 0)); - if(top_level->get_keypress() == RETURN) - handle_event(); + if( top_level->get_keypress() == RETURN ) + handle_event(); //printf("BC_ListBox::keypress_event %d %p\n", __LINE__, get_selection(0, 0)); - result = 1; - } - else - result = 0; - break; + result = 1; + } + else + result = 0; + break; - case UP: - new_selection = new_item = select_previous(0); + case UP: + new_selection = new_item = select_previous(0); //printf("BC_ListBox::keypress_event 1 %d\n", new_item); - if(new_item >= 0) - { - center_selection(new_item); - redraw = 1; - } - reset_query(); - result = 1; - break; - - case DOWN: - new_selection = new_item = select_next(0); + if( new_item >= 0 ) { + center_selection(new_item); + redraw = 1; + } + reset_query(); + result = 1; + break; - if(new_item >= 0) - { - center_selection(new_item); - redraw = 1; - } - reset_query(); - result = 1; - break; + case DOWN: + new_selection = new_item = select_next(0); - case PGUP: - new_selection = new_item = select_previous(view_items - 1); + if( new_item >= 0 ) { + center_selection(new_item); + redraw = 1; + } + reset_query(); + result = 1; + break; - if(new_item >= 0) - { - center_selection(new_item); - redraw = 1; - } - reset_query(); - result = 1; - break; + case PGUP: + new_selection = new_item = select_previous(view_items - 1); - case PGDN: - new_selection = new_item = select_next(view_items - 1); + if( new_item >= 0 ) { + center_selection(new_item); + redraw = 1; + } + reset_query(); + result = 1; + break; - if(new_item >= 0) - { - center_selection(new_item); - redraw = 1; - } - reset_query(); - result = 1; - break; + case PGDN: + new_selection = new_item = select_next(view_items - 1); - case LEFT: - xposition -= 10; + if( new_item >= 0 ) { + center_selection(new_item); redraw = 1; - result = 1; - break; + } + reset_query(); + result = 1; + break; - case RIGHT: - xposition += 10; - redraw = 1; - result = 1; - break; + case LEFT: + xposition -= 10; + redraw = 1; + result = 1; + break; - case DELETE: - case HOME: - case END: - result = 0; - break; + case RIGHT: + xposition += 10; + redraw = 1; + result = 1; + break; - default: - if(!ctrl_down()) - { - int query_len = strlen(query); - if( query_len < (int)sizeof(query)-1 && - top_level->get_keypress() > 30 && - top_level->get_keypress() < 127) - { - query[query_len++] = top_level->get_keypress(); - query[query_len] = 0; - new_selection = query_list(); - } + case DELETE: + case HOME: + case END: + result = 0; + break; + + default: + if( !ctrl_down() ) { + int query_len = strlen(query); + if( query_len < (int)sizeof(query)-1 && + top_level->get_keypress() > 30 && + top_level->get_keypress() < 127 ) { + query[query_len++] = top_level->get_keypress(); + query[query_len] = 0; + new_selection = query_list(); + } + else + if( top_level->get_keypress() == BACKSPACE ) { + if( query_len > 0 ) query[--query_len] = 0; + new_selection = query_list(); + } + if( show_query ) { + if( query_len > 0 ) + show_tooltip(query); else - if(top_level->get_keypress() == BACKSPACE) - { - if(query_len > 0) query[--query_len] = 0; - new_selection = query_list(); - } - if( show_query ) { - if( query_len > 0 ) - show_tooltip(query); - else - hide_tooltip(); - } - redraw = 1; - result = 1; + hide_tooltip(); } - break; + redraw = 1; + result = 1; + } + break; } - if(redraw) - { + if( redraw ) { clamp_positions(); draw_items(0); update_scrollbars(1); } //printf("BC_ListBox::keypress_event %d new_selection=%d\n", __LINE__, new_selection); - if(new_selection >= 0 && !is_suggestions) - { + if( new_selection >= 0 && !is_suggestions ) { //printf("BC_ListBox::keypress_event %d\n", __LINE__); selection_changed(); //printf("BC_ListBox::keypress_event %d\n", __LINE__); @@ -4148,7 +3543,7 @@ void BC_ListBox::draw_background() draw_box(0, 0, bg_surface->get_w(), bg_surface->get_h(), bg_surface); // Optional heroine pixmap - if(bg_pixmap) + if( bg_pixmap ) bg_surface->draw_pixmap(bg_pixmap, bg_surface->get_w() - top_level->get_resources()->listbox_bg->get_w(), 0); @@ -4175,40 +3570,32 @@ int BC_ListBox::get_format() int BC_ListBox::draw_items(int flush, int draw_bg) { - if(gui) - { + if( gui ) { BC_Resources *resources = get_resources(); //dump(data, columns); // Calculate items width calculate_item_coords(); - - // Create and destroy scrollbars as needed get_scrollbars(); - - if( bg_draw ) this->bg_draw = 1; draw_background(); first_in_view = -1; last_in_view = 0; // Icon display - if(display_format == LISTBOX_ICONS) - { + if( display_format == LISTBOX_ICONS ) { clear_listbox(2, 2 + title_h, view_w, view_h); set_font(MEDIUMFONT); - for(int i = 0; i < data[master_column].size(); i++) - { + for( int i = 0; i < data[master_column].size(); i++ ) { BC_ListBoxItem *item = data[master_column].get(i); - if(get_item_x(item) >= -get_item_w(item) && - get_item_x(item) < view_w && - get_item_y(item) >= -get_item_h(item) + title_h && - get_item_y(item) < view_h + title_h) - { + if( get_item_x(item) >= -get_item_w(item) && + get_item_x(item) < view_w && + get_item_y(item) >= -get_item_h(item) + title_h && + get_item_y(item) < view_h + title_h ) { item->set_in_view(1); if( first_in_view < 0 ) first_in_view = i; last_in_view = i; @@ -4220,9 +3607,7 @@ int BC_ListBox::draw_items(int flush, int draw_bg) get_icon_mask(item, icon_x, icon_y, icon_w, icon_h); get_text_mask(item, text_x, text_y, text_w, text_h); - - if(item_color != resources->listbox_inactive) - { + if( item_color != resources->listbox_inactive ) { gui->set_color(BLACK); gui->draw_rectangle(icon_x, icon_y, icon_w, icon_h); gui->set_color(item_color); @@ -4232,45 +3617,36 @@ int BC_ListBox::draw_items(int flush, int draw_bg) gui->set_color(item_color); gui->draw_box(text_x + 1, text_y + 1, text_w - 2, text_h - 2); - if(icon_position == ICON_LEFT) + if( icon_position == ICON_LEFT ) gui->draw_box(text_x - 1, text_y + 1, 2, text_h - 2); else - if(icon_position == ICON_TOP) + if( icon_position == ICON_TOP ) gui->draw_line(text_x + 1, text_y, text_x + icon_w - 2, text_y); - if(text_x + text_w < icon_x + icon_w) - { + if( text_x + text_w < icon_x + icon_w ) { gui->set_color(BLACK); - gui->draw_line(text_x + text_w, - icon_y + icon_h, - icon_x + icon_w, - icon_y + icon_h); + gui->draw_line(text_x + text_w, icon_y + icon_h, + icon_x + icon_w, icon_y + icon_h); } } - // Draw icons gui->set_color(get_item_color(data, 0, i)); - if(item->icon) + if( item->icon ) gui->pixmap->draw_pixmap(item->icon, - icon_x + ICON_MARGIN, - icon_y + ICON_MARGIN); - + icon_x + ICON_MARGIN, icon_y + ICON_MARGIN); gui->draw_text(text_x + ICON_MARGIN, - text_y + ICON_MARGIN + get_baseline(item), - item->text); + text_y + ICON_MARGIN + get_baseline(item), item->text); } else item->set_in_view(0); } } - else // Text display - { + else { // Draw one column at a time so text overruns don't go into the next column // clear column backgrounds int current_toggle = 0; - for(int j = 0; j < columns; j++) - { + for( int j = 0; j < columns; j++ ) { clear_listbox(LISTBOX_BORDER + get_column_offset(j) - xposition, LISTBOX_BORDER + title_h, get_column_width(j, 1), @@ -4280,8 +3656,7 @@ int BC_ListBox::draw_items(int flush, int draw_bg) } // Delete excess expanders - while(expanders.total > current_toggle) - { + while( expanders.total > current_toggle ) { expanders.remove_object(); } } @@ -4292,8 +3667,7 @@ int BC_ListBox::draw_items(int flush, int draw_bg) draw_titles(0); // Clear garbage from bottom right corner - if(xscrollbar && yscrollbar && is_popup) - { + if( xscrollbar && yscrollbar && is_popup ) { gui->draw_top_background(parent_window, popup_w - get_resources()->vscroll_data[SCROLL_HANDLE_UP]->get_w(), popup_h - get_resources()->hscroll_data[SCROLL_HANDLE_UP]->get_h(), @@ -4305,7 +3679,7 @@ int BC_ListBox::draw_items(int flush, int draw_bg) draw_border(0); - if(current_operation == SELECT_RECT) + if( current_operation == SELECT_RECT ) draw_rectangle(0); gui->flash(flush); @@ -4316,25 +3690,18 @@ int BC_ListBox::draw_items(int flush, int draw_bg) void BC_ListBox::draw_text_recursive(ArrayList *data, - int column, - int indent, - int *current_toggle) + int column, int indent, int *current_toggle) { - if(!data) return; - - + if( !data ) return; BC_Resources *resources = get_resources(); set_font(MEDIUMFONT); int subindent = 0; // Search for a branch and make room for toggle if there is one - if(column == 0) - { - for(int i = 0; i < data[column].size(); i++) - { - if(data[column].get(i)->get_sublist()) - { + if( column == 0 ) { + for( int i = 0; i < data[column].size(); i++ ) { + if( data[column].get(i)->get_sublist() ) { subindent = BC_WindowBase::get_resources()->listbox_expand[0]->get_w(); break; } @@ -4342,8 +3709,7 @@ void BC_ListBox::draw_text_recursive(ArrayList *data, } row_height = row_ascent = row_descent = 0; - for(int i = 0; i < data[column].total; i++) - { + for( int i = 0; i < data[column].total; i++ ) { BC_ListBoxItem *item = data[column].values[i]; int ht = get_text_h(item); if( ht > row_height ) row_height = ht; @@ -4353,25 +3719,22 @@ void BC_ListBox::draw_text_recursive(ArrayList *data, if( dt > row_descent ) row_ascent = bl; } - for(int i = 0; i < data[column].size(); i++) - { + for( int i = 0; i < data[column].size(); i++ ) { // Draw a row BC_ListBoxItem *item = data[column].values[i]; BC_ListBoxItem *first_item = data[master_column].values[i]; - if(get_item_y(item) >= -get_item_h(item) + title_h && - get_item_y(item) < view_h + title_h) - { + if( get_item_y(item) >= -get_item_h(item) + title_h && + get_item_y(item) < view_h + title_h ) { int row_color = get_item_highlight(data, 0, i); int x, y, w, h, column_width; get_text_mask(item, x, y, w, h); column_width = get_column_width(column, 1); - if(x + column_width > view_w + LISTBOX_BORDER * 2) + if( x + column_width > view_w + LISTBOX_BORDER * 2 ) column_width = view_w + LISTBOX_BORDER * 2 - x; - if(row_color != resources->listbox_inactive) - { + if( row_color != resources->listbox_inactive ) { gui->set_color(row_color); gui->draw_box(x, y, column_width, h); gui->set_color(BLACK); @@ -4389,13 +3752,9 @@ void BC_ListBox::draw_text_recursive(ArrayList *data, gui->set_color(get_item_color(data, column, i)); - if(column == 0 && display_format == LISTBOX_ICON_LIST) - { - if(item->icon) - { - gui->pixmap->draw_pixmap(item->icon, - x, - y); + if( column == 0 && display_format == LISTBOX_ICON_LIST ) { + if( item->icon ) { + gui->pixmap->draw_pixmap(item->icon, x, y); x += item->icon->get_w() + ICON_MARGIN; } } @@ -4413,30 +3772,21 @@ void BC_ListBox::draw_text_recursive(ArrayList *data, } // Update expander - if(column == 0 && - item->get_sublist() && - item->get_columns()) - { + if( column == 0 && item->get_sublist() && item->get_columns() ) { // Create new expander - if(*current_toggle >= expanders.total) - { + if( *current_toggle >= expanders.total ) { BC_ListBoxToggle *toggle = - new BC_ListBoxToggle(this, - item, - x + LISTBOX_BORDER + LISTBOX_MARGIN + indent, - y); + new BC_ListBoxToggle(this, item, + x + LISTBOX_BORDER + LISTBOX_MARGIN + indent, y); toggle->draw(0); expanders.append(toggle); } - else // Reposition existing expander - { + else { BC_ListBoxToggle *toggle = expanders.values[*current_toggle]; //printf("BC_ListBox::draw_text_recursive 1 %d\n", *current_toggle); toggle->update(item, - x + LISTBOX_BORDER + LISTBOX_MARGIN + indent, - y, - 0); + x + LISTBOX_BORDER + LISTBOX_MARGIN + indent, y, 0); } (*current_toggle)++; } @@ -4448,8 +3798,7 @@ void BC_ListBox::draw_text_recursive(ArrayList *data, item->set_in_view(0); // Descend into sublist - if(first_item->get_expand()) - { + if( first_item->get_expand() ) { draw_text_recursive(first_item->get_sublist(), column, indent + LISTBOX_INDENT, @@ -4458,27 +3807,19 @@ void BC_ListBox::draw_text_recursive(ArrayList *data, } } - - - int BC_ListBox::draw_border(int flash) { BC_Resources *resources = top_level->get_resources(); - gui->draw_3d_border(0, - 0, - view_w + LISTBOX_BORDER * 2, - view_h + title_h + LISTBOX_BORDER * 2, + gui->draw_3d_border(0, 0, + view_w + LISTBOX_BORDER * 2, view_h + title_h + LISTBOX_BORDER * 2, resources->listbox_border1, list_highlighted ? - resources->listbox_border2_hi : - resources->listbox_border2, + resources->listbox_border2_hi : resources->listbox_border2, list_highlighted ? - resources->listbox_border3_hi : - resources->listbox_border3, + resources->listbox_border3_hi : resources->listbox_border3, resources->listbox_border4); - if(flash) - { + if( flash ) { gui->flash(); gui->flush(); } @@ -4489,10 +3830,9 @@ void BC_ListBox::draw_title(int number) { // Column title background int image_number = 0; - if(number == highlighted_title) - { + if( number == highlighted_title ) { image_number = 1; - if(current_operation == COLUMN_DN) + if( current_operation == COLUMN_DN ) image_number = 2; } @@ -4511,7 +3851,7 @@ void BC_ListBox::draw_title(int number) column_titles[number]); // Column sort order - if(number == sort_column) { + if( number == sort_column ) { BC_Pixmap *src = sort_order == SORT_ASCENDING ? column_sort_dn : column_sort_up; @@ -4533,23 +3873,20 @@ void BC_ListBox::draw_title(int number) int BC_ListBox::draw_titles(int flash) { - if(column_titles && - (display_format == LISTBOX_TEXT || - display_format == LISTBOX_ICON_LIST)) - { + if( column_titles && + (display_format == LISTBOX_TEXT || + display_format == LISTBOX_ICON_LIST) ) { //printf("BC_ListBox::draw_titles 1 %d\n", highlighted_title); - for(int i = 0; i < columns; i++) - { - if(i != highlighted_title) + for( int i = 0; i < columns; i++ ) { + if( i != highlighted_title ) draw_title(i); } - if(highlighted_title >= 0) draw_title(highlighted_title); + if( highlighted_title >= 0 ) draw_title(highlighted_title); draw_border(0); } - if(flash) - { + if( flash ) { gui->flash(); } return 0; @@ -4557,14 +3894,12 @@ int BC_ListBox::draw_titles(int flash) void BC_ListBox::draw_toggles(int flash) { - for(int i = 0; i < expanders.total; i++) + for( int i = 0; i < expanders.total; i++ ) expanders.values[i]->draw(0); //printf("BC_ListBox::draw_toggles 1 %d\n", flash); - if(flash && expanders.total) - { + if( flash && expanders.total ) { gui->flash(); - gui->flush(); } } @@ -4575,7 +3910,7 @@ int BC_ListBox::draw_rectangle(int flash) int y1 = MIN(rect_y1, rect_y2); int y2 = MAX(rect_y1, rect_y2); - if(x1 == x2 || y1 == y2) return 0; + if( x1 == x2 || y1 == y2 ) return 0; gui->set_inverse(); gui->set_color(WHITE); @@ -4583,50 +3918,36 @@ int BC_ListBox::draw_rectangle(int flash) gui->set_opaque(); - if(flash) - { - gui->flash(1); + if( flash ) { + gui->flash(); } return 0; } -void BC_ListBox::dump(ArrayList *data, - int columns, - int indent, - int master_column) +void BC_ListBox::dump(ArrayList *data, int columns, + int indent, int master_column) { - if(!indent) - { + if( !indent ) { printf("BC_ListBox::dump 1\n"); } - for(int i = 0; i < data[master_column].total; i++) - { - for(int k = 0; k < indent; k++) + for( int i = 0; i < data[master_column].total; i++ ) { + for( int k = 0; k < indent; k++ ) printf(" "); - for(int j = 0; j < columns; j++) - { + for( int j = 0; j < columns; j++ ) { BC_ListBoxItem *item = data[j].values[i]; printf("%d,%d,%d=%s ", - item->get_text_x(), - item->get_text_y(), - item->autoplace_text, - item->get_text()); + item->get_text_x(), item->get_text_y(), + item->autoplace_text, item->get_text()); } printf("\n"); - if(data[master_column].values[i]->get_sublist()) - { + if( data[master_column].values[i]->get_sublist() ) { dump(data[master_column].values[i]->get_sublist(), data[master_column].values[i]->get_columns(), indent + 4, master_column); } } - - } - - - diff --git a/cinelerra-5.1/guicast/bcmenuitem.C b/cinelerra-5.1/guicast/bcmenuitem.C index f51a46d6..2c4469e4 100644 --- a/cinelerra-5.1/guicast/bcmenuitem.C +++ b/cinelerra-5.1/guicast/bcmenuitem.C @@ -202,7 +202,7 @@ int BC_MenuItem::dispatch_button_release(int &redraw) if( !result && menu_popup->cursor_inside() ) { int cursor_x, cursor_y; - menu_popup->get_popup()->get_relative_cursor_xy(cursor_x, cursor_y); + menu_popup->get_popup()->get_relative_cursor(cursor_x, cursor_y); if( cursor_x >= 0 && cursor_x < menu_popup->get_w() && cursor_y >= y && cursor_y < y + h ) { if(menu_bar) @@ -232,7 +232,7 @@ int BC_MenuItem::dispatch_motion_event(int &redraw) if( !result && menu_popup->cursor_inside() ) { int cursor_x, cursor_y; - menu_popup->get_popup()->get_relative_cursor_xy(cursor_x, cursor_y); + menu_popup->get_popup()->get_relative_cursor(cursor_x, cursor_y); if( cursor_x >= 0 && cursor_x < menu_popup->get_w() && cursor_y >= y && cursor_y < y + h) { // Highlight the item diff --git a/cinelerra-5.1/guicast/bcwindowbase.C b/cinelerra-5.1/guicast/bcwindowbase.C index 2794830f..b970cffd 100644 --- a/cinelerra-5.1/guicast/bcwindowbase.C +++ b/cinelerra-5.1/guicast/bcwindowbase.C @@ -1814,7 +1814,7 @@ int BC_WindowBase::show_tooltip(const char *text, int x, int y, int w, int h) if( wy >= (y1-=h) ) wy = y1; // avoid tip under cursor (flickers) int abs_x, abs_y; - get_abs_cursor_xy(abs_x,abs_y, 0); + get_abs_cursor(abs_x,abs_y, 0); if( wx < abs_x && abs_x < wx+w && wy < abs_y && abs_y < wy+h ) { if( wx-abs_x < wy-abs_y ) wx = abs_x+1; @@ -3742,13 +3742,13 @@ int BC_WindowBase::dispatch_selection_clear() } -void BC_WindowBase::get_relative_cursor_xy(int &x, int &y, int lock_window) +void BC_WindowBase::get_relative_cursor(int &x, int &y, int lock_window) { int abs_x, abs_y, win_x, win_y; unsigned int temp_mask; Window temp_win; - if(lock_window) this->lock_window("BC_WindowBase::get_relative_cursor_xy"); + if(lock_window) this->lock_window("BC_WindowBase::get_relative_cursor"); XQueryPointer(top_level->display, top_level->win, &temp_win, &temp_win, &abs_x, &abs_y, &win_x, &win_y, &temp_mask); @@ -3760,23 +3760,23 @@ void BC_WindowBase::get_relative_cursor_xy(int &x, int &y, int lock_window) int BC_WindowBase::get_relative_cursor_x(int lock_window) { int x, y; - get_relative_cursor_xy(x, y, lock_window); + get_relative_cursor(x, y, lock_window); return x; } int BC_WindowBase::get_relative_cursor_y(int lock_window) { int x, y; - get_relative_cursor_xy(x, y, lock_window); + get_relative_cursor(x, y, lock_window); return y; } -void BC_WindowBase::get_abs_cursor_xy(int &abs_x, int &abs_y, int lock_window) +void BC_WindowBase::get_abs_cursor(int &abs_x, int &abs_y, int lock_window) { int win_x, win_y; unsigned int temp_mask; Window temp_win; - if(lock_window) this->lock_window("BC_WindowBase::get_abs_cursor_xy"); + if(lock_window) this->lock_window("BC_WindowBase::get_abs_cursor"); XQueryPointer(top_level->display, top_level->win, &temp_win, &temp_win, &abs_x, &abs_y, &win_x, &win_y, &temp_mask); @@ -3785,20 +3785,20 @@ void BC_WindowBase::get_abs_cursor_xy(int &abs_x, int &abs_y, int lock_window) int BC_WindowBase::get_abs_cursor_x(int lock_window) { int abs_x, abs_y; - get_abs_cursor_xy(abs_x, abs_y, lock_window); + get_abs_cursor(abs_x, abs_y, lock_window); return abs_x; } int BC_WindowBase::get_abs_cursor_y(int lock_window) { int abs_x, abs_y; - get_abs_cursor_xy(abs_x, abs_y, lock_window); + get_abs_cursor(abs_x, abs_y, lock_window); return abs_y; } -void BC_WindowBase::get_pop_cursor_xy(int &px, int &py, int lock_window) +void BC_WindowBase::get_pop_cursor(int &px, int &py, int lock_window) { int margin = 100; - get_abs_cursor_xy(px, py, lock_window); + get_abs_cursor(px, py, lock_window); if( px < margin ) px = margin; if( py < margin ) py = margin; int wd = get_screen_w(lock_window,-1) - margin; @@ -3809,13 +3809,13 @@ void BC_WindowBase::get_pop_cursor_xy(int &px, int &py, int lock_window) int BC_WindowBase::get_pop_cursor_x(int lock_window) { int px, py; - get_pop_cursor_xy(px, py, lock_window); + get_pop_cursor(px, py, lock_window); return px; } int BC_WindowBase::get_pop_cursor_y(int lock_window) { int px, py; - get_pop_cursor_xy(px, py, lock_window); + get_pop_cursor(px, py, lock_window); return py; } @@ -3853,7 +3853,7 @@ int BC_WindowBase::get_cursor_over_window() int BC_WindowBase::cursor_above() { int rx, ry; - get_relative_cursor_xy(rx, ry); + get_relative_cursor(rx, ry); return rx < 0 || rx >= get_w() || ry < 0 || ry >= get_h() ? 0 : 1; } diff --git a/cinelerra-5.1/guicast/bcwindowbase.h b/cinelerra-5.1/guicast/bcwindowbase.h index 2c25dc1f..c765b282 100644 --- a/cinelerra-5.1/guicast/bcwindowbase.h +++ b/cinelerra-5.1/guicast/bcwindowbase.h @@ -282,13 +282,13 @@ public: int get_screen_x(int lock_display, int screen); int get_screen_y(int lock_display, int screen); // Get current position - void get_abs_cursor_xy(int &abs_x, int &abs_y, int lock_window=0); + void get_abs_cursor(int &abs_x, int &abs_y, int lock_window=0); int get_abs_cursor_x(int lock_window=0); int get_abs_cursor_y(int lock_window=0); - void get_pop_cursor_xy(int &px, int &py, int lock_window=0); + void get_pop_cursor(int &px, int &py, int lock_window=0); int get_pop_cursor_x(int lock_window=0); int get_pop_cursor_y(int lock_window=0); - void get_relative_cursor_xy(int &x, int &y, int lock_window=0); + void get_relative_cursor(int &x, int &y, int lock_window=0); int get_relative_cursor_x(int lock_window=0); int get_relative_cursor_y(int lock_window=0); void get_root_coordinates(int x, int y, int *abs_x, int *abs_y); diff --git a/cinelerra-5.1/info/plugins.txt b/cinelerra-5.1/info/plugins.txt index 699f5068..3318eaf4 100644 --- a/cinelerra-5.1/info/plugins.txt +++ b/cinelerra-5.1/info/plugins.txt @@ -96,7 +96,8 @@ Histogram: Shows the number of occurrences of each color on a Histogram Bezier: Uses a Bezier curve (parametric) on the histogram plot. HolographgicTV: Holographic tv effect. Hue saturation: Use to change hue, saturation and value parameters. -Interpolate Pixels: Works only for float color models. +Interpolate Bayer: Uses Bayer filter algorithm to interpolate (estimate) + missing color information. Interpolate Video: Create illusion of higher frame rate video of low framesrates by averaging over time. Inverse Telecine: Effective deinterlacing tool for use on a video @@ -180,6 +181,7 @@ Selective Temporal Averaging: Smooths out non-moving areas of a video Sharpen: Sharpen the video, either the luminance, horizontal, or interlace. ShiftInterlace: Shift the interlace lines using odd or even. +Sphere Cam: Converts a fisheye image into a panoramic projection. Swap Frames: Swap frames with 0-1, 2-3, 4-5... or 1-2, 3-4, 5-6... Swap channels: Swap R,G,B,Alpha with another color channel. Threshold: Converts the image to pure luminance and replaces diff --git a/cinelerra-5.1/plugins/crikey/crikeywindow.C b/cinelerra-5.1/plugins/crikey/crikeywindow.C index e774bae8..c55b98c7 100644 --- a/cinelerra-5.1/plugins/crikey/crikeywindow.C +++ b/cinelerra-5.1/plugins/crikey/crikeywindow.C @@ -255,7 +255,7 @@ int CriKeyWindow::grab_event(XEvent *event) MWindow *mwindow = plugin->server->mwindow; CWindowGUI *cwindow_gui = mwindow->cwindow->gui; CWindowCanvas *canvas = cwindow_gui->canvas; - int cx, cy; cwindow_gui->get_relative_cursor_xy(cx, cy); + int cx, cy; cwindow_gui->get_relative_cursor(cx, cy); cx -= mwindow->theme->ccanvas_x; cy -= mwindow->theme->ccanvas_y; diff --git a/cinelerra-5.1/plugins/titler/titlerwindow.C b/cinelerra-5.1/plugins/titler/titlerwindow.C index 9bd8cfe7..c816d607 100644 --- a/cinelerra-5.1/plugins/titler/titlerwindow.C +++ b/cinelerra-5.1/plugins/titler/titlerwindow.C @@ -480,7 +480,7 @@ int TitleWindow::grab_event(XEvent *event) MWindow *mwindow = client->server->mwindow; CWindowGUI *cwindow_gui = mwindow->cwindow->gui; CWindowCanvas *canvas = cwindow_gui->canvas; - int cx, cy; cwindow_gui->get_relative_cursor_xy(cx, cy); + int cx, cy; cwindow_gui->get_relative_cursor(cx, cy); cx -= mwindow->theme->ccanvas_x; cy -= mwindow->theme->ccanvas_y; @@ -1572,7 +1572,7 @@ int TitleCurSubMenuItem::handle_event() switch( popup_type ) { case POPUP_FONT: { int px, py; - window->get_pop_cursor_xy(px ,py); + window->get_pop_cursor(px ,py); window->fonts_popup->activate(px, py, 300,200); return 1; } case POPUP_COLOR: { @@ -1676,7 +1676,7 @@ void TitlePngPopup::handle_done_event(int result) BC_Window *TitlePngPopup::new_gui() { MWindow *mwindow = client->server->mwindow; - int x, y; mwindow->gui->get_abs_cursor_xy(x, y); + int x, y; mwindow->gui->get_abs_cursor(x, y); BC_Window *gui = new BrowseButtonWindow(mwindow->theme, x-25, y-100, window, "", _("Png file"), _("Png path"), 0);