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.ScaleButton;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gobject.Signals;
31 private import gtk.Adjustment;
32 private import gtk.Button;
33 private import gtk.OrientableIF;
34 private import gtk.OrientableT;
35 private import gtk.Widget;
36 private import gtk.c.functions;
37 public  import gtk.c.types;
38 public  import gtkc.gtktypes;
39 private import std.algorithm;
40 
41 
42 /**
43  * #GtkScaleButton provides a button which pops up a scale widget.
44  * This kind of widget is commonly used for volume controls in multimedia
45  * applications, and GTK+ provides a #GtkVolumeButton subclass that
46  * is tailored for this use case.
47  * 
48  * # CSS nodes
49  * 
50  * GtkScaleButton has a single CSS node with name button. To differentiate
51  * it from a plain #GtkButton, it gets the .scale style class.
52  */
53 public class ScaleButton : Button, OrientableIF
54 {
55 	/** the main Gtk struct */
56 	protected GtkScaleButton* gtkScaleButton;
57 
58 	/** Get the main Gtk struct */
59 	public GtkScaleButton* getScaleButtonStruct(bool transferOwnership = false)
60 	{
61 		if (transferOwnership)
62 			ownedRef = false;
63 		return gtkScaleButton;
64 	}
65 
66 	/** the main Gtk struct as a void* */
67 	protected override void* getStruct()
68 	{
69 		return cast(void*)gtkScaleButton;
70 	}
71 
72 	/**
73 	 * Sets our main struct and passes it to the parent class.
74 	 */
75 	public this (GtkScaleButton* gtkScaleButton, bool ownedRef = false)
76 	{
77 		this.gtkScaleButton = gtkScaleButton;
78 		super(cast(GtkButton*)gtkScaleButton, ownedRef);
79 	}
80 
81 	// add the Orientable capabilities
82 	mixin OrientableT!(GtkScaleButton);
83 
84 
85 	/** */
86 	public static GType getType()
87 	{
88 		return gtk_scale_button_get_type();
89 	}
90 
91 	/**
92 	 * Creates a #GtkScaleButton, with a range between @min and @max, with
93 	 * a stepping of @step.
94 	 *
95 	 * Params:
96 	 *     size = a stock icon size (#GtkIconSize)
97 	 *     min = the minimum value of the scale (usually 0)
98 	 *     max = the maximum value of the scale (usually 100)
99 	 *     step = the stepping of value when a scroll-wheel event,
100 	 *         or up/down arrow event occurs (usually 2)
101 	 *     icons = a %NULL-terminated
102 	 *         array of icon names, or %NULL if you want to set the list
103 	 *         later with gtk_scale_button_set_icons()
104 	 *
105 	 * Returns: a new #GtkScaleButton
106 	 *
107 	 * Since: 2.12
108 	 *
109 	 * Throws: ConstructionException GTK+ fails to create the object.
110 	 */
111 	public this(GtkIconSize size, double min, double max, double step, string[] icons)
112 	{
113 		auto p = gtk_scale_button_new(size, min, max, step, Str.toStringzArray(icons));
114 
115 		if(p is null)
116 		{
117 			throw new ConstructionException("null returned by new");
118 		}
119 
120 		this(cast(GtkScaleButton*) p);
121 	}
122 
123 	/**
124 	 * Gets the #GtkAdjustment associated with the #GtkScaleButton’s scale.
125 	 * See gtk_range_get_adjustment() for details.
126 	 *
127 	 * Returns: the adjustment associated with the scale
128 	 *
129 	 * Since: 2.12
130 	 */
131 	public Adjustment getAdjustment()
132 	{
133 		auto p = gtk_scale_button_get_adjustment(gtkScaleButton);
134 
135 		if(p is null)
136 		{
137 			return null;
138 		}
139 
140 		return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p);
141 	}
142 
143 	/**
144 	 * Retrieves the minus button of the #GtkScaleButton.
145 	 *
146 	 * Returns: the minus button of the #GtkScaleButton as a #GtkButton
147 	 *
148 	 * Since: 2.14
149 	 */
150 	public Button getMinusButton()
151 	{
152 		auto p = gtk_scale_button_get_minus_button(gtkScaleButton);
153 
154 		if(p is null)
155 		{
156 			return null;
157 		}
158 
159 		return ObjectG.getDObject!(Button)(cast(GtkButton*) p);
160 	}
161 
162 	/**
163 	 * Retrieves the plus button of the #GtkScaleButton.
164 	 *
165 	 * Returns: the plus button of the #GtkScaleButton as a #GtkButton
166 	 *
167 	 * Since: 2.14
168 	 */
169 	public Button getPlusButton()
170 	{
171 		auto p = gtk_scale_button_get_plus_button(gtkScaleButton);
172 
173 		if(p is null)
174 		{
175 			return null;
176 		}
177 
178 		return ObjectG.getDObject!(Button)(cast(GtkButton*) p);
179 	}
180 
181 	/**
182 	 * Retrieves the popup of the #GtkScaleButton.
183 	 *
184 	 * Returns: the popup of the #GtkScaleButton
185 	 *
186 	 * Since: 2.14
187 	 */
188 	public Widget getPopup()
189 	{
190 		auto p = gtk_scale_button_get_popup(gtkScaleButton);
191 
192 		if(p is null)
193 		{
194 			return null;
195 		}
196 
197 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
198 	}
199 
200 	/**
201 	 * Gets the current value of the scale button.
202 	 *
203 	 * Returns: current value of the scale button
204 	 *
205 	 * Since: 2.12
206 	 */
207 	public double getValue()
208 	{
209 		return gtk_scale_button_get_value(gtkScaleButton);
210 	}
211 
212 	/**
213 	 * Sets the #GtkAdjustment to be used as a model
214 	 * for the #GtkScaleButton’s scale.
215 	 * See gtk_range_set_adjustment() for details.
216 	 *
217 	 * Params:
218 	 *     adjustment = a #GtkAdjustment
219 	 *
220 	 * Since: 2.12
221 	 */
222 	public void setAdjustment(Adjustment adjustment)
223 	{
224 		gtk_scale_button_set_adjustment(gtkScaleButton, (adjustment is null) ? null : adjustment.getAdjustmentStruct());
225 	}
226 
227 	/**
228 	 * Sets the icons to be used by the scale button.
229 	 * For details, see the #GtkScaleButton:icons property.
230 	 *
231 	 * Params:
232 	 *     icons = a %NULL-terminated array of icon names
233 	 *
234 	 * Since: 2.12
235 	 */
236 	public void setIcons(string[] icons)
237 	{
238 		gtk_scale_button_set_icons(gtkScaleButton, Str.toStringzArray(icons));
239 	}
240 
241 	/**
242 	 * Sets the current value of the scale; if the value is outside
243 	 * the minimum or maximum range values, it will be clamped to fit
244 	 * inside them. The scale button emits the #GtkScaleButton::value-changed
245 	 * signal if the value changes.
246 	 *
247 	 * Params:
248 	 *     value = new value of the scale button
249 	 *
250 	 * Since: 2.12
251 	 */
252 	public void setValue(double value)
253 	{
254 		gtk_scale_button_set_value(gtkScaleButton, value);
255 	}
256 
257 	/**
258 	 * The ::popdown signal is a
259 	 * [keybinding signal][GtkBindingSignal]
260 	 * which gets emitted to popdown the scale widget.
261 	 *
262 	 * The default binding for this signal is Escape.
263 	 *
264 	 * Since: 2.12
265 	 */
266 	gulong addOnPopdown(void delegate(ScaleButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
267 	{
268 		return Signals.connect(this, "popdown", dlg, connectFlags ^ ConnectFlags.SWAPPED);
269 	}
270 
271 	/**
272 	 * The ::popup signal is a
273 	 * [keybinding signal][GtkBindingSignal]
274 	 * which gets emitted to popup the scale widget.
275 	 *
276 	 * The default bindings for this signal are Space, Enter and Return.
277 	 *
278 	 * Since: 2.12
279 	 */
280 	gulong addOnPopup(void delegate(ScaleButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
281 	{
282 		return Signals.connect(this, "popup", dlg, connectFlags ^ ConnectFlags.SWAPPED);
283 	}
284 
285 	/**
286 	 * The ::value-changed signal is emitted when the value field has
287 	 * changed.
288 	 *
289 	 * Params:
290 	 *     value = the new value
291 	 *
292 	 * Since: 2.12
293 	 */
294 	gulong addOnValueChanged(void delegate(double, ScaleButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
295 	{
296 		return Signals.connect(this, "value-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED);
297 	}
298 }