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