]>
Commit | Line | Data |
---|---|---|
32b8ec41 | 1 | ///////////////////////////////////////////////////////////////////////////// |
be5a51fb | 2 | // Program: wxWidgets Widgets Sample |
32b8ec41 VZ |
3 | // Name: spinbtn.cpp |
4 | // Purpose: Part of the widgets sample showing wxSpinButton | |
5 | // Author: Vadim Zeitlin | |
6 | // Created: 16.04.01 | |
7 | // Id: $Id$ | |
8 | // Copyright: (c) 2001 Vadim Zeitlin | |
9 | // License: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // ============================================================================ | |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
20 | // for compilers that support precompilation, includes "wx/wx.h". | |
21 | #include "wx/wxprec.h" | |
22 | ||
23 | #ifdef __BORLANDC__ | |
24 | #pragma hdrstop | |
25 | #endif | |
26 | ||
61c083e7 WS |
27 | #if wxUSE_SPINBTN |
28 | ||
32b8ec41 VZ |
29 | // for all others, include the necessary headers |
30 | #ifndef WX_PRECOMP | |
31 | #include "wx/log.h" | |
32 | ||
3bb70c40 | 33 | #include "wx/bitmap.h" |
32b8ec41 VZ |
34 | #include "wx/button.h" |
35 | #include "wx/checkbox.h" | |
36 | #include "wx/radiobox.h" | |
37 | #include "wx/statbox.h" | |
38 | #include "wx/textctrl.h" | |
39 | #endif | |
40 | ||
41 | #include "wx/spinbutt.h" | |
42 | #include "wx/spinctrl.h" | |
43 | ||
44 | #include "wx/sizer.h" | |
2a998b73 | 45 | #include "wx/stattext.h" |
32b8ec41 | 46 | #include "widgets.h" |
61c083e7 | 47 | |
32b8ec41 VZ |
48 | #include "icons/spinbtn.xpm" |
49 | ||
50 | // ---------------------------------------------------------------------------- | |
51 | // constants | |
52 | // ---------------------------------------------------------------------------- | |
53 | ||
54 | // control ids | |
55 | enum | |
56 | { | |
f0fa4312 | 57 | SpinBtnPage_Reset = wxID_HIGHEST, |
32b8ec41 VZ |
58 | SpinBtnPage_Clear, |
59 | SpinBtnPage_SetValue, | |
60 | SpinBtnPage_SetMinAndMax, | |
61 | SpinBtnPage_CurValueText, | |
62 | SpinBtnPage_ValueText, | |
63 | SpinBtnPage_MinText, | |
64 | SpinBtnPage_MaxText, | |
65 | SpinBtnPage_SpinBtn, | |
8cd6a9ad VZ |
66 | SpinBtnPage_SpinCtrl, |
67 | SpinBtnPage_SpinCtrlDouble | |
32b8ec41 VZ |
68 | }; |
69 | ||
70 | // ---------------------------------------------------------------------------- | |
71 | // SpinBtnWidgetsPage | |
72 | // ---------------------------------------------------------------------------- | |
73 | ||
74 | class SpinBtnWidgetsPage : public WidgetsPage | |
75 | { | |
76 | public: | |
f2fdc4d5 | 77 | SpinBtnWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist); |
8f6eaec9 | 78 | virtual ~SpinBtnWidgetsPage(){}; |
32b8ec41 | 79 | |
195df7a7 | 80 | virtual wxControl *GetWidget() const { return m_spinbtn; } |
1c01dd16 | 81 | virtual wxControl *GetWidget2() const { return m_spinctrl; } |
8cd6a9ad | 82 | virtual wxControl *GetWidget3() const { return m_spinctrldbl; } |
1301e228 | 83 | virtual void RecreateWidget() { CreateSpin(); } |
195df7a7 | 84 | |
453535a7 WS |
85 | // lazy creation of the content |
86 | virtual void CreateContent(); | |
87 | ||
32b8ec41 VZ |
88 | protected: |
89 | // event handlers | |
90 | void OnButtonReset(wxCommandEvent& event); | |
91 | void OnButtonClear(wxCommandEvent& event); | |
92 | void OnButtonSetValue(wxCommandEvent& event); | |
93 | void OnButtonSetMinAndMax(wxCommandEvent& event); | |
94 | ||
95 | void OnCheckOrRadioBox(wxCommandEvent& event); | |
96 | ||
0a3d26b8 VZ |
97 | void OnSpinBtn(wxSpinEvent& event); |
98 | void OnSpinBtnUp(wxSpinEvent& event); | |
99 | void OnSpinBtnDown(wxSpinEvent& event); | |
100 | void OnSpinCtrl(wxSpinEvent& event); | |
8cd6a9ad | 101 | void OnSpinCtrlDouble(wxSpinDoubleEvent& event); |
6ceb105f | 102 | void OnSpinText(wxCommandEvent& event); |
952ff7bc | 103 | void OnSpinTextEnter(wxCommandEvent& event); |
32b8ec41 VZ |
104 | |
105 | void OnUpdateUIValueButton(wxUpdateUIEvent& event); | |
106 | void OnUpdateUIMinMaxButton(wxUpdateUIEvent& event); | |
107 | ||
108 | void OnUpdateUIResetButton(wxUpdateUIEvent& event); | |
109 | ||
110 | void OnUpdateUICurValueText(wxUpdateUIEvent& event); | |
111 | ||
112 | // reset the spinbtn parameters | |
113 | void Reset(); | |
114 | ||
115 | // (re)create the spinbtn | |
116 | void CreateSpin(); | |
117 | ||
118 | // is this spinbtn value in range? | |
119 | bool IsValidValue(int val) const | |
120 | { return (val >= m_min) && (val <= m_max); } | |
121 | ||
122 | // the spinbtn range | |
123 | int m_min, m_max; | |
124 | ||
125 | // the controls | |
126 | // ------------ | |
127 | ||
128 | // the check/radio boxes for styles | |
129 | wxCheckBox *m_chkVert, | |
fd07e185 | 130 | *m_chkArrowKeys, |
242ec2f7 VZ |
131 | *m_chkWrap, |
132 | *m_chkProcessEnter; | |
32b8ec41 VZ |
133 | |
134 | // the spinbtn and the spinctrl and the sizer containing them | |
135 | wxSpinButton *m_spinbtn; | |
136 | wxSpinCtrl *m_spinctrl; | |
8cd6a9ad | 137 | wxSpinCtrlDouble *m_spinctrldbl; |
32b8ec41 VZ |
138 | |
139 | wxSizer *m_sizerSpin; | |
140 | ||
141 | // the text entries for set value/range | |
142 | wxTextCtrl *m_textValue, | |
143 | *m_textMin, | |
144 | *m_textMax; | |
145 | ||
146 | private: | |
5e173f35 GD |
147 | DECLARE_EVENT_TABLE() |
148 | DECLARE_WIDGETS_PAGE(SpinBtnWidgetsPage) | |
32b8ec41 VZ |
149 | }; |
150 | ||
151 | // ---------------------------------------------------------------------------- | |
152 | // event tables | |
153 | // ---------------------------------------------------------------------------- | |
154 | ||
155 | BEGIN_EVENT_TABLE(SpinBtnWidgetsPage, WidgetsPage) | |
156 | EVT_BUTTON(SpinBtnPage_Reset, SpinBtnWidgetsPage::OnButtonReset) | |
157 | EVT_BUTTON(SpinBtnPage_SetValue, SpinBtnWidgetsPage::OnButtonSetValue) | |
158 | EVT_BUTTON(SpinBtnPage_SetMinAndMax, SpinBtnWidgetsPage::OnButtonSetMinAndMax) | |
159 | ||
160 | EVT_UPDATE_UI(SpinBtnPage_SetValue, SpinBtnWidgetsPage::OnUpdateUIValueButton) | |
161 | EVT_UPDATE_UI(SpinBtnPage_SetMinAndMax, SpinBtnWidgetsPage::OnUpdateUIMinMaxButton) | |
162 | ||
163 | EVT_UPDATE_UI(SpinBtnPage_Reset, SpinBtnWidgetsPage::OnUpdateUIResetButton) | |
164 | ||
165 | EVT_UPDATE_UI(SpinBtnPage_CurValueText, SpinBtnWidgetsPage::OnUpdateUICurValueText) | |
166 | ||
167 | EVT_SPIN(SpinBtnPage_SpinBtn, SpinBtnWidgetsPage::OnSpinBtn) | |
168 | EVT_SPIN_UP(SpinBtnPage_SpinBtn, SpinBtnWidgetsPage::OnSpinBtnUp) | |
169 | EVT_SPIN_DOWN(SpinBtnPage_SpinBtn, SpinBtnWidgetsPage::OnSpinBtnDown) | |
170 | EVT_SPINCTRL(SpinBtnPage_SpinCtrl, SpinBtnWidgetsPage::OnSpinCtrl) | |
8cd6a9ad | 171 | EVT_SPINCTRLDOUBLE(SpinBtnPage_SpinCtrlDouble, SpinBtnWidgetsPage::OnSpinCtrlDouble) |
6ceb105f | 172 | EVT_TEXT(SpinBtnPage_SpinCtrl, SpinBtnWidgetsPage::OnSpinText) |
952ff7bc | 173 | EVT_TEXT_ENTER(SpinBtnPage_SpinCtrl, SpinBtnWidgetsPage::OnSpinTextEnter) |
8cd6a9ad | 174 | EVT_TEXT(SpinBtnPage_SpinCtrlDouble, SpinBtnWidgetsPage::OnSpinText) |
32b8ec41 | 175 | |
206d3a16 JS |
176 | EVT_CHECKBOX(wxID_ANY, SpinBtnWidgetsPage::OnCheckOrRadioBox) |
177 | EVT_RADIOBOX(wxID_ANY, SpinBtnWidgetsPage::OnCheckOrRadioBox) | |
32b8ec41 VZ |
178 | END_EVENT_TABLE() |
179 | ||
180 | // ============================================================================ | |
181 | // implementation | |
182 | // ============================================================================ | |
183 | ||
f0fa4312 WS |
184 | #if defined(__WXUNIVERSAL__) |
185 | #define FAMILY_CTRLS UNIVERSAL_CTRLS | |
186 | #else | |
187 | #define FAMILY_CTRLS NATIVE_CTRLS | |
188 | #endif | |
189 | ||
f2fdc4d5 | 190 | IMPLEMENT_WIDGETS_PAGE(SpinBtnWidgetsPage, _T("Spin"), |
f0fa4312 | 191 | FAMILY_CTRLS | EDITABLE_CTRLS |
f2fdc4d5 | 192 | ); |
32b8ec41 | 193 | |
f2fdc4d5 | 194 | SpinBtnWidgetsPage::SpinBtnWidgetsPage(WidgetsBookCtrl *book, |
32b8ec41 | 195 | wxImageList *imaglist) |
261357eb | 196 | : WidgetsPage(book, imaglist, spinbtn_xpm) |
32b8ec41 | 197 | { |
59b9edf0 | 198 | m_chkVert = NULL; |
fd07e185 | 199 | m_chkArrowKeys = NULL; |
59b9edf0 | 200 | m_chkWrap = NULL; |
242ec2f7 | 201 | m_chkProcessEnter = NULL; |
59b9edf0 JS |
202 | m_spinbtn = NULL; |
203 | m_spinctrl = NULL; | |
8cd6a9ad | 204 | m_spinctrldbl = NULL; |
59b9edf0 JS |
205 | m_textValue = NULL; |
206 | m_textMin = NULL; | |
207 | m_textMax = NULL; | |
32b8ec41 | 208 | |
32b8ec41 VZ |
209 | m_min = 0; |
210 | m_max = 10; | |
211 | ||
242ec2f7 | 212 | m_sizerSpin = NULL; |
453535a7 | 213 | } |
32b8ec41 | 214 | |
453535a7 WS |
215 | void SpinBtnWidgetsPage::CreateContent() |
216 | { | |
32b8ec41 VZ |
217 | wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL); |
218 | ||
219 | // left pane | |
206d3a16 | 220 | wxStaticBox *box = new wxStaticBox(this, wxID_ANY, _T("&Set style")); |
32b8ec41 VZ |
221 | wxSizer *sizerLeft = new wxStaticBoxSizer(box, wxVERTICAL); |
222 | ||
223 | m_chkVert = CreateCheckBoxAndAddToSizer(sizerLeft, _T("&Vertical")); | |
fd07e185 | 224 | m_chkArrowKeys = CreateCheckBoxAndAddToSizer(sizerLeft, _T("&Arrow Keys")); |
32b8ec41 | 225 | m_chkWrap = CreateCheckBoxAndAddToSizer(sizerLeft, _T("&Wrap")); |
242ec2f7 VZ |
226 | m_chkProcessEnter = CreateCheckBoxAndAddToSizer(sizerLeft, |
227 | _T("Process &Enter")); | |
32b8ec41 VZ |
228 | |
229 | sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer | |
230 | ||
231 | wxButton *btn = new wxButton(this, SpinBtnPage_Reset, _T("&Reset")); | |
232 | sizerLeft->Add(btn, 0, wxALIGN_CENTRE_HORIZONTAL | wxALL, 15); | |
233 | ||
234 | // middle pane | |
206d3a16 JS |
235 | wxStaticBox *box2 = new wxStaticBox(this, wxID_ANY, |
236 | _T("&Change spinbtn value")); | |
237 | ||
32b8ec41 VZ |
238 | wxSizer *sizerMiddle = new wxStaticBoxSizer(box2, wxVERTICAL); |
239 | ||
240 | wxTextCtrl *text; | |
241 | wxSizer *sizerRow = CreateSizerWithTextAndLabel(_T("Current value"), | |
242 | SpinBtnPage_CurValueText, | |
243 | &text); | |
206d3a16 | 244 | text->SetEditable(false); |
32b8ec41 VZ |
245 | |
246 | sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5); | |
247 | ||
248 | sizerRow = CreateSizerWithTextAndButton(SpinBtnPage_SetValue, | |
249 | _T("Set &value"), | |
250 | SpinBtnPage_ValueText, | |
251 | &m_textValue); | |
252 | sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5); | |
253 | ||
254 | sizerRow = CreateSizerWithTextAndButton(SpinBtnPage_SetMinAndMax, | |
255 | _T("&Min and max"), | |
256 | SpinBtnPage_MinText, | |
257 | &m_textMin); | |
258 | ||
206d3a16 | 259 | m_textMax = new wxTextCtrl(this, SpinBtnPage_MaxText, wxEmptyString); |
32b8ec41 VZ |
260 | sizerRow->Add(m_textMax, 1, wxLEFT | wxALIGN_CENTRE_VERTICAL, 5); |
261 | ||
aec18ff7 MB |
262 | m_textMin->SetValue( wxString::Format(_T("%d"), m_min) ); |
263 | m_textMax->SetValue( wxString::Format(_T("%d"), m_max) ); | |
32b8ec41 VZ |
264 | |
265 | sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5); | |
266 | ||
267 | // right pane | |
268 | wxSizer *sizerRight = new wxBoxSizer(wxVERTICAL); | |
7b127900 | 269 | sizerRight->SetMinSize(150, 0); |
32b8ec41 VZ |
270 | m_sizerSpin = sizerRight; // save it to modify it later |
271 | ||
272 | Reset(); | |
273 | CreateSpin(); | |
274 | ||
275 | // the 3 panes panes compose the window | |
276 | sizerTop->Add(sizerLeft, 0, wxGROW | (wxALL & ~wxLEFT), 10); | |
7b127900 | 277 | sizerTop->Add(sizerMiddle, 0, wxGROW | wxALL, 10); |
32b8ec41 VZ |
278 | sizerTop->Add(sizerRight, 1, wxGROW | (wxALL & ~wxRIGHT), 10); |
279 | ||
280 | // final initializations | |
32b8ec41 | 281 | SetSizer(sizerTop); |
32b8ec41 VZ |
282 | } |
283 | ||
32b8ec41 VZ |
284 | // ---------------------------------------------------------------------------- |
285 | // operations | |
286 | // ---------------------------------------------------------------------------- | |
287 | ||
288 | void SpinBtnWidgetsPage::Reset() | |
289 | { | |
206d3a16 | 290 | m_chkVert->SetValue(true); |
fd07e185 | 291 | m_chkArrowKeys->SetValue(true); |
206d3a16 | 292 | m_chkWrap->SetValue(false); |
242ec2f7 | 293 | m_chkProcessEnter->SetValue(false); |
32b8ec41 VZ |
294 | } |
295 | ||
296 | void SpinBtnWidgetsPage::CreateSpin() | |
297 | { | |
1301e228 | 298 | int flags = ms_defaultFlags; |
32b8ec41 VZ |
299 | |
300 | bool isVert = m_chkVert->GetValue(); | |
301 | if ( isVert ) | |
302 | flags |= wxSP_VERTICAL; | |
303 | else | |
304 | flags |= wxSP_HORIZONTAL; | |
305 | ||
fd07e185 VZ |
306 | if ( m_chkArrowKeys->GetValue() ) |
307 | flags |= wxSP_ARROW_KEYS; | |
308 | ||
32b8ec41 VZ |
309 | if ( m_chkWrap->GetValue() ) |
310 | flags |= wxSP_WRAP; | |
311 | ||
242ec2f7 VZ |
312 | if ( m_chkProcessEnter->GetValue() ) |
313 | flags |= wxTE_PROCESS_ENTER; | |
314 | ||
32b8ec41 VZ |
315 | int val = m_min; |
316 | if ( m_spinbtn ) | |
317 | { | |
318 | int valOld = m_spinbtn->GetValue(); | |
319 | if ( !IsValidValue(valOld) ) | |
320 | { | |
321 | val = valOld; | |
322 | } | |
323 | ||
55ab5200 | 324 | m_sizerSpin->Clear(true /* delete windows */); |
32b8ec41 VZ |
325 | } |
326 | ||
327 | m_spinbtn = new wxSpinButton(this, SpinBtnPage_SpinBtn, | |
328 | wxDefaultPosition, wxDefaultSize, | |
329 | flags); | |
330 | ||
331 | m_spinbtn->SetValue(val); | |
332 | m_spinbtn->SetRange(m_min, m_max); | |
333 | ||
334 | m_spinctrl = new wxSpinCtrl(this, SpinBtnPage_SpinCtrl, | |
335 | wxString::Format(_T("%d"), val), | |
336 | wxDefaultPosition, wxDefaultSize, | |
337 | flags, | |
338 | m_min, m_max, val); | |
339 | ||
8cd6a9ad VZ |
340 | m_spinctrldbl = new wxSpinCtrlDouble(this, SpinBtnPage_SpinCtrlDouble, |
341 | wxString::Format(_T("%d"), val), | |
342 | wxDefaultPosition, wxDefaultSize, | |
343 | flags, | |
344 | m_min, m_max, val, 0.1); | |
345 | ||
2a998b73 | 346 | // Add spacers, labels and spin controls to the sizer. |
32b8ec41 | 347 | m_sizerSpin->Add(0, 0, 1); |
2a998b73 VZ |
348 | m_sizerSpin->Add(new wxStaticText(this, wxID_ANY, wxT("wxSpinButton")), |
349 | 0, wxALIGN_CENTRE | wxALL, 5); | |
32b8ec41 VZ |
350 | m_sizerSpin->Add(m_spinbtn, 0, wxALIGN_CENTRE | wxALL, 5); |
351 | m_sizerSpin->Add(0, 0, 1); | |
2a998b73 VZ |
352 | m_sizerSpin->Add(new wxStaticText(this, wxID_ANY, wxT("wxSpinCtrl")), |
353 | 0, wxALIGN_CENTRE | wxALL, 5); | |
32b8ec41 VZ |
354 | m_sizerSpin->Add(m_spinctrl, 0, wxALIGN_CENTRE | wxALL, 5); |
355 | m_sizerSpin->Add(0, 0, 1); | |
2a998b73 VZ |
356 | m_sizerSpin->Add(new wxStaticText(this, wxID_ANY, wxT("wxSpinCtrlDouble")), |
357 | 0, wxALIGN_CENTRE | wxALL, 5); | |
8cd6a9ad VZ |
358 | m_sizerSpin->Add(m_spinctrldbl, 0, wxALIGN_CENTRE | wxALL, 5); |
359 | m_sizerSpin->Add(0, 0, 1); | |
32b8ec41 VZ |
360 | |
361 | m_sizerSpin->Layout(); | |
362 | } | |
363 | ||
364 | // ---------------------------------------------------------------------------- | |
365 | // event handlers | |
366 | // ---------------------------------------------------------------------------- | |
367 | ||
368 | void SpinBtnWidgetsPage::OnButtonReset(wxCommandEvent& WXUNUSED(event)) | |
369 | { | |
370 | Reset(); | |
371 | ||
372 | CreateSpin(); | |
373 | } | |
374 | ||
375 | void SpinBtnWidgetsPage::OnButtonSetMinAndMax(wxCommandEvent& WXUNUSED(event)) | |
376 | { | |
377 | long minNew, | |
378 | maxNew = 0; // init to suppress compiler warning | |
379 | if ( !m_textMin->GetValue().ToLong(&minNew) || | |
380 | !m_textMax->GetValue().ToLong(&maxNew) || | |
6dd21271 | 381 | minNew > maxNew ) |
32b8ec41 VZ |
382 | { |
383 | wxLogWarning(_T("Invalid min/max values for the spinbtn.")); | |
384 | ||
385 | return; | |
386 | } | |
387 | ||
388 | m_min = minNew; | |
389 | m_max = maxNew; | |
390 | ||
391 | m_spinbtn->SetRange(minNew, maxNew); | |
392 | m_spinctrl->SetRange(minNew, maxNew); | |
8cd6a9ad | 393 | m_spinctrldbl->SetRange(minNew, maxNew); |
32b8ec41 VZ |
394 | } |
395 | ||
396 | void SpinBtnWidgetsPage::OnButtonSetValue(wxCommandEvent& WXUNUSED(event)) | |
397 | { | |
398 | long val; | |
399 | if ( !m_textValue->GetValue().ToLong(&val) || !IsValidValue(val) ) | |
400 | { | |
401 | wxLogWarning(_T("Invalid spinbtn value.")); | |
402 | ||
403 | return; | |
404 | } | |
405 | ||
406 | m_spinbtn->SetValue(val); | |
407 | m_spinctrl->SetValue(val); | |
8cd6a9ad | 408 | m_spinctrldbl->SetValue(val); |
32b8ec41 VZ |
409 | } |
410 | ||
411 | void SpinBtnWidgetsPage::OnUpdateUIValueButton(wxUpdateUIEvent& event) | |
412 | { | |
413 | long val; | |
414 | event.Enable( m_textValue->GetValue().ToLong(&val) && IsValidValue(val) ); | |
415 | } | |
416 | ||
417 | void SpinBtnWidgetsPage::OnUpdateUIMinMaxButton(wxUpdateUIEvent& event) | |
418 | { | |
419 | long mn, mx; | |
420 | event.Enable( m_textMin->GetValue().ToLong(&mn) && | |
421 | m_textMax->GetValue().ToLong(&mx) && | |
6dd21271 | 422 | mn <= mx); |
32b8ec41 VZ |
423 | } |
424 | ||
425 | void SpinBtnWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event) | |
426 | { | |
242ec2f7 VZ |
427 | event.Enable( !m_chkVert->GetValue() || |
428 | m_chkWrap->GetValue() || | |
429 | m_chkProcessEnter->GetValue() ); | |
32b8ec41 VZ |
430 | } |
431 | ||
c02e5a31 | 432 | void SpinBtnWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event)) |
32b8ec41 VZ |
433 | { |
434 | CreateSpin(); | |
435 | } | |
436 | ||
437 | void SpinBtnWidgetsPage::OnUpdateUICurValueText(wxUpdateUIEvent& event) | |
438 | { | |
439 | event.SetText( wxString::Format(_T("%d"), m_spinbtn->GetValue())); | |
440 | } | |
441 | ||
0a3d26b8 | 442 | void SpinBtnWidgetsPage::OnSpinBtn(wxSpinEvent& event) |
32b8ec41 VZ |
443 | { |
444 | int value = event.GetInt(); | |
445 | ||
446 | wxASSERT_MSG( value == m_spinbtn->GetValue(), | |
447 | _T("spinbtn value should be the same") ); | |
448 | ||
449 | wxLogMessage(_T("Spin button value changed, now %d"), value); | |
450 | } | |
451 | ||
0a3d26b8 | 452 | void SpinBtnWidgetsPage::OnSpinBtnUp(wxSpinEvent& event) |
32b8ec41 | 453 | { |
33cf9a19 | 454 | wxLogMessage( _T("Spin button value incremented, will be %d (was %d)"), |
aec18ff7 | 455 | event.GetInt(), m_spinbtn->GetValue() ); |
32b8ec41 VZ |
456 | } |
457 | ||
0a3d26b8 | 458 | void SpinBtnWidgetsPage::OnSpinBtnDown(wxSpinEvent& event) |
32b8ec41 | 459 | { |
33cf9a19 | 460 | wxLogMessage( _T("Spin button value decremented, will be %d (was %d)"), |
aec18ff7 | 461 | event.GetInt(), m_spinbtn->GetValue() ); |
32b8ec41 VZ |
462 | } |
463 | ||
0a3d26b8 | 464 | void SpinBtnWidgetsPage::OnSpinCtrl(wxSpinEvent& event) |
32b8ec41 VZ |
465 | { |
466 | int value = event.GetInt(); | |
467 | ||
468 | wxASSERT_MSG( value == m_spinctrl->GetValue(), | |
469 | _T("spinctrl value should be the same") ); | |
470 | ||
471 | wxLogMessage(_T("Spin control value changed, now %d"), value); | |
472 | } | |
6ceb105f | 473 | |
8cd6a9ad VZ |
474 | void SpinBtnWidgetsPage::OnSpinCtrlDouble(wxSpinDoubleEvent& event) |
475 | { | |
476 | double value = event.GetValue(); | |
477 | ||
478 | wxLogMessage(_T("Spin control value changed, now %g"), value); | |
479 | } | |
480 | ||
6ceb105f VZ |
481 | void SpinBtnWidgetsPage::OnSpinText(wxCommandEvent& event) |
482 | { | |
483 | wxLogMessage(_T("Text changed in spin control, now \"%s\""), | |
484 | event.GetString().c_str()); | |
485 | } | |
486 | ||
952ff7bc VZ |
487 | void SpinBtnWidgetsPage::OnSpinTextEnter(wxCommandEvent& event) |
488 | { | |
489 | wxLogMessage("\"Enter\" pressed in spin control, text is \"%s\"", | |
490 | event.GetString()); | |
491 | } | |
492 | ||
6ceb105f | 493 | #endif // wxUSE_SPINBTN |