A slider is a control with a handle which can be pulled back and forth to change the value.
In Windows versions below Windows 95, a scrollbar is used to simulate the slider. In Windows 95, the track bar control is used.
Slider events are handled in the same way as a scrollbar.
Derived from
wxControl
wxWindow
wxEvtHandler
wxObject
Include files
<wx/slider.h>
Window styles
wxSL_HORIZONTAL | Displays the slider horizontally. |
wxSL_VERTICAL | Displays the slider vertically. |
wxSL_AUTOTICKS | Displays tick marks. |
wxSL_LABELS | Displays minimum, maximum and value labels. (NB: only displays the current value label under wxGTK) |
wxSL_LEFT | Displays ticks on the left, if a vertical slider. |
wxSL_RIGHT | Displays ticks on the right, if a vertical slider. |
wxSL_TOP | Displays ticks on the top, if a horizontal slider. |
wxSL_SELRANGE | Allows the user to select a range on the slider. Windows 95 only. |
See also window styles overview.
Event handling
To process input from a slider, use one of these event handler macros to direct input to member functions that take a wxScrollEvent argument:
EVT_COMMAND_SCROLL(id, func) | Catch all scroll commands. |
EVT_COMMAND_TOP(id, func) | Catch a command to put the scroll thumb at the maximum position. |
EVT_COMMAND_BOTTOM(id, func) | Catch a command to put the scroll thumb at the maximum position. |
EVT_COMMAND_LINEUP(id, func) | Catch a line up command. |
EVT_COMMAND_LINEDOWN(id, func) | Catch a line down command. |
EVT_COMMAND_PAGEUP(id, func) | Catch a page up command. |
EVT_COMMAND_PAGEDOWN(id, func) | Catch a page down command. |
EVT_COMMAND_THUMBTRACK(id, func) | Catch a thumbtrack command (continuous movement of the scroll thumb). |
EVT_SLIDER(id, func) | Process a wxEVT_COMMAND_SLIDER_UPDATED event, when the slider is moved. Though provided for backward compatibility, this is obsolete. |
Event handling overview, wxScrollBar
Members
wxSlider::wxSlider
wxSlider::~wxSlider
wxSlider::ClearSel
wxSlider::ClearTicks
wxSlider::Create
wxSlider::GetLineSize
wxSlider::GetMax
wxSlider::GetMin
wxSlider::GetPageSize
wxSlider::GetSelEnd
wxSlider::GetSelStart
wxSlider::GetThumbLength
wxSlider::GetTickFreq
wxSlider::GetValue
wxSlider::SetRange
wxSlider::SetTickFreq
wxSlider::SetLineSize
wxSlider::SetPageSize
wxSlider::SetSelection
wxSlider::SetThumbLength
wxSlider::SetTick
wxSlider::SetValue
wxSlider()
Default slider.
wxSlider(wxWindow* parent, wxWindowID id, int value , int minValue, int maxValue, const wxPoint& point = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSL_HORIZONTAL, const wxValidator& validator = wxDefaultValidator, const wxString& name = "slider")
Constructor, creating and showing a slider.
Parameters
parent
id
value
minValue
maxValue
size
style
validator
name
See also
void ~wxSlider()
Destructor, destroying the slider.
void ClearSel()
Clears the selection, for a slider with the wxSL_SELRANGE style.
Remarks
Windows 95 only.
void ClearTicks()
Clears the ticks.
Remarks
Windows 95 only.
bool Create(wxWindow* parent, wxWindowID id, int value , int minValue, int maxValue, const wxPoint& point = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSL_HORIZONTAL, const wxValidator& validator = wxDefaultValidator, const wxString& name = "slider")
Used for two-step slider construction. See wxSlider::wxSlider for further details.
int GetLineSize() const
Returns the line size.
See also
int GetMax() const
Gets the maximum slider value.
See also
wxSlider::GetMin, wxSlider::SetRange
int GetMin() const
Gets the minimum slider value.
See also
wxSlider::GetMin, wxSlider::SetRange
int GetPageSize() const
Returns the page size.
See also
int GetSelEnd() const
Returns the selection end point.
Remarks
Windows 95 only.
See also
wxSlider::GetSelStart, wxSlider::SetSelection
int GetSelStart() const
Returns the selection start point.
Remarks
Windows 95 only.
See also
wxSlider::GetSelEnd, wxSlider::SetSelection
int GetThumbLength() const
Returns the thumb length.
Remarks
Windows 95 only.
See also
int GetTickFreq() const
Returns the tick frequency.
Remarks
Windows 95 only.
See also
int GetValue() const
Gets the current slider value.
See also
wxSlider::GetMin, wxSlider::GetMax, wxSlider::SetValue
void SetRange(int minValue, int maxValue)
Sets the minimum and maximum slider values.
See also
wxSlider::GetMin, wxSlider::GetMax
void SetTickFreq(int n, int pos)
Sets the tick mark frequency and position.
Parameters
n
pos
Remarks
Windows 95 only.
See also
void SetLineSize(int lineSize)
Sets the line size for the slider.
Parameters
lineSize
See also
void SetPageSize(int pageSize)
Sets the page size for the slider.
Parameters
pageSize
See also
void SetSelection(int startPos, int endPos)
Sets the selection.
Parameters
startPos
endPos
Remarks
Windows 95 only.
See also
wxSlider::GetSelStart, wxSlider::GetSelEnd
void SetThumbLength(int len)
Sets the slider thumb length.
Parameters
len
Remarks
Windows 95 only.
See also
void SetTick(int tickPos)
Sets a tick position.
Parameters
tickPos
Remarks
Windows 95 only.
See also
void SetValue(int value)
Sets the slider position.
Parameters
value
See also