]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/slider.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxSlider
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
12 A slider is a control with a handle which can be pulled back and forth to
15 On Windows, the track bar control is used.
17 Slider events are handled in the same way as a scrollbar.
20 @style{wxSL_HORIZONTAL}
21 Displays the slider horizontally (this is the default).
23 Displays the slider vertically.
24 @style{wxSL_AUTOTICKS}
25 Displays tick marks. Windows only.
26 @style{wxSL_MIN_MAX_LABELS}
27 Displays minimum, maximum labels (new since wxWidgets 2.9.1).
28 @style{wxSL_VALUE_LABEL}
29 Displays value label (new since wxWidgets 2.9.1).
31 Displays minimum, maximum and value labels (same as wxSL_VALUE_LABEL
32 and wxSL_MIN_MAX_LABELS together).
34 Displays ticks on the left and forces the slider to be vertical.
36 Displays ticks on the right and forces the slider to be vertical.
38 Displays ticks on the top.
40 Displays ticks on the bottom (this is the default).
42 Allows the user to select a range on the slider. Windows only.
44 Inverses the mininum and maximum endpoints on the slider. Not
45 compatible with wxSL_SELRANGE.
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).
55 @beginEventEmissionTable{wxScrollEvent}
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).
104 @section slider_diff The difference between EVT_SCROLL_THUMBRELEASE and EVT_SCROLL_CHANGED
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).
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.
120 @appearance{slider.png}
122 @see @ref overview_events, wxScrollBar
124 class wxSlider
: public wxControl
133 Constructor, creating and showing a slider.
136 Parent window. Must not be @NULL.
138 Window identifier. The value wxID_ANY indicates a default value.
140 Initial position for the slider.
142 Minimum slider position.
144 Maximum slider position.
147 If ::wxDefaultPosition is specified then a default position is chosen.
150 If ::wxDefaultSize is specified then a default size is chosen.
152 Window style. See wxSlider.
158 @see Create(), wxValidator
160 wxSlider(wxWindow
* parent
, wxWindowID id
, int value
,
161 int minValue
, int maxValue
,
162 const wxPoint
& pos
= wxDefaultPosition
,
163 const wxSize
& size
= wxDefaultSize
,
164 long style
= wxSL_HORIZONTAL
,
165 const wxValidator
& validator
= wxDefaultValidator
,
166 const wxString
& name
= wxSliderNameStr
);
169 Destructor, destroying the slider.
174 Clears the selection, for a slider with the @b wxSL_SELRANGE style.
178 virtual void ClearSel();
185 virtual void ClearTicks();
188 Used for two-step slider construction.
189 See wxSlider() for further details.
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
,
194 const wxValidator
& validator
= wxDefaultValidator
,
195 const wxString
& name
= wxSliderNameStr
);
198 Returns the line size.
202 virtual int GetLineSize() const;
205 Gets the maximum slider value.
207 @see GetMin(), SetRange()
209 virtual int GetMax() const;
212 Gets the minimum slider value.
214 @see GetMin(), SetRange()
216 virtual int GetMin() const;
219 Returns the page size.
223 virtual int GetPageSize() const;
226 Returns the selection end point.
230 @see GetSelStart(), SetSelection()
232 virtual int GetSelEnd() const;
235 Returns the selection start point.
239 @see GetSelEnd(), SetSelection()
241 virtual int GetSelStart() const;
244 Returns the thumb length.
248 @see SetThumbLength()
250 virtual int GetThumbLength() const;
253 Returns the tick frequency.
259 virtual int GetTickFreq() const;
262 Gets the current slider value.
264 @see GetMin(), GetMax(), SetValue()
266 virtual int GetValue() const;
269 Sets the line size for the slider.
272 The number of steps the slider moves when the user moves it up
277 virtual void SetLineSize(int lineSize
);
280 Sets the page size for the slider.
283 The number of steps the slider moves when the user pages up or down.
287 virtual void SetPageSize(int pageSize
);
290 Sets the minimum and maximum slider values.
292 @see GetMin(), GetMax()
294 virtual void SetRange(int minValue
, int maxValue
);
300 The selection start position.
302 The selection end position.
306 @see GetSelStart(), GetSelEnd()
308 virtual void SetSelection(int startPos
, int endPos
);
311 Sets the slider thumb length.
318 @see GetThumbLength()
320 virtual void SetThumbLength(int len
);
323 Sets a tick position.
332 virtual void SetTick(int tickPos
);
335 Sets the tick mark frequency and position.
338 Frequency. For example, if the frequency is set to two, a tick mark is
339 displayed for every other increment in the slider's range.
341 Position. Must be greater than zero. @todo: what is this for?
347 virtual void SetTickFreq(int n
, int pos
);
350 Sets the slider position.
355 virtual void SetValue(int value
);