]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/treectrl/treetest.cpp
after a seek, reset error if error==EOF
[wxWidgets.git] / samples / treectrl / treetest.cpp
index 600751294e58175af0185dc8c6005bbae0c3d47a..6e8dc94fd08ac85b589d7adaddfc4b8e21699794 100644 (file)
@@ -72,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)
@@ -155,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();
@@ -272,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(_T("%d children"), i);
+}
+
+void MyFrame::OnCountRec(wxCommandEvent& WXUNUSED(event))
+{
+    wxTreeItemId item = m_treeCtrl->GetSelection();
+
+    CHECK_ITEM( item );
+
+    int i = m_treeCtrl->GetChildrenCount( item );
+    
+    wxLogMessage(_T("%d children"), i);
+}
+
 void MyFrame::DoSort(bool reverse)
 {
     wxTreeItemId item = m_treeCtrl->GetSelection();