]>
Commit | Line | Data |
---|---|---|
f4e325b3 DP |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: treectrl.cpp | |
d9692df7 | 3 | // Purpose: wxTreeCtrl |
f4e325b3 | 4 | // Author: Denis Pershin |
d9692df7 | 5 | // Modified by: |
f4e325b3 | 6 | // Created: 07/05/98 |
d9692df7 DP |
7 | // RCS-ID: $Id$ |
8 | // Copyright: (c) Denis Pershin | |
978f38c2 | 9 | // Licence: wxWindows licence |
f4e325b3 DP |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifdef __GNUG__ | |
e8cd8b1b | 13 | #pragma implementation "treectrl.h" |
f4e325b3 DP |
14 | #endif |
15 | ||
d9692df7 DP |
16 | // For compilers that support precompilation, includes "wx.h". |
17 | #include "wx/wxprec.h" | |
18 | ||
19 | #ifdef __BORLANDC__ | |
20 | #pragma hdrstop | |
21 | #endif | |
22 | ||
23 | #ifndef WX_PRECOMP | |
24 | #include "wx/wx.h" | |
25 | #endif | |
26 | ||
f4e325b3 | 27 | #include "wx/gtk/treectrl.h" |
3096bd2f | 28 | #include "wx/textctrl.h" |
f4e325b3 DP |
29 | #include "wx/log.h" |
30 | ||
d9692df7 | 31 | #include <gtk/gtk.h> |
f4e325b3 | 32 | |
e21a5048 DP |
33 | //static void wxConvertToGtkTreeItem(wxTreeCtrl *owner, wxTreeItem& info, GtkTreeItem **gtkItem); |
34 | //static void wxConvertFromGtkTreeItem(wxTreeItem& info, GtkTreeItem *gtkItem); | |
e1dc4cc6 | 35 | |
d9692df7 | 36 | static void gtk_treectrl_count_callback (GtkWidget *widget, gpointer data); |
e895ec45 | 37 | static void gtk_treectrl_first_selected_callback(GtkWidget *widget, gpointer data); |
e1dc4cc6 DP |
38 | static void gtk_treectrl_first_visible_callback(GtkWidget *widget, gpointer data); |
39 | ||
d9692df7 DP |
40 | // static void gtk_treectrl_next_callback (GtkWidget *widget, gpointer data); |
41 | // static void gtk_treectrl_next_visible_callback (GtkWidget *widget, gpointer data); | |
42 | // static void gtk_treectrl_next_selected_callback (GtkWidget *widget, gpointer data); | |
f4e325b3 | 43 | |
e21a5048 DP |
44 | static void gtk_treeitem_expand_callback(GtkWidget *widget, wxTreeItemId *treeitem); |
45 | static void gtk_treeitem_collapse_callback(GtkWidget *widget, wxTreeItemId *treeitem); | |
46 | static void gtk_treeitem_select_callback(GtkWidget *widget, wxTreeItemId *treeitem); | |
f4e325b3 | 47 | |
e21a5048 | 48 | static void gtk_treeitem_expand_callback(GtkWidget *widget, wxTreeItemId *treeitem) { |
d9692df7 DP |
49 | wxTreeCtrl *owner = (wxTreeCtrl *)gtk_object_get_data(GTK_OBJECT(widget), "owner"); |
50 | if (owner == NULL) | |
befe54c6 | 51 | return; |
d9692df7 | 52 | |
e21a5048 DP |
53 | // long id = (long)gtk_object_get_data(GTK_OBJECT(widget), "id"); |
54 | owner->SendExpanding(GTK_TREE_ITEM(widget)); | |
55 | owner->SendExpanded(GTK_TREE_ITEM(widget)); | |
f4e325b3 DP |
56 | }; |
57 | ||
e21a5048 | 58 | static void gtk_treeitem_collapse_callback(GtkWidget *widget, wxTreeItemId *treeitem) { |
d9692df7 DP |
59 | wxTreeCtrl *owner = (wxTreeCtrl *)gtk_object_get_data(GTK_OBJECT(widget), "owner"); |
60 | if (owner == NULL) | |
befe54c6 | 61 | return; |
d9692df7 | 62 | |
e21a5048 DP |
63 | // long id = (long)gtk_object_get_data(GTK_OBJECT(widget), "id"); |
64 | owner->SendCollapsing(GTK_TREE_ITEM(widget)); | |
65 | owner->SendCollapsed(GTK_TREE_ITEM(widget)); | |
f4e325b3 DP |
66 | }; |
67 | ||
e21a5048 | 68 | static void gtk_treeitem_select_callback(GtkWidget *widget, wxTreeItemId *treeitem) { |
d9692df7 DP |
69 | wxTreeCtrl *owner = (wxTreeCtrl *)gtk_object_get_data(GTK_OBJECT(widget), "owner"); |
70 | if (owner == NULL) | |
71 | return; | |
f4e325b3 | 72 | |
e21a5048 DP |
73 | // long id = (long)gtk_object_get_data(GTK_OBJECT(widget), "id"); |
74 | owner->SendSelChanging(GTK_TREE_ITEM(widget)); | |
75 | owner->SendSelChanged(GTK_TREE_ITEM(widget)); | |
f4e325b3 DP |
76 | } |
77 | ||
e21a5048 DP |
78 | IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrl, wxControl) |
79 | ||
f4e325b3 | 80 | |
e21a5048 | 81 | void wxTreeCtrl::Init() { |
d9692df7 DP |
82 | m_imageListNormal = NULL; |
83 | m_imageListState = NULL; | |
84 | m_textCtrl = NULL; | |
d9692df7 DP |
85 | } |
86 | ||
e21a5048 DP |
87 | bool wxTreeCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, |
88 | const wxSize& size, long style, | |
89 | const wxValidator& validator, const wxString& name) { | |
90 | Init(); | |
d9692df7 DP |
91 | |
92 | int x = pos.x; | |
93 | int y = pos.y; | |
94 | int width = size.x; | |
95 | int height = size.y; | |
96 | ||
97 | m_windowStyle = style; | |
98 | ||
99 | SetParent(parent); | |
100 | ||
101 | if (width <= 0) | |
102 | width = 100; | |
103 | if (height <= 0) | |
104 | height = 30; | |
105 | if (x < 0) | |
106 | x = 0; | |
107 | if (y < 0) | |
108 | y = 0; | |
109 | ||
110 | m_needParent = TRUE; | |
978f38c2 | 111 | |
e21a5048 | 112 | printf("precreate\n"); |
d9692df7 DP |
113 | PreCreation( parent, id, pos, size, style, name ); |
114 | ||
e21a5048 DP |
115 | printf("1\n"); |
116 | ||
d9692df7 | 117 | m_widget = gtk_scrolled_window_new(NULL, NULL); |
e21a5048 | 118 | printf("2\n"); |
d9692df7 | 119 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(m_widget), |
e21a5048 | 120 | GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
f4e325b3 | 121 | |
e21a5048 | 122 | printf("3\n"); |
f4e325b3 | 123 | m_tree = GTK_TREE(gtk_tree_new()); |
d9692df7 | 124 | |
e21a5048 | 125 | printf("4\n"); |
d9692df7 | 126 | gtk_container_add(GTK_CONTAINER(m_widget), GTK_WIDGET(m_tree)); |
e21a5048 | 127 | printf("5\n"); |
f4e325b3 | 128 | gtk_widget_show(GTK_WIDGET(m_tree)); |
befe54c6 | 129 | |
d9692df7 DP |
130 | SetName(name); |
131 | SetValidator(validator); | |
132 | ||
6ca41e57 | 133 | printf("Robert's new insertion code :-)\n"); |
f03fc89f | 134 | m_parent->DoAddChild( this ); |
e21a5048 | 135 | printf("postcreate\n"); |
d9692df7 DP |
136 | PostCreation(); |
137 | ||
138 | gtk_widget_realize(GTK_WIDGET(m_tree)); | |
139 | ||
140 | Show(TRUE); | |
978f38c2 | 141 | |
d9692df7 DP |
142 | return TRUE; |
143 | } | |
144 | ||
e21a5048 DP |
145 | wxTreeCtrl::~wxTreeCtrl(void) { |
146 | if (m_textCtrl) | |
147 | delete m_textCtrl; | |
f4e325b3 DP |
148 | } |
149 | ||
d9692df7 | 150 | // Attributes |
e21a5048 | 151 | static void gtk_treectrl_count_callback (GtkWidget *widget, gpointer data) { |
d9692df7 | 152 | int count = (*((int *)data)); |
f4e325b3 | 153 | |
d9692df7 DP |
154 | count++; |
155 | if (GTK_IS_CONTAINER(widget)) | |
156 | gtk_container_foreach(GTK_CONTAINER(widget), gtk_treectrl_count_callback, data); | |
f4e325b3 DP |
157 | } |
158 | ||
e21a5048 | 159 | size_t wxTreeCtrl::GetCount() const { |
d9692df7 DP |
160 | int count = 0; |
161 | ||
162 | if (m_anchor != NULL) | |
e895ec45 | 163 | gtk_treectrl_count_callback(GTK_WIDGET(m_anchor), &count); |
d9692df7 | 164 | return count; |
f4e325b3 DP |
165 | } |
166 | ||
e21a5048 | 167 | unsigned int wxTreeCtrl::GetIndent() const { |
d9692df7 DP |
168 | return m_tree->indent_value; |
169 | } | |
befe54c6 | 170 | |
e21a5048 | 171 | void wxTreeCtrl::SetIndent(unsigned int indent) { |
d9692df7 DP |
172 | m_tree->indent_value = indent; |
173 | } | |
174 | ||
e21a5048 DP |
175 | wxImageList *wxTreeCtrl::GetImageList() const { |
176 | return m_imageListNormal; | |
d9692df7 DP |
177 | } |
178 | ||
e21a5048 DP |
179 | wxImageList *wxTreeCtrl::GetStateImageList() const { |
180 | return m_imageListState; | |
d9692df7 DP |
181 | } |
182 | ||
e21a5048 DP |
183 | void wxTreeCtrl::SetImageList(wxImageList *imageList) { |
184 | m_imageListNormal = imageList; | |
185 | } | |
d9692df7 | 186 | |
e21a5048 DP |
187 | void wxTreeCtrl::SetStateImageList(wxImageList *imageList) { |
188 | m_imageListState = imageList; | |
d9692df7 DP |
189 | } |
190 | ||
e21a5048 DP |
191 | wxString wxTreeCtrl::GetItemText(const wxTreeItemId &item) const { |
192 | char *t; | |
d9692df7 | 193 | |
e21a5048 DP |
194 | if (!item.IsOk()) |
195 | return wxString(""); | |
f4e325b3 | 196 | |
e21a5048 DP |
197 | GtkLabel *l = GTK_LABEL(gtk_object_get_data(GTK_OBJECT((GtkTreeItem *)item), "w_label")); |
198 | gtk_label_get(l, &t); | |
199 | ||
200 | return t; | |
201 | } | |
202 | ||
203 | int wxTreeCtrl::GetItemImage(const wxTreeItemId& item) const { | |
204 | if (!item.IsOk()) | |
205 | return (-1); | |
206 | ||
207 | return (int)gtk_object_get_data(GTK_OBJECT((GtkTreeItem *)item), "image"); | |
f4e325b3 DP |
208 | } |
209 | ||
e21a5048 DP |
210 | int wxTreeCtrl::GetItemSelectedImage(const wxTreeItemId& item) const { |
211 | if (!item.IsOk()) | |
212 | return (-1); | |
f4e325b3 | 213 | |
e21a5048 DP |
214 | return (int)gtk_object_get_data(GTK_OBJECT((GtkTreeItem *)item), "selectedImage"); |
215 | } | |
f4e325b3 | 216 | |
e21a5048 DP |
217 | wxTreeItemData *wxTreeCtrl::GetItemData(const wxTreeItemId& item) const { |
218 | if (!item.IsOk()) | |
d9692df7 | 219 | return NULL; |
f4e325b3 | 220 | |
e21a5048 DP |
221 | return (wxTreeItemData *)gtk_object_get_data(GTK_OBJECT((GtkTreeItem *)item), "data"); |
222 | } | |
f4e325b3 | 223 | |
e21a5048 DP |
224 | void wxTreeCtrl::SetItemText(const wxTreeItemId& item, const wxString& text) { |
225 | if (!item.IsOk()) | |
226 | return; | |
f4e325b3 | 227 | |
e21a5048 DP |
228 | GtkLabel *l = GTK_LABEL(gtk_object_get_data(GTK_OBJECT((GtkTreeItem *)item), "w_label")); |
229 | gtk_label_set(l, text); | |
230 | } | |
f4e325b3 | 231 | |
e21a5048 DP |
232 | void wxTreeCtrl::SetItemImage(const wxTreeItemId& item, int image) { |
233 | if (!item.IsOk()) | |
234 | return; | |
235 | ||
236 | gtk_object_set_data(GTK_OBJECT((GtkTreeItem *)item), "image", (void *)image); | |
d9692df7 | 237 | } |
f4e325b3 | 238 | |
e21a5048 DP |
239 | void wxTreeCtrl::SetItemSelectedImage(const wxTreeItemId& item, int image) { |
240 | if (!item.IsOk()) | |
241 | return; | |
242 | ||
243 | gtk_object_set_data(GTK_OBJECT((GtkTreeItem *)item), "selectedImage", (void *)image); | |
d9692df7 | 244 | } |
f4e325b3 | 245 | |
e21a5048 DP |
246 | void wxTreeCtrl::SetItemData(const wxTreeItemId& item, wxTreeItemData *data) { |
247 | if (!item.IsOk()) | |
248 | return; | |
f4e325b3 | 249 | |
e21a5048 DP |
250 | gtk_object_set_data(GTK_OBJECT((GtkTreeItem *)item), "data", data); |
251 | } | |
f4e325b3 | 252 | |
e21a5048 | 253 | bool wxTreeCtrl::IsVisible(const wxTreeItemId& item) const { |
c9d9f242 | 254 | return GTK_WIDGET_VISIBLE(GTK_TREE_ITEM((GtkTreeItem *)item)); |
d9692df7 | 255 | } |
f4e325b3 | 256 | |
e21a5048 | 257 | bool wxTreeCtrl::ItemHasChildren(const wxTreeItemId& item) const { |
e895ec45 DP |
258 | GtkTreeItem *p = (GtkTreeItem *)item; |
259 | ||
260 | if (p->subtree == NULL) | |
261 | return wxFalse; | |
f4e325b3 | 262 | |
e895ec45 DP |
263 | if (GTK_TREE(p->subtree)->children == NULL) |
264 | return wxFalse; | |
f4e325b3 | 265 | |
e895ec45 DP |
266 | if (g_list_length(GTK_TREE(p->subtree)->children) == 0) |
267 | return wxFalse; | |
268 | ||
269 | return wxTrue; | |
d9692df7 | 270 | } |
f4e325b3 | 271 | |
e21a5048 DP |
272 | bool wxTreeCtrl::IsExpanded(const wxTreeItemId& item) const { |
273 | return (((GtkTreeItem *)item)->expanded != 0); | |
274 | } | |
275 | ||
276 | bool wxTreeCtrl::IsSelected(const wxTreeItemId& item) const { | |
e895ec45 DP |
277 | GtkTreeItem *p = (GtkTreeItem *)item; |
278 | GtkWidget *parent = GTK_WIDGET(p)->parent; | |
279 | ||
280 | if (!GTK_IS_TREE(parent)) | |
281 | return wxFalse; | |
282 | ||
283 | if (g_list_index(GTK_TREE(parent)->children, p) == -1) | |
284 | return wxFalse; | |
285 | ||
286 | return wxTrue; | |
e21a5048 DP |
287 | } |
288 | ||
289 | wxTreeItemId wxTreeCtrl::GetRootItem() const { | |
290 | return m_anchor; | |
291 | } | |
292 | ||
e895ec45 DP |
293 | static void gtk_treectrl_first_selected_callback(GtkWidget *widget, gpointer data) { |
294 | GtkTreeItem *p = (*((GtkTreeItem **)data)); | |
295 | ||
296 | GtkTree *tree = GTK_TREE(GTK_TREE_ITEM(widget)->subtree); | |
297 | ||
298 | if (tree->selection != NULL) { | |
299 | p = (GtkTreeItem *)tree->selection->data; | |
300 | return; | |
301 | } | |
302 | ||
303 | if (GTK_IS_CONTAINER(widget)) | |
304 | gtk_container_foreach(GTK_CONTAINER(widget), gtk_treectrl_first_selected_callback, data); | |
305 | } | |
306 | ||
e21a5048 | 307 | wxTreeItemId wxTreeCtrl::GetSelection() const { |
e895ec45 | 308 | GtkTreeItem *p = NULL; |
f4e325b3 | 309 | |
e895ec45 DP |
310 | if (m_anchor == NULL) |
311 | return NULL; | |
d9692df7 | 312 | |
e895ec45 DP |
313 | gtk_treectrl_first_selected_callback(GTK_WIDGET(m_anchor), &p); |
314 | ||
315 | return p; | |
d9692df7 DP |
316 | } |
317 | ||
e21a5048 | 318 | wxTreeItemId wxTreeCtrl::GetParent(const wxTreeItemId& item) const { |
e21a5048 DP |
319 | if (item.IsOk()) |
320 | return (GtkTreeItem *)gtk_object_get_data(GTK_OBJECT((GtkTreeItem *)item), "parent"); | |
d9692df7 | 321 | |
e21a5048 DP |
322 | return NULL; |
323 | } | |
d9692df7 | 324 | |
e21a5048 | 325 | wxTreeItemId wxTreeCtrl::GetFirstChild(const wxTreeItemId& item, long& cookie) const { |
e895ec45 DP |
326 | GtkTreeItem *p = (GtkTreeItem *)item; |
327 | GtkWidget *parent = GTK_WIDGET(p)->parent; | |
328 | ||
329 | if (!GTK_IS_TREE(parent)) | |
330 | return NULL; | |
331 | ||
332 | cookie = 0; | |
333 | return GTK_TREE_ITEM(g_list_first(GTK_TREE(parent)->children)->data); | |
d9692df7 | 334 | } |
f4e325b3 | 335 | |
e21a5048 | 336 | wxTreeItemId wxTreeCtrl::GetNextChild(const wxTreeItemId& item, long& cookie) const { |
e895ec45 DP |
337 | GtkTreeItem *p = (GtkTreeItem *)item; |
338 | GtkWidget *parent = GTK_WIDGET(p)->parent; | |
339 | ||
340 | if (!GTK_IS_TREE(parent)) | |
341 | return NULL; | |
342 | ||
343 | cookie++; | |
344 | return GTK_TREE_ITEM(g_list_nth(GTK_TREE(parent)->children, cookie)->data); | |
e21a5048 | 345 | } |
f4e325b3 | 346 | |
978f38c2 VZ |
347 | wxTreeItemId wxTreeCtrl::GetLastChild(const wxTreeItemId& item) const |
348 | { | |
349 | GtkTreeItem *p = (GtkTreeItem *)item; | |
350 | GtkWidget *parent = GTK_WIDGET(p)->parent; | |
351 | ||
352 | wxCHECK_MSG( GTK_IS_TREE(parent), NULL, "invalid tree item" ); | |
353 | ||
354 | return GTK_TREE_ITEM(g_list_last(GTK_TREE(parent)->children)->data); | |
355 | } | |
356 | ||
e21a5048 | 357 | wxTreeItemId wxTreeCtrl::GetNextSibling(const wxTreeItemId& item) const { |
e895ec45 DP |
358 | GtkTreeItem *p = (GtkTreeItem *)item; |
359 | GtkWidget *parent = GTK_WIDGET(p)->parent; | |
360 | ||
361 | if (!GTK_IS_TREE(parent)) | |
362 | return NULL; | |
363 | ||
364 | if (g_list_index(GTK_TREE(parent)->children, p) == -1) | |
365 | return NULL; | |
366 | ||
367 | return GTK_TREE_ITEM(g_list_next(g_list_find(GTK_TREE(parent)->children, p))->data); | |
e21a5048 | 368 | } |
f4e325b3 | 369 | |
e21a5048 | 370 | wxTreeItemId wxTreeCtrl::GetPrevSibling(const wxTreeItemId& item) const { |
e895ec45 DP |
371 | GtkTreeItem *p = (GtkTreeItem *)item; |
372 | GtkWidget *parent = GTK_WIDGET(p)->parent; | |
373 | ||
374 | if (!GTK_IS_TREE(parent)) | |
375 | return NULL; | |
376 | ||
377 | if (g_list_index(GTK_TREE(parent)->children, p) == -1) | |
378 | return NULL; | |
379 | ||
380 | return GTK_TREE_ITEM(g_list_previous(g_list_find(GTK_TREE(parent)->children, p))->data); | |
d9692df7 DP |
381 | } |
382 | ||
c9d9f242 DP |
383 | static void gtk_treectrl_first_visible_callback(GtkWidget *widget, gpointer data) { |
384 | GtkTreeItem *p = (*((GtkTreeItem **)data)); | |
385 | ||
386 | GtkTree *tree = GTK_TREE(GTK_TREE_ITEM(widget)->subtree); | |
387 | ||
388 | if (tree->children != NULL) { | |
389 | guint len = g_list_length(tree->children); | |
390 | for (guint i=0; i<len; i++) { | |
391 | if (GTK_WIDGET_VISIBLE(GTK_WIDGET(GTK_TREE_ITEM((GtkTreeItem *)g_list_nth(tree->children, i)->data)))) { | |
392 | p = GTK_TREE_ITEM((GtkTreeItem *)g_list_nth(tree->children, i)->data); | |
393 | return; | |
394 | } | |
395 | } | |
396 | } | |
397 | ||
398 | if (GTK_IS_CONTAINER(widget)) | |
399 | gtk_container_foreach(GTK_CONTAINER(widget), gtk_treectrl_first_visible_callback, data); | |
400 | } | |
401 | ||
e21a5048 | 402 | wxTreeItemId wxTreeCtrl::GetFirstVisibleItem() const { |
c9d9f242 DP |
403 | GtkTreeItem *p = NULL; |
404 | ||
405 | if (m_anchor == NULL) | |
406 | return NULL; | |
407 | ||
408 | gtk_treectrl_first_visible_callback(GTK_WIDGET(m_anchor), &p); | |
409 | ||
410 | return p; | |
d9692df7 DP |
411 | } |
412 | ||
e21a5048 | 413 | wxTreeItemId wxTreeCtrl::GetNextVisible(const wxTreeItemId& item) const { |
c9d9f242 DP |
414 | GtkTreeItem *p = (GtkTreeItem *)item; |
415 | GtkTree *parent = GTK_TREE(GTK_WIDGET(p)->parent); | |
416 | GtkTreeItem *q; | |
417 | ||
418 | if (!GTK_IS_TREE(parent)) | |
419 | return NULL; | |
420 | ||
421 | if (parent->children == NULL) | |
422 | return NULL; | |
423 | ||
424 | q = GTK_TREE_ITEM(g_list_next(g_list_find(GTK_TREE(parent)->children, p))->data); | |
425 | ||
426 | while (q != p) { | |
427 | q = GTK_TREE_ITEM(g_list_next(g_list_find(GTK_TREE(parent)->children, q))->data); | |
428 | if (GTK_WIDGET_VISIBLE(GTK_WIDGET(q))) | |
429 | return q; | |
430 | } | |
431 | ||
e21a5048 DP |
432 | return NULL; |
433 | } | |
d9692df7 | 434 | |
e21a5048 | 435 | wxTreeItemId wxTreeCtrl::GetPrevVisible(const wxTreeItemId& item) const { |
c9d9f242 DP |
436 | GtkTreeItem *p = (GtkTreeItem *)item; |
437 | GtkTree *parent = GTK_TREE(GTK_WIDGET(p)->parent); | |
438 | GtkTreeItem *q; | |
439 | ||
440 | if (!GTK_IS_TREE(parent)) | |
441 | return NULL; | |
442 | ||
443 | if (parent->children == NULL) | |
444 | return NULL; | |
445 | ||
446 | q = GTK_TREE_ITEM(g_list_previous(g_list_find(GTK_TREE(parent)->children, p))->data); | |
447 | ||
448 | while (q != p) { | |
449 | q = GTK_TREE_ITEM(g_list_previous(g_list_find(GTK_TREE(parent)->children, q))->data); | |
450 | if (GTK_WIDGET_VISIBLE(GTK_WIDGET(q))) | |
451 | return q; | |
452 | } | |
453 | ||
e21a5048 DP |
454 | return NULL; |
455 | } | |
d9692df7 | 456 | |
e21a5048 DP |
457 | wxTreeItemId wxTreeCtrl::AddRoot(const wxString& text, int image, |
458 | int selectedImage, wxTreeItemData *data) { | |
459 | return p_InsertItem(0, text, image, selectedImage, data); | |
460 | } | |
d9692df7 | 461 | |
e21a5048 DP |
462 | wxTreeItemId wxTreeCtrl::PrependItem(const wxTreeItemId& parent, |
463 | const wxString& text, int image, int selectedImage, | |
464 | wxTreeItemData *data) { | |
465 | #warning "Need to implement PrependItem" | |
466 | return NULL; | |
467 | } | |
f4e325b3 | 468 | |
e21a5048 DP |
469 | wxTreeItemId wxTreeCtrl::InsertItem(const wxTreeItemId& parent, |
470 | const wxTreeItemId& idPrevious, const wxString& text, | |
471 | int image, int selectedImage, wxTreeItemData *data) { | |
472 | #warning "Need to implement InsertItem" | |
473 | return NULL; | |
d9692df7 | 474 | } |
f4e325b3 | 475 | |
e21a5048 DP |
476 | wxTreeItemId wxTreeCtrl::AppendItem(const wxTreeItemId& parent, |
477 | const wxString& text, int image, int selectedImage, | |
978f38c2 | 478 | wxTreeItemData *data) { |
e21a5048 DP |
479 | return p_InsertItem(parent, text, image, selectedImage, data); |
480 | } | |
f4e325b3 | 481 | |
e21a5048 DP |
482 | wxTreeItemId wxTreeCtrl::p_InsertItem(GtkTreeItem *p, |
483 | const wxString& text, int image, int selectedImage, | |
978f38c2 | 484 | wxTreeItemData *data) { |
e21a5048 | 485 | GtkTreeItem *item; |
d9692df7 | 486 | |
e21a5048 DP |
487 | printf("begin insert\n"); |
488 | ||
489 | item = GTK_TREE_ITEM(gtk_tree_item_new()); | |
490 | ||
491 | GtkHBox *m_box = GTK_HBOX(gtk_hbox_new(FALSE, 0)); | |
492 | gtk_container_add (GTK_CONTAINER (item), GTK_WIDGET(m_box)); | |
493 | ||
494 | gtk_object_set_data(GTK_OBJECT(item), "w_box", m_box); | |
495 | ||
496 | const wxBitmap *bmp; | |
497 | const wxImageList *list; | |
498 | if ((list = GetImageList(wxIMAGE_LIST_NORMAL)) != NULL) | |
499 | if ((bmp = list->GetBitmap(image)) != NULL) | |
500 | if (bmp->Ok()) { | |
501 | GdkBitmap *mask = NULL; | |
502 | if (bmp->GetMask()) | |
503 | mask = bmp->GetMask()->GetBitmap(); | |
504 | GtkPixmap *m_image_widget = GTK_PIXMAP(gtk_pixmap_new(bmp->GetPixmap(), mask)); | |
505 | gtk_misc_set_alignment (GTK_MISC (m_image_widget), 0.0, 0.5); | |
506 | gtk_box_pack_start(GTK_BOX(m_box), GTK_WIDGET(m_image_widget), FALSE, FALSE, 0); | |
507 | gtk_object_set_data(GTK_OBJECT(item), "w_image", (void *)m_image_widget); | |
508 | gtk_object_set_data(GTK_OBJECT(item), "image", (void *)image); | |
509 | gtk_widget_show (GTK_WIDGET(m_image_widget)); | |
510 | } | |
511 | GtkLabel *m_label_widget = GTK_LABEL(gtk_label_new ((char *)(const char *)text)); | |
512 | gtk_misc_set_alignment (GTK_MISC (m_label_widget), 0.5, 0.5); | |
513 | gtk_box_pack_start(GTK_BOX(m_box), GTK_WIDGET(m_label_widget), FALSE, FALSE, 0); | |
514 | gtk_object_set_data(GTK_OBJECT(item), "w_label", m_label_widget); | |
515 | gtk_widget_show (GTK_WIDGET(m_label_widget)); | |
516 | ||
517 | gtk_widget_show(GTK_WIDGET(m_box)); | |
518 | ||
519 | gtk_object_set_data(GTK_OBJECT(item), "owner", this); | |
e895ec45 DP |
520 | gtk_object_set_data(GTK_OBJECT(item), "data", data); |
521 | gtk_object_set_data(GTK_OBJECT(item), "parent", p); | |
e21a5048 DP |
522 | |
523 | if (p != 0) { | |
524 | if (p->subtree == NULL) { | |
525 | GtkTree *tree = GTK_TREE(gtk_tree_new()); | |
526 | gtk_tree_item_set_subtree(GTK_TREE_ITEM(p), GTK_WIDGET(tree)); | |
527 | gtk_widget_show(GTK_WIDGET(tree)); | |
528 | p->expanded = 1; | |
529 | } | |
530 | ||
531 | gtk_container_add(GTK_CONTAINER(p->subtree), GTK_WIDGET(item)); | |
532 | } else { | |
533 | printf("Adding root\n"); | |
534 | printf("m_tree = %p\n", m_tree); | |
535 | m_anchor = item; | |
536 | gtk_container_add(GTK_CONTAINER(m_tree), GTK_WIDGET(item)); | |
d9692df7 | 537 | } |
f4e325b3 | 538 | |
e21a5048 | 539 | gtk_widget_show(GTK_WIDGET(item)); |
d9692df7 | 540 | |
e21a5048 DP |
541 | gtk_signal_connect(GTK_OBJECT(item), "select", |
542 | GTK_SIGNAL_FUNC(gtk_treeitem_select_callback), (gpointer)this ); | |
d9692df7 | 543 | |
e21a5048 DP |
544 | gtk_signal_connect(GTK_OBJECT(item), "deselect", |
545 | GTK_SIGNAL_FUNC(gtk_treeitem_select_callback), (gpointer)this ); | |
d9692df7 | 546 | |
e21a5048 DP |
547 | gtk_signal_connect(GTK_OBJECT(item), "expand", |
548 | GTK_SIGNAL_FUNC(gtk_treeitem_expand_callback), (gpointer)this ); | |
549 | gtk_signal_connect(GTK_OBJECT(item), "collapse", | |
550 | GTK_SIGNAL_FUNC(gtk_treeitem_collapse_callback), (gpointer)this ); | |
551 | ||
552 | return item; | |
d9692df7 DP |
553 | } |
554 | ||
e21a5048 DP |
555 | void wxTreeCtrl::Delete(const wxTreeItemId& item) { |
556 | if (!item.IsOk()) | |
557 | return; | |
d9692df7 | 558 | |
e21a5048 DP |
559 | GtkTreeItem *parent = GTK_TREE_ITEM(GTK_WIDGET((GtkTreeItem *)item)->parent); |
560 | if (parent == NULL) | |
561 | return; | |
d9692df7 | 562 | |
e21a5048 DP |
563 | gtk_container_remove(GTK_CONTAINER(parent), GTK_WIDGET((GtkTreeItem *)item)); |
564 | ||
565 | return; | |
d9692df7 DP |
566 | } |
567 | ||
e21a5048 DP |
568 | void wxTreeCtrl::DeleteAllItems() { |
569 | gtk_tree_item_remove_subtree(m_anchor); | |
570 | } | |
d9692df7 | 571 | |
e21a5048 DP |
572 | void wxTreeCtrl::Expand(const wxTreeItemId& item) { |
573 | if (!item.IsOk()) | |
574 | return; | |
d9692df7 | 575 | |
e21a5048 | 576 | gtk_tree_item_expand(GTK_TREE_ITEM((GtkTreeItem *)item)); |
d9692df7 DP |
577 | } |
578 | ||
e21a5048 DP |
579 | void wxTreeCtrl::Collapse(const wxTreeItemId& item) { |
580 | if (!item.IsOk()) | |
581 | return; | |
d9692df7 | 582 | |
e21a5048 DP |
583 | gtk_tree_item_collapse(GTK_TREE_ITEM((GtkTreeItem *)item)); |
584 | } | |
d9692df7 | 585 | |
e21a5048 DP |
586 | void wxTreeCtrl::CollapseAndReset(const wxTreeItemId& item) { |
587 | if (!item.IsOk()) | |
588 | return; | |
589 | ||
590 | gtk_tree_item_collapse(GTK_TREE_ITEM((GtkTreeItem *)item)); | |
591 | gtk_tree_item_remove_subtree(GTK_TREE_ITEM((GtkTreeItem *)item)); | |
d9692df7 DP |
592 | } |
593 | ||
e21a5048 DP |
594 | void wxTreeCtrl::Toggle(const wxTreeItemId& item) { |
595 | if (!item.IsOk()) | |
596 | return; | |
d9692df7 | 597 | |
e21a5048 DP |
598 | if (((GtkTreeItem *)item)->expanded) |
599 | gtk_tree_item_collapse(GTK_TREE_ITEM((GtkTreeItem *)item)); | |
600 | else | |
601 | gtk_tree_item_expand(GTK_TREE_ITEM((GtkTreeItem *)item)); | |
602 | } | |
d9692df7 | 603 | |
e1dc4cc6 DP |
604 | static void gtk_treectrl_unselect_callback(GtkWidget *widget, gpointer data) { |
605 | GtkTreeItem *p; | |
606 | ||
607 | GtkTree *tree = GTK_TREE(GTK_TREE_ITEM(widget)->subtree); | |
608 | ||
609 | if (tree->selection != NULL) { | |
610 | guint len = g_list_length(tree->selection); | |
611 | for (guint i=0; i<len; i++) { | |
612 | p = GTK_TREE_ITEM((GtkTreeItem *)g_list_nth(tree->selection, i)->data); | |
613 | gtk_tree_unselect_child(tree, GTK_WIDGET(p)); | |
614 | } | |
615 | } | |
616 | ||
617 | if (GTK_IS_CONTAINER(widget)) | |
618 | gtk_container_foreach(GTK_CONTAINER(widget), gtk_treectrl_unselect_callback, data); | |
619 | } | |
620 | ||
e21a5048 | 621 | void wxTreeCtrl::Unselect() { |
e1dc4cc6 DP |
622 | if (m_anchor == NULL) |
623 | return; | |
624 | ||
625 | gtk_treectrl_unselect_callback(GTK_WIDGET(m_anchor), NULL); | |
d9692df7 DP |
626 | } |
627 | ||
e21a5048 DP |
628 | void wxTreeCtrl::SelectItem(const wxTreeItemId& item) { |
629 | if (!item.IsOk()) | |
630 | return; | |
d9692df7 | 631 | |
e21a5048 DP |
632 | gtk_tree_item_select((GtkTreeItem *)item); |
633 | } | |
d9692df7 | 634 | |
e21a5048 DP |
635 | void wxTreeCtrl::EnsureVisible(const wxTreeItemId& item) { |
636 | #warning "Need to implement EnsureVisible" | |
d9692df7 DP |
637 | } |
638 | ||
e21a5048 DP |
639 | void wxTreeCtrl::ScrollTo(const wxTreeItemId& item) { |
640 | #warning "Need to implement ScrollTo" | |
641 | } | |
f4e325b3 | 642 | |
e21a5048 DP |
643 | wxTextCtrl* wxTreeCtrl::EditLabel(const wxTreeItemId& item, |
644 | wxClassInfo* textControlClass) { | |
645 | wxASSERT( textControlClass->IsKindOf(CLASSINFO(wxTextCtrl)) ); | |
646 | #warning "Need to implement EditLabel" | |
e1dc4cc6 DP |
647 | /* |
648 | char *s; | |
649 | m_editItem = item; | |
650 | ||
651 | GtkLabel *m_label = (GtkLabel *)gtk_object_get_data(GTK_OBJECT((GtkTreeItem *)item), "w_label"); | |
652 | gtk_label_get(m_label, &s); | |
653 | ||
654 | m_textCtrl = new wxTextCtrl(this, -1, s); | |
655 | // m_textCtrl->SetValue(s); | |
656 | ||
657 | gtk_object_set_data(GTK_OBJECT((GtkTreeItem *)item), "w_edit", m_textCtrl->m_widget); | |
658 | ||
659 | gtk_container_remove(GTK_CONTAINER((GtkTreeItem *)item), GTK_WIDGET(m_label)); | |
660 | gtk_container_add(GTK_CONTAINER((GtkTreeItem *)item), m_textCtrl->m_widget); | |
661 | ||
662 | */ | |
663 | return m_textCtrl; | |
e21a5048 | 664 | } |
d9692df7 | 665 | |
e21a5048 DP |
666 | wxTextCtrl* wxTreeCtrl::GetEditControl() const { |
667 | return m_textCtrl; | |
d9692df7 DP |
668 | } |
669 | ||
e21a5048 DP |
670 | void wxTreeCtrl::EndEditLabel(const wxTreeItemId& item, bool discardChanges) { |
671 | #warning "Need to implement EndEditLabel" | |
e1dc4cc6 DP |
672 | /* |
673 | GtkLabel *m_label = (GtkLabel *)gtk_object_get_data(GTK_OBJECT((GtkTreeItem *)m_editItem), "w_label"); | |
674 | gtk_label_set(m_label, m_textCtrl->GetValue()); | |
675 | ||
676 | gtk_object_remove_data(GTK_OBJECT((GtkTreeItem *)m_editItem), "w_edit"); | |
677 | ||
678 | gtk_container_remove(GTK_CONTAINER((GtkTreeItem *)m_editItem), m_textCtrl->m_widget); | |
679 | gtk_container_add(GTK_CONTAINER((GtkTreeItem *)m_editItem), GTK_WIDGET(m_label)); | |
680 | ||
681 | delete m_textCtrl; | |
682 | m_textCtrl = NULL; | |
683 | */ | |
e21a5048 | 684 | } |
befe54c6 | 685 | |
e21a5048 DP |
686 | void wxTreeCtrl::ExpandItem(const wxTreeItemId& item, int action) { |
687 | switch (action) { | |
688 | case wxTREE_EXPAND_EXPAND: | |
689 | Expand(item); | |
690 | break; | |
d9692df7 | 691 | |
e21a5048 DP |
692 | case wxTREE_EXPAND_COLLAPSE: |
693 | Collapse(item); | |
694 | break; | |
c89a6106 | 695 | |
e21a5048 DP |
696 | case wxTREE_EXPAND_COLLAPSE_RESET: |
697 | CollapseAndReset(item); | |
698 | break; | |
699 | ||
700 | case wxTREE_EXPAND_TOGGLE: | |
701 | Toggle(item); | |
702 | break; | |
703 | ||
704 | default: | |
705 | wxFAIL_MSG("unknown action in wxTreeCtrl::ExpandItem"); | |
706 | } | |
d9692df7 | 707 | } |
f4e325b3 | 708 | |
e21a5048 DP |
709 | wxTreeItemId wxTreeCtrl::InsertItem(const wxTreeItemId& parent, |
710 | const wxString& text, int image, int selImage, | |
711 | long insertAfter) { | |
712 | // InsertItem(parent, insertAfter, text, image, selImage); | |
713 | #warning "Need to implement InsertItem" | |
714 | return NULL; | |
d9692df7 | 715 | } |
f4e325b3 | 716 | |
e21a5048 DP |
717 | /* Old functions |
718 | long wxTreeCtrl::GetChild(long item) const { | |
d9692df7 | 719 | GtkTreeItem *p; |
e21a5048 | 720 | GtkTreeItem *next = NULL; |
f4e325b3 | 721 | |
d9692df7 | 722 | p = findGtkTreeItem(item); |
e21a5048 DP |
723 | GList *list = gtk_container_children(GTK_CONTAINER(p)); |
724 | next = GTK_TREE_ITEM(list->data);; | |
f4e325b3 | 725 | |
e21a5048 DP |
726 | if (next != NULL) |
727 | return (long)gtk_object_get_data(GTK_OBJECT(next), "id"); | |
978f38c2 | 728 | |
e21a5048 DP |
729 | return (-1); |
730 | } | |
d9692df7 | 731 | |
e21a5048 DP |
732 | long wxTreeCtrl::GetFirstVisibleItem(void) const { |
733 | GtkTreeItem *next = NULL; | |
d9692df7 | 734 | |
e21a5048 DP |
735 | GList *list = gtk_container_children(GTK_CONTAINER(m_anchor)); |
736 | next = GTK_TREE_ITEM(list->data);; | |
737 | // gtk_container_foreach(GTK_CONTAINER(m_anchor), gtk_treectrl_next_visible_callback, &next); | |
738 | ||
739 | if (next != NULL) | |
740 | return (long)gtk_object_get_data(GTK_OBJECT(next), "id"); | |
978f38c2 | 741 | |
e21a5048 | 742 | return (-1); |
d9692df7 DP |
743 | } |
744 | ||
e21a5048 | 745 | long wxTreeCtrl::GetNextVisibleItem(long item) const { |
d9692df7 | 746 | GtkTreeItem *p; |
e21a5048 | 747 | GtkTreeItem *next = NULL; |
d9692df7 DP |
748 | |
749 | p = findGtkTreeItem(item); | |
e21a5048 DP |
750 | GList *list = gtk_container_children(GTK_CONTAINER(p)); |
751 | next = GTK_TREE_ITEM(list->data);; | |
752 | // gtk_container_foreach(GTK_CONTAINER(p), gtk_treectrl_next_visible_callback, &next); | |
753 | ||
754 | if (next != NULL) | |
755 | return (long)gtk_object_get_data(GTK_OBJECT(next), "id"); | |
978f38c2 | 756 | |
e21a5048 DP |
757 | return (-1); |
758 | } | |
759 | ||
760 | bool wxTreeCtrl::GetItem(wxTreeItem& info) const { | |
761 | GtkTreeItem *p; | |
762 | ||
763 | p = findGtkTreeItem(info.m_itemId); | |
764 | ||
765 | if (p == NULL) { | |
766 | wxLogSysError("TreeCtrl::GetItem failed"); | |
d9692df7 | 767 | return FALSE; |
e21a5048 | 768 | } |
d9692df7 | 769 | |
e21a5048 | 770 | wxConvertFromGtkTreeItem(info, p); |
d9692df7 DP |
771 | |
772 | return TRUE; | |
773 | } | |
774 | ||
e21a5048 | 775 | bool wxTreeCtrl::SetItem(wxTreeItem& info) { |
d9692df7 DP |
776 | GtkTreeItem *p; |
777 | ||
e21a5048 | 778 | p = findGtkTreeItem(info.m_itemId); |
d9692df7 | 779 | |
e21a5048 DP |
780 | if (p == NULL) { |
781 | wxLogSysError("TreeCtrl::SetItem failed"); | |
f4e325b3 | 782 | return FALSE; |
e21a5048 | 783 | } |
f4e325b3 | 784 | |
e21a5048 | 785 | wxConvertToGtkTreeItem(this, info, &p); |
f4e325b3 | 786 | |
e21a5048 DP |
787 | return TRUE; |
788 | } | |
d9692df7 | 789 | |
e21a5048 DP |
790 | int wxTreeCtrl::GetItemState(long item, long stateMask) const { |
791 | wxTreeItem info; | |
f4e325b3 | 792 | |
e21a5048 DP |
793 | info.m_mask = wxTREE_MASK_STATE ; |
794 | info.m_stateMask = stateMask; | |
795 | info.m_itemId = item; | |
d9692df7 | 796 | |
e21a5048 DP |
797 | if (!GetItem(info)) |
798 | return 0; | |
799 | ||
800 | return info.m_state; | |
801 | } | |
802 | ||
803 | bool wxTreeCtrl::SetItemState(long item, long state, long stateMask) { | |
804 | wxTreeItem info; | |
805 | ||
806 | info.m_mask = wxTREE_MASK_STATE ; | |
807 | info.m_state = state; | |
808 | info.m_stateMask = stateMask; | |
809 | info.m_itemId = item; | |
810 | ||
811 | return SetItem(info); | |
812 | } | |
813 | */ | |
814 | ||
815 | // Operations | |
816 | /* | |
817 | bool wxTreeCtrl::DeleteChildren(long item) { | |
818 | GtkTreeItem *p; | |
819 | ||
820 | p = findGtkTreeItem(item); | |
821 | if (p == NULL) | |
822 | return FALSE; | |
823 | ||
824 | gtk_tree_item_remove_subtree(GTK_TREE_ITEM(p)); | |
f4e325b3 DP |
825 | |
826 | return TRUE; | |
d9692df7 | 827 | } |
e21a5048 | 828 | */ |
f4e325b3 | 829 | |
e21a5048 DP |
830 | /* |
831 | long wxTreeCtrl::InsertItem(long parent, wxTreeItem& info, long insertAfter) { | |
d9692df7 DP |
832 | GtkTreeItem *p; |
833 | GtkTreeItem *item = NULL; | |
834 | ||
835 | info.m_itemId = m_curitemId; | |
836 | m_curitemId++; | |
837 | ||
838 | wxConvertToGtkTreeItem(this, info, &item); | |
839 | ||
840 | if (parent != 0) { | |
841 | p = findGtkTreeItem(parent); | |
842 | if (p->subtree == NULL) { | |
843 | GtkTree *tree = GTK_TREE(gtk_tree_new()); | |
844 | gtk_tree_item_set_subtree(GTK_TREE_ITEM(p), GTK_WIDGET(tree)); | |
845 | gtk_widget_show(GTK_WIDGET(tree)); | |
846 | p->expanded = 1; | |
847 | } | |
f4e325b3 | 848 | |
d9692df7 DP |
849 | gtk_container_add(GTK_CONTAINER(p->subtree), GTK_WIDGET(item)); |
850 | } else { | |
851 | m_anchor = item; | |
852 | gtk_container_add(GTK_CONTAINER(m_tree), GTK_WIDGET(item)); | |
853 | } | |
854 | ||
855 | if ((info.m_mask & wxTREE_MASK_CHILDREN) != 0) { | |
856 | GtkTree *tree = GTK_TREE(gtk_tree_new()); | |
857 | gtk_tree_item_set_subtree(GTK_TREE_ITEM(item), GTK_WIDGET(tree)); | |
858 | gtk_widget_show(GTK_WIDGET(tree)); | |
859 | } | |
860 | ||
861 | gtk_widget_show(GTK_WIDGET(item)); | |
862 | ||
863 | gtk_signal_connect(GTK_OBJECT(item), "select", | |
864 | GTK_SIGNAL_FUNC(gtk_treeitem_select_callback), (gpointer)this ); | |
865 | ||
866 | gtk_signal_connect(GTK_OBJECT(item), "deselect", | |
867 | GTK_SIGNAL_FUNC(gtk_treeitem_select_callback), (gpointer)this ); | |
868 | ||
869 | gtk_signal_connect(GTK_OBJECT(item), "expand", | |
870 | GTK_SIGNAL_FUNC(gtk_treeitem_expand_callback), (gpointer)this ); | |
871 | gtk_signal_connect(GTK_OBJECT(item), "collapse", | |
872 | GTK_SIGNAL_FUNC(gtk_treeitem_collapse_callback), (gpointer)this ); | |
873 | ||
874 | return info.m_itemId; | |
f4e325b3 DP |
875 | } |
876 | ||
d9692df7 DP |
877 | long wxTreeCtrl::InsertItem(long parent, const wxString& label, int image, |
878 | int selImage, long insertAfter) { | |
879 | ||
880 | wxTreeItem info; | |
881 | info.m_text = label; | |
882 | info.m_mask = wxTREE_MASK_TEXT; | |
883 | if (image > -1) { | |
884 | info.m_mask |= wxTREE_MASK_IMAGE | wxTREE_MASK_SELECTED_IMAGE; | |
885 | info.m_image = image; | |
886 | if (selImage == -1) | |
887 | info.m_selectedImage = image; | |
888 | else | |
889 | info.m_selectedImage = selImage; | |
890 | } | |
f4e325b3 | 891 | |
d9692df7 | 892 | return InsertItem(parent, info, insertAfter); |
f4e325b3 | 893 | } |
d9692df7 | 894 | */ |
f4e325b3 | 895 | |
e895ec45 DP |
896 | void wxTreeCtrl::SendMessage(wxEventType command, const wxTreeItemId& item) { |
897 | wxTreeEvent event(command, GetId()); | |
d9692df7 | 898 | event.SetEventObject(this); |
e895ec45 | 899 | event.m_item = item; |
d9692df7 DP |
900 | ProcessEvent(event); |
901 | } | |
f4e325b3 | 902 | |
e895ec45 DP |
903 | void wxTreeCtrl::SendExpanding(const wxTreeItemId& item) { |
904 | SendMessage(wxEVT_COMMAND_TREE_ITEM_EXPANDING, item); | |
905 | } | |
906 | ||
e21a5048 | 907 | void wxTreeCtrl::SendExpanded(const wxTreeItemId& item) { |
e895ec45 | 908 | SendMessage(wxEVT_COMMAND_TREE_ITEM_EXPANDED, item); |
d9692df7 | 909 | } |
f4e325b3 | 910 | |
e21a5048 | 911 | void wxTreeCtrl::SendCollapsing(const wxTreeItemId& item) { |
e895ec45 | 912 | SendMessage(wxEVT_COMMAND_TREE_ITEM_COLLAPSING, item); |
d9692df7 | 913 | } |
f4e325b3 | 914 | |
e21a5048 | 915 | void wxTreeCtrl::SendCollapsed(const wxTreeItemId& item) { |
e895ec45 | 916 | SendMessage(wxEVT_COMMAND_TREE_ITEM_COLLAPSED, item); |
d9692df7 | 917 | } |
f4e325b3 | 918 | |
e21a5048 | 919 | void wxTreeCtrl::SendSelChanging(const wxTreeItemId& item) { |
e895ec45 | 920 | SendMessage(wxEVT_COMMAND_TREE_SEL_CHANGED, item); |
f4e325b3 DP |
921 | } |
922 | ||
e21a5048 | 923 | void wxTreeCtrl::SendSelChanged(const wxTreeItemId& item) { |
e895ec45 | 924 | SendMessage(wxEVT_COMMAND_TREE_SEL_CHANGING, item); |
d9692df7 | 925 | } |
f4e325b3 | 926 | |
d9692df7 DP |
927 | // Tree event |
928 | IMPLEMENT_DYNAMIC_CLASS(wxTreeEvent, wxCommandEvent) | |
929 | ||
e21a5048 DP |
930 | wxTreeEvent::wxTreeEvent(wxEventType commandType, int id): |
931 | wxCommandEvent(commandType, id) { | |
d9692df7 | 932 | m_code = 0; |
e21a5048 | 933 | m_itemOld = 0; |
d9692df7 | 934 | } |