void BC_ListBox::clamp_positions()
{
items_w = get_items_width();
+ if( xscroll_orientation & SCROLL_STRETCH )
+ items_w += view_w / 4;
items_h = get_items_height(data, columns);
+ if( yscroll_orientation & SCROLL_STRETCH )
+ items_h += view_h / 4;
if(yposition < 0) yposition = 0;
else
void BC_ListBox::move_selection(ArrayList<BC_ListBoxItem*> *dst,
ArrayList<BC_ListBoxItem*> *src)
{
- for(int i = 0; i < src[master_column].total; i++)
+ for(int i = 0; i < src[master_column].total; )
{
BC_ListBoxItem *item = src[master_column].values[i];
dst[j].append(src[j].values[i]);
src[j].remove_number(i);
}
+ continue;
}
- else
// Descend into sublist
if(item->get_sublist())
{
move_selection(dst,
item->get_sublist());
}
+ ++i;
}
}
int temp = -1;
if(!counter) counter = &temp;
- if(destination < 0)
+ if(destination < 0 || destination >= data[master_column].total)
{
for(int j = 0; j < columns; j++)
{
return rectangle_scroll_event();
break;
+ case DRAG_ITEM:
case SELECT:
if(duration == get_resources()->scroll_repeat)
return select_scroll_event();
switch(current_operation)
{
case SELECT:
- if(gui &&
- gui->is_event_win() &&
- allow_drag)
+ if( gui && gui->is_event_win() && allow_drag )
{
BC_ListBoxItem *item_return = 0;
selection_number = get_cursor_item(data,
if(selection_number >= 0)
{
-
- if (item_return->icon_vframe)
- {
+ int cx, cy;
+ get_abs_cursor_xy(cx, cy);
+ if( item_return->icon_vframe ) {
+ cx -= item_return->icon_vframe->get_w() / 2,
+ cy -= item_return->icon_vframe->get_h() / 2;
drag_popup = new BC_DragWindow(this,
- item_return->icon_vframe /*,
- get_abs_cursor_x(0) - item_return->icon_vframe->get_w() / 2,
- get_abs_cursor_y(0) - item_return->icon_vframe->get_h() / 2 */);
+ item_return->icon_vframe, cx, cy);
}
else
// this probably works not!
- if (item_return->icon)
- {
+ if( item_return->icon ) {
+ cx -= item_return->icon->get_w() / 2,
+ cy -= item_return->icon->get_h() / 2;
drag_popup = new BC_DragWindow(this,
- item_return->icon /*,
- get_abs_cursor_x(0) - item_return->icon->get_w() / 2,
- get_abs_cursor_y(0) - item_return->icon->get_h() / 2 */);
+ item_return->icon, cx, cy);
}
- else
- {
+ else {
+ cx -= drag_icon_vframe->get_w() / 2,
+ cy -= drag_icon_vframe->get_h() / 2;
drag_popup = new BC_DragWindow(this,
- drag_icon_vframe /*,
- get_abs_cursor_x(0) - drag_icon_vframe->get_w() / 2,
- get_abs_cursor_y(0) - drag_icon_vframe->get_h() / 2 */);
+ drag_icon_vframe, cx, cy);
}
-
current_operation = DRAG_ITEM;
+// require shift down for scrolling
+ if( allow_drag < 0 && shift_down() )
+ set_repeat(get_resources()->scroll_repeat);
return 1;
}
}
case COLUMN_DN:
if(gui && gui->is_event_win() && allow_drag_column)
{
+ int cx, cy;
+ get_abs_cursor_xy(cx, cy);
+ cx -= drag_column_icon_vframe->get_w() / 2,
+ cy -= drag_column_icon_vframe->get_h() / 2;
drag_popup = new BC_DragWindow(this,
- drag_column_icon_vframe /*,
- get_abs_cursor_x(0) - drag_column_icon_vframe->get_w() / 2,
- get_abs_cursor_y(0) - drag_column_icon_vframe->get_h() / 2 */);
+ drag_column_icon_vframe, cx, cy);
dragged_title = highlighted_title;
current_operation = COLUMN_DRAG;
draw_titles(1);
}
return drag_popup->cursor_motion_event();
- break;
}
case COLUMN_DRAG:
draw_titles(1);
}
return drag_popup->cursor_motion_event();
- break;
}
}
return 0;
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 &&
{
reposition_item(data,
selection_number,
- top_level->cursor_x +
- drag_popup->get_offset_x() -
- LISTBOX_MARGIN -
- 2 +
- xposition,
- top_level->cursor_y +
- drag_popup->get_offset_y() -
- LISTBOX_MARGIN -
- 2 +
- yposition);
+ top_level->cursor_x + drag_popup->get_offset_x() -
+ LISTBOX_MARGIN - 2 + xposition,
+ top_level->cursor_y + drag_popup->get_offset_y() -
+ LISTBOX_MARGIN - 2 + yposition);
}
else
// Move rows
if(process_drag)
{
-// Get destination
- int destination = highlighted_item = item_to_index(data,
- highlighted_ptr);
-//printf("BC_ListBox::drag_stop_event 1 %p %d\n", highlighted_ptr, destination);
-
// Move selected items from data to temporary
ArrayList<BC_ListBoxItem*> *src_items =
new ArrayList<BC_ListBoxItem*>[columns];
-
move_selection(src_items, data);
-
+// Get destination
+ int destination = highlighted_item = item_to_index(data,
+ highlighted_ptr);
// Insert items from temporary to data
- put_selection(data,
- src_items,
- destination);
-
+ put_selection(data, src_items, destination);
delete [] src_items;
set_autoplacement(data, 0, 1);
gui->set_color(BLACK);
int xx = x + column_width-1;
gui->draw_line(x, y, xx, y);
- int hh = row_height;
+ int hh = h;
if( display_format == LISTBOX_ICON_LIST ) {
int ih = get_icon_h(item);
if( ih > hh ) hh = ih;
image_number = 2;
}
- int column_offset = get_column_offset(number) - xposition + LISTBOX_BORDER;
- int column_width = get_column_width(number, 1);
gui->draw_3segmenth(get_column_offset(number) - xposition + LISTBOX_BORDER,
LISTBOX_BORDER,
get_column_width(number, 1) + get_resources()->listbox_title_overlap,
column_bg[image_number]);
-// Column title sort order
- if(number == sort_column)
- {
- BC_Pixmap *src;
- if(sort_order == SORT_ASCENDING)
- src = column_sort_dn;
- else
- src = column_sort_up;
+ int title_x = -xposition + get_column_offset(number) +
+ LISTBOX_MARGIN + LISTBOX_BORDER;
+ title_x += get_resources()->listbox_title_margin;
- int x = column_offset +
- column_width -
- LISTBOX_BORDER;
- if(x > items_w) x = items_w;
- x -= 5 + src->get_w();
+ gui->set_color(get_resources()->listbox_title_color);
+ gui->draw_text(title_x,
+ LISTBOX_MARGIN + LISTBOX_BORDER + get_text_ascent(MEDIUMFONT),
+ column_titles[number]);
+
+// Column sort order
+ if(number == sort_column) {
+ BC_Pixmap *src = sort_order == SORT_ASCENDING ?
+ column_sort_dn : column_sort_up;
+
+// int column_offset = get_column_offset(number) - xposition + LISTBOX_BORDER;
+// int column_width = get_column_width(number, 1);
+// int toggle_x = column_offset + column_width - LISTBOX_BORDER;
+// if( toggle_x > items_w ) toggle_x = items_w;
+// toggle_x -= 5 + src->get_w();
+
+ int x = title_x +
+ get_text_width(MEDIUMFONT, column_titles[number]) +
+ LISTBOX_MARGIN;
+
gui->draw_pixmap(src,
x,
title_h / 2 - src->get_h() / 2 + LISTBOX_BORDER);
}
-
-
- int x = -xposition +
- get_column_offset(number) +
- LISTBOX_MARGIN +
- LISTBOX_BORDER;
- x += get_resources()->listbox_title_margin;
-
- gui->set_color(get_resources()->listbox_title_color);
- gui->draw_text(x,
- LISTBOX_MARGIN + LISTBOX_BORDER + get_text_ascent(MEDIUMFONT),
- _(column_titles[number]));
}
int BC_ListBox::draw_titles(int flash)