]>
Commit | Line | Data |
---|---|---|
1e6feb95 VZ |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/univ/scrthumb.h | |
3 | // Purpose: wxScrollThumb class | |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 12.02.01 | |
442b35b5 | 7 | // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com) |
65571936 | 8 | // Licence: wxWindows licence |
1e6feb95 VZ |
9 | /////////////////////////////////////////////////////////////////////////////// |
10 | ||
11 | #ifndef _WX_UNIV_SCRTHUMB_H_ | |
12 | #define _WX_UNIV_SCRTHUMB_H_ | |
13 | ||
1e6feb95 VZ |
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 | |
18 | // | |
19 | // This class is similar to wxScrollThumb. | |
20 | // ---------------------------------------------------------------------------- | |
21 | ||
b5dbe15d VS |
22 | class WXDLLIMPEXP_FWD_CORE wxControlWithThumb; |
23 | class WXDLLIMPEXP_FWD_CORE wxMouseEvent; | |
24 | class WXDLLIMPEXP_FWD_CORE wxRect; | |
25 | class WXDLLIMPEXP_FWD_CORE wxScrollTimer; | |
1e6feb95 VZ |
26 | |
27 | #include "wx/timer.h" | |
28 | ||
29 | // ---------------------------------------------------------------------------- | |
30 | // wxScrollThumb: an abstraction of scrollbar thumb | |
31 | // ---------------------------------------------------------------------------- | |
32 | ||
53a2db12 | 33 | class WXDLLIMPEXP_CORE wxScrollThumb |
1e6feb95 VZ |
34 | { |
35 | public: | |
36 | enum Shaft | |
37 | { | |
38 | Shaft_None = -1, | |
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 | |
42 | Shaft_Max | |
43 | }; | |
44 | ||
45 | // ctor requires a back pointer to wxControlWithThumb | |
46 | wxScrollThumb(wxControlWithThumb *control); | |
47 | ||
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 | |
50 | // scrolling) | |
51 | bool HandleMouse(const wxMouseEvent& event) const; | |
52 | ||
53 | // process a mouse move | |
54 | bool HandleMouseMove(const wxMouseEvent& event) const; | |
55 | ||
56 | // dtor | |
57 | ~wxScrollThumb(); | |
58 | ||
59 | private: | |
60 | // do we have the mouse capture? | |
61 | bool HasCapture() const { return m_captureData != NULL; } | |
62 | ||
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; | |
66 | ||
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; | |
70 | ||
71 | // the main control | |
72 | wxControlWithThumb *m_control; | |
73 | ||
74 | // the part of it where the mouse currently is | |
75 | Shaft m_shaftPart; | |
76 | ||
77 | // the data for the mouse capture | |
b5dbe15d | 78 | struct WXDLLIMPEXP_FWD_CORE wxScrollThumbCaptureData *m_captureData; |
1e6feb95 VZ |
79 | }; |
80 | ||
81 | // ---------------------------------------------------------------------------- | |
82 | // wxControlWithThumb: interface implemented by controls using wxScrollThumb | |
83 | // ---------------------------------------------------------------------------- | |
84 | ||
53a2db12 | 85 | class WXDLLIMPEXP_CORE wxControlWithThumb |
1e6feb95 VZ |
86 | { |
87 | public: | |
23ff76d5 WS |
88 | virtual ~wxControlWithThumb() {} |
89 | ||
1e6feb95 VZ |
90 | // simple accessors |
91 | // ---------------- | |
92 | ||
93 | // get the controls window (used for mouse capturing) | |
94 | virtual wxWindow *GetWindow() = 0; | |
95 | ||
96 | // get the orientation of the shaft (vertical or horizontal) | |
97 | virtual bool IsVertical() const = 0; | |
98 | ||
99 | // geometry functions | |
100 | // ------------------ | |
101 | ||
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; | |
104 | ||
105 | // get the current position in pixels of the thumb | |
106 | virtual wxCoord ThumbPosToPixel() const = 0; | |
107 | ||
108 | // transform from pixel offset to the thumb logical position | |
109 | virtual int PixelToThumbPos(wxCoord x) const = 0; | |
110 | ||
111 | // callbacks | |
112 | // --------- | |
113 | ||
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, | |
117 | int flag, | |
a290fa5a | 118 | bool set = true) = 0; |
1e6feb95 VZ |
119 | |
120 | // called when the user starts dragging the thumb | |
121 | virtual void OnThumbDragStart(int pos) = 0; | |
122 | ||
123 | // called while the user drags the thumb | |
124 | virtual void OnThumbDrag(int pos) = 0; | |
125 | ||
126 | // called when the user stops dragging the thumb | |
127 | virtual void OnThumbDragEnd(int pos) = 0; | |
128 | ||
129 | // called before starting to call OnPageScroll() - gives the control the | |
130 | // possibility to remember its current state | |
131 | virtual void OnPageScrollStart() = 0; | |
132 | ||
133 | // called while the user keeps the mouse pressed above/below the thumb, | |
a290fa5a | 134 | // return true to continue scrollign and false to stop it (e.g. because the |
1e6feb95 VZ |
135 | // scrollbar has reached the top/bottom) |
136 | virtual bool OnPageScroll(int pageInc) = 0; | |
137 | }; | |
138 | ||
139 | #endif // _WX_UNIV_SCRTHUMB_H_ |