]> git.saurik.com Git - wxWidgets.git/blame - samples/widgets/slider.cpp
Map between int page ids and page pointers using hashes so that it works when
[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
WS
210 wxImageList *imaglist)
211 : WidgetsPage(book)
32b8ec41
VZ
212{
213 imaglist->Add(wxBitmap(slider_xpm));
214
215 // init everything
216 m_min = 0;
217 m_max = 100;
218
dc3155f1 219 m_chkInverse =
32b8ec41
VZ
220 m_chkTicks =
221 m_chkLabels =
53b98211
JS
222 m_chkBothSides = (wxCheckBox *)NULL;
223
224 m_radioSides = (wxRadioBox *)NULL;
32b8ec41
VZ
225
226 m_slider = (wxSlider *)NULL;
227 m_sizerSlider = (wxSizer *)NULL;
228
229 wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
230
231 // left pane
206d3a16 232 wxStaticBox *box = new wxStaticBox(this, wxID_ANY, _T("&Set style"));
32b8ec41
VZ
233 wxSizer *sizerLeft = new wxStaticBoxSizer(box, wxVERTICAL);
234
2bcdbe0f 235 m_chkInverse = CreateCheckBoxAndAddToSizer(sizerLeft, _T("&Inverse"));
32b8ec41
VZ
236 m_chkTicks = CreateCheckBoxAndAddToSizer(sizerLeft, _T("Show &ticks"));
237 m_chkLabels = CreateCheckBoxAndAddToSizer(sizerLeft, _T("Show &labels"));
53b98211
JS
238 static const wxString sides[] =
239 {
240 _T("top"),
241 _T("bottom"),
242 _T("left"),
243 _T("right"),
244 };
245 m_radioSides = new wxRadioBox(this, SliderPage_RadioSides, _T("&Ticks/Labels"),
246 wxDefaultPosition, wxDefaultSize,
247 WXSIZEOF(sides), sides,
248 1, wxRA_SPECIFY_COLS);
249 sizerLeft->Add(m_radioSides, 0, wxGROW | wxALL, 5);
250 m_chkBothSides = CreateCheckBoxAndAddToSizer
251 (sizerLeft, _T("&Both sides"), SliderPage_BothSides);
252#if wxUSE_TOOLTIPS
253 m_chkBothSides->SetToolTip( _T("\"Both sides\" is only supported \nin Win95 and Universal") );
254#endif // wxUSE_TOOLTIPS
32b8ec41
VZ
255
256 sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer
257
258 wxButton *btn = new wxButton(this, SliderPage_Reset, _T("&Reset"));
259 sizerLeft->Add(btn, 0, wxALIGN_CENTRE_HORIZONTAL | wxALL, 15);
260
261 // middle pane
206d3a16 262 wxStaticBox *box2 = new wxStaticBox(this, wxID_ANY, _T("&Change slider value"));
32b8ec41
VZ
263 wxSizer *sizerMiddle = new wxStaticBoxSizer(box2, wxVERTICAL);
264
265 wxTextCtrl *text;
266 wxSizer *sizerRow = CreateSizerWithTextAndLabel(_T("Current value"),
267 SliderPage_CurValueText,
268 &text);
206d3a16 269 text->SetEditable(false);
32b8ec41
VZ
270
271 sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
272
273 sizerRow = CreateSizerWithTextAndButton(SliderPage_SetValue,
274 _T("Set &value"),
275 SliderPage_ValueText,
276 &m_textValue);
277 sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
278
279 sizerRow = CreateSizerWithTextAndButton(SliderPage_SetMinAndMax,
280 _T("&Min and max"),
281 SliderPage_MinText,
282 &m_textMin);
283
206d3a16 284 m_textMax = new wxTextCtrl(this, SliderPage_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 sizerRow = CreateSizerWithTextAndButton(SliderPage_SetTickFreq,
293 _T("Tick &frequency"),
294 SliderPage_TickFreqText,
295 &m_textTickFreq);
296
297 m_textTickFreq->SetValue(_T("10"));
298
299 sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
300
53b98211 301 sizerRow = CreateSizerWithTextAndButton(SliderPage_SetThumbLen,
a0d9c6cb 302 _T("Thumb &length"),
53b98211
JS
303 SliderPage_ThumbLenText,
304 &m_textThumbLen);
305
306 sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
307
32b8ec41
VZ
308 // right pane
309 wxSizer *sizerRight = new wxBoxSizer(wxHORIZONTAL);
53b98211 310 sizerRight->SetMinSize(150, 40);
32b8ec41
VZ
311 m_sizerSlider = sizerRight; // save it to modify it later
312
313 Reset();
314 CreateSlider();
315
316 // the 3 panes panes compose the window
317 sizerTop->Add(sizerLeft, 0, wxGROW | (wxALL & ~wxLEFT), 10);
7b127900 318 sizerTop->Add(sizerMiddle, 0, wxGROW | wxALL, 10);
32b8ec41
VZ
319 sizerTop->Add(sizerRight, 1, wxGROW | (wxALL & ~wxRIGHT), 10);
320
321 // final initializations
32b8ec41
VZ
322 SetSizer(sizerTop);
323
324 sizerTop->Fit(this);
325}
326
32b8ec41
VZ
327// ----------------------------------------------------------------------------
328// operations
329// ----------------------------------------------------------------------------
330
331void SliderWidgetsPage::Reset()
332{
2bcdbe0f 333 m_chkInverse->SetValue(false);
206d3a16
JS
334 m_chkTicks->SetValue(true);
335 m_chkLabels->SetValue(true);
336 m_chkBothSides->SetValue(false);
53b98211 337
93103bab 338 m_radioSides->SetSelection(SliderTicks_Top);
32b8ec41
VZ
339}
340
341void SliderWidgetsPage::CreateSlider()
342{
1301e228 343 int flags = ms_defaultFlags;
32b8ec41 344
2bcdbe0f
KH
345 if ( m_chkInverse->GetValue() )
346 {
347 flags |= wxSL_INVERSE;
348 }
349
32b8ec41
VZ
350 if ( m_chkLabels->GetValue() )
351 {
352 flags |= wxSL_LABELS;
32b8ec41
VZ
353 }
354
355 if ( m_chkTicks->GetValue() )
356 {
357 flags |= wxSL_AUTOTICKS;
358 }
359
53b98211
JS
360 switch ( m_radioSides->GetSelection() )
361 {
93103bab 362 case SliderTicks_Top:
53b98211
JS
363 flags |= wxSL_TOP;
364 break;
93103bab
VZ
365
366 case SliderTicks_Left:
53b98211
JS
367 flags |= wxSL_LEFT;
368 break;
93103bab
VZ
369
370 case SliderTicks_Bottom:
53b98211
JS
371 flags |= wxSL_BOTTOM;
372 break;
93103bab
VZ
373
374 case SliderTicks_Right:
53b98211
JS
375 flags |= wxSL_RIGHT;
376 break;
93103bab 377
53b98211
JS
378 default:
379 wxFAIL_MSG(_T("unexpected radiobox selection"));
380 // fall through
381 }
382
383 if ( m_chkBothSides->GetValue() )
384 {
385 flags |= wxSL_BOTH;
386 }
387
32b8ec41
VZ
388 int val = m_min;
389 if ( m_slider )
390 {
391 int valOld = m_slider->GetValue();
392 if ( !IsValidValue(valOld) )
393 {
394 val = valOld;
395 }
396
12a3f227 397 m_sizerSlider->Detach( m_slider );
32b8ec41
VZ
398
399 if ( m_sizerSlider->GetChildren().GetCount() )
400 {
401 // we have 2 spacers, remove them too
9dd96c0f
VZ
402 m_sizerSlider->Remove( 0 );
403 m_sizerSlider->Remove( 0 );
32b8ec41
VZ
404 }
405
406 delete m_slider;
407 }
408
409 m_slider = new wxSlider(this, SliderPage_Slider,
410 val, m_min, m_max,
411 wxDefaultPosition, wxDefaultSize,
412 flags);
413
93103bab 414 if ( m_slider->HasFlag(wxSL_VERTICAL) )
32b8ec41
VZ
415 {
416 m_sizerSlider->Add(0, 0, 1);
417 m_sizerSlider->Add(m_slider, 0, wxGROW | wxALL, 5);
418 m_sizerSlider->Add(0, 0, 1);
419 }
420 else
421 {
422 m_sizerSlider->Add(m_slider, 1, wxCENTRE | wxALL, 5);
423 }
424
425 if ( m_chkTicks->GetValue() )
426 {
427 DoSetTickFreq();
428 }
429
430 m_sizerSlider->Layout();
431}
432
433void SliderWidgetsPage::DoSetTickFreq()
434{
435 long freq;
436 if ( !m_textTickFreq->GetValue().ToLong(&freq) )
437 {
438 wxLogWarning(_T("Invalid slider tick frequency"));
439
440 return;
441 }
442
443 m_slider->SetTickFreq(freq, 0 /* unused */);
444}
445
53b98211
JS
446void SliderWidgetsPage::DoSetThumbLen()
447{
448 long len;
449 if ( !m_textThumbLen->GetValue().ToLong(&len) )
450 {
a0d9c6cb 451 wxLogWarning(_T("Invalid slider thumb length"));
53b98211
JS
452
453 return;
454 }
455
456 m_slider->SetThumbLength(len);
457}
458
32b8ec41
VZ
459// ----------------------------------------------------------------------------
460// event handlers
461// ----------------------------------------------------------------------------
462
463void SliderWidgetsPage::OnButtonReset(wxCommandEvent& WXUNUSED(event))
464{
465 Reset();
466
467 CreateSlider();
468}
469
470void SliderWidgetsPage::OnButtonSetTickFreq(wxCommandEvent& WXUNUSED(event))
471{
472 DoSetTickFreq();
473}
474
53b98211
JS
475void SliderWidgetsPage::OnButtonSetThumbLen(wxCommandEvent& WXUNUSED(event))
476{
477 DoSetThumbLen();
478}
479
32b8ec41
VZ
480void SliderWidgetsPage::OnButtonSetMinAndMax(wxCommandEvent& WXUNUSED(event))
481{
482 long minNew,
483 maxNew = 0; // init to suppress compiler warning
484 if ( !m_textMin->GetValue().ToLong(&minNew) ||
485 !m_textMax->GetValue().ToLong(&maxNew) ||
486 minNew >= maxNew )
487 {
488 wxLogWarning(_T("Invalid min/max values for the slider."));
489
490 return;
491 }
492
493 m_min = minNew;
494 m_max = maxNew;
495
496 m_slider->SetRange(minNew, maxNew);
9690a439
WS
497
498 if ( m_slider->GetMin() != m_min ||
499 m_slider->GetMax() != m_max )
500 {
501 wxLogWarning(_T("Invalid range in slider."));
502 }
32b8ec41
VZ
503}
504
505void SliderWidgetsPage::OnButtonSetValue(wxCommandEvent& WXUNUSED(event))
506{
507 long val;
508 if ( !m_textValue->GetValue().ToLong(&val) || !IsValidValue(val) )
509 {
510 wxLogWarning(_T("Invalid slider value."));
511
512 return;
513 }
514
515 m_slider->SetValue(val);
516}
517
518void SliderWidgetsPage::OnUpdateUIValueButton(wxUpdateUIEvent& event)
519{
520 long val;
521 event.Enable( m_textValue->GetValue().ToLong(&val) && IsValidValue(val) );
522}
523
524void SliderWidgetsPage::OnUpdateUITickFreq(wxUpdateUIEvent& event)
525{
526 long freq;
527 event.Enable( m_chkTicks->GetValue() &&
528 m_textTickFreq->GetValue().ToLong(&freq) &&
529 (freq > 0) && (freq <= m_max - m_min) );
530}
531
53b98211
JS
532void SliderWidgetsPage::OnUpdateUIThumbLen(wxUpdateUIEvent& event)
533{
534 long val;
535 event.Enable( m_textThumbLen->GetValue().ToLong(&val));
536}
537
32b8ec41
VZ
538void SliderWidgetsPage::OnUpdateUIMinMaxButton(wxUpdateUIEvent& event)
539{
540 long mn, mx;
541 event.Enable( m_textMin->GetValue().ToLong(&mn) &&
542 m_textMax->GetValue().ToLong(&mx) &&
543 mn < mx);
544}
545
546void SliderWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
547{
93103bab 548 event.Enable( m_chkInverse->GetValue() ||
53b98211 549 !m_chkTicks->GetValue() ||
32b8ec41 550 !m_chkLabels->GetValue() ||
93103bab
VZ
551 m_chkBothSides->GetValue() ||
552 m_radioSides->GetSelection() != SliderTicks_Top );
32b8ec41
VZ
553}
554
c02e5a31 555void SliderWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
32b8ec41
VZ
556{
557 CreateSlider();
558}
559
560void SliderWidgetsPage::OnUpdateUICurValueText(wxUpdateUIEvent& event)
561{
aec18ff7 562 event.SetText( wxString::Format(_T("%d"), m_slider->GetValue()) );
32b8ec41
VZ
563}
564
53b98211
JS
565void SliderWidgetsPage::OnUpdateUIRadioSides(wxUpdateUIEvent& event)
566{
567 event.Enable( m_chkLabels->GetValue() || m_chkTicks->GetValue() );
568}
569
570void SliderWidgetsPage::OnUpdateUIBothSides(wxUpdateUIEvent& event)
32b8ec41 571{
a71d815b 572#if defined(__WXMSW__) || defined(__WXUNIVERSAL__)
53b98211
JS
573 event.Enable( m_chkTicks->GetValue() );
574#else
206d3a16 575 event.Enable( false );
a71d815b 576#endif // defined(__WXMSW__) || defined(__WXUNIVERSAL__)
32b8ec41
VZ
577}
578
d79b005a 579void SliderWidgetsPage::OnSlider(wxScrollEvent& event)
32b8ec41 580{
2b5f62a0
VZ
581 wxASSERT_MSG( event.GetInt() == m_slider->GetValue(),
582 wxT("slider value should be the same") );
32b8ec41 583
d79b005a
VZ
584 wxEventType eventType = event.GetEventType();
585
586 /*
587 This array takes the EXACT order of the declarations in
588 include/wx/event.h
589 (section "wxScrollBar and wxSlider event identifiers")
590 */
591 static const wxChar *eventNames[] =
592 {
593 wxT("wxEVT_SCROLL_TOP"),
594 wxT("wxEVT_SCROLL_BOTTOM"),
595 wxT("wxEVT_SCROLL_LINEUP"),
596 wxT("wxEVT_SCROLL_LINEDOWN"),
597 wxT("wxEVT_SCROLL_PAGEUP"),
598 wxT("wxEVT_SCROLL_PAGEDOWN"),
599 wxT("wxEVT_SCROLL_THUMBTRACK"),
600 wxT("wxEVT_SCROLL_THUMBRELEASE"),
cbc85508 601 wxT("wxEVT_SCROLL_CHANGED")
d79b005a
VZ
602 };
603
604 int index = eventType - wxEVT_SCROLL_TOP;
605
606 /*
607 If this assert is triggered, there is an unknown slider event which
608 should be added to the above eventNames array.
609 */
8b1d8f36 610 wxASSERT_MSG(index >= 0 && (size_t)index < WXSIZEOF(eventNames),
d79b005a
VZ
611 wxT("Unknown slider event") );
612
613
614 static int s_numSliderEvents = 0;
615
33cf9a19 616 wxLogMessage(wxT("Slider event #%d: %s (pos = %d, int value = %d)"),
580d78b3 617 s_numSliderEvents++,
d79b005a 618 eventNames[index],
2bcdbe0f
KH
619 event.GetPosition(),
620 event.GetInt());
32b8ec41
VZ
621}
622
61c083e7 623#endif // wxUSE_SLIDER