From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Tue, 12 Jan 1999 23:49:59 +0000 (+0000)
Subject: images in the notebook work under MSW too (with or without XPM)
X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/73c700fdeef6f2acfb86a0b9c8c7789505feee38?ds=inline

images in the notebook work under MSW too (with or without XPM)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1388 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---

diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp
index a8f5b70ac9..41860f5bb5 100644
--- a/samples/controls/controls.cpp
+++ b/samples/controls/controls.cpp
@@ -29,22 +29,18 @@
 #include "wx/spinbutt.h"
 #include "wx/clipbrd.h"
 
-// XPM doesn't seem to work under Windows at present. Or, wxNotebook images
-// aren't working.
-// Uncomment this line and comment out the next to try it.
-//#if defined(__WXGTK__) || defined(__WXMOTIF__) || (defined(__WXMSW__) && wxUSE_XPM_IN_MSW)
 #if defined(__WXGTK__) || defined(__WXMOTIF__)
-#define USE_XPM
+    #define USE_XPM
 #endif
 
 #ifdef USE_XPM
-#include "mondrian.xpm"
-#include "icons/choice.xpm"
-#include "icons/combo.xpm"
-#include "icons/list.xpm"
-#include "icons/radio.xpm"
-#include "icons/text.xpm"
-#include "icons/gauge.xpm"
+    #include "mondrian.xpm"
+    #include "icons/choice.xpm"
+    #include "icons/combo.xpm"
+    #include "icons/list.xpm"
+    #include "icons/radio.xpm"
+    #include "icons/text.xpm"
+    #include "icons/gauge.xpm"
 #endif
 
 //----------------------------------------------------------------------
@@ -268,7 +264,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
   };
 
 #ifdef USE_XPM
-  // image ids and names
+  // image ids
   enum
   {
     Image_List, Image_Choice, Image_Combo, Image_Text, Image_Radio, Image_Gauge, Image_Max
@@ -283,6 +279,30 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
   imagelist-> Add( wxBitmap( text_xpm ));
   imagelist-> Add( wxBitmap( radio_xpm ));
   imagelist-> Add( wxBitmap( gauge_xpm ));
+  m_notebook->SetImageList(imagelist);
+#elif defined(__WXMSW__)
+  // load images from resources
+  enum
+  {
+    Image_List, Image_Choice, Image_Combo, Image_Text, Image_Radio, Image_Gauge, Image_Max
+  };
+  wxImageList *imagelist = new wxImageList(32, 32, FALSE, Image_Max);
+
+  static const char *s_iconNames[Image_Max] =
+  {
+      "list", "choice", "combo", "text", "radio", "gauge"
+  };
+
+  for ( size_t n = 0; n < Image_Max; n++ )
+  {
+      wxBitmap bmp(s_iconNames[n]);
+      if ( !bmp.Ok() || (imagelist->Add(bmp) == -1) )
+      {
+          wxLogWarning("Couldn't load the image '%s' for the notebook page %d.",
+                       s_iconNames[n], n);
+      }
+  }
+
   m_notebook->SetImageList(imagelist);
 #else
 
diff --git a/samples/controls/controls.rc b/samples/controls/controls.rc
index 1016ec86f5..746abb4618 100644
--- a/samples/controls/controls.rc
+++ b/samples/controls/controls.rc
@@ -1,11 +1,10 @@
 mondrian ICON "mondrian.ico"
 
-/*
-list	ICON "icons/list.ico"
-choice	ICON "icons/choice.ico"
-combo	ICON "icons/combo.ico"
-text	ICON "icons/text.ico"
-radio	ICON "icons/radio.ico"
-*/
+choice	BITMAP "icons/choice.bmp"
+combo	BITMAP "icons/combo.bmp"
+gauge	BITMAP "icons/gauge.bmp"
+list	BITMAP "icons/list.bmp"
+radio	BITMAP "icons/radio.bmp"
+text	BITMAP "icons/text.bmp"
 
 #include "wx/msw/wx.rc"
diff --git a/samples/controls/icons/choice.bmp b/samples/controls/icons/choice.bmp
new file mode 100644
index 0000000000..4ee793ebae
Binary files /dev/null and b/samples/controls/icons/choice.bmp differ
diff --git a/samples/controls/icons/combo.bmp b/samples/controls/icons/combo.bmp
new file mode 100644
index 0000000000..bcad7cd216
Binary files /dev/null and b/samples/controls/icons/combo.bmp differ
diff --git a/samples/controls/icons/gauge.bmp b/samples/controls/icons/gauge.bmp
new file mode 100644
index 0000000000..ff1cdcf872
Binary files /dev/null and b/samples/controls/icons/gauge.bmp differ
diff --git a/samples/controls/icons/list.bmp b/samples/controls/icons/list.bmp
new file mode 100644
index 0000000000..07277af7e6
Binary files /dev/null and b/samples/controls/icons/list.bmp differ
diff --git a/samples/controls/icons/radio.bmp b/samples/controls/icons/radio.bmp
new file mode 100644
index 0000000000..ca0a837dc0
Binary files /dev/null and b/samples/controls/icons/radio.bmp differ
diff --git a/samples/controls/icons/text.bmp b/samples/controls/icons/text.bmp
new file mode 100644
index 0000000000..aedf05e5ca
Binary files /dev/null and b/samples/controls/icons/text.bmp differ