add resource wdw folder expanders, fix plugin close deadlock detect
[goodguy/history.git] / cinelerra-5.1 / guicast / bclistboxitem.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #ifndef BCLISTBOXITEM_H
23 #define BCLISTBOXITEM_H
24
25 #include "arraylist.h"
26 #include "bcpixmap.inc"
27 #include "bccolors.h"
28 #include "vframe.h"
29
30
31
32 // Every item in a list inherits this
33 class BC_ListBoxItem
34 {
35 public:
36         BC_ListBoxItem();
37 // New items
38         BC_ListBoxItem(const char *text,
39                 int color = -1);
40         BC_ListBoxItem(const char *text,
41                 BC_Pixmap *icon,
42                 int color = -1);
43
44
45
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.
49
50         virtual ~BC_ListBoxItem();
51
52         friend class BC_ListBox;
53
54         BC_Pixmap* get_icon();
55         int get_icon_x() { return icon_x; }
56         int get_icon_y() { return icon_y; }
57         int get_icon_w();
58         int get_icon_h();
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; }
85
86         void copy_from(BC_ListBoxItem *item);
87         BC_ListBoxItem& operator=(BC_ListBoxItem& item) {
88                 copy_from(&item);
89                 return *this;
90         }
91         void set_text(const char *new_text);
92
93 // The item with the sublist must be in column 0.  Only this is searched by
94 // BC_ListBox.
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);
106
107 private:
108         int initialize();
109         void set_in_view(int v) { in_view = v; }
110         static int compare_item_text(const void *a, const void *b);
111
112         BC_Pixmap *icon;
113         VFrame *icon_vframe;
114 // x and y position in listbox relative to top left
115 // Different positions for icon mode and text mode are maintained
116         int icon_x, icon_y;
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;
121         char *text;
122         int color;
123 // 1 - currently selected
124 // 2 - previously selected and now adding selections with shift
125         int selected;
126 // Allow this item to be included in queries.  Directories are not
127 // included in queries.
128         int searchable;
129
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
135         int columns;
136 // Sublist is visible
137         int expand;
138 // Item is selectable
139         int selectable;
140 };
141
142
143
144 #endif