1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/scrthumb.h
3 // Purpose: wxScrollThumb class
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_UNIV_SCRTHUMB_H_
13 #define _WX_UNIV_SCRTHUMB_H_
15 // ----------------------------------------------------------------------------
16 // wxScrollThumb is not a control but just a class containing the common
17 // functionality of scroll thumb such as used by scrollbars, sliders and maybe
18 // other (user) controls
20 // This class is similar to wxScrollThumb.
21 // ----------------------------------------------------------------------------
23 class WXDLLEXPORT wxControlWithThumb
;
24 class WXDLLEXPORT wxMouseEvent
;
25 class WXDLLEXPORT wxRect
;
26 class WXDLLEXPORT wxScrollTimer
;
30 // ----------------------------------------------------------------------------
31 // wxScrollThumb: an abstraction of scrollbar thumb
32 // ----------------------------------------------------------------------------
34 class WXDLLEXPORT wxScrollThumb
40 Shaft_Above
, // or to the left of the thumb
41 Shaft_Below
, // or to the right of the thumb
42 Shaft_Thumb
, // on the thumb
46 // ctor requires a back pointer to wxControlWithThumb
47 wxScrollThumb(wxControlWithThumb
*control
);
49 // process a mouse click: will capture the mouse if the button was pressed
50 // on either the thumb (start dragging it then) or the shaft (start
52 bool HandleMouse(const wxMouseEvent
& event
) const;
54 // process a mouse move
55 bool HandleMouseMove(const wxMouseEvent
& event
) const;
61 // do we have the mouse capture?
62 bool HasCapture() const { return m_captureData
!= NULL
; }
64 // get the coord of this event in the direction we're interested in (y for
65 // vertical shaft or x for horizontal ones)
66 wxCoord
GetMouseCoord(const wxMouseEvent
& event
) const;
68 // get the position of the thumb corresponding to the current mouse
69 // position (can only be called while we're dragging the thumb!)
70 int GetThumbPos(const wxMouseEvent
& event
) const;
73 wxControlWithThumb
*m_control
;
75 // the part of it where the mouse currently is
78 // the data for the mouse capture
79 struct WXDLLEXPORT wxScrollThumbCaptureData
*m_captureData
;
82 // ----------------------------------------------------------------------------
83 // wxControlWithThumb: interface implemented by controls using wxScrollThumb
84 // ----------------------------------------------------------------------------
86 class WXDLLEXPORT wxControlWithThumb
92 // get the controls window (used for mouse capturing)
93 virtual wxWindow
*GetWindow() = 0;
95 // get the orientation of the shaft (vertical or horizontal)
96 virtual bool IsVertical() const = 0;
101 // hit testing: return part of the shaft the point is in (or Shaft_None)
102 virtual wxScrollThumb::Shaft
HitTest(const wxPoint
& pt
) const = 0;
104 // get the current position in pixels of the thumb
105 virtual wxCoord
ThumbPosToPixel() const = 0;
107 // transform from pixel offset to the thumb logical position
108 virtual int PixelToThumbPos(wxCoord x
) const = 0;
113 // set or clear the specified flag in the arrow state: this function is
114 // responsible for refreshing the control
115 virtual void SetShaftPartState(wxScrollThumb::Shaft shaftPart
,
117 bool set
= true) = 0;
119 // called when the user starts dragging the thumb
120 virtual void OnThumbDragStart(int pos
) = 0;
122 // called while the user drags the thumb
123 virtual void OnThumbDrag(int pos
) = 0;
125 // called when the user stops dragging the thumb
126 virtual void OnThumbDragEnd(int pos
) = 0;
128 // called before starting to call OnPageScroll() - gives the control the
129 // possibility to remember its current state
130 virtual void OnPageScrollStart() = 0;
132 // called while the user keeps the mouse pressed above/below the thumb,
133 // return true to continue scrollign and false to stop it (e.g. because the
134 // scrollbar has reached the top/bottom)
135 virtual bool OnPageScroll(int pageInc
) = 0;
138 #endif // _WX_UNIV_SCRTHUMB_H_