]> git.saurik.com Git - wxWidgets.git/blame - samples/treectrl/treetest.cpp
more new files
[wxWidgets.git] / samples / treectrl / treetest.cpp
CommitLineData
457814b5
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: treetest.cpp
3// Purpose: wxTreeCtrl sample
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart and Markus Holzem
3a5a2f56 9// Licence: wxWindows license
457814b5
JS
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
3a5a2f56
VZ
13 #pragma implementation
14 #pragma interface
457814b5
JS
15#endif
16
17// For compilers that support precompilation, includes "wx/wx.h".
18#include "wx/wxprec.h"
19
20#ifdef __BORLANDC__
3a5a2f56 21 #pragma hdrstop
457814b5
JS
22#endif
23
24#ifndef WX_PRECOMP
3a5a2f56 25 #include "wx/wx.h"
457814b5
JS
26#endif
27
3a5a2f56 28// under Windows the icons are in the .rc file
c89a6106
VZ
29#ifndef __WXMSW__
30 #include "icon1.xpm"
31 #include "icon2.xpm"
32 #include "mondrian.xpm"
47908e25
RR
33#endif
34
3a5a2f56
VZ
35#include "wx/log.h"
36
37#include "wx/imaglist.h"
457814b5
JS
38#include "wx/treectrl.h"
39
cf724bce
RR
40#include "math.h"
41
457814b5
JS
42#include "treetest.h"
43
e1ee62bd
VZ
44// verify that the item is ok and insult the user if it is not
45#define CHECK_ITEM( item ) if ( !item.IsOk() ) { \
46 wxMessageBox("Please select some item first!", \
47 "Tree sample error", \
48 wxOK | wxICON_EXCLAMATION, \
49 this); \
50 return; \
5f939e78
VZ
51 }
52
457814b5 53BEGIN_EVENT_TABLE(MyFrame, wxFrame)
5f939e78
VZ
54 EVT_MENU(TreeTest_Quit, MyFrame::OnQuit)
55 EVT_MENU(TreeTest_About, MyFrame::OnAbout)
56 EVT_MENU(TreeTest_Dump, MyFrame::OnDump)
57 EVT_MENU(TreeTest_Rename, MyFrame::OnRename)
58 EVT_MENU(TreeTest_Sort, MyFrame::OnSort)
59 EVT_MENU(TreeTest_SortRev, MyFrame::OnSortRev)
60 EVT_MENU(TreeTest_Bold, MyFrame::OnSetBold)
61 EVT_MENU(TreeTest_UnBold, MyFrame::OnClearBold)
62 EVT_MENU(TreeTest_Delete, MyFrame::OnDelete)
63 EVT_MENU(TreeTest_DeleteChildren, MyFrame::OnDeleteChildren)
64 EVT_MENU(TreeTest_DeleteAll, MyFrame::OnDeleteAll)
65 EVT_MENU(TreeTest_Recreate, MyFrame::OnRecreate)
66 EVT_MENU(TreeTest_CollapseAndReset, MyFrame::OnCollapseAndReset)
67 EVT_MENU(TreeTest_EnsureVisible, MyFrame::OnEnsureVisible)
68 EVT_MENU(TreeTest_AddItem, MyFrame::OnAddItem)
cf724bce
RR
69 EVT_MENU(TreeTest_IncIndent, MyFrame::OnIncIndent)
70 EVT_MENU(TreeTest_DecIndent, MyFrame::OnDecIndent)
71 EVT_MENU(TreeTest_IncSpacing, MyFrame::OnIncSpacing)
72 EVT_MENU(TreeTest_DecSpacing, MyFrame::OnDecSpacing)
457814b5
JS
73END_EVENT_TABLE()
74
75BEGIN_EVENT_TABLE(MyTreeCtrl, wxTreeCtrl)
5f939e78
VZ
76 EVT_TREE_BEGIN_DRAG(TreeTest_Ctrl, MyTreeCtrl::OnBeginDrag)
77 EVT_TREE_BEGIN_RDRAG(TreeTest_Ctrl, MyTreeCtrl::OnBeginRDrag)
78 EVT_TREE_BEGIN_LABEL_EDIT(TreeTest_Ctrl, MyTreeCtrl::OnBeginLabelEdit)
79 EVT_TREE_END_LABEL_EDIT(TreeTest_Ctrl, MyTreeCtrl::OnEndLabelEdit)
80 EVT_TREE_DELETE_ITEM(TreeTest_Ctrl, MyTreeCtrl::OnDeleteItem)
81 EVT_TREE_GET_INFO(TreeTest_Ctrl, MyTreeCtrl::OnGetInfo)
82 EVT_TREE_SET_INFO(TreeTest_Ctrl, MyTreeCtrl::OnSetInfo)
83 EVT_TREE_ITEM_EXPANDED(TreeTest_Ctrl, MyTreeCtrl::OnItemExpanded)
84 EVT_TREE_ITEM_EXPANDING(TreeTest_Ctrl, MyTreeCtrl::OnItemExpanding)
85 EVT_TREE_ITEM_COLLAPSED(TreeTest_Ctrl, MyTreeCtrl::OnItemCollapsed)
86 EVT_TREE_ITEM_COLLAPSING(TreeTest_Ctrl, MyTreeCtrl::OnItemCollapsing)
87 EVT_TREE_SEL_CHANGED(TreeTest_Ctrl, MyTreeCtrl::OnSelChanged)
88 EVT_TREE_SEL_CHANGING(TreeTest_Ctrl, MyTreeCtrl::OnSelChanging)
89 EVT_TREE_KEY_DOWN(TreeTest_Ctrl, MyTreeCtrl::OnTreeKeyDown)
90 EVT_TREE_ITEM_ACTIVATED(TreeTest_Ctrl, MyTreeCtrl::OnItemActivated)
91 EVT_RIGHT_DCLICK(MyTreeCtrl::OnRMouseDClick)
457814b5
JS
92END_EVENT_TABLE()
93
94IMPLEMENT_APP(MyApp)
95
c89a6106 96bool MyApp::OnInit()
457814b5 97{
5f939e78
VZ
98 // Create the main frame window
99 MyFrame *frame = new MyFrame("wxTreeCtrl Test", 50, 50, 450, 340);
457814b5 100
5f939e78
VZ
101 // Show the frame
102 frame->Show(TRUE);
103 SetTopWindow(frame);
457814b5 104
5f939e78 105 return TRUE;
3a5a2f56 106}
457814b5 107
457814b5 108
3a5a2f56
VZ
109// My frame constructor
110MyFrame::MyFrame(const wxString& title, int x, int y, int w, int h)
111 : wxFrame((wxFrame *)NULL, -1, title, wxPoint(x, y), wxSize(w, h))
112{
5f939e78
VZ
113 // This reduces flicker effects - even better would be to define
114 // OnEraseBackground to do nothing. When the tree control's scrollbars are
115 // show or hidden, the frame is sent a background erase event.
116 SetBackgroundColour(wxColour(255, 255, 255));
117
118 // Give it an icon
119 SetIcon(wxICON(mondrian));
120
121 // Make a menubar
122 wxMenu *file_menu = new wxMenu,
123 *tree_menu = new wxMenu,
124 *item_menu = new wxMenu;
125
126 file_menu->Append(TreeTest_About, "&About...");
127 file_menu->AppendSeparator();
128 file_menu->Append(TreeTest_Quit, "E&xit");
129
130 tree_menu->Append(TreeTest_Recreate, "&Recreate the tree");
131 tree_menu->Append(TreeTest_CollapseAndReset, "C&ollapse and reset");
132 tree_menu->AppendSeparator();
133 tree_menu->Append(TreeTest_AddItem, "Append a &new item");
134 tree_menu->Append(TreeTest_Delete, "&Delete this item");
135 tree_menu->Append(TreeTest_DeleteChildren, "Delete &children");
136 tree_menu->Append(TreeTest_DeleteAll, "Delete &all items");
137 tree_menu->AppendSeparator();
138 tree_menu->Append(TreeTest_Sort, "Sort children of current item");
139 tree_menu->Append(TreeTest_SortRev, "Sort in reversed order");
140 tree_menu->AppendSeparator();
141 tree_menu->Append(TreeTest_EnsureVisible, "Make the last item &visible");
cf724bce
RR
142 tree_menu->AppendSeparator();
143 tree_menu->Append(TreeTest_IncIndent, "Add 5 points to indentation\tAlt-I");
144 tree_menu->Append(TreeTest_DecIndent, "Reduce indentation by 5 points\tAlt-R");
145 tree_menu->AppendSeparator();
146 tree_menu->Append(TreeTest_IncSpacing, "Add 5 points to spacing\tCtrl-I");
147 tree_menu->Append(TreeTest_DecSpacing, "Reduce spacing by 5 points\tCtrl-R");
5f939e78
VZ
148
149 item_menu->Append(TreeTest_Dump, "&Dump item children");
150 item_menu->AppendSeparator();
151 item_menu->Append(TreeTest_Rename, "&Rename item...");
152 item_menu->AppendSeparator();
153 item_menu->Append(TreeTest_Bold, "Make item &bold");
154 item_menu->Append(TreeTest_UnBold, "Make item &not bold");
155
156 wxMenuBar *menu_bar = new wxMenuBar;
157 menu_bar->Append(file_menu, "&File");
158 menu_bar->Append(tree_menu, "&Tree");
159 menu_bar->Append(item_menu, "&Item");
160 SetMenuBar(menu_bar);
161
162 m_treeCtrl = new MyTreeCtrl(this, TreeTest_Ctrl,
163 wxDefaultPosition, wxDefaultSize,
88ac883a
VZ
164 wxTR_HAS_BUTTONS | wxSUNKEN_BORDER
165 | wxTR_MULTIPLE
166 );
5f939e78
VZ
167 wxTextCtrl *textCtrl = new wxTextCtrl(this, -1, "",
168 wxDefaultPosition, wxDefaultSize,
169 wxTE_MULTILINE | wxSUNKEN_BORDER);
170
171 wxLayoutConstraints *c = new wxLayoutConstraints;
172 c->top.SameAs(this, wxTop);
173 c->left.SameAs(this, wxLeft);
174 c->right.SameAs(this, wxRight);
175 c->height.PercentOf(this, wxHeight, 66);
176 m_treeCtrl->SetConstraints(c);
177
178 c = new wxLayoutConstraints;
179 c->top.Below(m_treeCtrl);
180 c->left.SameAs(this, wxLeft);
181 c->right.SameAs(this, wxRight);
182 c->bottom.SameAs(this, wxBottom);
183 textCtrl->SetConstraints(c);
184 SetAutoLayout(TRUE);
185
186 // create a status bar with 3 panes
187 CreateStatusBar(3);
188 SetStatusText("", 0);
3a5a2f56 189
a367b9b3 190#ifdef __WXMOTIF__
5f939e78
VZ
191 // For some reason, we get a memcpy crash in wxLogStream::DoLogStream
192 // on gcc/wxMotif, if we use wxLogTextCtl. Maybe it's just gcc?
193 delete wxLog::SetActiveTarget(new wxLogStderr);
a367b9b3 194#else
5f939e78
VZ
195 // set our text control as the log target
196 wxLogTextCtrl *logWindow = new wxLogTextCtrl(textCtrl);
197 delete wxLog::SetActiveTarget(logWindow);
a367b9b3 198#endif
457814b5
JS
199}
200
c89a6106 201MyFrame::~MyFrame()
457814b5 202{
5f939e78 203 delete wxLog::SetActiveTarget(NULL);
457814b5
JS
204}
205
3a5a2f56 206void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
457814b5 207{
5f939e78 208 Close(TRUE);
457814b5
JS
209}
210
3a5a2f56 211void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
457814b5 212{
5f939e78
VZ
213 wxMessageBox("Tree test sample\n"
214 "Julian Smart (c) 1997,\n"
215 "Vadim Zeitlin (c) 1998",
216 "About tree test",
217 wxOK | wxICON_INFORMATION, this);
e1ee62bd
VZ
218}
219
220void MyFrame::OnRename(wxCommandEvent& WXUNUSED(event))
221{
5f939e78 222 wxTreeItemId item = m_treeCtrl->GetSelection();
e1ee62bd 223
5f939e78 224 CHECK_ITEM( item );
e1ee62bd 225
5f939e78
VZ
226 static wxString s_text;
227 s_text = wxGetTextFromUser("New name: ", "Tree sample question",
228 s_text, this);
229 if ( !s_text.IsEmpty() )
230 {
231 m_treeCtrl->SetItemText(item, s_text);
232 }
e1ee62bd
VZ
233}
234
235void MyFrame::DoSort(bool reverse)
236{
5f939e78 237 wxTreeItemId item = m_treeCtrl->GetSelection();
e1ee62bd 238
5f939e78 239 CHECK_ITEM( item );
457814b5 240
5f939e78 241 m_treeCtrl->DoSortChildren(item, reverse);
457814b5
JS
242}
243
4832f7c0
VZ
244void MyFrame::OnDump(wxCommandEvent& WXUNUSED(event))
245{
5f939e78 246 wxTreeItemId root = m_treeCtrl->GetSelection();
e1ee62bd 247
5f939e78 248 CHECK_ITEM( root );
e1ee62bd 249
5f939e78 250 m_treeCtrl->GetItemsRecursively(root, -1);
4832f7c0
VZ
251}
252
add28c55
VZ
253void MyFrame::DoSetBold(bool bold)
254{
5f939e78 255 wxTreeItemId item = m_treeCtrl->GetSelection();
e1ee62bd 256
5f939e78 257 CHECK_ITEM( item );
e1ee62bd 258
5f939e78 259 m_treeCtrl->SetItemBold(item, bold);
add28c55
VZ
260}
261
ff5bf259
VZ
262void MyFrame::OnDelete(wxCommandEvent& WXUNUSED(event))
263{
5f939e78 264 wxTreeItemId item = m_treeCtrl->GetSelection();
e1ee62bd 265
5f939e78 266 CHECK_ITEM( item );
e1ee62bd 267
5f939e78 268 m_treeCtrl->Delete(item);
ff5bf259
VZ
269}
270
372edb9d
VZ
271void MyFrame::OnDeleteChildren(wxCommandEvent& WXUNUSED(event))
272{
5f939e78 273 wxTreeItemId item = m_treeCtrl->GetSelection();
e1ee62bd 274
5f939e78 275 CHECK_ITEM( item );
e1ee62bd 276
5f939e78 277 m_treeCtrl->DeleteChildren(item);
372edb9d
VZ
278}
279
ff5bf259
VZ
280void MyFrame::OnDeleteAll(wxCommandEvent& WXUNUSED(event))
281{
5f939e78 282 m_treeCtrl->DeleteAllItems();
ff5bf259
VZ
283}
284
285void MyFrame::OnRecreate(wxCommandEvent& event)
286{
5f939e78
VZ
287 OnDeleteAll(event);
288 m_treeCtrl->AddTestItemsToTree(3, 2);
ff5bf259
VZ
289}
290
dd3646fd
VZ
291void MyFrame::OnCollapseAndReset(wxCommandEvent& event)
292{
5f939e78 293 m_treeCtrl->CollapseAndReset(m_treeCtrl->GetRootItem());
dd3646fd
VZ
294}
295
f65635b5
VZ
296void MyFrame::OnEnsureVisible(wxCommandEvent& event)
297{
298 m_treeCtrl->DoEnsureVisible();
299}
300
5f939e78
VZ
301void MyFrame::OnAddItem(wxCommandEvent& WXUNUSED(event))
302{
303 static int s_num = 0;
304
305 wxString text;
306 text.Printf("Item #%d", ++s_num);
307
308 m_treeCtrl->AppendItem(m_treeCtrl->GetRootItem(),
309 text,
310 MyTreeCtrl::TreeCtrlIcon_File);
311}
312
cf724bce
RR
313void MyFrame::OnIncIndent(wxCommandEvent& WXUNUSED(event))
314{
315 unsigned int indent = m_treeCtrl->GetIndent();
316 if (indent < 100)
317 m_treeCtrl->SetIndent( indent+5 );
318}
319
320void MyFrame::OnDecIndent(wxCommandEvent& WXUNUSED(event))
321{
322 unsigned int indent = m_treeCtrl->GetIndent();
323 if (indent > 10)
324 m_treeCtrl->SetIndent( indent-5 );
325}
326
327void MyFrame::OnIncSpacing(wxCommandEvent& WXUNUSED(event))
328{
329 unsigned int indent = m_treeCtrl->GetSpacing();
330 if (indent < 100)
331 m_treeCtrl->SetSpacing( indent+5 );
332}
333
334void MyFrame::OnDecSpacing(wxCommandEvent& WXUNUSED(event))
335{
336 unsigned int indent = m_treeCtrl->GetSpacing();
337 if (indent > 10)
338 m_treeCtrl->SetSpacing( indent-5 );
339}
340
3a5a2f56 341// MyTreeCtrl implementation
23fd5130
VZ
342IMPLEMENT_DYNAMIC_CLASS(MyTreeCtrl, wxTreeCtrl)
343
3a5a2f56
VZ
344MyTreeCtrl::MyTreeCtrl(wxWindow *parent, const wxWindowID id,
345 const wxPoint& pos, const wxSize& size,
346 long style)
347 : wxTreeCtrl(parent, id, pos, size, style)
457814b5 348{
5f939e78 349 m_reverseSort = FALSE;
e1ee62bd 350
5f939e78
VZ
351 // Make an image list containing small icons
352 m_imageListNormal = new wxImageList(16, 16, TRUE);
457814b5 353
5f939e78 354 // should correspond to TreeCtrlIcon_xxx enum
f60d0f94 355#if defined(__WXMSW__) && defined(__WIN16__)
5f939e78
VZ
356 // This is required in 16-bit Windows mode only because we can't load a specific (16x16)
357 // icon image, so it comes out stretched
358 m_imageListNormal->Add(wxBitmap("bitmap1", wxBITMAP_TYPE_BMP_RESOURCE));
359 m_imageListNormal->Add(wxBitmap("bitmap2", wxBITMAP_TYPE_BMP_RESOURCE));
f60d0f94 360#else
5f939e78
VZ
361 m_imageListNormal->Add(wxICON(icon1));
362 m_imageListNormal->Add(wxICON(icon2));
f60d0f94 363#endif
457814b5 364
5f939e78 365 SetImageList(m_imageListNormal);
457814b5 366
5f939e78
VZ
367 // Add some items to the tree
368 AddTestItemsToTree(3, 2);
457814b5
JS
369}
370
3a5a2f56 371MyTreeCtrl::~MyTreeCtrl()
457814b5 372{
5f939e78 373 delete m_imageListNormal;
457814b5
JS
374}
375
e1ee62bd
VZ
376int MyTreeCtrl::OnCompareItems(const wxTreeItemId& item1,
377 const wxTreeItemId& item2)
378{
5f939e78
VZ
379 if ( m_reverseSort )
380 {
381 // just exchange 1st and 2nd items
382 return wxTreeCtrl::OnCompareItems(item2, item1);
383 }
384 else
385 {
386 return wxTreeCtrl::OnCompareItems(item1, item2);
387 }
e1ee62bd
VZ
388}
389
3a5a2f56
VZ
390void MyTreeCtrl::AddItemsRecursively(const wxTreeItemId& idParent,
391 size_t numChildren,
4832f7c0
VZ
392 size_t depth,
393 size_t folder)
457814b5 394{
f65635b5 395 if ( depth > 0 )
3a5a2f56 396 {
f65635b5
VZ
397 wxString str;
398 for ( size_t n = 0; n < numChildren; n++ )
399 {
400 // at depth 1 elements won't have any more children
401 if (depth == 1)
402 str.Printf("%s child %d.%d", "File", folder, n + 1);
403 else
404 str.Printf("%s child %d", "Folder", n + 1);
405
406 int image = depth == 1 ? TreeCtrlIcon_File : TreeCtrlIcon_Folder;
407 wxTreeItemId id = AppendItem(idParent, str, image, image,
408 new MyTreeItemData(str));
409
410 // remember the last child for OnEnsureVisible()
411 if ( depth == 1 && n == numChildren - 1 )
412 {
413 m_lastItem = id;
414 }
415
416 AddItemsRecursively(id, numChildren, depth - 1, n + 1);
417 }
3a5a2f56 418 }
f65635b5 419 //else: done!
457814b5
JS
420}
421
3a5a2f56
VZ
422void MyTreeCtrl::AddTestItemsToTree(size_t numChildren,
423 size_t depth)
457814b5 424{
5f939e78
VZ
425 wxTreeItemId rootId = AddRoot("Root",
426 TreeCtrlIcon_Folder, TreeCtrlIcon_Folder,
427 new MyTreeItemData("Root item"));
457814b5 428
5f939e78 429 AddItemsRecursively(rootId, numChildren, depth, 0);
4832f7c0
VZ
430}
431
432void MyTreeCtrl::GetItemsRecursively(const wxTreeItemId& idParent, long cookie)
433{
5f939e78 434 wxTreeItemId id;
4832f7c0 435
5f939e78
VZ
436 if( cookie == -1 )
437 id = GetFirstChild(idParent, cookie);
438 else
439 id = GetNextChild(idParent, cookie);
4832f7c0 440
5f939e78
VZ
441 if(id <= 0)
442 return;
4832f7c0 443
5f939e78
VZ
444 wxString text=GetItemText(id);
445 wxLogMessage(text);
4832f7c0 446
5f939e78
VZ
447 if (ItemHasChildren(id))
448 GetItemsRecursively(id,-1);
4832f7c0 449
5f939e78 450 GetItemsRecursively(idParent, cookie);
457814b5
JS
451}
452
4832f7c0 453
3a5a2f56 454// avoid repetition
5f939e78
VZ
455#define TREE_EVENT_HANDLER(name) \
456void MyTreeCtrl::name(wxTreeEvent& WXUNUSED(event)) \
457{ \
458 wxLogMessage(#name); \
459}
457814b5 460
3a5a2f56
VZ
461TREE_EVENT_HANDLER(OnBeginDrag)
462TREE_EVENT_HANDLER(OnBeginRDrag)
463TREE_EVENT_HANDLER(OnBeginLabelEdit)
464TREE_EVENT_HANDLER(OnEndLabelEdit)
465TREE_EVENT_HANDLER(OnDeleteItem)
466TREE_EVENT_HANDLER(OnGetInfo)
467TREE_EVENT_HANDLER(OnSetInfo)
468TREE_EVENT_HANDLER(OnItemExpanded)
469TREE_EVENT_HANDLER(OnItemExpanding)
470TREE_EVENT_HANDLER(OnItemCollapsed)
471TREE_EVENT_HANDLER(OnSelChanged)
472TREE_EVENT_HANDLER(OnSelChanging)
473
474#undef TREE_EVENT_HANDLER
475
476void MyTreeCtrl::OnItemCollapsing(wxTreeEvent& event)
457814b5 477{
5f939e78 478 wxLogMessage("OnItemCollapsing");
f135ff73 479
5f939e78
VZ
480 // for testing, prevent the user from collapsing the first child folder
481 wxTreeItemId itemId = event.GetItem();
482 if ( GetParent(itemId) == GetRootItem() && !GetPrevSibling(itemId) )
483 {
484 wxMessageBox("You can't collapse this item.");
457814b5 485
5f939e78
VZ
486 event.Veto();
487 }
457814b5
JS
488}
489
6daa0637 490void MyTreeCtrl::OnTreeKeyDown(wxTreeEvent&WXUNUSED(event))
435fe83e 491{
5f939e78 492 wxLogMessage("OnTreeKeyDown");
435fe83e
RR
493}
494
495void MyTreeCtrl::OnItemActivated(wxTreeEvent&WXUNUSED(event))
457814b5 496{
5f939e78
VZ
497 // show some info about this item
498 wxTreeItemId itemId = GetSelection();
499 MyTreeItemData *item = (MyTreeItemData *)GetItemData(itemId);
457814b5 500
5f939e78
VZ
501 if ( item != NULL )
502 {
503 item->ShowInfo(this);
504 }
457814b5 505
5f939e78
VZ
506 wxLogMessage("OnItemActivated");
507}
508
509void MyTreeCtrl::OnRMouseDClick(wxMouseEvent& event)
510{
511 wxTreeItemId id = HitTest(event.GetPosition());
512 if ( !id )
513 wxLogMessage("No item under mouse");
514 else
515 {
516 MyTreeItemData *item = (MyTreeItemData *)GetItemData(id);
517 if ( item )
518 wxLogMessage("Item '%s' under mouse", item->GetDesc());
519 }
457814b5
JS
520}
521
3a5a2f56 522static inline const char *Bool2String(bool b)
457814b5 523{
5f939e78 524 return b ? "" : "not ";
457814b5
JS
525}
526
9769e589 527void MyTreeItemData::ShowInfo(wxTreeCtrl *tree)
457814b5 528{
5f939e78
VZ
529 wxLogMessage("Item '%s': %sselected, %sexpanded, %sbold,\n"
530 "%u children (%u immediately under this item).",
531 m_desc.c_str(),
532 Bool2String(tree->IsSelected(GetId())),
533 Bool2String(tree->IsExpanded(GetId())),
534 Bool2String(tree->IsBold(GetId())),
535 tree->GetChildrenCount(GetId()),
536 tree->GetChildrenCount(GetId(), FALSE));
457814b5 537}