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