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