X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/601964ff75f93953dd1f6e4665b9839a8eb72e44..830efc9b0cb87eae22d4435af7858175017522ab:/samples/controls/controls.cpp diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index bb6d0fea8a..6a64e31cf0 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -29,12 +29,13 @@ #include "wx/tglbtn.h" #include "wx/notebook.h" #include "wx/imaglist.h" +#include "wx/artprov.h" #if wxUSE_TOOLTIPS #include "wx/tooltip.h" #endif -#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) +#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) || defined(__WXX11__) #define USE_XPM #endif @@ -111,6 +112,9 @@ public: #if wxUSE_SPINCTRL void OnSpinCtrl(wxSpinEvent& event); + void OnSpinCtrlUp(wxSpinEvent& event); + void OnSpinCtrlDown(wxSpinEvent& event); + void OnSpinCtrlText(wxCommandEvent& event); #endif // wxUSE_SPINCTRL void OnEnableAll(wxCommandEvent& event); @@ -183,10 +187,12 @@ private: if ( m_frameStatusBar ) { wxString msg; - wxSize sizeCl = GetClientSize(); - msg.Printf(_("pos=(%d, %d), size=%dx%d (client=%dx%d)"), + wxSize sizeAll = GetSize(), + sizeCl = GetClientSize(); + msg.Printf(_("pos=(%d, %d), size=%dx%d or %dx%d (client=%dx%d)"), pos.x, pos.y, size.x, size.y, + sizeAll.x, sizeAll.y, sizeCl.x, sizeCl.y); SetStatusText(msg, 1); } @@ -448,6 +454,9 @@ EVT_BUTTON (ID_BTNPROGRESS, MyPanel::OnShowProgress) #endif // wxUSE_SPINBTN #if wxUSE_SPINCTRL EVT_SPINCTRL (ID_SPINCTRL, MyPanel::OnSpinCtrl) +EVT_SPIN_UP (ID_SPINCTRL, MyPanel::OnSpinCtrlUp) +EVT_SPIN_DOWN (ID_SPINCTRL, MyPanel::OnSpinCtrlDown) +EVT_TEXT (ID_SPINCTRL, MyPanel::OnSpinCtrlText) #endif // wxUSE_SPINCTRL #if wxUSE_TOGGLEBTN EVT_TOGGLEBUTTON(ID_BUTTON_LABEL, MyPanel::OnUpdateLabel) @@ -480,10 +489,34 @@ END_EVENT_TABLE() // ============================================================================ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) - : wxPanel( frame, -1, wxPoint(x, y), wxSize(w, h) ), - m_text(NULL), m_notebook(NULL) + : wxPanel( frame, -1, wxPoint(x, y), wxSize(w, h) ) { - wxLayoutConstraints *c; + m_listbox = NULL; + m_listboxSorted = NULL; +#if wxUSE_CHOICE + m_choice = NULL; + m_choiceSorted = NULL; +#endif + m_combo = NULL; + m_radio = NULL; + m_gauge = NULL; + m_gaugeVert = NULL; + m_slider = NULL; + m_fontButton = NULL; + m_lbSelectNum = NULL; + m_lbSelectThis = NULL; +#if wxUSE_SPINBTN + m_spinbutton = NULL; + m_btnProgress = NULL; +#endif // wxUSE_SPINBTN +#if wxUSE_SPINCTRL + m_spinctrl = NULL; +#endif // wxUSE_SPINCTRL + m_spintext = NULL; + m_checkbox = NULL; + m_text = NULL; + m_notebook = NULL; + m_label = NULL; m_text = new wxTextCtrl(this, -1, "This is the log window.\n", wxPoint(0, 250), wxSize(100, 50), wxTE_MULTILINE); @@ -705,7 +738,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) m_spintext = new wxTextCtrl( panel, -1, s, wxPoint(20,160), wxSize(80,-1) ); #if wxUSE_SPINBTN m_spinbutton = new wxSpinButton( panel, ID_SPIN, wxPoint(103,160), wxSize(80, -1) ); - m_spinbutton->SetRange(-10,30); + m_spinbutton->SetRange(-40,30); m_spinbutton->SetValue(initialSpinValue); m_btnProgress = new wxButton( panel, ID_BTNPROGRESS, "&Show progress dialog", @@ -723,12 +756,13 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) panel = new wxPanel(m_notebook); #if !defined(__WXMOTIF__) && !defined(__WIN16__) // wxStaticBitmap not working under Motif yet; and icons not allowed under WIN16. - wxIcon icon = wxTheApp->GetStdIcon(wxICON_INFORMATION); + wxIcon icon = wxArtProvider::GetIcon(wxART_INFORMATION); wxStaticBitmap *bmpStatic = new wxStaticBitmap(panel, -1, icon, wxPoint(10, 10)); - bmpStatic = new wxStaticBitmap(panel, -1, wxNullIcon, wxPoint(50, 10)); - bmpStatic->SetIcon(wxTheApp->GetStdIcon(wxICON_QUESTION)); + // VZ: don't leak memory + // bmpStatic = new wxStaticBitmap(panel, -1, wxNullIcon, wxPoint(50, 10)); + // bmpStatic->SetIcon(wxArtProvider::GetIcon(wxART_QUESTION)); #endif // !Motif wxBitmap bitmap( 100, 100 ); @@ -753,9 +787,9 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) } #endif - wxBitmap bmp1(wxTheApp->GetStdIcon(wxICON_INFORMATION)), - bmp2(wxTheApp->GetStdIcon(wxICON_WARNING)), - bmp3(wxTheApp->GetStdIcon(wxICON_QUESTION)); + wxBitmap bmp1(wxArtProvider::GetBitmap(wxART_INFORMATION)), + bmp2(wxArtProvider::GetBitmap(wxART_WARNING)), + bmp3(wxArtProvider::GetBitmap(wxART_QUESTION)); wxBitmapButton *bmpBtn = new wxBitmapButton ( panel, -1, @@ -779,6 +813,8 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) m_notebook->AddPage(panel, "wxBitmapXXX"); // layout constraints +#if wxUSE_CONSTRAINTS + wxLayoutConstraints *c; panel = new wxPanel(m_notebook); panel->SetAutoLayout( TRUE ); @@ -802,7 +838,8 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) pMyButton2->SetConstraints( c ); m_notebook->AddPage(panel, "wxLayoutConstraint"); - +#endif + // sizer panel = new wxPanel(m_notebook); @@ -812,7 +849,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) sizer->Add( new wxButton(panel, -1, "Test Button &1" ), 3, wxALL, 10 ); sizer->Add( 20,20, 1 ); - sizer->Add( new wxButton(panel, -1, "Test Button &2" ), 3, wxGROW|wxALL, 10 ); + sizer->Add( new wxButton(panel, -1, "Multiline\nbutton" ), 3, wxGROW|wxALL, 10 ); panel->SetSizer( sizer ); @@ -1212,12 +1249,44 @@ void MyPanel::OnSliderUpdate( wxCommandEvent &WXUNUSED(event) ) #if wxUSE_SPINCTRL +void MyPanel::OnSpinCtrlText(wxCommandEvent& event) +{ + if ( m_spinctrl ) + { + wxString s; + s.Printf(_T("Spin ctrl text changed: now %d (from event: %s)\n"), + m_spinctrl->GetValue(), event.GetString()); + m_text->AppendText(s); + } +} + void MyPanel::OnSpinCtrl(wxSpinEvent& event) { - wxString s; - s.Printf(_T("Spin ctrl changed: now %d (from event: %d)\n"), - m_spinctrl->GetValue(), event.GetInt()); - m_text->AppendText(s); + if ( m_spinctrl ) + { + wxString s; + s.Printf(_T("Spin ctrl changed: now %d (from event: %d)\n"), + m_spinctrl->GetValue(), event.GetInt()); + m_text->AppendText(s); + } +} + +void MyPanel::OnSpinCtrlUp(wxSpinEvent& event) +{ + if ( m_spinctrl ) + { + m_text->AppendText(wxString::Format(_T("Spin up: %d (from event: %d)\n"), + m_spinctrl->GetValue(), event.GetInt())); + } +} + +void MyPanel::OnSpinCtrlDown(wxSpinEvent& event) +{ + if ( m_spinctrl ) + { + m_text->AppendText(wxString::Format(_T("Spin down: %d (from event: %d)\n"), + m_spinctrl->GetValue(), event.GetInt())); + } } #endif // wxUSE_SPINCTRL @@ -1229,7 +1298,7 @@ void MyPanel::OnSpinUp( wxSpinEvent &event ) value.Printf( _T("Spin control up: current = %d\n"), m_spinbutton->GetValue()); - if ( m_spinbutton->GetValue() > 17 ) + if ( event.GetPosition() > 17 ) { value += _T("Preventing the spin button from going above 17.\n"); @@ -1245,7 +1314,7 @@ void MyPanel::OnSpinDown( wxSpinEvent &event ) value.Printf( _T("Spin control down: current = %d\n"), m_spinbutton->GetValue()); - if ( m_spinbutton->GetValue() < -17 ) + if ( event.GetPosition() < -17 ) { value += _T("Preventing the spin button from going below -17.\n");