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