#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
#include "icon2.xpm"
#include "icon3.xpm"
#include "icon4.xpm"
+ #include "icon5.xpm"
#include "mondrian.xpm"
#endif
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)
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();
(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();
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++ )
{