Contents Up Previous Next

wxSpinButton

A wxSpinButton has two small up and down (or left and right) arrow buttons. It is often used next to a text control for increment and decrementing a value. Portable programs should try to use wxSpinCtrl instead as wxSpinButton is not implemented for all platforms.

NB: the range supported by this control (and wxSpinCtrl) depends on the platform but is at least -0x8000 to 0x7fff. Under GTK and Win32 with sufficiently new version of comctrl32.dll (at least 4.71 is required, 5.80 is recommended) the full 32 bit range is supported.

Derived from

wxControl
wxWindow
wxEvtHandler
wxObject

See also

wxSpinCtrl

Include files

<wx/spinbutt.h>

Window styles

wxSP_HORIZONTAL Specifies a horizontal spin button (note that this style is not supported in wxGTK).
wxSP_VERTICAL Specifies a vertical spin button.
wxSP_ARROW_KEYS The user can use arrow keys to change the value.
wxSP_WRAP The value wraps at the minimum and maximum.

See also window styles overview.

Event handling

To process input from a spin button, use one of these event handler macros to direct input to member functions that take a wxSpinEvent argument:

EVT_SPIN(id, func) Generated whenever an arrow is pressed.
EVT_SPIN_UP(id, func) Generated when left/up arrow is pressed.
EVT_SPIN_DOWN(id, func) Generated when right/down arrow is pressed.
Note that if you handle both SPIN and UP or DOWN events, you will be notified about each of them twice: first the UP/DOWN event will be receieved and then, if it wasn't vetoed, the SPIN event will be sent. See also

Event handling overview

Members

wxSpinButton::wxSpinButton
wxSpinButton::~wxSpinButton
wxSpinButton::Create
wxSpinButton::GetMax
wxSpinButton::GetMin
wxSpinButton::GetValue
wxSpinButton::SetRange
wxSpinButton::SetValue


wxSpinButton::wxSpinButton

wxSpinButton()

Default constructor.

wxSpinButton(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSP_HORIZONTAL, const wxString& name = "spinButton")

Constructor, creating and showing a spin button.

Parameters

parent

id

pos

size

style

validator

name

See also

wxSpinButton::Create, wxValidator


wxSpinButton::~wxSpinButton

void ~wxSpinButton()

Destructor, destroys the spin button control.


wxSpinButton::Create

bool Create(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSP_HORIZONTAL, const wxString& name = "spinButton")

Scrollbar creation function called by the spin button constructor. See wxSpinButton::wxSpinButton for details.


wxSpinButton::GetMax

int GetMax() const

Returns the maximum permissible value.

See also

wxSpinButton::SetRange


wxSpinButton::GetMin

int GetMin() const

Returns the minimum permissible value.

See also

wxSpinButton::SetRange


wxSpinButton::GetValue

int GetValue() const

Returns the current spin button value.

See also

wxSpinButton::SetValue


wxSpinButton::SetRange

void SetRange(int min, int max)

Sets the range of the spin button.

Parameters

min

max

See also

wxSpinButton::GetMin, wxSpinButton::GetMax


wxSpinButton::SetValue

void SetValue(int value)

Sets the value of the spin button.

Parameters

value

See also

wxSpinButton::GetValue