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