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