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