yscrollbar = 0;
current_cursor = ARROW_CURSOR;
gui = 0;
- view_h = 0;
- view_w = 0;
+ view_w = items_w = 0;
+ view_h = items_h = 0;
title_h = 0;
active = 0;
is_suggestions = 0;
bg_tile = 0;
bg_draw = 1;
drag_popup = 0;
+ dragged_title = 0;
selection_number1 = -1;
selection_number2 = -1;
bg_surface = 0;
bg_pixmap = 0;
row_height = row_ascent = row_descent = 0;
-
+ selection_start = 0;
+ selection_center = 0;
+ selection_end = -1;
+ selection_number = -1;
current_operation = NO_OPERATION;
button_highlighted = 0;
+ button_releases = 0;
list_highlighted = 0;
disabled = 0;
+ scroll_repeat = 0;
allow_drag_scroll = 1;
process_drag = 1;
+ for( int i=0; i<32; ++i ) default_column_width[i] = 0;
sort_column = -1;
sort_order = 0;
drag_icon_vframe = 0;
drag_column_icon_vframe = 0;
-
-
+ drag_cursor_x = 0;
+ drag_column_w = 0;
+ temp_display_format = display_format;
+ packed_icons = display_format == LISTBOX_ICONS_PACKED ? 1 : 0;
+ rect_x1 = rect_x2 = 0;
+ rect_y1 = rect_y2 = 0;
// reset the search engine
//printf("BC_ListBox::BC_ListBox 4\n");
*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->sublist_active() && item->get_columns() ) {
calculate_last_coords_recursive(item->get_sublist(),
icon_x, next_icon_x, next_icon_y, next_text_y, 0);
}
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();
+ int icon_h = data[0].get(i)->icon->get_h() + 2*ICON_MARGIN;
+ if( row_height < icon_h ) row_height = icon_h;
}
}
}
int bl = get_baseline(item);
if( bl > row_ascent ) row_ascent = bl;
int dt = ht - bl;
- if( dt > row_descent ) row_ascent = bl;
+ if( dt > row_descent ) row_descent = dt;
// printf("BC_ListBox::calculate_item_coords_recursive %p %d %d %d %d %s \n",
-// item->get_sublist(), item->get_columns(), item->get_expand(),
+// item->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 ) {
// Set up a sublist
BC_ListBoxItem *item = data[master_column].values[i];
- if( item->get_sublist() && item->get_columns() &&
- item->get_expand() ) {
+ if( item->sublist_active() && item->get_columns() ) {
calculate_item_coords_recursive( item->get_sublist(),
icon_x, next_icon_x, next_icon_y, next_text_y, 0);
}
{
this->is_suggestions = value;
}
+void BC_ListBox::set_scroll_repeat()
+{
+ if( scroll_repeat ) return;
+ scroll_repeat = 1;
+ set_repeat(get_resources()->scroll_repeat);
+}
+
+void BC_ListBox::unset_scroll_repeat()
+{
+ if( !scroll_repeat ) return;
+ scroll_repeat = 0;
+ unset_repeat(get_resources()->scroll_repeat);
+}
void BC_ListBox::set_use_button(int value)
{
int BC_ListBox::get_item_x(BC_ListBoxItem *item)
{
- if( display_format == LISTBOX_TEXT )
- return item->text_x - xposition + 2;
- if( display_format == LISTBOX_ICON_LIST )
+ switch( display_format ) {
+ case LISTBOX_TEXT:
+ case LISTBOX_ICON_LIST:
return item->text_x - xposition + 2;
- return item->icon_x - xposition + 2;
+ case LISTBOX_ICONS:
+ case LISTBOX_ICONS_PACKED:
+ return item->icon_x - xposition + 2;
+ }
+ return 0;
}
int BC_ListBox::get_item_y(BC_ListBoxItem *item)
{
- if( display_format == LISTBOX_TEXT )
- return item->text_y - yposition + title_h + 2;
- if( display_format == LISTBOX_ICON_LIST )
+ switch( display_format ) {
+ case LISTBOX_TEXT:
+ case LISTBOX_ICON_LIST:
return item->text_y - yposition + title_h + 2;
- return item->icon_y - yposition + title_h + 2;
+ case LISTBOX_ICONS:
+ case LISTBOX_ICONS_PACKED:
+ return item->icon_y - yposition + 2;
+ }
+ return 0;
}
int BC_ListBox::get_item_w(BC_ListBoxItem *item)
{
- if( display_format == LISTBOX_ICONS ) {
+ switch( display_format ) {
+ case LISTBOX_TEXT:
+ case LISTBOX_ICON_LIST: {
+ return get_text_w(item) + 2 * LISTBOX_MARGIN; }
+ case LISTBOX_ICONS:
+ case LISTBOX_ICONS_PACKED: {
int x, y, w, h;
get_icon_mask(item, x, y, w, h);
int icon_w = w;
return icon_position == ICON_LEFT ? icon_w + text_w :
icon_w > text_w ? icon_w : text_w;
+ }
}
- return get_text_w(item) + 2 * LISTBOX_MARGIN;
+ return 0;
}
int BC_ListBox::get_item_h(BC_ListBoxItem *item)
{
- if( display_format == LISTBOX_ICONS ) {
+ switch( display_format ) {
+ case LISTBOX_TEXT:
+ case LISTBOX_ICON_LIST:
+ return get_text_h(item);
+ case LISTBOX_ICONS:
+ case LISTBOX_ICONS_PACKED: {
int x, y, w, h;
get_icon_mask(item, x, y, w, h);
int icon_h = h;
int text_h = h;
return icon_position != ICON_LEFT ? icon_h + text_h :
- icon_h > text_h ? icon_h : text_h;
+ icon_h > text_h ? icon_h : text_h; }
}
- return get_text_h(item);
+ return 0;
+}
+
+
+int BC_ListBox::get_icon_x(BC_ListBoxItem *item)
+{
+ return get_item_x(item) + ICON_MARGIN;
}
+int BC_ListBox::get_icon_y(BC_ListBoxItem *item)
+{
+ return get_item_y(item) + ICON_MARGIN;
+}
int BC_ListBox::get_icon_w(BC_ListBoxItem *item)
{
- return item->get_icon_w();
+ return item->get_icon_w() + 2*ICON_MARGIN;
}
int BC_ListBox::get_icon_h(BC_ListBoxItem *item)
{
- return item->get_icon_h();
+ return item->get_icon_h() + 2*ICON_MARGIN;
}
int BC_ListBox::get_text_w(BC_ListBoxItem *item)
int BC_ListBox::get_items_width()
{
- int widest = 0;
-
- if( display_format == LISTBOX_ICONS ) {
+ switch( display_format ) {
+ case LISTBOX_TEXT:
+ return get_column_offset(columns);
+ case LISTBOX_ICONS:
+ case LISTBOX_ICONS_PACKED: {
+ int widest = 0;
for( int i=0; i<columns; ++i ) {
for( int j=0; j<data[i].total; ++j ) {
int x1, x, y, w, h;
get_icon_mask(item, x, y, w, h);
if( x1 + w > widest ) widest = x1 + w;
- if( display_format == LISTBOX_ICONS && icon_position == ICON_LEFT )
+ if( icon_position == ICON_LEFT )
x1 += w;
get_text_mask(item, x, y, w, h);
if( x1 + w > widest ) widest = x1 + w;
}
}
- }
- else
- if( display_format == LISTBOX_TEXT ) {
- return get_column_offset(columns);
- }
- else {
+ return widest; }
+ case LISTBOX_ICON_LIST:
return get_column_offset(columns);
}
- return widest;
+ return 0;
}
int BC_ListBox::get_items_height(ArrayList<BC_ListBoxItem*> *data, int columns,
int x, y, w, h;
BC_ListBoxItem *item = data[master_column].values[j];
- if( display_format == LISTBOX_ICONS ||
- display_format == LISTBOX_ICON_LIST ) {
+ switch( display_format ) {
+ case LISTBOX_TEXT:
+ get_text_mask(item, x, y, w, h);
+ *result += h;
+// Descend into sublist
+ if( item->sublist_active() )
+ get_items_height(item->get_sublist(), item->get_columns(), result);
+ break;
+ case LISTBOX_ICONS:
+ case LISTBOX_ICONS_PACKED:
+ case LISTBOX_ICON_LIST:
get_icon_mask(item, x, y, w, h);
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;
- }
- else {
- get_text_mask(item, x, y, w, h);
- *result += h;
-// Descend into sublist
- if( item->get_sublist() && item->get_expand() ) {
- get_items_height(item->get_sublist(),
- item->get_columns(),
- result);
- }
+ break;
}
}
return 0;
}
+int BC_ListBox::is_highlighted()
+{
+ return list_highlighted;
+}
+
void BC_ListBox::expand_item(BC_ListBoxItem *item, int expand)
{
if( item ) {
{
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->sublist_active() ) {
item->expand = 0;
collapse_recursive(item->get_sublist(), master_column);
}
}
BC_ListBoxItem *item = data[master_column].values[i];
- if( item->get_sublist() ) {
+ if( item->sublist_active() ) {
set_autoplacement(item->get_sublist(), do_icons, do_text);
}
}
int BC_ListBox::get_icon_mask(BC_ListBoxItem *item,
int &x, int &y, int &w, int &h)
{
- if( display_format == LISTBOX_ICONS ) {
- x = get_item_x(item);
- y = get_item_y(item);
- w = get_icon_w(item) + ICON_MARGIN * 2;
- h = get_icon_h(item) + ICON_MARGIN * 2;
- }
- else
+ switch( display_format ) {
+ case LISTBOX_ICONS:
+ case LISTBOX_ICONS_PACKED:
+ case LISTBOX_ICON_LIST: {
+ x = get_icon_x(item);
+ y = get_icon_y(item);
+ w = get_icon_w(item);
+ h = get_icon_h(item);
+ break; }
+ case LISTBOX_TEXT:
+ default: {
x = y = w = h = 0;
+ break; }
+ }
return 0;
}
x = get_item_x(item);
y = get_item_y(item);
- if( display_format == LISTBOX_ICONS ) {
+ switch( display_format ) {
+ case LISTBOX_TEXT: {
+ w = get_text_w(item) + LISTBOX_MARGIN * 2;
+ h = get_text_h(item);
+ break; }
+ case LISTBOX_ICONS:
+ case LISTBOX_ICONS_PACKED: {
if( icon_position == ICON_LEFT ) {
- x += get_icon_w(item) + ICON_MARGIN * 2;
+ x += get_icon_w(item);
y += get_icon_h(item) - get_text_h(item);
}
else {
- y += get_icon_h(item) + ICON_MARGIN;
+ y += get_icon_h(item);
}
- w = get_text_w(item) + ICON_MARGIN * 2;
+ w = packed_icons ?
+ get_icon_w(item) + ICON_MARGIN * 2 :
+ get_text_w(item) + ICON_MARGIN * 2 ;
h = get_text_h(item) + ICON_MARGIN * 2;
- }
- else
- if( display_format == LISTBOX_TEXT ) {
- w = get_text_w(item) + LISTBOX_MARGIN * 2;
- h = get_text_h(item);
- }
- else {
+ break; }
+ case LISTBOX_ICON_LIST: {
w = get_text_width(MEDIUMFONT, item->text) + LISTBOX_MARGIN * 2;
h = row_height;
- int ih = get_icon_h(item);
- if( h < ih ) h = ih;
+ break; }
+ default:
+ w = h = 0;
}
return 0;
}
}
}
- if( item->get_sublist() ) {
+ if( item->sublist_active() ) {
BC_ListBoxItem *result = get_selection_recursive(item->get_sublist(),
column,
selection_number);
return (*counter);
}
}
- if( item->get_sublist() ) {
+ if( item->sublist_active() ) {
int result = get_selection_number_recursive(item->get_sublist(),
column, selection_number, counter);
if( result >= 0 ) return result;
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() ) {
+ if( current_item->sublist_active() ) {
int result = select_previous(skip, selected_item, counter,
current_item->get_sublist(), got_first, got_second);
if( *got_second )
}
// Descend into expanded level
- if( current_item->get_sublist() &&
- current_item->get_expand() ) {
+ if( current_item->sublist_active() ) {
int result = select_next(skip, selected_item, counter,
current_item->get_sublist(), got_first, got_second);
if( *got_second ) {
BC_ListBoxItem *item = data[master_column].values[i];
if( (*counter) == selection ) {
BC_ListBoxItem *top_item = this->data[master_column].values[0];
-
-
- if( display_format == LISTBOX_ICONS ) {
+ switch( display_format ) {
+ case LISTBOX_ICONS:
+ case LISTBOX_ICONS_PACKED: {
// Icon is out of window
if( item->icon_y-yposition > view_h-get_text_h(item) ||
item->icon_y-yposition < 0 ) {
data[master_column].values[selection]->icon_x - xposition < 0 ) {
xposition = item->icon_x - view_w / 2;
}
- }
- else {
+ break; }
+ case LISTBOX_TEXT:
+ case LISTBOX_ICON_LIST:
// Text coordinate is out of window
if( item->text_y-yposition > view_h-get_text_h(item) ||
item->text_y-yposition < 0 ) {
- yposition = item->text_y -
- top_item->text_y -
- view_h / 2;
+ yposition = item->text_y - top_item->text_y - view_h / 2;
}
}
return 1;
}
// Descend
- if( item->get_sublist() ) {
- int result = center_selection(selection,
- item->get_sublist(),
- counter);
+ if( item->sublist_active() ) {
+ int result = center_selection(selection, item->get_sublist(), counter);
if( result ) return result;
}
}
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 ) {
+ switch( display_format ) {
+ case LISTBOX_ICONS:
+ case LISTBOX_ICONS_PACKED: {
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);
result = 1;
}
}
- }
- else {
+ break; }
+ case LISTBOX_TEXT:
+ case LISTBOX_ICON_LIST: {
if( x2 >= 0 &&
x1 < (yscrollbar ?
gui->get_w() - get_resources()->vscroll_data[SCROLL_HANDLE_UP]->get_w() :
result = 1;
}
}
+ break; }
}
}
BC_ListBoxItem *item = data[master_column].values[i];
- if( item->get_sublist() &&
- item->get_expand() )
+ if( item->sublist_active() ) {
result |= select_rectangle(item->get_sublist(),
x1, y1, x2, y2);
+ }
}
return result;
}
continue;
}
// Descend into sublist
- if( item->get_sublist() ) {
- move_selection(dst,
- item->get_sublist());
+ if( item->sublist_active() ) {
+ move_selection(dst, item->get_sublist());
}
++i;
}
}
BC_ListBoxItem *item = data[master_column].values[i];
- if( item->get_sublist() ) {
- if( put_selection(item->get_sublist(),
- src,
- destination,
- counter) )
+ if( item->sublist_active() ) {
+ if( put_selection(item->get_sublist(), src, destination, counter) )
return 1;
}
}
}
BC_ListBoxItem *new_item = data[master_column].values[i];
- if( new_item->get_sublist() ) {
- if( item_to_index(new_item->get_sublist(),
- item,
- counter) >= 0 )
+ if( new_item->sublist_active() ) {
+ if( item_to_index(new_item->get_sublist(), item, counter) >= 0 )
return (*counter);
}
}
return data[column].values[i];
}
BC_ListBoxItem *item = data[master_column].values[i];
- if( item->get_sublist() ) {
+ if( item->sublist_active() ) {
BC_ListBoxItem *result = index_to_item(item->get_sublist(),
number, column, counter);
if( result ) return result;
if( !counter ) counter = &temp;
// Icons are not treed
- if( display_format == LISTBOX_ICONS ) {
- for( int j=data[master_column].total-1; j>=0; --j ) {
+ switch( display_format ) {
+ case LISTBOX_ICONS:
+ case LISTBOX_ICONS_PACKED:
+ case LISTBOX_ICON_LIST: {
+ for( int j=data[master_column].total; --j>=0; ) {
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];
return j;
}
}
- }
- else if( gui ) {
+ return -1; }
+ case LISTBOX_TEXT:
+ if( !gui ) break;
// Text is treed
// Cursor is inside items rectangle
if( cursor_x >= 0 &&
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( expanded < 0 ) (*counter) = i;
return (*counter);
}
// Descend into sublist
- if( item->get_sublist() ) {
+ if( item->sublist_active() ) {
if( get_cursor_item(item->get_sublist(),
cursor_x, cursor_y, item_return, counter,
- item->get_expand()) >= 0 )
+ item->get_expand()) >= 0 ) {
+ if( expanded < 0 ) (*counter) = i;
return (*counter);
+ }
}
}
}
+ break;
}
return -1;
}
+// short version
+int BC_ListBox::get_cursor_item_no()
+{
+ int rx, ry;
+ gui->get_relative_cursor(rx, ry);
+ return get_cursor_item(data, rx, ry, 0, 0);
+}
+
+int BC_ListBox::get_cursor_data_item_no(BC_ListBoxItem **item_return)
+{
+ int rx, ry;
+ gui->get_relative_cursor(rx, ry);
+ return get_cursor_item(data, rx, ry, item_return, 0, -1);
+}
+
int BC_ListBox::repeat_event(int64_t duration)
{
switch( current_operation ) {
BC_ListBoxItem *item = data[master_column].values[i];
(*result)++;
if( item->selected ) return (*result);
- if( item->get_sublist() ) {
+ if( item->sublist_active() ) {
if( get_first_selection(item->get_sublist(), result) >= 0 )
return (*result);
}
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]->sublist_active() )
get_total_items(data[master_column].values[i]->get_sublist(),
result,
master_column);
return (*result);
}
- if( item->get_sublist() ) {
+ if( item->sublist_active() ) {
if( get_last_selection(item->get_sublist(), result) >= 0 ) {
if( top_level )
return get_total_items(data, 0, master_column) - (*result) /* - 1 */;
data[j].values[i]->selected = 1;
}
BC_ListBoxItem *item = data[master_column].values[i];
- if( item->get_sublist() )
+ if( item->sublist_active() )
select_range(item->get_sublist(), start, end, current);
}
}
}
// Descend into sublist
- if( item->get_sublist() ) {
+ if( item->sublist_active() ) {
if( toggle_item_selection(item->get_sublist(),
selection_number, counter) )
return 1;
}
BC_ListBoxItem *item = data[master_column].values[i];
- if( item->get_sublist() ) {
+ if( item->sublist_active() ) {
set_selected(item->get_sublist(), item_number, value, counter);
}
}
for( int j=0; j<columns; ++j )
data[j].values[i]->selected = 0;
}
- if( item->get_sublist() )
+ if( item->sublist_active() )
result |= update_selection(item->get_sublist(),
selection_number,
counter);
if( item->selected == old_value ) item->selected = new_value;
}
BC_ListBoxItem *item = data[master_column].values[i];
- if( item->get_sublist() )
+ if( item->sublist_active() )
promote_selections(item->get_sublist(), old_value, new_value);
}
}
int BC_ListBox::button_release_event()
{
int result = 0;
- int cursor_x, cursor_y;
int do_event = 0;
new_value = 0;
+ unset_scroll_repeat();
//printf("BC_ListBox::button_release_event 1 %d\n", current_operation);
switch( current_operation ) {
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);
+ selection_number1 = selection_number = get_cursor_item_no();
//printf("BC_ListBox::button_release_event %d %d\n", selection_number2, selection_number1);
}
case SELECT_RECT:
- unset_repeat(get_resources()->scroll_repeat);
if( data ) {
// Demote selections from rectangle selection
promote_selections(data, 2, 1);
break; }
case SELECT_RECT: {
- if( test_drag_scroll(get_cursor_x(), get_cursor_y()) ) {
- set_repeat(get_resources()->scroll_repeat);
- }
+ if( test_drag_scroll(get_cursor_x(), get_cursor_y()) )
+ set_scroll_repeat();
int old_x1 = MIN(rect_x1, rect_x2);
int old_x2 = MAX(rect_x1, rect_x2);
case SELECT: {
int old_highlighted_item = highlighted_item;
- if( test_drag_scroll(get_cursor_x(),
- get_cursor_y()) ) {
- set_repeat(get_resources()->scroll_repeat);
- }
-
+ if( test_drag_scroll(get_cursor_x(), get_cursor_y()) )
+ set_scroll_repeat();
highlighted_item = selection_number = get_cursor_item(data,
get_cursor_x(), get_cursor_y(), &highlighted_ptr);
// Moved out of item area
if( old_highlighted_item != highlighted_item ) {
- redraw_items = 1;
+ if( !mouse_over_event(highlighted_item) )
+ redraw_items = 1;
}
//printf("BC_ListBox::cursor_motion_event 1 %d\n", highlighted_item);
{
switch( current_operation ) {
case SELECT:
+ if( expander_active() ) break;
if( gui && gui->is_event_win() && allow_drag ) {
BC_ListBoxItem *item_return = 0;
selection_number = get_cursor_item(data,
current_operation = DRAG_ITEM;
// require shift down for scrolling
if( allow_drag < 0 && shift_down() )
- set_repeat(get_resources()->scroll_repeat);
+ set_scroll_repeat();
return 1;
}
}
int BC_ListBox::drag_stop_event()
{
int result = 0;
+ unset_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 &&
// Move icon
- if( display_format == LISTBOX_ICONS ) {
+ if( display_format == LISTBOX_ICONS ||
+ display_format == LISTBOX_ICONS_PACKED ) {
reposition_item(data,
selection_number,
top_level->cursor_x - drag_popup->get_w() / 2 -
return active;
}
+int BC_ListBox::expander_active()
+{
+ for( int i=0; i<expanders.total; ++i ) {
+ if( expanders.values[i]->value ) return 1;
+ }
+ return 0 ;
+}
+
int BC_ListBox::keypress_event()
{
if( !active ) return 0;
break;
default:
- if( !ctrl_down() ) {
+ if( show_query && !ctrl_down() ) {
int query_len = strlen(query);
if( query_len < (int)sizeof(query)-1 &&
top_level->get_keypress() > 30 &&
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();
- }
+ if( query_len > 0 )
+ show_tooltip(query);
+ else
+ hide_tooltip();
redraw = 1;
result = 1;
}
void BC_ListBox::update_format(int display_format, int redraw)
{
this->display_format = display_format;
+ packed_icons = display_format == LISTBOX_ICONS_PACKED ? 1 : 0;
xposition = 0; yposition = 0;
if( redraw && gui ) draw_items(1, 1);
}
first_in_view = -1;
last_in_view = 0;
// Icon display
- if( display_format == LISTBOX_ICONS ) {
+ if( display_format == LISTBOX_ICONS ||
+ display_format == LISTBOX_ICONS_PACKED ) {
clear_listbox(2, 2 + title_h, view_w, view_h);
set_font(MEDIUMFONT);
}
// Draw icons
gui->set_color(get_item_color(data, 0, i));
- if( item->icon )
- gui->pixmap->draw_pixmap(item->icon,
- icon_x + ICON_MARGIN, icon_y + ICON_MARGIN);
-
- gui->draw_text(text_x + ICON_MARGIN,
- text_y + ICON_MARGIN + get_baseline(item), item->text);
+ VFrame *vicon = item->get_vicon_frame();
+ if( vicon )
+ gui->pixmap->draw_vframe(vicon, icon_x, icon_y);
+ else if( item->icon )
+ gui->pixmap->draw_pixmap(item->icon, icon_x, icon_y);
+ char item_text[BCTEXTLEN];
+ if( display_format == LISTBOX_ICONS_PACKED )
+ gui->truncate_text(item_text, item->text, text_w);
+ else
+ strcpy(item_text, item->text);
+ gui->draw_text(text_x, text_y + get_baseline(item), item_text);
}
else
item->set_in_view(0);
int bl = get_baseline(item);
if( bl > row_ascent ) row_ascent = bl;
int dt = ht - bl;
- if( dt > row_descent ) row_ascent = bl;
+ if( dt > row_descent ) row_descent = dt;
}
for( int i=0; i<data[column].size(); ++i ) {
if( column == 0 && display_format == LISTBOX_ICON_LIST ) {
- if( item->icon ) {
- gui->pixmap->draw_pixmap(item->icon, x, y);
+ int ix = get_icon_x(item), iy = get_icon_y(item);
+ VFrame *vicon = item->get_vicon_frame();
+ if( vicon ) {
+ gui->pixmap->draw_vframe(vicon, ix, iy);
+ x += vicon->get_w() + ICON_MARGIN;
+ }
+ else if( item->icon ) {
+ gui->pixmap->draw_pixmap(item->icon, ix, iy);
x += item->icon->get_w() + ICON_MARGIN;
}
}
item->set_in_view(0);
// Descend into sublist
- if( first_item->get_expand() ) {
+ if( first_item->sublist_active() ) {
draw_text_recursive(first_item->get_sublist(),
column,
indent + LISTBOX_INDENT,