#include "wx/wx.h"
#endif
+#if !defined( __WXMSW__ ) || defined( __WIN95__ )
#include "wx/spinbutt.h"
+#endif
#include "wx/notebook.h"
#include "wx/imaglist.h"
// Win16 doesn't have them
#undef wxUSE_SPINBUTTON
#define wxUSE_SPINBUTTON 0
+#else
+ #if !defined(wxUSE_SPINBUTTON)
+ #define wxUSE_SPINBUTTON 1
+ #endif
#endif // __WIN16__
#include "wx/progdlg.h"
+// VZ: this is a temp. hack, will remove soon
+#define wxUSE_SPINCTRL 1
+
+#if wxUSE_SPINCTRL
+ #include "wx/spinctrl.h"
+#endif // wxUSE_SPINCTRL
+
//----------------------------------------------------------------------
// class definitions
//----------------------------------------------------------------------
void OnPageChanged( wxNotebookEvent &event );
void OnPageChanging( wxNotebookEvent &event );
void OnSliderUpdate( wxCommandEvent &event );
-#ifndef wxUSE_SPINBUTTON
+#if wxUSE_SPINBUTTON
+ void OnSpinUp( wxSpinEvent &event );
+ void OnSpinDown( wxSpinEvent &event );
void OnSpinUpdate( wxSpinEvent &event );
void OnUpdateShowProgress( wxUpdateUIEvent& event );
void OnShowProgress( wxCommandEvent &event );
wxButton *m_fontButton;
wxButton *m_lbSelectNum;
wxButton *m_lbSelectThis;
-#ifndef wxUSE_SPINBUTTON
+#if wxUSE_SPINBUTTON
wxSpinButton *m_spinbutton;
wxButton *m_btnProgress;
-#endif
+#endif // wxUSE_SPINBUTTON
+
+#if wxUSE_SPINCTRL
+ wxSpinCtrl *m_spinctrl;
+#endif // wxUSE_SPINCTRL
+
wxTextCtrl *m_spintext;
wxCheckBox *m_checkbox;
EVT_CHECKBOX (ID_RADIOBOX_ENABLE, MyPanel::OnRadioButtons)
EVT_BUTTON (ID_SET_FONT, MyPanel::OnSetFont)
EVT_SLIDER (ID_SLIDER, MyPanel::OnSliderUpdate)
-#ifndef wxUSE_SPINBUTTON
+#if wxUSE_SPINBUTTON
EVT_SPIN (ID_SPIN, MyPanel::OnSpinUpdate)
+EVT_SPIN_UP (ID_SPIN, MyPanel::OnSpinUp)
+EVT_SPIN_DOWN (ID_SPIN, MyPanel::OnSpinDown)
EVT_UPDATE_UI (ID_BTNPROGRESS, MyPanel::OnUpdateShowProgress)
EVT_BUTTON (ID_BTNPROGRESS, MyPanel::OnShowProgress)
#endif
button->SetToolTip( "Press here to set italic font" );
#endif // wxUSE_TOOLTIPS
- m_checkbox = new wxCheckBox( panel, ID_LISTBOX_ENABLE, "&Disable", wxPoint(20,130), wxSize(-1, -1), wxALIGN_RIGHT );
+ m_checkbox = new wxCheckBox( panel, ID_LISTBOX_ENABLE, "&Disable", wxPoint(20,130) );
m_checkbox->SetValue(FALSE);
#if wxUSE_TOOLTIPS
m_checkbox->SetToolTip( "Click here to disable the listbox" );
panel = new wxPanel(m_notebook);
m_choice = new wxChoice( panel, ID_CHOICE, wxPoint(10,10), wxSize(120,-1), 5, choices );
+ m_choice->SetSelection(2);
m_choice->SetBackgroundColour( "red" );
(void)new wxButton( panel, ID_CHOICE_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
(void)new wxButton( panel, ID_CHOICE_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) );
"\n"
"This is also supposed to demonstrate how\n"
"to use static controls.\n",
- wxPoint(228,25),
- wxSize(240, 110)
+ wxPoint(228,25),
+ wxSize(240, 110)
);
#endif
- m_spintext = new wxTextCtrl( panel, -1, "-5", wxPoint(20,160), wxSize(80,-1) );
-#ifndef wxUSE_SPINBUTTON
- m_spinbutton = new wxSpinButton( panel, ID_SPIN, wxPoint(103,159), wxSize(-1,-1) );
+ int initialSpinValue = -5;
+ wxString s;
+ s << initialSpinValue;
+ m_spintext = new wxTextCtrl( panel, -1, s, wxPoint(20,160), wxSize(80,-1) );
+#if wxUSE_SPINBUTTON
+ m_spinbutton = new wxSpinButton( panel, ID_SPIN, wxPoint(103,160), wxSize(80, -1) );
m_spinbutton->SetRange(-10,30);
- m_spinbutton->SetValue(-5);
+ m_spinbutton->SetValue(initialSpinValue);
m_btnProgress = new wxButton( panel, ID_BTNPROGRESS, "Show progress dialog",
- wxPoint(208, 159) );
-#endif
+ wxPoint(300, 160) );
+#endif // wxUSE_SPINBUTTON
+
+#if wxUSE_SPINCTRL
+ m_spinctrl = new wxSpinCtrl( panel, -1, wxPoint(200, 160), wxSize(80, -1) );
+ m_spinctrl->SetRange(10,30);
+ m_spinctrl->SetValue(15);
+#endif // wxUSE_SPINCTRL
+
m_notebook->AddPage(panel, "wxGauge", FALSE, Image_Gauge);
panel = new wxPanel(m_notebook);
+
+#ifndef __WXMOTIF__ // wxStaticBitmap not working under Motif yet. MB
wxIcon icon = wxTheApp->GetStdIcon(wxICON_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));
+#endif // !Motif
wxBitmap bitmap( 100, 100 );
wxMemoryDC dc;
int selOld = event.GetOldSelection();
if ( selOld == 2 )
{
- wxMessageBox("This demonstrates how a program may prevent the "
- "page change from taking place - \n the current page will "
- "stay the third one", "Control sample",
- wxICON_INFORMATION | wxOK);
-
- event.Veto();
+ if ( wxMessageBox("This demonstrates how a program may prevent the\n"
+ "page change from taking place - if you select\n"
+ "[No] the current page will stay the third one\n",
+ "Control sample",
+ wxICON_QUESTION | wxYES_NO) != wxYES )
+ {
+ event.Veto();
- return;
+ return;
+ }
}
*m_text << "Notebook selection is being changed from " << selOld << "\n";
case ID_LISTBOX_SEL_NUM:
{
m_listbox->SetSelection( 2 );
- m_lbSelectThis->WarpPointer( 40, 14 );
+ m_lbSelectThis->WarpPointer( 40, 14 );
break;
}
case ID_LISTBOX_SEL_STR:
{
m_listbox->SetStringSelection( "This" );
- m_lbSelectNum->WarpPointer( 40, 14 );
+ m_lbSelectNum->WarpPointer( 40, 14 );
break;
}
case ID_LISTBOX_CLEAR:
m_gauge->SetValue( m_slider->GetValue() );
}
-#ifndef wxUSE_SPINBUTTON
+#if wxUSE_SPINBUTTON
+void MyPanel::OnSpinUp( wxSpinEvent &event )
+{
+ wxString value;
+ value.Printf( _T("Spin control up: current = %d\n"),
+ m_spinbutton->GetValue());
+
+ if ( m_spinbutton->GetValue() > 17 )
+ {
+ value += _T("Preventing the spin button from going above 17.\n");
+
+ event.Veto();
+ }
+
+ m_text->AppendText(value);
+}
+
+void MyPanel::OnSpinDown( wxSpinEvent &event )
+{
+ wxString value;
+ value.Printf( _T("Spin control down: current = %d\n"),
+ m_spinbutton->GetValue());
+
+ if ( m_spinbutton->GetValue() < -17 )
+ {
+ value += _T("Preventing the spin button from going below -17.\n");
+
+ event.Veto();
+ }
+
+ m_text->AppendText(value);
+}
+
void MyPanel::OnSpinUpdate( wxSpinEvent &event )
{
wxString value;
"An informative message",
max, // range
this, // parent
- wxPD_CAN_ABORT | wxPD_APP_MODAL | wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME | wxPD_REMAINING_TIME);
+ wxPD_CAN_ABORT |
+ wxPD_APP_MODAL |
+ wxPD_ELAPSED_TIME |
+ wxPD_ESTIMATED_TIME |
+ wxPD_REMAINING_TIME);
bool cont = TRUE;