1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/scrthumb.h
3 // Purpose: wxScrollThumb class
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_UNIV_SCRTHUMB_H_
12 #define _WX_UNIV_SCRTHUMB_H_
14 // ----------------------------------------------------------------------------
15 // wxScrollThumb is not a control but just a class containing the common
16 // functionality of scroll thumb such as used by scrollbars, sliders and maybe
17 // other (user) controls
19 // This class is similar to wxScrollThumb.
20 // ----------------------------------------------------------------------------
22 class WXDLLIMPEXP_FWD_CORE wxControlWithThumb
;
23 class WXDLLIMPEXP_FWD_CORE wxMouseEvent
;
24 class WXDLLIMPEXP_FWD_CORE wxRect
;
25 class WXDLLIMPEXP_FWD_CORE wxScrollTimer
;
29 // ----------------------------------------------------------------------------
30 // wxScrollThumb: an abstraction of scrollbar thumb
31 // ----------------------------------------------------------------------------
33 class WXDLLIMPEXP_CORE wxScrollThumb
39 Shaft_Above
, // or to the left of the thumb
40 Shaft_Below
, // or to the right of the thumb
41 Shaft_Thumb
, // on the thumb
45 // ctor requires a back pointer to wxControlWithThumb
46 wxScrollThumb(wxControlWithThumb
*control
);
48 // process a mouse click: will capture the mouse if the button was pressed
49 // on either the thumb (start dragging it then) or the shaft (start
51 bool HandleMouse(const wxMouseEvent
& event
) const;
53 // process a mouse move
54 bool HandleMouseMove(const wxMouseEvent
& event
) const;
60 // do we have the mouse capture?
61 bool HasCapture() const { return m_captureData
!= NULL
; }
63 // get the coord of this event in the direction we're interested in (y for
64 // vertical shaft or x for horizontal ones)
65 wxCoord
GetMouseCoord(const wxMouseEvent
& event
) const;
67 // get the position of the thumb corresponding to the current mouse
68 // position (can only be called while we're dragging the thumb!)
69 int GetThumbPos(const wxMouseEvent
& event
) const;
72 wxControlWithThumb
*m_control
;
74 // the part of it where the mouse currently is
77 // the data for the mouse capture
78 struct WXDLLIMPEXP_FWD_CORE wxScrollThumbCaptureData
*m_captureData
;
81 // ----------------------------------------------------------------------------
82 // wxControlWithThumb: interface implemented by controls using wxScrollThumb
83 // ----------------------------------------------------------------------------
85 class WXDLLIMPEXP_CORE wxControlWithThumb
88 virtual ~wxControlWithThumb() {}
93 // get the controls window (used for mouse capturing)
94 virtual wxWindow
*GetWindow() = 0;
96 // get the orientation of the shaft (vertical or horizontal)
97 virtual bool IsVertical() const = 0;
100 // ------------------
102 // hit testing: return part of the shaft the point is in (or Shaft_None)
103 virtual wxScrollThumb::Shaft
HitTest(const wxPoint
& pt
) const = 0;
105 // get the current position in pixels of the thumb
106 virtual wxCoord
ThumbPosToPixel() const = 0;
108 // transform from pixel offset to the thumb logical position
109 virtual int PixelToThumbPos(wxCoord x
) const = 0;
114 // set or clear the specified flag in the arrow state: this function is
115 // responsible for refreshing the control
116 virtual void SetShaftPartState(wxScrollThumb::Shaft shaftPart
,
118 bool set
= true) = 0;
120 // called when the user starts dragging the thumb
121 virtual void OnThumbDragStart(int pos
) = 0;
123 // called while the user drags the thumb
124 virtual void OnThumbDrag(int pos
) = 0;
126 // called when the user stops dragging the thumb
127 virtual void OnThumbDragEnd(int pos
) = 0;
129 // called before starting to call OnPageScroll() - gives the control the
130 // possibility to remember its current state
131 virtual void OnPageScrollStart() = 0;
133 // called while the user keeps the mouse pressed above/below the thumb,
134 // return true to continue scrollign and false to stop it (e.g. because the
135 // scrollbar has reached the top/bottom)
136 virtual bool OnPageScroll(int pageInc
) = 0;
139 #endif // _WX_UNIV_SCRTHUMB_H_