]>
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 @beginEventEmissionTable{wxScrollEvent}
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).
97 @section slider_diff The difference between EVT_SCROLL_THUMBRELEASE and EVT_SCROLL_CHANGED
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).
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.
113 @appearance{slider.png}
115 @see @ref overview_events, wxScrollBar
117 class wxSlider
: public wxControl
126 Constructor, creating and showing a slider.
129 Parent window. Must not be @NULL.
131 Window identifier. The value wxID_ANY indicates a default value.
133 Initial position for the slider.
135 Minimum slider position.
137 Maximum slider position.
140 If ::wxDefaultPosition is specified then a default position is chosen.
143 If ::wxDefaultSize is specified then a default size is chosen.
145 Window style. See wxSlider.
151 @see Create(), wxValidator
153 wxSlider(wxWindow
* parent
, wxWindowID id
, int value
,
154 int minValue
, int maxValue
,
155 const wxPoint
& pos
= wxDefaultPosition
,
156 const wxSize
& size
= wxDefaultSize
,
157 long style
= wxSL_HORIZONTAL
,
158 const wxValidator
& validator
= wxDefaultValidator
,
159 const wxString
& name
= wxSliderNameStr
);
162 Destructor, destroying the slider.
167 Clears the selection, for a slider with the @b wxSL_SELRANGE style.
171 virtual void ClearSel();
178 virtual void ClearTicks();
181 Used for two-step slider construction.
182 See wxSlider() for further details.
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
,
187 const wxValidator
& validator
= wxDefaultValidator
,
188 const wxString
& name
= wxSliderNameStr
);
191 Returns the line size.
195 virtual int GetLineSize() const;
198 Gets the maximum slider value.
200 @see GetMin(), SetRange()
202 virtual int GetMax() const;
205 Gets the minimum slider value.
207 @see GetMin(), SetRange()
209 virtual int GetMin() const;
212 Returns the page size.
216 virtual int GetPageSize() const;
219 Returns the selection end point.
223 @see GetSelStart(), SetSelection()
225 virtual int GetSelEnd() const;
228 Returns the selection start point.
232 @see GetSelEnd(), SetSelection()
234 virtual int GetSelStart() const;
237 Returns the thumb length.
241 @see SetThumbLength()
243 virtual int GetThumbLength() const;
246 Returns the tick frequency.
252 virtual int GetTickFreq() const;
255 Gets the current slider value.
257 @see GetMin(), GetMax(), SetValue()
259 virtual int GetValue() const;
262 Sets the line size for the slider.
265 The number of steps the slider moves when the user moves it up
270 virtual void SetLineSize(int lineSize
);
273 Sets the page size for the slider.
276 The number of steps the slider moves when the user pages up or down.
280 virtual void SetPageSize(int pageSize
);
283 Sets the minimum and maximum slider values.
285 @see GetMin(), GetMax()
287 virtual void SetRange(int minValue
, int maxValue
);
293 The selection start position.
295 The selection end position.
299 @see GetSelStart(), GetSelEnd()
301 virtual void SetSelection(int startPos
, int endPos
);
304 Sets the slider thumb length.
311 @see GetThumbLength()
313 virtual void SetThumbLength(int len
);
316 Sets a tick position.
325 virtual void SetTick(int tickPos
);
328 Sets the tick mark frequency and position.
331 Frequency. For example, if the frequency is set to two, a tick mark is
332 displayed for every other increment in the slider's range.
334 Position. Must be greater than zero. @todo: what is this for?
340 virtual void SetTickFreq(int n
, int pos
);
343 Sets the slider position.
348 virtual void SetValue(int value
);