W Wrapl, The Programming Language

Libraries:Gtk:Gtk:SpinButton

Types

T

Inherits from:

A T 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 Gtk.Gtk.Entry.T, T 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 T are through a Gtk.Gtk.Adjustment.T. See the Gtk.Gtk.Adjustment.T section for more details about an adjustment's properties.

Example 17. Using a GtkSpinButton to get an integer.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/* Provides a function to retrieve an integer value from a GtkSpinButton
 * and creates a spin button to model percentage values.
 */
gint grab_int_value (GtkSpinButton *a_spinner, gpointer user_data) {
   return gtk_spin_button_get_value_as_int (a_spinner);
}
void create_integer_spin_button (void) {
   GtkWidget *window, *spinner;
   GtkAdjustment *spinner_adj;
   spinner_adj = (GtkAdjustment *) gtk_adjustment_new (50.0, 0.0, 100.0, 1.0, 5.0, 5.0);
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_container_set_border_width (GTK_CONTAINER (window), 5);
   /* creates the spinner, with no decimal places */
   spinner = gtk_spin_button_new (spinner_adj, 1.0, 0);
   gtk_container_add (GTK_CONTAINER (window), spinner);
   gtk_widget_show_all (window);
   return;
}



Example 18. Using a GtkSpinButton to get a floating point value.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/* Provides a function to retrieve a floating point value from a
 * GtkSpinButton, and creates a high precision spin button.
 */
gfloat grab_int_value (GtkSpinButton *a_spinner, gpointer user_data) {
   return gtk_spin_button_get_value (a_spinner);
}
void create_floating_spin_button (void) {
   GtkWidget *window, *spinner;
   GtkAdjustment *spinner_adj;
   spinner_adj = (GtkAdjustment *) gtk_adjustment_new (2.500, 0.0, 5.0, 0.001, 0.1, 0.1);
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_container_set_border_width (GTK_CONTAINER (window), 5);
   /* creates the spinner, with three decimal places */
   spinner = gtk_spin_button_new (spinner_adj, 0.001, 3);
   gtk_container_add (GTK_CONTAINER (window), spinner);
   gtk_widget_show_all (window);
   return;
}





Constants

Nil : T

Functions

GetType() : Gtk.GObject.Type.T



New(adjustment @ Gtk.Gtk.Adjustment.T, climb_rate @ Std.Real.T, digits @ Std.Integer.SmallT) : Gtk.Gtk.SpinButton.T

Creates a new T.

adjustment the Gtk.Gtk.Adjustment.T 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.
Returns The new spin button as a Gtk.Gtk.Widget.T.


NewWithRange(min @ Std.Real.T, max @ Std.Real.T, step @ Std.Real.T) : Gtk.Gtk.SpinButton.T

This is a convenience constructor that allows creation of a numeric T without manually creating an adjustment. The value is initially set to the minimum value and a page increment of 10 * step is the default. The precision of the spin button is equivalent to the precision of step.

Note that the way in which the precision is derived works best if step is a power of ten. If the resulting precision is not suitable for your needs, use SetDigits to correct it.

min Minimum allowable value
max Maximum allowable value
step Increment added or subtracted by spinning the widget
Returns The new spin button as a Gtk.Gtk.Widget.T.


Methods

:Configure(self @ T, adjustment @ Gtk.Gtk.Adjustment.T, climb_rate @ Std.Real.T, digits @ Std.Integer.SmallT) : Std.Object.T

Changes the properties of an existing spin button. The adjustment, climb rate, and number of decimal places are all changed accordingly, after this function call.

spin_button a T
adjustment a Gtk.Gtk.Adjustment.T. [allow-none]
climb_rate the new climb rate.
digits the number of decimal places to display in the spin button.


:GetAdjustment(self @ T) : Gtk.Gtk.Adjustment.T

Get the adjustment associated with a T

spin_button a T
Returns the Gtk.Gtk.Adjustment.T of spin_button. [transfer none]


:GetDigits(self @ T) : Std.Integer.SmallT

Fetches the precision of spin_button. See SetDigits.

spin_button a T
Returns the current precision


:GetIncrements(self @ T, step @ Std.Object.T, page @ Std.Object.T) : Std.Object.T

Gets the current step and page the increments used by spin_button. See SetIncrements.

spin_button a T
step location to store step increment, or NULL. [out][allow-none]
page location to store page increment, or NULL. [out][allow-none]


:GetNumeric(self @ T) : Std.Symbol.T

Returns whether non-numeric text can be typed into the spin button. See SetNumeric.

spin_button a T
Returns TRUE if only numeric text can be entered


:GetRange(self @ T, min @ Std.Object.T, max @ Std.Object.T) : Std.Object.T

Gets the range allowed for spin_button. See SetRange.

spin_button a T
min location to store minimum allowed value, or NULL. [out][allow-none]
max location to store maximum allowed value, or NULL. [out][allow-none]


:GetSnapToTicks(self @ T) : Std.Symbol.T

Returns whether the values are corrected to the nearest step. See SetSnapToTicks.

spin_button a T
Returns TRUE if values are snapped to the nearest step.


:GetUpdatePolicy(self @ T) : Gtk.Gtk.SpinButtonUpdatePolicy.T

Gets the update behavior of a spin button. See SetUpdatePolicy.

spin_button a T
Returns the current update policy


:GetValue(self @ T) : Std.Real.T

Get the value in the spin_button.

spin_button a T
Returns the value of spin_button


:GetValueAsInt(self @ T) : Std.Integer.SmallT

Get the value spin_button represented as an integer.

spin_button a T
Returns the value of spin_button


:GetWrap(self @ T) : Std.Symbol.T

Returns whether the spin button's value wraps around to the opposite limit when the upper or lower limit of the range is exceeded. See SetWrap.

spin_button a T
Returns TRUE if the spin button wraps around


:SetAdjustment(self @ T, adjustment @ Gtk.Gtk.Adjustment.T) : Std.Object.T

Replaces the Gtk.Gtk.Adjustment.T associated with spin_button.

spin_button a T
adjustment a Gtk.Gtk.Adjustment.T to replace the existing adjustment


:SetDigits(self @ T, digits @ Std.Integer.SmallT) : Std.Object.T

Set the precision to be displayed by spin_button. Up to 20 digit precision is allowed.

spin_button a T
digits the number of digits after the decimal point to be displayed for the spin button's value


:SetIncrements(self @ T, step @ Std.Real.T, page @ Std.Real.T) : Std.Object.T

Sets the step and page increments for spin_button. This affects how quickly the value changes when the spin button's arrows are activated.

spin_button a T
step increment applied for a button 1 press.
page increment applied for a button 2 press.


:SetNumeric(self @ T, numeric @ Std.Symbol.T) : Std.Object.T

Sets the flag that determines if non-numeric text can be typed into the spin button.

spin_button a T
numeric flag indicating if only numeric entry is allowed.


:SetRange(self @ T, min @ Std.Real.T, max @ Std.Real.T) : Std.Object.T

Sets the minimum and maximum allowable values for spin_button

spin_button a T
min minimum allowable value
max maximum allowable value


:SetSnapToTicks(self @ T, snap_to_ticks @ Std.Symbol.T) : Std.Object.T

Sets the policy as to whether values are corrected to the nearest step increment when a spin button is activated after providing an invalid value.

spin_button a T
snap_to_ticks a flag indicating if invalid values should be corrected.


:SetUpdatePolicy(self @ T, policy @ Gtk.Gtk.SpinButtonUpdatePolicy.T) : Std.Object.T

Sets the update behavior of a spin button. This determines whether the spin button is always updated or only when a valid value is set.

spin_button a T
policy a Gtk.Gtk.SpinButtonUpdatePolicy.T value


:SetValue(self @ T, value @ Std.Real.T) : Std.Object.T

Set the value of spin_button.

spin_button a T
value the new value


:SetWrap(self @ T, wrap @ Std.Symbol.T) : Std.Object.T

Sets the flag that determines if a spin button value wraps around to the opposite limit when the upper or lower limit of the range is exceeded.

spin_button a T
wrap a flag indicating if wrapping behavior is performed.


:Spin(self @ T, direction @ Gtk.Gtk.SpinType.T, increment @ Std.Real.T) : Std.Object.T

Increment or decrement a spin button's value in a specified direction by a specified amount.

spin_button a T
direction a Gtk.Gtk.SpinType.T indicating the direction to spin.
increment step increment to apply in the specified direction.


:Update(self @ T) : Std.Object.T

Manually force an update of the spin button.

spin_button a T