]>
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 | |
76e9224e FM |
43 | @beginEventTable{wxScrollEvent} |
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 | ||
106 | @todo are all strings "Windows 95 only" really up2date? | |
107 | ||
23324ae1 FM |
108 | @library{wxcore} |
109 | @category{ctrl} | |
7e59b885 | 110 | @appearance{slider.png} |
7c913512 | 111 | |
4876436a | 112 | @see @ref overview_eventhandling, wxScrollBar |
23324ae1 FM |
113 | */ |
114 | class wxSlider : public wxControl | |
115 | { | |
116 | public: | |
7adc2e2e RR |
117 | /** |
118 | Default constructor | |
119 | */ | |
120 | wxSlider(); | |
4876436a | 121 | |
23324ae1 FM |
122 | /** |
123 | Constructor, creating and showing a slider. | |
3c4f71cc | 124 | |
7c913512 | 125 | @param parent |
4cc4bfaf | 126 | Parent window. Must not be @NULL. |
7c913512 | 127 | @param id |
4cc4bfaf | 128 | Window identifier. The value wxID_ANY indicates a default value. |
7c913512 | 129 | @param value |
4cc4bfaf | 130 | Initial position for the slider. |
7c913512 | 131 | @param minValue |
4cc4bfaf | 132 | Minimum slider position. |
7c913512 | 133 | @param maxValue |
4cc4bfaf | 134 | Maximum slider position. |
e725ba4f FM |
135 | @param pos |
136 | Window position. If wxDefaultPosition is specified then a default position is chosen. | |
7c913512 | 137 | @param size |
76e9224e | 138 | Window size. If wxDefaultSize is specified then a default size is chosen. |
7c913512 | 139 | @param style |
4cc4bfaf | 140 | Window style. See wxSlider. |
7c913512 | 141 | @param validator |
4cc4bfaf | 142 | Window validator. |
7c913512 | 143 | @param name |
4cc4bfaf | 144 | Window name. |
3c4f71cc | 145 | |
4cc4bfaf | 146 | @see Create(), wxValidator |
23324ae1 | 147 | */ |
7c913512 FM |
148 | wxSlider(wxWindow* parent, wxWindowID id, int value, |
149 | int minValue, int maxValue, | |
e725ba4f | 150 | const wxPoint& pos = wxDefaultPosition, |
7c913512 FM |
151 | const wxSize& size = wxDefaultSize, |
152 | long style = wxSL_HORIZONTAL, | |
153 | const wxValidator& validator = wxDefaultValidator, | |
154 | const wxString& name = "slider"); | |
23324ae1 FM |
155 | |
156 | /** | |
157 | Destructor, destroying the slider. | |
158 | */ | |
adaaa686 | 159 | virtual ~wxSlider(); |
23324ae1 FM |
160 | |
161 | /** | |
162 | Clears the selection, for a slider with the @b wxSL_SELRANGE style. | |
3c4f71cc | 163 | |
23324ae1 FM |
164 | @remarks Windows 95 only. |
165 | */ | |
adaaa686 | 166 | virtual void ClearSel(); |
23324ae1 FM |
167 | |
168 | /** | |
169 | Clears the ticks. | |
3c4f71cc | 170 | |
23324ae1 FM |
171 | @remarks Windows 95 only. |
172 | */ | |
adaaa686 | 173 | virtual void ClearTicks(); |
23324ae1 FM |
174 | |
175 | /** | |
76e9224e FM |
176 | Used for two-step slider construction. |
177 | See wxSlider() for further details. | |
23324ae1 FM |
178 | */ |
179 | bool Create(wxWindow* parent, wxWindowID id, int value, | |
180 | int minValue, int maxValue, | |
181 | const wxPoint& point = wxDefaultPosition, | |
182 | const wxSize& size = wxDefaultSize, | |
183 | long style = wxSL_HORIZONTAL, | |
184 | const wxValidator& validator = wxDefaultValidator, | |
185 | const wxString& name = "slider"); | |
186 | ||
187 | /** | |
188 | Returns the line size. | |
3c4f71cc | 189 | |
4cc4bfaf | 190 | @see SetLineSize() |
23324ae1 | 191 | */ |
adaaa686 | 192 | virtual int GetLineSize() const; |
23324ae1 FM |
193 | |
194 | /** | |
195 | Gets the maximum slider value. | |
3c4f71cc | 196 | |
4cc4bfaf | 197 | @see GetMin(), SetRange() |
23324ae1 | 198 | */ |
adaaa686 | 199 | virtual int GetMax() const; |
23324ae1 FM |
200 | |
201 | /** | |
202 | Gets the minimum slider value. | |
3c4f71cc | 203 | |
4cc4bfaf | 204 | @see GetMin(), SetRange() |
23324ae1 | 205 | */ |
adaaa686 | 206 | virtual int GetMin() const; |
23324ae1 FM |
207 | |
208 | /** | |
209 | Returns the page size. | |
3c4f71cc | 210 | |
4cc4bfaf | 211 | @see SetPageSize() |
23324ae1 | 212 | */ |
adaaa686 | 213 | virtual int GetPageSize() const; |
23324ae1 FM |
214 | |
215 | /** | |
216 | Returns the selection end point. | |
3c4f71cc | 217 | |
23324ae1 | 218 | @remarks Windows 95 only. |
3c4f71cc | 219 | |
4cc4bfaf | 220 | @see GetSelStart(), SetSelection() |
23324ae1 | 221 | */ |
adaaa686 | 222 | virtual int GetSelEnd() const; |
23324ae1 FM |
223 | |
224 | /** | |
225 | Returns the selection start point. | |
3c4f71cc | 226 | |
23324ae1 | 227 | @remarks Windows 95 only. |
3c4f71cc | 228 | |
4cc4bfaf | 229 | @see GetSelEnd(), SetSelection() |
23324ae1 | 230 | */ |
adaaa686 | 231 | virtual int GetSelStart() const; |
23324ae1 FM |
232 | |
233 | /** | |
234 | Returns the thumb length. | |
3c4f71cc | 235 | |
23324ae1 | 236 | @remarks Windows 95 only. |
3c4f71cc | 237 | |
4cc4bfaf | 238 | @see SetThumbLength() |
23324ae1 | 239 | */ |
adaaa686 | 240 | virtual int GetThumbLength() const; |
23324ae1 FM |
241 | |
242 | /** | |
243 | Returns the tick frequency. | |
3c4f71cc | 244 | |
23324ae1 | 245 | @remarks Windows 95 only. |
3c4f71cc | 246 | |
4cc4bfaf | 247 | @see SetTickFreq() |
23324ae1 | 248 | */ |
adaaa686 | 249 | virtual int GetTickFreq() const; |
23324ae1 FM |
250 | |
251 | /** | |
252 | Gets the current slider value. | |
3c4f71cc | 253 | |
4cc4bfaf | 254 | @see GetMin(), GetMax(), SetValue() |
23324ae1 | 255 | */ |
adaaa686 | 256 | virtual int GetValue() const; |
23324ae1 FM |
257 | |
258 | /** | |
259 | Sets the line size for the slider. | |
3c4f71cc | 260 | |
7c913512 | 261 | @param lineSize |
76e9224e FM |
262 | The number of steps the slider moves when the user moves it up |
263 | or down a line. | |
3c4f71cc | 264 | |
4cc4bfaf | 265 | @see GetLineSize() |
23324ae1 | 266 | */ |
adaaa686 | 267 | virtual void SetLineSize(int lineSize); |
23324ae1 FM |
268 | |
269 | /** | |
270 | Sets the page size for the slider. | |
3c4f71cc | 271 | |
7c913512 | 272 | @param pageSize |
4cc4bfaf | 273 | The number of steps the slider moves when the user pages up or down. |
3c4f71cc | 274 | |
4cc4bfaf | 275 | @see GetPageSize() |
23324ae1 | 276 | */ |
adaaa686 | 277 | virtual void SetPageSize(int pageSize); |
23324ae1 FM |
278 | |
279 | /** | |
280 | Sets the minimum and maximum slider values. | |
3c4f71cc | 281 | |
4cc4bfaf | 282 | @see GetMin(), GetMax() |
23324ae1 | 283 | */ |
adaaa686 | 284 | virtual void SetRange(int minValue, int maxValue); |
23324ae1 FM |
285 | |
286 | /** | |
287 | Sets the selection. | |
3c4f71cc | 288 | |
7c913512 | 289 | @param startPos |
4cc4bfaf | 290 | The selection start position. |
7c913512 | 291 | @param endPos |
4cc4bfaf | 292 | The selection end position. |
3c4f71cc | 293 | |
23324ae1 | 294 | @remarks Windows 95 only. |
3c4f71cc | 295 | |
4cc4bfaf | 296 | @see GetSelStart(), GetSelEnd() |
23324ae1 | 297 | */ |
adaaa686 | 298 | virtual void SetSelection(int startPos, int endPos); |
23324ae1 FM |
299 | |
300 | /** | |
301 | Sets the slider thumb length. | |
3c4f71cc | 302 | |
7c913512 | 303 | @param len |
4cc4bfaf | 304 | The thumb length. |
3c4f71cc | 305 | |
23324ae1 | 306 | @remarks Windows 95 only. |
3c4f71cc | 307 | |
4cc4bfaf | 308 | @see GetThumbLength() |
23324ae1 | 309 | */ |
adaaa686 | 310 | virtual void SetThumbLength(int len); |
23324ae1 FM |
311 | |
312 | /** | |
313 | Sets a tick position. | |
3c4f71cc | 314 | |
7c913512 | 315 | @param tickPos |
4cc4bfaf | 316 | The tick position. |
3c4f71cc | 317 | |
23324ae1 | 318 | @remarks Windows 95 only. |
3c4f71cc | 319 | |
4cc4bfaf | 320 | @see SetTickFreq() |
23324ae1 | 321 | */ |
adaaa686 | 322 | virtual void SetTick(int tickPos); |
23324ae1 FM |
323 | |
324 | /** | |
325 | Sets the tick mark frequency and position. | |
3c4f71cc | 326 | |
7c913512 | 327 | @param n |
4cc4bfaf | 328 | Frequency. For example, if the frequency is set to two, a tick mark is |
76e9224e | 329 | displayed for every other increment in the slider's range. |
7c913512 | 330 | @param pos |
76e9224e | 331 | Position. Must be greater than zero. @todo: what is this for? |
3c4f71cc | 332 | |
23324ae1 | 333 | @remarks Windows 95 only. |
3c4f71cc | 334 | |
4cc4bfaf | 335 | @see GetTickFreq() |
23324ae1 | 336 | */ |
adaaa686 | 337 | virtual void SetTickFreq(int n, int pos); |
23324ae1 FM |
338 | |
339 | /** | |
340 | Sets the slider position. | |
3c4f71cc | 341 | |
7c913512 | 342 | @param value |
4cc4bfaf | 343 | The slider position. |
23324ae1 | 344 | */ |
adaaa686 | 345 | virtual void SetValue(int value); |
23324ae1 | 346 | }; |
e54c96f1 | 347 |