]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/treectrl/treetest.cpp
use a slightly less ugly way to conditionally suppress unused parameter warnings
[wxWidgets.git] / samples / treectrl / treetest.cpp
index b3ba5a751ddd5b190476062a2fe1ab88b0a8d341..15069adaca8cba78d05f8f64a917465df8dd675c 100644 (file)
@@ -50,6 +50,9 @@
 #include "state4.xpm"
 #include "state5.xpm"
 
+#include "unchecked.xpm"
+#include "checked.xpm"
+
 #ifndef __WXMSW__
     #include "../sample.xpm"
 #endif
@@ -128,6 +131,9 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
 #endif // wxHAS_LAST_VISIBLE
     MENU_LINK(ShowNextVisible)
     MENU_LINK(ShowPrevVisible)
+    MENU_LINK(ShowParent)
+    MENU_LINK(ShowPrevSibling)
+    MENU_LINK(ShowNextSibling)
 #undef MENU_LINK
 
 END_EVENT_TABLE()
@@ -282,6 +288,10 @@ MyFrame::MyFrame(const wxString& title, int x, int y, int w, int h)
 #endif // wxHAS_LAST_VISIBLE
     item_menu->Append(TreeTest_ShowNextVisible, wxT("Show &next visible"));
     item_menu->Append(TreeTest_ShowPrevVisible, wxT("Show &previous visible"));
+    item_menu->AppendSeparator();
+    item_menu->Append(TreeTest_ShowParent, "Show pa&rent");
+    item_menu->Append(TreeTest_ShowPrevSibling, "Show &previous sibling");
+    item_menu->Append(TreeTest_ShowNextSibling, "Show &next sibling");
 
 #ifndef NO_MULTIPLE_SELECTION
     item_menu->AppendSeparator();
@@ -773,25 +783,27 @@ void MyFrame::DoShowFirstOrLast(TreeFunc0_t pfn, const wxString& label)
                      label, m_treeCtrl->GetItemText(item));
 }
 
-void MyFrame::DoShowNextOrPrev(TreeFunc1_t pfn, const wxString& label)
+void MyFrame::DoShowRelativeItem(TreeFunc1_t pfn, const wxString& label)
 {
     wxTreeItemId item = m_treeCtrl->GetSelection();
 
     CHECK_ITEM( item );
 
-    if ( !m_treeCtrl->IsVisible(item) )
+    if ((pfn == (TreeFunc1_t) &wxTreeCtrl::GetPrevVisible
+         || pfn == (TreeFunc1_t) &wxTreeCtrl::GetNextVisible)
+        && !m_treeCtrl->IsVisible(item))
     {
         wxLogMessage("The selected item must be visible.");
         return;
     }
 
-    item = (m_treeCtrl->*pfn)(item);
+    wxTreeItemId new_item = (m_treeCtrl->*pfn)(item);
 
-    if ( !item.IsOk() )
+    if ( !new_item.IsOk() )
         wxLogMessage("There is no %s item", label);
     else
         wxLogMessage("The %s item is \"%s\"",
-                     label, m_treeCtrl->GetItemText(item));
+                     label, m_treeCtrl->GetItemText(new_item));
 }
 
 void MyFrame::OnSetFgColour(wxCommandEvent& WXUNUSED(event))
@@ -916,40 +928,18 @@ void MyTreeCtrl::CreateStateImageList(bool del)
     }
     else
     {
-#if 0
-        int width  = ::GetSystemMetrics(SM_CXMENUCHECK),
-            height = ::GetSystemMetrics(SM_CYMENUCHECK);
-#else
-        int width = 16;
-        int height = 16;
-#endif
-
-        // make an state checkbox image list
+        wxIcon icons[2];
+        icons[0] = wxIcon(unchecked_xpm);
+        icons[1] = wxIcon(checked_xpm);
+        
+        int width  = icons[0].GetWidth(),
+            height = icons[0].GetHeight();
+            
+        // Make an state image list containing small icons
         states = new wxImageList(width, height, true);
 
-        wxBitmap checkBmp(width, height);
-        wxRect rect (0, 0, width, height);
-
-        wxRendererNative& renderer = wxRendererNative::Get();
-
-        // create no checked image
-        {
-            // first create bitmap in a memory DC
-            wxMemoryDC memDC(checkBmp);
-            memDC.Clear();
-            // then draw a check mark into it
-            renderer.DrawCheckBox(this, memDC, rect, 0);
-        } // select checkBmp out of memDC
-
-        states->Add(checkBmp);
-
-        // create checked image
-        {
-            wxMemoryDC memDC(checkBmp);
-            renderer.DrawCheckBox(this, memDC, rect, wxCONTROL_CHECKED);
-        }
-
-        states->Add(checkBmp);
+        for ( size_t i = 0; i < WXSIZEOF(icons); i++ )
+            states->Add(icons[i]);
     }
 
     AssignStateImageList(states);