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