4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #ifndef BCLISTBOXITEM_H
23 #define BCLISTBOXITEM_H
25 #include "arraylist.h"
26 #include "bcpixmap.inc"
32 // Every item in a list inherits this
38 BC_ListBoxItem(const char *text,
40 BC_ListBoxItem(const char *text,
46 // autoplace is always 1 in initialization.
47 // Positions set with the set_ commands cancel autoplacement.
48 // Final positions are calculated in the next draw_items.
50 virtual ~BC_ListBoxItem();
52 friend class BC_ListBox;
54 BC_Pixmap* get_icon();
55 int get_icon_x() { return icon_x; }
56 int get_icon_y() { return icon_y; }
59 int get_text_x() { return text_x; }
60 int get_text_y() { return text_y; }
61 int get_text_w() { return text_w; }
62 int get_text_h() { return text_h; }
63 int get_baseline() { return baseline; }
64 int get_in_view() { return in_view; }
65 void set_autoplace_icon(int value) { autoplace_icon = value; }
66 void set_autoplace_text(int value) { autoplace_text = value; }
67 void set_icon_x(int x) { icon_x = x; autoplace_icon = 0; }
68 void set_icon_y(int y) { icon_y = y; autoplace_icon = 0; }
69 void set_searchable(int value) { searchable = value; }
70 int get_selected() { return selected; }
71 void set_selected(int value) { selected = value; }
72 void set_selectable(int value) { selectable = value; }
73 int get_selectable() { return selectable; }
74 void set_text_x(int x) { text_x = x; autoplace_text = 0; }
75 void set_text_y(int y) { text_y = y; autoplace_text = 0; }
76 void set_text_w(int w) { text_w = w; }
77 void set_text_h(int h) { text_h = h; }
78 void set_baseline(int b) { baseline = b; }
79 char* get_text() { return text; }
80 void set_icon(BC_Pixmap *p) { icon = p; }
81 void set_icon_vframe(VFrame *p) { icon_vframe = p; }
82 void set_color(int v) { color = v; }
83 int get_color() { return color; }
84 virtual VFrame *get_vicon_frame() { return 0; }
86 void copy_from(BC_ListBoxItem *item);
87 BC_ListBoxItem& operator=(BC_ListBoxItem& item) {
91 void set_text(const char *new_text);
93 // The item with the sublist must be in column 0. Only this is searched by
95 int sublist_active() { return sublist && expand ? 1 : 0; }
96 // Mind you, sublists are ignored in icon mode.
97 ArrayList<BC_ListBoxItem*>* new_sublist(int columns);
98 ArrayList<BC_ListBoxItem*>* get_sublist() { return sublist; }
99 // Return the number of columns in the sublist
100 int get_columns() { return columns; }
101 // Return if it's expanded
102 int get_expand() { return expand; }
103 void set_expand(int value) { expand = value; }
104 // alpha sort on text
105 static void sort_items(ArrayList<BC_ListBoxItem*> &items);
109 void set_in_view(int v) { in_view = v; }
110 static int compare_item_text(const void *a, const void *b);
114 // x and y position in listbox relative to top left
115 // Different positions for icon mode and text mode are maintained
117 int text_x, text_y, text_w, text_h;
118 int baseline, in_view;
119 // If autoplacement should be performed in the next draw
120 int autoplace_icon, autoplace_text;
123 // 1 - currently selected
124 // 2 - previously selected and now adding selections with shift
126 // Allow this item to be included in queries. Directories are not
127 // included in queries.
130 // Array of one list of pointers for each column for a sublist.
131 // It's an array so we can pass the sublist directly to another listbox.
132 // Sublists were used on an obsolete DVD robot interface & never again.
133 ArrayList<BC_ListBoxItem*> *sublist;
134 // Columns in sublist
136 // Sublist is visible
138 // Item is selectable