r1009: Move the dependencies to newer package names
[cinelerra_cv/mob.git] / guicast / bclistboxitem.C
blob9ed6d49b04404a391357dd610068ad34f7ed949d
1 #include "bclistboxitem.h"
2 #include "bcpixmap.h"
3 #include "bcresources.h"
4 #include "bcwindowbase.h"
6 #include <string.h>
9 // ====================================================== item
11 BC_ListBoxItem::BC_ListBoxItem()
13         initialize();
15         color = BC_WindowBase::get_resources()->listbox_text;
16         this->text = new char[1];
17         text[0] = 0;
18         selectable = 1;
21 BC_ListBoxItem::BC_ListBoxItem(char *text, 
22         BC_Pixmap *icon, 
23         int color)
25         initialize();
27         if(color == -1) color = BC_WindowBase::get_resources()->listbox_text;
28         this->text = new char[strlen(text) + 1];
29         this->icon = icon;
31         strcpy(this->text, text);
32         this->color = color;
33         selectable = 1;
36 BC_ListBoxItem::BC_ListBoxItem(char *text, int color)
38         initialize();
40         if(color == -1) color = BC_WindowBase::get_resources()->listbox_text;
41         this->text = new char[strlen(text) + 1];
42         strcpy(this->text, text);
43         this->color = color;
44         selectable = 1;
47 BC_ListBoxItem::~BC_ListBoxItem()
49         if(text) delete [] text;
50         if(sublist)
51         {
52                 for(int i = 0; i < columns; i++)
53                         sublist[i].remove_all_objects();
54                 delete sublist;
55         }
58 int BC_ListBoxItem::initialize()
60         autoplace_icon = 1;
61         autoplace_text = 1;
62         text = 0;
63         color = BLACK;
64         selected = 0;
65         icon = 0;
66         icon_vframe = 0;
67         text_x = -1;
68         text_y = -1;
69         icon_x = -1;
70         icon_y = -1;
71         searchable = 1;
72         sublist = 0;
73         columns = 0;
74         expand = 0;
75         return 0;
78 int BC_ListBoxItem::get_icon_x()
80         return icon_x;
83 int BC_ListBoxItem::get_icon_y()
85         return icon_y;
88 int BC_ListBoxItem::get_text_x()
90         return text_x;
93 int BC_ListBoxItem::get_text_y()
95         return text_y;
98 int BC_ListBoxItem::set_autoplace_icon(int value)
100         autoplace_icon = value;
101         return 0;
104 int BC_ListBoxItem::set_autoplace_text(int value)
106         autoplace_text = value;
107         return 0;
110 void BC_ListBoxItem::set_icon_x(int x)
112         icon_x = x;
113         autoplace_icon = 0;
116 void BC_ListBoxItem::set_icon_y(int y)
118         icon_y = y;
119         autoplace_icon = 0;
122 void BC_ListBoxItem::set_selected(int value)
124         this->selected = value;
127 void BC_ListBoxItem::set_searchable(int value)
129         this->searchable = value;
132 void BC_ListBoxItem::set_selectable(int value)
134         this->selectable = value;
137 int BC_ListBoxItem::get_selectable()
139         return selectable;
144 void BC_ListBoxItem::set_text_x(int x)
146         text_x = x;
147         autoplace_text = 0;
149 void BC_ListBoxItem::set_text_y(int y)
151         text_y = y;
152         autoplace_text = 0;
155 int BC_ListBoxItem::get_icon_w()
157         return icon->get_w();
160 int BC_ListBoxItem::get_icon_h()
162         return icon->get_h();
165 void BC_ListBoxItem::set_text(char *new_text)
167         if(this->text) delete [] this->text;
168         this->text = 0;
170         if(new_text)
171         {
172                 this->text = new char[strlen(new_text) + 1];
173                 strcpy(this->text, new_text);
174         }
177 char* BC_ListBoxItem::get_text()
179         return text;
182 void BC_ListBoxItem::set_icon(BC_Pixmap *icon)
184         this->icon = icon;
187 void BC_ListBoxItem::set_icon_vframe(VFrame *icon_vframe)
189         this->icon_vframe = icon_vframe;
192 void BC_ListBoxItem::set_color(int color)
194         this->color = color;
197 int BC_ListBoxItem::get_color()
199         return color;
203 BC_ListBoxItem& BC_ListBoxItem::operator=(BC_ListBoxItem& item)
205         copy_from(&item);
206         return *this;
209 void BC_ListBoxItem::copy_from(BC_ListBoxItem *item)
211         if(item->text) set_text(item->text);
212         color = item->color;
213         text_x = item->text_x;
214         text_y = item->text_y;
215         icon_x = item->icon_x;
216         icon_y = item->icon_y;
217         selectable = item->selectable;
218         columns = item->columns;
219         if(item->sublist)
220         {
221                 sublist = new ArrayList<BC_ListBoxItem*>[columns];
222                 for(int i = 0; i < columns; i++)
223                 {
224                         ArrayList<BC_ListBoxItem*> *list = &item->get_sublist()[i];
226                         for(int j = 0; j < list->total; j++)
227                         {
228                                 BC_ListBoxItem *new_item = new BC_ListBoxItem;
229                                 BC_ListBoxItem *old_item = list->values[j];
230                                 sublist[i].append(new_item);
231                                 new_item->copy_from(old_item);
232                         }
233                 }
234         }
237 ArrayList<BC_ListBoxItem*>* BC_ListBoxItem::new_sublist(int columns)
239         sublist = new ArrayList<BC_ListBoxItem*>[columns];
240         this->columns = columns;
241         return sublist;
244 ArrayList<BC_ListBoxItem*>* BC_ListBoxItem::get_sublist()
246         return sublist;
249 int BC_ListBoxItem::get_columns()
251         return columns;
254 int BC_ListBoxItem::get_expand()
256         return expand;
259 void BC_ListBoxItem::set_expand(int value)
261         expand = value;