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 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)
return 0;
}
+int BC_ListBox::is_highlighted()
+{
+ return list_highlighted;
+}
+
void BC_ListBox::expand_item(BC_ListBoxItem *item, int expand)
{
if( item ) {
case LISTBOX_ICONS:
case LISTBOX_ICONS_PACKED:
case LISTBOX_ICON_LIST: {
- 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;
+ 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: {
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 = packed_icons ?
- get_icon_w(item) + ICON_MARGIN * 4 :
+ get_icon_w(item) + ICON_MARGIN * 2 :
get_text_w(item) + ICON_MARGIN * 2 ;
h = get_text_h(item) + ICON_MARGIN * 2;
break; }
// Icons are not treed
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;
return j;
}
}
- if( display_format == LISTBOX_ICONS ) return -1;
- } // fall through
+ return -1; }
case LISTBOX_TEXT:
if( !gui ) break;
// Text is treed
return -1;
}
+// short version
+int BC_ListBox::get_cursor_item()
+{
+ int rx, ry;
+ gui->get_relative_cursor(rx, ry);
+ return get_cursor_item(data, rx, ry, 0, 0);
+}
+
int BC_ListBox::repeat_event(int64_t duration)
{
switch( current_operation ) {
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 10\n");
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();
//printf("BC_ListBox::button_release_event %d %d\n", selection_number2, selection_number1);
}
// 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);
}
// 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);
+ 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 + ICON_MARGIN,
- text_y + ICON_MARGIN + get_baseline(item), item_text);
+ gui->draw_text(text_x, text_y + get_baseline(item), item_text);
}
else
item->set_in_view(0);
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;
}
}