]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/treectrl/treetest.cpp
Linux/AXP compilation fixed.
[wxWidgets.git] / samples / treectrl / treetest.cpp
index 873b8810839634dff1b21219f078df367c74699a..29098cf083911ec2eec682f4f163cc9bf28852bd 100644 (file)
 #include "math.h"
 
 #ifdef __WXMSW__
+    // comment out this line to test multiple selection even under MSW (where
+    // it looks ugly - but works)
     #define NO_MULTIPLE_SELECTION
-    #define NO_VARIABLE_HEIGHT
 #endif
 
+#define NO_VARIABLE_HEIGHT
+
 #include "treetest.h"
 
 // under Windows the icons are in the .rc file
@@ -46,6 +49,7 @@
   #include "icon2.xpm"
   #include "icon3.xpm"
   #include "icon4.xpm"
+  #include "icon5.xpm"
   #include "mondrian.xpm"
 #endif
 
@@ -68,6 +72,8 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
     EVT_MENU(TreeTest_Unselect, MyFrame::OnUnselect)
 #endif // NO_MULTIPLE_SELECTION
     EVT_MENU(TreeTest_Rename, MyFrame::OnRename)
+    EVT_MENU(TreeTest_Count, MyFrame::OnCount)
+    EVT_MENU(TreeTest_CountRec, MyFrame::OnCountRec)
     EVT_MENU(TreeTest_Sort, MyFrame::OnSort)
     EVT_MENU(TreeTest_SortRev, MyFrame::OnSortRev)
     EVT_MENU(TreeTest_Bold, MyFrame::OnSetBold)
@@ -151,6 +157,9 @@ MyFrame::MyFrame(const wxString& title, int x, int y, int w, int h)
     tree_menu->Append(TreeTest_DeleteChildren, "Delete &children");
     tree_menu->Append(TreeTest_DeleteAll, "Delete &all items");
     tree_menu->AppendSeparator();
+    tree_menu->Append(TreeTest_Count, "Count children of current item");
+    tree_menu->Append(TreeTest_CountRec, "Recursively count children of current item");
+    tree_menu->AppendSeparator();
     tree_menu->Append(TreeTest_Sort, "Sort children of current item");
     tree_menu->Append(TreeTest_SortRev, "Sort in reversed order");
     tree_menu->AppendSeparator();
@@ -268,6 +277,28 @@ void MyFrame::OnRename(wxCommandEvent& WXUNUSED(event))
     (void)m_treeCtrl->EditLabel(item);
 }
 
+void MyFrame::OnCount(wxCommandEvent& WXUNUSED(event))
+{
+    wxTreeItemId item = m_treeCtrl->GetSelection();
+
+    CHECK_ITEM( item );
+
+    int i = m_treeCtrl->GetChildrenCount( item, FALSE );
+    
+    wxLogMessage(wxT("%d children"), i);
+}
+
+void MyFrame::OnCountRec(wxCommandEvent& WXUNUSED(event))
+{
+    wxTreeItemId item = m_treeCtrl->GetSelection();
+
+    CHECK_ITEM( item );
+
+    int i = m_treeCtrl->GetChildrenCount( item );
+    
+    wxLogMessage(wxT("%d children"), i);
+}
+
 void MyFrame::DoSort(bool reverse)
 {
     wxTreeItemId item = m_treeCtrl->GetSelection();
@@ -293,7 +324,7 @@ void MyFrame::OnDumpSelected(wxCommandEvent& WXUNUSED(event))
     wxArrayTreeItemIds array;
 
     size_t count = m_treeCtrl->GetSelections(array);
-    wxLogMessage(_T("%u items selected"), count);
+    wxLogMessage(wxT("%u items selected"), count);
 
     for ( size_t n = 0; n < count; n++ )
     {