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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "univscrthumb.h"
19 // ----------------------------------------------------------------------------
20 // wxScrollThumb is not a control but just a class containing the common
21 // functionality of scroll thumb such as used by scrollbars, sliders and maybe
22 // other (user) controls
24 // This class is similar to wxScrollThumb.
25 // ----------------------------------------------------------------------------
27 class WXDLLEXPORT wxControlWithThumb
;
28 class WXDLLEXPORT wxMouseEvent
;
29 class WXDLLEXPORT wxRect
;
30 class WXDLLEXPORT wxScrollTimer
;
34 // ----------------------------------------------------------------------------
35 // wxScrollThumb: an abstraction of scrollbar thumb
36 // ----------------------------------------------------------------------------
38 class WXDLLEXPORT wxScrollThumb
44 Shaft_Above
, // or to the left of the thumb
45 Shaft_Below
, // or to the right of the thumb
46 Shaft_Thumb
, // on the thumb
50 // ctor requires a back pointer to wxControlWithThumb
51 wxScrollThumb(wxControlWithThumb
*control
);
53 // process a mouse click: will capture the mouse if the button was pressed
54 // on either the thumb (start dragging it then) or the shaft (start
56 bool HandleMouse(const wxMouseEvent
& event
) const;
58 // process a mouse move
59 bool HandleMouseMove(const wxMouseEvent
& event
) const;
65 // do we have the mouse capture?
66 bool HasCapture() const { return m_captureData
!= NULL
; }
68 // get the coord of this event in the direction we're interested in (y for
69 // vertical shaft or x for horizontal ones)
70 wxCoord
GetMouseCoord(const wxMouseEvent
& event
) const;
72 // get the position of the thumb corresponding to the current mouse
73 // position (can only be called while we're dragging the thumb!)
74 int GetThumbPos(const wxMouseEvent
& event
) const;
77 wxControlWithThumb
*m_control
;
79 // the part of it where the mouse currently is
82 // the data for the mouse capture
83 struct WXDLLEXPORT wxScrollThumbCaptureData
*m_captureData
;
86 // ----------------------------------------------------------------------------
87 // wxControlWithThumb: interface implemented by controls using wxScrollThumb
88 // ----------------------------------------------------------------------------
90 class WXDLLEXPORT wxControlWithThumb
96 // get the controls window (used for mouse capturing)
97 virtual wxWindow
*GetWindow() = 0;
99 // get the orientation of the shaft (vertical or horizontal)
100 virtual bool IsVertical() const = 0;
102 // geometry functions
103 // ------------------
105 // hit testing: return part of the shaft the point is in (or Shaft_None)
106 virtual wxScrollThumb::Shaft
HitTest(const wxPoint
& pt
) const = 0;
108 // get the current position in pixels of the thumb
109 virtual wxCoord
ThumbPosToPixel() const = 0;
111 // transform from pixel offset to the thumb logical position
112 virtual int PixelToThumbPos(wxCoord x
) const = 0;
117 // set or clear the specified flag in the arrow state: this function is
118 // responsible for refreshing the control
119 virtual void SetShaftPartState(wxScrollThumb::Shaft shaftPart
,
121 bool set
= TRUE
) = 0;
123 // called when the user starts dragging the thumb
124 virtual void OnThumbDragStart(int pos
) = 0;
126 // called while the user drags the thumb
127 virtual void OnThumbDrag(int pos
) = 0;
129 // called when the user stops dragging the thumb
130 virtual void OnThumbDragEnd(int pos
) = 0;
132 // called before starting to call OnPageScroll() - gives the control the
133 // possibility to remember its current state
134 virtual void OnPageScrollStart() = 0;
136 // called while the user keeps the mouse pressed above/below the thumb,
137 // return TRUE to continue scrollign and FALSE to stop it (e.g. because the
138 // scrollbar has reached the top/bottom)
139 virtual bool OnPageScroll(int pageInc
) = 0;
142 #endif // _WX_UNIV_SCRTHUMB_H_