]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: slider.h | |
e54c96f1 | 3 | // Purpose: interface of wxSlider |
23324ae1 | 4 | // Author: wxWidgets team |
526954c5 | 5 | // Licence: wxWindows licence |
23324ae1 FM |
6 | ///////////////////////////////////////////////////////////////////////////// |
7 | ||
7106fc46 RD |
8 | |
9 | #define wxSL_HORIZONTAL wxHORIZONTAL /* 0x0004 */ | |
10 | #define wxSL_VERTICAL wxVERTICAL /* 0x0008 */ | |
11 | ||
12 | #define wxSL_TICKS 0x0010 | |
13 | #define wxSL_AUTOTICKS wxSL_TICKS // we don't support manual ticks | |
14 | #define wxSL_LEFT 0x0040 | |
15 | #define wxSL_TOP 0x0080 | |
16 | #define wxSL_RIGHT 0x0100 | |
17 | #define wxSL_BOTTOM 0x0200 | |
18 | #define wxSL_BOTH 0x0400 | |
19 | #define wxSL_SELRANGE 0x0800 | |
20 | #define wxSL_INVERSE 0x1000 | |
21 | #define wxSL_MIN_MAX_LABELS 0x2000 | |
22 | #define wxSL_VALUE_LABEL 0x4000 | |
23 | #define wxSL_LABELS (wxSL_MIN_MAX_LABELS|wxSL_VALUE_LABEL) | |
24 | ||
23324ae1 FM |
25 | /** |
26 | @class wxSlider | |
7c913512 | 27 | |
76e9224e FM |
28 | A slider is a control with a handle which can be pulled back and forth to |
29 | change the value. | |
7c913512 | 30 | |
23324ae1 | 31 | On Windows, the track bar control is used. |
7c913512 | 32 | |
23324ae1 | 33 | Slider events are handled in the same way as a scrollbar. |
7c913512 | 34 | |
23324ae1 | 35 | @beginStyleTable |
8c6791e4 | 36 | @style{wxSL_HORIZONTAL} |
23324ae1 | 37 | Displays the slider horizontally (this is the default). |
8c6791e4 | 38 | @style{wxSL_VERTICAL} |
23324ae1 | 39 | Displays the slider vertically. |
8c6791e4 | 40 | @style{wxSL_AUTOTICKS} |
6d6f99cb RR |
41 | Displays tick marks. Windows only. |
42 | @style{wxSL_MIN_MAX_LABELS} | |
e0989408 | 43 | Displays minimum, maximum labels (new since wxWidgets 2.9.1). |
6d6f99cb | 44 | @style{wxSL_VALUE_LABEL} |
e0989408 | 45 | Displays value label (new since wxWidgets 2.9.1). |
8c6791e4 | 46 | @style{wxSL_LABELS} |
e0989408 VZ |
47 | Displays minimum, maximum and value labels (same as wxSL_VALUE_LABEL |
48 | and wxSL_MIN_MAX_LABELS together). | |
8c6791e4 | 49 | @style{wxSL_LEFT} |
23324ae1 | 50 | Displays ticks on the left and forces the slider to be vertical. |
8c6791e4 | 51 | @style{wxSL_RIGHT} |
23324ae1 | 52 | Displays ticks on the right and forces the slider to be vertical. |
8c6791e4 | 53 | @style{wxSL_TOP} |
23324ae1 | 54 | Displays ticks on the top. |
8c6791e4 | 55 | @style{wxSL_BOTTOM} |
23324ae1 | 56 | Displays ticks on the bottom (this is the default). |
8c6791e4 | 57 | @style{wxSL_SELRANGE} |
23324ae1 | 58 | Allows the user to select a range on the slider. Windows only. |
8c6791e4 | 59 | @style{wxSL_INVERSE} |
d13b34d3 | 60 | Inverses the minimum and maximum endpoints on the slider. Not |
23324ae1 FM |
61 | compatible with wxSL_SELRANGE. |
62 | @endStyleTable | |
7c913512 | 63 | |
c0a9fe92 VZ |
64 | Notice that @c wxSL_LEFT, @c wxSL_TOP, @c wxSL_RIGHT and @c wxSL_BOTTOM |
65 | specify the position of the slider ticks in MSW implementation and that the | |
66 | slider labels, if any, are positioned on the opposite side. So, to have a | |
67 | label on the left side of a vertical slider, @b wxSL_RIGHT must be used (or | |
68 | none of these styles at all should be specified as left and top are default | |
69 | positions for the vertical and horizontal sliders respectively). | |
70 | ||
3051a44a | 71 | @beginEventEmissionTable{wxScrollEvent} |
76e9224e FM |
72 | You can use EVT_COMMAND_SCROLL... macros with window IDs for when intercepting |
73 | scroll events from controls, or EVT_SCROLL... macros without window IDs for | |
74 | intercepting scroll events from the receiving window -- except for this, | |
75 | the macros behave exactly the same. | |
76 | @event{EVT_SCROLL(func)} | |
77 | Process all scroll events. | |
78 | @event{EVT_SCROLL_TOP(func)} | |
3a194bda | 79 | Process @c wxEVT_SCROLL_TOP scroll-to-top events (minimum position). |
76e9224e | 80 | @event{EVT_SCROLL_BOTTOM(func)} |
3a194bda | 81 | Process @c wxEVT_SCROLL_BOTTOM scroll-to-bottom events (maximum position). |
76e9224e | 82 | @event{EVT_SCROLL_LINEUP(func)} |
3a194bda | 83 | Process @c wxEVT_SCROLL_LINEUP line up events. |
76e9224e | 84 | @event{EVT_SCROLL_LINEDOWN(func)} |
3a194bda | 85 | Process @c wxEVT_SCROLL_LINEDOWN line down events. |
76e9224e | 86 | @event{EVT_SCROLL_PAGEUP(func)} |
3a194bda | 87 | Process @c wxEVT_SCROLL_PAGEUP page up events. |
76e9224e | 88 | @event{EVT_SCROLL_PAGEDOWN(func)} |
3a194bda | 89 | Process @c wxEVT_SCROLL_PAGEDOWN page down events. |
76e9224e | 90 | @event{EVT_SCROLL_THUMBTRACK(func)} |
3a194bda | 91 | Process @c wxEVT_SCROLL_THUMBTRACK thumbtrack events |
76e9224e FM |
92 | (frequent events sent as the user drags the thumbtrack). |
93 | @event{EVT_SCROLL_THUMBRELEASE(func)} | |
3a194bda | 94 | Process @c wxEVT_SCROLL_THUMBRELEASE thumb release events. |
76e9224e | 95 | @event{EVT_SCROLL_CHANGED(func)} |
3a194bda | 96 | Process @c wxEVT_SCROLL_CHANGED end of scrolling events (MSW only). |
76e9224e FM |
97 | @event{EVT_COMMAND_SCROLL(id, func)} |
98 | Process all scroll events. | |
99 | @event{EVT_COMMAND_SCROLL_TOP(id, func)} | |
3a194bda | 100 | Process @c wxEVT_SCROLL_TOP scroll-to-top events (minimum position). |
76e9224e | 101 | @event{EVT_COMMAND_SCROLL_BOTTOM(id, func)} |
3a194bda | 102 | Process @c wxEVT_SCROLL_BOTTOM scroll-to-bottom events (maximum position). |
76e9224e | 103 | @event{EVT_COMMAND_SCROLL_LINEUP(id, func)} |
3a194bda | 104 | Process @c wxEVT_SCROLL_LINEUP line up events. |
76e9224e | 105 | @event{EVT_COMMAND_SCROLL_LINEDOWN(id, func)} |
3a194bda | 106 | Process @c wxEVT_SCROLL_LINEDOWN line down events. |
76e9224e | 107 | @event{EVT_COMMAND_SCROLL_PAGEUP(id, func)} |
3a194bda | 108 | Process @c wxEVT_SCROLL_PAGEUP page up events. |
76e9224e | 109 | @event{EVT_COMMAND_SCROLL_PAGEDOWN(id, func)} |
3a194bda | 110 | Process @c wxEVT_SCROLL_PAGEDOWN page down events. |
76e9224e | 111 | @event{EVT_COMMAND_SCROLL_THUMBTRACK(id, func)} |
3a194bda | 112 | Process @c wxEVT_SCROLL_THUMBTRACK thumbtrack events |
76e9224e FM |
113 | (frequent events sent as the user drags the thumbtrack). |
114 | @event{EVT_COMMAND_SCROLL_THUMBRELEASE(func)} | |
3a194bda | 115 | Process @c wxEVT_SCROLL_THUMBRELEASE thumb release events. |
76e9224e | 116 | @event{EVT_COMMAND_SCROLL_CHANGED(func)} |
3a194bda | 117 | Process @c wxEVT_SCROLL_CHANGED end of scrolling events (MSW only). |
8c40af94 | 118 | @event{EVT_SLIDER(id, func)} |
ce7fe42e | 119 | Process @c wxEVT_SLIDER which is generated after any |
8c40af94 | 120 | change of wxSlider position in addition to one of the events above. |
76e9224e FM |
121 | @endEventTable |
122 | ||
123 | @section slider_diff The difference between EVT_SCROLL_THUMBRELEASE and EVT_SCROLL_CHANGED | |
124 | ||
125 | The EVT_SCROLL_THUMBRELEASE event is only emitted when actually dragging the | |
126 | thumb using the mouse and releasing it (This EVT_SCROLL_THUMBRELEASE event | |
127 | is also followed by an EVT_SCROLL_CHANGED event). | |
128 | ||
129 | The EVT_SCROLL_CHANGED event also occurs when using the keyboard to change | |
130 | the thumb position, and when clicking next to the thumb | |
131 | (In all these cases the EVT_SCROLL_THUMBRELEASE event does not happen). | |
132 | In short, the EVT_SCROLL_CHANGED event is triggered when scrolling/ moving | |
133 | has finished independently of the way it had started. | |
134 | Please see the widgets sample ("Slider" page) to see the difference between | |
135 | EVT_SCROLL_THUMBRELEASE and EVT_SCROLL_CHANGED in action. | |
136 | ||
23324ae1 FM |
137 | @library{wxcore} |
138 | @category{ctrl} | |
ce154616 | 139 | @appearance{slider} |
7c913512 | 140 | |
830b7aa7 | 141 | @see @ref overview_events, wxScrollBar |
23324ae1 FM |
142 | */ |
143 | class wxSlider : public wxControl | |
144 | { | |
145 | public: | |
7adc2e2e RR |
146 | /** |
147 | Default constructor | |
148 | */ | |
149 | wxSlider(); | |
4876436a | 150 | |
23324ae1 FM |
151 | /** |
152 | Constructor, creating and showing a slider. | |
3c4f71cc | 153 | |
7c913512 | 154 | @param parent |
4cc4bfaf | 155 | Parent window. Must not be @NULL. |
7c913512 | 156 | @param id |
4cc4bfaf | 157 | Window identifier. The value wxID_ANY indicates a default value. |
7c913512 | 158 | @param value |
4cc4bfaf | 159 | Initial position for the slider. |
7c913512 | 160 | @param minValue |
4cc4bfaf | 161 | Minimum slider position. |
7c913512 | 162 | @param maxValue |
4cc4bfaf | 163 | Maximum slider position. |
e725ba4f | 164 | @param pos |
dc1b07fd FM |
165 | Window position. |
166 | If ::wxDefaultPosition is specified then a default position is chosen. | |
7c913512 | 167 | @param size |
dc1b07fd FM |
168 | Window size. |
169 | If ::wxDefaultSize is specified then a default size is chosen. | |
7c913512 | 170 | @param style |
4cc4bfaf | 171 | Window style. See wxSlider. |
7c913512 | 172 | @param validator |
4cc4bfaf | 173 | Window validator. |
7c913512 | 174 | @param name |
4cc4bfaf | 175 | Window name. |
3c4f71cc | 176 | |
4cc4bfaf | 177 | @see Create(), wxValidator |
23324ae1 | 178 | */ |
7c913512 FM |
179 | wxSlider(wxWindow* parent, wxWindowID id, int value, |
180 | int minValue, int maxValue, | |
e725ba4f | 181 | const wxPoint& pos = wxDefaultPosition, |
7c913512 FM |
182 | const wxSize& size = wxDefaultSize, |
183 | long style = wxSL_HORIZONTAL, | |
184 | const wxValidator& validator = wxDefaultValidator, | |
11e3af6e | 185 | const wxString& name = wxSliderNameStr); |
23324ae1 FM |
186 | |
187 | /** | |
188 | Destructor, destroying the slider. | |
189 | */ | |
adaaa686 | 190 | virtual ~wxSlider(); |
23324ae1 FM |
191 | |
192 | /** | |
193 | Clears the selection, for a slider with the @b wxSL_SELRANGE style. | |
3c4f71cc | 194 | |
bb69632a | 195 | @onlyfor{wxmsw} |
23324ae1 | 196 | */ |
adaaa686 | 197 | virtual void ClearSel(); |
23324ae1 FM |
198 | |
199 | /** | |
200 | Clears the ticks. | |
3c4f71cc | 201 | |
bb69632a | 202 | @onlyfor{wxmsw} |
23324ae1 | 203 | */ |
adaaa686 | 204 | virtual void ClearTicks(); |
23324ae1 FM |
205 | |
206 | /** | |
76e9224e FM |
207 | Used for two-step slider construction. |
208 | See wxSlider() for further details. | |
23324ae1 | 209 | */ |
43c48e1e FM |
210 | bool Create(wxWindow* parent, wxWindowID id, int value, int minValue, |
211 | int maxValue, const wxPoint& point = wxDefaultPosition, | |
212 | const wxSize& size = wxDefaultSize, long style = wxSL_HORIZONTAL, | |
23324ae1 | 213 | const wxValidator& validator = wxDefaultValidator, |
43c48e1e | 214 | const wxString& name = wxSliderNameStr); |
23324ae1 FM |
215 | |
216 | /** | |
217 | Returns the line size. | |
3c4f71cc | 218 | |
4cc4bfaf | 219 | @see SetLineSize() |
23324ae1 | 220 | */ |
adaaa686 | 221 | virtual int GetLineSize() const; |
23324ae1 FM |
222 | |
223 | /** | |
224 | Gets the maximum slider value. | |
3c4f71cc | 225 | |
4cc4bfaf | 226 | @see GetMin(), SetRange() |
23324ae1 | 227 | */ |
adaaa686 | 228 | virtual int GetMax() const; |
23324ae1 FM |
229 | |
230 | /** | |
231 | Gets the minimum slider value. | |
3c4f71cc | 232 | |
4cc4bfaf | 233 | @see GetMin(), SetRange() |
23324ae1 | 234 | */ |
adaaa686 | 235 | virtual int GetMin() const; |
23324ae1 FM |
236 | |
237 | /** | |
238 | Returns the page size. | |
3c4f71cc | 239 | |
4cc4bfaf | 240 | @see SetPageSize() |
23324ae1 | 241 | */ |
adaaa686 | 242 | virtual int GetPageSize() const; |
23324ae1 FM |
243 | |
244 | /** | |
245 | Returns the selection end point. | |
3c4f71cc | 246 | |
bb69632a | 247 | @onlyfor{wxmsw} |
3c4f71cc | 248 | |
4cc4bfaf | 249 | @see GetSelStart(), SetSelection() |
23324ae1 | 250 | */ |
adaaa686 | 251 | virtual int GetSelEnd() const; |
23324ae1 FM |
252 | |
253 | /** | |
254 | Returns the selection start point. | |
3c4f71cc | 255 | |
bb69632a | 256 | @onlyfor{wxmsw} |
3c4f71cc | 257 | |
4cc4bfaf | 258 | @see GetSelEnd(), SetSelection() |
23324ae1 | 259 | */ |
adaaa686 | 260 | virtual int GetSelStart() const; |
23324ae1 FM |
261 | |
262 | /** | |
263 | Returns the thumb length. | |
3c4f71cc | 264 | |
bb69632a | 265 | @onlyfor{wxmsw} |
3c4f71cc | 266 | |
4cc4bfaf | 267 | @see SetThumbLength() |
23324ae1 | 268 | */ |
adaaa686 | 269 | virtual int GetThumbLength() const; |
23324ae1 FM |
270 | |
271 | /** | |
272 | Returns the tick frequency. | |
3c4f71cc | 273 | |
bb69632a | 274 | @onlyfor{wxmsw} |
3c4f71cc | 275 | |
4cc4bfaf | 276 | @see SetTickFreq() |
23324ae1 | 277 | */ |
adaaa686 | 278 | virtual int GetTickFreq() const; |
23324ae1 FM |
279 | |
280 | /** | |
281 | Gets the current slider value. | |
3c4f71cc | 282 | |
4cc4bfaf | 283 | @see GetMin(), GetMax(), SetValue() |
23324ae1 | 284 | */ |
adaaa686 | 285 | virtual int GetValue() const; |
23324ae1 FM |
286 | |
287 | /** | |
288 | Sets the line size for the slider. | |
3c4f71cc | 289 | |
7c913512 | 290 | @param lineSize |
76e9224e FM |
291 | The number of steps the slider moves when the user moves it up |
292 | or down a line. | |
3c4f71cc | 293 | |
4cc4bfaf | 294 | @see GetLineSize() |
23324ae1 | 295 | */ |
adaaa686 | 296 | virtual void SetLineSize(int lineSize); |
23324ae1 | 297 | |
a4eac766 RD |
298 | |
299 | /** | |
300 | Sets the minimum slider value. | |
301 | ||
302 | @param minValue | |
303 | The new bottom end of the slider range. | |
304 | ||
305 | @see GetMin(), SetRange() | |
306 | */ | |
307 | void SetMin( int minValue ); | |
308 | ||
309 | /** | |
310 | Sets the maximum slider value. | |
311 | ||
312 | @param maxValue | |
313 | The new top end of the slider range. | |
314 | ||
315 | @see GetMax(), SetRange() | |
316 | */ | |
317 | void SetMax( int maxValue ); | |
318 | ||
23324ae1 FM |
319 | /** |
320 | Sets the page size for the slider. | |
3c4f71cc | 321 | |
7c913512 | 322 | @param pageSize |
4cc4bfaf | 323 | The number of steps the slider moves when the user pages up or down. |
3c4f71cc | 324 | |
4cc4bfaf | 325 | @see GetPageSize() |
23324ae1 | 326 | */ |
adaaa686 | 327 | virtual void SetPageSize(int pageSize); |
23324ae1 FM |
328 | |
329 | /** | |
330 | Sets the minimum and maximum slider values. | |
3c4f71cc | 331 | |
4cc4bfaf | 332 | @see GetMin(), GetMax() |
23324ae1 | 333 | */ |
adaaa686 | 334 | virtual void SetRange(int minValue, int maxValue); |
23324ae1 FM |
335 | |
336 | /** | |
337 | Sets the selection. | |
3c4f71cc | 338 | |
7c913512 | 339 | @param startPos |
4cc4bfaf | 340 | The selection start position. |
7c913512 | 341 | @param endPos |
4cc4bfaf | 342 | The selection end position. |
3c4f71cc | 343 | |
bb69632a | 344 | @onlyfor{wxmsw} |
3c4f71cc | 345 | |
4cc4bfaf | 346 | @see GetSelStart(), GetSelEnd() |
23324ae1 | 347 | */ |
adaaa686 | 348 | virtual void SetSelection(int startPos, int endPos); |
23324ae1 FM |
349 | |
350 | /** | |
351 | Sets the slider thumb length. | |
3c4f71cc | 352 | |
7c913512 | 353 | @param len |
4cc4bfaf | 354 | The thumb length. |
3c4f71cc | 355 | |
bb69632a | 356 | @onlyfor{wxmsw} |
3c4f71cc | 357 | |
4cc4bfaf | 358 | @see GetThumbLength() |
23324ae1 | 359 | */ |
adaaa686 | 360 | virtual void SetThumbLength(int len); |
23324ae1 FM |
361 | |
362 | /** | |
363 | Sets a tick position. | |
3c4f71cc | 364 | |
7c913512 | 365 | @param tickPos |
4cc4bfaf | 366 | The tick position. |
3c4f71cc | 367 | |
bb69632a | 368 | @onlyfor{wxmsw} |
3c4f71cc | 369 | |
4cc4bfaf | 370 | @see SetTickFreq() |
23324ae1 | 371 | */ |
adaaa686 | 372 | virtual void SetTick(int tickPos); |
23324ae1 FM |
373 | |
374 | /** | |
375 | Sets the tick mark frequency and position. | |
3c4f71cc | 376 | |
7c913512 | 377 | @param n |
4cc4bfaf | 378 | Frequency. For example, if the frequency is set to two, a tick mark is |
76e9224e | 379 | displayed for every other increment in the slider's range. |
3c4f71cc | 380 | |
bb69632a | 381 | @onlyfor{wxmsw} |
3c4f71cc | 382 | |
4cc4bfaf | 383 | @see GetTickFreq() |
23324ae1 | 384 | */ |
0a12e013 | 385 | virtual void SetTickFreq(int n); |
23324ae1 FM |
386 | |
387 | /** | |
388 | Sets the slider position. | |
3c4f71cc | 389 | |
7c913512 | 390 | @param value |
4cc4bfaf | 391 | The slider position. |
23324ae1 | 392 | */ |
adaaa686 | 393 | virtual void SetValue(int value); |
23324ae1 | 394 | }; |
e54c96f1 | 395 |