]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/slider.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxSlider
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
10 #define wxSL_HORIZONTAL wxHORIZONTAL /* 0x0004 */
11 #define wxSL_VERTICAL wxVERTICAL /* 0x0008 */
13 #define wxSL_TICKS 0x0010
14 #define wxSL_AUTOTICKS wxSL_TICKS // we don't support manual ticks
15 #define wxSL_LEFT 0x0040
16 #define wxSL_TOP 0x0080
17 #define wxSL_RIGHT 0x0100
18 #define wxSL_BOTTOM 0x0200
19 #define wxSL_BOTH 0x0400
20 #define wxSL_SELRANGE 0x0800
21 #define wxSL_INVERSE 0x1000
22 #define wxSL_MIN_MAX_LABELS 0x2000
23 #define wxSL_VALUE_LABEL 0x4000
24 #define wxSL_LABELS (wxSL_MIN_MAX_LABELS|wxSL_VALUE_LABEL)
29 A slider is a control with a handle which can be pulled back and forth to
32 On Windows, the track bar control is used.
34 Slider events are handled in the same way as a scrollbar.
37 @style{wxSL_HORIZONTAL}
38 Displays the slider horizontally (this is the default).
40 Displays the slider vertically.
41 @style{wxSL_AUTOTICKS}
42 Displays tick marks. Windows only.
43 @style{wxSL_MIN_MAX_LABELS}
44 Displays minimum, maximum labels (new since wxWidgets 2.9.1).
45 @style{wxSL_VALUE_LABEL}
46 Displays value label (new since wxWidgets 2.9.1).
48 Displays minimum, maximum and value labels (same as wxSL_VALUE_LABEL
49 and wxSL_MIN_MAX_LABELS together).
51 Displays ticks on the left and forces the slider to be vertical.
53 Displays ticks on the right and forces the slider to be vertical.
55 Displays ticks on the top.
57 Displays ticks on the bottom (this is the default).
59 Allows the user to select a range on the slider. Windows only.
61 Inverses the minimum and maximum endpoints on the slider. Not
62 compatible with wxSL_SELRANGE.
65 Notice that @c wxSL_LEFT, @c wxSL_TOP, @c wxSL_RIGHT and @c wxSL_BOTTOM
66 specify the position of the slider ticks in MSW implementation and that the
67 slider labels, if any, are positioned on the opposite side. So, to have a
68 label on the left side of a vertical slider, @b wxSL_RIGHT must be used (or
69 none of these styles at all should be specified as left and top are default
70 positions for the vertical and horizontal sliders respectively).
72 @beginEventEmissionTable{wxScrollEvent}
73 You can use EVT_COMMAND_SCROLL... macros with window IDs for when intercepting
74 scroll events from controls, or EVT_SCROLL... macros without window IDs for
75 intercepting scroll events from the receiving window -- except for this,
76 the macros behave exactly the same.
77 @event{EVT_SCROLL(func)}
78 Process all scroll events.
79 @event{EVT_SCROLL_TOP(func)}
80 Process @c wxEVT_SCROLL_TOP scroll-to-top events (minimum position).
81 @event{EVT_SCROLL_BOTTOM(func)}
82 Process @c wxEVT_SCROLL_BOTTOM scroll-to-bottom events (maximum position).
83 @event{EVT_SCROLL_LINEUP(func)}
84 Process @c wxEVT_SCROLL_LINEUP line up events.
85 @event{EVT_SCROLL_LINEDOWN(func)}
86 Process @c wxEVT_SCROLL_LINEDOWN line down events.
87 @event{EVT_SCROLL_PAGEUP(func)}
88 Process @c wxEVT_SCROLL_PAGEUP page up events.
89 @event{EVT_SCROLL_PAGEDOWN(func)}
90 Process @c wxEVT_SCROLL_PAGEDOWN page down events.
91 @event{EVT_SCROLL_THUMBTRACK(func)}
92 Process @c wxEVT_SCROLL_THUMBTRACK thumbtrack events
93 (frequent events sent as the user drags the thumbtrack).
94 @event{EVT_SCROLL_THUMBRELEASE(func)}
95 Process @c wxEVT_SCROLL_THUMBRELEASE thumb release events.
96 @event{EVT_SCROLL_CHANGED(func)}
97 Process @c wxEVT_SCROLL_CHANGED end of scrolling events (MSW only).
98 @event{EVT_COMMAND_SCROLL(id, func)}
99 Process all scroll events.
100 @event{EVT_COMMAND_SCROLL_TOP(id, func)}
101 Process @c wxEVT_SCROLL_TOP scroll-to-top events (minimum position).
102 @event{EVT_COMMAND_SCROLL_BOTTOM(id, func)}
103 Process @c wxEVT_SCROLL_BOTTOM scroll-to-bottom events (maximum position).
104 @event{EVT_COMMAND_SCROLL_LINEUP(id, func)}
105 Process @c wxEVT_SCROLL_LINEUP line up events.
106 @event{EVT_COMMAND_SCROLL_LINEDOWN(id, func)}
107 Process @c wxEVT_SCROLL_LINEDOWN line down events.
108 @event{EVT_COMMAND_SCROLL_PAGEUP(id, func)}
109 Process @c wxEVT_SCROLL_PAGEUP page up events.
110 @event{EVT_COMMAND_SCROLL_PAGEDOWN(id, func)}
111 Process @c wxEVT_SCROLL_PAGEDOWN page down events.
112 @event{EVT_COMMAND_SCROLL_THUMBTRACK(id, func)}
113 Process @c wxEVT_SCROLL_THUMBTRACK thumbtrack events
114 (frequent events sent as the user drags the thumbtrack).
115 @event{EVT_COMMAND_SCROLL_THUMBRELEASE(func)}
116 Process @c wxEVT_SCROLL_THUMBRELEASE thumb release events.
117 @event{EVT_COMMAND_SCROLL_CHANGED(func)}
118 Process @c wxEVT_SCROLL_CHANGED end of scrolling events (MSW only).
119 @event{EVT_SLIDER(id, func)}
120 Process @c wxEVT_COMMAND_SLIDER_UPDATED which is generated after any
121 change of wxSlider position in addition to one of the events above.
124 @section slider_diff The difference between EVT_SCROLL_THUMBRELEASE and EVT_SCROLL_CHANGED
126 The EVT_SCROLL_THUMBRELEASE event is only emitted when actually dragging the
127 thumb using the mouse and releasing it (This EVT_SCROLL_THUMBRELEASE event
128 is also followed by an EVT_SCROLL_CHANGED event).
130 The EVT_SCROLL_CHANGED event also occurs when using the keyboard to change
131 the thumb position, and when clicking next to the thumb
132 (In all these cases the EVT_SCROLL_THUMBRELEASE event does not happen).
133 In short, the EVT_SCROLL_CHANGED event is triggered when scrolling/ moving
134 has finished independently of the way it had started.
135 Please see the widgets sample ("Slider" page) to see the difference between
136 EVT_SCROLL_THUMBRELEASE and EVT_SCROLL_CHANGED in action.
142 @see @ref overview_events, wxScrollBar
144 class wxSlider
: public wxControl
153 Constructor, creating and showing a slider.
156 Parent window. Must not be @NULL.
158 Window identifier. The value wxID_ANY indicates a default value.
160 Initial position for the slider.
162 Minimum slider position.
164 Maximum slider position.
167 If ::wxDefaultPosition is specified then a default position is chosen.
170 If ::wxDefaultSize is specified then a default size is chosen.
172 Window style. See wxSlider.
178 @see Create(), wxValidator
180 wxSlider(wxWindow
* parent
, wxWindowID id
, int value
,
181 int minValue
, int maxValue
,
182 const wxPoint
& pos
= wxDefaultPosition
,
183 const wxSize
& size
= wxDefaultSize
,
184 long style
= wxSL_HORIZONTAL
,
185 const wxValidator
& validator
= wxDefaultValidator
,
186 const wxString
& name
= wxSliderNameStr
);
189 Destructor, destroying the slider.
194 Clears the selection, for a slider with the @b wxSL_SELRANGE style.
198 virtual void ClearSel();
205 virtual void ClearTicks();
208 Used for two-step slider construction.
209 See wxSlider() for further details.
211 bool Create(wxWindow
* parent
, wxWindowID id
, int value
, int minValue
,
212 int maxValue
, const wxPoint
& point
= wxDefaultPosition
,
213 const wxSize
& size
= wxDefaultSize
, long style
= wxSL_HORIZONTAL
,
214 const wxValidator
& validator
= wxDefaultValidator
,
215 const wxString
& name
= wxSliderNameStr
);
218 Returns the line size.
222 virtual int GetLineSize() const;
225 Gets the maximum slider value.
227 @see GetMin(), SetRange()
229 virtual int GetMax() const;
232 Gets the minimum slider value.
234 @see GetMin(), SetRange()
236 virtual int GetMin() const;
239 Returns the page size.
243 virtual int GetPageSize() const;
246 Returns the selection end point.
250 @see GetSelStart(), SetSelection()
252 virtual int GetSelEnd() const;
255 Returns the selection start point.
259 @see GetSelEnd(), SetSelection()
261 virtual int GetSelStart() const;
264 Returns the thumb length.
268 @see SetThumbLength()
270 virtual int GetThumbLength() const;
273 Returns the tick frequency.
279 virtual int GetTickFreq() const;
282 Gets the current slider value.
284 @see GetMin(), GetMax(), SetValue()
286 virtual int GetValue() const;
289 Sets the line size for the slider.
292 The number of steps the slider moves when the user moves it up
297 virtual void SetLineSize(int lineSize
);
300 Sets the page size for the slider.
303 The number of steps the slider moves when the user pages up or down.
307 virtual void SetPageSize(int pageSize
);
310 Sets the minimum and maximum slider values.
312 @see GetMin(), GetMax()
314 virtual void SetRange(int minValue
, int maxValue
);
320 The selection start position.
322 The selection end position.
326 @see GetSelStart(), GetSelEnd()
328 virtual void SetSelection(int startPos
, int endPos
);
331 Sets the slider thumb length.
338 @see GetThumbLength()
340 virtual void SetThumbLength(int len
);
343 Sets a tick position.
352 virtual void SetTick(int tickPos
);
355 Sets the tick mark frequency and position.
358 Frequency. For example, if the frequency is set to two, a tick mark is
359 displayed for every other increment in the slider's range.
365 virtual void SetTickFreq(int n
);
368 Sets the slider position.
373 virtual void SetValue(int value
);