]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: spinbutt.h | |
e725ba4f | 3 | // Purpose: interface of wxSpinEvent, wxSpinButton |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
526954c5 | 6 | // Licence: wxWindows licence |
23324ae1 FM |
7 | ///////////////////////////////////////////////////////////////////////////// |
8 | ||
9 | /** | |
10 | @class wxSpinEvent | |
7c913512 | 11 | |
e725ba4f FM |
12 | This event class is used for the events generated by wxSpinButton and wxSpinCtrl. |
13 | ||
14 | @beginEventTable{wxSpinEvent} | |
15 | @event{EVT_SPIN(id, func)} | |
16 | Generated whenever an arrow is pressed. | |
17 | @event{EVT_SPIN_UP(id, func)} | |
18 | Generated when left/up arrow is pressed. | |
19 | @event{EVT_SPIN_DOWN(id, func)} | |
20 | Generated when right/down arrow is pressed. | |
21 | @endEventTable | |
22 | ||
23 | Note that if you handle both SPIN and UP or DOWN events, you will be notified | |
24 | about each of them twice: first the UP/DOWN event will be received and then, | |
25 | if it wasn't vetoed, the SPIN event will be sent. | |
7c913512 | 26 | |
23324ae1 FM |
27 | @library{wxcore} |
28 | @category{events} | |
7c913512 | 29 | |
e54c96f1 | 30 | @see wxSpinButton and wxSpinCtrl |
23324ae1 FM |
31 | */ |
32 | class wxSpinEvent : public wxNotifyEvent | |
33 | { | |
34 | public: | |
35 | /** | |
36 | The constructor is not normally used by the user code. | |
37 | */ | |
4cc4bfaf | 38 | wxSpinEvent(wxEventType commandType = wxEVT_NULL, int id = 0); |
23324ae1 FM |
39 | |
40 | /** | |
41 | Retrieve the current spin button or control value. | |
42 | */ | |
328f5751 | 43 | int GetPosition() const; |
23324ae1 FM |
44 | |
45 | /** | |
46 | Set the value associated with the event. | |
47 | */ | |
48 | void SetPosition(int pos); | |
49 | }; | |
50 | ||
51 | ||
e54c96f1 | 52 | |
23324ae1 FM |
53 | /** |
54 | @class wxSpinButton | |
7c913512 | 55 | |
e725ba4f FM |
56 | A wxSpinButton has two small up and down (or left and right) arrow buttons. |
57 | ||
58 | It is often used next to a text control for increment and decrementing a value. | |
59 | Portable programs should try to use wxSpinCtrl instead as wxSpinButton is not | |
60 | implemented for all platforms but wxSpinCtrl is as it degenerates to a simple | |
61 | wxTextCtrl on such platforms. | |
7c913512 | 62 | |
1f1d2182 | 63 | @note the range supported by this control (and wxSpinCtrl) depends on the |
e725ba4f FM |
64 | platform but is at least @c -0x8000 to @c 0x7fff. Under GTK and |
65 | Win32 with sufficiently new version of @c comctrl32.dll (at least 4.71 | |
66 | is required, 5.80 is recommended) the full 32 bit range is supported. | |
7c913512 | 67 | |
23324ae1 | 68 | @beginStyleTable |
8c6791e4 | 69 | @style{wxSP_HORIZONTAL} |
23324ae1 FM |
70 | Specifies a horizontal spin button (note that this style is not |
71 | supported in wxGTK). | |
8c6791e4 | 72 | @style{wxSP_VERTICAL} |
23324ae1 | 73 | Specifies a vertical spin button. |
8c6791e4 | 74 | @style{wxSP_ARROW_KEYS} |
23324ae1 | 75 | The user can use arrow keys to change the value. |
8c6791e4 | 76 | @style{wxSP_WRAP} |
23324ae1 FM |
77 | The value wraps at the minimum and maximum. |
78 | @endStyleTable | |
7c913512 | 79 | |
3051a44a | 80 | @beginEventEmissionTable{wxSpinEvent} |
e725ba4f FM |
81 | @event{EVT_SPIN(id, func)} |
82 | Generated whenever an arrow is pressed. | |
83 | @event{EVT_SPIN_UP(id, func)} | |
84 | Generated when left/up arrow is pressed. | |
85 | @event{EVT_SPIN_DOWN(id, func)} | |
86 | Generated when right/down arrow is pressed. | |
87 | @endEventTable | |
88 | ||
89 | Note that if you handle both SPIN and UP or DOWN events, you will be notified | |
90 | about each of them twice: first the UP/DOWN event will be received and then, | |
91 | if it wasn't vetoed, the SPIN event will be sent. | |
92 | ||
23324ae1 FM |
93 | @library{wxcore} |
94 | @category{ctrl} | |
7e59b885 | 95 | @appearance{spinbutton.png} |
7c913512 | 96 | |
e54c96f1 | 97 | @see wxSpinCtrl |
23324ae1 FM |
98 | */ |
99 | class wxSpinButton : public wxControl | |
100 | { | |
101 | public: | |
d930d177 RR |
102 | /** |
103 | Default constructor. | |
104 | */ | |
105 | wxSpinButton(); | |
e725ba4f | 106 | |
23324ae1 FM |
107 | /** |
108 | Constructor, creating and showing a spin button. | |
3c4f71cc | 109 | |
7c913512 | 110 | @param parent |
4cc4bfaf | 111 | Parent window. Must not be @NULL. |
7c913512 | 112 | @param id |
4cc4bfaf | 113 | Window identifier. The value wxID_ANY indicates a default value. |
7c913512 | 114 | @param pos |
e725ba4f | 115 | Window position. |
dc1b07fd | 116 | If ::wxDefaultPosition is specified then a default position is chosen. |
7c913512 | 117 | @param size |
e725ba4f | 118 | Window size. |
dc1b07fd | 119 | If ::wxDefaultSize is specified then a default size is chosen. |
7c913512 | 120 | @param style |
e725ba4f | 121 | Window style. See wxSpinButton class description. |
7c913512 | 122 | @param name |
4cc4bfaf | 123 | Window name. |
3c4f71cc | 124 | |
4cc4bfaf | 125 | @see Create() |
23324ae1 | 126 | */ |
11e3af6e | 127 | wxSpinButton(wxWindow* parent, wxWindowID id = -1, |
7c913512 FM |
128 | const wxPoint& pos = wxDefaultPosition, |
129 | const wxSize& size = wxDefaultSize, | |
11e3af6e | 130 | long style = wxSP_VERTICAL, |
7c913512 | 131 | const wxString& name = "spinButton"); |
23324ae1 FM |
132 | |
133 | /** | |
134 | Destructor, destroys the spin button control. | |
135 | */ | |
adaaa686 | 136 | virtual ~wxSpinButton(); |
23324ae1 FM |
137 | |
138 | /** | |
139 | Scrollbar creation function called by the spin button constructor. | |
140 | See wxSpinButton() for details. | |
141 | */ | |
5267aefd | 142 | bool Create(wxWindow* parent, wxWindowID id = -1, |
23324ae1 | 143 | const wxPoint& pos = wxDefaultPosition, |
11e3af6e FM |
144 | const wxSize& size = wxDefaultSize, |
145 | long style = wxSP_VERTICAL, | |
5267aefd | 146 | const wxString& name = "wxSpinButton"); |
23324ae1 FM |
147 | |
148 | /** | |
149 | Returns the maximum permissible value. | |
3c4f71cc | 150 | |
4cc4bfaf | 151 | @see SetRange() |
23324ae1 | 152 | */ |
adaaa686 | 153 | virtual int GetMax() const; |
23324ae1 FM |
154 | |
155 | /** | |
156 | Returns the minimum permissible value. | |
3c4f71cc | 157 | |
4cc4bfaf | 158 | @see SetRange() |
23324ae1 | 159 | */ |
adaaa686 | 160 | virtual int GetMin() const; |
23324ae1 FM |
161 | |
162 | /** | |
163 | Returns the current spin button value. | |
3c4f71cc | 164 | |
4cc4bfaf | 165 | @see SetValue() |
23324ae1 | 166 | */ |
adaaa686 | 167 | virtual int GetValue() const; |
23324ae1 FM |
168 | |
169 | /** | |
170 | Sets the range of the spin button. | |
3c4f71cc | 171 | |
7c913512 | 172 | @param min |
4cc4bfaf | 173 | The minimum value for the spin button. |
7c913512 | 174 | @param max |
4cc4bfaf | 175 | The maximum value for the spin button. |
3c4f71cc | 176 | |
4cc4bfaf | 177 | @see GetMin(), GetMax() |
23324ae1 | 178 | */ |
adaaa686 | 179 | virtual void SetRange(int min, int max); |
23324ae1 FM |
180 | |
181 | /** | |
182 | Sets the value of the spin button. | |
3c4f71cc | 183 | |
7c913512 | 184 | @param value |
4cc4bfaf | 185 | The value for the spin button. |
23324ae1 | 186 | */ |
adaaa686 | 187 | virtual void SetValue(int value); |
23324ae1 | 188 | }; |
e54c96f1 | 189 |