]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/slider.h
Fix typo in wxStandardPathsBase::ResourceCat description and document it.
[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)}
63 Process wxEVT_SCROLL_TOP scroll-to-top events (minimum position).
64 @event{EVT_SCROLL_BOTTOM(func)}
65 Process wxEVT_SCROLL_BOTTOM scroll-to-bottom events (maximum position).
66 @event{EVT_SCROLL_LINEUP(func)}
67 Process wxEVT_SCROLL_LINEUP line up events.
68 @event{EVT_SCROLL_LINEDOWN(func)}
69 Process wxEVT_SCROLL_LINEDOWN line down events.
70 @event{EVT_SCROLL_PAGEUP(func)}
71 Process wxEVT_SCROLL_PAGEUP page up events.
72 @event{EVT_SCROLL_PAGEDOWN(func)}
73 Process wxEVT_SCROLL_PAGEDOWN page down events.
74 @event{EVT_SCROLL_THUMBTRACK(func)}
75 Process wxEVT_SCROLL_THUMBTRACK thumbtrack events
76 (frequent events sent as the user drags the thumbtrack).
77 @event{EVT_SCROLL_THUMBRELEASE(func)}
78 Process wxEVT_SCROLL_THUMBRELEASE thumb release events.
79 @event{EVT_SCROLL_CHANGED(func)}
80 Process wxEVT_SCROLL_CHANGED end of scrolling events (MSW only).
81 @event{EVT_COMMAND_SCROLL(id, func)}
82 Process all scroll events.
83 @event{EVT_COMMAND_SCROLL_TOP(id, func)}
84 Process wxEVT_SCROLL_TOP scroll-to-top events (minimum position).
85 @event{EVT_COMMAND_SCROLL_BOTTOM(id, func)}
86 Process wxEVT_SCROLL_BOTTOM scroll-to-bottom events (maximum position).
87 @event{EVT_COMMAND_SCROLL_LINEUP(id, func)}
88 Process wxEVT_SCROLL_LINEUP line up events.
89 @event{EVT_COMMAND_SCROLL_LINEDOWN(id, func)}
90 Process wxEVT_SCROLL_LINEDOWN line down events.
91 @event{EVT_COMMAND_SCROLL_PAGEUP(id, func)}
92 Process wxEVT_SCROLL_PAGEUP page up events.
93 @event{EVT_COMMAND_SCROLL_PAGEDOWN(id, func)}
94 Process wxEVT_SCROLL_PAGEDOWN page down events.
95 @event{EVT_COMMAND_SCROLL_THUMBTRACK(id, func)}
96 Process wxEVT_SCROLL_THUMBTRACK thumbtrack events
97 (frequent events sent as the user drags the thumbtrack).
98 @event{EVT_COMMAND_SCROLL_THUMBRELEASE(func)}
99 Process wxEVT_SCROLL_THUMBRELEASE thumb release events.
100 @event{EVT_COMMAND_SCROLL_CHANGED(func)}
101 Process wxEVT_SCROLL_CHANGED end of scrolling events (MSW only).
102 @endEventTable
103
104 @section slider_diff The difference between EVT_SCROLL_THUMBRELEASE and EVT_SCROLL_CHANGED
105
106 The EVT_SCROLL_THUMBRELEASE event is only emitted when actually dragging the
107 thumb using the mouse and releasing it (This EVT_SCROLL_THUMBRELEASE event
108 is also followed by an EVT_SCROLL_CHANGED event).
109
110 The EVT_SCROLL_CHANGED event also occurs when using the keyboard to change
111 the thumb position, and when clicking next to the thumb
112 (In all these cases the EVT_SCROLL_THUMBRELEASE event does not happen).
113 In short, the EVT_SCROLL_CHANGED event is triggered when scrolling/ moving
114 has finished independently of the way it had started.
115 Please see the widgets sample ("Slider" page) to see the difference between
116 EVT_SCROLL_THUMBRELEASE and EVT_SCROLL_CHANGED in action.
117
23324ae1
FM
118 @library{wxcore}
119 @category{ctrl}
7e59b885 120 @appearance{slider.png}
7c913512 121
830b7aa7 122 @see @ref overview_events, wxScrollBar
23324ae1
FM
123*/
124class wxSlider : public wxControl
125{
126public:
7adc2e2e
RR
127 /**
128 Default constructor
129 */
130 wxSlider();
4876436a 131
23324ae1
FM
132 /**
133 Constructor, creating and showing a slider.
3c4f71cc 134
7c913512 135 @param parent
4cc4bfaf 136 Parent window. Must not be @NULL.
7c913512 137 @param id
4cc4bfaf 138 Window identifier. The value wxID_ANY indicates a default value.
7c913512 139 @param value
4cc4bfaf 140 Initial position for the slider.
7c913512 141 @param minValue
4cc4bfaf 142 Minimum slider position.
7c913512 143 @param maxValue
4cc4bfaf 144 Maximum slider position.
e725ba4f 145 @param pos
dc1b07fd
FM
146 Window position.
147 If ::wxDefaultPosition is specified then a default position is chosen.
7c913512 148 @param size
dc1b07fd
FM
149 Window size.
150 If ::wxDefaultSize is specified then a default size is chosen.
7c913512 151 @param style
4cc4bfaf 152 Window style. See wxSlider.
7c913512 153 @param validator
4cc4bfaf 154 Window validator.
7c913512 155 @param name
4cc4bfaf 156 Window name.
3c4f71cc 157
4cc4bfaf 158 @see Create(), wxValidator
23324ae1 159 */
7c913512
FM
160 wxSlider(wxWindow* parent, wxWindowID id, int value,
161 int minValue, int maxValue,
e725ba4f 162 const wxPoint& pos = wxDefaultPosition,
7c913512
FM
163 const wxSize& size = wxDefaultSize,
164 long style = wxSL_HORIZONTAL,
165 const wxValidator& validator = wxDefaultValidator,
11e3af6e 166 const wxString& name = wxSliderNameStr);
23324ae1
FM
167
168 /**
169 Destructor, destroying the slider.
170 */
adaaa686 171 virtual ~wxSlider();
23324ae1
FM
172
173 /**
174 Clears the selection, for a slider with the @b wxSL_SELRANGE style.
3c4f71cc 175
bb69632a 176 @onlyfor{wxmsw}
23324ae1 177 */
adaaa686 178 virtual void ClearSel();
23324ae1
FM
179
180 /**
181 Clears the ticks.
3c4f71cc 182
bb69632a 183 @onlyfor{wxmsw}
23324ae1 184 */
adaaa686 185 virtual void ClearTicks();
23324ae1
FM
186
187 /**
76e9224e
FM
188 Used for two-step slider construction.
189 See wxSlider() for further details.
23324ae1 190 */
43c48e1e
FM
191 bool Create(wxWindow* parent, wxWindowID id, int value, int minValue,
192 int maxValue, const wxPoint& point = wxDefaultPosition,
193 const wxSize& size = wxDefaultSize, long style = wxSL_HORIZONTAL,
23324ae1 194 const wxValidator& validator = wxDefaultValidator,
43c48e1e 195 const wxString& name = wxSliderNameStr);
23324ae1
FM
196
197 /**
198 Returns the line size.
3c4f71cc 199
4cc4bfaf 200 @see SetLineSize()
23324ae1 201 */
adaaa686 202 virtual int GetLineSize() const;
23324ae1
FM
203
204 /**
205 Gets the maximum slider value.
3c4f71cc 206
4cc4bfaf 207 @see GetMin(), SetRange()
23324ae1 208 */
adaaa686 209 virtual int GetMax() const;
23324ae1
FM
210
211 /**
212 Gets the minimum slider value.
3c4f71cc 213
4cc4bfaf 214 @see GetMin(), SetRange()
23324ae1 215 */
adaaa686 216 virtual int GetMin() const;
23324ae1
FM
217
218 /**
219 Returns the page size.
3c4f71cc 220
4cc4bfaf 221 @see SetPageSize()
23324ae1 222 */
adaaa686 223 virtual int GetPageSize() const;
23324ae1
FM
224
225 /**
226 Returns the selection end point.
3c4f71cc 227
bb69632a 228 @onlyfor{wxmsw}
3c4f71cc 229
4cc4bfaf 230 @see GetSelStart(), SetSelection()
23324ae1 231 */
adaaa686 232 virtual int GetSelEnd() const;
23324ae1
FM
233
234 /**
235 Returns the selection start point.
3c4f71cc 236
bb69632a 237 @onlyfor{wxmsw}
3c4f71cc 238
4cc4bfaf 239 @see GetSelEnd(), SetSelection()
23324ae1 240 */
adaaa686 241 virtual int GetSelStart() const;
23324ae1
FM
242
243 /**
244 Returns the thumb length.
3c4f71cc 245
bb69632a 246 @onlyfor{wxmsw}
3c4f71cc 247
4cc4bfaf 248 @see SetThumbLength()
23324ae1 249 */
adaaa686 250 virtual int GetThumbLength() const;
23324ae1
FM
251
252 /**
253 Returns the tick frequency.
3c4f71cc 254
bb69632a 255 @onlyfor{wxmsw}
3c4f71cc 256
4cc4bfaf 257 @see SetTickFreq()
23324ae1 258 */
adaaa686 259 virtual int GetTickFreq() const;
23324ae1
FM
260
261 /**
262 Gets the current slider value.
3c4f71cc 263
4cc4bfaf 264 @see GetMin(), GetMax(), SetValue()
23324ae1 265 */
adaaa686 266 virtual int GetValue() const;
23324ae1
FM
267
268 /**
269 Sets the line size for the slider.
3c4f71cc 270
7c913512 271 @param lineSize
76e9224e
FM
272 The number of steps the slider moves when the user moves it up
273 or down a line.
3c4f71cc 274
4cc4bfaf 275 @see GetLineSize()
23324ae1 276 */
adaaa686 277 virtual void SetLineSize(int lineSize);
23324ae1
FM
278
279 /**
280 Sets the page size for the slider.
3c4f71cc 281
7c913512 282 @param pageSize
4cc4bfaf 283 The number of steps the slider moves when the user pages up or down.
3c4f71cc 284
4cc4bfaf 285 @see GetPageSize()
23324ae1 286 */
adaaa686 287 virtual void SetPageSize(int pageSize);
23324ae1
FM
288
289 /**
290 Sets the minimum and maximum slider values.
3c4f71cc 291
4cc4bfaf 292 @see GetMin(), GetMax()
23324ae1 293 */
adaaa686 294 virtual void SetRange(int minValue, int maxValue);
23324ae1
FM
295
296 /**
297 Sets the selection.
3c4f71cc 298
7c913512 299 @param startPos
4cc4bfaf 300 The selection start position.
7c913512 301 @param endPos
4cc4bfaf 302 The selection end position.
3c4f71cc 303
bb69632a 304 @onlyfor{wxmsw}
3c4f71cc 305
4cc4bfaf 306 @see GetSelStart(), GetSelEnd()
23324ae1 307 */
adaaa686 308 virtual void SetSelection(int startPos, int endPos);
23324ae1
FM
309
310 /**
311 Sets the slider thumb length.
3c4f71cc 312
7c913512 313 @param len
4cc4bfaf 314 The thumb length.
3c4f71cc 315
bb69632a 316 @onlyfor{wxmsw}
3c4f71cc 317
4cc4bfaf 318 @see GetThumbLength()
23324ae1 319 */
adaaa686 320 virtual void SetThumbLength(int len);
23324ae1
FM
321
322 /**
323 Sets a tick position.
3c4f71cc 324
7c913512 325 @param tickPos
4cc4bfaf 326 The tick position.
3c4f71cc 327
bb69632a 328 @onlyfor{wxmsw}
3c4f71cc 329
4cc4bfaf 330 @see SetTickFreq()
23324ae1 331 */
adaaa686 332 virtual void SetTick(int tickPos);
23324ae1
FM
333
334 /**
335 Sets the tick mark frequency and position.
3c4f71cc 336
7c913512 337 @param n
4cc4bfaf 338 Frequency. For example, if the frequency is set to two, a tick mark is
76e9224e 339 displayed for every other increment in the slider's range.
7c913512 340 @param pos
76e9224e 341 Position. Must be greater than zero. @todo: what is this for?
3c4f71cc 342
bb69632a 343 @onlyfor{wxmsw}
3c4f71cc 344
4cc4bfaf 345 @see GetTickFreq()
23324ae1 346 */
adaaa686 347 virtual void SetTickFreq(int n, int pos);
23324ae1
FM
348
349 /**
350 Sets the slider position.
3c4f71cc 351
7c913512 352 @param value
4cc4bfaf 353 The slider position.
23324ae1 354 */
adaaa686 355 virtual void SetValue(int value);
23324ae1 356};
e54c96f1 357