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