]>
Commit | Line | Data |
---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/univ/scrarrow.h | |
3 | // Purpose: wxScrollArrows class | |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 22.01.01 | |
7 | // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com) | |
8 | // Licence: wxWindows licence | |
9 | /////////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #ifndef _WX_UNIV_SCRARROW_H_ | |
12 | #define _WX_UNIV_SCRARROW_H_ | |
13 | ||
14 | // ---------------------------------------------------------------------------- | |
15 | // wxScrollArrows is not a control but just a class containing the common | |
16 | // functionality of scroll arrows, whether part of scrollbars, spin ctrls or | |
17 | // anything else. | |
18 | // | |
19 | // To customize its behaviour, wxScrollArrows doesn't use any virtual methods | |
20 | // but instead a callback pointer to a wxControlWithArrows object which is used | |
21 | // for all control-dependent stuff. Thus, to use wxScrollArrows, you just need | |
22 | // to derive from the wxControlWithArrows interface and implement its methods. | |
23 | // ---------------------------------------------------------------------------- | |
24 | ||
25 | class WXDLLIMPEXP_FWD_CORE wxControlWithArrows; | |
26 | class WXDLLIMPEXP_FWD_CORE wxDC; | |
27 | class WXDLLIMPEXP_FWD_CORE wxMouseEvent; | |
28 | class WXDLLIMPEXP_FWD_CORE wxRect; | |
29 | class WXDLLIMPEXP_FWD_CORE wxRenderer; | |
30 | ||
31 | // ---------------------------------------------------------------------------- | |
32 | // wxScrollArrows: an abstraction of scrollbar arrow | |
33 | // ---------------------------------------------------------------------------- | |
34 | ||
35 | class WXDLLIMPEXP_CORE wxScrollArrows | |
36 | { | |
37 | public: | |
38 | enum Arrow | |
39 | { | |
40 | Arrow_None = -1, | |
41 | Arrow_First, // left or top | |
42 | Arrow_Second, // right or bottom | |
43 | Arrow_Max | |
44 | }; | |
45 | ||
46 | // ctor requires a back pointer to wxControlWithArrows | |
47 | wxScrollArrows(wxControlWithArrows *control); | |
48 | ||
49 | // draws the arrow on the given DC in the given rectangle, uses | |
50 | // wxControlWithArrows::GetArrowState() to get its current state | |
51 | void DrawArrow(Arrow arrow, wxDC& dc, const wxRect& rect, | |
52 | bool scrollbarLike = false) const; | |
53 | ||
54 | // process a mouse move, enter or leave event, possibly calling | |
55 | // wxControlWithArrows::SetArrowState() if | |
56 | // wxControlWithArrows::HitTestArrow() says that the mouse has left/entered | |
57 | // an arrow | |
58 | bool HandleMouseMove(const wxMouseEvent& event) const; | |
59 | ||
60 | // process a mouse click event | |
61 | bool HandleMouse(const wxMouseEvent& event) const; | |
62 | ||
63 | // dtor | |
64 | ~wxScrollArrows(); | |
65 | ||
66 | private: | |
67 | // set or clear the wxCONTROL_CURRENT flag for the arrow | |
68 | void UpdateCurrentFlag(Arrow arrow, Arrow arrowCur) const; | |
69 | ||
70 | // the main control | |
71 | wxControlWithArrows *m_control; | |
72 | ||
73 | // the data for the mouse capture | |
74 | struct wxScrollArrowCaptureData *m_captureData; | |
75 | }; | |
76 | ||
77 | // ---------------------------------------------------------------------------- | |
78 | // wxControlWithArrows: interface implemented by controls using wxScrollArrows | |
79 | // ---------------------------------------------------------------------------- | |
80 | ||
81 | class WXDLLIMPEXP_CORE wxControlWithArrows | |
82 | { | |
83 | public: | |
84 | virtual ~wxControlWithArrows() {} | |
85 | ||
86 | // get the renderer to use for drawing the arrows | |
87 | virtual wxRenderer *GetRenderer() const = 0; | |
88 | ||
89 | // get the controls window (used for mouse capturing) | |
90 | virtual wxWindow *GetWindow() = 0; | |
91 | ||
92 | // get the orientation of the arrows (vertical or horizontal) | |
93 | virtual bool IsVertical() const = 0; | |
94 | ||
95 | // get the state of this arrow as combination of wxCONTROL_XXX flags | |
96 | virtual int GetArrowState(wxScrollArrows::Arrow arrow) const = 0; | |
97 | ||
98 | // set or clear the specified flag in the arrow state: this function is | |
99 | // responsible for refreshing the control | |
100 | virtual void SetArrowFlag(wxScrollArrows::Arrow arrow, | |
101 | int flag, bool set = true) = 0; | |
102 | ||
103 | // hit testing: return on which arrow the point is (or Arrow_None) | |
104 | virtual wxScrollArrows::Arrow HitTestArrow(const wxPoint& pt) const = 0; | |
105 | ||
106 | // called when the arrow is pressed, return true to continue scrolling and | |
107 | // false to stop it | |
108 | virtual bool OnArrow(wxScrollArrows::Arrow arrow) = 0; | |
109 | }; | |
110 | ||
111 | #endif // _WX_UNIV_SCRARROW_H_ |