Contents Up Previous Next

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 table macros

To process a scroll event, use these event handler macros to direct input to member functions that take a wxScrollEvent argument. You can use EVT_COMMAND_SCROLL... macros with window IDs for when intercepting scroll events from controls, or EVT_SCROLL... macros without window IDs for intercepting scroll events from the receiving window - except for this, the macros behave exactly the same.

EVT_SCROLL(func) Process all scroll events.
EVT_SCROLL_TOP(func) Process wxEVT_SCROLL_TOP scroll-to-top events (minium position).
EVT_SCROLL_BOTTOM(func) Process wxEVT_SCROLL_TOP scroll-to-bottom events (maximum position).
EVT_SCROLL_LINEUP(func) Process wxEVT_SCROLL_LINEUP line up events.
EVT_SCROLL_LINEDOWN(func) Process wxEVT_SCROLL_LINEDOWN line down events.
EVT_SCROLL_PAGEUP(func) Process wxEVT_SCROLL_PAGEUP page up events.
EVT_SCROLL_PAGEDOWN(func) Process wxEVT_SCROLL_PAGEDOWN page down events.
EVT_SCROLL_THUMBTRACK(func) Process wxEVT_SCROLL_THUMBTRACK thumbtrack events (frequent events sent as the user drags the thumbtrack).
EVT_SCROLL_THUMBRELEASE(func) Process wxEVT_SCROLL_THUMBRELEASE thumb release events.
EVT_SCROLL_ENDSCROLL(func) Process wxEVT_SCROLL_ENDSCROLL end of scrolling events (MSW only).
EVT_COMMAND_SCROLL(id, func) Process all scroll events.
EVT_COMMAND_SCROLL_TOP(id, func) Process wxEVT_SCROLL_TOP scroll-to-top events (minimum position).
EVT_COMMAND_SCROLL_BOTTOM(id, func) Process wxEVT_SCROLL_TOP scroll-to-bottom events (maximum position).
EVT_COMMAND_SCROLL_LINEUP(id, func) Process wxEVT_SCROLL_LINEUP line up events.
EVT_COMMAND_SCROLL_LINEDOWN(id, func) Process wxEVT_SCROLL_LINEDOWN line down events.
EVT_COMMAND_SCROLL_PAGEUP(id, func) Process wxEVT_SCROLL_PAGEUP page up events.
EVT_COMMAND_SCROLL_PAGEDOWN(id, func) Process wxEVT_SCROLL_PAGEDOWN page down events.
EVT_COMMAND_SCROLL_THUMBTRACK(id, func) Process wxEVT_SCROLL_THUMBTRACK thumbtrack events (frequent events sent as the user drags the thumbtrack).
EVT_COMMAND_SCROLL_THUMBRELEASE(func) Process wxEVT_SCROLL_THUMBRELEASE thumb release events.
EVT_COMMAND_SCROLL_ENDSCROLL(func) Process wxEVT_SCROLL_ENDSCROLL end of scrolling events (MSW only).

The difference between EVT_SCROLL_THUMBRELEASE and EVT_SCROLL_ENDSCROLL

The EVT_SCROLL_THUMBRELEASE event is only emitted when actually dragging the thumb using the mouse and releasing it (This EVT_SCROLL_THUMBRELEASE event is also followed by an EVT_SCROLL_ENDSCROLL event).

The EVT_SCROLL_ENDSCROLL event also occurs when using the keyboard to change the thumb position, and when clicking next to the thumb (In all these cases the EVT_SCROLL_THUMBRELEASE event does not happen).

In short, the EVT_SCROLL_ENDSCROLL event is triggered when scrolling/ moving has finished. The only exception (unfortunately) is that changing the thumb position using the mousewheel does give a EVT_SCROLL_THUMBRELEASE event but NOT an EVT_SCROLL_ENDSCROLL event.

Please see the widgets sample ("Slider" page) to see the difference between EVT_SCROLL_THUMBRELEASE and EVT_SCROLL_ENDSCROLL in action.

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

id

value

minValue

maxValue

size

style

validator

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

pos

Remarks

Windows 95 only.

See also

wxSlider::GetTickFreq


wxSlider::SetLineSize

void SetLineSize(int lineSize)

Sets the line size for the slider.

Parameters

lineSize

See also

wxSlider::GetLineSize


wxSlider::SetPageSize

void SetPageSize(int pageSize)

Sets the page size for the slider.

Parameters

pageSize

See also

wxSlider::GetPageSize


wxSlider::SetSelection

void SetSelection(int startPos, int endPos)

Sets the selection.

Parameters

startPos

endPos

Remarks

Windows 95 only.

See also

wxSlider::GetSelStart, wxSlider::GetSelEnd


wxSlider::SetThumbLength

void SetThumbLength(int len)

Sets the slider thumb length.

Parameters

len

Remarks

Windows 95 only.

See also

wxSlider::GetThumbLength


wxSlider::SetTick

void SetTick(int tickPos)

Sets a tick position.

Parameters

tickPos

Remarks

Windows 95 only.

See also

wxSlider::SetTickFreq


wxSlider::SetValue

void SetValue(int value)

Sets the slider position.

Parameters

value

See also

wxSlider::GetValue