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