1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/spinbutt.h
3 // Purpose: universal version of wxSpinButton
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_UNIV_SPINBUTT_H_
13 #define _WX_UNIV_SPINBUTT_H_
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "univspinbutt.h"
19 #include "wx/univ/scrarrow.h"
21 // ----------------------------------------------------------------------------
23 // ----------------------------------------------------------------------------
25 // actions supported by this control
26 #define wxACTION_SPIN_INC _T("inc")
27 #define wxACTION_SPIN_DEC _T("dec")
29 class WXDLLEXPORT wxSpinButton
: public wxSpinButtonBase
,
30 public wxControlWithArrows
34 wxSpinButton(wxWindow
*parent
,
36 const wxPoint
& pos
= wxDefaultPosition
,
37 const wxSize
& size
= wxDefaultSize
,
38 long style
= wxSP_VERTICAL
| wxSP_ARROW_KEYS
,
39 const wxString
& name
= wxSPIN_BUTTON_NAME
);
41 bool Create(wxWindow
*parent
,
43 const wxPoint
& pos
= wxDefaultPosition
,
44 const wxSize
& size
= wxDefaultSize
,
45 long style
= wxSP_VERTICAL
| wxSP_ARROW_KEYS
,
46 const wxString
& name
= wxSPIN_BUTTON_NAME
);
48 // implement wxSpinButtonBase methods
49 virtual int GetValue() const;
50 virtual void SetValue(int val
);
51 virtual void SetRange(int minVal
, int maxVal
);
53 // implement wxControlWithArrows methods
54 virtual wxRenderer
*GetRenderer() const { return m_renderer
; }
55 virtual wxWindow
*GetWindow() { return this; }
56 virtual bool IsVertical() const { return wxSpinButtonBase::IsVertical(); }
57 virtual int GetArrowState(wxScrollArrows::Arrow arrow
) const;
58 virtual void SetArrowFlag(wxScrollArrows::Arrow arrow
, int flag
, bool set
);
59 virtual bool OnArrow(wxScrollArrows::Arrow arrow
);
60 virtual wxScrollArrows::Arrow
HitTest(const wxPoint
& pt
) const;
62 // for wxStdSpinButtonInputHandler
63 const wxScrollArrows
& GetArrows() { return m_arrows
; }
66 virtual wxSize
DoGetBestClientSize() const;
67 virtual void DoDraw(wxControlRenderer
*renderer
);
68 virtual wxBorder
GetDefaultBorder() const { return wxBORDER_NONE
; }
70 virtual bool PerformAction(const wxControlAction
& action
,
72 const wxString
& strArg
= wxEmptyString
);
74 // the common part of all ctors
77 // normalize the value to fit into min..max range
78 int NormalizeValue(int value
) const;
80 // change the value by +1/-1 and send the event, return TRUE if value was
82 bool ChangeValue(int inc
);
84 // get the rectangles for our 2 arrows
85 void CalcArrowRects(wxRect
*rect1
, wxRect
*rect2
) const;
87 // the current controls value
91 // the object which manages our arrows
92 wxScrollArrows m_arrows
;
94 // the state (combination of wxCONTROL_XXX flags) of the arrows
95 int m_arrowsState
[wxScrollArrows::Arrow_Max
];
97 DECLARE_DYNAMIC_CLASS(wxSpinButton
)
100 // ----------------------------------------------------------------------------
101 // wxStdSpinButtonInputHandler: manages clicks on them (use arrows like
102 // wxStdScrollBarInputHandler) and processes keyboard events too
103 // ----------------------------------------------------------------------------
105 class WXDLLEXPORT wxStdSpinButtonInputHandler
: public wxStdInputHandler
108 wxStdSpinButtonInputHandler(wxInputHandler
*inphand
);
110 virtual bool HandleKey(wxInputConsumer
*consumer
,
111 const wxKeyEvent
& event
,
113 virtual bool HandleMouse(wxInputConsumer
*consumer
,
114 const wxMouseEvent
& event
);
115 virtual bool HandleMouseMove(wxInputConsumer
*consumer
,
116 const wxMouseEvent
& event
);
119 #endif // _WX_UNIV_SPINBUTT_H_