X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a67c56641d3a1a22764570f9d487ba916e4ade3c..f20a2e1f4066e4f0235698e6220f1eed91c73326:/samples/treectrl/treetest.cpp diff --git a/samples/treectrl/treetest.cpp b/samples/treectrl/treetest.cpp index 60f030ae13..4d60c4be87 100644 --- a/samples/treectrl/treetest.cpp +++ b/samples/treectrl/treetest.cpp @@ -27,6 +27,7 @@ #endif #include "wx/colordlg.h" +#include "wx/numdlg.h" #include "wx/image.h" #include "wx/imaglist.h" @@ -46,7 +47,10 @@ #include "icon3.xpm" #include "icon4.xpm" #include "icon5.xpm" + +#if defined(__WXGTK__) || defined(__WXX11__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) #include "mondrian.xpm" +#endif // verify that the item is ok and insult the user if it is not @@ -109,6 +113,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) MENU_LINK(IncSpacing) MENU_LINK(DecSpacing) MENU_LINK(ToggleIcon) + MENU_LINK(SelectRoot) #undef MENU_LINK END_EVENT_TABLE() @@ -210,6 +215,7 @@ MyFrame::MyFrame(const wxString& title, int x, int y, int w, int h) tree_menu->Append(TreeTest_Delete, wxT("&Delete this item")); tree_menu->Append(TreeTest_DeleteChildren, wxT("Delete &children")); tree_menu->Append(TreeTest_DeleteAll, wxT("Delete &all items")); + tree_menu->Append(TreeTest_SelectRoot, wxT("Select root item")); tree_menu->AppendSeparator(); tree_menu->Append(TreeTest_Count, wxT("Count children of current item")); tree_menu->Append(TreeTest_CountRec, wxT("Recursively count children of current item")); @@ -329,15 +335,18 @@ void MyFrame::TogStyle(int id, long flag) void MyFrame::OnIdle(wxIdleEvent& event) { #if wxUSE_STATUSBAR - wxTreeItemId idRoot = m_treeCtrl->GetRootItem(); - - SetStatusText(wxString::Format - ( - _T("Root/last item is %svisible/%svisible"), - m_treeCtrl->IsVisible(idRoot) ? _T("") : _T("not "), - m_treeCtrl->IsVisible(m_treeCtrl->GetLastChild(idRoot)) - ? _T("") : _T("not ") - ), 1); + if ( m_treeCtrl ) + { + wxTreeItemId idRoot = m_treeCtrl->GetRootItem(); + + SetStatusText(wxString::Format + ( + _T("Root/last item is %svisible/%svisible"), + m_treeCtrl->IsVisible(idRoot) ? _T("") : _T("not "), + m_treeCtrl->IsVisible(m_treeCtrl->GetLastChild(idRoot)) + ? _T("") : _T("not ") + ), 1); + } #endif // wxUSE_STATUSBAR event.Skip(); @@ -459,6 +468,11 @@ void MyFrame::OnSelect(wxCommandEvent& WXUNUSED(event)) m_treeCtrl->SelectItem(m_treeCtrl->GetSelection()); } +void MyFrame::OnSelectRoot(wxCommandEvent& WXUNUSED(event)) +{ + m_treeCtrl->SelectItem(m_treeCtrl->GetRootItem()); +} + void MyFrame::OnUnselect(wxCommandEvent& WXUNUSED(event)) { m_treeCtrl->UnselectAll();