// Draw the button for a popup listbox
if( use_button && is_popup ) {
int image_number = 0;
-
- draw_top_background(parent_window, 0, 0, w, h);
-
if( button_highlighted )
image_number = 1;
if( current_operation == BUTTON_DN )
if( disabled )
image_number = 3;
- pixmap->draw_pixmap(button_images[image_number],
- 0, 0, w, h, 0, 0);
+ int iw = button_images[image_number]->get_w();
+ int ih = button_images[image_number]->get_h();
+ pixmap->draw_pixmap(button_images[image_number],0,0,iw,ih);
flash(flush);
}
return 0;
h = get_text_h(item) + ICON_MARGIN * 2;
break; }
case LISTBOX_ICON_LIST: {
- w = get_text_width(MEDIUMFONT, item->text) + LISTBOX_MARGIN * 2;
+ w = column_width ? column_width[0] : default_column_width[0];
h = row_height;
break; }
default:
yposition = item->text_y - top_item->text_y - view_h / 2;
}
}
+ if( yposition < 0 ) yposition = 0;
return 1;
}
int flush = 0;
title_h = get_title_h();
- view_h = popup_h - title_h - 4;
- view_w = popup_w - 4;
+ view_h = popup_h - title_h - yS(4);
+ view_w = popup_w - xS(4);
// Create scrollbars as needed
for( int i=0; i<2; ++i ) {
if( w_needed > view_w ) {
need_xscroll = 1;
- view_h = popup_h -
- title_h -
+ view_h = popup_h - title_h -
get_resources()->hscroll_data[SCROLL_HANDLE_UP]->get_h() -
- 4;
+ yS(4);
}
else {
need_xscroll = 0;
need_yscroll = 1;
view_w = popup_w -
get_resources()->vscroll_data[SCROLL_HANDLE_UP]->get_w() -
- 4;
+ xS(4);
}
else {
need_yscroll = 0;
}
if( !bg_surface ||
- view_w + 4 != bg_surface->get_w() ||
- view_h + 4 != bg_surface->get_h() ) {
+ view_w + xS(4) != bg_surface->get_w() ||
+ view_h + yS(4) != bg_surface->get_h() ) {
if( bg_surface ) delete bg_surface;
- bg_surface = new BC_Pixmap(gui, view_w + 4, view_h + 4);
+ bg_surface = new BC_Pixmap(gui, view_w + xS(4), view_h + yS(4));
bg_draw = 1;
}
return 0;
}
+int BC_ListBox::get_w()
+{
+ return is_popup ? BCPOPUPLISTBOX_W : popup_w;
+}
+int BC_ListBox::get_h()
+{
+ return is_popup ? BCPOPUPLISTBOX_H : popup_h;
+}
+
+int BC_ListBox::gui_tooltip(const char *text)
+{
+ return is_popup && gui ? gui->show_tooltip(text, gui->get_w(),0, -1,-1) : -1;
+}
void BC_ListBox::set_drag_scroll(int value)
{
result = 1;
}
else
- if( get_cursor_y() >= view_h + title_h + 4 ) {
- yposition += get_cursor_y() - (view_h + title_h + 4);
+ if( get_cursor_y() >= view_h + title_h + yS(4) ) {
+ yposition += get_cursor_y() - (view_h + title_h + yS(4));
result = 1;
}
- if( get_cursor_x() < 2 ) {
- xposition -= 2 - get_cursor_x();
+ if( get_cursor_x() < xS(2) ) {
+ xposition -= xS(2) - get_cursor_x();
result = 1;
}
else
- if( get_cursor_x() >= view_w + 2 ) {
- xposition += get_cursor_x() - (view_w + 2);
+ if( get_cursor_x() >= view_w + xS(2) ) {
+ xposition += get_cursor_x() - (view_w + xS(2));
result = 1;
}
// Multiple item selection is possible
if( selection_mode == LISTBOX_MULTIPLE &&
- (ctrl_down() || shift_down()) ) {
+ (ctrl_down() || shift_down() || current_item->selected) ) {
// Expand text selection.
// Fill items between selected region and current item.
if( shift_down() &&
new_value = 1;
}
// Toggle a single item on or off
- else {
+ else if( ctrl_down() ) {
toggle_item_selection(data, selection_number);
new_value = current_item->selected;
}
}
// Select single item
else {
- if( !current_item->selected ) {
+ if( !current_item->selected || (get_buttonpress() == 1 && !new_value) ) {
set_all_selected(data, 0);
- set_selected(data,
- selection_number,
- 1);
+ set_selected(data, selection_number, 1);
}
new_value = 1;
}
if( (display_format == LISTBOX_TEXT ||
display_format == LISTBOX_ICON_LIST) &&
shift_down() ) {
-// Deselect everything.
- set_all_selected(data, 0);
-
// Select just the items
redraw = expand_selection(0, selection_number);
}
reposition_item(data,
selection_number,
top_level->cursor_x - drag_popup->get_w() / 2 -
- LISTBOX_MARGIN - 2 + xposition,
+ LISTBOX_MARGIN - xS(2) + xposition,
top_level->cursor_y - drag_popup->get_h() / 2 -
- LISTBOX_MARGIN - 2 + yposition);
+ LISTBOX_MARGIN - yS(2) + yposition);
}
else
// Move rows
XTranslateCoordinates(top_level->display,
parent_window->win, top_level->rootwin,
wx, wy, &abs_x, &abs_y, &xwin);
- if( x <= 0 ) x = 2;
- if( y <= 0 ) y = 2;
+ if( x <= 0 ) x = xS(2);
+ if( y <= 0 ) y = yS(2);
return activate(abs_x, abs_y);
}
int BC_ListBox::keypress_event()
{
- if( !active ) return 0;
+ if( !active ) return context_help_check_and_show();
//printf("BC_ListBox::keypress_event %d\n", __LINE__);
break;
case LEFT:
- xposition -= 10;
+ xposition -= xS(10);
redraw = 1;
result = 1;
break;
case RIGHT:
- xposition += 10;
+ xposition += xS(10);
redraw = 1;
result = 1;
break;
//printf("BC_ListBox::keypress_event %d\n", __LINE__);
}
+ if( !result )
+ result = context_help_check_and_show();
+
return result;
}
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);
+ char *item_text = display_format == LISTBOX_ICONS_PACKED ?
+ get_truncated_text(MEDIUMFONT, item->text, text_w) :
+ cstrdup(item->text);
gui->draw_text(text_x, text_y + get_baseline(item), item_text);
+ delete [] item_text;
}
else
item->set_in_view(0);