]>
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 | |
e21a5048 | 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" |
e21a5048 | 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 | ||
d9692df7 | 78 | #if !USE_SHARED_LIBRARY |
e21a5048 DP |
79 | IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrl, wxControl) |
80 | ||
d9692df7 | 81 | #endif |
f4e325b3 | 82 | |
e21a5048 | 83 | void wxTreeCtrl::Init() { |
d9692df7 DP |
84 | m_imageListNormal = NULL; |
85 | m_imageListState = NULL; | |
86 | m_textCtrl = NULL; | |
d9692df7 DP |
87 | } |
88 | ||
e21a5048 DP |
89 | bool wxTreeCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, |
90 | const wxSize& size, long style, | |
91 | const wxValidator& validator, const wxString& name) { | |
92 | Init(); | |
d9692df7 DP |
93 | |
94 | int x = pos.x; | |
95 | int y = pos.y; | |
96 | int width = size.x; | |
97 | int height = size.y; | |
98 | ||
99 | m_windowStyle = style; | |
100 | ||
101 | SetParent(parent); | |
102 | ||
103 | if (width <= 0) | |
104 | width = 100; | |
105 | if (height <= 0) | |
106 | height = 30; | |
107 | if (x < 0) | |
108 | x = 0; | |
109 | if (y < 0) | |
110 | y = 0; | |
111 | ||
112 | m_needParent = TRUE; | |
113 | ||
e21a5048 | 114 | printf("precreate\n"); |
d9692df7 DP |
115 | PreCreation( parent, id, pos, size, style, name ); |
116 | ||
e21a5048 DP |
117 | printf("1\n"); |
118 | ||
d9692df7 | 119 | m_widget = gtk_scrolled_window_new(NULL, NULL); |
e21a5048 | 120 | printf("2\n"); |
d9692df7 | 121 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(m_widget), |
e21a5048 | 122 | GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
f4e325b3 | 123 | |
e21a5048 | 124 | printf("3\n"); |
f4e325b3 | 125 | m_tree = GTK_TREE(gtk_tree_new()); |
d9692df7 | 126 | |
e21a5048 | 127 | printf("4\n"); |
d9692df7 | 128 | gtk_container_add(GTK_CONTAINER(m_widget), GTK_WIDGET(m_tree)); |
e21a5048 | 129 | printf("5\n"); |
f4e325b3 | 130 | gtk_widget_show(GTK_WIDGET(m_tree)); |
befe54c6 | 131 | |
d9692df7 DP |
132 | SetName(name); |
133 | SetValidator(validator); | |
134 | ||
e21a5048 | 135 | printf("postcreate\n"); |
d9692df7 DP |
136 | PostCreation(); |
137 | ||
138 | gtk_widget_realize(GTK_WIDGET(m_tree)); | |
139 | ||
140 | Show(TRUE); | |
141 | ||
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 | |
e21a5048 | 347 | wxTreeItemId wxTreeCtrl::GetNextSibling(const wxTreeItemId& item) const { |
e895ec45 DP |
348 | GtkTreeItem *p = (GtkTreeItem *)item; |
349 | GtkWidget *parent = GTK_WIDGET(p)->parent; | |
350 | ||
351 | if (!GTK_IS_TREE(parent)) | |
352 | return NULL; | |
353 | ||
354 | if (g_list_index(GTK_TREE(parent)->children, p) == -1) | |
355 | return NULL; | |
356 | ||
357 | return GTK_TREE_ITEM(g_list_next(g_list_find(GTK_TREE(parent)->children, p))->data); | |
e21a5048 | 358 | } |
f4e325b3 | 359 | |
e21a5048 | 360 | wxTreeItemId wxTreeCtrl::GetPrevSibling(const wxTreeItemId& item) const { |
e895ec45 DP |
361 | GtkTreeItem *p = (GtkTreeItem *)item; |
362 | GtkWidget *parent = GTK_WIDGET(p)->parent; | |
363 | ||
364 | if (!GTK_IS_TREE(parent)) | |
365 | return NULL; | |
366 | ||
367 | if (g_list_index(GTK_TREE(parent)->children, p) == -1) | |
368 | return NULL; | |
369 | ||
370 | return GTK_TREE_ITEM(g_list_previous(g_list_find(GTK_TREE(parent)->children, p))->data); | |
d9692df7 DP |
371 | } |
372 | ||
c9d9f242 DP |
373 | static void gtk_treectrl_first_visible_callback(GtkWidget *widget, gpointer data) { |
374 | GtkTreeItem *p = (*((GtkTreeItem **)data)); | |
375 | ||
376 | GtkTree *tree = GTK_TREE(GTK_TREE_ITEM(widget)->subtree); | |
377 | ||
378 | if (tree->children != NULL) { | |
379 | guint len = g_list_length(tree->children); | |
380 | for (guint i=0; i<len; i++) { | |
381 | if (GTK_WIDGET_VISIBLE(GTK_WIDGET(GTK_TREE_ITEM((GtkTreeItem *)g_list_nth(tree->children, i)->data)))) { | |
382 | p = GTK_TREE_ITEM((GtkTreeItem *)g_list_nth(tree->children, i)->data); | |
383 | return; | |
384 | } | |
385 | } | |
386 | } | |
387 | ||
388 | if (GTK_IS_CONTAINER(widget)) | |
389 | gtk_container_foreach(GTK_CONTAINER(widget), gtk_treectrl_first_visible_callback, data); | |
390 | } | |
391 | ||
e21a5048 | 392 | wxTreeItemId wxTreeCtrl::GetFirstVisibleItem() const { |
c9d9f242 DP |
393 | GtkTreeItem *p = NULL; |
394 | ||
395 | if (m_anchor == NULL) | |
396 | return NULL; | |
397 | ||
398 | gtk_treectrl_first_visible_callback(GTK_WIDGET(m_anchor), &p); | |
399 | ||
400 | return p; | |
d9692df7 DP |
401 | } |
402 | ||
e21a5048 | 403 | wxTreeItemId wxTreeCtrl::GetNextVisible(const wxTreeItemId& item) const { |
c9d9f242 DP |
404 | GtkTreeItem *p = (GtkTreeItem *)item; |
405 | GtkTree *parent = GTK_TREE(GTK_WIDGET(p)->parent); | |
406 | GtkTreeItem *q; | |
407 | ||
408 | if (!GTK_IS_TREE(parent)) | |
409 | return NULL; | |
410 | ||
411 | if (parent->children == NULL) | |
412 | return NULL; | |
413 | ||
414 | q = GTK_TREE_ITEM(g_list_next(g_list_find(GTK_TREE(parent)->children, p))->data); | |
415 | ||
416 | while (q != p) { | |
417 | q = GTK_TREE_ITEM(g_list_next(g_list_find(GTK_TREE(parent)->children, q))->data); | |
418 | if (GTK_WIDGET_VISIBLE(GTK_WIDGET(q))) | |
419 | return q; | |
420 | } | |
421 | ||
e21a5048 DP |
422 | return NULL; |
423 | } | |
d9692df7 | 424 | |
e21a5048 | 425 | wxTreeItemId wxTreeCtrl::GetPrevVisible(const wxTreeItemId& item) const { |
c9d9f242 DP |
426 | GtkTreeItem *p = (GtkTreeItem *)item; |
427 | GtkTree *parent = GTK_TREE(GTK_WIDGET(p)->parent); | |
428 | GtkTreeItem *q; | |
429 | ||
430 | if (!GTK_IS_TREE(parent)) | |
431 | return NULL; | |
432 | ||
433 | if (parent->children == NULL) | |
434 | return NULL; | |
435 | ||
436 | q = GTK_TREE_ITEM(g_list_previous(g_list_find(GTK_TREE(parent)->children, p))->data); | |
437 | ||
438 | while (q != p) { | |
439 | q = GTK_TREE_ITEM(g_list_previous(g_list_find(GTK_TREE(parent)->children, q))->data); | |
440 | if (GTK_WIDGET_VISIBLE(GTK_WIDGET(q))) | |
441 | return q; | |
442 | } | |
443 | ||
e21a5048 DP |
444 | return NULL; |
445 | } | |
d9692df7 | 446 | |
e21a5048 DP |
447 | wxTreeItemId wxTreeCtrl::AddRoot(const wxString& text, int image, |
448 | int selectedImage, wxTreeItemData *data) { | |
449 | return p_InsertItem(0, text, image, selectedImage, data); | |
450 | } | |
d9692df7 | 451 | |
e21a5048 DP |
452 | wxTreeItemId wxTreeCtrl::PrependItem(const wxTreeItemId& parent, |
453 | const wxString& text, int image, int selectedImage, | |
454 | wxTreeItemData *data) { | |
455 | #warning "Need to implement PrependItem" | |
456 | return NULL; | |
457 | } | |
f4e325b3 | 458 | |
e21a5048 DP |
459 | wxTreeItemId wxTreeCtrl::InsertItem(const wxTreeItemId& parent, |
460 | const wxTreeItemId& idPrevious, const wxString& text, | |
461 | int image, int selectedImage, wxTreeItemData *data) { | |
462 | #warning "Need to implement InsertItem" | |
463 | return NULL; | |
d9692df7 | 464 | } |
f4e325b3 | 465 | |
e21a5048 DP |
466 | wxTreeItemId wxTreeCtrl::AppendItem(const wxTreeItemId& parent, |
467 | const wxString& text, int image, int selectedImage, | |
468 | wxTreeItemData *data) { | |
469 | return p_InsertItem(parent, text, image, selectedImage, data); | |
470 | } | |
f4e325b3 | 471 | |
e21a5048 DP |
472 | wxTreeItemId wxTreeCtrl::p_InsertItem(GtkTreeItem *p, |
473 | const wxString& text, int image, int selectedImage, | |
474 | wxTreeItemData *data) { | |
475 | GtkTreeItem *item; | |
d9692df7 | 476 | |
e21a5048 DP |
477 | printf("begin insert\n"); |
478 | ||
479 | item = GTK_TREE_ITEM(gtk_tree_item_new()); | |
480 | ||
481 | GtkHBox *m_box = GTK_HBOX(gtk_hbox_new(FALSE, 0)); | |
482 | gtk_container_add (GTK_CONTAINER (item), GTK_WIDGET(m_box)); | |
483 | ||
484 | gtk_object_set_data(GTK_OBJECT(item), "w_box", m_box); | |
485 | ||
486 | const wxBitmap *bmp; | |
487 | const wxImageList *list; | |
488 | if ((list = GetImageList(wxIMAGE_LIST_NORMAL)) != NULL) | |
489 | if ((bmp = list->GetBitmap(image)) != NULL) | |
490 | if (bmp->Ok()) { | |
491 | GdkBitmap *mask = NULL; | |
492 | if (bmp->GetMask()) | |
493 | mask = bmp->GetMask()->GetBitmap(); | |
494 | GtkPixmap *m_image_widget = GTK_PIXMAP(gtk_pixmap_new(bmp->GetPixmap(), mask)); | |
495 | gtk_misc_set_alignment (GTK_MISC (m_image_widget), 0.0, 0.5); | |
496 | gtk_box_pack_start(GTK_BOX(m_box), GTK_WIDGET(m_image_widget), FALSE, FALSE, 0); | |
497 | gtk_object_set_data(GTK_OBJECT(item), "w_image", (void *)m_image_widget); | |
498 | gtk_object_set_data(GTK_OBJECT(item), "image", (void *)image); | |
499 | gtk_widget_show (GTK_WIDGET(m_image_widget)); | |
500 | } | |
501 | GtkLabel *m_label_widget = GTK_LABEL(gtk_label_new ((char *)(const char *)text)); | |
502 | gtk_misc_set_alignment (GTK_MISC (m_label_widget), 0.5, 0.5); | |
503 | gtk_box_pack_start(GTK_BOX(m_box), GTK_WIDGET(m_label_widget), FALSE, FALSE, 0); | |
504 | gtk_object_set_data(GTK_OBJECT(item), "w_label", m_label_widget); | |
505 | gtk_widget_show (GTK_WIDGET(m_label_widget)); | |
506 | ||
507 | gtk_widget_show(GTK_WIDGET(m_box)); | |
508 | ||
509 | gtk_object_set_data(GTK_OBJECT(item), "owner", this); | |
e895ec45 DP |
510 | gtk_object_set_data(GTK_OBJECT(item), "data", data); |
511 | gtk_object_set_data(GTK_OBJECT(item), "parent", p); | |
e21a5048 DP |
512 | |
513 | if (p != 0) { | |
514 | if (p->subtree == NULL) { | |
515 | GtkTree *tree = GTK_TREE(gtk_tree_new()); | |
516 | gtk_tree_item_set_subtree(GTK_TREE_ITEM(p), GTK_WIDGET(tree)); | |
517 | gtk_widget_show(GTK_WIDGET(tree)); | |
518 | p->expanded = 1; | |
519 | } | |
520 | ||
521 | gtk_container_add(GTK_CONTAINER(p->subtree), GTK_WIDGET(item)); | |
522 | } else { | |
523 | printf("Adding root\n"); | |
524 | printf("m_tree = %p\n", m_tree); | |
525 | m_anchor = item; | |
526 | gtk_container_add(GTK_CONTAINER(m_tree), GTK_WIDGET(item)); | |
d9692df7 | 527 | } |
f4e325b3 | 528 | |
e21a5048 | 529 | gtk_widget_show(GTK_WIDGET(item)); |
d9692df7 | 530 | |
e21a5048 DP |
531 | gtk_signal_connect(GTK_OBJECT(item), "select", |
532 | GTK_SIGNAL_FUNC(gtk_treeitem_select_callback), (gpointer)this ); | |
d9692df7 | 533 | |
e21a5048 DP |
534 | gtk_signal_connect(GTK_OBJECT(item), "deselect", |
535 | GTK_SIGNAL_FUNC(gtk_treeitem_select_callback), (gpointer)this ); | |
d9692df7 | 536 | |
e21a5048 DP |
537 | gtk_signal_connect(GTK_OBJECT(item), "expand", |
538 | GTK_SIGNAL_FUNC(gtk_treeitem_expand_callback), (gpointer)this ); | |
539 | gtk_signal_connect(GTK_OBJECT(item), "collapse", | |
540 | GTK_SIGNAL_FUNC(gtk_treeitem_collapse_callback), (gpointer)this ); | |
541 | ||
542 | return item; | |
d9692df7 DP |
543 | } |
544 | ||
e21a5048 DP |
545 | void wxTreeCtrl::Delete(const wxTreeItemId& item) { |
546 | if (!item.IsOk()) | |
547 | return; | |
d9692df7 | 548 | |
e21a5048 DP |
549 | GtkTreeItem *parent = GTK_TREE_ITEM(GTK_WIDGET((GtkTreeItem *)item)->parent); |
550 | if (parent == NULL) | |
551 | return; | |
d9692df7 | 552 | |
e21a5048 DP |
553 | gtk_container_remove(GTK_CONTAINER(parent), GTK_WIDGET((GtkTreeItem *)item)); |
554 | ||
555 | return; | |
d9692df7 DP |
556 | } |
557 | ||
e21a5048 DP |
558 | void wxTreeCtrl::DeleteAllItems() { |
559 | gtk_tree_item_remove_subtree(m_anchor); | |
560 | } | |
d9692df7 | 561 | |
e21a5048 DP |
562 | void wxTreeCtrl::Expand(const wxTreeItemId& item) { |
563 | if (!item.IsOk()) | |
564 | return; | |
d9692df7 | 565 | |
e21a5048 | 566 | gtk_tree_item_expand(GTK_TREE_ITEM((GtkTreeItem *)item)); |
d9692df7 DP |
567 | } |
568 | ||
e21a5048 DP |
569 | void wxTreeCtrl::Collapse(const wxTreeItemId& item) { |
570 | if (!item.IsOk()) | |
571 | return; | |
d9692df7 | 572 | |
e21a5048 DP |
573 | gtk_tree_item_collapse(GTK_TREE_ITEM((GtkTreeItem *)item)); |
574 | } | |
d9692df7 | 575 | |
e21a5048 DP |
576 | void wxTreeCtrl::CollapseAndReset(const wxTreeItemId& item) { |
577 | if (!item.IsOk()) | |
578 | return; | |
579 | ||
580 | gtk_tree_item_collapse(GTK_TREE_ITEM((GtkTreeItem *)item)); | |
581 | gtk_tree_item_remove_subtree(GTK_TREE_ITEM((GtkTreeItem *)item)); | |
d9692df7 DP |
582 | } |
583 | ||
e21a5048 DP |
584 | void wxTreeCtrl::Toggle(const wxTreeItemId& item) { |
585 | if (!item.IsOk()) | |
586 | return; | |
d9692df7 | 587 | |
e21a5048 DP |
588 | if (((GtkTreeItem *)item)->expanded) |
589 | gtk_tree_item_collapse(GTK_TREE_ITEM((GtkTreeItem *)item)); | |
590 | else | |
591 | gtk_tree_item_expand(GTK_TREE_ITEM((GtkTreeItem *)item)); | |
592 | } | |
d9692df7 | 593 | |
e1dc4cc6 DP |
594 | static void gtk_treectrl_unselect_callback(GtkWidget *widget, gpointer data) { |
595 | GtkTreeItem *p; | |
596 | ||
597 | GtkTree *tree = GTK_TREE(GTK_TREE_ITEM(widget)->subtree); | |
598 | ||
599 | if (tree->selection != NULL) { | |
600 | guint len = g_list_length(tree->selection); | |
601 | for (guint i=0; i<len; i++) { | |
602 | p = GTK_TREE_ITEM((GtkTreeItem *)g_list_nth(tree->selection, i)->data); | |
603 | gtk_tree_unselect_child(tree, GTK_WIDGET(p)); | |
604 | } | |
605 | } | |
606 | ||
607 | if (GTK_IS_CONTAINER(widget)) | |
608 | gtk_container_foreach(GTK_CONTAINER(widget), gtk_treectrl_unselect_callback, data); | |
609 | } | |
610 | ||
e21a5048 | 611 | void wxTreeCtrl::Unselect() { |
e1dc4cc6 DP |
612 | if (m_anchor == NULL) |
613 | return; | |
614 | ||
615 | gtk_treectrl_unselect_callback(GTK_WIDGET(m_anchor), NULL); | |
d9692df7 DP |
616 | } |
617 | ||
e21a5048 DP |
618 | void wxTreeCtrl::SelectItem(const wxTreeItemId& item) { |
619 | if (!item.IsOk()) | |
620 | return; | |
d9692df7 | 621 | |
e21a5048 DP |
622 | gtk_tree_item_select((GtkTreeItem *)item); |
623 | } | |
d9692df7 | 624 | |
e21a5048 DP |
625 | void wxTreeCtrl::EnsureVisible(const wxTreeItemId& item) { |
626 | #warning "Need to implement EnsureVisible" | |
d9692df7 DP |
627 | } |
628 | ||
e21a5048 DP |
629 | void wxTreeCtrl::ScrollTo(const wxTreeItemId& item) { |
630 | #warning "Need to implement ScrollTo" | |
631 | } | |
f4e325b3 | 632 | |
e21a5048 DP |
633 | wxTextCtrl* wxTreeCtrl::EditLabel(const wxTreeItemId& item, |
634 | wxClassInfo* textControlClass) { | |
635 | wxASSERT( textControlClass->IsKindOf(CLASSINFO(wxTextCtrl)) ); | |
636 | #warning "Need to implement EditLabel" | |
e1dc4cc6 DP |
637 | /* |
638 | char *s; | |
639 | m_editItem = item; | |
640 | ||
641 | GtkLabel *m_label = (GtkLabel *)gtk_object_get_data(GTK_OBJECT((GtkTreeItem *)item), "w_label"); | |
642 | gtk_label_get(m_label, &s); | |
643 | ||
644 | m_textCtrl = new wxTextCtrl(this, -1, s); | |
645 | // m_textCtrl->SetValue(s); | |
646 | ||
647 | gtk_object_set_data(GTK_OBJECT((GtkTreeItem *)item), "w_edit", m_textCtrl->m_widget); | |
648 | ||
649 | gtk_container_remove(GTK_CONTAINER((GtkTreeItem *)item), GTK_WIDGET(m_label)); | |
650 | gtk_container_add(GTK_CONTAINER((GtkTreeItem *)item), m_textCtrl->m_widget); | |
651 | ||
652 | */ | |
653 | return m_textCtrl; | |
e21a5048 | 654 | } |
d9692df7 | 655 | |
e21a5048 DP |
656 | wxTextCtrl* wxTreeCtrl::GetEditControl() const { |
657 | return m_textCtrl; | |
d9692df7 DP |
658 | } |
659 | ||
e21a5048 DP |
660 | void wxTreeCtrl::EndEditLabel(const wxTreeItemId& item, bool discardChanges) { |
661 | #warning "Need to implement EndEditLabel" | |
e1dc4cc6 DP |
662 | /* |
663 | GtkLabel *m_label = (GtkLabel *)gtk_object_get_data(GTK_OBJECT((GtkTreeItem *)m_editItem), "w_label"); | |
664 | gtk_label_set(m_label, m_textCtrl->GetValue()); | |
665 | ||
666 | gtk_object_remove_data(GTK_OBJECT((GtkTreeItem *)m_editItem), "w_edit"); | |
667 | ||
668 | gtk_container_remove(GTK_CONTAINER((GtkTreeItem *)m_editItem), m_textCtrl->m_widget); | |
669 | gtk_container_add(GTK_CONTAINER((GtkTreeItem *)m_editItem), GTK_WIDGET(m_label)); | |
670 | ||
671 | delete m_textCtrl; | |
672 | m_textCtrl = NULL; | |
673 | */ | |
e21a5048 | 674 | } |
befe54c6 | 675 | |
e21a5048 DP |
676 | void wxTreeCtrl::ExpandItem(const wxTreeItemId& item, int action) { |
677 | switch (action) { | |
678 | case wxTREE_EXPAND_EXPAND: | |
679 | Expand(item); | |
680 | break; | |
d9692df7 | 681 | |
e21a5048 DP |
682 | case wxTREE_EXPAND_COLLAPSE: |
683 | Collapse(item); | |
684 | break; | |
c89a6106 | 685 | |
e21a5048 DP |
686 | case wxTREE_EXPAND_COLLAPSE_RESET: |
687 | CollapseAndReset(item); | |
688 | break; | |
689 | ||
690 | case wxTREE_EXPAND_TOGGLE: | |
691 | Toggle(item); | |
692 | break; | |
693 | ||
694 | default: | |
695 | wxFAIL_MSG("unknown action in wxTreeCtrl::ExpandItem"); | |
696 | } | |
d9692df7 | 697 | } |
f4e325b3 | 698 | |
e21a5048 DP |
699 | wxTreeItemId wxTreeCtrl::InsertItem(const wxTreeItemId& parent, |
700 | const wxString& text, int image, int selImage, | |
701 | long insertAfter) { | |
702 | // InsertItem(parent, insertAfter, text, image, selImage); | |
703 | #warning "Need to implement InsertItem" | |
704 | return NULL; | |
d9692df7 | 705 | } |
f4e325b3 | 706 | |
e21a5048 DP |
707 | /* Old functions |
708 | long wxTreeCtrl::GetChild(long item) const { | |
d9692df7 | 709 | GtkTreeItem *p; |
e21a5048 | 710 | GtkTreeItem *next = NULL; |
f4e325b3 | 711 | |
d9692df7 | 712 | p = findGtkTreeItem(item); |
e21a5048 DP |
713 | GList *list = gtk_container_children(GTK_CONTAINER(p)); |
714 | next = GTK_TREE_ITEM(list->data);; | |
f4e325b3 | 715 | |
e21a5048 DP |
716 | if (next != NULL) |
717 | return (long)gtk_object_get_data(GTK_OBJECT(next), "id"); | |
718 | ||
719 | return (-1); | |
720 | } | |
d9692df7 | 721 | |
e21a5048 DP |
722 | long wxTreeCtrl::GetFirstVisibleItem(void) const { |
723 | GtkTreeItem *next = NULL; | |
d9692df7 | 724 | |
e21a5048 DP |
725 | GList *list = gtk_container_children(GTK_CONTAINER(m_anchor)); |
726 | next = GTK_TREE_ITEM(list->data);; | |
727 | // gtk_container_foreach(GTK_CONTAINER(m_anchor), gtk_treectrl_next_visible_callback, &next); | |
728 | ||
729 | if (next != NULL) | |
730 | return (long)gtk_object_get_data(GTK_OBJECT(next), "id"); | |
731 | ||
732 | return (-1); | |
d9692df7 DP |
733 | } |
734 | ||
e21a5048 | 735 | long wxTreeCtrl::GetNextVisibleItem(long item) const { |
d9692df7 | 736 | GtkTreeItem *p; |
e21a5048 | 737 | GtkTreeItem *next = NULL; |
d9692df7 DP |
738 | |
739 | p = findGtkTreeItem(item); | |
e21a5048 DP |
740 | GList *list = gtk_container_children(GTK_CONTAINER(p)); |
741 | next = GTK_TREE_ITEM(list->data);; | |
742 | // gtk_container_foreach(GTK_CONTAINER(p), gtk_treectrl_next_visible_callback, &next); | |
743 | ||
744 | if (next != NULL) | |
745 | return (long)gtk_object_get_data(GTK_OBJECT(next), "id"); | |
746 | ||
747 | return (-1); | |
748 | } | |
749 | ||
750 | bool wxTreeCtrl::GetItem(wxTreeItem& info) const { | |
751 | GtkTreeItem *p; | |
752 | ||
753 | p = findGtkTreeItem(info.m_itemId); | |
754 | ||
755 | if (p == NULL) { | |
756 | wxLogSysError("TreeCtrl::GetItem failed"); | |
d9692df7 | 757 | return FALSE; |
e21a5048 | 758 | } |
d9692df7 | 759 | |
e21a5048 | 760 | wxConvertFromGtkTreeItem(info, p); |
d9692df7 DP |
761 | |
762 | return TRUE; | |
763 | } | |
764 | ||
e21a5048 | 765 | bool wxTreeCtrl::SetItem(wxTreeItem& info) { |
d9692df7 DP |
766 | GtkTreeItem *p; |
767 | ||
e21a5048 | 768 | p = findGtkTreeItem(info.m_itemId); |
d9692df7 | 769 | |
e21a5048 DP |
770 | if (p == NULL) { |
771 | wxLogSysError("TreeCtrl::SetItem failed"); | |
f4e325b3 | 772 | return FALSE; |
e21a5048 | 773 | } |
f4e325b3 | 774 | |
e21a5048 | 775 | wxConvertToGtkTreeItem(this, info, &p); |
f4e325b3 | 776 | |
e21a5048 DP |
777 | return TRUE; |
778 | } | |
d9692df7 | 779 | |
e21a5048 DP |
780 | int wxTreeCtrl::GetItemState(long item, long stateMask) const { |
781 | wxTreeItem info; | |
f4e325b3 | 782 | |
e21a5048 DP |
783 | info.m_mask = wxTREE_MASK_STATE ; |
784 | info.m_stateMask = stateMask; | |
785 | info.m_itemId = item; | |
d9692df7 | 786 | |
e21a5048 DP |
787 | if (!GetItem(info)) |
788 | return 0; | |
789 | ||
790 | return info.m_state; | |
791 | } | |
792 | ||
793 | bool wxTreeCtrl::SetItemState(long item, long state, long stateMask) { | |
794 | wxTreeItem info; | |
795 | ||
796 | info.m_mask = wxTREE_MASK_STATE ; | |
797 | info.m_state = state; | |
798 | info.m_stateMask = stateMask; | |
799 | info.m_itemId = item; | |
800 | ||
801 | return SetItem(info); | |
802 | } | |
803 | */ | |
804 | ||
805 | // Operations | |
806 | /* | |
807 | bool wxTreeCtrl::DeleteChildren(long item) { | |
808 | GtkTreeItem *p; | |
809 | ||
810 | p = findGtkTreeItem(item); | |
811 | if (p == NULL) | |
812 | return FALSE; | |
813 | ||
814 | gtk_tree_item_remove_subtree(GTK_TREE_ITEM(p)); | |
f4e325b3 DP |
815 | |
816 | return TRUE; | |
d9692df7 | 817 | } |
e21a5048 | 818 | */ |
f4e325b3 | 819 | |
e21a5048 DP |
820 | /* |
821 | long wxTreeCtrl::InsertItem(long parent, wxTreeItem& info, long insertAfter) { | |
d9692df7 DP |
822 | GtkTreeItem *p; |
823 | GtkTreeItem *item = NULL; | |
824 | ||
825 | info.m_itemId = m_curitemId; | |
826 | m_curitemId++; | |
827 | ||
828 | wxConvertToGtkTreeItem(this, info, &item); | |
829 | ||
830 | if (parent != 0) { | |
831 | p = findGtkTreeItem(parent); | |
832 | if (p->subtree == NULL) { | |
833 | GtkTree *tree = GTK_TREE(gtk_tree_new()); | |
834 | gtk_tree_item_set_subtree(GTK_TREE_ITEM(p), GTK_WIDGET(tree)); | |
835 | gtk_widget_show(GTK_WIDGET(tree)); | |
836 | p->expanded = 1; | |
837 | } | |
f4e325b3 | 838 | |
d9692df7 DP |
839 | gtk_container_add(GTK_CONTAINER(p->subtree), GTK_WIDGET(item)); |
840 | } else { | |
841 | m_anchor = item; | |
842 | gtk_container_add(GTK_CONTAINER(m_tree), GTK_WIDGET(item)); | |
843 | } | |
844 | ||
845 | if ((info.m_mask & wxTREE_MASK_CHILDREN) != 0) { | |
846 | GtkTree *tree = GTK_TREE(gtk_tree_new()); | |
847 | gtk_tree_item_set_subtree(GTK_TREE_ITEM(item), GTK_WIDGET(tree)); | |
848 | gtk_widget_show(GTK_WIDGET(tree)); | |
849 | } | |
850 | ||
851 | gtk_widget_show(GTK_WIDGET(item)); | |
852 | ||
853 | gtk_signal_connect(GTK_OBJECT(item), "select", | |
854 | GTK_SIGNAL_FUNC(gtk_treeitem_select_callback), (gpointer)this ); | |
855 | ||
856 | gtk_signal_connect(GTK_OBJECT(item), "deselect", | |
857 | GTK_SIGNAL_FUNC(gtk_treeitem_select_callback), (gpointer)this ); | |
858 | ||
859 | gtk_signal_connect(GTK_OBJECT(item), "expand", | |
860 | GTK_SIGNAL_FUNC(gtk_treeitem_expand_callback), (gpointer)this ); | |
861 | gtk_signal_connect(GTK_OBJECT(item), "collapse", | |
862 | GTK_SIGNAL_FUNC(gtk_treeitem_collapse_callback), (gpointer)this ); | |
863 | ||
864 | return info.m_itemId; | |
f4e325b3 DP |
865 | } |
866 | ||
d9692df7 DP |
867 | long wxTreeCtrl::InsertItem(long parent, const wxString& label, int image, |
868 | int selImage, long insertAfter) { | |
869 | ||
870 | wxTreeItem info; | |
871 | info.m_text = label; | |
872 | info.m_mask = wxTREE_MASK_TEXT; | |
873 | if (image > -1) { | |
874 | info.m_mask |= wxTREE_MASK_IMAGE | wxTREE_MASK_SELECTED_IMAGE; | |
875 | info.m_image = image; | |
876 | if (selImage == -1) | |
877 | info.m_selectedImage = image; | |
878 | else | |
879 | info.m_selectedImage = selImage; | |
880 | } | |
f4e325b3 | 881 | |
d9692df7 | 882 | return InsertItem(parent, info, insertAfter); |
f4e325b3 | 883 | } |
d9692df7 | 884 | */ |
f4e325b3 | 885 | |
e895ec45 DP |
886 | void wxTreeCtrl::SendMessage(wxEventType command, const wxTreeItemId& item) { |
887 | wxTreeEvent event(command, GetId()); | |
d9692df7 | 888 | event.SetEventObject(this); |
e895ec45 | 889 | event.m_item = item; |
d9692df7 DP |
890 | ProcessEvent(event); |
891 | } | |
f4e325b3 | 892 | |
e895ec45 DP |
893 | void wxTreeCtrl::SendExpanding(const wxTreeItemId& item) { |
894 | SendMessage(wxEVT_COMMAND_TREE_ITEM_EXPANDING, item); | |
895 | } | |
896 | ||
e21a5048 | 897 | void wxTreeCtrl::SendExpanded(const wxTreeItemId& item) { |
e895ec45 | 898 | SendMessage(wxEVT_COMMAND_TREE_ITEM_EXPANDED, item); |
d9692df7 | 899 | } |
f4e325b3 | 900 | |
e21a5048 | 901 | void wxTreeCtrl::SendCollapsing(const wxTreeItemId& item) { |
e895ec45 | 902 | SendMessage(wxEVT_COMMAND_TREE_ITEM_COLLAPSING, item); |
d9692df7 | 903 | } |
f4e325b3 | 904 | |
e21a5048 | 905 | void wxTreeCtrl::SendCollapsed(const wxTreeItemId& item) { |
e895ec45 | 906 | SendMessage(wxEVT_COMMAND_TREE_ITEM_COLLAPSED, item); |
d9692df7 | 907 | } |
f4e325b3 | 908 | |
e21a5048 | 909 | void wxTreeCtrl::SendSelChanging(const wxTreeItemId& item) { |
e895ec45 | 910 | SendMessage(wxEVT_COMMAND_TREE_SEL_CHANGED, item); |
f4e325b3 DP |
911 | } |
912 | ||
e21a5048 | 913 | void wxTreeCtrl::SendSelChanged(const wxTreeItemId& item) { |
e895ec45 | 914 | SendMessage(wxEVT_COMMAND_TREE_SEL_CHANGING, item); |
d9692df7 | 915 | } |
f4e325b3 | 916 | |
d9692df7 DP |
917 | // Tree event |
918 | IMPLEMENT_DYNAMIC_CLASS(wxTreeEvent, wxCommandEvent) | |
919 | ||
e21a5048 DP |
920 | wxTreeEvent::wxTreeEvent(wxEventType commandType, int id): |
921 | wxCommandEvent(commandType, id) { | |
d9692df7 | 922 | m_code = 0; |
e21a5048 | 923 | m_itemOld = 0; |
d9692df7 | 924 | } |