]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/treectrl/treetest.cpp
added missing includes required for CW8 Carbon compilation
[wxWidgets.git] / samples / treectrl / treetest.cpp
index 897c30382dd876fe325609b96c27dbb7a0d66b43..4d60c4be87dcfa7f4da5ec77fb004db66ca8ec7a 100644 (file)
@@ -27,6 +27,7 @@
 #endif
 
 #include "wx/colordlg.h"
 #endif
 
 #include "wx/colordlg.h"
+#include "wx/numdlg.h"
 
 #include "wx/image.h"
 #include "wx/imaglist.h"
 
 #include "wx/image.h"
 #include "wx/imaglist.h"
 #include "icon3.xpm"
 #include "icon4.xpm"
 #include "icon5.xpm"
 #include "icon3.xpm"
 #include "icon4.xpm"
 #include "icon5.xpm"
+
+#if defined(__WXGTK__) || defined(__WXX11__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__)
 #include "mondrian.xpm"
 #include "mondrian.xpm"
+#endif
 
 
 // verify that the item is ok and insult the user if it is not
 
 
 // verify that the item is ok and insult the user if it is not
@@ -61,6 +65,7 @@
 #define MENU_LINK(name) EVT_MENU(TreeTest_##name, MyFrame::On##name)
 
 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
 #define MENU_LINK(name) EVT_MENU(TreeTest_##name, MyFrame::On##name)
 
 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
+    EVT_IDLE(MyFrame::OnIdle)
     EVT_SIZE(MyFrame::OnSize)
 
     MENU_LINK(Quit)
     EVT_SIZE(MyFrame::OnSize)
 
     MENU_LINK(Quit)
@@ -108,6 +113,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
     MENU_LINK(IncSpacing)
     MENU_LINK(DecSpacing)
     MENU_LINK(ToggleIcon)
     MENU_LINK(IncSpacing)
     MENU_LINK(DecSpacing)
     MENU_LINK(ToggleIcon)
+    MENU_LINK(SelectRoot)
 #undef MENU_LINK
 
 END_EVENT_TABLE()
 #undef MENU_LINK
 
 END_EVENT_TABLE()
@@ -209,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_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"));
     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"));
@@ -257,9 +264,10 @@ MyFrame::MyFrame(const wxString& title, int x, int y, int w, int h)
 
     menu_bar->Check(TreeTest_ToggleImages, TRUE);
 
 
     menu_bar->Check(TreeTest_ToggleImages, TRUE);
 
-    // create a status bar with 3 panes
-    CreateStatusBar(3);
-    SetStatusText(wxT(""), 0);
+#if wxUSE_STATUSBAR
+    // create a status bar
+    CreateStatusBar(2);
+#endif // wxUSE_STATUSBAR
 
 #ifdef __WXMOTIF__
     // For some reason, we get a memcpy crash in wxLogStream::DoLogStream
 
 #ifdef __WXMOTIF__
     // For some reason, we get a memcpy crash in wxLogStream::DoLogStream
@@ -324,6 +332,26 @@ void MyFrame::TogStyle(int id, long flag)
     GetMenuBar()->Check(id, (style & flag) != 0);
 }
 
     GetMenuBar()->Check(id, (style & flag) != 0);
 }
 
+void MyFrame::OnIdle(wxIdleEvent& event)
+{
+#if wxUSE_STATUSBAR
+    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();
+}
+
 void MyFrame::OnSize(wxSizeEvent& event)
 {
     if ( m_treeCtrl && m_textCtrl )
 void MyFrame::OnSize(wxSizeEvent& event)
 {
     if ( m_treeCtrl && m_textCtrl )
@@ -440,6 +468,11 @@ void MyFrame::OnSelect(wxCommandEvent& WXUNUSED(event))
     m_treeCtrl->SelectItem(m_treeCtrl->GetSelection());
 }
 
     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();
 void MyFrame::OnUnselect(wxCommandEvent& WXUNUSED(event))
 {
     m_treeCtrl->UnselectAll();