1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = GtkLevelBar.html
27  * outPack = gtk
28  * outFile = LevelBar
29  * strct   = GtkLevelBar
30  * realStrct=
31  * ctorStrct=
32  * clss    = LevelBar
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_level_bar_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * structWrap:
48  * module aliases:
49  * local aliases:
50  * overrides:
51  */
52 
53 module gtk.LevelBar;
54 
55 public  import gtkc.gtktypes;
56 
57 private import gtkc.gtk;
58 private import glib.ConstructionException;
59 private import gobject.ObjectG;
60 
61 private import gobject.Signals;
62 public  import gtkc.gdktypes;
63 
64 private import glib.Str;
65 
66 
67 
68 private import gtk.Widget;
69 
70 /**
71  * The GtkLevelBar is a bar widget that can be used
72  * as a level indicator. Typical use cases are displaying the strength
73  * of a password, or showing the charge level of a battery.
74  *
75  * Use gtk_level_bar_set_value() to set the current value, and
76  * gtk_level_bar_add_offset_value() to set the value offsets at which
77  * the bar will be considered in a different state. GTK will add two offsets
78  * by default on the level bar: GTK_LEVEL_BAR_OFFSET_LOW and
79  * GTK_LEVEL_BAR_OFFSET_HIGH, with values 0.25 and 0.75 respectively.
80  *
81  * $(DDOC_COMMENT example)
82  *
83  * The default interval of values is between zero and one, but it's possible to
84  * modify the interval using gtk_level_bar_set_min_value() and
85  * gtk_level_bar_set_max_value(). The value will be always drawn in proportion to
86  * the admissible interval, i.e. a value of 15 with a specified interval between
87  * 10 and 20 is equivalent to a value of 0.5 with an interval between 0 and 1.
88  * When GTK_LEVEL_BAR_MODE_DISCRETE is used, the bar level is rendered
89  * as a finite and number of separated blocks instead of a single one. The number
90  * of blocks that will be rendered is equal to the number of units specified by
91  * the admissible interval.
92  * For instance, to build a bar rendered with five blocks, it's sufficient to
93  * set the minimum value to 0 and the maximum value to 5 after changing the indicator
94  * mode to discrete.
95  */
96 public class LevelBar : Widget
97 {
98 	
99 	/** the main Gtk struct */
100 	protected GtkLevelBar* gtkLevelBar;
101 	
102 	
103 	public GtkLevelBar* getLevelBarStruct()
104 	{
105 		return gtkLevelBar;
106 	}
107 	
108 	
109 	/** the main Gtk struct as a void* */
110 	protected override void* getStruct()
111 	{
112 		return cast(void*)gtkLevelBar;
113 	}
114 	
115 	/**
116 	 * Sets our main struct and passes it to the parent class
117 	 */
118 	public this (GtkLevelBar* gtkLevelBar)
119 	{
120 		super(cast(GtkWidget*)gtkLevelBar);
121 		this.gtkLevelBar = gtkLevelBar;
122 	}
123 	
124 	protected override void setStruct(GObject* obj)
125 	{
126 		super.setStruct(obj);
127 		gtkLevelBar = cast(GtkLevelBar*)obj;
128 	}
129 	
130 	/**
131 	 */
132 	int[string] connectedSignals;
133 	
134 	void delegate(string, LevelBar)[] onOffsetChangedListeners;
135 	/**
136 	 * Emitted when an offset specified on the bar changes value as an
137 	 * effect to gtk_level_bar_add_offset_value() being called.
138 	 * The signal supports detailed connections; you can connect to the
139 	 * detailed signal "changed::x" in order to only receive callbacks when
140 	 * the value of offset "x" changes.
141 	 * Since 3.6
142 	 */
143 	void addOnOffsetChanged(void delegate(string, LevelBar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
144 	{
145 		if ( !("offset-changed" in connectedSignals) )
146 		{
147 			Signals.connectData(
148 			getStruct(),
149 			"offset-changed",
150 			cast(GCallback)&callBackOffsetChanged,
151 			cast(void*)this,
152 			null,
153 			connectFlags);
154 			connectedSignals["offset-changed"] = 1;
155 		}
156 		onOffsetChangedListeners ~= dlg;
157 	}
158 	extern(C) static void callBackOffsetChanged(GtkLevelBar* selfStruct, gchar* name, LevelBar _levelBar)
159 	{
160 		foreach ( void delegate(string, LevelBar) dlg ; _levelBar.onOffsetChangedListeners )
161 		{
162 			dlg(Str.toString(name), _levelBar);
163 		}
164 	}
165 	
166 	
167 	/**
168 	 * Creates a new GtkLevelBar.
169 	 * Throws: ConstructionException GTK+ fails to create the object.
170 	 */
171 	public this ()
172 	{
173 		// GtkWidget * gtk_level_bar_new (void);
174 		auto p = gtk_level_bar_new();
175 		if(p is null)
176 		{
177 			throw new ConstructionException("null returned by gtk_level_bar_new()");
178 		}
179 		this(cast(GtkLevelBar*) p);
180 	}
181 	
182 	/**
183 	 * Utility constructor that creates a new GtkLevelBar for the specified
184 	 * interval.
185 	 * Params:
186 	 * minValue = a positive value
187 	 * maxValue = a positive value
188 	 * Throws: ConstructionException GTK+ fails to create the object.
189 	 */
190 	public this (double minValue, double maxValue)
191 	{
192 		// GtkWidget * gtk_level_bar_new_for_interval (gdouble min_value,  gdouble max_value);
193 		auto p = gtk_level_bar_new_for_interval(minValue, maxValue);
194 		if(p is null)
195 		{
196 			throw new ConstructionException("null returned by gtk_level_bar_new_for_interval(minValue, maxValue)");
197 		}
198 		this(cast(GtkLevelBar*) p);
199 	}
200 	
201 	/**
202 	 * Sets the value of the "mode" property.
203 	 * Params:
204 	 * mode = a GtkLevelBarMode
205 	 * Since 3.6
206 	 */
207 	public void setMode(GtkLevelBarMode mode)
208 	{
209 		// void gtk_level_bar_set_mode (GtkLevelBar *self,  GtkLevelBarMode mode);
210 		gtk_level_bar_set_mode(gtkLevelBar, mode);
211 	}
212 	
213 	/**
214 	 * Returns the value of the "mode" property.
215 	 * Returns: a GtkLevelBarMode Since 3.6
216 	 */
217 	public GtkLevelBarMode getMode()
218 	{
219 		// GtkLevelBarMode gtk_level_bar_get_mode (GtkLevelBar *self);
220 		return gtk_level_bar_get_mode(gtkLevelBar);
221 	}
222 	
223 	/**
224 	 * Sets the value of the "value" property.
225 	 * Params:
226 	 * value = a value in the interval between
227 	 * "min-value" and "max-value"
228 	 * Since 3.6
229 	 */
230 	public void setValue(double value)
231 	{
232 		// void gtk_level_bar_set_value (GtkLevelBar *self,  gdouble value);
233 		gtk_level_bar_set_value(gtkLevelBar, value);
234 	}
235 	
236 	/**
237 	 * Returns the value of the "value" property.
238 	 * Returns: a value in the interval between "min-value" and "max-value" Since 3.6
239 	 */
240 	public double getValue()
241 	{
242 		// gdouble gtk_level_bar_get_value (GtkLevelBar *self);
243 		return gtk_level_bar_get_value(gtkLevelBar);
244 	}
245 	
246 	/**
247 	 * Sets the value of the "min-value" property.
248 	 * Params:
249 	 * value = a positive value
250 	 * Since 3.6
251 	 */
252 	public void setMinValue(double value)
253 	{
254 		// void gtk_level_bar_set_min_value (GtkLevelBar *self,  gdouble value);
255 		gtk_level_bar_set_min_value(gtkLevelBar, value);
256 	}
257 	
258 	/**
259 	 * Returns the value of the "min-value" property.
260 	 * Returns: a positive value Since 3.6
261 	 */
262 	public double getMinValue()
263 	{
264 		// gdouble gtk_level_bar_get_min_value (GtkLevelBar *self);
265 		return gtk_level_bar_get_min_value(gtkLevelBar);
266 	}
267 	
268 	/**
269 	 * Sets the value of the "max-value" property.
270 	 * Params:
271 	 * value = a positive value
272 	 * Since 3.6
273 	 */
274 	public void setMaxValue(double value)
275 	{
276 		// void gtk_level_bar_set_max_value (GtkLevelBar *self,  gdouble value);
277 		gtk_level_bar_set_max_value(gtkLevelBar, value);
278 	}
279 	
280 	/**
281 	 * Returns the value of the "max-value" property.
282 	 * Returns: a positive value Since 3.6
283 	 */
284 	public double getMaxValue()
285 	{
286 		// gdouble gtk_level_bar_get_max_value (GtkLevelBar *self);
287 		return gtk_level_bar_get_max_value(gtkLevelBar);
288 	}
289 	
290 	/**
291 	 * Sets the value of the "inverted" property.
292 	 * Params:
293 	 * inverted = TRUE to invert the level bar
294 	 * Since 3.8
295 	 */
296 	public void setInverted(int inverted)
297 	{
298 		// void gtk_level_bar_set_inverted (GtkLevelBar *self,  gboolean inverted);
299 		gtk_level_bar_set_inverted(gtkLevelBar, inverted);
300 	}
301 	
302 	/**
303 	 * Return the value of the "inverted" property.
304 	 * Returns: TRUE if the level bar is inverted Since 3.8
305 	 */
306 	public int getInverted()
307 	{
308 		// gboolean gtk_level_bar_get_inverted (GtkLevelBar *self);
309 		return gtk_level_bar_get_inverted(gtkLevelBar);
310 	}
311 	
312 	/**
313 	 * Adds a new offset marker on self at the position specified by value.
314 	 * When the bar value is in the interval topped by value (or between value
315 	 * and "max-value" in case the offset is the last one on the bar)
316 	 * a style class named level-name will be applied
317 	 * when rendering the level bar fill.
318 	 * If another offset marker named name exists, its value will be
319 	 * replaced by value.
320 	 * Params:
321 	 * name = the name of the new offset
322 	 * value = the value for the new offset
323 	 * Since 3.6
324 	 */
325 	public void addOffsetValue(string name, double value)
326 	{
327 		// void gtk_level_bar_add_offset_value (GtkLevelBar *self,  const gchar *name,  gdouble value);
328 		gtk_level_bar_add_offset_value(gtkLevelBar, Str.toStringz(name), value);
329 	}
330 	
331 	/**
332 	 * Removes an offset marker previously added with
333 	 * gtk_level_bar_add_offset_value().
334 	 * Params:
335 	 * name = the name of an offset in the bar. [allow-none]
336 	 * Since 3.6
337 	 */
338 	public void removeOffsetValue(string name)
339 	{
340 		// void gtk_level_bar_remove_offset_value (GtkLevelBar *self,  const gchar *name);
341 		gtk_level_bar_remove_offset_value(gtkLevelBar, Str.toStringz(name));
342 	}
343 	
344 	/**
345 	 * Fetches the value specified for the offset marker name in self,
346 	 * returning TRUE in case an offset named name was found.
347 	 * Params:
348 	 * name = the name of an offset in the bar. [allow-none]
349 	 * value = location where to store the value. [out]
350 	 * Returns: TRUE if the specified offset is found Since 3.6
351 	 */
352 	public int getOffsetValue(string name, out double value)
353 	{
354 		// gboolean gtk_level_bar_get_offset_value (GtkLevelBar *self,  const gchar *name,  gdouble *value);
355 		return gtk_level_bar_get_offset_value(gtkLevelBar, Str.toStringz(name), &value);
356 	}
357 }