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 private import std.algorithm;
39 
40 
41 /**
42  * `GtkScaleButton` provides a button which pops up a scale widget.
43  * 
44  * This kind of widget is commonly used for volume controls in multimedia
45  * applications, and GTK provides a [class@Gtk.VolumeButton] 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 : Widget, 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(GtkWidget*)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`.
93 	 *
94 	 * The new scale button has a range between @min and @max,
95 	 * with a stepping of @step.
96 	 *
97 	 * Params:
98 	 *     min = the minimum value of the scale (usually 0)
99 	 *     max = the maximum value of the scale (usually 100)
100 	 *     step = the stepping of value when a scroll-wheel event,
101 	 *         or up/down arrow event occurs (usually 2)
102 	 *     icons = a %NULL-terminated
103 	 *         array of icon names, or %NULL if you want to set the list
104 	 *         later with gtk_scale_button_set_icons()
105 	 *
106 	 * Returns: a new `GtkScaleButton`
107 	 *
108 	 * Throws: ConstructionException GTK+ fails to create the object.
109 	 */
110 	public this(double min, double max, double step, string[] icons)
111 	{
112 		auto __p = gtk_scale_button_new(min, max, step, Str.toStringzArray(icons));
113 
114 		if(__p is null)
115 		{
116 			throw new ConstructionException("null returned by new");
117 		}
118 
119 		this(cast(GtkScaleButton*) __p);
120 	}
121 
122 	/**
123 	 * Gets the `GtkAdjustment` associated with the `GtkScaleButton`’s scale.
124 	 *
125 	 * See [method@Gtk.Range.get_adjustment] for details.
126 	 *
127 	 * Returns: the adjustment associated with the scale
128 	 */
129 	public Adjustment getAdjustment()
130 	{
131 		auto __p = gtk_scale_button_get_adjustment(gtkScaleButton);
132 
133 		if(__p is null)
134 		{
135 			return null;
136 		}
137 
138 		return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) __p);
139 	}
140 
141 	/**
142 	 * Retrieves the minus button of the `GtkScaleButton`.
143 	 *
144 	 * Returns: the minus button
145 	 *     of the `GtkScaleButton`
146 	 */
147 	public Button getMinusButton()
148 	{
149 		auto __p = gtk_scale_button_get_minus_button(gtkScaleButton);
150 
151 		if(__p is null)
152 		{
153 			return null;
154 		}
155 
156 		return ObjectG.getDObject!(Button)(cast(GtkButton*) __p);
157 	}
158 
159 	/**
160 	 * Retrieves the plus button of the `GtkScaleButton.`
161 	 *
162 	 * Returns: the plus button
163 	 *     of the `GtkScaleButton`
164 	 */
165 	public Button getPlusButton()
166 	{
167 		auto __p = gtk_scale_button_get_plus_button(gtkScaleButton);
168 
169 		if(__p is null)
170 		{
171 			return null;
172 		}
173 
174 		return ObjectG.getDObject!(Button)(cast(GtkButton*) __p);
175 	}
176 
177 	/**
178 	 * Retrieves the popup of the `GtkScaleButton`.
179 	 *
180 	 * Returns: the popup of the `GtkScaleButton`
181 	 */
182 	public Widget getPopup()
183 	{
184 		auto __p = gtk_scale_button_get_popup(gtkScaleButton);
185 
186 		if(__p is null)
187 		{
188 			return null;
189 		}
190 
191 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p);
192 	}
193 
194 	/**
195 	 * Gets the current value of the scale button.
196 	 *
197 	 * Returns: current value of the scale button
198 	 */
199 	public double getValue()
200 	{
201 		return gtk_scale_button_get_value(gtkScaleButton);
202 	}
203 
204 	/**
205 	 * Sets the `GtkAdjustment` to be used as a model
206 	 * for the `GtkScaleButton`’s scale.
207 	 *
208 	 * See [method@Gtk.Range.set_adjustment] for details.
209 	 *
210 	 * Params:
211 	 *     adjustment = a `GtkAdjustment`
212 	 */
213 	public void setAdjustment(Adjustment adjustment)
214 	{
215 		gtk_scale_button_set_adjustment(gtkScaleButton, (adjustment is null) ? null : adjustment.getAdjustmentStruct());
216 	}
217 
218 	/**
219 	 * Sets the icons to be used by the scale button.
220 	 *
221 	 * Params:
222 	 *     icons = a %NULL-terminated array of icon names
223 	 */
224 	public void setIcons(string[] icons)
225 	{
226 		gtk_scale_button_set_icons(gtkScaleButton, Str.toStringzArray(icons));
227 	}
228 
229 	/**
230 	 * Sets the current value of the scale.
231 	 *
232 	 * If the value is outside the minimum or maximum range values,
233 	 * it will be clamped to fit inside them.
234 	 *
235 	 * The scale button emits the [signal@Gtk.ScaleButton::value-changed]
236 	 * signal if the value changes.
237 	 *
238 	 * Params:
239 	 *     value = new value of the scale button
240 	 */
241 	public void setValue(double value)
242 	{
243 		gtk_scale_button_set_value(gtkScaleButton, value);
244 	}
245 
246 	/**
247 	 * Emitted to dismiss the popup.
248 	 *
249 	 * This is a [keybinding signal](class.SignalAction.html).
250 	 *
251 	 * The default binding for this signal is <kbd>Escape</kbd>.
252 	 */
253 	gulong addOnPopdown(void delegate(ScaleButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
254 	{
255 		return Signals.connect(this, "popdown", dlg, connectFlags ^ ConnectFlags.SWAPPED);
256 	}
257 
258 	/**
259 	 * Emitted to popup the scale widget.
260 	 *
261 	 * This is a [keybinding signal](class.SignalAction.html).
262 	 *
263 	 * The default bindings for this signal are <kbd>Space</kbd>,
264 	 * <kbd>Enter</kbd> and <kbd>Return</kbd>.
265 	 */
266 	gulong addOnPopup(void delegate(ScaleButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
267 	{
268 		return Signals.connect(this, "popup", dlg, connectFlags ^ ConnectFlags.SWAPPED);
269 	}
270 
271 	/**
272 	 * Emitted when the value field has changed.
273 	 *
274 	 * Params:
275 	 *     value = the new value
276 	 */
277 	gulong addOnValueChanged(void delegate(double, ScaleButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
278 	{
279 		return Signals.connect(this, "value-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED);
280 	}
281 }