gtkSpinButtonConfigure(object, adjustment = NULL, climb.rate, digits)
gtkSpinButtonNew(adjustment = NULL, climb.rate = NULL, digits = NULL, show = TRUE)
gtkSpinButtonNewWithRange(min, max, step, show = TRUE)
gtkSpinButtonSetAdjustment(object, adjustment)
gtkSpinButtonGetAdjustment(object)
gtkSpinButtonSetDigits(object, digits)
gtkSpinButtonSetIncrements(object, step, page)
gtkSpinButtonSetRange(object, min, max)
gtkSpinButtonGetValueAsInt(object)
gtkSpinButtonSetValue(object, value)
gtkSpinButtonSetUpdatePolicy(object, policy)
gtkSpinButtonSetNumeric(object, numeric)
gtkSpinButtonSpin(object, direction, increment)
gtkSpinButtonSetWrap(object, wrap)
gtkSpinButtonSetSnapToTicks(object, snap.to.ticks)
gtkSpinButtonUpdate(object)
gtkSpinButtonGetDigits(object)
gtkSpinButtonGetIncrements(object)
gtkSpinButtonGetNumeric(object)
gtkSpinButtonGetRange(object)
gtkSpinButtonGetSnapToTicks(object)
gtkSpinButtonGetUpdatePolicy(object)
gtkSpinButtonGetValue(object)
gtkSpinButtonGetWrap(object)
gtkSpinButton(adjustment = NULL, climb.rate = NULL, digits = NULL, min, max, step, show = TRUE)GObject
+----GInitiallyUnowned
+----GtkObject
+----GtkWidget
+----GtkEntry
+----GtkSpinButtonGtkBuildable, GtkEditable and GtkCellEditable.GtkSpinButton is an ideal way to allow the user to set the value of some
attribute. Rather than having to directly type a number into a GtkEntry,
GtkSpinButton allows the user to click on one of two arrows to increment or
decrement the displayed value. A value can still be typed in, with the bonus
that it can be checked to ensure it is in a given range. The main properties of a GtkSpinButton are through a GtkAdjustment. See the
GtkAdjustment section for more details about an adjustment's properties. Using a GtkSpinButton to get an integer.
## Provides a function to retrieve an integer value from a GtkSpinButton
## and creates a spin button to model percentage values. grab_int_value <- function(a_spinner, user_data) {
return(a_spinner$getValueAsInt())
} create_integer_spin_button <- function() { spinner_adj <- gtkAdjustment(50.0, 0.0, 100.0, 1.0, 5.0, 5.0) window <- gtkWindow("toplevel", show = F)
window$setBorderWidth(5) ## creates the spinner, with no decimal places
spinner <- gtkSpinner(spinner_adj, 1.0, 0)
window$add(spinner) window$showAll()
}
Using a GtkSpinButton to get a floating point value.
# Provides a function to retrieve a floating point value from a
# GtkSpinButton, and creates a high precision spin button. grab_value <- function(a_spinner, user_data) {
return(a_spinner$getValue())
} create_floating_spin_button <- function() { spinner_adj <- gtkAdjustment(2.500, 0.0, 5.0, 0.001, 0.1, 0.1) window <- gtkWindow("toplevel", show = F)
window$setBorderWidth(5) ## creates the spinner, with three decimal places
spinner <- gtkSpinner(spinner_adj, 0.001, 3)
window$add(spinner) window$showAll()
}
gtkSpinButton is the result of collapsing the constructors of GtkSpinButton (gtkSpinButtonNew, gtkSpinButtonNewWithRange) and accepts a subset of its arguments matching the required arguments of one of its delegate constructors.GtkSpinButtonUpdatePolicy| GTK_UPDATE_ALWAYS |
When refreshing your GtkSpinButton , the value is always displayed. |
| GTK_UPDATE_IF_VALID |
When refreshing your GtkSpinButton , the value is only displayed if it is valid within the bounds of the spin button's GtkAdjustment . |
alwaysif-validGtkSpinType| GTK_SPIN_STEP_FORWARD, GTK_SPIN_STEP_BACKWARD, GTK_SPIN_PAGE_FORWARD, GTK_SPIN_PAGE_BACKWARD |
These values spin a GtkSpinButton by the relevant values of the spin button's GtkAdjustment . |
| GTK_SPIN_HOME, GTK_SPIN_END |
These set the spin button's value to the minimum or maxmimum possible values, (set by its GtkAdjustment ), respectively. |
| GTK_SPIN_USER_DEFINED |
The programmer must specify the exact amount to spin the GtkSpinButton . |
step-forwardstep-backwardpage-forwardpage-backwardhomeenduser-definedchange-value(spinbutton, user.data)spinbuttonuser.datainput(spinbutton, user.data)spinbuttonuser.dataoutput(spin.button, user.data)/* show leading zeros */
static gboolean
on_output (GtkSpinButton *spin,
gpointer data)
{
GtkAdjustment *adj;
gchar *text;
int value; adj = gtk_spin_button_get_adjustment (spin);
value = (int)gtk_adjustment_get_value (adj);
text = g_strdup_printf ("%02d", value);
gtk_entry_set_text (GTK_ENTRY (spin), text);
g_free (text); return TRUE;
}
spin.buttonuser.dataTRUE if the value has been displayed. value-changed(spinbutton, user.data)spinbuttonuser.datawrapped(spinbutton, user.data)spinbuttonuser.dataadjustment [GtkAdjustment : * : Read / Write]climb-rate [numeric : Read / Write]digits [numeric : Read / Write]numeric [logical : Read / Write]snap-to-ticks [logical : Read / Write]update-policy [GtkSpinButtonUpdatePolicy : Read / Write]value [numeric : Read / Write]wrap [logical : Read / Write]