1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/scrarrow.h
3 // Purpose: wxScrollArrows class
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_UNIV_SCRARROW_H_
13 #define _WX_UNIV_SCRARROW_H_
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
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 // ----------------------------------------------------------------------------
26 class WXDLLIMPEXP_FWD_CORE wxControlWithArrows
;
27 class WXDLLIMPEXP_FWD_CORE wxDC
;
28 class WXDLLIMPEXP_FWD_CORE wxMouseEvent
;
29 class WXDLLIMPEXP_FWD_CORE wxRect
;
30 class WXDLLIMPEXP_FWD_CORE wxRenderer
;
32 // ----------------------------------------------------------------------------
33 // wxScrollArrows: an abstraction of scrollbar arrow
34 // ----------------------------------------------------------------------------
36 class WXDLLIMPEXP_CORE wxScrollArrows
42 Arrow_First
, // left or top
43 Arrow_Second
, // right or bottom
47 // ctor requires a back pointer to wxControlWithArrows
48 wxScrollArrows(wxControlWithArrows
*control
);
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;
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
59 bool HandleMouseMove(const wxMouseEvent
& event
) const;
61 // process a mouse click event
62 bool HandleMouse(const wxMouseEvent
& event
) const;
68 // set or clear the wxCONTROL_CURRENT flag for the arrow
69 void UpdateCurrentFlag(Arrow arrow
, Arrow arrowCur
) const;
72 wxControlWithArrows
*m_control
;
74 // the data for the mouse capture
75 struct wxScrollArrowCaptureData
*m_captureData
;
78 // ----------------------------------------------------------------------------
79 // wxControlWithArrows: interface implemented by controls using wxScrollArrows
80 // ----------------------------------------------------------------------------
82 class WXDLLIMPEXP_CORE wxControlWithArrows
85 virtual ~wxControlWithArrows() {}
87 // get the renderer to use for drawing the arrows
88 virtual wxRenderer
*GetRenderer() const = 0;
90 // get the controls window (used for mouse capturing)
91 virtual wxWindow
*GetWindow() = 0;
93 // get the orientation of the arrows (vertical or horizontal)
94 virtual bool IsVertical() const = 0;
96 // get the state of this arrow as combination of wxCONTROL_XXX flags
97 virtual int GetArrowState(wxScrollArrows::Arrow arrow
) const = 0;
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;
104 // hit testing: return on which arrow the point is (or Arrow_None)
105 virtual wxScrollArrows::Arrow
HitTestArrow(const wxPoint
& pt
) const = 0;
107 // called when the arrow is pressed, return true to continue scrolling and
109 virtual bool OnArrow(wxScrollArrows::Arrow arrow
) = 0;
112 #endif // _WX_UNIV_SCRARROW_H_