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 public import gtkc.gdktypes; 37 private import gtkc.gtk; 38 public import gtkc.gtktypes; 39 40 41 /** 42 * #GtkScaleButton provides a button which pops up a scale widget. 43 * This kind of widget is commonly used for volume controls in multimedia 44 * applications, and GTK+ provides a #GtkVolumeButton subclass that 45 * is tailored for this use case. 46 */ 47 public class ScaleButton : Button, OrientableIF 48 { 49 /** the main Gtk struct */ 50 protected GtkScaleButton* gtkScaleButton; 51 52 /** Get the main Gtk struct */ 53 public GtkScaleButton* getScaleButtonStruct() 54 { 55 return gtkScaleButton; 56 } 57 58 /** the main Gtk struct as a void* */ 59 protected override void* getStruct() 60 { 61 return cast(void*)gtkScaleButton; 62 } 63 64 protected override void setStruct(GObject* obj) 65 { 66 gtkScaleButton = cast(GtkScaleButton*)obj; 67 super.setStruct(obj); 68 } 69 70 /** 71 * Sets our main struct and passes it to the parent class. 72 */ 73 public this (GtkScaleButton* gtkScaleButton, bool ownedRef = false) 74 { 75 this.gtkScaleButton = gtkScaleButton; 76 super(cast(GtkButton*)gtkScaleButton, ownedRef); 77 } 78 79 // add the Orientable capabilities 80 mixin OrientableT!(GtkScaleButton); 81 82 83 /** */ 84 public static GType getType() 85 { 86 return gtk_scale_button_get_type(); 87 } 88 89 /** 90 * Creates a #GtkScaleButton, with a range between @min and @max, with 91 * a stepping of @step. 92 * 93 * Params: 94 * size = a stock icon size 95 * min = the minimum value of the scale (usually 0) 96 * max = the maximum value of the scale (usually 100) 97 * step = the stepping of value when a scroll-wheel event, 98 * or up/down arrow event occurs (usually 2) 99 * icons = a %NULL-terminated 100 * array of icon names, or %NULL if you want to set the list 101 * later with gtk_scale_button_set_icons() 102 * 103 * Return: a new #GtkScaleButton 104 * 105 * Since: 2.12 106 * 107 * Throws: ConstructionException GTK+ fails to create the object. 108 */ 109 public this(GtkIconSize size, double min, double max, double step, string[] icons) 110 { 111 auto p = gtk_scale_button_new(size, min, max, step, Str.toStringzArray(icons)); 112 113 if(p is null) 114 { 115 throw new ConstructionException("null returned by new"); 116 } 117 118 this(cast(GtkScaleButton*) p); 119 } 120 121 /** 122 * Gets the #GtkAdjustment associated with the #GtkScaleButton’s scale. 123 * See gtk_range_get_adjustment() for details. 124 * 125 * Return: the adjustment associated with the scale 126 * 127 * Since: 2.12 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 * Return: the minus button of the #GtkScaleButton as a #GtkButton 145 * 146 * Since: 2.14 147 */ 148 public Button getMinusButton() 149 { 150 auto p = gtk_scale_button_get_minus_button(gtkScaleButton); 151 152 if(p is null) 153 { 154 return null; 155 } 156 157 return ObjectG.getDObject!(Button)(cast(GtkButton*) p); 158 } 159 160 /** 161 * Retrieves the plus button of the #GtkScaleButton. 162 * 163 * Return: the plus button of the #GtkScaleButton as a #GtkButton 164 * 165 * Since: 2.14 166 */ 167 public Button getPlusButton() 168 { 169 auto p = gtk_scale_button_get_plus_button(gtkScaleButton); 170 171 if(p is null) 172 { 173 return null; 174 } 175 176 return ObjectG.getDObject!(Button)(cast(GtkButton*) p); 177 } 178 179 /** 180 * Retrieves the popup of the #GtkScaleButton. 181 * 182 * Return: the popup of the #GtkScaleButton 183 * 184 * Since: 2.14 185 */ 186 public Widget getPopup() 187 { 188 auto p = gtk_scale_button_get_popup(gtkScaleButton); 189 190 if(p is null) 191 { 192 return null; 193 } 194 195 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 196 } 197 198 /** 199 * Gets the current value of the scale button. 200 * 201 * Return: current value of the scale button 202 * 203 * Since: 2.12 204 */ 205 public double getValue() 206 { 207 return gtk_scale_button_get_value(gtkScaleButton); 208 } 209 210 /** 211 * Sets the #GtkAdjustment to be used as a model 212 * for the #GtkScaleButton’s scale. 213 * See gtk_range_set_adjustment() for details. 214 * 215 * Params: 216 * adjustment = a #GtkAdjustment 217 * 218 * Since: 2.12 219 */ 220 public void setAdjustment(Adjustment adjustment) 221 { 222 gtk_scale_button_set_adjustment(gtkScaleButton, (adjustment is null) ? null : adjustment.getAdjustmentStruct()); 223 } 224 225 /** 226 * Sets the icons to be used by the scale button. 227 * For details, see the #GtkScaleButton:icons property. 228 * 229 * Params: 230 * icons = a %NULL-terminated array of icon names 231 * 232 * Since: 2.12 233 */ 234 public void setIcons(string[] icons) 235 { 236 gtk_scale_button_set_icons(gtkScaleButton, Str.toStringzArray(icons)); 237 } 238 239 /** 240 * Sets the current value of the scale; if the value is outside 241 * the minimum or maximum range values, it will be clamped to fit 242 * inside them. The scale button emits the #GtkScaleButton::value-changed 243 * signal if the value changes. 244 * 245 * Params: 246 * value = new value of the scale button 247 * 248 * Since: 2.12 249 */ 250 public void setValue(double value) 251 { 252 gtk_scale_button_set_value(gtkScaleButton, value); 253 } 254 255 int[string] connectedSignals; 256 257 void delegate(ScaleButton)[] onPopdownListeners; 258 /** 259 * The ::popdown signal is a 260 * [keybinding signal][GtkBindingSignal] 261 * which gets emitted to popdown the scale widget. 262 * 263 * The default binding for this signal is Escape. 264 * 265 * Since: 2.12 266 */ 267 void addOnPopdown(void delegate(ScaleButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 268 { 269 if ( "popdown" !in connectedSignals ) 270 { 271 Signals.connectData( 272 this, 273 "popdown", 274 cast(GCallback)&callBackPopdown, 275 cast(void*)this, 276 null, 277 connectFlags); 278 connectedSignals["popdown"] = 1; 279 } 280 onPopdownListeners ~= dlg; 281 } 282 extern(C) static void callBackPopdown(GtkScaleButton* scalebuttonStruct, ScaleButton _scalebutton) 283 { 284 foreach ( void delegate(ScaleButton) dlg; _scalebutton.onPopdownListeners ) 285 { 286 dlg(_scalebutton); 287 } 288 } 289 290 void delegate(ScaleButton)[] onPopupListeners; 291 /** 292 * The ::popup signal is a 293 * [keybinding signal][GtkBindingSignal] 294 * which gets emitted to popup the scale widget. 295 * 296 * The default bindings for this signal are Space, Enter and Return. 297 * 298 * Since: 2.12 299 */ 300 void addOnPopup(void delegate(ScaleButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 301 { 302 if ( "popup" !in connectedSignals ) 303 { 304 Signals.connectData( 305 this, 306 "popup", 307 cast(GCallback)&callBackPopup, 308 cast(void*)this, 309 null, 310 connectFlags); 311 connectedSignals["popup"] = 1; 312 } 313 onPopupListeners ~= dlg; 314 } 315 extern(C) static void callBackPopup(GtkScaleButton* scalebuttonStruct, ScaleButton _scalebutton) 316 { 317 foreach ( void delegate(ScaleButton) dlg; _scalebutton.onPopupListeners ) 318 { 319 dlg(_scalebutton); 320 } 321 } 322 323 void delegate(double, ScaleButton)[] onValueChangedListeners; 324 /** 325 * The ::value-changed signal is emitted when the value field has 326 * changed. 327 * 328 * Params: 329 * value = the new value 330 * 331 * Since: 2.12 332 */ 333 void addOnValueChanged(void delegate(double, ScaleButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 334 { 335 if ( "value-changed" !in connectedSignals ) 336 { 337 Signals.connectData( 338 this, 339 "value-changed", 340 cast(GCallback)&callBackValueChanged, 341 cast(void*)this, 342 null, 343 connectFlags); 344 connectedSignals["value-changed"] = 1; 345 } 346 onValueChangedListeners ~= dlg; 347 } 348 extern(C) static void callBackValueChanged(GtkScaleButton* scalebuttonStruct, double value, ScaleButton _scalebutton) 349 { 350 foreach ( void delegate(double, ScaleButton) dlg; _scalebutton.onValueChangedListeners ) 351 { 352 dlg(value, _scalebutton); 353 } 354 } 355 }