]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/controls/controls.cpp
wxString::Right() changed to AfterLast() (config works again)
[wxWidgets.git] / samples / controls / controls.cpp
index d8a9805a4f3a12e7a4ab1645475b8ab355b813dc..4e2621c15c0c2c5c7455f02908cec03b231d0ded 100644 (file)
 #include "wx/spinbutt.h"
 #include "wx/clipbrd.h"
 
 #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__)
 #if defined(__WXGTK__) || defined(__WXMOTIF__)
-#define USE_XPM
+    #define USE_XPM
 #endif
 
 #ifdef 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
 
 //----------------------------------------------------------------------
 #endif
 
 //----------------------------------------------------------------------
@@ -268,7 +264,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
   };
 
 #ifdef USE_XPM
   };
 
 #ifdef USE_XPM
-  // image ids and names
+  // image ids
   enum
   {
     Image_List, Image_Choice, Image_Combo, Image_Text, Image_Radio, Image_Gauge, Image_Max
   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 ));
   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
 
   m_notebook->SetImageList(imagelist);
 #else
 
@@ -369,9 +389,9 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
   panel = new wxPanel(m_notebook);
   panel->SetBackgroundColour("cadet blue");
   panel->SetForegroundColour("blue");
   panel = new wxPanel(m_notebook);
   panel->SetBackgroundColour("cadet blue");
   panel->SetForegroundColour("blue");
-  m_radio = new wxRadioBox( panel, ID_RADIOBOX, "That", wxPoint(10,160), wxSize(-1,-1), 2, choices2, 1, wxRA_VERTICAL );
+  m_radio = new wxRadioBox( panel, ID_RADIOBOX, "That", wxPoint(10,160), wxSize(-1,-1), 2, choices2, 1, wxRA_SPECIFY_ROWS );
   m_radio->SetBackgroundColour("wheat");
   m_radio->SetBackgroundColour("wheat");
-  m_radio = new wxRadioBox( panel, ID_RADIOBOX, "This", wxPoint(10,10), wxSize(-1,-1), 5, choices, 1, wxRA_HORIZONTAL );
+  m_radio = new wxRadioBox( panel, ID_RADIOBOX, "This", wxPoint(10,10), wxSize(-1,-1), 5, choices, 1, wxRA_SPECIFY_COLS );
   m_radio->SetBackgroundColour("wheat");
   (void)new wxButton( panel, ID_RADIOBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
   (void)new wxButton( panel, ID_RADIOBOX_SEL_STR, "Select 'This'", wxPoint(180,80), wxSize(140,30) );
   m_radio->SetBackgroundColour("wheat");
   (void)new wxButton( panel, ID_RADIOBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
   (void)new wxButton( panel, ID_RADIOBOX_SEL_STR, "Select 'This'", wxPoint(180,80), wxSize(140,30) );
@@ -400,7 +420,11 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
     "\n"
     "This is also supposed to demonstrate how\n"
     "to use static controls.\n",
     "\n"
     "This is also supposed to demonstrate how\n"
     "to use static controls.\n",
-    wxPoint(208,25), wxSize(200, 100) );
+    wxPoint(208,25)
+#ifdef __WXMSW__ 
+    ,wxSize(210, 110)
+#endif
+    );
   m_spintext = new wxTextCtrl( panel, -1, "0", wxPoint(20,160), wxSize(80,-1) );
   m_spintext->SetBackgroundColour("wheat");
   m_spinbutton = new wxSpinButton( panel, ID_SPIN, wxPoint(103,159), wxSize(-1,-1) );
   m_spintext = new wxTextCtrl( panel, -1, "0", wxPoint(20,160), wxSize(80,-1) );
   m_spintext->SetBackgroundColour("wheat");
   m_spinbutton = new wxSpinButton( panel, ID_SPIN, wxPoint(103,159), wxSize(-1,-1) );
@@ -414,13 +438,6 @@ void MyPanel::OnPasteFromClipboard( wxCommandEvent &WXUNUSED(event) )
 {
 #ifdef __WXGTK__
 
 {
 #ifdef __WXGTK__
 
-  if (!wxTheClipboard->IsSupportedFormat( wxDF_TEXT ))
-  {
-     *m_text << "The clipboard doesn't contain any data in the requested format." << "\n";
-
-     return;
-  }
-
   if (!wxTheClipboard->Open())
   {
      *m_text << "Error opening the clipboard." << "\n";
   if (!wxTheClipboard->Open())
   {
      *m_text << "Error opening the clipboard." << "\n";
@@ -461,8 +478,6 @@ void MyPanel::OnCopyToClipboard( wxCommandEvent &WXUNUSED(event) )
 
   if (text.IsEmpty()) return;
 
 
   if (text.IsEmpty()) return;
 
-  wxTextDataObject *data = new wxTextDataObject( text );
-
   if (!wxTheClipboard->Open())
   {
      *m_text << "Error opening the clipboard." << "\n";
   if (!wxTheClipboard->Open())
   {
      *m_text << "Error opening the clipboard." << "\n";
@@ -474,7 +489,11 @@ void MyPanel::OnCopyToClipboard( wxCommandEvent &WXUNUSED(event) )
      *m_text << "Successfully opened the clipboard." << "\n";
   }
 
      *m_text << "Successfully opened the clipboard." << "\n";
   }
 
-  if (!wxTheClipboard->SetData( data ))
+  wxTextDataObject *data = new wxTextDataObject( text );
+  wxDataBroker *broker = new wxDataBroker();
+  broker->Add( data );
+
+  if (!wxTheClipboard->SetData( broker ))
   {
      *m_text << "Error while copying to the clipboard." << "\n";
   }
   {
      *m_text << "Error while copying to the clipboard." << "\n";
   }