1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/scrarrow.h
3 // Purpose: wxScrollArrows class
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_UNIV_SCRARROW_H_
12 #define _WX_UNIV_SCRARROW_H_
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
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 // ----------------------------------------------------------------------------
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
;
31 // ----------------------------------------------------------------------------
32 // wxScrollArrows: an abstraction of scrollbar arrow
33 // ----------------------------------------------------------------------------
35 class WXDLLIMPEXP_CORE wxScrollArrows
41 Arrow_First
, // left or top
42 Arrow_Second
, // right or bottom
46 // ctor requires a back pointer to wxControlWithArrows
47 wxScrollArrows(wxControlWithArrows
*control
);
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;
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
58 bool HandleMouseMove(const wxMouseEvent
& event
) const;
60 // process a mouse click event
61 bool HandleMouse(const wxMouseEvent
& event
) const;
67 // set or clear the wxCONTROL_CURRENT flag for the arrow
68 void UpdateCurrentFlag(Arrow arrow
, Arrow arrowCur
) const;
71 wxControlWithArrows
*m_control
;
73 // the data for the mouse capture
74 struct wxScrollArrowCaptureData
*m_captureData
;
77 // ----------------------------------------------------------------------------
78 // wxControlWithArrows: interface implemented by controls using wxScrollArrows
79 // ----------------------------------------------------------------------------
81 class WXDLLIMPEXP_CORE wxControlWithArrows
84 virtual ~wxControlWithArrows() {}
86 // get the renderer to use for drawing the arrows
87 virtual wxRenderer
*GetRenderer() const = 0;
89 // get the controls window (used for mouse capturing)
90 virtual wxWindow
*GetWindow() = 0;
92 // get the orientation of the arrows (vertical or horizontal)
93 virtual bool IsVertical() const = 0;
95 // get the state of this arrow as combination of wxCONTROL_XXX flags
96 virtual int GetArrowState(wxScrollArrows::Arrow arrow
) const = 0;
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;
103 // hit testing: return on which arrow the point is (or Arrow_None)
104 virtual wxScrollArrows::Arrow
HitTestArrow(const wxPoint
& pt
) const = 0;
106 // called when the arrow is pressed, return true to continue scrolling and
108 virtual bool OnArrow(wxScrollArrows::Arrow arrow
) = 0;
111 #endif // _WX_UNIV_SCRARROW_H_