]> git.saurik.com Git - wxWidgets.git/blob - include/wx/univ/spinbutt.h
Add lambda-friendly wxDialog::ShowWindowModalThenDo().
[wxWidgets.git] / include / wx / univ / spinbutt.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/spinbutt.h
3 // Purpose: universal version of wxSpinButton
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 21.01.01
7 // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_UNIV_SPINBUTT_H_
12 #define _WX_UNIV_SPINBUTT_H_
13
14 #include "wx/univ/scrarrow.h"
15
16 // ----------------------------------------------------------------------------
17 // wxSpinButton
18 // ----------------------------------------------------------------------------
19
20 // actions supported by this control
21 #define wxACTION_SPIN_INC wxT("inc")
22 #define wxACTION_SPIN_DEC wxT("dec")
23
24 class WXDLLIMPEXP_CORE wxSpinButton : public wxSpinButtonBase,
25 public wxControlWithArrows
26 {
27 public:
28 wxSpinButton();
29 wxSpinButton(wxWindow *parent,
30 wxWindowID id = wxID_ANY,
31 const wxPoint& pos = wxDefaultPosition,
32 const wxSize& size = wxDefaultSize,
33 long style = wxSP_VERTICAL | wxSP_ARROW_KEYS,
34 const wxString& name = wxSPIN_BUTTON_NAME);
35
36 bool Create(wxWindow *parent,
37 wxWindowID id = wxID_ANY,
38 const wxPoint& pos = wxDefaultPosition,
39 const wxSize& size = wxDefaultSize,
40 long style = wxSP_VERTICAL | wxSP_ARROW_KEYS,
41 const wxString& name = wxSPIN_BUTTON_NAME);
42
43 // implement wxSpinButtonBase methods
44 virtual int GetValue() const;
45 virtual void SetValue(int val);
46 virtual void SetRange(int minVal, int maxVal);
47
48 // implement wxControlWithArrows methods
49 virtual wxRenderer *GetRenderer() const { return m_renderer; }
50 virtual wxWindow *GetWindow() { return this; }
51 virtual bool IsVertical() const { return wxSpinButtonBase::IsVertical(); }
52 virtual int GetArrowState(wxScrollArrows::Arrow arrow) const;
53 virtual void SetArrowFlag(wxScrollArrows::Arrow arrow, int flag, bool set);
54 virtual bool OnArrow(wxScrollArrows::Arrow arrow);
55 virtual wxScrollArrows::Arrow HitTestArrow(const wxPoint& pt) const;
56
57 // for wxStdSpinButtonInputHandler
58 const wxScrollArrows& GetArrows() { return m_arrows; }
59
60 virtual bool PerformAction(const wxControlAction& action,
61 long numArg = 0,
62 const wxString& strArg = wxEmptyString);
63
64 static wxInputHandler *GetStdInputHandler(wxInputHandler *handlerDef);
65 virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef)
66 {
67 return GetStdInputHandler(handlerDef);
68 }
69
70 protected:
71 virtual wxSize DoGetBestClientSize() const;
72 virtual void DoDraw(wxControlRenderer *renderer);
73 virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
74
75 // the common part of all ctors
76 void Init();
77
78 // normalize the value to fit into min..max range
79 int NormalizeValue(int value) const;
80
81 // change the value by +1/-1 and send the event, return true if value was
82 // changed
83 bool ChangeValue(int inc);
84
85 // get the rectangles for our 2 arrows
86 void CalcArrowRects(wxRect *rect1, wxRect *rect2) const;
87
88 // the current controls value
89 int m_value;
90
91 private:
92 // the object which manages our arrows
93 wxScrollArrows m_arrows;
94
95 // the state (combination of wxCONTROL_XXX flags) of the arrows
96 int m_arrowsState[wxScrollArrows::Arrow_Max];
97
98 DECLARE_DYNAMIC_CLASS(wxSpinButton)
99 };
100
101 // ----------------------------------------------------------------------------
102 // wxStdSpinButtonInputHandler: manages clicks on them (use arrows like
103 // wxStdScrollBarInputHandler) and processes keyboard events too
104 // ----------------------------------------------------------------------------
105
106 class WXDLLIMPEXP_CORE wxStdSpinButtonInputHandler : public wxStdInputHandler
107 {
108 public:
109 wxStdSpinButtonInputHandler(wxInputHandler *inphand);
110
111 virtual bool HandleKey(wxInputConsumer *consumer,
112 const wxKeyEvent& event,
113 bool pressed);
114 virtual bool HandleMouse(wxInputConsumer *consumer,
115 const wxMouseEvent& event);
116 virtual bool HandleMouseMove(wxInputConsumer *consumer,
117 const wxMouseEvent& event);
118 };
119
120 #endif // _WX_UNIV_SPINBUTT_H_
121