3 * Copyright (C) 2010-2014 Adam Williams <broadcast at earthling dot net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "bcdisplayinfo.h"
22 #include "bcdragwindow.h"
23 #include "bclistbox.h"
24 #include "bclistboxitem.h"
26 #include "bcresources.h"
27 #include "bcsignals.h"
39 // ====================================================== scrollbars
41 BC_ListBoxYScroll::BC_ListBoxYScroll(BC_ListBox *listbox)
42 : BC_ScrollBar(listbox->get_yscroll_x(), listbox->get_yscroll_y(),
43 listbox->yscroll_orientation, listbox->get_yscroll_height(),
44 listbox->items_h, listbox->yposition, listbox->view_h)
46 this->listbox = listbox;
49 BC_ListBoxYScroll::~BC_ListBoxYScroll()
53 int BC_ListBoxYScroll::handle_event()
55 listbox->set_yposition(get_value());
59 BC_ListBoxXScroll::BC_ListBoxXScroll(BC_ListBox *listbox)
60 : BC_ScrollBar(listbox->get_xscroll_x(), listbox->get_xscroll_y(),
61 listbox->xscroll_orientation, listbox->get_xscroll_width(),
62 listbox->items_w, listbox->xposition, listbox->view_w)
64 this->listbox = listbox;
67 BC_ListBoxXScroll::~BC_ListBoxXScroll()
71 int BC_ListBoxXScroll::handle_event()
73 listbox->set_xposition(get_value());
78 BC_ListBoxToggle::BC_ListBoxToggle(BC_ListBox *listbox,
83 this->listbox = listbox;
87 this->value = item->get_expand();
89 state = BC_Toggle::TOGGLE_CHECKED;
91 state = BC_Toggle::TOGGLE_UP;
94 void BC_ListBoxToggle::update(BC_ListBoxItem *item,
99 this->value = item->get_expand();
108 state = TOGGLE_CHECKED;
113 state = TOGGLE_CHECKEDHI;
124 case TOGGLE_CHECKEDHI:
129 case TOGGLE_DOWN_EXIT:
137 int BC_ListBoxToggle::cursor_motion_event(int *redraw_toggles)
139 int w = listbox->toggle_images[0]->get_w();
140 int h = listbox->toggle_images[0]->get_h();
141 int cursor_inside = listbox->get_cursor_x() >= x &&
142 listbox->get_cursor_x() < x + w &&
143 listbox->get_cursor_y() >= y &&
144 listbox->get_cursor_y() < y + h;
148 case BC_ListBoxToggle::TOGGLE_UPHI:
149 if( !cursor_inside ) {
150 state = BC_ListBoxToggle::TOGGLE_UP;
155 case BC_ListBoxToggle::TOGGLE_CHECKEDHI:
156 if( !cursor_inside ) {
157 state = BC_ListBoxToggle::TOGGLE_CHECKED;
162 case BC_ListBoxToggle::TOGGLE_DOWN:
163 if( !cursor_inside ) {
164 state = BC_ListBoxToggle::TOGGLE_DOWN_EXIT;
170 case BC_ListBoxToggle::TOGGLE_DOWN_EXIT:
171 if( cursor_inside ) {
172 state = BC_ListBoxToggle::TOGGLE_DOWN;
179 if( cursor_inside ) {
181 state = BC_ListBoxToggle::TOGGLE_CHECKEDHI;
183 state = BC_ListBoxToggle::TOGGLE_UPHI;
191 int BC_ListBoxToggle::cursor_leave_event(int *redraw_toggles)
194 state = BC_ListBoxToggle::TOGGLE_CHECKED;
196 state = BC_ListBoxToggle::TOGGLE_UP;
200 int BC_ListBoxToggle::button_press_event()
202 int w = listbox->toggle_images[0]->get_w();
203 int h = listbox->toggle_images[0]->get_h();
205 if( listbox->gui->get_cursor_x() >= x &&
206 listbox->gui->get_cursor_x() < x + w &&
207 listbox->gui->get_cursor_y() >= y &&
208 listbox->gui->get_cursor_y() < y + h ) {
209 state = BC_ListBoxToggle::TOGGLE_DOWN;
215 int BC_ListBoxToggle::button_release_event(int *redraw_toggles)
220 case BC_ListBoxToggle::TOGGLE_DOWN:
223 state = BC_ListBoxToggle::TOGGLE_CHECKEDHI;
225 state = BC_ListBoxToggle::TOGGLE_UPHI;
226 listbox->expand_item(item, value);
230 case BC_ListBoxToggle::TOGGLE_DOWN_EXIT:
232 state = BC_ListBoxToggle::TOGGLE_CHECKED;
234 state = BC_ListBoxToggle::TOGGLE_UP;
242 void BC_ListBoxToggle::draw(int flash)
245 int image_number = 0;
246 int w = listbox->toggle_images[0]->get_w();
247 int h = listbox->toggle_images[0]->get_h();
250 case BC_ListBoxToggle::TOGGLE_UP: image_number = 0; break;
251 case BC_ListBoxToggle::TOGGLE_UPHI: image_number = 1; break;
252 case BC_ListBoxToggle::TOGGLE_CHECKED: image_number = 2; break;
253 case BC_ListBoxToggle::TOGGLE_DOWN: image_number = 3; break;
254 case BC_ListBoxToggle::TOGGLE_CHECKEDHI: image_number = 4; break;
255 case BC_ListBoxToggle::TOGGLE_DOWN_EXIT:
256 image_number = value ? 2 : 0;
260 //printf("BC_ListBoxToggle::draw 1 %d\n", state);
261 listbox->gui->draw_pixmap(listbox->toggle_images[image_number], x, y);
264 listbox->gui->flash(x, y, w, h);
265 listbox->gui->flush();
271 // ====================================================== box
273 BC_ListBox::BC_ListBox(int x, int y, int w, int h,
274 int display_format, ArrayList<BC_ListBoxItem*> *data,
275 const char **column_titles, int *column_width, int columns,
276 int yposition, int is_popup, int selection_mode,
277 int icon_position, int allow_drag)
278 : BC_SubWindow(x, y, w, h, -1)
280 justify = LISTBOX_RIGHT;
282 highlighted_item = -1;
283 highlighted_title = -1;
284 highlighted_division = -1;
288 current_cursor = ARROW_CURSOR;
290 view_w = items_w = 0;
291 view_h = items_h = 0;
298 xscroll_orientation = SCROLL_HORIZ;
299 yscroll_orientation = SCROLL_VERT;
304 selection_number1 = -1;
305 selection_number2 = -1;
308 row_height = row_ascent = row_descent = 0;
310 selection_center = 0;
312 selection_number = -1;
313 current_operation = NO_OPERATION;
314 button_highlighted = 0;
316 list_highlighted = 0;
320 allow_drag_scroll = 1;
322 for( int i=0; i<32; ++i ) default_column_width[i] = 0;
327 allow_drag_column = 0;
334 for( int i=0; i<3; ++i ) column_bg[i] = 0;
335 for( int i=0; i<4; ++i ) button_images[i] = 0;
336 for( int i=0; i<5; ++i ) toggle_images[i] = 0;
341 //printf("BC_ListBox::BC_ListBox 1\n");
343 this->columns = columns;
344 this->yposition = yposition;
345 this->is_popup = is_popup;
346 this->use_button = 1;
347 this->display_format = display_format;
348 this->selection_mode = selection_mode;
349 this->icon_position = icon_position;
350 this->allow_drag = allow_drag;
351 this->column_titles = 0;
352 this->column_width = 0;
353 this->first_in_view = -1;
354 this->last_in_view = 0;
355 //printf("BC_ListBox::BC_ListBox 1\n");
357 if( (!column_titles && column_width) ||
358 (column_titles && !column_width) ) {
359 printf("BC_ListBox::BC_ListBox either column_titles or column_widths == NULL but not both.\n");
361 //printf("BC_ListBox::BC_ListBox 2 %p %p\n", column_titles, column_width);
363 set_columns(column_titles, column_width, columns);
365 //printf("BC_ListBox::BC_ListBox 3\n");
367 drag_icon_vframe = 0;
368 drag_column_icon_vframe = 0;
371 temp_display_format = display_format;
372 packed_icons = display_format == LISTBOX_ICONS_PACKED ? 1 : 0;
373 rect_x1 = rect_x2 = 0;
374 rect_y1 = rect_y2 = 0;
376 // reset the search engine
377 //printf("BC_ListBox::BC_ListBox 4\n");
380 //printf("BC_ListBox::BC_ListBox 5\n");
383 BC_ListBox::~BC_ListBox()
385 expanders.remove_all_objects();
386 if( bg_surface ) delete bg_surface;
387 if( bg_pixmap ) delete bg_pixmap;
388 if( xscrollbar ) delete xscrollbar;
389 if( yscrollbar ) delete yscrollbar;
390 for( int i=0; i<3; ++i ) delete column_bg[i];
391 for( int i=0; i<4; ++i ) delete button_images[i];
392 for( int i=0; i<5; ++i ) delete toggle_images[i];
393 if( column_sort_up ) delete column_sort_up;
394 if( column_sort_dn ) delete column_sort_dn;
397 if( drag_popup ) delete drag_popup;
400 int BC_ListBox::enable()
407 int BC_ListBox::disable()
414 void BC_ListBox::reset_query()
416 query[0] = 0; // reset query
419 int BC_ListBox::evaluate_query(char *string)
421 for( int i=0; i<data[search_column].size(); ++i ) {
422 if( strcmp(string, data[search_column].get(i)->text) <= 0 &&
423 data[search_column].get(i)->searchable ) {
431 int BC_ListBox::query_list()
433 if( query[0] == 0 ) return 0;
437 int selection_changed = 0;
438 int prev_selection = -1;
439 result = evaluate_query(query);
440 if( result >= 0 ) done = 1;
444 for( int i=0; i<data[0].total; ++i ) {
445 for( int j=0; j<columns; ++j ) {
446 if( data[j].values[i]->selected ) prev_selection = i;
447 data[j].values[i]->selected = 0;
452 if( prev_selection != result )
453 selection_changed = 1;
454 for( int j=0; j<columns; ++j ) {
455 data[j].values[result]->selected = 1;
457 center_selection(result);
460 return selection_changed;
463 void BC_ListBox::init_column_width()
465 if( !column_width && data ) {
467 for( int i=0; i<data[0].total; ++i ) {
468 wd = get_text_w(data[0].values[i]);
469 if( wd > widest ) widest = wd;
471 default_column_width[0] = widest + 2 * LISTBOX_MARGIN;
475 int BC_ListBox::initialize()
479 for( int i=0; i<4; ++i ) {
480 button_images[i] = new BC_Pixmap(parent_window,
481 BC_WindowBase::get_resources()->listbox_button[i],
484 w = button_images[0]->get_w();
485 h = button_images[0]->get_h();
489 current_operation = NO_OPERATION;
494 current_operation = NO_OPERATION;
497 for( int i=0; i<3; ++i ) {
498 column_bg[i] = new BC_Pixmap(parent_window,
499 get_resources()->listbox_column[i],
502 for( int i=0; i<5; ++i ) {
503 toggle_images[i] = new BC_Pixmap(parent_window,
504 get_resources()->listbox_expand[i],
508 column_sort_up = new BC_Pixmap(parent_window,
509 BC_WindowBase::get_resources()->listbox_up,
511 column_sort_dn = new BC_Pixmap(parent_window,
512 BC_WindowBase::get_resources()->listbox_dn,
515 //printf("BC_ListBox::initialize 10\n");
516 drag_icon_vframe = get_resources()->type_to_icon[ICON_UNKNOWN];
517 drag_column_icon_vframe = get_resources()->type_to_icon[ICON_COLUMN];
518 // = new BC_Pixmap(parent_window,
519 // get_resources()->type_to_icon[ICON_UNKNOWN],
521 // drag_column_icon = new BC_Pixmap(parent_window,
522 // get_resources()->type_to_icon[ICON_COLUMN],
524 BC_SubWindow::initialize();
528 if( top_level->get_resources()->listbox_bg )
529 bg_pixmap = new BC_Pixmap(this,
530 get_resources()->listbox_bg,
536 if( !use_button && is_popup ) {
544 void BC_ListBox::deactivate_selection()
546 current_operation = NO_OPERATION;
549 int BC_ListBox::draw_button(int flush)
551 // Draw the button for a popup listbox
552 if( use_button && is_popup ) {
553 int image_number = 0;
555 draw_top_background(parent_window, 0, 0, w, h);
557 if( button_highlighted )
559 if( current_operation == BUTTON_DN )
564 pixmap->draw_pixmap(button_images[image_number],
571 int BC_ListBox::calculate_item_coords()
573 if( !data ) return 0;
579 // Change the display_format to get the right item dimensions for both
581 temp_display_format = display_format;
584 // Scan the first column for lowest y coord of all text
585 // and lowest right x and y coord for all icons which aren't auto placable
586 calculate_last_coords_recursive(data,
587 &icon_x, &next_icon_x, &next_icon_y, &next_text_y, 1);
589 // Reset last column width. It's recalculated based on text width.
590 calculate_item_coords_recursive(data,
591 &icon_x, &next_icon_x, &next_icon_y, &next_text_y, 1);
593 display_format = temp_display_format;
598 void BC_ListBox::calculate_last_coords_recursive(
599 ArrayList<BC_ListBoxItem*> *data,
606 for( int i=0; i<data[0].size(); ++i ) {
607 int current_text_y = 0;
608 int current_icon_x = 0;
609 int current_icon_y = 0;
610 BC_ListBoxItem *item = data[0].get(i);
613 if( !item->autoplace_text ) {
614 // Lowest text coordinate
615 display_format = LISTBOX_TEXT;
616 current_text_y = item->text_y + get_text_h(item);
617 if( current_text_y > *next_text_y )
618 *next_text_y = current_text_y;
620 // Add sublist depth if it is expanded
621 if( item->sublist_active() && item->get_columns() ) {
622 calculate_last_coords_recursive(item->get_sublist(),
623 icon_x, next_icon_x, next_icon_y, next_text_y, 0);
627 // Get next_icon coordinate
629 BC_ListBoxItem *item = data[master_column].get(i);
630 if( !item->autoplace_icon ) {
631 display_format = LISTBOX_ICONS;
632 // Lowest right icon coordinate.
633 current_icon_x = item->icon_x;
634 if( current_icon_x > *icon_x ) *icon_x = current_icon_x;
635 if( current_icon_x + get_item_w(item) > *next_icon_x ) {
636 *next_icon_x = current_icon_x + get_item_w(item);
639 current_icon_y = item->icon_y + get_item_h(item);
640 if( current_icon_y > *next_icon_y )
641 *next_icon_y = current_icon_y;
648 void BC_ListBox::calculate_item_coords_recursive(
649 ArrayList<BC_ListBoxItem*> *data,
650 int *icon_x, int *next_icon_x, int *next_icon_y, int *next_text_y,
653 // get maximum height of an icon
654 row_height = get_text_height(MEDIUMFONT);
655 if( temp_display_format == LISTBOX_ICON_LIST ) {
656 for( int i=0; i<data[0].size(); ++i ) {
657 if( data[0].get(i)->icon ) {
658 int icon_h = data[0].get(i)->icon->get_h() + 2*ICON_MARGIN;
659 if( row_height < icon_h ) row_height = icon_h;
665 // Set up items which need autoplacement.
666 // Should fill icons down and then across
667 for( int i=0; i<data[0].size(); ++i ) {
668 // Don't increase y unless the row requires autoplacing.
669 int total_autoplaced_columns = 0;
671 // Set up icons in first column
673 BC_ListBoxItem *item = data[master_column].get(i);
674 if( item->autoplace_icon ) {
675 // 1 column only if icons are used
676 display_format = LISTBOX_ICONS;
679 if( *next_icon_y + get_item_h(item) >= get_h() &&
681 *icon_x = *next_icon_x;
685 if( *icon_x + get_item_w(item) > *next_icon_x )
686 *next_icon_x = *icon_x + get_item_w(item);
689 item->set_icon_x(*icon_x);
690 item->set_icon_y(*next_icon_y);
692 *next_icon_y += get_item_h(item);
698 row_ascent = row_descent = 0;
699 // row_height still holds icon max height
700 for( int j=0; j<columns; ++j ) {
701 BC_ListBoxItem *item = data[j].get(i);
702 if( item->autoplace_text ) {
703 display_format = LISTBOX_TEXT;
704 item->set_text_x(next_text_x);
705 item->set_text_y(*next_text_y);
706 int ht = get_text_h(item);
707 if( ht > row_height ) row_height = ht;
708 int bl = get_baseline(item);
709 if( bl > row_ascent ) row_ascent = bl;
711 if( dt > row_descent ) row_descent = dt;
713 // printf("BC_ListBox::calculate_item_coords_recursive %p %d %d %d %d %s \n",
714 // item->sublist, item->get_columns(), item->get_expand(),
715 // next_text_x, *next_text_y, item->get_text());
716 // Increment position of next column
717 if( j < columns - 1 ) {
718 next_text_x += (column_width ?
720 default_column_width[j]);
722 // Set last column width based on text width
724 int new_w = get_item_w(item);
726 int *previous_w = (column_width ?
728 &default_column_width[j]);
729 if( new_w > *previous_w )
731 //printf("BC_ListBox::calculate_item_coords_recursive 1 %d\n", new_w);
733 total_autoplaced_columns++;
737 // Increase the text vertical position
738 if( total_autoplaced_columns ) {
739 display_format = LISTBOX_TEXT;
740 *next_text_y += row_height;
744 BC_ListBoxItem *item = data[master_column].values[i];
745 if( item->sublist_active() && item->get_columns() ) {
746 calculate_item_coords_recursive( item->get_sublist(),
747 icon_x, next_icon_x, next_icon_y, next_text_y, 0);
752 void BC_ListBox::set_is_suggestions(int value)
754 this->is_suggestions = value;
756 void BC_ListBox::set_scroll_repeat()
758 if( scroll_repeat ) return;
760 set_repeat(get_resources()->scroll_repeat);
763 void BC_ListBox::unset_scroll_repeat()
765 if( !scroll_repeat ) return;
767 unset_repeat(get_resources()->scroll_repeat);
770 void BC_ListBox::set_use_button(int value)
772 this->use_button = value;
775 void BC_ListBox::set_justify(int value)
777 this->justify = value;
780 void BC_ListBox::set_allow_drag_column(int value)
782 this->allow_drag_column = value;
785 void BC_ListBox::set_process_drag(int value)
787 this->process_drag = value;
790 void BC_ListBox::set_master_column(int value, int redraw)
792 this->master_column = value;
798 void BC_ListBox::set_search_column(int value)
800 this->search_column = value;
803 int BC_ListBox::get_sort_column()
808 void BC_ListBox::set_sort_column(int value, int redraw)
816 int BC_ListBox::get_sort_order()
821 void BC_ListBox::set_sort_order(int value, int redraw)
830 int BC_ListBox::get_display_mode()
832 return display_format;
835 int BC_ListBox::get_yposition()
840 int BC_ListBox::get_xposition()
845 int BC_ListBox::get_highlighted_item()
847 return highlighted_item;
851 int BC_ListBox::get_item_x(BC_ListBoxItem *item)
853 switch( display_format ) {
855 case LISTBOX_ICON_LIST:
856 return item->text_x - xposition + 2;
858 case LISTBOX_ICONS_PACKED:
859 return item->icon_x - xposition + 2;
864 int BC_ListBox::get_item_y(BC_ListBoxItem *item)
866 switch( display_format ) {
868 case LISTBOX_ICON_LIST:
869 return item->text_y - yposition + title_h + 2;
871 case LISTBOX_ICONS_PACKED:
872 return item->icon_y - yposition + 2;
877 int BC_ListBox::get_item_w(BC_ListBoxItem *item)
879 switch( display_format ) {
881 case LISTBOX_ICON_LIST: {
882 return get_text_w(item) + 2 * LISTBOX_MARGIN; }
884 case LISTBOX_ICONS_PACKED: {
886 get_icon_mask(item, x, y, w, h);
888 get_text_mask(item, x, y, w, h);
891 return icon_position == ICON_LEFT ? icon_w + text_w :
892 icon_w > text_w ? icon_w : text_w;
898 int BC_ListBox::get_item_h(BC_ListBoxItem *item)
900 switch( display_format ) {
902 case LISTBOX_ICON_LIST:
903 return get_text_h(item);
905 case LISTBOX_ICONS_PACKED: {
907 get_icon_mask(item, x, y, w, h);
909 get_text_mask(item, x, y, w, h);
912 return icon_position != ICON_LEFT ? icon_h + text_h :
913 icon_h > text_h ? icon_h : text_h; }
919 int BC_ListBox::get_icon_x(BC_ListBoxItem *item)
921 return get_item_x(item) + ICON_MARGIN;
924 int BC_ListBox::get_icon_y(BC_ListBoxItem *item)
926 return get_item_y(item) + ICON_MARGIN;
929 int BC_ListBox::get_icon_w(BC_ListBoxItem *item)
931 return item->get_icon_w() + 2*ICON_MARGIN;
934 int BC_ListBox::get_icon_h(BC_ListBoxItem *item)
936 return item->get_icon_h() + 2*ICON_MARGIN;
939 int BC_ListBox::get_text_w(BC_ListBoxItem *item)
941 int w = item->get_text_w();
942 if( w < 0 ) item->set_text_w(w = get_text_width(MEDIUMFONT, item->get_text()));
946 int BC_ListBox::get_text_h(BC_ListBoxItem *item)
948 int h = item->get_text_h();
949 if( h < 0 ) item->set_text_h(h = get_text_height(MEDIUMFONT, item->get_text()));
953 int BC_ListBox::get_baseline(BC_ListBoxItem *item)
955 int b = item->get_baseline();
956 if( b < 0 ) item->set_baseline(b = get_text_ascent(MEDIUMFONT));
960 int BC_ListBox::get_items_width()
962 switch( display_format ) {
964 return get_column_offset(columns);
966 case LISTBOX_ICONS_PACKED: {
968 for( int i=0; i<columns; ++i ) {
969 for( int j=0; j<data[i].total; ++j ) {
971 BC_ListBoxItem *item = data[i].values[j];
974 get_icon_mask(item, x, y, w, h);
975 if( x1 + w > widest ) widest = x1 + w;
977 if( icon_position == ICON_LEFT )
980 get_text_mask(item, x, y, w, h);
981 if( x1 + w > widest ) widest = x1 + w;
985 case LISTBOX_ICON_LIST:
986 return get_column_offset(columns);
991 int BC_ListBox::get_items_height(ArrayList<BC_ListBoxItem*> *data, int columns,
1002 for( int j=0; j<(data?data[master_column].total:0); ++j ) {
1004 BC_ListBoxItem *item = data[master_column].values[j];
1006 switch( display_format ) {
1008 get_text_mask(item, x, y, w, h);
1010 // Descend into sublist
1011 if( item->sublist_active() )
1012 get_items_height(item->get_sublist(), item->get_columns(), result);
1015 case LISTBOX_ICONS_PACKED:
1016 case LISTBOX_ICON_LIST:
1017 get_icon_mask(item, x, y, w, h);
1018 if( y + h + yposition > highest ) highest = y + h + yposition;
1020 get_text_mask(item, x, y, w, h);
1021 if( y + h + yposition > highest ) highest = y + h + yposition;
1026 if( display_format == LISTBOX_TEXT && top_level ) {
1027 highest = LISTBOX_MARGIN + *result;
1033 int BC_ListBox::set_yposition(int position, int draw_items)
1035 this->yposition = position;
1037 this->draw_items(1);
1042 int BC_ListBox::set_xposition(int position)
1044 this->xposition = position;
1049 int BC_ListBox::is_highlighted()
1051 return list_highlighted;
1054 void BC_ListBox::expand_item(BC_ListBoxItem *item, int expand)
1057 item->expand = expand;
1058 // Collapse sublists if this is collapsed to make it easier to calculate
1060 if( item->get_sublist() )
1061 collapse_recursive(item->get_sublist(), master_column);
1063 // Set everything for autoplacement
1064 set_autoplacement(data, 0, 1);
1069 void BC_ListBox::collapse_recursive(ArrayList<BC_ListBoxItem*> *data,
1072 for( int i=0; i<data[master_column].total; ++i ) {
1073 BC_ListBoxItem *item = data[master_column].values[i];
1074 if( item->sublist_active() ) {
1076 collapse_recursive(item->get_sublist(), master_column);
1081 void BC_ListBox::set_autoplacement(ArrayList<BC_ListBoxItem*> *data,
1085 for( int i=0; i<data[0].total; ++i ) {
1086 for( int j=0; j<columns; ++j ) {
1087 if( do_icons ) data[j].values[i]->autoplace_icon = 1;
1088 if( do_text ) data[j].values[i]->autoplace_text = 1;
1091 BC_ListBoxItem *item = data[master_column].values[i];
1092 if( item->sublist_active() ) {
1093 set_autoplacement(item->get_sublist(), do_icons, do_text);
1099 void BC_ListBox::set_scroll_stretch(int xv, int yv)
1101 if( xv >= 0 ) xscroll_orientation =
1102 !xv ? SCROLL_HORIZ : SCROLL_HORIZ + SCROLL_STRETCH;
1103 if( yv >= 0 ) yscroll_orientation =
1104 !yv ? SCROLL_VERT : SCROLL_VERT + SCROLL_STRETCH;
1107 int BC_ListBox::get_yscroll_x()
1110 return popup_w - get_resources()->vscroll_data[SCROLL_HANDLE_UP]->get_w();
1112 return get_x() + popup_w -
1113 get_resources()->vscroll_data[SCROLL_HANDLE_UP]->get_w();
1116 int BC_ListBox::get_yscroll_y()
1118 return is_popup ? 0 : get_y();
1121 int BC_ListBox::get_yscroll_height()
1123 return popup_h - (need_xscroll ?
1124 get_resources()->hscroll_data[SCROLL_HANDLE_UP]->get_h() :
1128 int BC_ListBox::get_xscroll_x()
1130 return is_popup ? 0 : get_x();
1133 int BC_ListBox::get_xscroll_y()
1135 return (is_popup ? popup_h : get_y() + popup_h) -
1136 get_resources()->hscroll_data[SCROLL_HANDLE_UP]->get_h();
1139 int BC_ListBox::get_xscroll_width()
1141 return popup_w - (need_yscroll ?
1142 get_resources()->vscroll_data[SCROLL_HANDLE_UP]->get_w() : 0);
1145 int BC_ListBox::get_column_offset(int column)
1148 while( column > 0 ) {
1150 column_width[--column] :
1151 default_column_width[--column];
1156 void BC_ListBox::column_width_boundaries()
1158 if( column_width ) {
1159 for( int i=0; i<columns; ++i ) {
1160 if( column_width[i] < MIN_COLUMN_WIDTH )
1161 column_width[i] = MIN_COLUMN_WIDTH;
1165 for( int i=0; i<columns; ++i ) {
1166 if( default_column_width[i] < MIN_COLUMN_WIDTH )
1167 default_column_width[i] = MIN_COLUMN_WIDTH;
1172 int BC_ListBox::get_column_width(int column, int clamp_right)
1174 if( column < columns - 1 || !clamp_right )
1175 return column_width ? column_width[column] : default_column_width[column];
1176 return popup_w + xposition - get_column_offset(column);
1179 int BC_ListBox::get_icon_mask(BC_ListBoxItem *item,
1180 int &x, int &y, int &w, int &h)
1182 switch( display_format ) {
1184 case LISTBOX_ICONS_PACKED:
1185 case LISTBOX_ICON_LIST: {
1186 x = get_icon_x(item);
1187 y = get_icon_y(item);
1188 w = get_icon_w(item);
1189 h = get_icon_h(item);
1199 int BC_ListBox::get_text_mask(BC_ListBoxItem *item,
1200 int &x, int &y, int &w, int &h)
1202 x = get_item_x(item);
1203 y = get_item_y(item);
1205 switch( display_format ) {
1206 case LISTBOX_TEXT: {
1207 w = get_text_w(item) + LISTBOX_MARGIN * 2;
1208 h = get_text_h(item);
1211 case LISTBOX_ICONS_PACKED: {
1212 if( icon_position == ICON_LEFT ) {
1213 x += get_icon_w(item);
1214 y += get_icon_h(item) - get_text_h(item);
1217 y += get_icon_h(item);
1221 get_icon_w(item) + ICON_MARGIN * 2 :
1222 get_text_w(item) + ICON_MARGIN * 2 ;
1223 h = get_text_h(item) + ICON_MARGIN * 2;
1225 case LISTBOX_ICON_LIST: {
1226 w = get_text_width(MEDIUMFONT, item->text) + LISTBOX_MARGIN * 2;
1235 int BC_ListBox::get_item_highlight(ArrayList<BC_ListBoxItem*> *data,
1236 int column, int item)
1238 BC_Resources *resources = get_resources();
1239 if( data[column].values[item]->selected )
1240 return resources->listbox_selected;
1241 if( highlighted_item >= 0 &&
1242 highlighted_ptr == data[master_column].values[item] )
1243 return resources->listbox_highlighted;
1244 return resources->listbox_inactive;
1247 int BC_ListBox::get_item_color(ArrayList<BC_ListBoxItem*> *data,
1248 int column, int item)
1250 int color = data[column].values[item]->color;
1251 if( color == -1 ) color = get_resources()->listbox_text;
1252 if( get_item_highlight(data, column, item) == color )
1257 int BC_ListBox::get_from_column()
1259 return dragged_title;
1262 int BC_ListBox::get_to_column()
1264 return highlighted_title;
1268 BC_ListBoxItem* BC_ListBox::get_selection(int column, int selection_number)
1270 return get_selection_recursive(data,
1275 BC_ListBoxItem* BC_ListBox::get_selection_recursive(ArrayList<BC_ListBoxItem*> *data,
1276 int column, int selection_number)
1278 if( !data ) return 0;
1280 for( int i=0; i<data[master_column].total; ++i ) {
1281 BC_ListBoxItem *item = data[master_column].values[i];
1282 if( item->selected ) {
1283 //printf("BC_ListBox::get_selection_recursive %d\n", __LINE__);
1285 if( selection_number < 0 ) {
1287 return data[column].values[i];
1291 if( item->sublist_active() ) {
1292 BC_ListBoxItem *result = get_selection_recursive(item->get_sublist(),
1295 if( result ) return result;
1303 int BC_ListBox::get_selection_number(int column, int selection_number)
1305 return get_selection_number_recursive(data, column, selection_number);
1308 int BC_ListBox::get_selection_number_recursive(ArrayList<BC_ListBoxItem*> *data,
1309 int column, int selection_number, int *counter)
1312 if( !data ) return 0;
1313 if( !counter ) counter = &temp;
1315 for( int i=0; i<data[master_column].total; ++i ) {
1317 BC_ListBoxItem *item = data[master_column].values[i];
1318 if( item->selected ) {
1320 if( selection_number < 0 ) {
1324 if( item->sublist_active() ) {
1325 int result = get_selection_number_recursive(item->get_sublist(),
1326 column, selection_number, counter);
1327 if( result >= 0 ) return result;
1334 int BC_ListBox::set_selection_mode(int mode)
1336 this->selection_mode = mode;
1340 void BC_ListBox::delete_columns()
1342 if( column_titles ) {
1343 for( int i=0; i<columns; ++i ) {
1344 delete [] column_titles[i];
1346 delete [] column_titles;
1349 if( column_width ) delete [] column_width;
1355 // Need to copy titles so EDL can change
1356 void BC_ListBox::set_columns(const char **column_titles, int *column_width, int columns)
1358 if( (!column_titles && column_width) ||
1359 (column_titles && !column_width) ) {
1360 printf("BC_ListBox::set_columns either column_titles or column_width == NULL but not both.\n");
1365 if( column_titles ) {
1366 this->column_titles = new char*[columns];
1367 for( int i=0; i<columns; ++i ) {
1368 this->column_titles[i] = new char[strlen(column_titles[i]) + 1];
1369 strcpy(this->column_titles[i], column_titles[i]);
1372 if( column_width ) {
1373 this->column_width = new int[columns];
1374 for( int i=0; i<columns; ++i ) {
1375 this->column_width[i] = column_width[i];
1379 this->columns = columns;
1384 int BC_ListBox::update(ArrayList<BC_ListBoxItem*> *data,
1385 const char **column_titles, int *column_widths, int columns,
1386 int xposition, int yposition, int highlighted_number,
1387 int recalc_positions, int draw)
1389 set_columns(column_titles, column_widths, columns);
1391 this->yposition = yposition;
1392 this->xposition = xposition;
1393 this->highlighted_item = highlighted_number;
1394 this->highlighted_ptr = index_to_item(data, highlighted_number, 0);
1396 if( recalc_positions )
1397 set_autoplacement(data, 1, 1);
1399 init_column_width();
1403 update_scrollbars(1);
1409 void BC_ListBox::center_selection()
1411 int selection = get_selection_number(0, 0);
1412 calculate_item_coords();
1413 center_selection(selection);
1417 update_scrollbars(0);
1418 gui->show_window(1);
1422 void BC_ListBox::move_vertical(int pixels)
1426 void BC_ListBox::move_horizontal(int pixels)
1430 int BC_ListBox::select_previous(int skip, BC_ListBoxItem *selected_item, int *counter,
1431 ArrayList<BC_ListBoxItem*> *data, int *got_first, int *got_second)
1434 if( !selected_item )
1435 selected_item = get_selection(0, 0);
1446 got_second = &temp3;
1450 // Scan backwards to item pointer. Then count visible items to get
1451 // destination. No wraparound.
1453 for( int i=data[master_column].total-1; i>=0; --i ) {
1454 BC_ListBoxItem *current_item = data[master_column].values[i];
1455 if( current_item->sublist_active() ) {
1456 int result = select_previous(skip, selected_item, counter,
1457 current_item->get_sublist(), got_first, got_second);
1464 if( (*counter) >= skip ) {
1465 for( int j=0; j<columns; ++j )
1466 data[j].values[i]->selected = 1;
1468 return item_to_index(this->data, current_item);
1472 if( current_item->selected ) {
1473 for( int j=0; j<columns; ++j )
1474 data[j].values[i]->selected = 0;
1481 // Hit top of top level without finding a selected item.
1483 // Select first item in top level and quit
1484 BC_ListBoxItem *current_item;
1486 current_item = data[master_column].values[0];
1488 for( int j=0; j<columns; ++j )
1489 data[j].values[0]->selected = 1;
1491 return item_to_index(this->data, current_item);
1493 } while( top_level && data[master_column].total );
1498 int BC_ListBox::select_next(int skip, BC_ListBoxItem *selected_item, int *counter,
1499 ArrayList<BC_ListBoxItem*> *data, int *got_first, int *got_second)
1502 if( !selected_item )
1503 selected_item = get_selection(0, 0);
1514 got_second = &temp3;
1518 // Scan forwards to currently selected item pointer.
1519 // Then count visible items to get destination. No wraparound.
1521 for( int i=0; i<data[master_column].total; ++i ) {
1522 BC_ListBoxItem *current_item = data[master_column].values[i];
1524 // Select next item once the number items after the currently selected item
1525 // have been passed.
1528 if( (*counter) >= skip ) {
1529 for( int j=0; j<columns; ++j )
1530 data[j].values[i]->selected = 1;
1532 return item_to_index(this->data, current_item);
1536 // Got currently selected item. Deselect it.
1537 if( current_item->selected ) {
1538 for( int j=0; j<columns; ++j )
1539 data[j].values[i]->selected = 0;
1545 // Descend into expanded level
1546 if( current_item->sublist_active() ) {
1547 int result = select_next(skip, selected_item, counter,
1548 current_item->get_sublist(), got_first, got_second);
1555 // Hit bottom of top level without finding the next item.
1557 BC_ListBoxItem *current_item;
1558 // Select first item in top level and quit
1559 if( !(*got_first) ) {
1561 current_item = data[master_column].values[0];
1563 for( int j=0; j<columns; ++j )
1564 data[j].values[0]->selected = 1;
1568 // Select last item in top level and quit
1570 int current_row = data[master_column].total - 1;
1571 current_item = data[master_column].values[current_row];
1573 for( int j=0; j<columns; ++j )
1574 data[j].values[current_row]->selected = 1;
1578 return item_to_index(this->data, current_item);
1580 } while( top_level && data[master_column].total );
1586 void BC_ListBox::clamp_positions()
1588 items_w = get_items_width();
1589 if( xscroll_orientation & SCROLL_STRETCH )
1590 items_w += view_w / 4;
1591 items_h = get_items_height(data, columns);
1592 if( yscroll_orientation & SCROLL_STRETCH )
1593 items_h += view_h / 4;
1595 if( yposition < 0 ) yposition = 0;
1597 if( yposition > items_h - view_h )
1598 yposition = items_h - view_h;
1600 if( yposition < 0 ) yposition = 0;
1602 if( xposition < 0 ) xposition = 0;
1604 if( xposition >= items_w - view_w )
1605 xposition = items_w - view_w;
1607 if( xposition < 0 ) xposition = 0;
1610 int BC_ListBox::center_selection(int selection,
1611 ArrayList<BC_ListBoxItem*> *data, int *counter)
1614 if( !data ) data = this->data;
1615 if( !counter ) counter = &temp;
1617 for( int i=0; i<data[master_column].total; ++i ) {
1621 BC_ListBoxItem *item = data[master_column].values[i];
1622 if( (*counter) == selection ) {
1623 BC_ListBoxItem *top_item = this->data[master_column].values[0];
1624 switch( display_format ) {
1626 case LISTBOX_ICONS_PACKED: {
1627 // Icon is out of window
1628 if( item->icon_y-yposition > view_h-get_text_h(item) ||
1629 item->icon_y-yposition < 0 ) {
1630 yposition = item->icon_y - view_h / 2;
1633 if( data[master_column].values[selection]->icon_x - xposition > view_w ||
1634 data[master_column].values[selection]->icon_x - xposition < 0 ) {
1635 xposition = item->icon_x - view_w / 2;
1639 case LISTBOX_ICON_LIST:
1640 // Text coordinate is out of window
1641 if( item->text_y-yposition > view_h-get_text_h(item) ||
1642 item->text_y-yposition < 0 ) {
1643 yposition = item->text_y - top_item->text_y - view_h / 2;
1646 if( yposition < 0 ) yposition = 0;
1651 if( item->sublist_active() ) {
1652 int result = center_selection(selection, item->get_sublist(), counter);
1653 if( result ) return result;
1659 void BC_ListBox::update_scrollbars(int flush)
1661 int h_needed = items_h = get_items_height(data, columns);
1662 int w_needed = items_w = get_items_width();
1664 // if( columns > 0 && column_width )
1665 // printf("BC_ListBox::update_scrollbars 1 %d %d\n", column_width[columns - 1], w_needed);
1668 if( xposition != xscrollbar->get_value() )
1669 xscrollbar->update_value(xposition);
1671 if( w_needed != xscrollbar->get_length() ||
1672 view_w != xscrollbar->get_handlelength() )
1673 xscrollbar->update_length(w_needed, xposition, view_w, 0);
1677 if( yposition != yscrollbar->get_value() )
1678 yscrollbar->update_value(yposition);
1680 if( h_needed != yscrollbar->get_length() || view_h != yscrollbar->get_handlelength() )
1681 yscrollbar->update_length(h_needed, yposition, view_h, 0);
1684 if( flush ) this->flush();
1687 int BC_ListBox::get_scrollbars()
1689 int h_needed = items_h = get_items_height(data, columns);
1690 int w_needed = items_w = get_items_width();
1693 title_h = get_title_h();
1694 view_h = popup_h - title_h - 4;
1695 view_w = popup_w - 4;
1697 // Create scrollbars as needed
1698 for( int i=0; i<2; ++i ) {
1699 if( w_needed > view_w ) {
1703 get_resources()->hscroll_data[SCROLL_HANDLE_UP]->get_h() -
1710 if( h_needed > view_h ) {
1713 get_resources()->vscroll_data[SCROLL_HANDLE_UP]->get_w() -
1721 // Update subwindow size
1722 int new_w = popup_w;
1723 int new_h = popup_h;
1724 if( need_xscroll ) new_h -= get_resources()->hscroll_data[SCROLL_HANDLE_UP]->get_h();
1725 if( need_yscroll ) new_w -= get_resources()->vscroll_data[SCROLL_HANDLE_UP]->get_w();
1728 if( new_w != BC_WindowBase::get_w() || new_h != BC_WindowBase::get_h() )
1729 gui->resize_window(new_w, new_h);
1731 BC_WindowBase *destination = (is_popup ? gui : parent_window);
1732 if( need_xscroll ) {
1734 xscrollbar = new BC_ListBoxXScroll(this);
1735 destination->add_subwindow(xscrollbar);
1736 xscrollbar->show_window(0);
1737 xscrollbar->bound_to = this;
1740 xscrollbar->update_length(w_needed, xposition, view_w, flush);
1741 xscrollbar->reposition_window(get_xscroll_x(),
1743 get_xscroll_width());
1747 if( xscrollbar ) delete xscrollbar;
1752 if( need_yscroll ) {
1754 yscrollbar = new BC_ListBoxYScroll(this);
1755 destination->add_subwindow(yscrollbar);
1756 yscrollbar->show_window(0);
1757 yscrollbar->bound_to = this;
1760 yscrollbar->update_length(h_needed, yposition, view_h, flush);
1761 yscrollbar->reposition_window(get_yscroll_x(),
1763 get_yscroll_height());
1767 if( yscrollbar ) delete yscrollbar;
1773 view_w + 4 != bg_surface->get_w() ||
1774 view_h + 4 != bg_surface->get_h() ) {
1775 if( bg_surface ) delete bg_surface;
1776 bg_surface = new BC_Pixmap(gui, view_w + 4, view_h + 4);
1785 void BC_ListBox::set_drag_scroll(int value)
1787 allow_drag_scroll = value;
1790 // Test for scrolling by dragging
1792 int BC_ListBox::test_drag_scroll(int cursor_x, int cursor_y)
1795 if( allow_drag_scroll ||
1796 current_operation == SELECT_RECT ) {
1798 int top_boundary = get_title_h();
1800 if( cursor_y < top_boundary ||
1801 cursor_y >= view_h + title_h + LISTBOX_BORDER * 2 ||
1802 cursor_x < LISTBOX_BORDER ||
1803 cursor_x >= view_w + LISTBOX_BORDER ) {
1810 int BC_ListBox::drag_scroll_event()
1812 int top_boundary = get_title_h();
1815 if( get_cursor_y() < top_boundary ) {
1816 yposition -= top_boundary - get_cursor_y();
1820 if( get_cursor_y() >= view_h + title_h + 4 ) {
1821 yposition += get_cursor_y() - (view_h + title_h + 4);
1825 if( get_cursor_x() < 2 ) {
1826 xposition -= 2 - get_cursor_x();
1830 if( get_cursor_x() >= view_w + 2 ) {
1831 xposition += get_cursor_x() - (view_w + 2);
1841 int BC_ListBox::rectangle_scroll_event()
1843 int old_xposition = xposition;
1844 int old_yposition = yposition;
1845 int result = drag_scroll_event();
1848 rect_x1 += old_xposition - xposition;
1849 rect_y1 += old_yposition - yposition;
1850 rect_x2 = get_cursor_x();
1851 rect_y2 = get_cursor_y();
1853 int x1 = MIN(rect_x1, rect_x2);
1854 int x2 = MAX(rect_x1, rect_x2);
1855 int y1 = MIN(rect_y1, rect_y2);
1856 int y2 = MAX(rect_y1, rect_y2);
1858 if( select_rectangle(data, x1, y1, x2, y2) ) {
1859 selection_changed();
1864 update_scrollbars(1);
1869 int BC_ListBox::select_scroll_event()
1871 int result = drag_scroll_event();
1873 highlighted_item = selection_number = get_cursor_item(data,
1874 get_cursor_x(), get_cursor_y(), &highlighted_ptr);
1877 update_scrollbars(1);
1878 selection_changed();
1883 int BC_ListBox::select_rectangle(ArrayList<BC_ListBoxItem*> *data,
1884 int x1, int y1, int x2, int y2)
1887 for( int i=0; i<data[master_column].total; ++i ) {
1888 for( int j=0; j<columns; ++j ) {
1889 BC_ListBoxItem *item = data[j].values[i];
1890 switch( display_format ) {
1892 case LISTBOX_ICONS_PACKED: {
1893 int icon_x, icon_y, icon_w, icon_h;
1894 int text_x, text_y, text_w, text_h;
1895 get_icon_mask(item, icon_x, icon_y, icon_w, icon_h);
1896 get_text_mask(item, text_x, text_y, text_w, text_h);
1898 if( (x2 >= icon_x && x1 < icon_x + icon_w &&
1899 y2 >= icon_y && y1 < icon_y + icon_h) ||
1900 (x2 >= text_x && x1 < text_x + text_w &&
1901 y2 >= text_y && y1 < text_y + text_h) ) {
1902 if( !item->selected ) {
1908 if( item->selected ) {
1915 case LISTBOX_ICON_LIST: {
1918 gui->get_w() - get_resources()->vscroll_data[SCROLL_HANDLE_UP]->get_w() :
1919 gui->get_w()) && y2 > 0 &&
1920 y1 < gui->get_h() && y2 >= get_item_y(item) &&
1921 y1 < get_item_y(item) + get_item_h(item) ) {
1922 if( !item->selected ) {
1928 if( item->selected ) {
1937 BC_ListBoxItem *item = data[master_column].values[i];
1938 if( item->sublist_active() ) {
1939 result |= select_rectangle(item->get_sublist(),
1946 int BC_ListBox::reposition_item(ArrayList<BC_ListBoxItem*> *data,
1947 int selection_number, int x, int y, int *counter)
1950 if( !counter ) counter = &temp;
1952 for( int i=0; i<data[master_column].total; ++i ) {
1953 BC_ListBoxItem *item = data[master_column].values[i];
1955 if( (*counter) == selection_number ) {
1960 // Not recursive because it's only used for icons
1965 void BC_ListBox::move_selection(ArrayList<BC_ListBoxItem*> *dst,
1966 ArrayList<BC_ListBoxItem*> *src)
1968 for( int i=0; i<src[master_column].total; ) {
1969 BC_ListBoxItem *item = src[master_column].values[i];
1972 if( item->selected ) {
1973 for( int j=0; j<columns; ++j ) {
1974 dst[j].append(src[j].values[i]);
1975 src[j].remove_number(i);
1979 // Descend into sublist
1980 if( item->sublist_active() ) {
1981 move_selection(dst, item->get_sublist());
1987 int BC_ListBox::put_selection(ArrayList<BC_ListBoxItem*> *data,
1988 ArrayList<BC_ListBoxItem*> *src, int destination, int *counter)
1991 if( !counter ) counter = &temp;
1993 if( destination < 0 || destination >= data[master_column].total ) {
1994 for( int j=0; j<columns; ++j ) {
1995 for( int i=0; i<src[j].total; ++i ) {
1996 data[j].append(src[j].values[i]);
2002 for( int i=0; i<data[master_column].total; ++i ) {
2004 if( (*counter) == destination ) {
2005 for( int j=0; j<columns; ++j ) {
2006 for( int k=0; k<src[j].total; ++k ) {
2007 data[j].insert(src[j].values[k], destination + k);
2013 BC_ListBoxItem *item = data[master_column].values[i];
2014 if( item->sublist_active() ) {
2015 if( put_selection(item->get_sublist(), src, destination, counter) )
2024 int BC_ListBox::item_to_index(ArrayList<BC_ListBoxItem*> *data,
2025 BC_ListBoxItem *item, int *counter)
2028 if( !counter ) counter = &temp;
2030 for( int i=0; i<data[master_column].total; ++i ) {
2032 for( int j=0; j<columns; ++j ) {
2033 BC_ListBoxItem *new_item = data[j].values[i];
2034 //printf("BC_ListBox::item_to_index 1 %d %d %p\n", j, i, new_item);
2035 if( new_item == item ) {
2040 BC_ListBoxItem *new_item = data[master_column].values[i];
2041 if( new_item->sublist_active() ) {
2042 if( item_to_index(new_item->get_sublist(), item, counter) >= 0 )
2050 BC_ListBoxItem* BC_ListBox::index_to_item(ArrayList<BC_ListBoxItem*> *data,
2051 int number, int column, int *counter)
2054 if( !counter ) counter = &temp;
2055 for( int i=0; i<data[master_column].total; ++i ) {
2057 if( (*counter) == number ) {
2058 return data[column].values[i];
2060 BC_ListBoxItem *item = data[master_column].values[i];
2061 if( item->sublist_active() ) {
2062 BC_ListBoxItem *result = index_to_item(item->get_sublist(),
2063 number, column, counter);
2064 if( result ) return result;
2070 int BC_ListBox::get_cursor_item(ArrayList<BC_ListBoxItem*> *data, int cursor_x, int cursor_y,
2071 BC_ListBoxItem **item_return, int *counter, int expanded)
2074 if( !data ) return -1;
2075 if( !counter ) counter = &temp;
2077 // Icons are not treed
2078 switch( display_format ) {
2080 case LISTBOX_ICONS_PACKED:
2081 case LISTBOX_ICON_LIST: {
2082 for( int j=data[master_column].total; --j>=0; ) {
2083 int icon_x, icon_y, icon_w, icon_h;
2084 int text_x, text_y, text_w, text_h;
2085 BC_ListBoxItem *item = data[master_column].values[j];
2086 get_icon_mask(item, icon_x, icon_y, icon_w, icon_h);
2087 get_text_mask(item, text_x, text_y, text_w, text_h);
2089 if( (cursor_x >= icon_x && cursor_x < icon_x + icon_w &&
2090 cursor_y >= icon_y && cursor_y < icon_y + icon_h) ||
2091 (cursor_x >= text_x && cursor_x < text_x + text_w &&
2092 cursor_y >= text_y && cursor_y < text_y + text_h) ) {
2093 if( item_return ) (*item_return) = item;
2101 // Cursor is inside items rectangle
2102 if( cursor_x >= 0 &&
2103 cursor_x < (yscrollbar ?
2104 gui->get_w() - get_resources()->vscroll_data[SCROLL_HANDLE_UP]->get_w() :
2106 // Only clamp y if we're not in a SELECT operation.
2107 (current_operation == BC_ListBox::SELECT ||
2108 (cursor_y > get_title_h() + LISTBOX_BORDER &&
2109 cursor_y < gui->get_h())) ) {
2110 // Search table for cursor obstruction
2111 for( int i=0; i<data[master_column].total; ++i ) {
2112 BC_ListBoxItem *item = data[master_column].values[i];
2115 // Cursor is inside item on current level
2116 if( expanded && item->selectable &&
2117 cursor_y >= get_item_y(item) &&
2118 cursor_y < get_item_y(item) + get_item_h(item) ) {
2119 //printf("BC_ListBox::get_cursor_item %d %d %p\n", master_column, i, item);
2120 if( item_return ) (*item_return) = item;
2121 if( expanded < 0 ) (*counter) = i;
2125 // Descend into sublist
2126 if( item->sublist_active() ) {
2127 if( get_cursor_item(item->get_sublist(),
2128 cursor_x, cursor_y, item_return, counter,
2129 item->get_expand()) >= 0 ) {
2130 if( expanded < 0 ) (*counter) = i;
2143 int BC_ListBox::get_cursor_item_no()
2146 gui->get_relative_cursor(rx, ry);
2147 return get_cursor_item(data, rx, ry, 0, 0);
2150 int BC_ListBox::get_cursor_data_item_no(BC_ListBoxItem **item_return)
2153 gui->get_relative_cursor(rx, ry);
2154 return get_cursor_item(data, rx, ry, item_return, 0, -1);
2157 int BC_ListBox::repeat_event(int64_t duration)
2159 switch( current_operation ) {
2160 // Repeat out of bounds selection
2162 if( duration != get_resources()->scroll_repeat ) break;
2163 return rectangle_scroll_event();
2166 if( duration != get_resources()->scroll_repeat ) break;
2167 if( !drag_scroll_event() ) break;
2170 update_scrollbars(1);
2174 if( duration != get_resources()->scroll_repeat ) break;
2175 return select_scroll_event();
2179 if( duration != get_resources()->tooltip_delay ) break;
2180 if( !button_highlighted || !is_popup ) break;
2181 if( !tooltip_text || !tooltip_text[0] ) break;
2189 int BC_ListBox::cursor_enter_event()
2193 switch( current_operation ) {
2194 // Cursor moved over button, pressed, and exited.
2195 case BUTTON_DOWN_SELECT:
2196 if( top_level->event_win == win ) {
2197 current_operation = BUTTON_DN;
2199 button_highlighted = 1;
2205 // Cursor entered button
2206 if( is_popup && top_level->event_win == win ) {
2207 button_highlighted = 1;
2212 // TODO: Need to get the highlighted column title or item
2213 if( gui && top_level->event_win == gui->win ) {
2214 list_highlighted = 1;
2224 int BC_ListBox::cursor_leave_event()
2226 if( current_operation == COLUMN_DRAG ) return 0;
2229 if( button_highlighted ) {
2230 button_highlighted = 0;
2235 if( list_highlighted ) {
2236 list_highlighted = 0;
2237 highlighted_item = -1;
2238 highlighted_ptr = 0;
2239 highlighted_title = -1;
2240 int redraw_toggles = 0;
2241 for( int i=0; i<expanders.total; ++i )
2242 expanders.values[i]->cursor_leave_event(&redraw_toggles);
2250 int BC_ListBox::get_first_selection(ArrayList<BC_ListBoxItem*> *data, int *result)
2253 if( !result ) result = &temp;
2255 for( int i=0; i<data[master_column].total; ++i ) {
2256 BC_ListBoxItem *item = data[master_column].values[i];
2258 if( item->selected ) return (*result);
2259 if( item->sublist_active() ) {
2260 if( get_first_selection(item->get_sublist(), result) >= 0 )
2267 int BC_ListBox::get_total_items(ArrayList<BC_ListBoxItem*> *data,
2272 if( !result ) result = &temp;
2274 for( int i=0; i<data[master_column].total; ++i ) {
2276 if( data[master_column].values[i]->sublist_active() )
2277 get_total_items(data[master_column].values[i]->get_sublist(),
2286 int BC_ListBox::get_last_selection(ArrayList<BC_ListBoxItem*> *data,
2296 for( int i=data[master_column].total-1; i>=0; --i ) {
2297 BC_ListBoxItem *item = data[master_column].values[i];
2299 if( item->selected ) {
2301 return get_total_items(data, 0, master_column) - (*result) /* - 1 */;
2306 if( item->sublist_active() ) {
2307 if( get_last_selection(item->get_sublist(), result) >= 0 ) {
2309 return get_total_items(data, 0, master_column) - (*result) /* - 1 */;
2318 void BC_ListBox::select_range(ArrayList<BC_ListBoxItem*> *data,
2319 int start, int end, int *current)
2322 if( !current ) current = &temp;
2324 for( int i=0; i<data[master_column].total; ++i ) {
2326 if( (*current) >= start && (*current) < end ) {
2327 for( int j=0; j<columns; ++j )
2328 data[j].values[i]->selected = 1;
2330 BC_ListBoxItem *item = data[master_column].values[i];
2331 if( item->sublist_active() )
2332 select_range(item->get_sublist(), start, end, current);
2337 // Fill items between current selection and new selection
2338 int BC_ListBox::expand_selection(int button_press, int selection_number)
2340 int old_selection_start = selection_start;
2341 int old_selection_end = selection_end;
2343 // printf("BC_ListBox::expand_selection %d %d\n",
2344 // selection_center,
2345 // selection_number);
2347 // Calculate the range to select based on selection_center and selection_number
2348 if( selection_number < selection_center ) {
2349 selection_start = selection_number;
2352 selection_end = selection_number + 1;
2355 //printf("BC_ListBox::expand_selection %d %d %d %d\n", old_selection_start, old_selection_end, selection_start, selection_end);
2356 // Recurse through all the items and select the desired range
2357 select_range(data, selection_start, selection_end);
2360 return (old_selection_start != selection_start ||
2361 old_selection_end != selection_end);
2364 int BC_ListBox::toggle_item_selection(ArrayList<BC_ListBoxItem*> *data,
2365 int selection_number, int *counter)
2368 if( !counter ) counter = &temp;
2370 for( int i=0; i<data[master_column].total; ++i ) {
2371 BC_ListBoxItem *item = data[master_column].values[i];
2373 if( (*counter) == selection_number ) {
2374 // Get new value for selection
2375 int selected = !item->selected;
2377 for( int j=0; j<columns; ++j )
2378 data[j].values[i]->selected = selected;
2382 // Descend into sublist
2383 if( item->sublist_active() ) {
2384 if( toggle_item_selection(item->get_sublist(),
2385 selection_number, counter) )
2394 void BC_ListBox::set_all_selected(ArrayList<BC_ListBoxItem*> *data, int value)
2396 for( int i=0; i<data[master_column].total; ++i ) {
2397 for( int j=0; j<columns; ++j ) {
2398 BC_ListBoxItem *item = data[j].values[i];
2399 item->selected = value;
2401 BC_ListBoxItem *item = data[master_column].values[i];
2402 if( item->get_sublist() ) {
2403 set_all_selected(item->get_sublist(), value);
2408 void BC_ListBox::set_selected(ArrayList<BC_ListBoxItem*> *data,
2409 int item_number, int value, int *counter)
2412 if( !counter ) counter = &temp;
2413 for( int i=0; i<data[master_column].total&&(*counter)!=item_number; ++i ) {
2415 if( (*counter) == item_number ) {
2416 for( int j=0; j<columns; ++j ) {
2417 BC_ListBoxItem *item = data[j].values[i];
2418 item->selected = value;
2423 BC_ListBoxItem *item = data[master_column].values[i];
2424 if( item->sublist_active() ) {
2425 set_selected(item->get_sublist(), item_number, value, counter);
2430 int BC_ListBox::update_selection(ArrayList<BC_ListBoxItem*> *data,
2431 int selection_number, int *counter)
2435 if( !counter ) counter = &temp;
2437 for( int i=0; i<data[master_column].total; ++i ) {
2438 BC_ListBoxItem *item = data[master_column].values[i];
2440 if( (*counter) == selection_number && !item->selected ) {
2442 for( int j=0; j<columns; ++j )
2443 data[j].values[i]->selected = 1;
2446 if( (*counter) != selection_number && item->selected ) {
2448 for( int j=0; j<columns; ++j )
2449 data[j].values[i]->selected = 0;
2451 if( item->sublist_active() )
2452 result |= update_selection(item->get_sublist(),
2459 void BC_ListBox::promote_selections(ArrayList<BC_ListBoxItem*> *data,
2460 int old_value, int new_value)
2462 for( int i=0; i<data[master_column].total; ++i ) {
2463 for( int j=0; j<columns; ++j ) {
2464 BC_ListBoxItem *item = data[j].values[i];
2465 if( item->selected == old_value ) item->selected = new_value;
2467 BC_ListBoxItem *item = data[master_column].values[i];
2468 if( item->sublist_active() )
2469 promote_selections(item->get_sublist(), old_value, new_value);
2473 int BC_ListBox::focus_out_event()
2479 int BC_ListBox::button_press_event()
2482 BC_ListBoxItem *current_item = 0;
2484 int do_selection_change = 0;
2485 const int debug = 0;
2488 if( debug ) printf("BC_ListBox::button_press_event %d this=%p event_win=%p %p %p %p\n",
2489 __LINE__, this, (void*)top_level->event_win,
2490 (void*)(gui ? gui->win : 0), (void*)win, (void*)parent_window->win);
2492 // Pressed in button
2493 if( is_popup && top_level->event_win == win ) {
2494 if( debug ) printf("BC_ListBox::button_press_event %d\n", __LINE__);
2495 current_operation = BUTTON_DN;
2499 if( !active && !disabled ) {
2500 top_level->deactivate();
2507 // Pressed in scrollbar
2508 if( (xscrollbar && top_level->event_win == xscrollbar->win) ||
2509 (yscrollbar && top_level->event_win == yscrollbar->win) ) {
2510 if( debug ) printf("BC_ListBox::button_press_event %d\n", __LINE__);
2515 if( gui && top_level->event_win == gui->win ) {
2516 if( debug ) printf("BC_ListBox::button_press_event %d\n", __LINE__);
2518 // Activate list items
2519 // If it is a suggestion popup, it is visible without being active
2521 if( debug ) printf("BC_ListBox::button_press_event %d\n", __LINE__);
2522 if( !is_suggestions ) top_level->deactivate();
2523 if( debug ) printf("BC_ListBox::button_press_event %d\n", __LINE__);
2525 if( debug ) printf("BC_ListBox::button_press_event %d\n", __LINE__);
2528 if( current_operation != NO_OPERATION ) {
2529 switch( current_operation ) {
2532 return drag_stop_event();
2536 // Wheel mouse pressed
2537 if( get_buttonpress() == 4 ) {
2538 if( current_operation == NO_OPERATION ) {
2539 current_operation = WHEEL;
2541 set_yposition(yposition - gui->get_h() / 10, 0);
2543 update_scrollbars(0);
2544 highlighted_ptr = 0;
2545 highlighted_item = get_cursor_item(data,
2546 top_level->cursor_x, top_level->cursor_y,
2554 if( get_buttonpress() == 5 ) {
2555 if( current_operation == NO_OPERATION ) {
2556 current_operation = WHEEL;
2558 set_yposition(yposition + gui->get_h() / 10, 0);
2560 update_scrollbars(0);
2561 highlighted_ptr = 0;
2562 highlighted_item = get_cursor_item(data,
2563 top_level->cursor_x, top_level->cursor_y,
2571 // Pressed over column title division
2572 if( test_column_divisions(gui->get_cursor_x(),
2573 gui->get_cursor_y(),
2575 drag_cursor_x = gui->get_cursor_x() + xposition;
2577 drag_column_w = column_width[highlighted_division - 1];
2579 drag_column_w = default_column_width[highlighted_division - 1];
2581 current_operation = DRAG_DIVISION;
2585 // Pressed in column title
2586 if( test_column_titles(gui->get_cursor_x(), gui->get_cursor_y()) ) {
2587 current_operation = COLUMN_DN;
2588 button_highlighted = 0;
2589 list_highlighted = 1;
2594 // Pressed in expander
2595 if( test_expanders() ) {
2596 current_operation = EXPAND_DN;
2597 // Need to redraw items because of alpha
2602 // Pressed over item
2603 if( (selection_number = get_cursor_item(data,
2604 gui->get_cursor_x(), gui->get_cursor_y(),
2605 ¤t_item)) >= 0 ) {
2606 if( debug ) printf("BC_ListBox::button_press_event %d\n", __LINE__);
2608 // Get item button was pressed over
2609 selection_number2 = selection_number1;
2610 selection_number1 = selection_number;
2612 selection_start = -1;
2616 // Multiple item selection is possible
2617 if( selection_mode == LISTBOX_MULTIPLE &&
2618 (ctrl_down() || shift_down()) ) {
2619 // Expand text selection.
2620 // Fill items between selected region and current item.
2622 (display_format == LISTBOX_TEXT ||
2623 display_format == LISTBOX_ICON_LIST) ) {
2624 // Get first item selected
2625 selection_start = get_first_selection(data);
2626 // Get last item selected
2627 selection_end = get_last_selection(data);
2628 // Get center of selected region
2629 if( selection_end > selection_start ) {
2630 selection_center = (selection_end + selection_start) >> 1;
2633 selection_center = selection_number;
2635 // Deselect everything.
2636 set_all_selected(data, 0);
2637 // Select just the items
2638 expand_selection(1, selection_number);
2641 // Toggle a single item on or off
2643 toggle_item_selection(data, selection_number);
2644 new_value = current_item->selected;
2647 // Select single item
2649 if( !current_item->selected || (get_buttonpress() == 1 && !new_value) ) {
2650 set_all_selected(data, 0);
2651 set_selected(data, selection_number, 1);
2657 current_operation = SELECT;
2658 highlighted_item = selection_number;
2659 highlighted_ptr = current_item;
2660 button_highlighted = 0;
2661 list_highlighted = 1;
2664 do_selection_change = 1;
2668 // Pressed over nothing. Start rectangle selection.
2670 if( get_buttonpress() == 1 &&
2671 selection_mode == LISTBOX_MULTIPLE ) {
2672 if( !shift_down() ) {
2673 // Deselect all and redraw if anything was selected
2674 if( get_selection_number(0, 0) >= 0 ) {
2675 set_all_selected(data, 0);
2677 do_selection_change = 1;
2682 // Promote selections to protect from a rectangle selection
2683 promote_selections(data, 1, 2);
2686 // Start rectangle selection
2687 current_operation = SELECT_RECT;
2688 rect_x1 = rect_x2 = get_cursor_x();
2689 rect_y1 = rect_y2 = get_cursor_y();
2697 // Suggestion box is not active but visible, so lie to get it to deactivate
2698 if( is_popup && (active || (is_suggestions && gui)) ) {
2700 if( debug ) printf("BC_ListBox::button_press_event %d\n", __LINE__);
2706 if( do_selection_change ) selection_changed();
2707 if( debug ) printf("BC_ListBox::button_press_event %d %d\n", __LINE__, result);
2712 int BC_ListBox::button_release_event()
2717 unset_scroll_repeat();
2719 //printf("BC_ListBox::button_release_event 1 %d\n", current_operation);
2720 switch( current_operation ) {
2722 current_operation = NO_OPERATION;
2727 current_operation = NO_OPERATION;
2731 // Release item selection
2732 case BUTTON_DOWN_SELECT:
2734 //printf("BC_ListBox::button_release_event 10\n");
2735 current_operation = NO_OPERATION;
2737 selection_number1 = selection_number = get_cursor_item_no();
2738 //printf("BC_ListBox::button_release_event %d %d\n", selection_number2, selection_number1);
2743 if( selection_number >= 0 ) {
2748 // Second button release outside button
2749 if( button_releases > 1 ) {
2754 if( top_level->get_double_click() &&
2755 selection_number2 == selection_number1 &&
2756 selection_number2 >= 0 && selection_number1 >= 0 ) {
2766 // Demote selections from rectangle selection
2767 promote_selections(data, 2, 1);
2770 // Hide rectangle overlay
2772 current_operation = NO_OPERATION;
2776 // Release popup button
2779 current_operation = NO_OPERATION;
2783 // Second button release inside button
2784 if( button_releases > 1 ) {
2791 current_operation = NO_OPERATION;
2792 // Update the sort column and the sort order for the user only if the existing
2793 // sort column is valid.
2794 if( sort_column >= 0 ) {
2795 // Invert order only if column is the same
2796 if( highlighted_title == sort_column )
2797 sort_order = sort_order == SORT_ASCENDING ?
2798 SORT_DESCENDING : SORT_ASCENDING;
2799 // Set the new sort column
2800 sort_column = highlighted_title;
2801 if( !sort_order_event() ) {
2806 // Sorting not enabled. Redraw the title state.
2814 int redraw_toggles = 0;
2815 for( int i=0; i<expanders.total&&!result; ++i ) {
2816 if( expanders.values[i]->button_release_event(&redraw_toggles) ) {
2820 // Need to redraw items because of alpha
2821 if( redraw_toggles ) draw_items(1);
2822 current_operation = NO_OPERATION;
2826 // Can't default to NO_OPERATION because it may be used in a drag event.
2831 if( do_event ) handle_event();
2833 //printf("BC_ListBox::button_release_event %d %d\n", __LINE__, get_window_lock());
2837 int BC_ListBox::get_title_h()
2839 if( display_format == LISTBOX_TEXT ||
2840 display_format == LISTBOX_ICON_LIST )
2841 return column_titles ? column_bg[0]->get_h() : 0;
2845 void BC_ListBox::reset_cursor(int new_cursor)
2848 if( gui->get_cursor() != new_cursor ) {
2849 gui->set_cursor(new_cursor, 0, 0);
2853 if( get_cursor() != new_cursor ) {
2854 set_cursor(new_cursor, 0, 0);
2858 int BC_ListBox::test_column_divisions(int cursor_x, int cursor_y, int &new_cursor)
2860 if( gui && column_titles &&
2861 cursor_y >= 0 && cursor_y < get_title_h() &&
2862 cursor_x >= 0 && cursor_x < gui->get_w() ) {
2863 for( int i=1; i<columns; ++i ) {
2864 if( cursor_x >= -xposition + get_column_offset(i) - 5 &&
2865 cursor_x < -xposition + get_column_offset(i) +
2866 get_resources()->listbox_title_hotspot ) {
2867 highlighted_item = -1;
2868 highlighted_ptr = 0;
2869 highlighted_division = i;
2870 highlighted_title = -1;
2871 list_highlighted = 1;
2872 new_cursor = HSEPARATE_CURSOR;
2877 highlighted_division = -1;
2881 int BC_ListBox::test_column_titles(int cursor_x, int cursor_y)
2883 if( gui && column_titles &&
2884 cursor_y >= 0 && cursor_y < get_title_h() &&
2885 cursor_x >= 0 && cursor_x < gui->get_w() ) {
2886 for( int i=0; i<columns; ++i ) {
2887 if( cursor_x >= -xposition + get_column_offset(i) &&
2888 (cursor_x < -xposition + get_column_offset(i + 1) ||
2889 i == columns - 1) ) {
2890 highlighted_item = -1;
2891 highlighted_ptr = 0;
2892 highlighted_division = -1;
2893 highlighted_title = i;
2894 list_highlighted = 1;
2899 highlighted_title = -1;
2903 int BC_ListBox::test_expanders()
2905 for( int i=0; i<expanders.total; ++i ) {
2906 if( expanders.values[i]->button_press_event() ) {
2907 current_operation = EXPAND_DN;
2915 int BC_ListBox::cursor_motion_event()
2917 int redraw = 0, result = 0;
2918 int new_cursor = ARROW_CURSOR;
2920 selection_number = -1;
2923 switch( current_operation ) {
2925 // Button pressed and slid off button
2926 if( !cursor_inside() ) {
2927 current_operation = BUTTON_DOWN_SELECT;
2933 case DRAG_DIVISION: {
2934 // int new_w = get_cursor_x() +
2936 // get_column_offset(highlighted_division - 1);
2937 int difference = get_cursor_x() + xposition - drag_cursor_x;
2938 int new_w = drag_column_w + difference;
2940 new_cursor = HSEPARATE_CURSOR;
2942 if( column_width ) {
2943 column_width[highlighted_division - 1] = new_w;
2946 default_column_width[highlighted_division - 1] = new_w;
2949 column_width_boundaries();
2951 // Force update of coords
2952 set_autoplacement(data, 0, 1);
2953 column_resize_event();
2957 update_scrollbars(1);
2962 if( test_drag_scroll(get_cursor_x(), get_cursor_y()) )
2963 set_scroll_repeat();
2965 int old_x1 = MIN(rect_x1, rect_x2);
2966 int old_x2 = MAX(rect_x1, rect_x2);
2967 int old_y1 = MIN(rect_y1, rect_y2);
2968 int old_y2 = MAX(rect_y1, rect_y2);
2970 int new_rect_x2 = get_cursor_x();
2971 int new_rect_y2 = get_cursor_y();
2973 int x1 = MIN(rect_x1, new_rect_x2);
2974 int x2 = MAX(rect_x1, new_rect_x2);
2975 int y1 = MIN(rect_y1, new_rect_y2);
2976 int y2 = MAX(rect_y1, new_rect_y2);
2978 // Adjust rectangle coverage
2979 if( old_x1 != x1 || old_x2 != x2 ||
2980 old_y1 != y1 || old_y2 != y2 ) {
2982 redraw = select_rectangle(data, x1, y1, x2, y2);
2987 //printf("BC_ListBox::cursor_motion_event %d\n", __LINE__);
2992 rect_x2 = get_cursor_x();
2993 rect_y2 = get_cursor_y();
2997 update_scrollbars(1);
2998 selection_changed();
2999 //printf("BC_ListBox::cursor_motion_event %d\n", __LINE__);
3002 if( old_x1 != x1 || old_x2 != x2 ||
3003 old_y1 != y1 || old_y2 != y2 ) {
3004 //printf("BC_ListBox::cursor_motion_event %d\n", __LINE__);
3012 int old_highlighted_item = highlighted_item;
3014 if( test_drag_scroll(get_cursor_x(), get_cursor_y()) )
3015 set_scroll_repeat();
3017 highlighted_item = selection_number = get_cursor_item(data,
3018 get_cursor_x(), get_cursor_y(), &highlighted_ptr);
3021 // Deselect all items and select just the one we're over
3022 if( selection_number >= 0 && !allow_drag &&
3023 ((!shift_down() && !ctrl_down()) ||
3024 selection_mode == LISTBOX_SINGLE) ) {
3025 redraw = update_selection(data, selection_number);
3028 // Expand multiple selection
3029 if( selection_mode == LISTBOX_MULTIPLE &&
3030 (shift_down() || ctrl_down()) ) {
3031 // Expand selected region in text mode centered around initial range
3032 if( (display_format == LISTBOX_TEXT ||
3033 display_format == LISTBOX_ICON_LIST) &&
3035 // Select just the items
3036 redraw = expand_selection(0, selection_number);
3038 // Set the one item we're over to the selection value determined in
3039 // button_press_event.
3041 set_selected(data, selection_number, new_value);
3045 if( highlighted_item != old_highlighted_item ) {
3048 update_scrollbars(1);
3049 //printf("BC_ListBox::cursor_motion_event %d %d\n", highlighted_item, old_highlighted_item);
3050 selection_changed();
3054 case BUTTON_DOWN_SELECT:
3055 // Went back into button area
3056 if( cursor_inside() ) {
3057 current_operation = BUTTON_DN;
3062 // Went into item area
3064 int cursor_x = 0, cursor_y = 0;
3065 translate_coordinates(top_level->event_win, gui->win,
3066 top_level->cursor_x, top_level->cursor_y,
3067 &cursor_x, &cursor_y);
3068 int old_highlighted_item = highlighted_item;
3069 highlighted_item = selection_number = get_cursor_item(data,
3074 if( highlighted_item != old_highlighted_item ) {
3075 update_selection(data, selection_number);
3077 selection_changed();
3083 int redraw_toggles = 0;
3084 for( int i=0; i<expanders.total&&!result; ++i ) {
3085 result = expanders.values[i]->cursor_motion_event(
3088 if( redraw_toggles ) {
3089 // Need to redraw items because of the alpha
3094 case NO_OPERATION: {
3095 int cursor_x = get_cursor_x(), cursor_y = get_cursor_y();
3096 if( gui && top_level->event_win == gui->win ) {
3097 int old_highlighted_title = highlighted_title;
3098 int old_list_highlighted = list_highlighted;
3099 int old_highlighted_item = highlighted_item;
3100 int redraw_titles = 0;
3101 int redraw_border = 0;
3102 int redraw_items = 0;
3103 int redraw_toggles = 0;
3106 // Test if cursor moved over a title division
3107 test_column_divisions(cursor_x, cursor_y, new_cursor);
3109 // Test if cursor moved over a title
3110 if( highlighted_division < 0 ) {
3111 test_column_titles(cursor_x, cursor_y);
3114 // Test if cursor moved over expander
3115 if( highlighted_division < 0 && highlighted_title < 0 &&
3116 (display_format == LISTBOX_TEXT ||
3117 display_format == LISTBOX_ICON_LIST) ) {
3118 for( int i=0; i<expanders.total; ++i ) {
3119 expanders.values[i]->cursor_motion_event(
3122 //printf("BC_ListBox::cursor_motion_event %d\n", redraw_toggles);
3125 // Test if cursor moved over an item
3126 if( highlighted_division < 0 && highlighted_title < 0 ) {
3127 highlighted_item = get_cursor_item(data,
3134 // Clear title highlighting if moved over division
3135 if( old_highlighted_title != highlighted_title ) {
3139 // Highlight list border
3140 if( old_list_highlighted != list_highlighted ) {
3144 // Moved out of item area
3145 if( old_highlighted_item != highlighted_item ) {
3146 if( !mouse_over_event(highlighted_item) )
3150 //printf("BC_ListBox::cursor_motion_event 1 %d\n", highlighted_item);
3152 // Change cursor to title division adjustment
3153 reset_cursor(new_cursor);
3155 if( redraw_items ) {
3163 if( redraw_toggles )
3167 if( redraw_items || redraw_titles ||
3168 redraw_border || redraw_toggles ) {
3175 if( !result && list_highlighted ) {
3176 list_highlighted = 0;
3177 highlighted_item = -1;
3178 highlighted_ptr = 0;
3179 highlighted_title = -1;
3180 highlighted_division = -1;
3190 int BC_ListBox::drag_start_event()
3192 switch( current_operation ) {
3194 if( expander_active() ) break;
3195 if( gui && gui->is_event_win() && allow_drag ) {
3196 BC_ListBoxItem *item_return = 0;
3197 selection_number = get_cursor_item(data,
3198 top_level->cursor_x,
3199 top_level->cursor_y,
3202 if( selection_number >= 0 ) {
3204 get_abs_cursor(cx, cy);
3205 if( item_return->icon_vframe ) {
3206 drag_popup = new BC_DragWindow(this,
3207 item_return->icon_vframe, cx, cy);
3210 if( item_return->icon ) {
3211 drag_popup = new BC_DragWindow(this,
3212 item_return->icon, cx, cy);
3215 drag_popup = new BC_DragWindow(this,
3216 drag_icon_vframe, cx, cy);
3218 current_operation = DRAG_ITEM;
3219 // require shift down for scrolling
3220 if( allow_drag < 0 && shift_down() )
3221 set_scroll_repeat();
3228 if( gui && gui->is_event_win() && allow_drag_column ) {
3230 get_abs_cursor(cx, cy);
3231 cx -= drag_column_icon_vframe->get_w() / 2,
3232 cy -= drag_column_icon_vframe->get_h() / 2;
3233 drag_popup = new BC_DragWindow(this,
3234 drag_column_icon_vframe, cx, cy);
3235 dragged_title = highlighted_title;
3236 current_operation = COLUMN_DRAG;
3246 int BC_ListBox::drag_motion_event()
3248 //printf("BC_ListBox::drag_motion_event 1 %d\n", current_operation);
3249 switch( current_operation ) {
3252 int new_highlighted_item = -1;
3253 BC_ListBoxItem *new_highlighted_ptr = 0;
3254 new_highlighted_item = get_cursor_item(data,
3255 top_level->cursor_x, top_level->cursor_y,
3256 &new_highlighted_ptr);
3258 if( new_highlighted_item != highlighted_item ) {
3262 // Always update highlighted value for drag_stop
3263 highlighted_item = new_highlighted_item;
3264 highlighted_ptr = new_highlighted_ptr;
3265 //printf("BC_ListBox::drag_motion_event 1 %p\n", highlighted_ptr);
3269 update_scrollbars(1);
3272 return drag_popup->cursor_motion_event(); }
3275 int old_highlighted_title = highlighted_title;
3276 test_column_titles(get_cursor_x(), get_cursor_y());
3277 if( old_highlighted_title != highlighted_title ) {
3280 return drag_popup->cursor_motion_event(); }
3286 int BC_ListBox::drag_stop_event()
3289 unset_scroll_repeat();
3290 switch( current_operation ) {
3292 // Inside window boundary
3293 if( top_level->cursor_x > 0 &&
3294 top_level->cursor_x < gui->get_w() - drag_popup->get_w() / 2 &&
3295 top_level->cursor_y > 0 &&
3296 top_level->cursor_y < gui->get_h() - drag_popup->get_h() / 2 ) {
3300 if( display_format == LISTBOX_ICONS ||
3301 display_format == LISTBOX_ICONS_PACKED ) {
3302 reposition_item(data,
3304 top_level->cursor_x - drag_popup->get_w() / 2 -
3305 LISTBOX_MARGIN - 2 + xposition,
3306 top_level->cursor_y - drag_popup->get_h() / 2 -
3307 LISTBOX_MARGIN - 2 + yposition);
3311 if( process_drag ) {
3312 // Move selected items from data to temporary
3313 ArrayList<BC_ListBoxItem*> *src_items =
3314 new ArrayList<BC_ListBoxItem*>[columns];
3315 move_selection(src_items, data);
3317 int destination = highlighted_item = item_to_index(data,
3319 // Insert items from temporary to data
3320 put_selection(data, src_items, destination);
3322 delete [] src_items;
3323 set_autoplacement(data, 0, 1);
3329 drag_popup->drag_failure_event();
3334 if( dragged_title != highlighted_title ) {
3335 if( highlighted_title >= 0 ) {
3336 if( !move_column_event() ) draw_titles(1);
3339 drag_popup->drag_failure_event();
3345 current_operation = NO_OPERATION;
3355 BC_DragWindow* BC_ListBox::get_drag_popup()
3360 int BC_ListBox::translation_event()
3362 if( is_popup && gui ) {
3363 int new_x = gui->get_x() +
3364 (top_level->last_translate_x - top_level->prev_x -
3365 BC_DisplayInfo::get_left_border());
3366 int new_y = gui->get_y() +
3367 (top_level->last_translate_y - top_level->prev_y -
3368 BC_DisplayInfo::get_top_border());
3370 gui->reposition_window(new_x, new_y);
3376 int BC_ListBox::reposition_window(int x, int y, int w, int h, int flush)
3380 if( h != -1 ) popup_h = h;
3381 //printf("BC_ListBox::reposition_window %d %d\n", popup_w, popup_h);
3385 xscrollbar->reposition_window(get_xscroll_x(),
3387 get_xscroll_width());
3389 yscrollbar->reposition_window(get_yscroll_x(),
3391 get_yscroll_height());
3395 BC_WindowBase::reposition_window(x, y, w, h);
3401 int BC_ListBox::deactivate()
3404 // printf("BC_ListBox::deactivate %d this=%p gui=%p active=%d\n",
3405 // __LINE__, this, gui, active);
3408 //printf("BC_ListBox::deactivate %d this=%p gui=%p\n", __LINE__, this, gui);
3410 delete gui; gui = 0;
3415 highlighted_item = -1;
3416 highlighted_ptr = 0;
3419 //printf("BC_ListBox::deactivate %d this=%p\n", __LINE__, this);
3421 top_level->active_subwindow = 0;
3427 int BC_ListBox::activate(int take_focus)
3429 if( active ) return 0;
3432 set_active_subwindow(this);
3433 button_releases = 0;
3434 if( !is_popup || gui ) return 0;
3435 int wx = get_x(), wy = get_y() + get_h();
3436 if( justify == LISTBOX_RIGHT ) wx += get_w() - popup_w;
3439 XTranslateCoordinates(top_level->display,
3440 parent_window->win, top_level->rootwin,
3441 wx, wy, &abs_x, &abs_y, &xwin);
3444 return activate(abs_x, abs_y);
3447 int BC_ListBox::activate(int x, int y, int w, int h)
3449 if( !is_popup || gui ) return 0;
3451 if( w != -1 ) popup_w = w;
3452 if( h != -1 ) popup_h = h;
3454 if( y + popup_h > top_level->get_root_h(0) )
3455 y -= get_h() + popup_h;
3456 add_subwindow(gui = new BC_Popup(this,
3457 x, y, popup_w, popup_h, -1, 0, 0));
3459 gui->show_window(1);
3463 int BC_ListBox::is_active()
3468 int BC_ListBox::expander_active()
3470 for( int i=0; i<expanders.total; ++i ) {
3471 if( expanders.values[i]->value ) return 1;
3476 int BC_ListBox::keypress_event()
3478 if( !active ) return 0;
3480 //printf("BC_ListBox::keypress_event %d\n", __LINE__);
3482 int result = 0, redraw = 0;
3483 int view_items = last_in_view - first_in_view + 1;
3484 if( view_items <= 0 ) view_items = view_h / get_text_height(MEDIUMFONT);
3485 int new_item = -1, new_selection = -1;
3487 switch( top_level->get_keypress() ) {
3490 top_level->deactivate();
3492 // If user is manipulating popup with keyboard, don't pass on event.
3494 //printf("BC_ListBox::keypress_event %d %p\n", __LINE__, get_selection(0, 0));
3495 if( top_level->get_keypress() == RETURN )
3497 //printf("BC_ListBox::keypress_event %d %p\n", __LINE__, get_selection(0, 0));
3505 new_selection = new_item = select_previous(0);
3507 //printf("BC_ListBox::keypress_event 1 %d\n", new_item);
3508 if( new_item >= 0 ) {
3509 center_selection(new_item);
3517 new_selection = new_item = select_next(0);
3519 if( new_item >= 0 ) {
3520 center_selection(new_item);
3528 new_selection = new_item = select_previous(view_items - 1);
3530 if( new_item >= 0 ) {
3531 center_selection(new_item);
3539 new_selection = new_item = select_next(view_items - 1);
3541 if( new_item >= 0 ) {
3542 center_selection(new_item);
3568 if( show_query && !ctrl_down() ) {
3569 int query_len = strlen(query);
3570 if( query_len < (int)sizeof(query)-1 &&
3571 top_level->get_keypress() > 30 &&
3572 top_level->get_keypress() < 127 ) {
3573 query[query_len++] = top_level->get_keypress();
3574 query[query_len] = 0;
3575 new_selection = query_list();
3578 if( top_level->get_keypress() == BACKSPACE ) {
3579 if( query_len > 0 ) query[--query_len] = 0;
3580 new_selection = query_list();
3583 show_tooltip(query);
3595 update_scrollbars(1);
3598 //printf("BC_ListBox::keypress_event %d new_selection=%d\n", __LINE__, new_selection);
3599 if( new_selection >= 0 && !is_suggestions ) {
3600 //printf("BC_ListBox::keypress_event %d\n", __LINE__);
3601 selection_changed();
3602 //printf("BC_ListBox::keypress_event %d\n", __LINE__);
3609 BC_Pixmap* BC_ListBox::get_bg_surface()
3615 void BC_ListBox::draw_background()
3617 if( !bg_draw ) return;
3619 // White background pixmap
3620 set_color(top_level->get_resources()->listbox_inactive);
3621 draw_box(0, 0, bg_surface->get_w(), bg_surface->get_h(), bg_surface);
3623 // Optional heroine pixmap
3625 bg_surface->draw_pixmap(bg_pixmap,
3626 bg_surface->get_w() - top_level->get_resources()->listbox_bg->get_w(),
3630 void BC_ListBox::clear_listbox(int x, int y, int w, int h)
3632 gui->draw_pixmap(bg_surface, x, y, w, h, x, y - title_h);
3635 void BC_ListBox::update_format(int display_format, int redraw)
3637 this->display_format = display_format;
3638 packed_icons = display_format == LISTBOX_ICONS_PACKED ? 1 : 0;
3639 xposition = 0; yposition = 0;
3640 if( redraw && gui ) draw_items(1, 1);
3643 int BC_ListBox::get_format()
3645 return display_format;
3650 int BC_ListBox::draw_items(int flush, int draw_bg)
3653 BC_Resources *resources = get_resources();
3655 //dump(data, columns);
3657 // Calculate items width
3658 calculate_item_coords();
3659 // Create and destroy scrollbars as needed
3662 if( bg_draw ) this->bg_draw = 1;
3668 if( display_format == LISTBOX_ICONS ||
3669 display_format == LISTBOX_ICONS_PACKED ) {
3670 clear_listbox(2, 2 + title_h, view_w, view_h);
3672 set_font(MEDIUMFONT);
3673 for( int i=0; i<data[master_column].size(); ++i ) {
3674 BC_ListBoxItem *item = data[master_column].get(i);
3675 if( get_item_x(item) >= -get_item_w(item) &&
3676 get_item_x(item) < view_w &&
3677 get_item_y(item) >= -get_item_h(item) + title_h &&
3678 get_item_y(item) < view_h + title_h ) {
3679 item->set_in_view(1);
3680 if( first_in_view < 0 ) first_in_view = i;
3682 int item_color = get_item_highlight(data, 0, i);
3683 int icon_x, icon_y, icon_w, icon_h;
3684 int text_x, text_y, text_w, text_h;
3687 get_icon_mask(item, icon_x, icon_y, icon_w, icon_h);
3688 get_text_mask(item, text_x, text_y, text_w, text_h);
3690 if( item_color != resources->listbox_inactive ) {
3691 gui->set_color(BLACK);
3692 gui->draw_rectangle(icon_x, icon_y, icon_w, icon_h);
3693 gui->set_color(item_color);
3694 gui->draw_box(icon_x + 1, icon_y + 1, icon_w - 2, icon_h - 2);
3695 gui->set_color(BLACK);
3696 gui->draw_rectangle(text_x, text_y, text_w, text_h);
3697 gui->set_color(item_color);
3698 gui->draw_box(text_x + 1, text_y + 1, text_w - 2, text_h - 2);
3700 if( icon_position == ICON_LEFT )
3701 gui->draw_box(text_x - 1, text_y + 1, 2, text_h - 2);
3703 if( icon_position == ICON_TOP )
3704 gui->draw_line(text_x + 1, text_y, text_x + icon_w - 2, text_y);
3705 if( text_x + text_w < icon_x + icon_w ) {
3706 gui->set_color(BLACK);
3707 gui->draw_line(text_x + text_w, icon_y + icon_h,
3708 icon_x + icon_w, icon_y + icon_h);
3712 gui->set_color(get_item_color(data, 0, i));
3713 VFrame *vicon = item->get_vicon_frame();
3715 gui->pixmap->draw_vframe(vicon, icon_x, icon_y);
3716 else if( item->icon )
3717 gui->pixmap->draw_pixmap(item->icon, icon_x, icon_y);
3718 char item_text[BCTEXTLEN];
3719 if( display_format == LISTBOX_ICONS_PACKED )
3720 gui->truncate_text(item_text, item->text, text_w);
3722 strcpy(item_text, item->text);
3723 gui->draw_text(text_x, text_y + get_baseline(item), item_text);
3726 item->set_in_view(0);
3731 // Draw one column at a time so text overruns don't go into the next column
3732 // clear column backgrounds
3733 int current_toggle = 0;
3734 for( int j=0; j<columns; ++j ) {
3735 clear_listbox(LISTBOX_BORDER + get_column_offset(j) - xposition,
3736 LISTBOX_BORDER + title_h,
3737 get_column_width(j, 1),
3739 // Draw rows in the column recursively
3740 draw_text_recursive(data, j, 0, ¤t_toggle);
3743 // Delete excess expanders
3744 while( expanders.total > current_toggle ) {
3745 expanders.remove_object();
3749 // draw user images if available
3751 // Draw titles on top of rows for superposition effect
3754 // Clear garbage from bottom right corner
3755 if( xscrollbar && yscrollbar && is_popup ) {
3756 gui->draw_top_background(parent_window,
3757 popup_w - get_resources()->vscroll_data[SCROLL_HANDLE_UP]->get_w(),
3758 popup_h - get_resources()->hscroll_data[SCROLL_HANDLE_UP]->get_h(),
3759 get_resources()->vscroll_data[SCROLL_HANDLE_UP]->get_w(),
3760 get_resources()->hscroll_data[SCROLL_HANDLE_UP]->get_h());
3767 if( current_operation == SELECT_RECT )
3777 void BC_ListBox::draw_text_recursive(ArrayList<BC_ListBoxItem*> *data,
3778 int column, int indent, int *current_toggle)
3781 BC_Resources *resources = get_resources();
3783 set_font(MEDIUMFONT);
3786 // Search for a branch and make room for toggle if there is one
3788 for( int i=0; i<data[column].size(); ++i ) {
3789 if( data[column].get(i)->get_sublist() ) {
3790 subindent = BC_WindowBase::get_resources()->listbox_expand[0]->get_w();
3796 row_height = row_ascent = row_descent = 0;
3797 for( int i=0; i<data[column].total; ++i ) {
3798 BC_ListBoxItem *item = data[column].values[i];
3799 int ht = get_text_h(item);
3800 if( ht > row_height ) row_height = ht;
3801 int bl = get_baseline(item);
3802 if( bl > row_ascent ) row_ascent = bl;
3804 if( dt > row_descent ) row_descent = dt;
3807 for( int i=0; i<data[column].size(); ++i ) {
3809 BC_ListBoxItem *item = data[column].values[i];
3810 BC_ListBoxItem *first_item = data[master_column].values[i];
3812 if( get_item_y(item) >= -get_item_h(item) + title_h &&
3813 get_item_y(item) < view_h + title_h ) {
3814 int row_color = get_item_highlight(data, 0, i);
3815 int x, y, w, h, column_width;
3817 get_text_mask(item, x, y, w, h);
3818 column_width = get_column_width(column, 1);
3819 if( x + column_width > view_w + LISTBOX_BORDER * 2 )
3820 column_width = view_w + LISTBOX_BORDER * 2 - x;
3822 if( row_color != resources->listbox_inactive ) {
3823 gui->set_color(row_color);
3824 gui->draw_box(x, y, column_width, h);
3825 gui->set_color(BLACK);
3826 int xx = x + column_width-1;
3827 gui->draw_line(x, y, xx, y);
3829 if( display_format == LISTBOX_ICON_LIST ) {
3830 int ih = get_icon_h(item);
3831 if( ih > hh ) hh = ih;
3834 gui->draw_line(x, yy, xx, yy);
3837 gui->set_color(get_item_color(data, column, i));
3840 if( column == 0 && display_format == LISTBOX_ICON_LIST ) {
3841 int ix = get_icon_x(item), iy = get_icon_y(item);
3842 VFrame *vicon = item->get_vicon_frame();
3844 gui->pixmap->draw_vframe(vicon, ix, iy);
3845 x += vicon->get_w() + ICON_MARGIN;
3847 else if( item->icon ) {
3848 gui->pixmap->draw_pixmap(item->icon, ix, iy);
3849 x += item->icon->get_w() + ICON_MARGIN;
3854 // Indent only applies to first column
3856 x + LISTBOX_BORDER + LISTBOX_MARGIN +
3857 (column == 0 ? indent + subindent : 0),
3858 y + get_baseline(item), item->text);
3859 item->set_in_view(1);
3861 if( first_in_view < 0 ) first_in_view = i;
3866 if( column == 0 && item->get_sublist() && item->get_columns() ) {
3867 // Create new expander
3868 if( *current_toggle >= expanders.total ) {
3869 BC_ListBoxToggle *toggle =
3870 new BC_ListBoxToggle(this, item,
3871 x + LISTBOX_BORDER + LISTBOX_MARGIN + indent, y);
3873 expanders.append(toggle);
3875 // Reposition existing expander
3877 BC_ListBoxToggle *toggle = expanders.values[*current_toggle];
3878 //printf("BC_ListBox::draw_text_recursive 1 %d\n", *current_toggle);
3879 toggle->update(item,
3880 x + LISTBOX_BORDER + LISTBOX_MARGIN + indent, y, 0);
3882 (*current_toggle)++;
3889 item->set_in_view(0);
3891 // Descend into sublist
3892 if( first_item->sublist_active() ) {
3893 draw_text_recursive(first_item->get_sublist(),
3895 indent + LISTBOX_INDENT,
3901 int BC_ListBox::draw_border(int flash)
3903 BC_Resources *resources = top_level->get_resources();
3904 gui->draw_3d_border(0, 0,
3905 view_w + LISTBOX_BORDER * 2, view_h + title_h + LISTBOX_BORDER * 2,
3906 resources->listbox_border1,
3908 resources->listbox_border2_hi : resources->listbox_border2,
3910 resources->listbox_border3_hi : resources->listbox_border3,
3911 resources->listbox_border4);
3920 void BC_ListBox::draw_title(int number)
3922 // Column title background
3923 int image_number = 0;
3924 if( number == highlighted_title ) {
3926 if( current_operation == COLUMN_DN )
3930 gui->draw_3segmenth(get_column_offset(number) - xposition + LISTBOX_BORDER,
3932 get_column_width(number, 1) + get_resources()->listbox_title_overlap,
3933 column_bg[image_number]);
3935 int title_x = -xposition + get_column_offset(number) +
3936 LISTBOX_MARGIN + LISTBOX_BORDER;
3937 title_x += get_resources()->listbox_title_margin;
3939 gui->set_color(get_resources()->listbox_title_color);
3940 gui->draw_text(title_x,
3941 LISTBOX_MARGIN + LISTBOX_BORDER + get_text_ascent(MEDIUMFONT),
3942 column_titles[number]);
3944 // Column sort order
3945 if( number == sort_column ) {
3946 BC_Pixmap *src = sort_order == SORT_ASCENDING ?
3947 column_sort_dn : column_sort_up;
3949 // int column_offset = get_column_offset(number) - xposition + LISTBOX_BORDER;
3950 // int column_width = get_column_width(number, 1);
3951 // int toggle_x = column_offset + column_width - LISTBOX_BORDER;
3952 // if( toggle_x > items_w ) toggle_x = items_w;
3953 // toggle_x -= 5 + src->get_w();
3956 get_text_width(MEDIUMFONT, column_titles[number]) +
3959 gui->draw_pixmap(src,
3961 title_h / 2 - src->get_h() / 2 + LISTBOX_BORDER);
3965 int BC_ListBox::draw_titles(int flash)
3967 if( column_titles &&
3968 (display_format == LISTBOX_TEXT ||
3969 display_format == LISTBOX_ICON_LIST) ) {
3970 //printf("BC_ListBox::draw_titles 1 %d\n", highlighted_title);
3971 for( int i=0; i<columns; ++i ) {
3972 if( i != highlighted_title )
3976 if( highlighted_title >= 0 ) draw_title(highlighted_title);
3986 void BC_ListBox::draw_toggles(int flash)
3988 for( int i=0; i<expanders.total; ++i )
3989 expanders.values[i]->draw(0);
3991 //printf("BC_ListBox::draw_toggles 1 %d\n", flash);
3992 if( flash && expanders.total ) {
3997 int BC_ListBox::draw_rectangle(int flash)
3999 int x1 = MIN(rect_x1, rect_x2);
4000 int x2 = MAX(rect_x1, rect_x2);
4001 int y1 = MIN(rect_y1, rect_y2);
4002 int y2 = MAX(rect_y1, rect_y2);
4004 if( x1 == x2 || y1 == y2 ) return 0;
4007 gui->set_color(WHITE);
4008 gui->draw_rectangle(x1, y1, x2 - x1, y2 - y1);
4018 void BC_ListBox::dump(ArrayList<BC_ListBoxItem*> *data, int columns,
4019 int indent, int master_column)
4022 printf("BC_ListBox::dump 1\n");
4025 for( int i=0; i<data[master_column].total; ++i ) {
4026 for( int k=0; k<indent; ++k )
4028 for( int j=0; j<columns; ++j ) {
4029 BC_ListBoxItem *item = data[j].values[i];
4030 printf("%d,%d,%d=%s ",
4031 item->get_text_x(), item->get_text_y(),
4032 item->autoplace_text, item->get_text());
4036 if( data[master_column].values[i]->get_sublist() ) {
4037 dump(data[master_column].values[i]->get_sublist(),
4038 data[master_column].values[i]->get_columns(),