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