]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/treectrl/treetest.cpp
don't crash if an item has a NULL ID
[wxWidgets.git] / samples / treectrl / treetest.cpp
index a6c3435ade908086f264cacfa836dacbee60fe5b..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
@@ -925,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);