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