+void MyTreeCtrl::CreateStateImageList(bool del)
+{
+ if ( del )
+ {
+ SetStateImageList(NULL);
+ return;
+ }
+
+ wxImageList *states;
+ wxBusyCursor wait;
+
+ if (m_alternateStates)
+ {
+ wxIcon icons[5];
+ icons[0] = wxIcon(state1_xpm); // yellow
+ icons[1] = wxIcon(state2_xpm); // green
+ icons[2] = wxIcon(state3_xpm); // red
+ icons[3] = wxIcon(state4_xpm); // blue
+ icons[4] = wxIcon(state5_xpm); // black
+
+ int width = icons[0].GetWidth(),
+ height = icons[0].GetHeight();
+
+ // Make an state image list containing small icons
+ states = new wxImageList(width, height, true);
+
+ for ( size_t i = 0; i < WXSIZEOF(icons); i++ )
+ states->Add(icons[i]);
+ }
+ else
+ {
+ wxRendererNative& renderer = wxRendererNative::Get();
+
+ wxSize size(renderer.GetCheckBoxSize(this));
+
+ // make an state checkbox image list
+ states = new wxImageList(size.GetWidth(), size.GetHeight(), true);
+
+ wxBitmap checkBmp(size.GetWidth(), size.GetHeight());
+ wxRect rect(size);
+
+ // 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);
+ memDC.Clear();
+ renderer.DrawCheckBox(this, memDC, rect, wxCONTROL_CHECKED);
+ }
+
+ states->Add(checkBmp);
+ }
+
+ AssignStateImageList(states);
+}
+