alternative to assert
[gtkD.git] / src / gtk / Scale.d
blob6b9d89171957c4e7171cd20fae647b43ef97029f
1 /*
2 * This file is part of duit.
4 * duit 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 * duit 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 duit; 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 = GtkScale.html
26 * outPack = gtk
27 * outFile = Scale
28 * strct = GtkScale
29 * realStrct=
30 * ctorStrct=
31 * clss = Scale
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gtk_scale_
40 * - gtk_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * imports:
45 * structWrap:
46 * local aliases:
49 module gtk.Scale;
51 private import gtk.gtktypes;
53 private import lib.gtk;
56 /**
57 * Description
58 * A GtkScale is a slider control used to select a numeric value.
59 * To use it, you'll probably want to investigate the methods on
60 * its base class, GtkRange, in addition to the methods for GtkScale itself.
61 * To set the value of a scale, you would normally use gtk_range_set_value().
62 * To detect changes to the value, you would normally use the "value_changed"
63 * signal.
64 * The GtkScale widget is an abstract class, used only for deriving the
65 * subclasses GtkHScale and GtkVScale. To create a scale widget,
66 * call gtk_hscale_new_with_range() or gtk_vscale_new_with_range().
68 private import gtk.Range;
69 public class Scale : Range
72 /** the main Gtk struct */
73 protected GtkScale* gtkScale;
76 public GtkScale* getScaleStruct()
78 return gtkScale;
82 /** the main Gtk struct as a void* */
83 protected void* getStruct()
85 return cast(void*)gtkScale;
88 /**
89 * Sets our main struct and passes it to the parent class
91 public this (GtkScale* gtkScale)
93 super(cast(GtkRange*)gtkScale);
94 this.gtkScale = gtkScale;
97 /**
100 // imports for the signal processing
101 private import gobject.Signals;
102 private import gdk.gdktypes;
103 int[char[]] connectedSignals;
105 char[] delegate(gdouble, Scale)[] onFormatValueListeners;
106 void addOnFormatValue(char[] delegate(gdouble, Scale) dlg)
108 if ( !("format-value" in connectedSignals) )
110 Signals.connectData(
111 getStruct(),
112 "format-value",
113 cast(GCallback)&callBackFormatValue,
114 this,
115 null,
116 cast(ConnectFlags)0);
117 connectedSignals["format-value"] = 1;
119 onFormatValueListeners ~= dlg;
121 extern(C) static void callBackFormatValue(GtkScale* scaleStruct, gdouble arg1, Scale scale)
123 bit consumed = false;
125 foreach ( char[] delegate(gdouble, Scale) dlg ; scale.onFormatValueListeners )
127 dlg(arg1, scale);
130 return consumed;
136 * Sets the number of decimal places that are displayed in the value. Also causes
137 * the value of the adjustment to be rounded off to this number of digits, so the
138 * retrieved value matches the value the user saw.
139 * scale:
140 * a GtkScale.
141 * digits:
142 * the number of decimal places to display, e.g. use 1 to display 1.0,
143 * 2 to display 1.00 etc.
145 public void setDigits(int digits)
147 // void gtk_scale_set_digits (GtkScale *scale, gint digits);
148 gtk_scale_set_digits(gtkScale, digits);
152 * Specifies whether the current value is displayed as a string next to the
153 * slider.
154 * scale:
155 * a GtkScale.
156 * draw_value:
157 * a boolean.
159 public void setDrawValue(int drawValue)
161 // void gtk_scale_set_draw_value (GtkScale *scale, gboolean draw_value);
162 gtk_scale_set_draw_value(gtkScale, drawValue);
166 * Sets the position in which the current value is displayed.
167 * scale:
168 * a GtkScale.
169 * pos:
170 * the position in which the current value is displayed.
172 public void setValuePos(GtkPositionType pos)
174 // void gtk_scale_set_value_pos (GtkScale *scale, GtkPositionType pos);
175 gtk_scale_set_value_pos(gtkScale, pos);
179 * Gets the number of decimal places that are displayed in the value.
180 * scale:
181 * a GtkScale.
182 * Returns:
183 * the number of decimal places that are displayed.
185 public int getDigits()
187 // gint gtk_scale_get_digits (GtkScale *scale);
188 return gtk_scale_get_digits(gtkScale);
192 * Returns whether the current value is displayed as a string next to the
193 * slider.
194 * scale:
195 * a GtkScale.
196 * Returns:
197 * whether the current value is displayed as a string.
199 public int getDrawValue()
201 // gboolean gtk_scale_get_draw_value (GtkScale *scale);
202 return gtk_scale_get_draw_value(gtkScale);
206 * Gets the position in which the current value is displayed.
207 * scale:
208 * a GtkScale.
209 * Returns:
210 * the position in which the current value is displayed.
212 public GtkPositionType getValuePos()
214 // GtkPositionType gtk_scale_get_value_pos (GtkScale *scale);
215 return gtk_scale_get_value_pos(gtkScale);
219 * Gets the PangoLayout used to display the scale. The returned object
220 * is owned by the scale so does not need to be freed by the caller.
221 * scale:
222 * A GtkScale
223 * Returns:
224 * the PangoLayout for this scale, or NULL if the draw_value property
225 * is FALSE.
226 * Since 2.4
228 public PangoLayout* getLayout()
230 // PangoLayout* gtk_scale_get_layout (GtkScale *scale);
231 return gtk_scale_get_layout(gtkScale);
235 * Obtains the coordinates where the scale will draw the PangoLayout
236 * representing the text in the scale. Remember
237 * when using the PangoLayout function you need to convert to
238 * and from pixels using PANGO_PIXELS() or PANGO_SCALE.
239 * If the draw_value property is FALSE, the return values are
240 * undefined.
241 * scale:
242 * a GtkScale
243 * x:
244 * location to store X offset of layout, or NULL
245 * y:
246 * location to store Y offset of layout, or NULL
247 * Since 2.4
248 * Property Details
249 * The "digits" property
250 * "digits" gint : Read / Write
251 * The number of decimal places that are displayed in the value.
252 * Allowed values: [-1,64]
253 * Default value: 1
255 public void getLayoutOffsets(int* x, int* y)
257 // void gtk_scale_get_layout_offsets (GtkScale *scale, gint *x, gint *y);
258 gtk_scale_get_layout_offsets(gtkScale, x, y);