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