1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/scrarrow.h
3 // Purpose: wxScrollArrows class
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_UNIV_SCRARROW_H_
13 #define _WX_UNIV_SCRARROW_H_
16 #pragma interface "univscrarrow.h"
19 // ----------------------------------------------------------------------------
20 // wxScrollArrows is not a control but just a class containing the common
21 // functionality of scroll arrows, whether part of scrollbars, spin ctrls or
24 // To customize its behaviour, wxScrollArrows doesn't use any virtual methods
25 // but instead a callback pointer to a wxControlWithArrows object which is used
26 // for all control-dependent stuff. Thus, to use wxScrollArrows, you just need
27 // to derive from the wxControlWithArrows interface and implement its methods.
28 // ----------------------------------------------------------------------------
30 class WXDLLEXPORT wxControlWithArrows
;
31 class WXDLLEXPORT wxDC
;
32 class WXDLLEXPORT wxMouseEvent
;
33 class WXDLLEXPORT wxRect
;
34 class WXDLLEXPORT wxRenderer
;
36 // ----------------------------------------------------------------------------
37 // wxScrollArrows: an abstraction of scrollbar arrow
38 // ----------------------------------------------------------------------------
40 class WXDLLEXPORT wxScrollArrows
46 Arrow_First
, // left or top
47 Arrow_Second
, // right or bottom
51 // ctor requires a back pointer to wxControlWithArrows
52 wxScrollArrows(wxControlWithArrows
*control
);
54 // draws the arrow on the given DC in the given rectangle, uses
55 // wxControlWithArrows::GetArrowState() to get its current state
56 void DrawArrow(Arrow arrow
, wxDC
& dc
, const wxRect
& rect
,
57 bool scrollbarLike
= FALSE
) const;
59 // process a mouse move, enter or leave event, possibly calling
60 // wxControlWithArrows::SetArrowState() if wxControlWithArrows::HitTest()
61 // says that the mosue has left/entered an arrow
62 bool HandleMouseMove(const wxMouseEvent
& event
) const;
64 // process a mouse click event
65 bool HandleMouse(const wxMouseEvent
& event
) const;
71 // set or clear the wxCONTROL_CURRENT flag for the arrow
72 void UpdateCurrentFlag(Arrow arrow
, Arrow arrowCur
) const;
75 wxControlWithArrows
*m_control
;
77 // the data for the mouse capture
78 struct wxScrollArrowCaptureData
*m_captureData
;
81 // ----------------------------------------------------------------------------
82 // wxControlWithArrows: interface implemented by controls using wxScrollArrows
83 // ----------------------------------------------------------------------------
85 class WXDLLEXPORT wxControlWithArrows
88 // get the renderer to use for drawing the arrows
89 virtual wxRenderer
*GetRenderer() const = 0;
91 // get the controls window (used for mouse capturing)
92 virtual wxWindow
*GetWindow() = 0;
94 // get the orientation of the arrows (vertical or horizontal)
95 virtual bool IsVertical() const = 0;
97 // get the state of this arrow as combination of wxCONTROL_XXX flags
98 virtual int GetArrowState(wxScrollArrows::Arrow arrow
) const = 0;
100 // set or clear the specified flag in the arrow state: this function is
101 // responsible for refreshing the control
102 virtual void SetArrowFlag(wxScrollArrows::Arrow arrow
,
103 int flag
, bool set
= TRUE
) = 0;
105 // hit testing: return on which arrow the point is (or Arrow_None)
106 virtual wxScrollArrows::Arrow
HitTest(const wxPoint
& pt
) const = 0;
108 // called when the arrow is pressed, return TRUE to continue scrolling and
110 virtual bool OnArrow(wxScrollArrows::Arrow arrow
) = 0;
113 #endif // _WX_UNIV_SCRARROW_H_