]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/treectrl/treetest.cpp
reSWIGged
[wxWidgets.git] / samples / treectrl / treetest.cpp
index 60f030ae13903ea5d5700a9e4da9cbf736c108b9..4d60c4be87dcfa7f4da5ec77fb004db66ca8ec7a 100644 (file)
@@ -27,6 +27,7 @@
 #endif
 
 #include "wx/colordlg.h"
+#include "wx/numdlg.h"
 
 #include "wx/image.h"
 #include "wx/imaglist.h"
 #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();