]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/controls/controls.cpp
wxUSE_GUI=0 not needed anymore
[wxWidgets.git] / samples / controls / controls.cpp
index 0b8561cef52f2877aed51f5f4aaa81f387df9ca1..d2f3693dfd0e360d923a1fd65e0fc3f07df7f530 100644 (file)
@@ -97,6 +97,8 @@ public:
     void OnComboButtons( wxCommandEvent &event );
     void OnRadio( wxCommandEvent &event );
     void OnRadioButtons( wxCommandEvent &event );
+    void OnRadioButton1( wxCommandEvent &event );
+    void OnRadioButton2( wxCommandEvent &event );
     void OnSetFont( wxCommandEvent &event );
     void OnPageChanged( wxNotebookEvent &event );
     void OnPageChanging( wxNotebookEvent &event );
@@ -464,6 +466,8 @@ EVT_BUTTON    (ID_RADIOBOX_SEL_NUM,     MyPanel::OnRadioButtons)
 EVT_BUTTON    (ID_RADIOBOX_SEL_STR,     MyPanel::OnRadioButtons)
 EVT_BUTTON    (ID_RADIOBOX_FONT,        MyPanel::OnRadioButtons)
 EVT_CHECKBOX  (ID_RADIOBOX_ENABLE,      MyPanel::OnRadioButtons)
+EVT_RADIOBUTTON(ID_RADIOBUTTON_1,       MyPanel::OnRadioButton1)
+EVT_RADIOBUTTON(ID_RADIOBUTTON_2,       MyPanel::OnRadioButton2)
 EVT_BUTTON    (ID_SET_FONT,             MyPanel::OnSetFont)
 EVT_SLIDER    (ID_SLIDER,               MyPanel::OnSliderUpdate)
 #if wxUSE_SPINBTN
@@ -481,6 +485,8 @@ EVT_TEXT      (ID_SPINCTRL,             MyPanel::OnSpinCtrlText)
 #endif // wxUSE_SPINCTRL
 #if wxUSE_TOGGLEBTN
 EVT_TOGGLEBUTTON(ID_BUTTON_LABEL,       MyPanel::OnUpdateLabel)
+#else
+EVT_CHECKBOX(ID_BUTTON_LABEL,       MyPanel::OnUpdateLabel)
 #endif // wxUSE_TOGGLEBTN
 EVT_CHECKBOX  (ID_CHANGE_COLOUR,        MyPanel::OnChangeColour)
 EVT_BUTTON    (ID_BUTTON_TEST1,         MyPanel::OnTestButton)
@@ -551,8 +557,6 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
                             wxPoint(0, 250), wxSize(100, 50), wxTE_MULTILINE);
     m_text->SetBackgroundColour(wxT("wheat"));
 
-    if ( 0 )
-        wxLog::AddTraceMask(_T("focus"));
     m_logTargetOld = wxLog::SetActiveTarget(new wxLogTextCtrl(m_text));
 
     m_notebook = new wxNotebook(this, ID_NOTEBOOK);
@@ -574,9 +578,11 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
     };
 
     // fill the image list
-    wxImageList *imagelist = new wxImageList(32, 32);
+    wxBitmap bmp(list_xpm);
+
+    wxImageList *imagelist = new wxImageList(bmp.GetWidth(), bmp.GetHeight());
 
-    imagelist-> Add( wxBitmap( list_xpm ));
+    imagelist-> Add( bmp );
     imagelist-> Add( wxBitmap( choice_xpm ));
     imagelist-> Add( wxBitmap( combo_xpm ));
     imagelist-> Add( wxBitmap( text_xpm ));
@@ -810,7 +816,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
 
     (void)new wxBitmapButton(panel, ID_BITMAP_BTN, bitmap, wxPoint(100, 20));
 
-#ifdef __WXMSW__
+#if defined(__WXMSW__) || defined(__WXMOTIF__)
     // test for masked bitmap display
     bitmap = wxBitmap(_T("test2.bmp"), wxBITMAP_TYPE_BMP);
     if (bitmap.Ok())
@@ -837,6 +843,9 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
 #if wxUSE_TOGGLEBTN
     (void)new wxToggleButton(panel, ID_BUTTON_LABEL,
                              _T("&Toggle label"), wxPoint(250, 20));
+#else
+    (void)new wxCheckBox(panel, ID_BUTTON_LABEL,
+                         _T("&Toggle label"), wxPoint(250, 20));
 #endif // wxUSE_TOGGLEBTN
 
     m_label = new wxStaticText(panel, -1, _T("Label with some long text"),
@@ -978,7 +987,7 @@ void MyPanel::OnTestButton(wxCommandEvent& event)
                  event.GetId() == ID_BUTTON_TEST1 ? _T('1') : _T('2'));
 }
 
-void MyPanel::OnBmpButton(wxCommandEvent& event)
+void MyPanel::OnBmpButton(wxCommandEvent& WXUNUSED(event))
 {
     wxLogMessage(_T("Bitmap button clicked."));
 }
@@ -1076,15 +1085,19 @@ void MyPanel::OnListBoxButtons( wxCommandEvent &event )
             }
         case ID_LISTBOX_SEL_NUM:
             {
-                m_listbox->SetSelection( 2 );
-                m_listboxSorted->SetSelection( 2 );
+                if (m_listbox->GetCount() > 2)
+                    m_listbox->SetSelection( 2 );
+                if (m_listboxSorted->GetCount() > 2)
+                    m_listboxSorted->SetSelection( 2 );
                 m_lbSelectThis->WarpPointer( 40, 14 );
                 break;
             }
         case ID_LISTBOX_SEL_STR:
             {
-                m_listbox->SetStringSelection( _T("This") );
-                m_listboxSorted->SetStringSelection( _T("This") );
+                if (m_listbox->FindString(_T("This")) > -1)
+                    m_listbox->SetStringSelection( _T("This") );
+                if (m_listboxSorted->FindString(_T("This")) > -1)
+                    m_listboxSorted->SetStringSelection( _T("This") );
                 m_lbSelectNum->WarpPointer( 40, 14 );
                 break;
             }
@@ -1281,6 +1294,16 @@ void MyPanel::OnRadio( wxCommandEvent &event )
     m_text->AppendText( _T("\n") );
 }
 
+void MyPanel::OnRadioButton1( wxCommandEvent & WXUNUSED(event) )
+{
+    wxMessageBox(_T("First wxRadioButton selected."), _T("wxControl sample"));
+}
+
+void MyPanel::OnRadioButton2( wxCommandEvent & WXUNUSED(event) )
+{
+    m_text->AppendText(_T("Second wxRadioButton selected.\n"));
+}
+
 void MyPanel::OnRadioButtons( wxCommandEvent &event )
 {
     switch (event.GetId())
@@ -1600,7 +1623,7 @@ void MyFrame::OnClearLog(wxCommandEvent& WXUNUSED(event))
 }
 
 #if wxUSE_TOOLTIPS
-void MyFrame::OnSetTooltipDelay(wxCommandEvent& event)
+void MyFrame::OnSetTooltipDelay(wxCommandEvent& WXUNUSED(event))
 {
     static long s_delay = 5000;
 
@@ -1621,7 +1644,7 @@ void MyFrame::OnSetTooltipDelay(wxCommandEvent& event)
     wxLogStatus(this, _T("Tooltip delay set to %ld milliseconds"), s_delay);
 }
 
-void MyFrame::OnToggleTooltips(wxCommandEvent& event)
+void MyFrame::OnToggleTooltips(wxCommandEvent& WXUNUSED(event))
 {
     static bool s_enabled = TRUE;
 
@@ -1685,7 +1708,7 @@ void MyComboBox::OnChar(wxKeyEvent& event)
 {
     wxLogMessage(_T("MyComboBox::OnChar"));
 
-    if ( event.KeyCode() == 'w' )
+    if ( event.GetKeyCode() == 'w' )
         wxLogMessage(_T("MyComboBox: 'w' will be ignored."));
     else
         event.Skip();
@@ -1695,7 +1718,7 @@ void MyComboBox::OnKeyDown(wxKeyEvent& event)
 {
     wxLogMessage(_T("MyComboBox::OnKeyDown"));
 
-    if ( event.KeyCode() == 'w' )
+    if ( event.GetKeyCode() == 'w' )
         wxLogMessage(_T("MyComboBox: 'w' will be ignored."));
     else
         event.Skip();