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 IMPLEMENT_DYNAMIC_CLASS(wxSlider
, wxControl
)
101 BEGIN_EVENT_TABLE(wxSlider
, wxControl
)
102 EVT_SIZE(wxSlider::OnSize
)
105 // ----------------------------------------------------------------------------
107 // ----------------------------------------------------------------------------
110 // warning C4355: 'this' : used in base member initializer list
111 #pragma warning(disable:4355)
120 wxSlider::wxSlider(wxWindow
*parent
,
122 int value
, int minValue
, int maxValue
,
126 const wxValidator
& validator
,
127 const wxString
& name
)
132 (void)Create(parent
, id
, value
, minValue
, maxValue
,
133 pos
, size
, style
, validator
, name
);
137 // warning C4355: 'this' : used in base member initializer list
138 #pragma warning(default:4355)
141 void wxSlider::Init()
156 bool wxSlider::Create(wxWindow
*parent
,
158 int value
, int minValue
, int maxValue
,
162 const wxValidator
& validator
,
163 const wxString
& name
)
165 if ( !wxSliderBase::Create(parent
, id
, pos
, size
, style
,
169 SetRange(minValue
, maxValue
);
172 // call this after setting the range as the best size depends (at least if
173 // we have wxSL_LABELS style) on the range
174 SetInitialSize(size
);
176 CreateInputHandler(wxINP_HANDLER_SLIDER
);
181 // ----------------------------------------------------------------------------
182 // wxSlider range and value
183 // ----------------------------------------------------------------------------
185 int wxSlider::GetValue() const
190 int wxSlider::NormalizeValue(int value
) const
194 else if ( value
> m_max
)
200 bool wxSlider::ChangeValueBy(int inc
)
202 return ChangeValueTo(NormalizeValue(m_value
+ inc
));
205 bool wxSlider::ChangeValueTo(int value
)
207 // check if the value is going to change at all
208 if (value
== m_value
)
211 // this method is protected and we should only call it with normalized
213 wxCHECK_MSG( IsInRange(value
), false, wxT("invalid slider value") );
219 // generate the events: both a specific scroll event and a command event
220 wxScrollEvent
eventScroll(wxEVT_SCROLL_CHANGED
, GetId());
221 eventScroll
.SetPosition(m_value
);
222 eventScroll
.SetEventObject( this );
223 (void)GetEventHandler()->ProcessEvent(eventScroll
);
225 wxCommandEvent
event(wxEVT_COMMAND_SLIDER_UPDATED
, GetId());
226 event
.SetInt(m_value
);
227 event
.SetEventObject(this);
228 (void)GetEventHandler()->ProcessEvent(event
);
233 void wxSlider::SetValue(int value
)
235 value
= NormalizeValue(value
);
237 if ( m_value
!= value
)
245 void wxSlider::SetRange(int minValue
, int maxValue
)
247 if ( minValue
> maxValue
)
249 // swap them, we always want min to be less than max
255 if ( m_min
!= minValue
|| m_max
!= maxValue
)
260 // reset the value to make sure it is in the new range
263 // the size of the label rect might have changed
271 //else: nothing changed
274 int wxSlider::GetMin() const
279 int wxSlider::GetMax() const
284 // ----------------------------------------------------------------------------
285 // wxSlider line/page/thumb size
286 // ----------------------------------------------------------------------------
288 void wxSlider::SetLineSize(int lineSize
)
290 wxCHECK_RET( lineSize
>= 0, wxT("invalid slider line size") );
292 m_lineSize
= lineSize
;
295 void wxSlider::SetPageSize(int pageSize
)
297 wxCHECK_RET( pageSize
>= 0, wxT("invalid slider page size") );
299 m_pageSize
= pageSize
;
302 int wxSlider::GetLineSize() const
306 // the default line increment is 1
307 wxConstCast(this, wxSlider
)->m_lineSize
= 1;
313 int wxSlider::GetPageSize() const
317 // the default page increment is m_tickFreq
318 wxConstCast(this, wxSlider
)->m_pageSize
= m_tickFreq
;
324 void wxSlider::SetThumbLength(int lenPixels
)
326 wxCHECK_RET( lenPixels
>= 0, wxT("invalid slider thumb size") );
328 // use m_thumbSize here directly and not GetThumbLength() to avoid setting
329 // it to the default value as we don't need it
330 if ( lenPixels
!= m_thumbSize
)
332 m_thumbSize
= lenPixels
;
338 int wxSlider::GetThumbLength() const
340 wxSize sz
= GetDefaultThumbSize();
341 int len
= (IsVert() ? sz
.x
: sz
.y
);
342 if (m_thumbSize
> len
)
353 // ----------------------------------------------------------------------------
355 // ----------------------------------------------------------------------------
357 void wxSlider::SetTickFreq(int n
, int WXUNUSED(dummy
))
359 wxCHECK_RET (n
> 0, wxT("invalid slider tick frequency"));
361 if ( n
!= m_tickFreq
)
369 // ----------------------------------------------------------------------------
371 // ----------------------------------------------------------------------------
373 wxSize
wxSlider::CalcLabelSize() const
377 // there is no sense in trying to calc the labels size if we haven't got
378 // any, the caller must check for it
379 wxCHECK_MSG( HasLabels(), size
, wxT("shouldn't be called") );
381 wxCoord w1
, h1
, w2
, h2
;
382 GetTextExtent(FormatValue(m_min
), &w1
, &h1
);
383 GetTextExtent(FormatValue(m_max
), &w2
, &h2
);
385 size
.x
= wxMax(w1
, w2
);
386 size
.y
= wxMax(h1
, h2
);
391 wxSize
wxSlider::DoGetBestClientSize() const
393 // this dimension is completely arbitrary
394 static const wxCoord SLIDER_WIDTH
= 40;
396 long style
= GetWindowStyle();
398 // first calculate the size of the slider itself: i.e. the shaft and the
400 wxCoord height
= GetRenderer()->GetSliderDim();
406 size
.y
= SLIDER_WIDTH
;
410 size
.x
= SLIDER_WIDTH
;
414 // add space for ticks
417 wxCoord lenTick
= GetRenderer()->GetSliderTickLen();
418 if (style
& wxSL_BOTH
)
420 lenTick
= 2 * lenTick
;
429 // if we have the label, reserve enough space for it
432 wxSize sizeLabels
= CalcLabelSize();
434 if (style
& (wxSL_LEFT
|wxSL_RIGHT
))
436 size
.x
+= sizeLabels
.x
+ SLIDER_LABEL_MARGIN
;
438 else if (style
& (wxSL_TOP
|wxSL_BOTTOM
))
440 size
.y
+= sizeLabels
.y
+ SLIDER_LABEL_MARGIN
;
447 void wxSlider::OnSize(wxSizeEvent
& event
)
454 const wxRect
& wxSlider::GetSliderRect() const
456 if ( m_rectSlider
.width
< 0 )
458 wxConstCast(this, wxSlider
)->CalcGeometry();
464 void wxSlider::CalcGeometry()
467 recalc the label and slider positions, this looks like this for
468 wxSL_HORIZONTAL | wxSL_TOP slider:
471 -------------------------
472 | T | <-- this is the slider rect
473 | HHHHHHHHHHHHHHHTHHHHH |
476 -------------------------
478 LLL is m_rectLabel as calculated here and lll is the real rect used for
479 label drawing in OnDraw() (TTT indicated the thumb position and *s are
482 in the wxSL_VERTICAL | wxSL_RIGHT case the picture is like this:
497 long style
= GetWindowStyle();
499 // initialize to the full client rect
500 wxRect rectTotal
= GetClientRect();
501 m_rectSlider
= rectTotal
;
502 wxSize sizeThumb
= GetThumbSize();
504 // Labels reduce the size of the slider rect
507 wxSize sizeLabels
= CalcLabelSize();
509 m_rectLabel
= wxRect(rectTotal
.GetPosition(), sizeLabels
);
511 if (style
& wxSL_TOP
)
513 // shrink and offset the slider to the bottom
514 m_rectSlider
.y
+= sizeLabels
.y
+ SLIDER_LABEL_MARGIN
;
515 m_rectSlider
.height
-= sizeLabels
.y
+ SLIDER_LABEL_MARGIN
;
517 else if (style
& wxSL_BOTTOM
)
519 // shrink the slider and move the label to the bottom
520 m_rectSlider
.height
-= sizeLabels
.y
+ SLIDER_LABEL_MARGIN
;
521 m_rectLabel
.y
+= m_rectSlider
.height
+ SLIDER_LABEL_MARGIN
;
523 else if (style
& wxSL_LEFT
)
525 // shrink and offset the slider to the right
526 m_rectSlider
.x
+= sizeLabels
.x
+ SLIDER_LABEL_MARGIN
;
527 m_rectSlider
.width
-= sizeLabels
.x
+ SLIDER_LABEL_MARGIN
;
529 else if (style
& wxSL_RIGHT
)
531 // shrink the slider and move the label to the right
532 m_rectSlider
.width
-= sizeLabels
.x
+ SLIDER_LABEL_MARGIN
;
533 m_rectLabel
.x
+= m_rectSlider
.width
+ SLIDER_LABEL_MARGIN
;
537 // calculate ticks too
540 wxCoord lenTick
= GetRenderer()->GetSliderTickLen();
543 m_rectTicks
= GetShaftRect();
547 if (style
& (wxSL_LEFT
|wxSL_BOTH
))
549 m_rectTicks
.x
= m_rectSlider
.x
;
553 m_rectTicks
.x
= m_rectSlider
.x
+ m_rectSlider
.width
- lenTick
;
555 m_rectTicks
.width
= lenTick
;
559 if (style
& (wxSL_TOP
|wxSL_BOTH
))
561 m_rectTicks
.y
= m_rectSlider
.y
;
565 m_rectTicks
.y
= m_rectSlider
.y
+ m_rectSlider
.height
- lenTick
;
567 m_rectTicks
.height
= lenTick
;
571 // slider is never smaller than thumb size unless rectTotal
574 wxCoord width
= wxMin ( rectTotal
.width
, sizeThumb
.x
);
575 m_rectSlider
.width
= wxMax ( m_rectSlider
.width
, width
);
579 wxCoord height
= wxMin ( rectTotal
.height
, sizeThumb
.y
);
580 m_rectSlider
.height
= wxMax ( m_rectSlider
.height
, height
);
584 wxSize
wxSlider::GetDefaultThumbSize() const
586 // Default size has no styles (arrows)
587 return GetRenderer()->GetSliderThumbSize(GetSliderRect(), 0, GetOrientation());
590 wxSize
wxSlider::GetThumbSize() const
592 return GetRenderer()->GetSliderThumbSize(GetSliderRect(), m_thumbSize
, GetOrientation());
595 // ----------------------------------------------------------------------------
596 // wxSlider thumb geometry
597 // ----------------------------------------------------------------------------
599 wxRect
wxSlider::GetShaftRect() const
601 return GetRenderer()->GetSliderShaftRect(m_rectSlider
, m_thumbSize
, GetOrientation(), GetWindowStyle());
604 void wxSlider::CalcThumbRect(const wxRect
*rectShaftIn
,
605 wxRect
*rectThumbOut
,
606 wxRect
*rectLabelOut
,
609 if ( value
== INVALID_THUMB_VALUE
)
611 // use the current if not specified
615 bool isVertical
= IsVert();
620 rectShaft
= *rectShaftIn
;
622 else // no shaft rect provided, calc it
624 rectShaft
= GetShaftRect();
631 wxRect
rectThumb(rectShaft
.GetPosition(), GetThumbSize());
634 rectThumb
.x
+= (rectShaft
.width
- rectThumb
.width
) / 2;
636 lenThumb
= rectThumb
.height
;
637 lenShaft
= rectShaft
.height
;
642 rectThumb
.y
+= (rectShaft
.height
- rectThumb
.height
) / 2;
644 lenThumb
= rectThumb
.width
;
645 lenShaft
= rectShaft
.width
;
649 // the thumb must always be entirely inside the shaft limits, so the max
650 // position is not at lenShaft but at lenShaft - thumbSize
651 if ( m_max
!= m_min
)
655 *p
+= ((lenShaft
- lenThumb
)*(m_max
- value
))/(m_max
- m_min
);
659 *p
+= ((lenShaft
- lenThumb
)*(value
- m_min
))/(m_max
- m_min
);
663 // calc the label rect
664 if ( HasLabels() && rectLabelOut
)
666 long style
= GetWindowStyle();
667 wxRect rectLabel
= m_rectLabel
;
669 // centre the label relatively to the thumb position
670 if (style
& (wxSL_TOP
|wxSL_BOTTOM
))
672 rectLabel
.x
= rectThumb
.x
+ (rectThumb
.width
- m_rectLabel
.width
)/2;
674 else if (style
& (wxSL_LEFT
|wxSL_RIGHT
))
676 rectLabel
.y
= rectThumb
.y
+ (rectThumb
.height
- m_rectLabel
.height
)/2;
679 *rectLabelOut
= rectLabel
;
684 *rectThumbOut
= rectThumb
;
687 // ----------------------------------------------------------------------------
689 // ----------------------------------------------------------------------------
691 wxString
wxSlider::FormatValue(int value
) const
693 return wxString::Format(wxT("%d"), value
);
696 void wxSlider::DoDraw(wxControlRenderer
*renderer
)
698 wxRenderer
*rend
= GetRenderer();
699 wxDC
& dc
= renderer
->GetDC();
700 wxRect rectUpdate
= GetUpdateClientRect();
702 wxOrientation orient
= GetOrientation();
703 int flags
= GetStateFlags();
704 long style
= GetWindowStyle();
706 wxSize sz
= GetThumbSize();
707 int len
= IsVert() ? sz
.x
: sz
.y
;
709 // first draw the shaft
710 wxRect rectShaft
= rend
->GetSliderShaftRect(m_rectSlider
, len
, orient
, style
);
711 if ( rectUpdate
.Intersects(rectShaft
) )
713 rend
->DrawSliderShaft(dc
, m_rectSlider
, len
, orient
, flags
, style
);
716 // calculate the thumb position in pixels and draw it
717 wxRect rectThumb
, rectLabel
;
718 CalcThumbRect(&rectShaft
, &rectThumb
, &rectLabel
);
720 // then draw the ticks
721 if ( HasTicks() && rectUpdate
.Intersects(m_rectTicks
) )
723 rend
->DrawSliderTicks(dc
, m_rectSlider
, len
, orient
,
724 m_min
, m_max
, m_tickFreq
, flags
, style
);
727 // then draw the thumb
728 if ( rectUpdate
.Intersects(rectThumb
) )
730 rend
->DrawSliderThumb(dc
, rectThumb
, orient
, flags
| m_thumbFlags
, style
);
733 // finally, draw the label near the thumb
734 if ( HasLabels() && rectUpdate
.Intersects(rectLabel
) )
736 // align it to be close to the shaft
738 if (style
& wxSL_TOP
)
740 align
= wxALIGN_CENTRE_HORIZONTAL
|wxALIGN_TOP
;
742 else if (style
& wxSL_BOTTOM
)
744 align
= wxALIGN_CENTRE_HORIZONTAL
|wxALIGN_BOTTOM
;
746 else if (style
& wxSL_LEFT
)
748 align
= wxALIGN_CENTRE_VERTICAL
|wxALIGN_LEFT
;
750 else if (style
& wxSL_RIGHT
)
752 align
= wxALIGN_CENTRE_VERTICAL
|wxALIGN_RIGHT
;
755 dc
.SetFont(GetFont());
756 dc
.SetTextForeground(GetForegroundColour());
758 // the slider label is never drawn focused
759 rend
->DrawLabel(dc
, FormatValue(m_value
), rectLabel
,
760 flags
& ~wxCONTROL_FOCUSED
, align
);
764 // ----------------------------------------------------------------------------
765 // wxSlider input processing
766 // ----------------------------------------------------------------------------
768 bool wxSlider::PerformAction(const wxControlAction
& action
,
770 const wxString
& strArg
)
772 wxEventType scrollEvent
= wxEVT_NULL
;
774 bool valueChanged
= true;
776 if ( action
== wxACTION_SLIDER_START
)
778 scrollEvent
= wxEVT_SCROLL_TOP
;
781 else if ( action
== wxACTION_SLIDER_END
)
783 scrollEvent
= wxEVT_SCROLL_BOTTOM
;
786 else if ( action
== wxACTION_SLIDER_PAGE_CHANGE
)
788 value
= NormalizeValue(m_value
+ numArg
* GetPageSize());
790 else if ( action
== wxACTION_SLIDER_LINE_UP
)
792 scrollEvent
= wxEVT_SCROLL_LINEUP
;
793 value
= NormalizeValue(m_value
+ +GetLineSize());
795 else if ( action
== wxACTION_SLIDER_LINE_DOWN
)
797 scrollEvent
= wxEVT_SCROLL_LINEDOWN
;
798 value
= NormalizeValue(m_value
+ -GetLineSize());
800 else if ( action
== wxACTION_SLIDER_PAGE_UP
)
802 scrollEvent
= wxEVT_SCROLL_PAGEUP
;
803 value
= NormalizeValue(m_value
+ +GetPageSize());
805 else if ( action
== wxACTION_SLIDER_PAGE_DOWN
)
807 scrollEvent
= wxEVT_SCROLL_PAGEDOWN
;
808 value
= NormalizeValue(m_value
+ -GetPageSize());
810 else if ( action
== wxACTION_SLIDER_THUMB_DRAG
||
811 action
== wxACTION_SLIDER_THUMB_MOVE
)
813 scrollEvent
= wxEVT_SCROLL_THUMBTRACK
;
815 // we shouldn't generate a command event about this change but we still
816 // should update our value and the slider appearance
817 valueChanged
= false;
822 else if ( action
== wxACTION_SLIDER_THUMB_RELEASE
)
824 scrollEvent
= wxEVT_SCROLL_THUMBRELEASE
;
829 return wxControl::PerformAction(action
, numArg
, strArg
);
832 // update wxSlider current value and generate wxCommandEvent, except while
833 // dragging the thumb
835 ChangeValueTo(value
);
837 // also generate more precise wxScrollEvent if applicable
838 if ( scrollEvent
!= wxEVT_NULL
)
840 wxScrollEvent
event(scrollEvent
, GetId());
841 event
.SetPosition(value
);
842 event
.SetEventObject( this );
843 GetEventHandler()->ProcessEvent(event
);
850 wxInputHandler
*wxSlider::GetStdInputHandler(wxInputHandler
*handlerDef
)
852 static wxStdSliderInputHandler
s_handler(handlerDef
);
857 // ----------------------------------------------------------------------------
858 // wxSlider implementation of wxControlWithThumb interface
859 // ----------------------------------------------------------------------------
861 wxScrollThumb::Shaft
wxSlider::HitTest(const wxPoint
& pt
) const
863 wxRect rectShaft
= GetShaftRect();
865 CalcThumbRect(&rectShaft
, &rectThumb
, NULL
);
867 // check for possible shaft or thumb hit
868 if (!rectShaft
.Contains(pt
) && !rectThumb
.Contains(pt
))
870 return wxScrollThumb::Shaft_None
;
873 // the position to test and the start and end of the thumb
874 wxCoord x
, x1
, x2
, x3
, x4
;
878 x1
= rectThumb
.GetBottom();
879 x2
= rectShaft
.GetBottom();
880 x3
= rectShaft
.GetTop();
881 x4
= rectThumb
.GetTop();
886 x1
= rectShaft
.GetLeft();
887 x2
= rectThumb
.GetLeft();
888 x3
= rectThumb
.GetRight();
889 x4
= rectShaft
.GetRight();
891 if ((x1
<= x
) && (x
< x2
))
894 return wxScrollThumb::Shaft_Above
;
897 if ((x3
< x
) && (x
<= x4
)) {
899 return wxScrollThumb::Shaft_Below
;
902 // where else can it be?
903 return wxScrollThumb::Shaft_Thumb
;
906 wxCoord
wxSlider::ThumbPosToPixel() const
909 CalcThumbRect(NULL
, &rectThumb
, NULL
);
911 return IsVert() ? rectThumb
.y
: rectThumb
.x
;
914 int wxSlider::PixelToThumbPos(wxCoord x
) const
916 wxRect rectShaft
= GetShaftRect();
917 wxSize sizeThumb
= GetThumbSize();
923 len
= rectShaft
.height
- sizeThumb
.y
;
928 len
= rectShaft
.width
- sizeThumb
.x
;
936 pos
+= ((x
- x0
) * (m_max
- m_min
)) / len
;
940 //else: x <= x0, leave pos = min
946 void wxSlider::SetShaftPartState(wxScrollThumb::Shaft shaftPart
,
950 // for now we ignore the flags for the shaft as no renderer uses them
952 if ( shaftPart
== wxScrollThumb::Shaft_Thumb
)
955 m_thumbFlags
|= flag
;
957 m_thumbFlags
&= ~flag
;
963 void wxSlider::OnThumbDragStart(int pos
)
967 PerformAction(wxACTION_SLIDER_THUMB_DRAG
, m_max
- pos
);
971 PerformAction(wxACTION_SLIDER_THUMB_DRAG
, pos
);
975 void wxSlider::OnThumbDrag(int pos
)
979 PerformAction(wxACTION_SLIDER_THUMB_MOVE
, m_max
- pos
);
983 PerformAction(wxACTION_SLIDER_THUMB_MOVE
, pos
);
987 void wxSlider::OnThumbDragEnd(int pos
)
991 PerformAction(wxACTION_SLIDER_THUMB_RELEASE
, m_max
- pos
);
995 PerformAction(wxACTION_SLIDER_THUMB_RELEASE
, pos
);
999 void wxSlider::OnPageScrollStart()
1001 // we do nothing here
1004 bool wxSlider::OnPageScroll(int pageInc
)
1006 int value
= GetValue();
1007 PerformAction(wxACTION_SLIDER_PAGE_CHANGE
, pageInc
);
1009 return GetValue() != value
;
1012 // ----------------------------------------------------------------------------
1013 // wxStdSliderInputHandler
1014 // ----------------------------------------------------------------------------
1016 bool wxStdSliderInputHandler::HandleKey(wxInputConsumer
*consumer
,
1017 const wxKeyEvent
& event
,
1022 int keycode
= event
.GetKeyCode();
1024 wxControlAction action
;
1028 action
= wxACTION_SLIDER_END
;
1032 action
= wxACTION_SLIDER_START
;
1037 action
= wxACTION_SLIDER_LINE_UP
;
1042 action
= wxACTION_SLIDER_LINE_DOWN
;
1046 action
= wxACTION_SLIDER_PAGE_UP
;
1050 action
= wxACTION_SLIDER_PAGE_DOWN
;
1054 if ( !action
.IsEmpty() )
1056 consumer
->PerformAction(action
);
1062 return wxStdInputHandler::HandleKey(consumer
, event
, pressed
);
1065 bool wxStdSliderInputHandler::HandleMouse(wxInputConsumer
*consumer
,
1066 const wxMouseEvent
& event
)
1068 wxSlider
*slider
= wxStaticCast(consumer
->GetInputWindow(), wxSlider
);
1070 if ( slider
->GetThumb().HandleMouse(event
) )
1072 // processed by the thumb
1076 return wxStdInputHandler::HandleMouse(consumer
, event
);
1079 bool wxStdSliderInputHandler::HandleMouseMove(wxInputConsumer
*consumer
,
1080 const wxMouseEvent
& event
)
1082 wxSlider
*slider
= wxStaticCast(consumer
->GetInputWindow(), wxSlider
);
1084 if ( slider
->GetThumb().HandleMouseMove(event
) )
1086 // processed by the thumb
1090 return wxStdInputHandler::HandleMouseMove(consumer
, event
);
1094 wxStdSliderInputHandler::HandleFocus(wxInputConsumer
* WXUNUSED(consumer
),
1095 const wxFocusEvent
& WXUNUSED(event
))
1097 // slider appearance changes when it gets/loses focus
1101 #endif // wxUSE_SLIDER