popup_w = w;
popup_h = h;
- for(int i = 0; i < 3; i++)
- {
- button_images[i] = 0;
- column_bg[i] = 0;
- }
- for(int i = 0; i < 5; i++)
- toggle_images[i] = 0;
+ for(int i = 0; i < 3; i++) column_bg[i] = 0;
+ for(int i = 0; i < 4; i++) button_images[i] = 0;
+ for(int i = 0; i < 5; i++) toggle_images[i] = 0;
column_sort_up = 0;
column_sort_dn = 0;
if(bg_pixmap) delete bg_pixmap;
if(xscrollbar) delete xscrollbar;
if(yscrollbar) delete yscrollbar;
- for(int i = 0; i < 3; i++)
- {
- if(button_images[i]) delete button_images[i];
- if(column_bg[i]) delete column_bg[i];
- }
- for(int i = 0; i < 5; i++)
- if(toggle_images[i]) delete toggle_images[i];
+ for(int i = 0; i < 3; i++) delete column_bg[i];
+ for(int i = 0; i < 4; i++) delete button_images[i];
+ for(int i = 0; i < 5; i++) delete toggle_images[i];
if(column_sort_up) delete column_sort_up;
if(column_sort_dn) delete column_sort_dn;
{
if(use_button)
{
- for( volatile int i = 0; i < 4; ++i ) // volatile due to cplr bug
+ for( int i = 0; i < 4; ++i )
{
button_images[i] = new BC_Pixmap(parent_window,
BC_WindowBase::get_resources()->listbox_button[i],
// Lowest right icon coordinate.
current_icon_x = item->icon_x;
if(current_icon_x > *icon_x) *icon_x = current_icon_x;
- if(current_icon_x + get_item_w(item) > *next_icon_x)
+ if(current_icon_x + get_item_w(item) > *next_icon_x) {
*next_icon_x = current_icon_x + get_item_w(item);
-
+ *next_icon_y = 0;
+ }
current_icon_y = item->icon_y + get_item_h(item);
if(current_icon_y > *next_icon_y)
*next_icon_y = current_icon_y;
int x, y, w, h;
BC_ListBoxItem *item = data[master_column].values[j];
- if(display_format == LISTBOX_ICONS)
- {
+ if( display_format == LISTBOX_ICONS ||
+ display_format == 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);
*result += h;
-
-
// Descend into sublist
if(item->get_sublist() &&
item->get_expand())
}
}
- if((display_format == LISTBOX_TEXT ||
- display_format == LISTBOX_ICON_LIST) &&
- top_level)
+ if( display_format == LISTBOX_TEXT && top_level )
{
highest = LISTBOX_MARGIN + *result;
}
}
}
}
- else
+ else if( gui ) {
// Text is treed
- {
// Cursor is inside items rectangle
if(cursor_x >= 0 &&
cursor_x < (yscrollbar ?
//printf("BC_ListBox::button_release_event 10\n");
unset_repeat(get_resources()->scroll_repeat);
current_operation = NO_OPERATION;
- 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);
+ 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);
//printf("BC_ListBox::button_release_event %d %d\n", selection_number2, selection_number1);
+ }
if(is_popup)
{
if(!is_popup)
{
- if(w != -1) popup_w = w;
- if(h != -1) popup_h = h;
if(xscrollbar)
xscrollbar->reposition_window(get_xscroll_x(),
get_xscroll_y(),
int BC_ListBox::activate(int take_focus)
{
-//printf("BC_ListBox::activate %d %p\n", __LINE__, this);
- if(!active)
- {
- if(take_focus)
- {
- top_level->active_subwindow = this;
- active = 1;
- }
-
- button_releases = 0;
-
-// Test for existence of GUI in case this was previously called without
-// take_focus & again with take_focus
- if(is_popup && !gui)
- {
- Window tempwin;
- int x, y;
- int new_x, new_y;
- y = get_y() + get_h();
- if(justify == LISTBOX_RIGHT)
- {
- x = get_x() - popup_w + get_w();
- }
- else
- {
- x = get_x();
- }
-
-
- XTranslateCoordinates(top_level->display,
- parent_window->win,
- top_level->rootwin,
- x,
- y,
- &new_x,
- &new_y,
- &tempwin);
-
- if(new_x < 0) new_x = 0;
- if(new_y + popup_h > top_level->get_root_h(0))
- new_y -= get_h() + popup_h;
-
- add_subwindow(gui = new BC_Popup(this,
- new_x,
- new_y,
- popup_w,
- popup_h,
- -1,
- 0,
- 0));
-// Avoid top going out of screen
- if(new_y < 0 )
- new_y = 2;
-//printf("BC_ListBox::activate %d this=%p %p\n", __LINE__, this, gui->win);
- draw_items(1);
- gui->show_window(1);
- }
-//printf("BC_ListBox::activate %d %p\n", __LINE__, this);
-//sleep(1);
- }
+ if( active ) return 0;
+ if( take_focus )
+ set_active_subwindow(this);
+ button_releases = 0;
+ if( !is_popup || gui ) return 0;
+ int wx = get_x(), wy = get_y() + get_h();
+ if( justify == LISTBOX_RIGHT ) wx += get_w() - popup_w;
+ Window xwin;
+ int abs_x, abs_y;
+ 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;
+ return activate(abs_x, abs_y);
+}
+
+int BC_ListBox::activate(int x, int y, int w, int h)
+{
+ if( active || !is_popup || gui ) return 0;
+ if(w != -1) popup_w = w;
+ if(h != -1) popup_h = h;
+ active = 1;
+ if( y + popup_h > top_level->get_root_h(0) )
+ y -= get_h() + popup_h;
+ add_subwindow(gui = new BC_Popup(this,
+ x, y, popup_w, popup_h, -1, 0, 0));
+ draw_items(1);
+ gui->show_window(1);
return 0;
}
+int BC_ListBox::is_active()
+{
+ return active;
+}
+
int BC_ListBox::keypress_event()
{
if(!active) return 0;