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  = GtkAdjustment.html
27  * outPack = gtk
28  * outFile = Adjustment
29  * strct   = GtkAdjustment
30  * realStrct=
31  * ctorStrct=
32  * clss    = Adjustment
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_adjustment_
41  * 	- gtk_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- gtk.ObjectGtk
48  * structWrap:
49  * 	- GtkObject* -> ObjectGtk
50  * module aliases:
51  * local aliases:
52  * overrides:
53  */
54 
55 module gtk.Adjustment;
56 
57 public  import gtkc.gtktypes;
58 
59 private import gtkc.gtk;
60 private import glib.ConstructionException;
61 private import gobject.ObjectG;
62 
63 private import gobject.Signals;
64 public  import gtkc.gdktypes;
65 
66 private import gtk.ObjectGtk;
67 
68 
69 
70 private import gtk.ObjectGtk;
71 
72 /**
73  * Description
74  * The GtkAdjustment object represents a value which has an associated lower
75  * and upper bound, together with step and page increments, and a page size.
76  * It is used within several GTK+ widgets, including
77  * GtkSpinButton, GtkViewport, and GtkRange (which is a base class for
78  * GtkHScrollbar, GtkVScrollbar, GtkHScale, and GtkVScale).
79  * The GtkAdjustment object does not update the value itself. Instead
80  * it is left up to the owner of the GtkAdjustment to control the value.
81  * The owner of the GtkAdjustment typically calls the
82  * gtk_adjustment_value_changed() and gtk_adjustment_changed() functions
83  * after changing the value and its bounds. This results in the emission of the
84  * "value_changed" or "changed" signal respectively.
85  */
86 public class Adjustment : ObjectGtk
87 {
88 	
89 	/** the main Gtk struct */
90 	protected GtkAdjustment* gtkAdjustment;
91 	
92 	
93 	public GtkAdjustment* getAdjustmentStruct()
94 	{
95 		return gtkAdjustment;
96 	}
97 	
98 	
99 	/** the main Gtk struct as a void* */
100 	protected override void* getStruct()
101 	{
102 		return cast(void*)gtkAdjustment;
103 	}
104 	
105 	/**
106 	 * Sets our main struct and passes it to the parent class
107 	 */
108 	public this (GtkAdjustment* gtkAdjustment)
109 	{
110 		super(cast(GtkObject*)gtkAdjustment);
111 		this.gtkAdjustment = gtkAdjustment;
112 	}
113 	
114 	protected override void setStruct(GObject* obj)
115 	{
116 		super.setStruct(obj);
117 		gtkAdjustment = cast(GtkAdjustment*)obj;
118 	}
119 	
120 	/**
121 	 */
122 	int[string] connectedSignals;
123 	
124 	void delegate(Adjustment)[] onChangedListeners;
125 	/**
126 	 * Emitted when one or more of the GtkAdjustment fields have been changed,
127 	 * other than the value field.
128 	 */
129 	void addOnChanged(void delegate(Adjustment) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
130 	{
131 		if ( !("changed" in connectedSignals) )
132 		{
133 			Signals.connectData(
134 			getStruct(),
135 			"changed",
136 			cast(GCallback)&callBackChanged,
137 			cast(void*)this,
138 			null,
139 			connectFlags);
140 			connectedSignals["changed"] = 1;
141 		}
142 		onChangedListeners ~= dlg;
143 	}
144 	extern(C) static void callBackChanged(GtkAdjustment* adjustmentStruct, Adjustment _adjustment)
145 	{
146 		foreach ( void delegate(Adjustment) dlg ; _adjustment.onChangedListeners )
147 		{
148 			dlg(_adjustment);
149 		}
150 	}
151 	
152 	void delegate(Adjustment)[] onValueChangedListeners;
153 	/**
154 	 * Emitted when the GtkAdjustment value field has been changed.
155 	 */
156 	void addOnValueChanged(void delegate(Adjustment) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
157 	{
158 		if ( !("value-changed" in connectedSignals) )
159 		{
160 			Signals.connectData(
161 			getStruct(),
162 			"value-changed",
163 			cast(GCallback)&callBackValueChanged,
164 			cast(void*)this,
165 			null,
166 			connectFlags);
167 			connectedSignals["value-changed"] = 1;
168 		}
169 		onValueChangedListeners ~= dlg;
170 	}
171 	extern(C) static void callBackValueChanged(GtkAdjustment* adjustmentStruct, Adjustment _adjustment)
172 	{
173 		foreach ( void delegate(Adjustment) dlg ; _adjustment.onValueChangedListeners )
174 		{
175 			dlg(_adjustment);
176 		}
177 	}
178 	
179 	
180 	/**
181 	 * Creates a new GtkAdjustment.
182 	 * Params:
183 	 * value = the initial value.
184 	 * lower = the minimum value.
185 	 * upper = the maximum value.
186 	 * stepIncrement = the step increment.
187 	 * pageIncrement = the page increment.
188 	 * pageSize = the page size.
189 	 * Throws: ConstructionException GTK+ fails to create the object.
190 	 */
191 	public this (double value, double lower, double upper, double stepIncrement, double pageIncrement, double pageSize)
192 	{
193 		// GtkObject * gtk_adjustment_new (gdouble value,  gdouble lower,  gdouble upper,  gdouble step_increment,  gdouble page_increment,  gdouble page_size);
194 		auto p = gtk_adjustment_new(value, lower, upper, stepIncrement, pageIncrement, pageSize);
195 		if(p is null)
196 		{
197 			throw new ConstructionException("null returned by gtk_adjustment_new(value, lower, upper, stepIncrement, pageIncrement, pageSize)");
198 		}
199 		this(cast(GtkAdjustment*) p);
200 	}
201 	
202 	/**
203 	 * Gets the current value of the adjustment. See
204 	 * gtk_adjustment_set_value().
205 	 * Returns: The current value of the adjustment.
206 	 */
207 	public double getValue()
208 	{
209 		// gdouble gtk_adjustment_get_value (GtkAdjustment *adjustment);
210 		return gtk_adjustment_get_value(gtkAdjustment);
211 	}
212 	
213 	/**
214 	 * Sets the GtkAdjustment value. The value is clamped to lie between
215 	 * adjustment->lower and
216 	 * adjustment->upper.
217 	 * Note that for adjustments which are used in a GtkScrollbar, the effective
218 	 * range of allowed values goes from adjustment->lower to
219 	 * adjustment->upper - adjustment->page_size.
220 	 * Params:
221 	 * value = the new value.
222 	 */
223 	public void setValue(double value)
224 	{
225 		// void gtk_adjustment_set_value (GtkAdjustment *adjustment,  gdouble value);
226 		gtk_adjustment_set_value(gtkAdjustment, value);
227 	}
228 	
229 	/**
230 	 * Updates the GtkAdjustment value to ensure that the range between lower
231 	 * and upper is in the current page (i.e. between value and value +
232 	 * page_size).
233 	 * If the range is larger than the page size, then only the start of it will
234 	 * be in the current page.
235 	 * A "changed" signal will be emitted if the value is changed.
236 	 * Params:
237 	 * lower = the lower value.
238 	 * upper = the upper value.
239 	 */
240 	public void clampPage(double lower, double upper)
241 	{
242 		// void gtk_adjustment_clamp_page (GtkAdjustment *adjustment,  gdouble lower,  gdouble upper);
243 		gtk_adjustment_clamp_page(gtkAdjustment, lower, upper);
244 	}
245 	
246 	/**
247 	 * Emits a "changed" signal from the GtkAdjustment.
248 	 * This is typically called by the owner of the GtkAdjustment after it has
249 	 * changed any of the GtkAdjustment fields other than the value.
250 	 */
251 	public void changed()
252 	{
253 		// void gtk_adjustment_changed (GtkAdjustment *adjustment);
254 		gtk_adjustment_changed(gtkAdjustment);
255 	}
256 	
257 	/**
258 	 * Emits a "value_changed" signal from the GtkAdjustment.
259 	 * This is typically called by the owner of the GtkAdjustment after it has
260 	 * changed the GtkAdjustment value field.
261 	 */
262 	public void valueChanged()
263 	{
264 		// void gtk_adjustment_value_changed (GtkAdjustment *adjustment);
265 		gtk_adjustment_value_changed(gtkAdjustment);
266 	}
267 	
268 	/**
269 	 * Sets all properties of the adjustment at once.
270 	 * Use this function to avoid multiple emissions of the "changed"
271 	 * signal. See gtk_adjustment_set_lower() for an alternative way
272 	 * of compressing multiple emissions of "changed" into one.
273 	 * Since 2.14
274 	 * Params:
275 	 * value = the new value
276 	 * lower = the new minimum value
277 	 * upper = the new maximum value
278 	 * stepIncrement = the new step increment
279 	 * pageIncrement = the new page increment
280 	 * pageSize = the new page size
281 	 */
282 	public void configure(double value, double lower, double upper, double stepIncrement, double pageIncrement, double pageSize)
283 	{
284 		// void gtk_adjustment_configure (GtkAdjustment *adjustment,  gdouble value,  gdouble lower,  gdouble upper,  gdouble step_increment,  gdouble page_increment,  gdouble page_size);
285 		gtk_adjustment_configure(gtkAdjustment, value, lower, upper, stepIncrement, pageIncrement, pageSize);
286 	}
287 	
288 	/**
289 	 * Retrieves the minimum value of the adjustment.
290 	 * Since 2.14
291 	 * Returns: The current minimum value of the adjustment.
292 	 */
293 	public double getLower()
294 	{
295 		// gdouble gtk_adjustment_get_lower (GtkAdjustment *adjustment);
296 		return gtk_adjustment_get_lower(gtkAdjustment);
297 	}
298 	
299 	/**
300 	 * Retrieves the page increment of the adjustment.
301 	 * Since 2.14
302 	 * Returns: The current page increment of the adjustment.
303 	 */
304 	public double getPageIncrement()
305 	{
306 		// gdouble gtk_adjustment_get_page_increment (GtkAdjustment *adjustment);
307 		return gtk_adjustment_get_page_increment(gtkAdjustment);
308 	}
309 	
310 	/**
311 	 * Retrieves the page size of the adjustment.
312 	 * Since 2.14
313 	 * Returns: The current page size of the adjustment.
314 	 */
315 	public double getPageSize()
316 	{
317 		// gdouble gtk_adjustment_get_page_size (GtkAdjustment *adjustment);
318 		return gtk_adjustment_get_page_size(gtkAdjustment);
319 	}
320 	
321 	/**
322 	 * Retrieves the step increment of the adjustment.
323 	 * Since 2.14
324 	 * Returns: The current step increment of the adjustment.
325 	 */
326 	public double getStepIncrement()
327 	{
328 		// gdouble gtk_adjustment_get_step_increment (GtkAdjustment *adjustment);
329 		return gtk_adjustment_get_step_increment(gtkAdjustment);
330 	}
331 	
332 	/**
333 	 * Retrieves the maximum value of the adjustment.
334 	 * Since 2.14
335 	 * Returns: The current maximum value of the adjustment.
336 	 */
337 	public double getUpper()
338 	{
339 		// gdouble gtk_adjustment_get_upper (GtkAdjustment *adjustment);
340 		return gtk_adjustment_get_upper(gtkAdjustment);
341 	}
342 	
343 	/**
344 	 * Sets the minimum value of the adjustment.
345 	 * When setting multiple adjustment properties via their individual
346 	 * setters, multiple "changed" signals will be emitted. However, since
347 	 * the emission of the "changed" signal is tied to the emission of the
348 	 * "GObject::notify" signals of the changed properties, it's possible
349 	 * to compress the "changed" signals into one by calling
350 	 * g_object_freeze_notify() and g_object_thaw_notify() around the
351 	 * calls to the individual setters.
352 	 * Alternatively, using a single g_object_set() for all the properties
353 	 * to change, or using gtk_adjustment_configure() has the same effect
354 	 * of compressing "changed" emissions.
355 	 * Since 2.14
356 	 * Params:
357 	 * lower = the new minimum value
358 	 */
359 	public void setLower(double lower)
360 	{
361 		// void gtk_adjustment_set_lower (GtkAdjustment *adjustment,  gdouble lower);
362 		gtk_adjustment_set_lower(gtkAdjustment, lower);
363 	}
364 	
365 	/**
366 	 * Sets the page increment of the adjustment.
367 	 * See gtk_adjustment_set_lower() about how to compress multiple
368 	 * emissions of the "changed" signal when setting multiple adjustment
369 	 * properties.
370 	 * Since 2.14
371 	 * Params:
372 	 * pageIncrement = the new page increment
373 	 */
374 	public void setPageIncrement(double pageIncrement)
375 	{
376 		// void gtk_adjustment_set_page_increment (GtkAdjustment *adjustment,  gdouble page_increment);
377 		gtk_adjustment_set_page_increment(gtkAdjustment, pageIncrement);
378 	}
379 	
380 	/**
381 	 * Sets the page size of the adjustment.
382 	 * See gtk_adjustment_set_lower() about how to compress multiple
383 	 * emissions of the "changed" signal when setting multiple adjustment
384 	 * properties.
385 	 * Since 2.14
386 	 * Params:
387 	 * pageSize = the new page size
388 	 */
389 	public void setPageSize(double pageSize)
390 	{
391 		// void gtk_adjustment_set_page_size (GtkAdjustment *adjustment,  gdouble page_size);
392 		gtk_adjustment_set_page_size(gtkAdjustment, pageSize);
393 	}
394 	
395 	/**
396 	 * Sets the step increment of the adjustment.
397 	 * See gtk_adjustment_set_lower() about how to compress multiple
398 	 * emissions of the "changed" signal when setting multiple adjustment
399 	 * properties.
400 	 * Since 2.14
401 	 * Params:
402 	 * stepIncrement = the new step increment
403 	 */
404 	public void setStepIncrement(double stepIncrement)
405 	{
406 		// void gtk_adjustment_set_step_increment (GtkAdjustment *adjustment,  gdouble step_increment);
407 		gtk_adjustment_set_step_increment(gtkAdjustment, stepIncrement);
408 	}
409 	
410 	/**
411 	 * Sets the maximum value of the adjustment.
412 	 * Note that values will be restricted by
413 	 * upper - page-size if the page-size
414 	 * property is nonzero.
415 	 * See gtk_adjustment_set_lower() about how to compress multiple
416 	 * emissions of the "changed" signal when setting multiple adjustment
417 	 * properties.
418 	 * Since 2.14
419 	 * Params:
420 	 * upper = the new maximum value
421 	 */
422 	public void setUpper(double upper)
423 	{
424 		// void gtk_adjustment_set_upper (GtkAdjustment *adjustment,  gdouble upper);
425 		gtk_adjustment_set_upper(gtkAdjustment, upper);
426 	}
427 }