initial commit
[goodguy/history.git] / cinelerra-5.0 / 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 "colors.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
85         void copy_from(BC_ListBoxItem *item);
86         BC_ListBoxItem& operator=(BC_ListBoxItem& item) {
87                 copy_from(&item);
88                 return *this;
89         }
90         void set_text(const char *new_text);
91
92 // The item with the sublist must be in column 0.  Only this is searched by
93 // BC_ListBox.
94 // Mind you, sublists are ignored in icon mode.
95         ArrayList<BC_ListBoxItem*>* new_sublist(int columns);
96         ArrayList<BC_ListBoxItem*>* get_sublist() { return sublist; }
97 // Return the number of columns in the sublist
98         int get_columns() { return columns; }
99 // Return if it's expanded
100         int get_expand() { return expand; }
101         void set_expand(int value) { expand = value; }
102
103 private:
104         int initialize();
105         void set_in_view(int v) { in_view = v; }
106
107         BC_Pixmap *icon;
108         VFrame *icon_vframe;
109 // x and y position in listbox relative to top left
110 // Different positions for icon mode and text mode are maintained
111         int icon_x, icon_y;
112         int text_x, text_y, text_w, text_h;
113         int baseline, in_view;
114 // If autoplacement should be performed in the next draw
115         int autoplace_icon, autoplace_text;
116         char *text;
117         int color;
118 // 1 - currently selected
119 // 2 - previously selected and now adding selections with shift
120         int selected;
121 // Allow this item to be included in queries.  Directories are not
122 // included in queries.
123         int searchable;
124
125 // Array of one list of pointers for each column for a sublist.
126 // It's an array so we can pass the sublist directly to another listbox.
127 // Sublists were used on an obsolete DVD robot interface & never again.
128         ArrayList<BC_ListBoxItem*> *sublist;
129 // Columns in sublist
130         int columns;
131 // Sublist is visible
132         int expand;
133 // Item is selectable
134         int selectable;
135 };
136
137
138
139 #endif