## wxSlider

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.

See also

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::wxSlider

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

Parent window. Must not be NULL.

id

Window identifier. A value of -1 indicates a default value.

value

Initial position for the slider.

minValue

Minimum slider position.

maxValue

Maximum slider position.

size

Window size. If the default size (-1, -1) is specified then a default size is chosen.

style

Window style. See wxSlider.

validator

Window validator.

name

Window name.

See also

wxSlider::Create, wxValidator

### wxSlider::~wxSlider

void ~wxSlider()

Destructor, destroying the slider.

### wxSlider::ClearSel

void ClearSel()

Clears the selection, for a slider with the wxSL_SELRANGE style.

Remarks

Windows 95 only.

### wxSlider::ClearTicks

void ClearTicks()

Clears the ticks.

Remarks

Windows 95 only.

### wxSlider::Create

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.

### wxSlider::GetLineSize

int GetLineSize() const

Returns the line size.

See also

wxSlider::SetLineSize

### wxSlider::GetMax

int GetMax() const

Gets the maximum slider value.

See also

wxSlider::GetMin, wxSlider::SetRange

### wxSlider::GetMin

int GetMin() const

Gets the minimum slider value.

See also

wxSlider::GetMin, wxSlider::SetRange

### wxSlider::GetPageSize

int GetPageSize() const

Returns the page size.

See also

wxSlider::SetPageSize

### wxSlider::GetSelEnd

int GetSelEnd() const

Returns the selection end point.

Remarks

Windows 95 only.

See also

wxSlider::GetSelStart, wxSlider::SetSelection

### wxSlider::GetSelStart

int GetSelStart() const

Returns the selection start point.

Remarks

Windows 95 only.

See also

wxSlider::GetSelEnd, wxSlider::SetSelection

### wxSlider::GetThumbLength

int GetThumbLength() const

Returns the thumb length.

Remarks

Windows 95 only.

See also

wxSlider::SetThumbLength

### wxSlider::GetTickFreq

int GetTickFreq() const

Returns the tick frequency.

Remarks

Windows 95 only.

See also

wxSlider::SetTickFreq

### wxSlider::GetValue

int GetValue() const

Gets the current slider value.

See also

wxSlider::GetMin, wxSlider::GetMax, wxSlider::SetValue

### wxSlider::SetRange

void SetRange(int minValue, int maxValue)

Sets the minimum and maximum slider values.

See also

wxSlider::GetMin, wxSlider::GetMax

### wxSlider::SetTickFreq

void SetTickFreq(int n, int pos)

Sets the tick mark frequency and position.

Parameters

n

Frequency. For example, if the frequency is set to two, a tick mark is displayed for every other increment in the slider's range.

pos

Position. Must be greater than zero. TODO: what is this for?

Remarks

Windows 95 only.

See also

wxSlider::GetTickFreq

### wxSlider::SetLineSize

void SetLineSize(int lineSize)

Sets the line size for the slider.

Parameters

lineSize

The number of steps the slider moves when the user moves it up or down a line.

See also

wxSlider::GetLineSize

### wxSlider::SetPageSize

void SetPageSize(int pageSize)

Sets the page size for the slider.

Parameters

pageSize

The number of steps the slider moves when the user pages up or down.

See also

wxSlider::GetPageSize

### wxSlider::SetSelection

void SetSelection(int startPos, int endPos)

Sets the selection.

Parameters

startPos

The selection start position.

endPos

The selection end position.

Remarks

Windows 95 only.

See also

wxSlider::GetSelStart, wxSlider::GetSelEnd

### wxSlider::SetThumbLength

void SetThumbLength(int len)

Sets the slider thumb length.

Parameters

len

The thumb length.

Remarks

Windows 95 only.

See also

wxSlider::GetThumbLength

### wxSlider::SetTick

void SetTick(int tickPos)

Sets a tick position.

Parameters

tickPos

The tick position.

Remarks

Windows 95 only.

See also

wxSlider::SetTickFreq

### wxSlider::SetValue

void SetValue(int value)

Sets the slider position.

Parameters

value

The slider position.

See also

wxSlider::GetValue