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 private import glib.Str;
64 
65 
66 private import gtk.Widget;
67 
68 /**
69  * The GtkLevelBar is a bar widget that can be used
70  * as a level indicator. Typical use cases are displaying the strength
71  * of a password, or showing the charge level of a battery.
72  *
73  * Use gtk_level_bar_set_value() to set the current value, and
74  * gtk_level_bar_add_offset_value() to set the value offsets at which
75  * the bar will be considered in a different state. GTK will add two offsets
76  * by default on the level bar: GTK_LEVEL_BAR_OFFSET_LOW and
77  * GTK_LEVEL_BAR_OFFSET_HIGH, with values 0.25 and 0.75 respectively.
78  *
79  * $(DDOC_COMMENT example)
80  *
81  * The default interval of values is between zero and one, but it's possible to
82  * modify the interval using gtk_level_bar_set_min_value() and
83  * gtk_level_bar_set_max_value(). The value will be always drawn in proportion to
84  * the admissible interval, i.e. a value of 15 with a specified interval between
85  * 10 and 20 is equivalent to a value of 0.5 with an interval between 0 and 1.
86  * When GTK_LEVEL_BAR_MODE_DISCRETE is used, the bar level is rendered
87  * as a finite and number of separated blocks instead of a single one. The number
88  * of blocks that will be rendered is equal to the number of units specified by
89  * the admissible interval.
90  * For instance, to build a bar rendered with five blocks, it's sufficient to
91  * set the minimum value to 0 and the maximum value to 5 after changing the indicator
92  * mode to discrete.
93  */
94 public class LevelBar : Widget
95 {
96 	
97 	/** the main Gtk struct */
98 	protected GtkLevelBar* gtkLevelBar;
99 	
100 	
101 	/** Get the main Gtk struct */
102 	public GtkLevelBar* getLevelBarStruct()
103 	{
104 		return gtkLevelBar;
105 	}
106 	
107 	
108 	/** the main Gtk struct as a void* */
109 	protected override void* getStruct()
110 	{
111 		return cast(void*)gtkLevelBar;
112 	}
113 	
114 	/**
115 	 * Sets our main struct and passes it to the parent class
116 	 */
117 	public this (GtkLevelBar* gtkLevelBar)
118 	{
119 		super(cast(GtkWidget*)gtkLevelBar);
120 		this.gtkLevelBar = gtkLevelBar;
121 	}
122 	
123 	protected override void setStruct(GObject* obj)
124 	{
125 		super.setStruct(obj);
126 		gtkLevelBar = cast(GtkLevelBar*)obj;
127 	}
128 	
129 	/**
130 	 */
131 	int[string] connectedSignals;
132 	
133 	void delegate(string, LevelBar)[] onOffsetChangedListeners;
134 	/**
135 	 * Emitted when an offset specified on the bar changes value as an
136 	 * effect to gtk_level_bar_add_offset_value() being called.
137 	 * The signal supports detailed connections; you can connect to the
138 	 * detailed signal "changed::x" in order to only receive callbacks when
139 	 * the value of offset "x" changes.
140 	 * Since 3.6
141 	 */
142 	void addOnOffsetChanged(void delegate(string, LevelBar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
143 	{
144 		if ( !("offset-changed" in connectedSignals) )
145 		{
146 			Signals.connectData(
147 			getStruct(),
148 			"offset-changed",
149 			cast(GCallback)&callBackOffsetChanged,
150 			cast(void*)this,
151 			null,
152 			connectFlags);
153 			connectedSignals["offset-changed"] = 1;
154 		}
155 		onOffsetChangedListeners ~= dlg;
156 	}
157 	extern(C) static void callBackOffsetChanged(GtkLevelBar* selfStruct, gchar* name, LevelBar _levelBar)
158 	{
159 		foreach ( void delegate(string, LevelBar) dlg ; _levelBar.onOffsetChangedListeners )
160 		{
161 			dlg(Str.toString(name), _levelBar);
162 		}
163 	}
164 	
165 	
166 	/**
167 	 * Creates a new GtkLevelBar.
168 	 * Throws: ConstructionException GTK+ fails to create the object.
169 	 */
170 	public this ()
171 	{
172 		// GtkWidget * gtk_level_bar_new (void);
173 		auto p = gtk_level_bar_new();
174 		if(p is null)
175 		{
176 			throw new ConstructionException("null returned by gtk_level_bar_new()");
177 		}
178 		this(cast(GtkLevelBar*) p);
179 	}
180 	
181 	/**
182 	 * Utility constructor that creates a new GtkLevelBar for the specified
183 	 * interval.
184 	 * Params:
185 	 * minValue = a positive value
186 	 * maxValue = a positive value
187 	 * Throws: ConstructionException GTK+ fails to create the object.
188 	 */
189 	public this (double minValue, double maxValue)
190 	{
191 		// GtkWidget * gtk_level_bar_new_for_interval (gdouble min_value,  gdouble max_value);
192 		auto p = gtk_level_bar_new_for_interval(minValue, maxValue);
193 		if(p is null)
194 		{
195 			throw new ConstructionException("null returned by gtk_level_bar_new_for_interval(minValue, maxValue)");
196 		}
197 		this(cast(GtkLevelBar*) p);
198 	}
199 	
200 	/**
201 	 * Sets the value of the "mode" property.
202 	 * Params:
203 	 * mode = a GtkLevelBarMode
204 	 * Since 3.6
205 	 */
206 	public void setMode(GtkLevelBarMode mode)
207 	{
208 		// void gtk_level_bar_set_mode (GtkLevelBar *self,  GtkLevelBarMode mode);
209 		gtk_level_bar_set_mode(gtkLevelBar, mode);
210 	}
211 	
212 	/**
213 	 * Returns the value of the "mode" property.
214 	 * Returns: a GtkLevelBarMode Since 3.6
215 	 */
216 	public GtkLevelBarMode getMode()
217 	{
218 		// GtkLevelBarMode gtk_level_bar_get_mode (GtkLevelBar *self);
219 		return gtk_level_bar_get_mode(gtkLevelBar);
220 	}
221 	
222 	/**
223 	 * Sets the value of the "value" property.
224 	 * Params:
225 	 * value = a value in the interval between
226 	 * "min-value" and "max-value"
227 	 * Since 3.6
228 	 */
229 	public void setValue(double value)
230 	{
231 		// void gtk_level_bar_set_value (GtkLevelBar *self,  gdouble value);
232 		gtk_level_bar_set_value(gtkLevelBar, value);
233 	}
234 	
235 	/**
236 	 * Returns the value of the "value" property.
237 	 * Returns: a value in the interval between "min-value" and "max-value" Since 3.6
238 	 */
239 	public double getValue()
240 	{
241 		// gdouble gtk_level_bar_get_value (GtkLevelBar *self);
242 		return gtk_level_bar_get_value(gtkLevelBar);
243 	}
244 	
245 	/**
246 	 * Sets the value of the "min-value" property.
247 	 * Params:
248 	 * value = a positive value
249 	 * Since 3.6
250 	 */
251 	public void setMinValue(double value)
252 	{
253 		// void gtk_level_bar_set_min_value (GtkLevelBar *self,  gdouble value);
254 		gtk_level_bar_set_min_value(gtkLevelBar, value);
255 	}
256 	
257 	/**
258 	 * Returns the value of the "min-value" property.
259 	 * Returns: a positive value Since 3.6
260 	 */
261 	public double getMinValue()
262 	{
263 		// gdouble gtk_level_bar_get_min_value (GtkLevelBar *self);
264 		return gtk_level_bar_get_min_value(gtkLevelBar);
265 	}
266 	
267 	/**
268 	 * Sets the value of the "max-value" property.
269 	 * Params:
270 	 * value = a positive value
271 	 * Since 3.6
272 	 */
273 	public void setMaxValue(double value)
274 	{
275 		// void gtk_level_bar_set_max_value (GtkLevelBar *self,  gdouble value);
276 		gtk_level_bar_set_max_value(gtkLevelBar, value);
277 	}
278 	
279 	/**
280 	 * Returns the value of the "max-value" property.
281 	 * Returns: a positive value Since 3.6
282 	 */
283 	public double getMaxValue()
284 	{
285 		// gdouble gtk_level_bar_get_max_value (GtkLevelBar *self);
286 		return gtk_level_bar_get_max_value(gtkLevelBar);
287 	}
288 	
289 	/**
290 	 * Sets the value of the "inverted" property.
291 	 * Params:
292 	 * inverted = TRUE to invert the level bar
293 	 * Since 3.8
294 	 */
295 	public void setInverted(int inverted)
296 	{
297 		// void gtk_level_bar_set_inverted (GtkLevelBar *self,  gboolean inverted);
298 		gtk_level_bar_set_inverted(gtkLevelBar, inverted);
299 	}
300 	
301 	/**
302 	 * Return the value of the "inverted" property.
303 	 * Returns: TRUE if the level bar is inverted Since 3.8
304 	 */
305 	public int getInverted()
306 	{
307 		// gboolean gtk_level_bar_get_inverted (GtkLevelBar *self);
308 		return gtk_level_bar_get_inverted(gtkLevelBar);
309 	}
310 	
311 	/**
312 	 * Adds a new offset marker on self at the position specified by value.
313 	 * When the bar value is in the interval topped by value (or between value
314 	 * and "max-value" in case the offset is the last one on the bar)
315 	 * a style class named level-name will be applied
316 	 * when rendering the level bar fill.
317 	 * If another offset marker named name exists, its value will be
318 	 * replaced by value.
319 	 * Params:
320 	 * name = the name of the new offset
321 	 * value = the value for the new offset
322 	 * Since 3.6
323 	 */
324 	public void addOffsetValue(string name, double value)
325 	{
326 		// void gtk_level_bar_add_offset_value (GtkLevelBar *self,  const gchar *name,  gdouble value);
327 		gtk_level_bar_add_offset_value(gtkLevelBar, Str.toStringz(name), value);
328 	}
329 	
330 	/**
331 	 * Removes an offset marker previously added with
332 	 * gtk_level_bar_add_offset_value().
333 	 * Params:
334 	 * name = the name of an offset in the bar. [allow-none]
335 	 * Since 3.6
336 	 */
337 	public void removeOffsetValue(string name)
338 	{
339 		// void gtk_level_bar_remove_offset_value (GtkLevelBar *self,  const gchar *name);
340 		gtk_level_bar_remove_offset_value(gtkLevelBar, Str.toStringz(name));
341 	}
342 	
343 	/**
344 	 * Fetches the value specified for the offset marker name in self,
345 	 * returning TRUE in case an offset named name was found.
346 	 * Params:
347 	 * name = the name of an offset in the bar. [allow-none]
348 	 * value = location where to store the value. [out]
349 	 * Returns: TRUE if the specified offset is found Since 3.6
350 	 */
351 	public int getOffsetValue(string name, out double value)
352 	{
353 		// gboolean gtk_level_bar_get_offset_value (GtkLevelBar *self,  const gchar *name,  gdouble *value);
354 		return gtk_level_bar_get_offset_value(gtkLevelBar, Str.toStringz(name), &value);
355 	}
356 }