]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/controls/controls.cpp
Put a backslash before a '_'
[wxWidgets.git] / samples / controls / controls.cpp
index d42475368c08ebc7c8df21b6b1e34df1761e70ff..066ed1b2ccb8e41ecb58d4c5313fa6168b79d237 100644 (file)
@@ -34,7 +34,7 @@
     #include "wx/tooltip.h"
 #endif
 
-#if defined(__WXGTK__) || defined(__WXMOTIF__)
+#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__)
     #define USE_XPM
 #endif
 
@@ -86,8 +86,10 @@ public:
     void OnListBox( wxCommandEvent &event );
     void OnListBoxDoubleClick( wxCommandEvent &event );
     void OnListBoxButtons( wxCommandEvent &event );
+#if wxUSE_CHOICE
     void OnChoice( wxCommandEvent &event );
     void OnChoiceButtons( wxCommandEvent &event );
+#endif
     void OnCombo( wxCommandEvent &event );
     void OnComboTextChanged( wxCommandEvent &event );
     void OnComboTextEnter( wxCommandEvent &event );
@@ -118,8 +120,10 @@ public:
 
     wxListBox     *m_listbox,
                   *m_listboxSorted;
+#if wxUSE_CHOICE
     wxChoice      *m_choice,
                   *m_choiceSorted;
+#endif
     wxComboBox    *m_combo;
     wxRadioBox    *m_radio;
     wxGauge       *m_gauge,
@@ -284,7 +288,7 @@ private:
 // other
 //----------------------------------------------------------------------
 
-static void SetControlClientData(const char *name,
+static void SetControlClientData(const wxChar *name,
                                  wxControlWithItems *control);
 
 IMPLEMENT_APP(MyApp)
@@ -315,8 +319,8 @@ bool MyApp::OnInit()
         y = 50;
     if ( argc == 3 )
     {
-        wxSscanf(argv[1], "%d", &x);
-        wxSscanf(argv[2], "%d", &y);
+        //wxSscanf(argv[1], "%d", &x);
+        //wxSscanf(argv[2], "%d", &y);
     }
 
     // Create the main frame window
@@ -443,6 +447,7 @@ EVT_BUTTON    (ID_LISTBOX_APPEND,       MyPanel::OnListBoxButtons)
 EVT_BUTTON    (ID_LISTBOX_DELETE,       MyPanel::OnListBoxButtons)
 EVT_BUTTON    (ID_LISTBOX_FONT,         MyPanel::OnListBoxButtons)
 EVT_CHECKBOX  (ID_LISTBOX_ENABLE,       MyPanel::OnListBoxButtons)
+#if wxUSE_CHOICE
 EVT_CHOICE    (ID_CHOICE,               MyPanel::OnChoice)
 EVT_CHOICE    (ID_CHOICE_SORTED,        MyPanel::OnChoice)
 EVT_BUTTON    (ID_CHOICE_SEL_NUM,       MyPanel::OnChoiceButtons)
@@ -452,6 +457,7 @@ EVT_BUTTON    (ID_CHOICE_APPEND,        MyPanel::OnChoiceButtons)
 EVT_BUTTON    (ID_CHOICE_DELETE,        MyPanel::OnChoiceButtons)
 EVT_BUTTON    (ID_CHOICE_FONT,          MyPanel::OnChoiceButtons)
 EVT_CHECKBOX  (ID_CHOICE_ENABLE,        MyPanel::OnChoiceButtons)
+#endif
 EVT_COMBOBOX  (ID_COMBO,                MyPanel::OnCombo)
 EVT_TEXT      (ID_COMBO,                MyPanel::OnComboTextChanged)
 EVT_TEXT_ENTER(ID_COMBO,                MyPanel::OnComboTextEnter)
@@ -569,7 +575,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
         wxBitmap bmp(s_iconNames[n]);
         if ( !bmp.Ok() || (imagelist->Add(bmp) == -1) )
         {
-            wxLogWarning("Couldn't load the image '%s' for the notebook page %d.",
+            wxLogWarning(wxT("Couldn't load the image '%s' for the notebook page %d."),
                     s_iconNames[n], n);
         }
     }
@@ -596,8 +602,8 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
                                      wxPoint(10,90), wxSize(120,70),
                                      5, choices, wxLB_SORT );
 
-    SetControlClientData("listbox", m_listbox);
-    SetControlClientData("listbox", m_listboxSorted);
+    SetControlClientData(wxT("listbox"), m_listbox);
+    SetControlClientData(wxT("listbox"), m_listboxSorted);
 
     m_listbox->SetCursor(*wxCROSS_CURSOR);
 #if wxUSE_TOOLTIPS
@@ -629,13 +635,14 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
     panel->SetCursor(wxCursor(wxCURSOR_HAND));
     m_notebook->AddPage(panel, "wxListBox", TRUE, Image_List);
 
+#if wxUSE_CHOICE
     panel = new wxPanel(m_notebook);
     m_choice = new wxChoice( panel, ID_CHOICE, wxPoint(10,10), wxSize(120,-1), 5, choices );
     m_choiceSorted = new wxChoice( panel, ID_CHOICE_SORTED, wxPoint(10,70), wxSize(120,-1),
                                    5, choices, wxCB_SORT );
 
-    SetControlClientData("choice", m_choice);
-    SetControlClientData("choice", m_choiceSorted);
+    SetControlClientData(wxT("choice"), m_choice);
+    SetControlClientData(wxT("choice"), m_choiceSorted);
 
     m_choice->SetSelection(2);
     m_choice->SetBackgroundColour( "red" );
@@ -648,6 +655,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
     (void)new wxCheckBox( panel, ID_CHOICE_ENABLE, "&Disable", wxPoint(20,130), wxSize(140,30) );
 
     m_notebook->AddPage(panel, "wxChoice", FALSE, Image_Choice);
+#endif // wxUSE_CHOICE
 
     panel = new wxPanel(m_notebook);
     (void)new wxStaticBox( panel, -1, "&Box around combobox",
@@ -747,7 +755,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
 
     panel = new wxPanel(m_notebook);
 
-#if !defined(__WXMOTIF__) && !defined(__WXMAC__) && !defined(__WIN16__)  // wxStaticBitmap not working under Motif yet; and icons not allowed under WIN16.
+#if !defined(__WXMOTIF__) && !defined(__WIN16__)  // wxStaticBitmap not working under Motif yet; and icons not allowed under WIN16.
     wxIcon icon = wxTheApp->GetStdIcon(wxICON_INFORMATION);
     wxStaticBitmap *bmpStatic = new wxStaticBitmap(panel, -1, icon,
                                                    wxPoint(10, 10));
@@ -787,6 +795,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
                                   bmp1,
                                   wxPoint(30, 70)
                                  );
+
     bmpBtn->SetBitmapSelected(bmp2);
     bmpBtn->SetBitmapFocus(bmp3);
 
@@ -794,6 +803,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
     (void)new wxToggleButton(panel, ID_BUTTON_LABEL,
                              "&Toggle label", wxPoint(250, 20));
 #endif // wxUSE_TOGGLEBTN
+
     m_label = new wxStaticText(panel, -1, "Label with some long text",
                                wxPoint(250, 60), wxDefaultSize,
                                wxALIGN_RIGHT /*| wxST_NO_AUTORESIZE*/);
@@ -869,12 +879,16 @@ void MyPanel::OnPageChanging( wxNotebookEvent &event )
         }
     }
 
-    *m_text << "Notebook selection is being changed from " << selOld << "\n";
+    *m_text << "Notebook selection is being changed from " << selOld
+            << " to " << event.GetSelection()
+            << " (current page from notebook is "
+            << m_notebook->GetSelection() << ")\n";
 }
 
 void MyPanel::OnPageChanged( wxNotebookEvent &event )
 {
-    *m_text << "Notebook selection is " << event.GetSelection() << "\n";
+    *m_text << "Notebook selection is now " << event.GetSelection()
+            << " (from notebook: " << m_notebook->GetSelection() << ")\n";
 }
 
 void MyPanel::OnTestButton(wxCommandEvent& event)
@@ -1026,6 +1040,7 @@ void MyPanel::OnListBoxButtons( wxCommandEvent &event )
     }
 }
 
+#if wxUSE_CHOICE
 void MyPanel::OnChoice( wxCommandEvent &event )
 {
     wxChoice *choice = event.GetId() == ID_CHOICE ? m_choice
@@ -1109,6 +1124,7 @@ void MyPanel::OnChoiceButtons( wxCommandEvent &event )
             }
     }
 }
+#endif // wxUSE_CHOICE
 
 void MyPanel::OnCombo( wxCommandEvent &event )
 {
@@ -1499,14 +1515,14 @@ void MyComboBox::OnKeyUp(wxKeyEvent& event)
     event.Skip();
 }
 
-static void SetControlClientData(const char *name,
+static void SetControlClientData(const wxChar *name,
                                  wxControlWithItems *control)
 {
     size_t count = control->GetCount();
     for ( size_t n = 0; n < count; n++ )
     {
         wxString s;
-        s.Printf("%s client data for '%s'",
+        s.Printf(wxT("%s client data for '%s'"),
                  name, control->GetString(n).c_str());
 
         control->SetClientObject(n, new wxStringClientData(s));