]> git.saurik.com Git - wxWidgets.git/blame - samples/widgets/spinbtn.cpp
Fix wrong configure test for abi::__forced_unwind in previous commit.
[wxWidgets.git] / samples / widgets / spinbtn.cpp
CommitLineData
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
526954c5 9// Licence: wxWindows licence
32b8ec41
VZ
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
55enum
56{
f0fa4312 57 SpinBtnPage_Reset = wxID_HIGHEST,
32b8ec41
VZ
58 SpinBtnPage_Clear,
59 SpinBtnPage_SetValue,
60 SpinBtnPage_SetMinAndMax,
9e565667 61 SpinBtnPage_SetBase,
32b8ec41
VZ
62 SpinBtnPage_CurValueText,
63 SpinBtnPage_ValueText,
64 SpinBtnPage_MinText,
65 SpinBtnPage_MaxText,
9e565667 66 SpinBtnPage_BaseText,
32b8ec41 67 SpinBtnPage_SpinBtn,
8cd6a9ad
VZ
68 SpinBtnPage_SpinCtrl,
69 SpinBtnPage_SpinCtrlDouble
32b8ec41
VZ
70};
71
7e4952db
VZ
72// alignment radiobox values
73enum
74{
75 Align_Left,
76 Align_Centre,
77 Align_Right
78};
79
32b8ec41
VZ
80// ----------------------------------------------------------------------------
81// SpinBtnWidgetsPage
82// ----------------------------------------------------------------------------
83
84class SpinBtnWidgetsPage : public WidgetsPage
85{
86public:
f2fdc4d5 87 SpinBtnWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist);
8f6eaec9 88 virtual ~SpinBtnWidgetsPage(){};
32b8ec41 89
195df7a7 90 virtual wxControl *GetWidget() const { return m_spinbtn; }
ca288f2a
VZ
91 virtual Widgets GetWidgets() const
92 {
93 Widgets widgets(WidgetsPage::GetWidgets());
94 widgets.push_back(m_spinctrl);
95 widgets.push_back(m_spinctrldbl);
96 return widgets;
97 }
98
1301e228 99 virtual void RecreateWidget() { CreateSpin(); }
195df7a7 100
453535a7
WS
101 // lazy creation of the content
102 virtual void CreateContent();
103
32b8ec41
VZ
104protected:
105 // event handlers
106 void OnButtonReset(wxCommandEvent& event);
107 void OnButtonClear(wxCommandEvent& event);
108 void OnButtonSetValue(wxCommandEvent& event);
109 void OnButtonSetMinAndMax(wxCommandEvent& event);
9e565667 110 void OnButtonSetBase(wxCommandEvent& event);
32b8ec41
VZ
111
112 void OnCheckOrRadioBox(wxCommandEvent& event);
113
0a3d26b8
VZ
114 void OnSpinBtn(wxSpinEvent& event);
115 void OnSpinBtnUp(wxSpinEvent& event);
116 void OnSpinBtnDown(wxSpinEvent& event);
117 void OnSpinCtrl(wxSpinEvent& event);
8cd6a9ad 118 void OnSpinCtrlDouble(wxSpinDoubleEvent& event);
6ceb105f 119 void OnSpinText(wxCommandEvent& event);
952ff7bc 120 void OnSpinTextEnter(wxCommandEvent& event);
32b8ec41
VZ
121
122 void OnUpdateUIValueButton(wxUpdateUIEvent& event);
123 void OnUpdateUIMinMaxButton(wxUpdateUIEvent& event);
9e565667 124 void OnUpdateUIBaseButton(wxUpdateUIEvent& event);
32b8ec41
VZ
125
126 void OnUpdateUIResetButton(wxUpdateUIEvent& event);
127
128 void OnUpdateUICurValueText(wxUpdateUIEvent& event);
129
130 // reset the spinbtn parameters
131 void Reset();
132
133 // (re)create the spinbtn
134 void CreateSpin();
135
136 // is this spinbtn value in range?
137 bool IsValidValue(int val) const
138 { return (val >= m_min) && (val <= m_max); }
139
140 // the spinbtn range
141 int m_min, m_max;
142
9e565667
VZ
143 // and numeric base
144 int m_base;
145
32b8ec41
VZ
146 // the controls
147 // ------------
148
149 // the check/radio boxes for styles
150 wxCheckBox *m_chkVert,
fd07e185 151 *m_chkArrowKeys,
242ec2f7
VZ
152 *m_chkWrap,
153 *m_chkProcessEnter;
9e565667 154 wxRadioBox *m_radioAlign;
32b8ec41
VZ
155
156 // the spinbtn and the spinctrl and the sizer containing them
157 wxSpinButton *m_spinbtn;
158 wxSpinCtrl *m_spinctrl;
8cd6a9ad 159 wxSpinCtrlDouble *m_spinctrldbl;
32b8ec41
VZ
160
161 wxSizer *m_sizerSpin;
162
163 // the text entries for set value/range
164 wxTextCtrl *m_textValue,
165 *m_textMin,
9e565667
VZ
166 *m_textMax,
167 *m_textBase;
32b8ec41
VZ
168
169private:
5e173f35
GD
170 DECLARE_EVENT_TABLE()
171 DECLARE_WIDGETS_PAGE(SpinBtnWidgetsPage)
32b8ec41
VZ
172};
173
174// ----------------------------------------------------------------------------
175// event tables
176// ----------------------------------------------------------------------------
177
178BEGIN_EVENT_TABLE(SpinBtnWidgetsPage, WidgetsPage)
179 EVT_BUTTON(SpinBtnPage_Reset, SpinBtnWidgetsPage::OnButtonReset)
180 EVT_BUTTON(SpinBtnPage_SetValue, SpinBtnWidgetsPage::OnButtonSetValue)
181 EVT_BUTTON(SpinBtnPage_SetMinAndMax, SpinBtnWidgetsPage::OnButtonSetMinAndMax)
9e565667 182 EVT_BUTTON(SpinBtnPage_SetBase, SpinBtnWidgetsPage::OnButtonSetBase)
32b8ec41
VZ
183
184 EVT_UPDATE_UI(SpinBtnPage_SetValue, SpinBtnWidgetsPage::OnUpdateUIValueButton)
185 EVT_UPDATE_UI(SpinBtnPage_SetMinAndMax, SpinBtnWidgetsPage::OnUpdateUIMinMaxButton)
9e565667 186 EVT_UPDATE_UI(SpinBtnPage_SetBase, SpinBtnWidgetsPage::OnUpdateUIBaseButton)
32b8ec41
VZ
187
188 EVT_UPDATE_UI(SpinBtnPage_Reset, SpinBtnWidgetsPage::OnUpdateUIResetButton)
189
190 EVT_UPDATE_UI(SpinBtnPage_CurValueText, SpinBtnWidgetsPage::OnUpdateUICurValueText)
191
192 EVT_SPIN(SpinBtnPage_SpinBtn, SpinBtnWidgetsPage::OnSpinBtn)
193 EVT_SPIN_UP(SpinBtnPage_SpinBtn, SpinBtnWidgetsPage::OnSpinBtnUp)
194 EVT_SPIN_DOWN(SpinBtnPage_SpinBtn, SpinBtnWidgetsPage::OnSpinBtnDown)
195 EVT_SPINCTRL(SpinBtnPage_SpinCtrl, SpinBtnWidgetsPage::OnSpinCtrl)
8cd6a9ad 196 EVT_SPINCTRLDOUBLE(SpinBtnPage_SpinCtrlDouble, SpinBtnWidgetsPage::OnSpinCtrlDouble)
6ceb105f 197 EVT_TEXT(SpinBtnPage_SpinCtrl, SpinBtnWidgetsPage::OnSpinText)
952ff7bc 198 EVT_TEXT_ENTER(SpinBtnPage_SpinCtrl, SpinBtnWidgetsPage::OnSpinTextEnter)
8cd6a9ad 199 EVT_TEXT(SpinBtnPage_SpinCtrlDouble, SpinBtnWidgetsPage::OnSpinText)
9bd25c86 200 EVT_TEXT_ENTER(SpinBtnPage_SpinCtrlDouble, SpinBtnWidgetsPage::OnSpinTextEnter)
32b8ec41 201
206d3a16
JS
202 EVT_CHECKBOX(wxID_ANY, SpinBtnWidgetsPage::OnCheckOrRadioBox)
203 EVT_RADIOBOX(wxID_ANY, SpinBtnWidgetsPage::OnCheckOrRadioBox)
32b8ec41
VZ
204END_EVENT_TABLE()
205
206// ============================================================================
207// implementation
208// ============================================================================
209
f0fa4312
WS
210#if defined(__WXUNIVERSAL__)
211 #define FAMILY_CTRLS UNIVERSAL_CTRLS
212#else
213 #define FAMILY_CTRLS NATIVE_CTRLS
214#endif
215
9a83f860 216IMPLEMENT_WIDGETS_PAGE(SpinBtnWidgetsPage, wxT("Spin"),
f0fa4312 217 FAMILY_CTRLS | EDITABLE_CTRLS
f2fdc4d5 218 );
32b8ec41 219
f2fdc4d5 220SpinBtnWidgetsPage::SpinBtnWidgetsPage(WidgetsBookCtrl *book,
32b8ec41 221 wxImageList *imaglist)
261357eb 222 : WidgetsPage(book, imaglist, spinbtn_xpm)
32b8ec41 223{
59b9edf0 224 m_chkVert = NULL;
fd07e185 225 m_chkArrowKeys = NULL;
59b9edf0 226 m_chkWrap = NULL;
242ec2f7 227 m_chkProcessEnter = NULL;
7e4952db 228 m_radioAlign = NULL;
59b9edf0
JS
229 m_spinbtn = NULL;
230 m_spinctrl = NULL;
8cd6a9ad 231 m_spinctrldbl = NULL;
9e565667
VZ
232 m_textValue =
233 m_textMin =
234 m_textMax =
235 m_textBase = NULL;
32b8ec41 236
32b8ec41
VZ
237 m_min = 0;
238 m_max = 10;
239
9e565667
VZ
240 m_base = 10;
241
242ec2f7 242 m_sizerSpin = NULL;
453535a7 243}
32b8ec41 244
453535a7
WS
245void SpinBtnWidgetsPage::CreateContent()
246{
32b8ec41
VZ
247 wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
248
249 // left pane
9a83f860 250 wxStaticBox *box = new wxStaticBox(this, wxID_ANY, wxT("&Set style"));
32b8ec41
VZ
251 wxSizer *sizerLeft = new wxStaticBoxSizer(box, wxVERTICAL);
252
9a83f860
VZ
253 m_chkVert = CreateCheckBoxAndAddToSizer(sizerLeft, wxT("&Vertical"));
254 m_chkArrowKeys = CreateCheckBoxAndAddToSizer(sizerLeft, wxT("&Arrow Keys"));
255 m_chkWrap = CreateCheckBoxAndAddToSizer(sizerLeft, wxT("&Wrap"));
242ec2f7 256 m_chkProcessEnter = CreateCheckBoxAndAddToSizer(sizerLeft,
9a83f860 257 wxT("Process &Enter"));
32b8ec41
VZ
258
259 sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer
260
7e4952db
VZ
261 static const wxString halign[] =
262 {
9a83f860
VZ
263 wxT("left"),
264 wxT("centre"),
265 wxT("right"),
7e4952db
VZ
266 };
267
9a83f860 268 m_radioAlign = new wxRadioBox(this, wxID_ANY, wxT("&Text alignment"),
7e4952db
VZ
269 wxDefaultPosition, wxDefaultSize,
270 WXSIZEOF(halign), halign, 1);
271
272 sizerLeft->Add(m_radioAlign, 0, wxGROW | wxALL, 5);
273
274 sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer
275
9a83f860 276 wxButton *btn = new wxButton(this, SpinBtnPage_Reset, wxT("&Reset"));
32b8ec41
VZ
277 sizerLeft->Add(btn, 0, wxALIGN_CENTRE_HORIZONTAL | wxALL, 15);
278
279 // middle pane
206d3a16 280 wxStaticBox *box2 = new wxStaticBox(this, wxID_ANY,
9a83f860 281 wxT("&Change spinbtn value"));
206d3a16 282
32b8ec41
VZ
283 wxSizer *sizerMiddle = new wxStaticBoxSizer(box2, wxVERTICAL);
284
285 wxTextCtrl *text;
9a83f860 286 wxSizer *sizerRow = CreateSizerWithTextAndLabel(wxT("Current value"),
32b8ec41
VZ
287 SpinBtnPage_CurValueText,
288 &text);
206d3a16 289 text->SetEditable(false);
32b8ec41
VZ
290
291 sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
292
293 sizerRow = CreateSizerWithTextAndButton(SpinBtnPage_SetValue,
9a83f860 294 wxT("Set &value"),
32b8ec41
VZ
295 SpinBtnPage_ValueText,
296 &m_textValue);
297 sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
298
299 sizerRow = CreateSizerWithTextAndButton(SpinBtnPage_SetMinAndMax,
9a83f860 300 wxT("&Min and max"),
32b8ec41
VZ
301 SpinBtnPage_MinText,
302 &m_textMin);
303
206d3a16 304 m_textMax = new wxTextCtrl(this, SpinBtnPage_MaxText, wxEmptyString);
32b8ec41
VZ
305 sizerRow->Add(m_textMax, 1, wxLEFT | wxALIGN_CENTRE_VERTICAL, 5);
306
9a83f860
VZ
307 m_textMin->SetValue( wxString::Format(wxT("%d"), m_min) );
308 m_textMax->SetValue( wxString::Format(wxT("%d"), m_max) );
32b8ec41
VZ
309
310 sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
311
9e565667
VZ
312 sizerRow = CreateSizerWithTextAndButton(SpinBtnPage_SetBase,
313 "Set &base",
314 SpinBtnPage_BaseText,
315 &m_textBase);
316 m_textBase->SetValue("10");
317 sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
318
32b8ec41
VZ
319 // right pane
320 wxSizer *sizerRight = new wxBoxSizer(wxVERTICAL);
7b127900 321 sizerRight->SetMinSize(150, 0);
32b8ec41
VZ
322 m_sizerSpin = sizerRight; // save it to modify it later
323
324 Reset();
325 CreateSpin();
326
327 // the 3 panes panes compose the window
328 sizerTop->Add(sizerLeft, 0, wxGROW | (wxALL & ~wxLEFT), 10);
7b127900 329 sizerTop->Add(sizerMiddle, 0, wxGROW | wxALL, 10);
32b8ec41
VZ
330 sizerTop->Add(sizerRight, 1, wxGROW | (wxALL & ~wxRIGHT), 10);
331
332 // final initializations
32b8ec41 333 SetSizer(sizerTop);
32b8ec41
VZ
334}
335
32b8ec41
VZ
336// ----------------------------------------------------------------------------
337// operations
338// ----------------------------------------------------------------------------
339
340void SpinBtnWidgetsPage::Reset()
341{
206d3a16 342 m_chkVert->SetValue(true);
fd07e185 343 m_chkArrowKeys->SetValue(true);
206d3a16 344 m_chkWrap->SetValue(false);
242ec2f7 345 m_chkProcessEnter->SetValue(false);
7e4952db 346 m_radioAlign->SetSelection(Align_Right);
32b8ec41
VZ
347}
348
349void SpinBtnWidgetsPage::CreateSpin()
350{
1301e228 351 int flags = ms_defaultFlags;
32b8ec41
VZ
352
353 bool isVert = m_chkVert->GetValue();
354 if ( isVert )
355 flags |= wxSP_VERTICAL;
356 else
357 flags |= wxSP_HORIZONTAL;
358
fd07e185
VZ
359 if ( m_chkArrowKeys->GetValue() )
360 flags |= wxSP_ARROW_KEYS;
361
32b8ec41
VZ
362 if ( m_chkWrap->GetValue() )
363 flags |= wxSP_WRAP;
364
242ec2f7
VZ
365 if ( m_chkProcessEnter->GetValue() )
366 flags |= wxTE_PROCESS_ENTER;
367
7e4952db
VZ
368 int textFlags = 0;
369 switch ( m_radioAlign->GetSelection() )
370 {
371 default:
9a83f860 372 wxFAIL_MSG(wxT("unexpected radiobox selection"));
7e4952db
VZ
373 // fall through
374
375 case Align_Left:
376 textFlags |= wxALIGN_LEFT; // no-op
377 break;
378
379 case Align_Centre:
380 textFlags |= wxALIGN_CENTRE_HORIZONTAL;
381 break;
382
383 case Align_Right:
384 textFlags |= wxALIGN_RIGHT;
385 break;
386 }
387
32b8ec41
VZ
388 int val = m_min;
389 if ( m_spinbtn )
390 {
391 int valOld = m_spinbtn->GetValue();
392 if ( !IsValidValue(valOld) )
393 {
394 val = valOld;
395 }
396
55ab5200 397 m_sizerSpin->Clear(true /* delete windows */);
32b8ec41
VZ
398 }
399
400 m_spinbtn = new wxSpinButton(this, SpinBtnPage_SpinBtn,
401 wxDefaultPosition, wxDefaultSize,
402 flags);
403
404 m_spinbtn->SetValue(val);
405 m_spinbtn->SetRange(m_min, m_max);
406
407 m_spinctrl = new wxSpinCtrl(this, SpinBtnPage_SpinCtrl,
9a83f860 408 wxString::Format(wxT("%d"), val),
32b8ec41 409 wxDefaultPosition, wxDefaultSize,
7e4952db 410 flags | textFlags,
32b8ec41
VZ
411 m_min, m_max, val);
412
8cd6a9ad 413 m_spinctrldbl = new wxSpinCtrlDouble(this, SpinBtnPage_SpinCtrlDouble,
9a83f860 414 wxString::Format(wxT("%d"), val),
8cd6a9ad 415 wxDefaultPosition, wxDefaultSize,
7e4952db 416 flags | textFlags,
8cd6a9ad
VZ
417 m_min, m_max, val, 0.1);
418
2a998b73 419 // Add spacers, labels and spin controls to the sizer.
32b8ec41 420 m_sizerSpin->Add(0, 0, 1);
2a998b73
VZ
421 m_sizerSpin->Add(new wxStaticText(this, wxID_ANY, wxT("wxSpinButton")),
422 0, wxALIGN_CENTRE | wxALL, 5);
32b8ec41
VZ
423 m_sizerSpin->Add(m_spinbtn, 0, wxALIGN_CENTRE | wxALL, 5);
424 m_sizerSpin->Add(0, 0, 1);
2a998b73
VZ
425 m_sizerSpin->Add(new wxStaticText(this, wxID_ANY, wxT("wxSpinCtrl")),
426 0, wxALIGN_CENTRE | wxALL, 5);
32b8ec41
VZ
427 m_sizerSpin->Add(m_spinctrl, 0, wxALIGN_CENTRE | wxALL, 5);
428 m_sizerSpin->Add(0, 0, 1);
2a998b73
VZ
429 m_sizerSpin->Add(new wxStaticText(this, wxID_ANY, wxT("wxSpinCtrlDouble")),
430 0, wxALIGN_CENTRE | wxALL, 5);
8cd6a9ad
VZ
431 m_sizerSpin->Add(m_spinctrldbl, 0, wxALIGN_CENTRE | wxALL, 5);
432 m_sizerSpin->Add(0, 0, 1);
32b8ec41
VZ
433
434 m_sizerSpin->Layout();
435}
436
437// ----------------------------------------------------------------------------
438// event handlers
439// ----------------------------------------------------------------------------
440
441void SpinBtnWidgetsPage::OnButtonReset(wxCommandEvent& WXUNUSED(event))
442{
443 Reset();
444
445 CreateSpin();
446}
447
448void SpinBtnWidgetsPage::OnButtonSetMinAndMax(wxCommandEvent& WXUNUSED(event))
449{
450 long minNew,
451 maxNew = 0; // init to suppress compiler warning
452 if ( !m_textMin->GetValue().ToLong(&minNew) ||
453 !m_textMax->GetValue().ToLong(&maxNew) ||
6dd21271 454 minNew > maxNew )
32b8ec41 455 {
9a83f860 456 wxLogWarning(wxT("Invalid min/max values for the spinbtn."));
32b8ec41
VZ
457
458 return;
459 }
460
461 m_min = minNew;
462 m_max = maxNew;
463
464 m_spinbtn->SetRange(minNew, maxNew);
465 m_spinctrl->SetRange(minNew, maxNew);
8cd6a9ad 466 m_spinctrldbl->SetRange(minNew, maxNew);
32b8ec41
VZ
467}
468
9e565667
VZ
469void SpinBtnWidgetsPage::OnButtonSetBase(wxCommandEvent& WXUNUSED(event))
470{
471 unsigned long base;
472 if ( !m_textBase->GetValue().ToULong(&base) || !base )
473 {
474 wxLogWarning("Invalid base value.");
475 return;
476 }
477
478 m_base = base;
479 if ( !m_spinctrl->SetBase(m_base) )
480 {
481 wxLogWarning("Setting base %d failed.", m_base);
482 }
483}
484
32b8ec41
VZ
485void SpinBtnWidgetsPage::OnButtonSetValue(wxCommandEvent& WXUNUSED(event))
486{
487 long val;
488 if ( !m_textValue->GetValue().ToLong(&val) || !IsValidValue(val) )
489 {
9a83f860 490 wxLogWarning(wxT("Invalid spinbtn value."));
32b8ec41
VZ
491
492 return;
493 }
494
495 m_spinbtn->SetValue(val);
496 m_spinctrl->SetValue(val);
8cd6a9ad 497 m_spinctrldbl->SetValue(val);
32b8ec41
VZ
498}
499
500void SpinBtnWidgetsPage::OnUpdateUIValueButton(wxUpdateUIEvent& event)
501{
502 long val;
503 event.Enable( m_textValue->GetValue().ToLong(&val) && IsValidValue(val) );
504}
505
506void SpinBtnWidgetsPage::OnUpdateUIMinMaxButton(wxUpdateUIEvent& event)
507{
508 long mn, mx;
509 event.Enable( m_textMin->GetValue().ToLong(&mn) &&
510 m_textMax->GetValue().ToLong(&mx) &&
6dd21271 511 mn <= mx);
32b8ec41
VZ
512}
513
9e565667
VZ
514void SpinBtnWidgetsPage::OnUpdateUIBaseButton(wxUpdateUIEvent& event)
515{
516 unsigned long base;
517 event.Enable( m_textBase->GetValue().ToULong(&base) && base );
518}
519
32b8ec41
VZ
520void SpinBtnWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
521{
242ec2f7
VZ
522 event.Enable( !m_chkVert->GetValue() ||
523 m_chkWrap->GetValue() ||
524 m_chkProcessEnter->GetValue() );
32b8ec41
VZ
525}
526
c02e5a31 527void SpinBtnWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
32b8ec41
VZ
528{
529 CreateSpin();
530}
531
532void SpinBtnWidgetsPage::OnUpdateUICurValueText(wxUpdateUIEvent& event)
533{
9a83f860 534 event.SetText( wxString::Format(wxT("%d"), m_spinbtn->GetValue()));
32b8ec41
VZ
535}
536
0a3d26b8 537void SpinBtnWidgetsPage::OnSpinBtn(wxSpinEvent& event)
32b8ec41
VZ
538{
539 int value = event.GetInt();
540
541 wxASSERT_MSG( value == m_spinbtn->GetValue(),
9a83f860 542 wxT("spinbtn value should be the same") );
32b8ec41 543
9a83f860 544 wxLogMessage(wxT("Spin button value changed, now %d"), value);
32b8ec41
VZ
545}
546
0a3d26b8 547void SpinBtnWidgetsPage::OnSpinBtnUp(wxSpinEvent& event)
32b8ec41 548{
9a83f860 549 wxLogMessage( wxT("Spin button value incremented, will be %d (was %d)"),
aec18ff7 550 event.GetInt(), m_spinbtn->GetValue() );
32b8ec41
VZ
551}
552
0a3d26b8 553void SpinBtnWidgetsPage::OnSpinBtnDown(wxSpinEvent& event)
32b8ec41 554{
9a83f860 555 wxLogMessage( wxT("Spin button value decremented, will be %d (was %d)"),
aec18ff7 556 event.GetInt(), m_spinbtn->GetValue() );
32b8ec41
VZ
557}
558
0a3d26b8 559void SpinBtnWidgetsPage::OnSpinCtrl(wxSpinEvent& event)
32b8ec41
VZ
560{
561 int value = event.GetInt();
562
563 wxASSERT_MSG( value == m_spinctrl->GetValue(),
9a83f860 564 wxT("spinctrl value should be the same") );
32b8ec41 565
9a83f860 566 wxLogMessage(wxT("Spin control value changed, now %d"), value);
32b8ec41 567}
6ceb105f 568
8cd6a9ad
VZ
569void SpinBtnWidgetsPage::OnSpinCtrlDouble(wxSpinDoubleEvent& event)
570{
571 double value = event.GetValue();
572
9a83f860 573 wxLogMessage(wxT("Spin control value changed, now %g"), value);
8cd6a9ad
VZ
574}
575
6ceb105f
VZ
576void SpinBtnWidgetsPage::OnSpinText(wxCommandEvent& event)
577{
9a83f860 578 wxLogMessage(wxT("Text changed in spin control, now \"%s\""),
6ceb105f
VZ
579 event.GetString().c_str());
580}
581
952ff7bc
VZ
582void SpinBtnWidgetsPage::OnSpinTextEnter(wxCommandEvent& event)
583{
584 wxLogMessage("\"Enter\" pressed in spin control, text is \"%s\"",
585 event.GetString());
586}
587
6ceb105f 588#endif // wxUSE_SPINBTN