1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/univ/slider.cpp
3 // Purpose: implementation of the universal version of wxSlider
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
12 There is some discrepancy in wxSL_LABELS style handling between wxMSW and
13 wxGTK: the latter handles it natively and shows only the current value of
14 the slider on the side corresponding to wxSL_TOP/BOTTOM/LEFT/RIGHT style
15 given (which can be combined with wxSL_HORIZONTAL/VERTICAL) while wxMSW
16 emulates this somehow and shows the min and max values near the ends of the
17 slider and the current value in a separate static box nearby.
19 We currently follow wxGTK except that wxSL_HORIZONTAL slider can only have
20 the label displayed on top or bottom of it and wxSL_VERTICAL - to the left
23 What we really need is probably a more fine grain control on labels, i.e. we
24 should be able to select if we show nothing at all, the current value only
25 or the value and the limits - the current approach is just that of the
26 lowest common denominator.
31 1. support for all orientations
32 2. draw the slider thumb highlighted when it is dragged
33 ?3. manual ticks support?
36 // ============================================================================
38 // ============================================================================
40 // ----------------------------------------------------------------------------
42 // ----------------------------------------------------------------------------
44 #include "wx/wxprec.h"
52 #include "wx/slider.h"
58 #include "wx/univ/renderer.h"
59 #include "wx/univ/inphand.h"
60 #include "wx/univ/theme.h"
62 // ----------------------------------------------------------------------------
63 // wxStdSliderInputHandler: default slider input handling
64 // ----------------------------------------------------------------------------
66 class WXDLLEXPORT wxStdSliderInputHandler
: public wxStdInputHandler
70 wxStdSliderInputHandler(wxInputHandler
*inphand
)
71 : wxStdInputHandler(inphand
)
76 virtual bool HandleKey(wxInputConsumer
*consumer
,
77 const wxKeyEvent
& event
,
79 virtual bool HandleMouse(wxInputConsumer
*consumer
,
80 const wxMouseEvent
& event
);
81 virtual bool HandleMouseMove(wxInputConsumer
*consumer
,
82 const wxMouseEvent
& event
);
84 virtual bool HandleFocus(wxInputConsumer
*consumer
, const wxFocusEvent
& event
);
87 // ----------------------------------------------------------------------------
89 // ----------------------------------------------------------------------------
91 // the margin between the slider and the label (FIXME: hardcoded)
92 static const wxCoord SLIDER_LABEL_MARGIN
= 2;
94 // ============================================================================
95 // implementation of wxSlider
96 // ============================================================================
98 BEGIN_EVENT_TABLE(wxSlider
, wxControl
)
99 EVT_SIZE(wxSlider::OnSize
)
102 // ----------------------------------------------------------------------------
104 // ----------------------------------------------------------------------------
107 // warning C4355: 'this' : used in base member initializer list
108 #pragma warning(disable:4355)
117 wxSlider::wxSlider(wxWindow
*parent
,
119 int value
, int minValue
, int maxValue
,
123 const wxValidator
& validator
,
124 const wxString
& name
)
129 (void)Create(parent
, id
, value
, minValue
, maxValue
,
130 pos
, size
, style
, validator
, name
);
134 // warning C4355: 'this' : used in base member initializer list
135 #pragma warning(default:4355)
138 void wxSlider::Init()
153 bool wxSlider::Create(wxWindow
*parent
,
155 int value
, int minValue
, int maxValue
,
159 const wxValidator
& validator
,
160 const wxString
& name
)
162 if ( !wxSliderBase::Create(parent
, id
, pos
, size
, style
,
166 SetRange(minValue
, maxValue
);
169 // call this after setting the range as the best size depends (at least if
170 // we have wxSL_LABELS style) on the range
171 SetInitialSize(size
);
173 CreateInputHandler(wxINP_HANDLER_SLIDER
);
178 // ----------------------------------------------------------------------------
179 // wxSlider range and value
180 // ----------------------------------------------------------------------------
182 int wxSlider::GetValue() const
187 int wxSlider::NormalizeValue(int value
) const
191 else if ( value
> m_max
)
197 bool wxSlider::ChangeValueBy(int inc
)
199 return ChangeValueTo(NormalizeValue(m_value
+ inc
));
202 bool wxSlider::ChangeValueTo(int value
)
204 // check if the value is going to change at all
205 if (value
== m_value
)
208 // this method is protected and we should only call it with normalized
210 wxCHECK_MSG( IsInRange(value
), false, wxT("invalid slider value") );
216 // generate the events: both a specific scroll event and a command event
217 wxScrollEvent
eventScroll(wxEVT_SCROLL_CHANGED
, GetId());
218 eventScroll
.SetPosition(m_value
);
219 eventScroll
.SetEventObject( this );
220 (void)GetEventHandler()->ProcessEvent(eventScroll
);
222 wxCommandEvent
event(wxEVT_SLIDER
, GetId());
223 event
.SetInt(m_value
);
224 event
.SetEventObject(this);
225 (void)GetEventHandler()->ProcessEvent(event
);
230 void wxSlider::SetValue(int value
)
232 value
= NormalizeValue(value
);
234 if ( m_value
!= value
)
242 void wxSlider::SetRange(int minValue
, int maxValue
)
244 if ( minValue
> maxValue
)
246 // swap them, we always want min to be less than max
252 if ( m_min
!= minValue
|| m_max
!= maxValue
)
257 // reset the value to make sure it is in the new range
260 // the size of the label rect might have changed
268 //else: nothing changed
271 int wxSlider::GetMin() const
276 int wxSlider::GetMax() const
281 // ----------------------------------------------------------------------------
282 // wxSlider line/page/thumb size
283 // ----------------------------------------------------------------------------
285 void wxSlider::SetLineSize(int lineSize
)
287 wxCHECK_RET( lineSize
>= 0, wxT("invalid slider line size") );
289 m_lineSize
= lineSize
;
292 void wxSlider::SetPageSize(int pageSize
)
294 wxCHECK_RET( pageSize
>= 0, wxT("invalid slider page size") );
296 m_pageSize
= pageSize
;
299 int wxSlider::GetLineSize() const
303 // the default line increment is 1
304 wxConstCast(this, wxSlider
)->m_lineSize
= 1;
310 int wxSlider::GetPageSize() const
314 // the default page increment is m_tickFreq
315 wxConstCast(this, wxSlider
)->m_pageSize
= m_tickFreq
;
321 void wxSlider::SetThumbLength(int lenPixels
)
323 wxCHECK_RET( lenPixels
>= 0, wxT("invalid slider thumb size") );
325 // use m_thumbSize here directly and not GetThumbLength() to avoid setting
326 // it to the default value as we don't need it
327 if ( lenPixels
!= m_thumbSize
)
329 m_thumbSize
= lenPixels
;
335 int wxSlider::GetThumbLength() const
337 wxSize sz
= GetDefaultThumbSize();
338 int len
= (IsVert() ? sz
.x
: sz
.y
);
339 if (m_thumbSize
> len
)
350 // ----------------------------------------------------------------------------
352 // ----------------------------------------------------------------------------
354 void wxSlider::DoSetTickFreq(int n
)
356 wxCHECK_RET (n
> 0, wxT("invalid slider tick frequency"));
358 if ( n
!= m_tickFreq
)
366 // ----------------------------------------------------------------------------
368 // ----------------------------------------------------------------------------
370 wxSize
wxSlider::CalcLabelSize() const
374 // there is no sense in trying to calc the labels size if we haven't got
375 // any, the caller must check for it
376 wxCHECK_MSG( HasLabels(), size
, wxT("shouldn't be called") );
378 wxCoord w1
, h1
, w2
, h2
;
379 GetTextExtent(FormatValue(m_min
), &w1
, &h1
);
380 GetTextExtent(FormatValue(m_max
), &w2
, &h2
);
382 size
.x
= wxMax(w1
, w2
);
383 size
.y
= wxMax(h1
, h2
);
388 wxSize
wxSlider::DoGetBestClientSize() const
390 // this dimension is completely arbitrary
391 static const wxCoord SLIDER_WIDTH
= 40;
393 long style
= GetWindowStyle();
395 // first calculate the size of the slider itself: i.e. the shaft and the
397 wxCoord height
= GetRenderer()->GetSliderDim();
403 size
.y
= SLIDER_WIDTH
;
407 size
.x
= SLIDER_WIDTH
;
411 // add space for ticks
414 wxCoord lenTick
= GetRenderer()->GetSliderTickLen();
415 if (style
& wxSL_BOTH
)
417 lenTick
= 2 * lenTick
;
426 // if we have the label, reserve enough space for it
429 wxSize sizeLabels
= CalcLabelSize();
431 if (style
& (wxSL_LEFT
|wxSL_RIGHT
))
433 size
.x
+= sizeLabels
.x
+ SLIDER_LABEL_MARGIN
;
435 else if (style
& (wxSL_TOP
|wxSL_BOTTOM
))
437 size
.y
+= sizeLabels
.y
+ SLIDER_LABEL_MARGIN
;
444 void wxSlider::OnSize(wxSizeEvent
& event
)
451 const wxRect
& wxSlider::GetSliderRect() const
453 if ( m_rectSlider
.width
< 0 )
455 wxConstCast(this, wxSlider
)->CalcGeometry();
461 void wxSlider::CalcGeometry()
464 recalc the label and slider positions, this looks like this for
465 wxSL_HORIZONTAL | wxSL_TOP slider:
468 -------------------------
469 | T | <-- this is the slider rect
470 | HHHHHHHHHHHHHHHTHHHHH |
473 -------------------------
475 LLL is m_rectLabel as calculated here and lll is the real rect used for
476 label drawing in OnDraw() (TTT indicated the thumb position and *s are
479 in the wxSL_VERTICAL | wxSL_RIGHT case the picture is like this:
494 long style
= GetWindowStyle();
496 // initialize to the full client rect
497 wxRect rectTotal
= GetClientRect();
498 m_rectSlider
= rectTotal
;
499 wxSize sizeThumb
= GetThumbSize();
501 // Labels reduce the size of the slider rect
504 wxSize sizeLabels
= CalcLabelSize();
506 m_rectLabel
= wxRect(rectTotal
.GetPosition(), sizeLabels
);
508 if (style
& wxSL_TOP
)
510 // shrink and offset the slider to the bottom
511 m_rectSlider
.y
+= sizeLabels
.y
+ SLIDER_LABEL_MARGIN
;
512 m_rectSlider
.height
-= sizeLabels
.y
+ SLIDER_LABEL_MARGIN
;
514 else if (style
& wxSL_BOTTOM
)
516 // shrink the slider and move the label to the bottom
517 m_rectSlider
.height
-= sizeLabels
.y
+ SLIDER_LABEL_MARGIN
;
518 m_rectLabel
.y
+= m_rectSlider
.height
+ SLIDER_LABEL_MARGIN
;
520 else if (style
& wxSL_LEFT
)
522 // shrink and offset the slider to the right
523 m_rectSlider
.x
+= sizeLabels
.x
+ SLIDER_LABEL_MARGIN
;
524 m_rectSlider
.width
-= sizeLabels
.x
+ SLIDER_LABEL_MARGIN
;
526 else if (style
& wxSL_RIGHT
)
528 // shrink the slider and move the label to the right
529 m_rectSlider
.width
-= sizeLabels
.x
+ SLIDER_LABEL_MARGIN
;
530 m_rectLabel
.x
+= m_rectSlider
.width
+ SLIDER_LABEL_MARGIN
;
534 // calculate ticks too
537 wxCoord lenTick
= GetRenderer()->GetSliderTickLen();
540 m_rectTicks
= GetShaftRect();
544 if (style
& (wxSL_LEFT
|wxSL_BOTH
))
546 m_rectTicks
.x
= m_rectSlider
.x
;
550 m_rectTicks
.x
= m_rectSlider
.x
+ m_rectSlider
.width
- lenTick
;
552 m_rectTicks
.width
= lenTick
;
556 if (style
& (wxSL_TOP
|wxSL_BOTH
))
558 m_rectTicks
.y
= m_rectSlider
.y
;
562 m_rectTicks
.y
= m_rectSlider
.y
+ m_rectSlider
.height
- lenTick
;
564 m_rectTicks
.height
= lenTick
;
568 // slider is never smaller than thumb size unless rectTotal
571 wxCoord width
= wxMin ( rectTotal
.width
, sizeThumb
.x
);
572 m_rectSlider
.width
= wxMax ( m_rectSlider
.width
, width
);
576 wxCoord height
= wxMin ( rectTotal
.height
, sizeThumb
.y
);
577 m_rectSlider
.height
= wxMax ( m_rectSlider
.height
, height
);
581 wxSize
wxSlider::GetDefaultThumbSize() const
583 // Default size has no styles (arrows)
584 return GetRenderer()->GetSliderThumbSize(GetSliderRect(), 0, GetOrientation());
587 wxSize
wxSlider::GetThumbSize() const
589 return GetRenderer()->GetSliderThumbSize(GetSliderRect(), m_thumbSize
, GetOrientation());
592 // ----------------------------------------------------------------------------
593 // wxSlider thumb geometry
594 // ----------------------------------------------------------------------------
596 wxRect
wxSlider::GetShaftRect() const
598 return GetRenderer()->GetSliderShaftRect(m_rectSlider
, m_thumbSize
, GetOrientation(), GetWindowStyle());
601 void wxSlider::CalcThumbRect(const wxRect
*rectShaftIn
,
602 wxRect
*rectThumbOut
,
603 wxRect
*rectLabelOut
,
606 if ( value
== INVALID_THUMB_VALUE
)
608 // use the current if not specified
612 bool isVertical
= IsVert();
617 rectShaft
= *rectShaftIn
;
619 else // no shaft rect provided, calc it
621 rectShaft
= GetShaftRect();
628 wxRect
rectThumb(rectShaft
.GetPosition(), GetThumbSize());
631 rectThumb
.x
+= (rectShaft
.width
- rectThumb
.width
) / 2;
633 lenThumb
= rectThumb
.height
;
634 lenShaft
= rectShaft
.height
;
639 rectThumb
.y
+= (rectShaft
.height
- rectThumb
.height
) / 2;
641 lenThumb
= rectThumb
.width
;
642 lenShaft
= rectShaft
.width
;
646 // the thumb must always be entirely inside the shaft limits, so the max
647 // position is not at lenShaft but at lenShaft - thumbSize
648 if ( m_max
!= m_min
)
652 *p
+= ((lenShaft
- lenThumb
)*(m_max
- value
))/(m_max
- m_min
);
656 *p
+= ((lenShaft
- lenThumb
)*(value
- m_min
))/(m_max
- m_min
);
660 // calc the label rect
661 if ( HasLabels() && rectLabelOut
)
663 long style
= GetWindowStyle();
664 wxRect rectLabel
= m_rectLabel
;
666 // centre the label relatively to the thumb position
667 if (style
& (wxSL_TOP
|wxSL_BOTTOM
))
669 rectLabel
.x
= rectThumb
.x
+ (rectThumb
.width
- m_rectLabel
.width
)/2;
671 else if (style
& (wxSL_LEFT
|wxSL_RIGHT
))
673 rectLabel
.y
= rectThumb
.y
+ (rectThumb
.height
- m_rectLabel
.height
)/2;
676 *rectLabelOut
= rectLabel
;
681 *rectThumbOut
= rectThumb
;
684 // ----------------------------------------------------------------------------
686 // ----------------------------------------------------------------------------
688 wxString
wxSlider::FormatValue(int value
) const
690 return wxString::Format(wxT("%d"), value
);
693 void wxSlider::DoDraw(wxControlRenderer
*renderer
)
695 wxRenderer
*rend
= GetRenderer();
696 wxDC
& dc
= renderer
->GetDC();
697 wxRect rectUpdate
= GetUpdateClientRect();
699 wxOrientation orient
= GetOrientation();
700 int flags
= GetStateFlags();
701 long style
= GetWindowStyle();
703 wxSize sz
= GetThumbSize();
704 int len
= IsVert() ? sz
.x
: sz
.y
;
706 // first draw the shaft
707 wxRect rectShaft
= rend
->GetSliderShaftRect(m_rectSlider
, len
, orient
, style
);
708 if ( rectUpdate
.Intersects(rectShaft
) )
710 rend
->DrawSliderShaft(dc
, m_rectSlider
, len
, orient
, flags
, style
);
713 // calculate the thumb position in pixels and draw it
714 wxRect rectThumb
, rectLabel
;
715 CalcThumbRect(&rectShaft
, &rectThumb
, &rectLabel
);
717 // then draw the ticks
718 if ( HasTicks() && rectUpdate
.Intersects(m_rectTicks
) )
720 rend
->DrawSliderTicks(dc
, m_rectSlider
, len
, orient
,
721 m_min
, m_max
, m_tickFreq
, flags
, style
);
724 // then draw the thumb
725 if ( rectUpdate
.Intersects(rectThumb
) )
727 rend
->DrawSliderThumb(dc
, rectThumb
, orient
, flags
| m_thumbFlags
, style
);
730 // finally, draw the label near the thumb
731 if ( HasLabels() && rectUpdate
.Intersects(rectLabel
) )
733 // align it to be close to the shaft
735 if (style
& wxSL_TOP
)
737 align
= wxALIGN_CENTRE_HORIZONTAL
|wxALIGN_TOP
;
739 else if (style
& wxSL_BOTTOM
)
741 align
= wxALIGN_CENTRE_HORIZONTAL
|wxALIGN_BOTTOM
;
743 else if (style
& wxSL_LEFT
)
745 align
= wxALIGN_CENTRE_VERTICAL
|wxALIGN_LEFT
;
747 else if (style
& wxSL_RIGHT
)
749 align
= wxALIGN_CENTRE_VERTICAL
|wxALIGN_RIGHT
;
752 dc
.SetFont(GetFont());
753 dc
.SetTextForeground(GetForegroundColour());
755 // the slider label is never drawn focused
756 rend
->DrawLabel(dc
, FormatValue(m_value
), rectLabel
,
757 flags
& ~wxCONTROL_FOCUSED
, align
);
761 // ----------------------------------------------------------------------------
762 // wxSlider input processing
763 // ----------------------------------------------------------------------------
765 bool wxSlider::PerformAction(const wxControlAction
& action
,
767 const wxString
& strArg
)
769 wxEventType scrollEvent
= wxEVT_NULL
;
771 bool valueChanged
= true;
773 if ( action
== wxACTION_SLIDER_START
)
775 scrollEvent
= wxEVT_SCROLL_TOP
;
778 else if ( action
== wxACTION_SLIDER_END
)
780 scrollEvent
= wxEVT_SCROLL_BOTTOM
;
783 else if ( action
== wxACTION_SLIDER_PAGE_CHANGE
)
785 value
= NormalizeValue(m_value
+ numArg
* GetPageSize());
787 else if ( action
== wxACTION_SLIDER_LINE_UP
)
789 scrollEvent
= wxEVT_SCROLL_LINEUP
;
790 value
= NormalizeValue(m_value
+ +GetLineSize());
792 else if ( action
== wxACTION_SLIDER_LINE_DOWN
)
794 scrollEvent
= wxEVT_SCROLL_LINEDOWN
;
795 value
= NormalizeValue(m_value
+ -GetLineSize());
797 else if ( action
== wxACTION_SLIDER_PAGE_UP
)
799 scrollEvent
= wxEVT_SCROLL_PAGEUP
;
800 value
= NormalizeValue(m_value
+ +GetPageSize());
802 else if ( action
== wxACTION_SLIDER_PAGE_DOWN
)
804 scrollEvent
= wxEVT_SCROLL_PAGEDOWN
;
805 value
= NormalizeValue(m_value
+ -GetPageSize());
807 else if ( action
== wxACTION_SLIDER_THUMB_DRAG
||
808 action
== wxACTION_SLIDER_THUMB_MOVE
)
810 scrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
812 // we shouldn't generate a command event about this change but we still
813 // should update our value and the slider appearance
814 valueChanged
= false;
819 else if ( action
== wxACTION_SLIDER_THUMB_RELEASE
)
821 scrollEvent
= wxEVT_SCROLL_THUMBRELEASE
;
826 return wxControl::PerformAction(action
, numArg
, strArg
);
829 // update wxSlider current value and generate wxCommandEvent, except while
830 // dragging the thumb
832 ChangeValueTo(value
);
834 // also generate more precise wxScrollEvent if applicable
835 if ( scrollEvent
!= wxEVT_NULL
)
837 wxScrollEvent
event(scrollEvent
, GetId());
838 event
.SetPosition(value
);
839 event
.SetEventObject( this );
840 GetEventHandler()->ProcessEvent(event
);
847 wxInputHandler
*wxSlider::GetStdInputHandler(wxInputHandler
*handlerDef
)
849 static wxStdSliderInputHandler
s_handler(handlerDef
);
854 // ----------------------------------------------------------------------------
855 // wxSlider implementation of wxControlWithThumb interface
856 // ----------------------------------------------------------------------------
858 wxScrollThumb::Shaft
wxSlider::HitTest(const wxPoint
& pt
) const
860 wxRect rectShaft
= GetShaftRect();
862 CalcThumbRect(&rectShaft
, &rectThumb
, NULL
);
864 // check for possible shaft or thumb hit
865 if (!rectShaft
.Contains(pt
) && !rectThumb
.Contains(pt
))
867 return wxScrollThumb::Shaft_None
;
870 // the position to test and the start and end of the thumb
871 wxCoord x
, x1
, x2
, x3
, x4
;
875 x1
= rectThumb
.GetBottom();
876 x2
= rectShaft
.GetBottom();
877 x3
= rectShaft
.GetTop();
878 x4
= rectThumb
.GetTop();
883 x1
= rectShaft
.GetLeft();
884 x2
= rectThumb
.GetLeft();
885 x3
= rectThumb
.GetRight();
886 x4
= rectShaft
.GetRight();
888 if ((x1
<= x
) && (x
< x2
))
891 return wxScrollThumb::Shaft_Above
;
894 if ((x3
< x
) && (x
<= x4
)) {
896 return wxScrollThumb::Shaft_Below
;
899 // where else can it be?
900 return wxScrollThumb::Shaft_Thumb
;
903 wxCoord
wxSlider::ThumbPosToPixel() const
906 CalcThumbRect(NULL
, &rectThumb
, NULL
);
908 return IsVert() ? rectThumb
.y
: rectThumb
.x
;
911 int wxSlider::PixelToThumbPos(wxCoord x
) const
913 wxRect rectShaft
= GetShaftRect();
914 wxSize sizeThumb
= GetThumbSize();
920 len
= rectShaft
.height
- sizeThumb
.y
;
925 len
= rectShaft
.width
- sizeThumb
.x
;
933 pos
+= ((x
- x0
) * (m_max
- m_min
)) / len
;
937 //else: x <= x0, leave pos = min
943 void wxSlider::SetShaftPartState(wxScrollThumb::Shaft shaftPart
,
947 // for now we ignore the flags for the shaft as no renderer uses them
949 if ( shaftPart
== wxScrollThumb::Shaft_Thumb
)
952 m_thumbFlags
|= flag
;
954 m_thumbFlags
&= ~flag
;
960 void wxSlider::OnThumbDragStart(int pos
)
964 PerformAction(wxACTION_SLIDER_THUMB_DRAG
, m_max
- pos
);
968 PerformAction(wxACTION_SLIDER_THUMB_DRAG
, pos
);
972 void wxSlider::OnThumbDrag(int pos
)
976 PerformAction(wxACTION_SLIDER_THUMB_MOVE
, m_max
- pos
);
980 PerformAction(wxACTION_SLIDER_THUMB_MOVE
, pos
);
984 void wxSlider::OnThumbDragEnd(int pos
)
988 PerformAction(wxACTION_SLIDER_THUMB_RELEASE
, m_max
- pos
);
992 PerformAction(wxACTION_SLIDER_THUMB_RELEASE
, pos
);
996 void wxSlider::OnPageScrollStart()
998 // we do nothing here
1001 bool wxSlider::OnPageScroll(int pageInc
)
1003 int value
= GetValue();
1004 PerformAction(wxACTION_SLIDER_PAGE_CHANGE
, pageInc
);
1006 return GetValue() != value
;
1009 // ----------------------------------------------------------------------------
1010 // wxStdSliderInputHandler
1011 // ----------------------------------------------------------------------------
1013 bool wxStdSliderInputHandler::HandleKey(wxInputConsumer
*consumer
,
1014 const wxKeyEvent
& event
,
1019 int keycode
= event
.GetKeyCode();
1021 wxControlAction action
;
1025 action
= wxACTION_SLIDER_END
;
1029 action
= wxACTION_SLIDER_START
;
1034 action
= wxACTION_SLIDER_LINE_UP
;
1039 action
= wxACTION_SLIDER_LINE_DOWN
;
1043 action
= wxACTION_SLIDER_PAGE_UP
;
1047 action
= wxACTION_SLIDER_PAGE_DOWN
;
1051 if ( !action
.IsEmpty() )
1053 consumer
->PerformAction(action
);
1059 return wxStdInputHandler::HandleKey(consumer
, event
, pressed
);
1062 bool wxStdSliderInputHandler::HandleMouse(wxInputConsumer
*consumer
,
1063 const wxMouseEvent
& event
)
1065 wxSlider
*slider
= wxStaticCast(consumer
->GetInputWindow(), wxSlider
);
1067 if ( slider
->GetThumb().HandleMouse(event
) )
1069 // processed by the thumb
1073 return wxStdInputHandler::HandleMouse(consumer
, event
);
1076 bool wxStdSliderInputHandler::HandleMouseMove(wxInputConsumer
*consumer
,
1077 const wxMouseEvent
& event
)
1079 wxSlider
*slider
= wxStaticCast(consumer
->GetInputWindow(), wxSlider
);
1081 if ( slider
->GetThumb().HandleMouseMove(event
) )
1083 // processed by the thumb
1087 return wxStdInputHandler::HandleMouseMove(consumer
, event
);
1091 wxStdSliderInputHandler::HandleFocus(wxInputConsumer
* WXUNUSED(consumer
),
1092 const wxFocusEvent
& WXUNUSED(event
))
1094 // slider appearance changes when it gets/loses focus
1098 #endif // wxUSE_SLIDER