// ====================================================== scrollbars
-
-BC_ListBoxYScroll::BC_ListBoxYScroll(BC_ListBox *listbox,
- int total_height,
- int view_height,
- int position)
- : BC_ScrollBar(listbox->get_yscroll_x(),
- listbox->get_yscroll_y(),
- SCROLL_VERT,
- listbox->get_yscroll_height(),
- total_height,
- position,
- view_height)
+BC_ListBoxYScroll::BC_ListBoxYScroll(BC_ListBox *listbox)
+ : BC_ScrollBar(listbox->get_yscroll_x(), listbox->get_yscroll_y(),
+ listbox->yscroll_orientation, listbox->get_yscroll_height(),
+ listbox->items_h, listbox->yposition, listbox->view_h)
{
this->listbox = listbox;
}
return 1;
}
-
-
-
-
-
-
-BC_ListBoxXScroll::BC_ListBoxXScroll(BC_ListBox *listbox,
- int total_width,
- int view_width,
- int position)
- : BC_ScrollBar(listbox->get_xscroll_x(),
- listbox->get_xscroll_y(),
- SCROLL_HORIZ,
- listbox->get_xscroll_width(),
- total_width,
- position,
- view_width)
+BC_ListBoxXScroll::BC_ListBoxXScroll(BC_ListBox *listbox)
+ : BC_ScrollBar(listbox->get_xscroll_x(), listbox->get_xscroll_y(),
+ listbox->xscroll_orientation, listbox->get_xscroll_width(),
+ listbox->items_w, listbox->xposition, listbox->view_w)
{
this->listbox = listbox;
}
}
-
-
-
-
-
-
BC_ListBoxToggle::BC_ListBoxToggle(BC_ListBox *listbox,
BC_ListBoxItem *item,
int x,
new_value = 0;
need_xscroll = 0;
need_yscroll = 0;
+ xscroll_orientation = SCROLL_HORIZ;
+ yscroll_orientation = SCROLL_VERT;
bg_tile = 0;
bg_draw = 1;
drag_popup = 0;
// reset the search engine
//printf("BC_ListBox::BC_ListBox 4\n");
+ show_query = 0;
reset_query();
//printf("BC_ListBox::BC_ListBox 5\n");
}
int BC_ListBox::get_text_h(BC_ListBoxItem *item)
{
int h = item->get_text_h();
- if( h < 0 ) item->set_text_h(h = get_text_height(MEDIUMFONT));
+ if( h < 0 ) item->set_text_h(h = get_text_height(MEDIUMFONT, item->get_text()));
return h;
}
}
+void BC_ListBox::set_scroll_stretch(int xv, int yv)
+{
+ if( xv >= 0 ) xscroll_orientation =
+ !xv ? SCROLL_HORIZ : SCROLL_HORIZ + SCROLL_STRETCH;
+ if( yv >= 0 ) yscroll_orientation =
+ !yv ? SCROLL_VERT : SCROLL_VERT + SCROLL_STRETCH;
+}
int BC_ListBox::get_yscroll_x()
{
{
w = get_text_width(MEDIUMFONT, item->text) + LISTBOX_MARGIN * 2;
h = row_height;
+ int ih = get_icon_h(item);
+ if( h < ih ) h = ih;
}
return 0;
}
{
if(!xscrollbar)
{
- destination->add_subwindow(xscrollbar =
- new BC_ListBoxXScroll(this,
- w_needed,
- view_w,
- xposition));
+ xscrollbar = new BC_ListBoxXScroll(this);
+ destination->add_subwindow(xscrollbar);
xscrollbar->show_window(0);
xscrollbar->bound_to = this;
}
{
if(!yscrollbar)
{
- destination->add_subwindow(yscrollbar =
- new BC_ListBoxYScroll(this,
- h_needed,
- view_h,
- yposition));
+ yscrollbar = new BC_ListBoxYScroll(this);
+ destination->add_subwindow(yscrollbar);
yscrollbar->show_window(0);
yscrollbar->bound_to = this;
}
case NO_OPERATION:
// Show tooltip
- if(button_highlighted && is_popup && !tooltip_done &&
+ if(button_highlighted && is_popup &&
tooltip_text && tooltip_text[0] != 0 &&
duration == get_resources()->tooltip_delay)
{
show_tooltip();
- tooltip_done = 1;
return 1;
}
break;
int BC_ListBox::deactivate()
{
+ hide_tooltip();
// printf("BC_ListBox::deactivate %d this=%p gui=%p active=%d\n",
// __LINE__,
// this,
int BC_ListBox::activate(int take_focus)
{
if( active ) return 0;
+ active = 1;
if( take_focus )
set_active_subwindow(this);
button_releases = 0;
int BC_ListBox::activate(int x, int y, int w, int h)
{
- if( active || !is_popup || gui ) return 0;
+ if( !is_popup || gui ) return 0;
+ active = 1;
if(w != -1) popup_w = w;
if(h != -1) popup_h = h;
reset_query();
- active = 1;
if( y + popup_h > top_level->get_root_h(0) )
y -= get_h() + popup_h;
add_subwindow(gui = new BC_Popup(this,
{
case ESC:
case RETURN:
- case BACKSPACE:
top_level->deactivate();
// If user is manipulating popup with keyboard, don't pass on event.
if(query_len > 0) query[--query_len] = 0;
new_selection = query_list();
}
-
+ if( show_query ) {
+ if( query_len > 0 )
+ show_tooltip(query);
+ else
+ hide_tooltip();
+ }
redraw = 1;
result = 1;
}
void BC_ListBox::update_format(int display_format, int redraw)
{
this->display_format = display_format;
+ xposition = 0; yposition = 0;
if( redraw && gui ) draw_items(1, 1);
}
gui->set_color(row_color);
gui->draw_box(x, y, column_width, h);
gui->set_color(BLACK);
- int yy = y, xx = x + column_width-1;
- gui->draw_line(x, yy, xx, yy);
- yy = y + row_height;
+ int xx = x + column_width-1;
+ gui->draw_line(x, y, xx, y);
+ int hh = row_height;
+ if( display_format == LISTBOX_ICON_LIST ) {
+ int ih = get_icon_h(item);
+ if( ih > hh ) hh = ih;
+ }
+ int yy = y + hh-1;
gui->draw_line(x, yy, xx, yy);
}