Class Index | Cross Index | Namespace Index |
Retrieve an integer or floating-point number from the user.
Contained in: Gtk
Derived from:
Gtk::Entry
Derived by:
none
#include <gtk--/spinbutton.h>
public function member index: |
||
SpinButton | (gfloat climb_rate=0, gint digits=0); | |
SpinButton | (Adjustment& adjustment, gfloat climb_rate=0, gint digits=0); | |
Adjustment* | get_adjustment | () const; |
guint | get_digits | () const; |
bool | get_numeric | () const; |
GtkShadowType | get_shadow_type | () const; |
bool | get_snap_to_ticks | () const; |
GtkSpinButtonUpdatePolicy | get_update_policy | () const; |
gfloat | get_value_as_float | () const; |
gint | get_value_as_int | () const; |
bool | get_wrap | () const; |
GtkSpinButton* | gtkobj | (); |
const GtkSpinButton* | gtkobj | () const; |
static bool | isA | (Object* object); |
void | set_adjustment | (Adjustment& adjustment); |
void | set_adjustment | (Adjustment* adjustment); |
void | set_digits | (gint digits); |
void | set_numeric | (bool numeric); |
void | set_shadow_type | (GtkShadowType shadow_type); |
void | set_snap_to_ticks | (bool snap_to_ticks); |
void | set_update_policy | (GtkSpinButtonUpdatePolicy policy); |
void | set_value | (gfloat value); |
void | set_wrap | (bool wrap); |
void | spin | (GtkSpinType direction, gfloat step); |
void | update | (); |
virtual | ~SpinButton | (); |
The main properties of a Gtk::SpinButton are through a Gtk::Adjustment. See the Gtk::Adjustment section for more details about an adjustment's properties.
The Gtk::Adjustment of a spin button can be set or retrieved with a call to set_adjustment or get_adjustment, respectively.
The number of digits after the decimal point of a spin button can be altered with set_digits.
To retrieve values from a spin button, use get_value_as_float if you require a floating point number, or get_value_as_int if you require an integer.
To set the value of a Gtk::SpinButton, use set_value. To change the update behaviour of a spin button, use set_update_policy.
When a spin button reaches it's upper or lower limit, it can either stop spinning, or wrap around and continue spinning from the opposite limit. For example, if five is the upper limit and the lower limit is zero, upon reaching the value five, the spin button can change it's value back to zero and continue spinning upwards. This behaviour is set with set_wrap.
A border around a spin button's arrows can be created using set_shadow_type.
A number may be entered that is invalid, given a spin button's range. An erroneous number can be corrected as soon as the spin button is 'activated' using set_snap_to_ticks, which will alter the current value to the nearest step increment. (See Gtk::Adjustment for step increments).
Because a spin contains a Gtk::Entry, alphabetic characters may be entered. These can be ignored by using set_numeric with a value of TRUE. Then only numeric values, '-' and a decimal point will be accepted.
To manually increment or decrement the spin button, use spin, and to force an
update (refresh), use update.
adjustment: The Gtk::Adjustment object that this spin button should use.climb_rate: Specifies how much the spin button changes when an arrow is clicked on.
digits: The number of decimal places to display. Must be less than 6.
Returns: A Gtk::Adjustment.
If the number has no decimal places, it is converted to a float before the function returns. Returns: The value of the spin button as a gfloat.
Returns: The value of the spin button as a gint.
adjustment: A Gtk::Adjustment.
adjustment: A Gtk::Adjustment.
digits: The number of decimal places.
A value of TRUE to numeric means that all non-numeric characters (except '-' and a decimal point) are ignored.numeric: Whether letters should be ignored.
The type of border is determined by shadow_type.shadow_type: The new border type. This is one of: GTK_SHADOW_NONE, GTK_SHADOW_IN, GTK_SHADOW_OUT, GTK_SHADOW_ETCHED_IN, or GTK_SHADOW_ETCHED_OUT.
snap_to_ticks: TRUE or FALSE.
policy: The new update policy. This is one of: GTK_UPDATE_ALWAYS, or GTK_UPDATE_IF_VALID.
value: The new floating point value.
wrap: Defaults to FALSE, set to TRUE to make the spin button wrap.
direction: The type of spin to perform.increment: The amount to spin.
The behaviour of the update is determined set_update_policy.