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