wxSlider Class Reference
[Controls]

#include <wx/slider.h>

Inheritance diagram for wxSlider:
Inheritance graph
[legend]

Detailed Description

A slider is a control with a handle which can be pulled back and forth to change the value.

On Windows, the track bar control is used.

Slider events are handled in the same way as a scrollbar.

Styles

This class supports the following styles:

Notice that wxSL_LEFT, wxSL_TOP, wxSL_RIGHT and wxSL_BOTTOM specify the position of the slider ticks in MSW implementation and that the slider labels, if any, are positioned on the opposite side. So, to have a label on the left side of a vertical slider, wxSL_RIGHT must be used (or none of these styles at all should be specified as left and top are default positions for the vertical and horizontal sliders respectively).

Events emitted by this class

The following event handler macros redirect the events to member function handlers 'func' with prototypes like:

void handlerFuncName(wxScrollEvent& event)

Event macros for events emitted by this class:

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.

The difference between EVT_SCROLL_THUMBRELEASE and EVT_SCROLL_CHANGED

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_CHANGED event).

The EVT_SCROLL_CHANGED 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_CHANGED event is triggered when scrolling/ moving has finished independently of the way it had started. Please see the widgets sample ("Slider" page) to see the difference between EVT_SCROLL_THUMBRELEASE and EVT_SCROLL_CHANGED in action.

Library:  wxCore
Category:  Controls

Appearance:
wxMSW appearancewxGTK appearancewxMac appearance
wxMSW appearancewxGTK appearancewxMac appearance
See also:
Events and Event Handling, wxScrollBar

Public Member Functions

 wxSlider ()
 Default constructor.
 wxSlider (wxWindow *parent, wxWindowID id, int value, int minValue, int maxValue, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxSL_HORIZONTAL, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxSliderNameStr)
 Constructor, creating and showing a slider.
virtual ~wxSlider ()
 Destructor, destroying the slider.
virtual void ClearSel ()
 Clears the selection, for a slider with the wxSL_SELRANGE style.
virtual void ClearTicks ()
 Clears the ticks.
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=wxSliderNameStr)
 Used for two-step slider construction.
virtual int GetLineSize () const
 Returns the line size.
virtual int GetMax () const
 Gets the maximum slider value.
virtual int GetMin () const
 Gets the minimum slider value.
virtual int GetPageSize () const
 Returns the page size.
virtual int GetSelEnd () const
 Returns the selection end point.
virtual int GetSelStart () const
 Returns the selection start point.
virtual int GetThumbLength () const
 Returns the thumb length.
virtual int GetTickFreq () const
 Returns the tick frequency.
virtual int GetValue () const
 Gets the current slider value.
virtual void SetLineSize (int lineSize)
 Sets the line size for the slider.
virtual void SetPageSize (int pageSize)
 Sets the page size for the slider.
virtual void SetRange (int minValue, int maxValue)
 Sets the minimum and maximum slider values.
virtual void SetSelection (int startPos, int endPos)
 Sets the selection.
virtual void SetThumbLength (int len)
 Sets the slider thumb length.
virtual void SetTick (int tickPos)
 Sets a tick position.
virtual void SetTickFreq (int n, int pos)
 Sets the tick mark frequency and position.
virtual void SetValue (int value)
 Sets the slider position.

List of all members.


Constructor & Destructor Documentation

wxSlider::wxSlider (  ) 

Default constructor.

wxSlider::wxSlider ( wxWindow parent,
wxWindowID  id,
int  value,
int  minValue,
int  maxValue,
const wxPoint pos = wxDefaultPosition,
const wxSize size = wxDefaultSize,
long  style = wxSL_HORIZONTAL,
const wxValidator validator = wxDefaultValidator,
const wxString name = wxSliderNameStr 
)

Constructor, creating and showing a slider.

Parameters:
parent Parent window. Must not be NULL.
id Window identifier. The value wxID_ANY indicates a default value.
value Initial position for the slider.
minValue Minimum slider position.
maxValue Maximum slider position.
pos Window position. If wxDefaultPosition is specified then a default position is chosen.
size Window size. If wxDefaultSize is specified then a default size is chosen.
style Window style. See wxSlider.
validator Window validator.
name Window name.
See also:
Create(), wxValidator
virtual wxSlider::~wxSlider (  )  [virtual]

Destructor, destroying the slider.


Member Function Documentation

virtual void wxSlider::ClearSel (  )  [virtual]

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

Availability:  only available for the wxMSW port.
virtual void wxSlider::ClearTicks (  )  [virtual]

Clears the ticks.

Availability:  only available for the wxMSW port.
bool wxSlider::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 = wxSliderNameStr 
)

Used for two-step slider construction.

See wxSlider() for further details.

virtual int wxSlider::GetLineSize (  )  const [virtual]

Returns the line size.

See also:
SetLineSize()
virtual int wxSlider::GetMax (  )  const [virtual]

Gets the maximum slider value.

See also:
GetMin(), SetRange()
virtual int wxSlider::GetMin (  )  const [virtual]

Gets the minimum slider value.

See also:
GetMin(), SetRange()
virtual int wxSlider::GetPageSize (  )  const [virtual]

Returns the page size.

See also:
SetPageSize()
virtual int wxSlider::GetSelEnd (  )  const [virtual]

Returns the selection end point.

Availability:  only available for the wxMSW port.
See also:
GetSelStart(), SetSelection()
virtual int wxSlider::GetSelStart (  )  const [virtual]

Returns the selection start point.

Availability:  only available for the wxMSW port.
See also:
GetSelEnd(), SetSelection()
virtual int wxSlider::GetThumbLength (  )  const [virtual]

Returns the thumb length.

Availability:  only available for the wxMSW port.
See also:
SetThumbLength()
virtual int wxSlider::GetTickFreq (  )  const [virtual]

Returns the tick frequency.

Availability:  only available for the wxMSW port.
See also:
SetTickFreq()
virtual int wxSlider::GetValue (  )  const [virtual]

Gets the current slider value.

See also:
GetMin(), GetMax(), SetValue()
virtual void wxSlider::SetLineSize ( int  lineSize  )  [virtual]

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:
GetLineSize()
virtual void wxSlider::SetPageSize ( int  pageSize  )  [virtual]

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:
GetPageSize()
virtual void wxSlider::SetRange ( int  minValue,
int  maxValue 
) [virtual]

Sets the minimum and maximum slider values.

See also:
GetMin(), GetMax()
virtual void wxSlider::SetSelection ( int  startPos,
int  endPos 
) [virtual]

Sets the selection.

Parameters:
startPos The selection start position.
endPos The selection end position.
Availability:  only available for the wxMSW port.
See also:
GetSelStart(), GetSelEnd()
virtual void wxSlider::SetThumbLength ( int  len  )  [virtual]

Sets the slider thumb length.

Parameters:
len The thumb length.
Availability:  only available for the wxMSW port.
See also:
GetThumbLength()
virtual void wxSlider::SetTick ( int  tickPos  )  [virtual]

Sets a tick position.

Parameters:
tickPos The tick position.
Availability:  only available for the wxMSW port.
See also:
SetTickFreq()
virtual void wxSlider::SetTickFreq ( int  n,
int  pos 
) [virtual]

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?
Availability:  only available for the wxMSW port.
See also:
GetTickFreq()
virtual void wxSlider::SetValue ( int  value  )  [virtual]

Sets the slider position.

Parameters:
value The slider position.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines



wxWidgets logo

[ top ]