]> git.saurik.com Git - wxWidgets.git/blame - samples/widgets/slider.cpp
fix for potential crash when conversion fails
[wxWidgets.git] / samples / widgets / slider.cpp
CommitLineData
32b8ec41 1/////////////////////////////////////////////////////////////////////////////
be5a51fb 2// Program: wxWidgets Widgets Sample
32b8ec41
VZ
3// Name: slider.cpp
4// Purpose: Part of the widgets sample showing wxSlider
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_SLIDER
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/slider.h"
38 #include "wx/statbox.h"
39 #include "wx/textctrl.h"
40#endif
41
53b98211
JS
42#if wxUSE_TOOLTIPS
43 #include "wx/tooltip.h"
44#endif
45
32b8ec41
VZ
46#include "wx/sizer.h"
47
48#include "widgets.h"
61c083e7 49
32b8ec41
VZ
50#include "icons/slider.xpm"
51
52// ----------------------------------------------------------------------------
53// constants
54// ----------------------------------------------------------------------------
55
56// control ids
57enum
58{
d79b005a 59 SliderPage_Reset = wxID_HIGHEST,
32b8ec41
VZ
60 SliderPage_Clear,
61 SliderPage_SetValue,
62 SliderPage_SetMinAndMax,
63 SliderPage_SetTickFreq,
53b98211 64 SliderPage_SetThumbLen,
32b8ec41
VZ
65 SliderPage_CurValueText,
66 SliderPage_ValueText,
67 SliderPage_MinText,
68 SliderPage_MaxText,
69 SliderPage_TickFreqText,
53b98211
JS
70 SliderPage_ThumbLenText,
71 SliderPage_RadioSides,
72 SliderPage_BothSides,
32b8ec41
VZ
73 SliderPage_Slider
74};
75
53b98211
JS
76// sides radiobox values
77enum
78{
93103bab
VZ
79 SliderTicks_Top,
80 SliderTicks_Bottom,
81 SliderTicks_Left,
82 SliderTicks_Right
53b98211
JS
83};
84
32b8ec41
VZ
85// ----------------------------------------------------------------------------
86// SliderWidgetsPage
87// ----------------------------------------------------------------------------
88
89class SliderWidgetsPage : public WidgetsPage
90{
91public:
f2fdc4d5 92 SliderWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist);
8f6eaec9 93 virtual ~SliderWidgetsPage(){};
32b8ec41 94
195df7a7 95 virtual wxControl *GetWidget() const { return m_slider; }
1301e228 96 virtual void RecreateWidget() { CreateSlider(); }
195df7a7 97
453535a7
WS
98 // lazy creation of the content
99 virtual void CreateContent();
100
32b8ec41
VZ
101protected:
102 // event handlers
103 void OnButtonReset(wxCommandEvent& event);
104 void OnButtonClear(wxCommandEvent& event);
105 void OnButtonSetValue(wxCommandEvent& event);
106 void OnButtonSetMinAndMax(wxCommandEvent& event);
107 void OnButtonSetTickFreq(wxCommandEvent& event);
53b98211 108 void OnButtonSetThumbLen(wxCommandEvent& event);
32b8ec41
VZ
109
110 void OnCheckOrRadioBox(wxCommandEvent& event);
111
d79b005a 112 void OnSlider(wxScrollEvent& event);
32b8ec41 113
32b8ec41
VZ
114 void OnUpdateUIValueButton(wxUpdateUIEvent& event);
115 void OnUpdateUIMinMaxButton(wxUpdateUIEvent& event);
116 void OnUpdateUITickFreq(wxUpdateUIEvent& event);
53b98211
JS
117 void OnUpdateUIThumbLen(wxUpdateUIEvent& event);
118 void OnUpdateUIRadioSides(wxUpdateUIEvent& event);
119 void OnUpdateUIBothSides(wxUpdateUIEvent& event);
32b8ec41
VZ
120
121 void OnUpdateUIResetButton(wxUpdateUIEvent& event);
122
123 void OnUpdateUICurValueText(wxUpdateUIEvent& event);
124
125 // reset the slider parameters
126 void Reset();
127
128 // (re)create the slider
129 void CreateSlider();
130
131 // set the tick frequency from the text field value
132 void DoSetTickFreq();
133
53b98211
JS
134 // set the thumb len from the text field value
135 void DoSetThumbLen();
136
32b8ec41
VZ
137 // is this slider value in range?
138 bool IsValidValue(int val) const
139 { return (val >= m_min) && (val <= m_max); }
140
141 // the slider range
142 int m_min, m_max;
143
144 // the controls
145 // ------------
146
147 // the check/radio boxes for styles
148 wxCheckBox *m_chkLabels,
2bcdbe0f 149 *m_chkInverse,
53b98211
JS
150 *m_chkTicks,
151 *m_chkBothSides;
152
153 wxRadioBox *m_radioSides;
32b8ec41
VZ
154
155 // the slider itself and the sizer it is in
156 wxSlider *m_slider;
157 wxSizer *m_sizerSlider;
158
159 // the text entries for set value/range
160 wxTextCtrl *m_textValue,
161 *m_textMin,
162 *m_textMax,
53b98211
JS
163 *m_textTickFreq,
164 *m_textThumbLen;
32b8ec41
VZ
165
166private:
5e173f35
GD
167 DECLARE_EVENT_TABLE()
168 DECLARE_WIDGETS_PAGE(SliderWidgetsPage)
32b8ec41
VZ
169};
170
171// ----------------------------------------------------------------------------
172// event tables
173// ----------------------------------------------------------------------------
174
175BEGIN_EVENT_TABLE(SliderWidgetsPage, WidgetsPage)
176 EVT_BUTTON(SliderPage_Reset, SliderWidgetsPage::OnButtonReset)
177 EVT_BUTTON(SliderPage_SetValue, SliderWidgetsPage::OnButtonSetValue)
178 EVT_BUTTON(SliderPage_SetMinAndMax, SliderWidgetsPage::OnButtonSetMinAndMax)
179 EVT_BUTTON(SliderPage_SetTickFreq, SliderWidgetsPage::OnButtonSetTickFreq)
53b98211 180 EVT_BUTTON(SliderPage_SetThumbLen, SliderWidgetsPage::OnButtonSetThumbLen)
32b8ec41
VZ
181
182 EVT_UPDATE_UI(SliderPage_SetValue, SliderWidgetsPage::OnUpdateUIValueButton)
183 EVT_UPDATE_UI(SliderPage_SetMinAndMax, SliderWidgetsPage::OnUpdateUIMinMaxButton)
184 EVT_UPDATE_UI(SliderPage_SetTickFreq, SliderWidgetsPage::OnUpdateUITickFreq)
53b98211 185 EVT_UPDATE_UI(SliderPage_SetThumbLen, SliderWidgetsPage::OnUpdateUIThumbLen)
32b8ec41 186 EVT_UPDATE_UI(SliderPage_TickFreqText, SliderWidgetsPage::OnUpdateUITickFreq)
53b98211
JS
187 EVT_UPDATE_UI(SliderPage_RadioSides, SliderWidgetsPage::OnUpdateUIRadioSides)
188 EVT_UPDATE_UI(SliderPage_BothSides, SliderWidgetsPage::OnUpdateUIBothSides)
32b8ec41
VZ
189
190 EVT_UPDATE_UI(SliderPage_Reset, SliderWidgetsPage::OnUpdateUIResetButton)
191
192 EVT_UPDATE_UI(SliderPage_CurValueText, SliderWidgetsPage::OnUpdateUICurValueText)
193
d79b005a 194 EVT_COMMAND_SCROLL(SliderPage_Slider, SliderWidgetsPage::OnSlider)
32b8ec41 195
206d3a16
JS
196 EVT_CHECKBOX(wxID_ANY, SliderWidgetsPage::OnCheckOrRadioBox)
197 EVT_RADIOBOX(wxID_ANY, SliderWidgetsPage::OnCheckOrRadioBox)
32b8ec41
VZ
198END_EVENT_TABLE()
199
200// ============================================================================
201// implementation
202// ============================================================================
203
f0fa4312
WS
204#if defined(__WXUNIVERSAL__)
205 #define FAMILY_CTRLS UNIVERSAL_CTRLS
206#else
207 #define FAMILY_CTRLS NATIVE_CTRLS
208#endif
209
210IMPLEMENT_WIDGETS_PAGE(SliderWidgetsPage, _T("Slider"), FAMILY_CTRLS );
32b8ec41 211
f2fdc4d5 212SliderWidgetsPage::SliderWidgetsPage(WidgetsBookCtrl *book,
61c083e7 213 wxImageList *imaglist)
261357eb 214 : WidgetsPage(book, imaglist, slider_xpm)
32b8ec41 215{
32b8ec41
VZ
216 // init everything
217 m_min = 0;
218 m_max = 100;
219
dc3155f1 220 m_chkInverse =
32b8ec41
VZ
221 m_chkTicks =
222 m_chkLabels =
53b98211
JS
223 m_chkBothSides = (wxCheckBox *)NULL;
224
225 m_radioSides = (wxRadioBox *)NULL;
32b8ec41
VZ
226
227 m_slider = (wxSlider *)NULL;
228 m_sizerSlider = (wxSizer *)NULL;
453535a7 229}
32b8ec41 230
453535a7
WS
231void SliderWidgetsPage::CreateContent()
232{
32b8ec41
VZ
233 wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
234
235 // left pane
206d3a16 236 wxStaticBox *box = new wxStaticBox(this, wxID_ANY, _T("&Set style"));
32b8ec41
VZ
237 wxSizer *sizerLeft = new wxStaticBoxSizer(box, wxVERTICAL);
238
2bcdbe0f 239 m_chkInverse = CreateCheckBoxAndAddToSizer(sizerLeft, _T("&Inverse"));
32b8ec41
VZ
240 m_chkTicks = CreateCheckBoxAndAddToSizer(sizerLeft, _T("Show &ticks"));
241 m_chkLabels = CreateCheckBoxAndAddToSizer(sizerLeft, _T("Show &labels"));
53b98211
JS
242 static const wxString sides[] =
243 {
244 _T("top"),
245 _T("bottom"),
246 _T("left"),
247 _T("right"),
248 };
249 m_radioSides = new wxRadioBox(this, SliderPage_RadioSides, _T("&Ticks/Labels"),
250 wxDefaultPosition, wxDefaultSize,
251 WXSIZEOF(sides), sides,
252 1, wxRA_SPECIFY_COLS);
253 sizerLeft->Add(m_radioSides, 0, wxGROW | wxALL, 5);
254 m_chkBothSides = CreateCheckBoxAndAddToSizer
255 (sizerLeft, _T("&Both sides"), SliderPage_BothSides);
256#if wxUSE_TOOLTIPS
257 m_chkBothSides->SetToolTip( _T("\"Both sides\" is only supported \nin Win95 and Universal") );
258#endif // wxUSE_TOOLTIPS
32b8ec41
VZ
259
260 sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer
261
262 wxButton *btn = new wxButton(this, SliderPage_Reset, _T("&Reset"));
263 sizerLeft->Add(btn, 0, wxALIGN_CENTRE_HORIZONTAL | wxALL, 15);
264
265 // middle pane
206d3a16 266 wxStaticBox *box2 = new wxStaticBox(this, wxID_ANY, _T("&Change slider value"));
32b8ec41
VZ
267 wxSizer *sizerMiddle = new wxStaticBoxSizer(box2, wxVERTICAL);
268
269 wxTextCtrl *text;
270 wxSizer *sizerRow = CreateSizerWithTextAndLabel(_T("Current value"),
271 SliderPage_CurValueText,
272 &text);
206d3a16 273 text->SetEditable(false);
32b8ec41
VZ
274
275 sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
276
277 sizerRow = CreateSizerWithTextAndButton(SliderPage_SetValue,
278 _T("Set &value"),
279 SliderPage_ValueText,
280 &m_textValue);
281 sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
282
283 sizerRow = CreateSizerWithTextAndButton(SliderPage_SetMinAndMax,
284 _T("&Min and max"),
285 SliderPage_MinText,
286 &m_textMin);
287
206d3a16 288 m_textMax = new wxTextCtrl(this, SliderPage_MaxText, wxEmptyString);
32b8ec41
VZ
289 sizerRow->Add(m_textMax, 1, wxLEFT | wxALIGN_CENTRE_VERTICAL, 5);
290
aec18ff7
MB
291 m_textMin->SetValue( wxString::Format(_T("%d"), m_min) );
292 m_textMax->SetValue( wxString::Format(_T("%d"), m_max) );
32b8ec41
VZ
293
294 sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
295
296 sizerRow = CreateSizerWithTextAndButton(SliderPage_SetTickFreq,
297 _T("Tick &frequency"),
298 SliderPage_TickFreqText,
299 &m_textTickFreq);
300
301 m_textTickFreq->SetValue(_T("10"));
302
303 sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
304
53b98211 305 sizerRow = CreateSizerWithTextAndButton(SliderPage_SetThumbLen,
a0d9c6cb 306 _T("Thumb &length"),
53b98211
JS
307 SliderPage_ThumbLenText,
308 &m_textThumbLen);
309
310 sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
311
32b8ec41
VZ
312 // right pane
313 wxSizer *sizerRight = new wxBoxSizer(wxHORIZONTAL);
53b98211 314 sizerRight->SetMinSize(150, 40);
32b8ec41
VZ
315 m_sizerSlider = sizerRight; // save it to modify it later
316
317 Reset();
318 CreateSlider();
319
320 // the 3 panes panes compose the window
321 sizerTop->Add(sizerLeft, 0, wxGROW | (wxALL & ~wxLEFT), 10);
7b127900 322 sizerTop->Add(sizerMiddle, 0, wxGROW | wxALL, 10);
32b8ec41
VZ
323 sizerTop->Add(sizerRight, 1, wxGROW | (wxALL & ~wxRIGHT), 10);
324
325 // final initializations
32b8ec41
VZ
326 SetSizer(sizerTop);
327
328 sizerTop->Fit(this);
329}
330
32b8ec41
VZ
331// ----------------------------------------------------------------------------
332// operations
333// ----------------------------------------------------------------------------
334
335void SliderWidgetsPage::Reset()
336{
2bcdbe0f 337 m_chkInverse->SetValue(false);
206d3a16
JS
338 m_chkTicks->SetValue(true);
339 m_chkLabels->SetValue(true);
340 m_chkBothSides->SetValue(false);
53b98211 341
93103bab 342 m_radioSides->SetSelection(SliderTicks_Top);
32b8ec41
VZ
343}
344
345void SliderWidgetsPage::CreateSlider()
346{
1301e228 347 int flags = ms_defaultFlags;
32b8ec41 348
2bcdbe0f
KH
349 if ( m_chkInverse->GetValue() )
350 {
351 flags |= wxSL_INVERSE;
352 }
353
32b8ec41
VZ
354 if ( m_chkLabels->GetValue() )
355 {
356 flags |= wxSL_LABELS;
32b8ec41
VZ
357 }
358
359 if ( m_chkTicks->GetValue() )
360 {
361 flags |= wxSL_AUTOTICKS;
362 }
363
53b98211
JS
364 switch ( m_radioSides->GetSelection() )
365 {
93103bab 366 case SliderTicks_Top:
53b98211
JS
367 flags |= wxSL_TOP;
368 break;
93103bab
VZ
369
370 case SliderTicks_Left:
53b98211
JS
371 flags |= wxSL_LEFT;
372 break;
93103bab
VZ
373
374 case SliderTicks_Bottom:
53b98211
JS
375 flags |= wxSL_BOTTOM;
376 break;
93103bab
VZ
377
378 case SliderTicks_Right:
53b98211
JS
379 flags |= wxSL_RIGHT;
380 break;
93103bab 381
53b98211
JS
382 default:
383 wxFAIL_MSG(_T("unexpected radiobox selection"));
384 // fall through
385 }
386
387 if ( m_chkBothSides->GetValue() )
388 {
389 flags |= wxSL_BOTH;
390 }
391
32b8ec41
VZ
392 int val = m_min;
393 if ( m_slider )
394 {
395 int valOld = m_slider->GetValue();
396 if ( !IsValidValue(valOld) )
397 {
398 val = valOld;
399 }
400
12a3f227 401 m_sizerSlider->Detach( m_slider );
32b8ec41
VZ
402
403 if ( m_sizerSlider->GetChildren().GetCount() )
404 {
405 // we have 2 spacers, remove them too
9dd96c0f
VZ
406 m_sizerSlider->Remove( 0 );
407 m_sizerSlider->Remove( 0 );
32b8ec41
VZ
408 }
409
410 delete m_slider;
411 }
412
413 m_slider = new wxSlider(this, SliderPage_Slider,
414 val, m_min, m_max,
415 wxDefaultPosition, wxDefaultSize,
416 flags);
417
93103bab 418 if ( m_slider->HasFlag(wxSL_VERTICAL) )
32b8ec41
VZ
419 {
420 m_sizerSlider->Add(0, 0, 1);
421 m_sizerSlider->Add(m_slider, 0, wxGROW | wxALL, 5);
422 m_sizerSlider->Add(0, 0, 1);
423 }
424 else
425 {
426 m_sizerSlider->Add(m_slider, 1, wxCENTRE | wxALL, 5);
427 }
428
429 if ( m_chkTicks->GetValue() )
430 {
431 DoSetTickFreq();
432 }
433
434 m_sizerSlider->Layout();
435}
436
437void SliderWidgetsPage::DoSetTickFreq()
438{
439 long freq;
440 if ( !m_textTickFreq->GetValue().ToLong(&freq) )
441 {
442 wxLogWarning(_T("Invalid slider tick frequency"));
443
444 return;
445 }
446
447 m_slider->SetTickFreq(freq, 0 /* unused */);
448}
449
53b98211
JS
450void SliderWidgetsPage::DoSetThumbLen()
451{
452 long len;
453 if ( !m_textThumbLen->GetValue().ToLong(&len) )
454 {
a0d9c6cb 455 wxLogWarning(_T("Invalid slider thumb length"));
53b98211
JS
456
457 return;
458 }
459
460 m_slider->SetThumbLength(len);
461}
462
32b8ec41
VZ
463// ----------------------------------------------------------------------------
464// event handlers
465// ----------------------------------------------------------------------------
466
467void SliderWidgetsPage::OnButtonReset(wxCommandEvent& WXUNUSED(event))
468{
469 Reset();
470
471 CreateSlider();
472}
473
474void SliderWidgetsPage::OnButtonSetTickFreq(wxCommandEvent& WXUNUSED(event))
475{
476 DoSetTickFreq();
477}
478
53b98211
JS
479void SliderWidgetsPage::OnButtonSetThumbLen(wxCommandEvent& WXUNUSED(event))
480{
481 DoSetThumbLen();
482}
483
32b8ec41
VZ
484void SliderWidgetsPage::OnButtonSetMinAndMax(wxCommandEvent& WXUNUSED(event))
485{
486 long minNew,
487 maxNew = 0; // init to suppress compiler warning
488 if ( !m_textMin->GetValue().ToLong(&minNew) ||
489 !m_textMax->GetValue().ToLong(&maxNew) ||
490 minNew >= maxNew )
491 {
492 wxLogWarning(_T("Invalid min/max values for the slider."));
493
494 return;
495 }
496
497 m_min = minNew;
498 m_max = maxNew;
499
500 m_slider->SetRange(minNew, maxNew);
9690a439
WS
501
502 if ( m_slider->GetMin() != m_min ||
503 m_slider->GetMax() != m_max )
504 {
505 wxLogWarning(_T("Invalid range in slider."));
506 }
32b8ec41
VZ
507}
508
509void SliderWidgetsPage::OnButtonSetValue(wxCommandEvent& WXUNUSED(event))
510{
511 long val;
512 if ( !m_textValue->GetValue().ToLong(&val) || !IsValidValue(val) )
513 {
514 wxLogWarning(_T("Invalid slider value."));
515
516 return;
517 }
518
519 m_slider->SetValue(val);
520}
521
522void SliderWidgetsPage::OnUpdateUIValueButton(wxUpdateUIEvent& event)
523{
524 long val;
525 event.Enable( m_textValue->GetValue().ToLong(&val) && IsValidValue(val) );
526}
527
528void SliderWidgetsPage::OnUpdateUITickFreq(wxUpdateUIEvent& event)
529{
530 long freq;
531 event.Enable( m_chkTicks->GetValue() &&
532 m_textTickFreq->GetValue().ToLong(&freq) &&
533 (freq > 0) && (freq <= m_max - m_min) );
534}
535
53b98211
JS
536void SliderWidgetsPage::OnUpdateUIThumbLen(wxUpdateUIEvent& event)
537{
538 long val;
539 event.Enable( m_textThumbLen->GetValue().ToLong(&val));
540}
541
32b8ec41
VZ
542void SliderWidgetsPage::OnUpdateUIMinMaxButton(wxUpdateUIEvent& event)
543{
544 long mn, mx;
545 event.Enable( m_textMin->GetValue().ToLong(&mn) &&
546 m_textMax->GetValue().ToLong(&mx) &&
547 mn < mx);
548}
549
550void SliderWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
551{
93103bab 552 event.Enable( m_chkInverse->GetValue() ||
53b98211 553 !m_chkTicks->GetValue() ||
32b8ec41 554 !m_chkLabels->GetValue() ||
93103bab
VZ
555 m_chkBothSides->GetValue() ||
556 m_radioSides->GetSelection() != SliderTicks_Top );
32b8ec41
VZ
557}
558
c02e5a31 559void SliderWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
32b8ec41
VZ
560{
561 CreateSlider();
562}
563
564void SliderWidgetsPage::OnUpdateUICurValueText(wxUpdateUIEvent& event)
565{
aec18ff7 566 event.SetText( wxString::Format(_T("%d"), m_slider->GetValue()) );
32b8ec41
VZ
567}
568
53b98211
JS
569void SliderWidgetsPage::OnUpdateUIRadioSides(wxUpdateUIEvent& event)
570{
571 event.Enable( m_chkLabels->GetValue() || m_chkTicks->GetValue() );
572}
573
574void SliderWidgetsPage::OnUpdateUIBothSides(wxUpdateUIEvent& event)
32b8ec41 575{
a71d815b 576#if defined(__WXMSW__) || defined(__WXUNIVERSAL__)
53b98211
JS
577 event.Enable( m_chkTicks->GetValue() );
578#else
206d3a16 579 event.Enable( false );
a71d815b 580#endif // defined(__WXMSW__) || defined(__WXUNIVERSAL__)
32b8ec41
VZ
581}
582
d79b005a 583void SliderWidgetsPage::OnSlider(wxScrollEvent& event)
32b8ec41 584{
2b5f62a0
VZ
585 wxASSERT_MSG( event.GetInt() == m_slider->GetValue(),
586 wxT("slider value should be the same") );
32b8ec41 587
d79b005a
VZ
588 wxEventType eventType = event.GetEventType();
589
590 /*
591 This array takes the EXACT order of the declarations in
592 include/wx/event.h
593 (section "wxScrollBar and wxSlider event identifiers")
594 */
595 static const wxChar *eventNames[] =
596 {
597 wxT("wxEVT_SCROLL_TOP"),
598 wxT("wxEVT_SCROLL_BOTTOM"),
599 wxT("wxEVT_SCROLL_LINEUP"),
600 wxT("wxEVT_SCROLL_LINEDOWN"),
601 wxT("wxEVT_SCROLL_PAGEUP"),
602 wxT("wxEVT_SCROLL_PAGEDOWN"),
603 wxT("wxEVT_SCROLL_THUMBTRACK"),
604 wxT("wxEVT_SCROLL_THUMBRELEASE"),
cbc85508 605 wxT("wxEVT_SCROLL_CHANGED")
d79b005a
VZ
606 };
607
608 int index = eventType - wxEVT_SCROLL_TOP;
609
610 /*
611 If this assert is triggered, there is an unknown slider event which
612 should be added to the above eventNames array.
613 */
8b1d8f36 614 wxASSERT_MSG(index >= 0 && (size_t)index < WXSIZEOF(eventNames),
d79b005a
VZ
615 wxT("Unknown slider event") );
616
617
618 static int s_numSliderEvents = 0;
619
33cf9a19 620 wxLogMessage(wxT("Slider event #%d: %s (pos = %d, int value = %d)"),
580d78b3 621 s_numSliderEvents++,
d79b005a 622 eventNames[index],
2bcdbe0f
KH
623 event.GetPosition(),
624 event.GetInt());
32b8ec41
VZ
625}
626
61c083e7 627#endif // wxUSE_SLIDER