1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/univ/slider.cpp
3 // Purpose: implementation of the universal version of wxSlider
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
13 There is some discrepancy in wxSL_LABELS style handling between wxMSW and
14 wxGTK: the latter handles it natively and shows only the current value of
15 the slider on the side corresponding to wxSL_TOP/BOTTOM/LEFT/RIGHT style
16 given (which can be combined with wxSL_HORIZONTAL/VERTICAL) while wxMSW
17 emulates this somehow and shows the min and max values near the ends of the
18 slider and the current value in a separate static box nearby.
20 We currently follow wxGTK except that wxSL_HORIZONTAL slider can only have
21 the label displayed on top or bottom of it and wxSL_VERTICAL - to the left
24 What we really need is probably a more fine grain control on labels, i.e. we
25 should be able to select if we show nothing at all, the current value only
26 or the value and the limits - the current approach is just that of the
27 lowest common denominator.
32 1. support for all orientations
33 2. draw the slider thumb highlighted when it is dragged
34 ?3. manual ticks support?
37 // ============================================================================
39 // ============================================================================
41 // ----------------------------------------------------------------------------
43 // ----------------------------------------------------------------------------
45 #include "wx/wxprec.h"
53 #include "wx/slider.h"
59 #include "wx/univ/renderer.h"
60 #include "wx/univ/inphand.h"
61 #include "wx/univ/theme.h"
63 // ----------------------------------------------------------------------------
64 // wxStdSliderInputHandler: default slider input handling
65 // ----------------------------------------------------------------------------
67 class WXDLLEXPORT wxStdSliderInputHandler
: public wxStdInputHandler
71 wxStdSliderInputHandler(wxInputHandler
*inphand
)
72 : wxStdInputHandler(inphand
)
77 virtual bool HandleKey(wxInputConsumer
*consumer
,
78 const wxKeyEvent
& event
,
80 virtual bool HandleMouse(wxInputConsumer
*consumer
,
81 const wxMouseEvent
& event
);
82 virtual bool HandleMouseMove(wxInputConsumer
*consumer
,
83 const wxMouseEvent
& event
);
85 virtual bool HandleFocus(wxInputConsumer
*consumer
, const wxFocusEvent
& event
);
88 // ----------------------------------------------------------------------------
90 // ----------------------------------------------------------------------------
92 // the margin between the slider and the label (FIXME: hardcoded)
93 static const wxCoord SLIDER_LABEL_MARGIN
= 2;
95 // ============================================================================
96 // implementation of wxSlider
97 // ============================================================================
99 BEGIN_EVENT_TABLE(wxSlider
, wxControl
)
100 EVT_SIZE(wxSlider::OnSize
)
103 // ----------------------------------------------------------------------------
105 // ----------------------------------------------------------------------------
108 // warning C4355: 'this' : used in base member initializer list
109 #pragma warning(disable:4355)
118 wxSlider::wxSlider(wxWindow
*parent
,
120 int value
, int minValue
, int maxValue
,
124 const wxValidator
& validator
,
125 const wxString
& name
)
130 (void)Create(parent
, id
, value
, minValue
, maxValue
,
131 pos
, size
, style
, validator
, name
);
135 // warning C4355: 'this' : used in base member initializer list
136 #pragma warning(default:4355)
139 void wxSlider::Init()
154 bool wxSlider::Create(wxWindow
*parent
,
156 int value
, int minValue
, int maxValue
,
160 const wxValidator
& validator
,
161 const wxString
& name
)
163 if ( !wxSliderBase::Create(parent
, id
, pos
, size
, style
,
167 SetRange(minValue
, maxValue
);
170 // call this after setting the range as the best size depends (at least if
171 // we have wxSL_LABELS style) on the range
172 SetInitialSize(size
);
174 CreateInputHandler(wxINP_HANDLER_SLIDER
);
179 // ----------------------------------------------------------------------------
180 // wxSlider range and value
181 // ----------------------------------------------------------------------------
183 int wxSlider::GetValue() const
188 int wxSlider::NormalizeValue(int value
) const
192 else if ( value
> m_max
)
198 bool wxSlider::ChangeValueBy(int inc
)
200 return ChangeValueTo(NormalizeValue(m_value
+ inc
));
203 bool wxSlider::ChangeValueTo(int value
)
205 // check if the value is going to change at all
206 if (value
== m_value
)
209 // this method is protected and we should only call it with normalized
211 wxCHECK_MSG( IsInRange(value
), false, wxT("invalid slider value") );
217 // generate the events: both a specific scroll event and a command event
218 wxScrollEvent
eventScroll(wxEVT_SCROLL_CHANGED
, GetId());
219 eventScroll
.SetPosition(m_value
);
220 eventScroll
.SetEventObject( this );
221 (void)GetEventHandler()->ProcessEvent(eventScroll
);
223 wxCommandEvent
event(wxEVT_COMMAND_SLIDER_UPDATED
, GetId());
224 event
.SetInt(m_value
);
225 event
.SetEventObject(this);
226 (void)GetEventHandler()->ProcessEvent(event
);
231 void wxSlider::SetValue(int value
)
233 value
= NormalizeValue(value
);
235 if ( m_value
!= value
)
243 void wxSlider::SetRange(int minValue
, int maxValue
)
245 if ( minValue
> maxValue
)
247 // swap them, we always want min to be less than max
253 if ( m_min
!= minValue
|| m_max
!= maxValue
)
258 // reset the value to make sure it is in the new range
261 // the size of the label rect might have changed
269 //else: nothing changed
272 int wxSlider::GetMin() const
277 int wxSlider::GetMax() const
282 // ----------------------------------------------------------------------------
283 // wxSlider line/page/thumb size
284 // ----------------------------------------------------------------------------
286 void wxSlider::SetLineSize(int lineSize
)
288 wxCHECK_RET( lineSize
>= 0, wxT("invalid slider line size") );
290 m_lineSize
= lineSize
;
293 void wxSlider::SetPageSize(int pageSize
)
295 wxCHECK_RET( pageSize
>= 0, wxT("invalid slider page size") );
297 m_pageSize
= pageSize
;
300 int wxSlider::GetLineSize() const
304 // the default line increment is 1
305 wxConstCast(this, wxSlider
)->m_lineSize
= 1;
311 int wxSlider::GetPageSize() const
315 // the default page increment is m_tickFreq
316 wxConstCast(this, wxSlider
)->m_pageSize
= m_tickFreq
;
322 void wxSlider::SetThumbLength(int lenPixels
)
324 wxCHECK_RET( lenPixels
>= 0, wxT("invalid slider thumb size") );
326 // use m_thumbSize here directly and not GetThumbLength() to avoid setting
327 // it to the default value as we don't need it
328 if ( lenPixels
!= m_thumbSize
)
330 m_thumbSize
= lenPixels
;
336 int wxSlider::GetThumbLength() const
338 wxSize sz
= GetDefaultThumbSize();
339 int len
= (IsVert() ? sz
.x
: sz
.y
);
340 if (m_thumbSize
> len
)
351 // ----------------------------------------------------------------------------
353 // ----------------------------------------------------------------------------
355 void wxSlider::SetTickFreq(int n
, int WXUNUSED(dummy
))
357 wxCHECK_RET (n
> 0, wxT("invalid slider tick frequency"));
359 if ( n
!= m_tickFreq
)
367 // ----------------------------------------------------------------------------
369 // ----------------------------------------------------------------------------
371 wxSize
wxSlider::CalcLabelSize() const
375 // there is no sense in trying to calc the labels size if we haven't got
376 // any, the caller must check for it
377 wxCHECK_MSG( HasLabels(), size
, wxT("shouldn't be called") );
379 wxCoord w1
, h1
, w2
, h2
;
380 GetTextExtent(FormatValue(m_min
), &w1
, &h1
);
381 GetTextExtent(FormatValue(m_max
), &w2
, &h2
);
383 size
.x
= wxMax(w1
, w2
);
384 size
.y
= wxMax(h1
, h2
);
389 wxSize
wxSlider::DoGetBestClientSize() const
391 // this dimension is completely arbitrary
392 static const wxCoord SLIDER_WIDTH
= 40;
394 long style
= GetWindowStyle();
396 // first calculate the size of the slider itself: i.e. the shaft and the
398 wxCoord height
= GetRenderer()->GetSliderDim();
404 size
.y
= SLIDER_WIDTH
;
408 size
.x
= SLIDER_WIDTH
;
412 // add space for ticks
415 wxCoord lenTick
= GetRenderer()->GetSliderTickLen();
416 if (style
& wxSL_BOTH
)
418 lenTick
= 2 * lenTick
;
427 // if we have the label, reserve enough space for it
430 wxSize sizeLabels
= CalcLabelSize();
432 if (style
& (wxSL_LEFT
|wxSL_RIGHT
))
434 size
.x
+= sizeLabels
.x
+ SLIDER_LABEL_MARGIN
;
436 else if (style
& (wxSL_TOP
|wxSL_BOTTOM
))
438 size
.y
+= sizeLabels
.y
+ SLIDER_LABEL_MARGIN
;
445 void wxSlider::OnSize(wxSizeEvent
& event
)
452 const wxRect
& wxSlider::GetSliderRect() const
454 if ( m_rectSlider
.width
< 0 )
456 wxConstCast(this, wxSlider
)->CalcGeometry();
462 void wxSlider::CalcGeometry()
465 recalc the label and slider positions, this looks like this for
466 wxSL_HORIZONTAL | wxSL_TOP slider:
469 -------------------------
470 | T | <-- this is the slider rect
471 | HHHHHHHHHHHHHHHTHHHHH |
474 -------------------------
476 LLL is m_rectLabel as calculated here and lll is the real rect used for
477 label drawing in OnDraw() (TTT indicated the thumb position and *s are
480 in the wxSL_VERTICAL | wxSL_RIGHT case the picture is like this:
495 long style
= GetWindowStyle();
497 // initialize to the full client rect
498 wxRect rectTotal
= GetClientRect();
499 m_rectSlider
= rectTotal
;
500 wxSize sizeThumb
= GetThumbSize();
502 // Labels reduce the size of the slider rect
505 wxSize sizeLabels
= CalcLabelSize();
507 m_rectLabel
= wxRect(rectTotal
.GetPosition(), sizeLabels
);
509 if (style
& wxSL_TOP
)
511 // shrink and offset the slider to the bottom
512 m_rectSlider
.y
+= sizeLabels
.y
+ SLIDER_LABEL_MARGIN
;
513 m_rectSlider
.height
-= sizeLabels
.y
+ SLIDER_LABEL_MARGIN
;
515 else if (style
& wxSL_BOTTOM
)
517 // shrink the slider and move the label to the bottom
518 m_rectSlider
.height
-= sizeLabels
.y
+ SLIDER_LABEL_MARGIN
;
519 m_rectLabel
.y
+= m_rectSlider
.height
+ SLIDER_LABEL_MARGIN
;
521 else if (style
& wxSL_LEFT
)
523 // shrink and offset the slider to the right
524 m_rectSlider
.x
+= sizeLabels
.x
+ SLIDER_LABEL_MARGIN
;
525 m_rectSlider
.width
-= sizeLabels
.x
+ SLIDER_LABEL_MARGIN
;
527 else if (style
& wxSL_RIGHT
)
529 // shrink the slider and move the label to the right
530 m_rectSlider
.width
-= sizeLabels
.x
+ SLIDER_LABEL_MARGIN
;
531 m_rectLabel
.x
+= m_rectSlider
.width
+ SLIDER_LABEL_MARGIN
;
535 // calculate ticks too
538 wxCoord lenTick
= GetRenderer()->GetSliderTickLen();
541 m_rectTicks
= GetShaftRect();
545 if (style
& (wxSL_LEFT
|wxSL_BOTH
))
547 m_rectTicks
.x
= m_rectSlider
.x
;
551 m_rectTicks
.x
= m_rectSlider
.x
+ m_rectSlider
.width
- lenTick
;
553 m_rectTicks
.width
= lenTick
;
557 if (style
& (wxSL_TOP
|wxSL_BOTH
))
559 m_rectTicks
.y
= m_rectSlider
.y
;
563 m_rectTicks
.y
= m_rectSlider
.y
+ m_rectSlider
.height
- lenTick
;
565 m_rectTicks
.height
= lenTick
;
569 // slider is never smaller than thumb size unless rectTotal
572 wxCoord width
= wxMin ( rectTotal
.width
, sizeThumb
.x
);
573 m_rectSlider
.width
= wxMax ( m_rectSlider
.width
, width
);
577 wxCoord height
= wxMin ( rectTotal
.height
, sizeThumb
.y
);
578 m_rectSlider
.height
= wxMax ( m_rectSlider
.height
, height
);
582 wxSize
wxSlider::GetDefaultThumbSize() const
584 // Default size has no styles (arrows)
585 return GetRenderer()->GetSliderThumbSize(GetSliderRect(), 0, GetOrientation());
588 wxSize
wxSlider::GetThumbSize() const
590 return GetRenderer()->GetSliderThumbSize(GetSliderRect(), m_thumbSize
, GetOrientation());
593 // ----------------------------------------------------------------------------
594 // wxSlider thumb geometry
595 // ----------------------------------------------------------------------------
597 wxRect
wxSlider::GetShaftRect() const
599 return GetRenderer()->GetSliderShaftRect(m_rectSlider
, m_thumbSize
, GetOrientation(), GetWindowStyle());
602 void wxSlider::CalcThumbRect(const wxRect
*rectShaftIn
,
603 wxRect
*rectThumbOut
,
604 wxRect
*rectLabelOut
,
607 if ( value
== INVALID_THUMB_VALUE
)
609 // use the current if not specified
613 bool isVertical
= IsVert();
618 rectShaft
= *rectShaftIn
;
620 else // no shaft rect provided, calc it
622 rectShaft
= GetShaftRect();
629 wxRect
rectThumb(rectShaft
.GetPosition(), GetThumbSize());
632 rectThumb
.x
+= (rectShaft
.width
- rectThumb
.width
) / 2;
634 lenThumb
= rectThumb
.height
;
635 lenShaft
= rectShaft
.height
;
640 rectThumb
.y
+= (rectShaft
.height
- rectThumb
.height
) / 2;
642 lenThumb
= rectThumb
.width
;
643 lenShaft
= rectShaft
.width
;
647 // the thumb must always be entirely inside the shaft limits, so the max
648 // position is not at lenShaft but at lenShaft - thumbSize
649 if ( m_max
!= m_min
)
653 *p
+= ((lenShaft
- lenThumb
)*(m_max
- value
))/(m_max
- m_min
);
657 *p
+= ((lenShaft
- lenThumb
)*(value
- m_min
))/(m_max
- m_min
);
661 // calc the label rect
662 if ( HasLabels() && rectLabelOut
)
664 long style
= GetWindowStyle();
665 wxRect rectLabel
= m_rectLabel
;
667 // centre the label relatively to the thumb position
668 if (style
& (wxSL_TOP
|wxSL_BOTTOM
))
670 rectLabel
.x
= rectThumb
.x
+ (rectThumb
.width
- m_rectLabel
.width
)/2;
672 else if (style
& (wxSL_LEFT
|wxSL_RIGHT
))
674 rectLabel
.y
= rectThumb
.y
+ (rectThumb
.height
- m_rectLabel
.height
)/2;
677 *rectLabelOut
= rectLabel
;
682 *rectThumbOut
= rectThumb
;
685 // ----------------------------------------------------------------------------
687 // ----------------------------------------------------------------------------
689 wxString
wxSlider::FormatValue(int value
) const
691 return wxString::Format(wxT("%d"), value
);
694 void wxSlider::DoDraw(wxControlRenderer
*renderer
)
696 wxRenderer
*rend
= GetRenderer();
697 wxDC
& dc
= renderer
->GetDC();
698 wxRect rectUpdate
= GetUpdateClientRect();
700 wxOrientation orient
= GetOrientation();
701 int flags
= GetStateFlags();
702 long style
= GetWindowStyle();
704 wxSize sz
= GetThumbSize();
705 int len
= IsVert() ? sz
.x
: sz
.y
;
707 // first draw the shaft
708 wxRect rectShaft
= rend
->GetSliderShaftRect(m_rectSlider
, len
, orient
, style
);
709 if ( rectUpdate
.Intersects(rectShaft
) )
711 rend
->DrawSliderShaft(dc
, m_rectSlider
, len
, orient
, flags
, style
);
714 // calculate the thumb position in pixels and draw it
715 wxRect rectThumb
, rectLabel
;
716 CalcThumbRect(&rectShaft
, &rectThumb
, &rectLabel
);
718 // then draw the ticks
719 if ( HasTicks() && rectUpdate
.Intersects(m_rectTicks
) )
721 rend
->DrawSliderTicks(dc
, m_rectSlider
, len
, orient
,
722 m_min
, m_max
, m_tickFreq
, flags
, style
);
725 // then draw the thumb
726 if ( rectUpdate
.Intersects(rectThumb
) )
728 rend
->DrawSliderThumb(dc
, rectThumb
, orient
, flags
| m_thumbFlags
, style
);
731 // finally, draw the label near the thumb
732 if ( HasLabels() && rectUpdate
.Intersects(rectLabel
) )
734 // align it to be close to the shaft
736 if (style
& wxSL_TOP
)
738 align
= wxALIGN_CENTRE_HORIZONTAL
|wxALIGN_TOP
;
740 else if (style
& wxSL_BOTTOM
)
742 align
= wxALIGN_CENTRE_HORIZONTAL
|wxALIGN_BOTTOM
;
744 else if (style
& wxSL_LEFT
)
746 align
= wxALIGN_CENTRE_VERTICAL
|wxALIGN_LEFT
;
748 else if (style
& wxSL_RIGHT
)
750 align
= wxALIGN_CENTRE_VERTICAL
|wxALIGN_RIGHT
;
753 dc
.SetFont(GetFont());
754 dc
.SetTextForeground(GetForegroundColour());
756 // the slider label is never drawn focused
757 rend
->DrawLabel(dc
, FormatValue(m_value
), rectLabel
,
758 flags
& ~wxCONTROL_FOCUSED
, align
);
762 // ----------------------------------------------------------------------------
763 // wxSlider input processing
764 // ----------------------------------------------------------------------------
766 bool wxSlider::PerformAction(const wxControlAction
& action
,
768 const wxString
& strArg
)
770 wxEventType scrollEvent
= wxEVT_NULL
;
772 bool valueChanged
= true;
774 if ( action
== wxACTION_SLIDER_START
)
776 scrollEvent
= wxEVT_SCROLL_TOP
;
779 else if ( action
== wxACTION_SLIDER_END
)
781 scrollEvent
= wxEVT_SCROLL_BOTTOM
;
784 else if ( action
== wxACTION_SLIDER_PAGE_CHANGE
)
786 value
= NormalizeValue(m_value
+ numArg
* GetPageSize());
788 else if ( action
== wxACTION_SLIDER_LINE_UP
)
790 scrollEvent
= wxEVT_SCROLL_LINEUP
;
791 value
= NormalizeValue(m_value
+ +GetLineSize());
793 else if ( action
== wxACTION_SLIDER_LINE_DOWN
)
795 scrollEvent
= wxEVT_SCROLL_LINEDOWN
;
796 value
= NormalizeValue(m_value
+ -GetLineSize());
798 else if ( action
== wxACTION_SLIDER_PAGE_UP
)
800 scrollEvent
= wxEVT_SCROLL_PAGEUP
;
801 value
= NormalizeValue(m_value
+ +GetPageSize());
803 else if ( action
== wxACTION_SLIDER_PAGE_DOWN
)
805 scrollEvent
= wxEVT_SCROLL_PAGEDOWN
;
806 value
= NormalizeValue(m_value
+ -GetPageSize());
808 else if ( action
== wxACTION_SLIDER_THUMB_DRAG
||
809 action
== wxACTION_SLIDER_THUMB_MOVE
)
811 scrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
813 // we shouldn't generate a command event about this change but we still
814 // should update our value and the slider appearance
815 valueChanged
= false;
820 else if ( action
== wxACTION_SLIDER_THUMB_RELEASE
)
822 scrollEvent
= wxEVT_SCROLL_THUMBRELEASE
;
827 return wxControl::PerformAction(action
, numArg
, strArg
);
830 // update wxSlider current value and generate wxCommandEvent, except while
831 // dragging the thumb
833 ChangeValueTo(value
);
835 // also generate more precise wxScrollEvent if applicable
836 if ( scrollEvent
!= wxEVT_NULL
)
838 wxScrollEvent
event(scrollEvent
, GetId());
839 event
.SetPosition(value
);
840 event
.SetEventObject( this );
841 GetEventHandler()->ProcessEvent(event
);
848 wxInputHandler
*wxSlider::GetStdInputHandler(wxInputHandler
*handlerDef
)
850 static wxStdSliderInputHandler
s_handler(handlerDef
);
855 // ----------------------------------------------------------------------------
856 // wxSlider implementation of wxControlWithThumb interface
857 // ----------------------------------------------------------------------------
859 wxScrollThumb::Shaft
wxSlider::HitTest(const wxPoint
& pt
) const
861 wxRect rectShaft
= GetShaftRect();
863 CalcThumbRect(&rectShaft
, &rectThumb
, NULL
);
865 // check for possible shaft or thumb hit
866 if (!rectShaft
.Contains(pt
) && !rectThumb
.Contains(pt
))
868 return wxScrollThumb::Shaft_None
;
871 // the position to test and the start and end of the thumb
872 wxCoord x
, x1
, x2
, x3
, x4
;
876 x1
= rectThumb
.GetBottom();
877 x2
= rectShaft
.GetBottom();
878 x3
= rectShaft
.GetTop();
879 x4
= rectThumb
.GetTop();
884 x1
= rectShaft
.GetLeft();
885 x2
= rectThumb
.GetLeft();
886 x3
= rectThumb
.GetRight();
887 x4
= rectShaft
.GetRight();
889 if ((x1
<= x
) && (x
< x2
))
892 return wxScrollThumb::Shaft_Above
;
895 if ((x3
< x
) && (x
<= x4
)) {
897 return wxScrollThumb::Shaft_Below
;
900 // where else can it be?
901 return wxScrollThumb::Shaft_Thumb
;
904 wxCoord
wxSlider::ThumbPosToPixel() const
907 CalcThumbRect(NULL
, &rectThumb
, NULL
);
909 return IsVert() ? rectThumb
.y
: rectThumb
.x
;
912 int wxSlider::PixelToThumbPos(wxCoord x
) const
914 wxRect rectShaft
= GetShaftRect();
915 wxSize sizeThumb
= GetThumbSize();
921 len
= rectShaft
.height
- sizeThumb
.y
;
926 len
= rectShaft
.width
- sizeThumb
.x
;
934 pos
+= ((x
- x0
) * (m_max
- m_min
)) / len
;
938 //else: x <= x0, leave pos = min
944 void wxSlider::SetShaftPartState(wxScrollThumb::Shaft shaftPart
,
948 // for now we ignore the flags for the shaft as no renderer uses them
950 if ( shaftPart
== wxScrollThumb::Shaft_Thumb
)
953 m_thumbFlags
|= flag
;
955 m_thumbFlags
&= ~flag
;
961 void wxSlider::OnThumbDragStart(int pos
)
965 PerformAction(wxACTION_SLIDER_THUMB_DRAG
, m_max
- pos
);
969 PerformAction(wxACTION_SLIDER_THUMB_DRAG
, pos
);
973 void wxSlider::OnThumbDrag(int pos
)
977 PerformAction(wxACTION_SLIDER_THUMB_MOVE
, m_max
- pos
);
981 PerformAction(wxACTION_SLIDER_THUMB_MOVE
, pos
);
985 void wxSlider::OnThumbDragEnd(int pos
)
989 PerformAction(wxACTION_SLIDER_THUMB_RELEASE
, m_max
- pos
);
993 PerformAction(wxACTION_SLIDER_THUMB_RELEASE
, pos
);
997 void wxSlider::OnPageScrollStart()
999 // we do nothing here
1002 bool wxSlider::OnPageScroll(int pageInc
)
1004 int value
= GetValue();
1005 PerformAction(wxACTION_SLIDER_PAGE_CHANGE
, pageInc
);
1007 return GetValue() != value
;
1010 // ----------------------------------------------------------------------------
1011 // wxStdSliderInputHandler
1012 // ----------------------------------------------------------------------------
1014 bool wxStdSliderInputHandler::HandleKey(wxInputConsumer
*consumer
,
1015 const wxKeyEvent
& event
,
1020 int keycode
= event
.GetKeyCode();
1022 wxControlAction action
;
1026 action
= wxACTION_SLIDER_END
;
1030 action
= wxACTION_SLIDER_START
;
1035 action
= wxACTION_SLIDER_LINE_UP
;
1040 action
= wxACTION_SLIDER_LINE_DOWN
;
1044 action
= wxACTION_SLIDER_PAGE_UP
;
1048 action
= wxACTION_SLIDER_PAGE_DOWN
;
1052 if ( !action
.IsEmpty() )
1054 consumer
->PerformAction(action
);
1060 return wxStdInputHandler::HandleKey(consumer
, event
, pressed
);
1063 bool wxStdSliderInputHandler::HandleMouse(wxInputConsumer
*consumer
,
1064 const wxMouseEvent
& event
)
1066 wxSlider
*slider
= wxStaticCast(consumer
->GetInputWindow(), wxSlider
);
1068 if ( slider
->GetThumb().HandleMouse(event
) )
1070 // processed by the thumb
1074 return wxStdInputHandler::HandleMouse(consumer
, event
);
1077 bool wxStdSliderInputHandler::HandleMouseMove(wxInputConsumer
*consumer
,
1078 const wxMouseEvent
& event
)
1080 wxSlider
*slider
= wxStaticCast(consumer
->GetInputWindow(), wxSlider
);
1082 if ( slider
->GetThumb().HandleMouseMove(event
) )
1084 // processed by the thumb
1088 return wxStdInputHandler::HandleMouseMove(consumer
, event
);
1092 wxStdSliderInputHandler::HandleFocus(wxInputConsumer
* WXUNUSED(consumer
),
1093 const wxFocusEvent
& WXUNUSED(event
))
1095 // slider appearance changes when it gets/loses focus
1099 #endif // wxUSE_SLIDER