]> git.saurik.com Git - wxWidgets.git/blob - include/wx/univ/scrarrow.h
renamed BLOCK_SIZE which conflicts with a #define in a std Linux (and maybe not only...
[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 wxControlWithArrows::HitTest()
57 // says that the mosue has left/entered 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 WXDLLEXPORT wxControlWithArrows
82 {
83 public:
84 // get the renderer to use for drawing the arrows
85 virtual wxRenderer *GetRenderer() const = 0;
86
87 // get the controls window (used for mouse capturing)
88 virtual wxWindow *GetWindow() = 0;
89
90 // get the orientation of the arrows (vertical or horizontal)
91 virtual bool IsVertical() const = 0;
92
93 // get the state of this arrow as combination of wxCONTROL_XXX flags
94 virtual int GetArrowState(wxScrollArrows::Arrow arrow) const = 0;
95
96 // set or clear the specified flag in the arrow state: this function is
97 // responsible for refreshing the control
98 virtual void SetArrowFlag(wxScrollArrows::Arrow arrow,
99 int flag, bool set = true) = 0;
100
101 // hit testing: return on which arrow the point is (or Arrow_None)
102 virtual wxScrollArrows::Arrow HitTest(const wxPoint& pt) const = 0;
103
104 // called when the arrow is pressed, return true to continue scrolling and
105 // false to stop it
106 virtual bool OnArrow(wxScrollArrows::Arrow arrow) = 0;
107 };
108
109 #endif // _WX_UNIV_SCRARROW_H_