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