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