X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/91b073576e8fd216c71acacf5c1495e1a56dd39f..740af654d1d20aaccad331e0eb73d113b5c0b02f:/samples/controls/controls.cpp diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index 0cd2b4f593..57daa3fd06 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -19,9 +19,7 @@ #include "wx/wx.h" #endif -#if !defined( __WXMSW__ ) || defined( __WIN95__ ) #include "wx/spinbutt.h" -#endif #include "wx/tglbtn.h" #include "wx/bookctrl.h" #include "wx/imaglist.h" @@ -77,6 +75,7 @@ public: virtual ~MyPanel(); void OnSize( wxSizeEvent& event ); + void OnIdle( wxIdleEvent &event ); void OnListBox( wxCommandEvent &event ); void OnListBoxDoubleClick( wxCommandEvent &event ); void OnListBoxButtons( wxCommandEvent &event ); @@ -326,7 +325,7 @@ public: long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxChoiceNameStr ) - : wxChoice(parent, id, pos, size, n, choices, + : wxChoice(parent, id, pos, size, n, choices, style, validator, name) { } protected: @@ -481,6 +480,7 @@ const int ID_SIZER_CHECKBIG = 206; BEGIN_EVENT_TABLE(MyPanel, wxPanel) EVT_SIZE ( MyPanel::OnSize) +EVT_IDLE ( MyPanel::OnIdle) EVT_BOOKCTRL_PAGE_CHANGING(ID_BOOK, MyPanel::OnPageChanging) EVT_BOOKCTRL_PAGE_CHANGED(ID_BOOK, MyPanel::OnPageChanged) EVT_LISTBOX (ID_LISTBOX, MyPanel::OnListBox) @@ -831,10 +831,10 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) #if wxUSE_SLIDER && wxUSE_GAUGE panel = new wxPanel(m_book); - + wxBoxSizer *main_sizer = new wxBoxSizer( wxHORIZONTAL ); panel->SetSizer( main_sizer ); - + wxStaticBoxSizer *gauge_sizer = new wxStaticBoxSizer( wxHORIZONTAL, panel, _T("&wxGauge and wxSlider") ); main_sizer->Add( gauge_sizer, 0, wxALL, 5 ); wxBoxSizer *sz = new wxBoxSizer( wxVERTICAL ); @@ -851,7 +851,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) m_slider->SetToolTip(_T("This is a sliding slider")); #endif // wxUSE_TOOLTIPS sz->Add( m_slider, 0, wxALL, 10 ); - + m_gaugeVert = new wxGauge( panel, wxID_ANY, 100, wxDefaultPosition, wxSize(wxDefaultCoord, 90), wxGA_VERTICAL | wxGA_SMOOTH | wxNO_BORDER ); @@ -880,7 +880,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) _T("This is also supposed to demonstrate how ") _T("to use static controls with line wrapping."), wxDefaultPosition, - wxSize(240, -1) + wxSize(240, wxDefaultCoord) ); #endif wrapping_sizer->Add( m_wrappingText ); @@ -913,7 +913,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) #endif // wxUSE_SPINBTN #if wxUSE_SPINCTRL - m_spinctrl = new wxSpinCtrl( panel, ID_SPINCTRL, _T(""), wxPoint(200, 160), wxSize(80, wxDefaultCoord) ); + m_spinctrl = new wxSpinCtrl( panel, ID_SPINCTRL, wxEmptyString, wxPoint(200, 160), wxSize(80, wxDefaultCoord) ); m_spinctrl->SetRange(10,30); m_spinctrl->SetValue(15); #endif // wxUSE_SPINCTRL @@ -1049,6 +1049,39 @@ void MyPanel::OnSize( wxSizeEvent& WXUNUSED(event) ) if (m_text) m_text->SetSize( 2, y*2/3+2, x-4, y/3-4 ); } +void MyPanel::OnIdle(wxIdleEvent& event) +{ + static const int INVALID_SELECTION = -2; + + static int s_selCombo = INVALID_SELECTION; + int sel = m_combo->GetSelection(); + if ( sel != s_selCombo ) + { + if ( s_selCombo != INVALID_SELECTION ) + { + wxLogMessage(_T("EVT_IDLE: combobox selection changed from %d to %d"), + s_selCombo, sel); + } + + s_selCombo = sel; + } + + static int s_selChoice = INVALID_SELECTION; + sel = m_choice->GetSelection(); + if ( sel != s_selChoice ) + { + if ( s_selChoice != INVALID_SELECTION ) + { + wxLogMessage(_T("EVT_IDLE: choice selection changed from %d to %d"), + s_selChoice, sel); + } + + s_selChoice = sel; + } + + event.Skip(); +} + void MyPanel::OnPageChanging( wxBookCtrlEvent &event ) { int selOld = event.GetOldSelection(); @@ -1326,20 +1359,18 @@ void MyPanel::OnChoiceButtons( wxCommandEvent &event ) void MyPanel::OnCombo( wxCommandEvent &event ) { - m_text->AppendText( _T("ComboBox event selection string is: ") ); - m_text->AppendText( event.GetString() ); - m_text->AppendText( _T("\n") ); - m_text->AppendText( _T("ComboBox control selection string is: ") ); - m_text->AppendText( m_combo->GetStringSelection() ); - m_text->AppendText( _T("\n") ); + wxLogMessage(_T("EVT_COMBOBOX: item %d/%d (event/control), string \"%s\"/\"%s\""), + (int)event.GetInt(), + m_combo->GetSelection(), + event.GetString().c_str(), + m_combo->GetStringSelection().c_str()); } void MyPanel::OnComboTextChanged(wxCommandEvent& event) { - wxString str; - str.Printf( wxT("Text in the combobox changed: now is '%s'."), - event.GetString().c_str() ); - wxLogMessage( str.c_str() ); + wxLogMessage(wxT("EVT_TEXT for the combobox: \"%s\" (event) or \"%s\" (control)."), + event.GetString().c_str(), + m_combo->GetValue().c_str()); } void MyPanel::OnComboTextEnter(wxCommandEvent& WXUNUSED(event))