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.Adjustment; 26 27 private import glib.ConstructionException; 28 private import gobject.ObjectG; 29 private import gobject.Signals; 30 public import gtkc.gdktypes; 31 private import gtkc.gtk; 32 public import gtkc.gtktypes; 33 34 35 /** 36 * The #GtkAdjustment object represents a value which has an associated lower 37 * and upper bound, together with step and page increments, and a page size. 38 * It is used within several GTK+ widgets, including #GtkSpinButton, #GtkViewport, 39 * and #GtkRange (which is a base class for #GtkScrollbar and #GtkScale). 40 * 41 * The #GtkAdjustment object does not update the value itself. Instead 42 * it is left up to the owner of the #GtkAdjustment to control the value. 43 */ 44 public class Adjustment : ObjectG 45 { 46 /** the main Gtk struct */ 47 protected GtkAdjustment* gtkAdjustment; 48 49 /** Get the main Gtk struct */ 50 public GtkAdjustment* getAdjustmentStruct() 51 { 52 return gtkAdjustment; 53 } 54 55 /** the main Gtk struct as a void* */ 56 protected override void* getStruct() 57 { 58 return cast(void*)gtkAdjustment; 59 } 60 61 protected override void setStruct(GObject* obj) 62 { 63 gtkAdjustment = cast(GtkAdjustment*)obj; 64 super.setStruct(obj); 65 } 66 67 /** 68 * Sets our main struct and passes it to the parent class. 69 */ 70 public this (GtkAdjustment* gtkAdjustment, bool ownedRef = false) 71 { 72 this.gtkAdjustment = gtkAdjustment; 73 super(cast(GObject*)gtkAdjustment, ownedRef); 74 } 75 76 77 /** */ 78 public static GType getType() 79 { 80 return gtk_adjustment_get_type(); 81 } 82 83 /** 84 * Creates a new #GtkAdjustment. 85 * 86 * Params: 87 * value = the initial value 88 * lower = the minimum value 89 * upper = the maximum value 90 * stepIncrement = the step increment 91 * pageIncrement = the page increment 92 * pageSize = the page size 93 * 94 * Return: a new #GtkAdjustment 95 * 96 * Throws: ConstructionException GTK+ fails to create the object. 97 */ 98 public this(double value, double lower, double upper, double stepIncrement, double pageIncrement, double pageSize) 99 { 100 auto p = gtk_adjustment_new(value, lower, upper, stepIncrement, pageIncrement, pageSize); 101 102 if(p is null) 103 { 104 throw new ConstructionException("null returned by new"); 105 } 106 107 this(cast(GtkAdjustment*) p); 108 } 109 110 /** 111 * Emits a #GtkAdjustment::changed signal from the #GtkAdjustment. 112 * This is typically called by the owner of the #GtkAdjustment after it has 113 * changed any of the #GtkAdjustment properties other than the value. 114 * 115 * Deprecated: GTK+ emits #GtkAdjustment::changed itself whenever any 116 * of the properties (other than value) change 117 */ 118 public void changed() 119 { 120 gtk_adjustment_changed(gtkAdjustment); 121 } 122 123 /** 124 * Updates the #GtkAdjustment:value property to ensure that the range 125 * between @lower and @upper is in the current page (i.e. between 126 * #GtkAdjustment:value and #GtkAdjustment:value + #GtkAdjustment:page-size). 127 * If the range is larger than the page size, then only the start of it will 128 * be in the current page. 129 * 130 * A #GtkAdjustment::value-changed signal will be emitted if the value is changed. 131 * 132 * Params: 133 * lower = the lower value 134 * upper = the upper value 135 */ 136 public void clampPage(double lower, double upper) 137 { 138 gtk_adjustment_clamp_page(gtkAdjustment, lower, upper); 139 } 140 141 /** 142 * Sets all properties of the adjustment at once. 143 * 144 * Use this function to avoid multiple emissions of the 145 * #GtkAdjustment::changed signal. See gtk_adjustment_set_lower() 146 * for an alternative way of compressing multiple emissions of 147 * #GtkAdjustment::changed into one. 148 * 149 * Params: 150 * value = the new value 151 * lower = the new minimum value 152 * upper = the new maximum value 153 * stepIncrement = the new step increment 154 * pageIncrement = the new page increment 155 * pageSize = the new page size 156 * 157 * Since: 2.14 158 */ 159 public void configure(double value, double lower, double upper, double stepIncrement, double pageIncrement, double pageSize) 160 { 161 gtk_adjustment_configure(gtkAdjustment, value, lower, upper, stepIncrement, pageIncrement, pageSize); 162 } 163 164 /** 165 * Retrieves the minimum value of the adjustment. 166 * 167 * Return: The current minimum value of the adjustment 168 * 169 * Since: 2.14 170 */ 171 public double getLower() 172 { 173 return gtk_adjustment_get_lower(gtkAdjustment); 174 } 175 176 /** 177 * Gets the smaller of step increment and page increment. 178 * 179 * Return: the minimum increment of @adjustment 180 * 181 * Since: 3.2 182 */ 183 public double getMinimumIncrement() 184 { 185 return gtk_adjustment_get_minimum_increment(gtkAdjustment); 186 } 187 188 /** 189 * Retrieves the page increment of the adjustment. 190 * 191 * Return: The current page increment of the adjustment 192 * 193 * Since: 2.14 194 */ 195 public double getPageIncrement() 196 { 197 return gtk_adjustment_get_page_increment(gtkAdjustment); 198 } 199 200 /** 201 * Retrieves the page size of the adjustment. 202 * 203 * Return: The current page size of the adjustment 204 * 205 * Since: 2.14 206 */ 207 public double getPageSize() 208 { 209 return gtk_adjustment_get_page_size(gtkAdjustment); 210 } 211 212 /** 213 * Retrieves the step increment of the adjustment. 214 * 215 * Return: The current step increment of the adjustment. 216 * 217 * Since: 2.14 218 */ 219 public double getStepIncrement() 220 { 221 return gtk_adjustment_get_step_increment(gtkAdjustment); 222 } 223 224 /** 225 * Retrieves the maximum value of the adjustment. 226 * 227 * Return: The current maximum value of the adjustment 228 * 229 * Since: 2.14 230 */ 231 public double getUpper() 232 { 233 return gtk_adjustment_get_upper(gtkAdjustment); 234 } 235 236 /** 237 * Gets the current value of the adjustment. 238 * See gtk_adjustment_set_value(). 239 * 240 * Return: The current value of the adjustment 241 */ 242 public double getValue() 243 { 244 return gtk_adjustment_get_value(gtkAdjustment); 245 } 246 247 /** 248 * Sets the minimum value of the adjustment. 249 * 250 * When setting multiple adjustment properties via their individual 251 * setters, multiple #GtkAdjustment::changed signals will be emitted. 252 * However, since the emission of the #GtkAdjustment::changed signal 253 * is tied to the emission of the #GObject::notify signals of the changed 254 * properties, it’s possible to compress the #GtkAdjustment::changed 255 * signals into one by calling g_object_freeze_notify() and 256 * g_object_thaw_notify() around the calls to the individual setters. 257 * 258 * Alternatively, using a single g_object_set() for all the properties 259 * to change, or using gtk_adjustment_configure() has the same effect 260 * of compressing #GtkAdjustment::changed emissions. 261 * 262 * Params: 263 * lower = the new minimum value 264 * 265 * Since: 2.14 266 */ 267 public void setLower(double lower) 268 { 269 gtk_adjustment_set_lower(gtkAdjustment, lower); 270 } 271 272 /** 273 * Sets the page increment of the adjustment. 274 * 275 * See gtk_adjustment_set_lower() about how to compress multiple 276 * emissions of the #GtkAdjustment::changed signal when setting 277 * multiple adjustment properties. 278 * 279 * Params: 280 * pageIncrement = the new page increment 281 * 282 * Since: 2.14 283 */ 284 public void setPageIncrement(double pageIncrement) 285 { 286 gtk_adjustment_set_page_increment(gtkAdjustment, pageIncrement); 287 } 288 289 /** 290 * Sets the page size of the adjustment. 291 * 292 * See gtk_adjustment_set_lower() about how to compress multiple 293 * emissions of the GtkAdjustment::changed signal when setting 294 * multiple adjustment properties. 295 * 296 * Params: 297 * pageSize = the new page size 298 * 299 * Since: 2.14 300 */ 301 public void setPageSize(double pageSize) 302 { 303 gtk_adjustment_set_page_size(gtkAdjustment, pageSize); 304 } 305 306 /** 307 * Sets the step increment of the adjustment. 308 * 309 * See gtk_adjustment_set_lower() about how to compress multiple 310 * emissions of the #GtkAdjustment::changed signal when setting 311 * multiple adjustment properties. 312 * 313 * Params: 314 * stepIncrement = the new step increment 315 * 316 * Since: 2.14 317 */ 318 public void setStepIncrement(double stepIncrement) 319 { 320 gtk_adjustment_set_step_increment(gtkAdjustment, stepIncrement); 321 } 322 323 /** 324 * Sets the maximum value of the adjustment. 325 * 326 * Note that values will be restricted by `upper - page-size` 327 * if the page-size property is nonzero. 328 * 329 * See gtk_adjustment_set_lower() about how to compress multiple 330 * emissions of the #GtkAdjustment::changed signal when setting 331 * multiple adjustment properties. 332 * 333 * Params: 334 * upper = the new maximum value 335 * 336 * Since: 2.14 337 */ 338 public void setUpper(double upper) 339 { 340 gtk_adjustment_set_upper(gtkAdjustment, upper); 341 } 342 343 /** 344 * Sets the #GtkAdjustment value. The value is clamped to lie between 345 * #GtkAdjustment:lower and #GtkAdjustment:upper. 346 * 347 * Note that for adjustments which are used in a #GtkScrollbar, the 348 * effective range of allowed values goes from #GtkAdjustment:lower to 349 * #GtkAdjustment:upper - #GtkAdjustment:page-size. 350 * 351 * Params: 352 * value = the new value 353 */ 354 public void setValue(double value) 355 { 356 gtk_adjustment_set_value(gtkAdjustment, value); 357 } 358 359 /** 360 * Emits a #GtkAdjustment::value-changed signal from the #GtkAdjustment. 361 * This is typically called by the owner of the #GtkAdjustment after it has 362 * changed the #GtkAdjustment:value property. 363 * 364 * Deprecated: GTK+ emits #GtkAdjustment::value-changed itself whenever 365 * the value changes 366 */ 367 public void valueChanged() 368 { 369 gtk_adjustment_value_changed(gtkAdjustment); 370 } 371 372 int[string] connectedSignals; 373 374 void delegate(Adjustment)[] onChangedListeners; 375 /** 376 * Emitted when one or more of the #GtkAdjustment properties have been 377 * changed, other than the #GtkAdjustment:value property. 378 */ 379 void addOnChanged(void delegate(Adjustment) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 380 { 381 if ( "changed" !in connectedSignals ) 382 { 383 Signals.connectData( 384 this, 385 "changed", 386 cast(GCallback)&callBackChanged, 387 cast(void*)this, 388 null, 389 connectFlags); 390 connectedSignals["changed"] = 1; 391 } 392 onChangedListeners ~= dlg; 393 } 394 extern(C) static void callBackChanged(GtkAdjustment* adjustmentStruct, Adjustment _adjustment) 395 { 396 foreach ( void delegate(Adjustment) dlg; _adjustment.onChangedListeners ) 397 { 398 dlg(_adjustment); 399 } 400 } 401 402 void delegate(Adjustment)[] onValueChangedListeners; 403 /** 404 * Emitted when the #GtkAdjustment:value property has been changed. 405 */ 406 void addOnValueChanged(void delegate(Adjustment) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 407 { 408 if ( "value-changed" !in connectedSignals ) 409 { 410 Signals.connectData( 411 this, 412 "value-changed", 413 cast(GCallback)&callBackValueChanged, 414 cast(void*)this, 415 null, 416 connectFlags); 417 connectedSignals["value-changed"] = 1; 418 } 419 onValueChangedListeners ~= dlg; 420 } 421 extern(C) static void callBackValueChanged(GtkAdjustment* adjustmentStruct, Adjustment _adjustment) 422 { 423 foreach ( void delegate(Adjustment) dlg; _adjustment.onValueChangedListeners ) 424 { 425 dlg(_adjustment); 426 } 427 } 428 }