2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GtkSpinButton.html
27 * outFile = SpinButton
28 * strct = GtkSpinButton
48 * - GtkAdjustment* -> Adjustment
49 * - GtkWidget* -> Widget
54 module gtk
.SpinButton
;
60 import tango
.io
.Stdout
; // use the tango loging?
64 private import gtkc
.gtktypes
;
66 private import gtkc
.gtk
;
69 private import gtk
.Widget
;
70 private import gtk
.Adjustment
;
77 * A GtkSpinButton is an ideal way to allow the user to set the value of some
78 * attribute. Rather than having to directly type a number into a GtkEntry,
79 * GtkSpinButton allows the user to click on one of two arrows to increment or
80 * decrement the displayed value. A value can still be typed in, with the bonus
81 * that it can be checked to ensure it is in a given range.
82 * The main properties of a GtkSpinButton are through a GtkAdjustment. See the
83 * GtkAdjustment section for more details about an adjustment's properties.
84 * Example1.Using a GtkSpinButton to get an integer.
85 * /+* Provides a function to retrieve an integer value from a GtkSpinButton
86 * * and creates a spin button to model percentage values.
88 * gint grab_int_value (GtkSpinButton *a_spinner, gpointer user_data) {
89 * return gtk_spin_button_get_value_as_int (a_spinner);
91 * void create_integer_spin_button (void) {
92 * GtkWidget *window, *spinner;
93 * GtkAdjustment *spinner_adj;
94 * spinner_adj = (GtkAdjustment *) gtk_adjustment_new (50.0, 0.0, 100.0, 1.0, 5.0, 5.0);
95 * window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
96 * gtk_container_set_border_width (GTK_CONTAINER (window), 5);
97 * /+* creates the spinner, with no decimal places +/
98 * spinner = gtk_spin_button_new (spinner_adj, 1.0, 0);
99 * gtk_container_add (GTK_CONTAINER (window), spinner);
100 * gtk_widget_show_all (window);
103 * Example2.Using a GtkSpinButton to get a floating point value.
104 * /+* Provides a function to retrieve a floating point value from a
105 * * GtkSpinButton, and creates a high precision spin button.
107 * gfloat grab_int_value (GtkSpinButton *a_spinner, gpointer user_data) {
108 * return gtk_spin_button_get_value (a_spinner);
110 * void create_floating_spin_button (void) {
111 * GtkWidget *window, *spinner;
112 * GtkAdjustment *spinner_adj;
113 * spinner_adj = (GtkAdjustment *) gtk_adjustment_new (2.500, 0.0, 5.0, 0.001, 0.1, 0.1);
114 * window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
115 * gtk_container_set_border_width (GTK_CONTAINER (window), 5);
116 * /+* creates the spinner, with three decimal places +/
117 * spinner = gtk_spin_button_new (spinner_adj, 0.001, 3);
118 * gtk_container_add (GTK_CONTAINER (window), spinner);
119 * gtk_widget_show_all (window);
123 private import gtk
.Entry
;
124 public class SpinButton
: Entry
127 /** the main Gtk struct */
128 protected GtkSpinButton
* gtkSpinButton
;
131 public GtkSpinButton
* getSpinButtonStruct()
133 return gtkSpinButton
;
137 /** the main Gtk struct as a void* */
138 protected void* getStruct()
140 return cast(void*)gtkSpinButton
;
144 * Sets our main struct and passes it to the parent class
146 public this (GtkSpinButton
* gtkSpinButton
)
150 if ( gtkSpinButton
is null )
155 Stdout("struct gtkSpinButton is null on constructor").newline
;
159 printf("struct gtkSpinButton is null on constructor");
166 assert(gtkSpinButton
!is null, "struct gtkSpinButton is null on constructor");
168 super(cast(GtkEntry
*)gtkSpinButton
);
169 this.gtkSpinButton
= gtkSpinButton
;
175 // imports for the signal processing
176 private import gobject
.Signals
;
177 private import gtkc
.gdktypes
;
178 int[char[]] connectedSignals
;
180 void delegate(GtkScrollType
, SpinButton
)[] onChangeValueListeners
;
181 void addOnChangeValue(void delegate(GtkScrollType
, SpinButton
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
183 if ( !("change-value" in connectedSignals
) )
188 cast(GCallback
)&callBackChangeValue
,
192 connectedSignals
["change-value"] = 1;
194 onChangeValueListeners
~= dlg
;
196 extern(C
) static void callBackChangeValue(GtkSpinButton
* spinbuttonStruct
, GtkScrollType arg1
, SpinButton spinButton
)
198 bool consumed
= false;
200 foreach ( void delegate(GtkScrollType
, SpinButton
) dlg
; spinButton
.onChangeValueListeners
)
202 dlg(arg1
, spinButton
);
208 gint
delegate(gpointer
, SpinButton
)[] onInputListeners
;
209 void addOnInput(gint
delegate(gpointer
, SpinButton
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
211 if ( !("input" in connectedSignals
) )
216 cast(GCallback
)&callBackInput
,
220 connectedSignals
["input"] = 1;
222 onInputListeners
~= dlg
;
224 extern(C
) static void callBackInput(GtkSpinButton
* spinbuttonStruct
, gpointer arg1
, SpinButton spinButton
)
226 bool consumed
= false;
228 foreach ( gint
delegate(gpointer
, SpinButton
) dlg
; spinButton
.onInputListeners
)
230 dlg(arg1
, spinButton
);
236 gboolean
delegate(SpinButton
)[] onOutputListeners
;
237 void addOnOutput(gboolean
delegate(SpinButton
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
239 if ( !("output" in connectedSignals
) )
244 cast(GCallback
)&callBackOutput
,
248 connectedSignals
["output"] = 1;
250 onOutputListeners
~= dlg
;
252 extern(C
) static void callBackOutput(GtkSpinButton
* spinbuttonStruct
, SpinButton spinButton
)
254 bool consumed
= false;
256 foreach ( gboolean
delegate(SpinButton
) dlg
; spinButton
.onOutputListeners
)
264 void delegate(SpinButton
)[] onValueChangedListeners
;
265 void addOnValueChanged(void delegate(SpinButton
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
267 if ( !("value-changed" in connectedSignals
) )
272 cast(GCallback
)&callBackValueChanged
,
276 connectedSignals
["value-changed"] = 1;
278 onValueChangedListeners
~= dlg
;
280 extern(C
) static void callBackValueChanged(GtkSpinButton
* spinbuttonStruct
, SpinButton spinButton
)
282 bool consumed
= false;
284 foreach ( void delegate(SpinButton
) dlg
; spinButton
.onValueChangedListeners
)
292 void delegate(SpinButton
)[] onWrappedListeners
;
293 void addOnWrapped(void delegate(SpinButton
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
295 if ( !("wrapped" in connectedSignals
) )
300 cast(GCallback
)&callBackWrapped
,
304 connectedSignals
["wrapped"] = 1;
306 onWrappedListeners
~= dlg
;
308 extern(C
) static void callBackWrapped(GtkSpinButton
* spinbuttonStruct
, SpinButton spinButton
)
310 bool consumed
= false;
312 foreach ( void delegate(SpinButton
) dlg
; spinButton
.onWrappedListeners
)
325 * 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.
331 * the new climb rate.
333 * the number of decimal places to display in the spin button.
335 public void configure(Adjustment adjustment
, double climbRate
, uint digits
)
337 // void gtk_spin_button_configure (GtkSpinButton *spin_button, GtkAdjustment *adjustment, gdouble climb_rate, guint digits);
338 gtk_spin_button_configure(gtkSpinButton
, (adjustment
is null) ?
null : adjustment
.getAdjustmentStruct(), climbRate
, digits
);
342 * Creates a new GtkSpinButton.
344 * the GtkAdjustment object that this spin button should use.
346 * specifies how much the spin button changes when an arrow is clicked on.
348 * the number of decimal places to display.
350 * The new spin button as a GtkWidget.
352 public this (Adjustment adjustment
, double climbRate
, uint digits
)
354 // GtkWidget* gtk_spin_button_new (GtkAdjustment *adjustment, gdouble climb_rate, guint digits);
355 this(cast(GtkSpinButton
*)gtk_spin_button_new((adjustment
is null) ?
null : adjustment
.getAdjustmentStruct(), climbRate
, digits
) );
359 * This is a convenience constructor that allows creation of a numeric
360 * GtkSpinButton without manually creating an adjustment. The value is
361 * initially set to the minimum value and a page increment of 10 * step
362 * is the default. The precision of the spin button is equivalent to the
364 * Note that the way in which the precision is derived works best if step
365 * is a power of ten. If the resulting precision is not suitable for your
366 * needs, use gtk_spin_button_set_digits() to correct it.
368 * Minimum allowable value
370 * Maximum allowable value
372 * Increment added or subtracted by spinning the widget
374 * The new spin button as a GtkWidget.
376 public this (double min
, double max
, double step
)
378 // GtkWidget* gtk_spin_button_new_with_range (gdouble min, gdouble max, gdouble step);
379 this(cast(GtkSpinButton
*)gtk_spin_button_new_with_range(min
, max
, step
) );
383 * Replaces the GtkAdjustment associated with spin_button.
387 * a GtkAdjustment to replace the existing adjustment
389 public void setAdjustment(Adjustment adjustment
)
391 // void gtk_spin_button_set_adjustment (GtkSpinButton *spin_button, GtkAdjustment *adjustment);
392 gtk_spin_button_set_adjustment(gtkSpinButton
, (adjustment
is null) ?
null : adjustment
.getAdjustmentStruct());
396 * Get the adjustment associated with a GtkSpinButton
400 * the GtkAdjustment of spin_button
402 public Adjustment
getAdjustment()
404 // GtkAdjustment* gtk_spin_button_get_adjustment (GtkSpinButton *spin_button);
405 return new Adjustment( gtk_spin_button_get_adjustment(gtkSpinButton
) );
409 * Set the precision to be displayed by spin_button. Up to 20 digit precision
414 * the number of digits after the decimal point to be displayed for the spin button's value
416 public void setDigits(uint digits
)
418 // void gtk_spin_button_set_digits (GtkSpinButton *spin_button, guint digits);
419 gtk_spin_button_set_digits(gtkSpinButton
, digits
);
423 * Sets the step and page increments for spin_button. This affects how
424 * quickly the value changes when the spin button's arrows are activated.
428 * increment applied for a button 1 press.
430 * increment applied for a button 2 press.
432 public void setIncrements(double step
, double page
)
434 // void gtk_spin_button_set_increments (GtkSpinButton *spin_button, gdouble step, gdouble page);
435 gtk_spin_button_set_increments(gtkSpinButton
, step
, page
);
439 * Sets the minimum and maximum allowable values for spin_button
443 * minimum allowable value
445 * maximum allowable value
447 public void setRange(double min
, double max
)
449 // void gtk_spin_button_set_range (GtkSpinButton *spin_button, gdouble min, gdouble max);
450 gtk_spin_button_set_range(gtkSpinButton
, min
, max
);
455 * Get the value spin_button represented as an integer.
459 * the value of spin_button
461 public int getValueAsInt()
463 // gint gtk_spin_button_get_value_as_int (GtkSpinButton *spin_button);
464 return gtk_spin_button_get_value_as_int(gtkSpinButton
);
468 * Set the value of spin_button.
474 public void setValue(double value
)
476 // void gtk_spin_button_set_value (GtkSpinButton *spin_button, gdouble value);
477 gtk_spin_button_set_value(gtkSpinButton
, value
);
481 * Sets the update behavior of a spin button. This determines whether the
482 * spin button is always updated or only when a valid value is set.
486 * a GtkSpinButtonUpdatePolicy value
488 public void setUpdatePolicy(GtkSpinButtonUpdatePolicy policy
)
490 // void gtk_spin_button_set_update_policy (GtkSpinButton *spin_button, GtkSpinButtonUpdatePolicy policy);
491 gtk_spin_button_set_update_policy(gtkSpinButton
, policy
);
495 * Sets the flag that determines if non-numeric text can be typed into
500 * flag indicating if only numeric entry is allowed.
502 public void setNumeric(int numeric
)
504 // void gtk_spin_button_set_numeric (GtkSpinButton *spin_button, gboolean numeric);
505 gtk_spin_button_set_numeric(gtkSpinButton
, numeric
);
509 * Increment or decrement a spin button's value in a specified direction
510 * by a specified amount.
514 * a GtkSpinType indicating the direction to spin.
516 * step increment to apply in the specified direction.
518 public void spin(GtkSpinType direction
, double increment
)
520 // void gtk_spin_button_spin (GtkSpinButton *spin_button, GtkSpinType direction, gdouble increment);
521 gtk_spin_button_spin(gtkSpinButton
, direction
, increment
);
525 * Sets the flag that determines if a spin button value wraps around to the
526 * opposite limit when the upper or lower limit of the range is exceeded.
530 * a flag indicating if wrapping behavior is performed.
532 public void setWrap(int wrap
)
534 // void gtk_spin_button_set_wrap (GtkSpinButton *spin_button, gboolean wrap);
535 gtk_spin_button_set_wrap(gtkSpinButton
, wrap
);
539 * Sets the policy as to whether values are corrected to the nearest step
540 * increment when a spin button is activated after providing an invalid value.
544 * a flag indicating if invalid values should be corrected.
546 public void setSnapToTicks(int snapToTicks
)
548 // void gtk_spin_button_set_snap_to_ticks (GtkSpinButton *spin_button, gboolean snap_to_ticks);
549 gtk_spin_button_set_snap_to_ticks(gtkSpinButton
, snapToTicks
);
553 * Manually force an update of the spin button.
559 // void gtk_spin_button_update (GtkSpinButton *spin_button);
560 gtk_spin_button_update(gtkSpinButton
);
564 * Fetches the precision of spin_button. See gtk_spin_button_set_digits().
568 * the current precision
570 public uint getDigits()
572 // guint gtk_spin_button_get_digits (GtkSpinButton *spin_button);
573 return gtk_spin_button_get_digits(gtkSpinButton
);
577 * Gets the current step and page the increments used by spin_button. See
578 * gtk_spin_button_set_increments().
582 * location to store step increment, or NULL
584 * location to store page increment, or NULL
586 public void getIncrements(double* step
, double* page
)
588 // void gtk_spin_button_get_increments (GtkSpinButton *spin_button, gdouble *step, gdouble *page);
589 gtk_spin_button_get_increments(gtkSpinButton
, step
, page
);
593 * Returns whether non-numeric text can be typed into the spin button.
594 * See gtk_spin_button_set_numeric().
598 * TRUE if only numeric text can be entered
600 public int getNumeric()
602 // gboolean gtk_spin_button_get_numeric (GtkSpinButton *spin_button);
603 return gtk_spin_button_get_numeric(gtkSpinButton
);
607 * Gets the range allowed for spin_button. See
608 * gtk_spin_button_set_range().
612 * location to store minimum allowed value, or NULL
614 * location to store maximum allowed value, or NULL
616 public void getRange(double* min
, double* max
)
618 // void gtk_spin_button_get_range (GtkSpinButton *spin_button, gdouble *min, gdouble *max);
619 gtk_spin_button_get_range(gtkSpinButton
, min
, max
);
623 * Returns whether the values are corrected to the nearest step. See
624 * gtk_spin_button_set_snap_to_ticks().
628 * TRUE if values are snapped to the nearest step.
630 public int getSnapToTicks()
632 // gboolean gtk_spin_button_get_snap_to_ticks (GtkSpinButton *spin_button);
633 return gtk_spin_button_get_snap_to_ticks(gtkSpinButton
);
637 * Gets the update behavior of a spin button. See
638 * gtk_spin_button_set_update_policy().
642 * the current update policy
644 public GtkSpinButtonUpdatePolicy
getUpdatePolicy()
646 // GtkSpinButtonUpdatePolicy gtk_spin_button_get_update_policy (GtkSpinButton *spin_button);
647 return gtk_spin_button_get_update_policy(gtkSpinButton
);
651 * Get the value in the spin_button.
655 * the value of spin_button
657 public double getValue()
659 // gdouble gtk_spin_button_get_value (GtkSpinButton *spin_button);
660 return gtk_spin_button_get_value(gtkSpinButton
);
664 * Returns whether the spin button's value wraps around to the
665 * opposite limit when the upper or lower limit of the range is
666 * exceeded. See gtk_spin_button_set_wrap().
670 * TRUE if the spin button wraps around
674 // gboolean gtk_spin_button_get_wrap (GtkSpinButton *spin_button);
675 return gtk_spin_button_get_wrap(gtkSpinButton
);