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