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 = GtkRange.html 27 * outPack = gtk 28 * outFile = Range 29 * strct = GtkRange 30 * realStrct= 31 * ctorStrct= 32 * clss = Range 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * - OrientableIF 40 * prefixes: 41 * - gtk_range_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * - gtk.Adjustment 48 * - gtk.OrientableIF 49 * - gtk.OrientableT 50 * structWrap: 51 * - GtkAdjustment* -> Adjustment 52 * module aliases: 53 * local aliases: 54 * overrides: 55 */ 56 57 module gtk.Range; 58 59 public import gtkc.gtktypes; 60 61 private import gtkc.gtk; 62 private import glib.ConstructionException; 63 private import gobject.ObjectG; 64 65 private import gobject.Signals; 66 public import gtkc.gdktypes; 67 68 private import gtk.Adjustment; 69 private import gtk.OrientableIF; 70 private import gtk.OrientableT; 71 72 73 74 private import gtk.Widget; 75 76 /** 77 * GtkRange is the common base class for widgets which visualize an 78 * adjustment, e.g GtkScale or GtkScrollbar. 79 * 80 * Apart from signals for monitoring the parameters of the adjustment, 81 * GtkRange provides properties and methods for influencing the sensitivity 82 * of the "steppers". It also provides properties and methods for setting a 83 * "fill level" on range widgets. See gtk_range_set_fill_level(). 84 */ 85 public class Range : Widget, OrientableIF 86 { 87 88 /** the main Gtk struct */ 89 protected GtkRange* gtkRange; 90 91 92 public GtkRange* getRangeStruct() 93 { 94 return gtkRange; 95 } 96 97 98 /** the main Gtk struct as a void* */ 99 protected override void* getStruct() 100 { 101 return cast(void*)gtkRange; 102 } 103 104 /** 105 * Sets our main struct and passes it to the parent class 106 */ 107 public this (GtkRange* gtkRange) 108 { 109 super(cast(GtkWidget*)gtkRange); 110 this.gtkRange = gtkRange; 111 } 112 113 protected override void setStruct(GObject* obj) 114 { 115 super.setStruct(obj); 116 gtkRange = cast(GtkRange*)obj; 117 } 118 119 // add the Orientable capabilities 120 mixin OrientableT!(GtkRange); 121 122 /** 123 */ 124 int[string] connectedSignals; 125 126 void delegate(gdouble, Range)[] onAdjustBoundsListeners; 127 /** 128 * Emitted before clamping a value, to give the application a 129 * chance to adjust the bounds. 130 */ 131 void addOnAdjustBounds(void delegate(gdouble, Range) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 132 { 133 if ( !("adjust-bounds" in connectedSignals) ) 134 { 135 Signals.connectData( 136 getStruct(), 137 "adjust-bounds", 138 cast(GCallback)&callBackAdjustBounds, 139 cast(void*)this, 140 null, 141 connectFlags); 142 connectedSignals["adjust-bounds"] = 1; 143 } 144 onAdjustBoundsListeners ~= dlg; 145 } 146 extern(C) static void callBackAdjustBounds(GtkRange* rangeStruct, gdouble value, Range _range) 147 { 148 foreach ( void delegate(gdouble, Range) dlg ; _range.onAdjustBoundsListeners ) 149 { 150 dlg(value, _range); 151 } 152 } 153 154 bool delegate(GtkScrollType, gdouble, Range)[] onChangeValueListeners; 155 /** 156 * The "change-value" signal is emitted when a scroll action is 157 * performed on a range. It allows an application to determine the 158 * type of scroll event that occurred and the resultant new value. 159 * The application can handle the event itself and return TRUE to 160 * prevent further processing. Or, by returning FALSE, it can pass 161 * the event to other handlers until the default GTK+ handler is 162 * reached. 163 * The value parameter is unrounded. An application that overrides 164 * the GtkRange::change-value signal is responsible for clamping the 165 * value to the desired number of decimal digits; the default GTK+ 166 * handler clamps the value based on "round-digits". 167 * It is not possible to use delayed update policies in an overridden 168 * "change-value" handler. 169 * TRUE to prevent other handlers from being invoked for 170 * the signal, FALSE to propagate the signal further 171 * Since 2.6 172 */ 173 void addOnChangeValue(bool delegate(GtkScrollType, gdouble, Range) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 174 { 175 if ( !("change-value" in connectedSignals) ) 176 { 177 Signals.connectData( 178 getStruct(), 179 "change-value", 180 cast(GCallback)&callBackChangeValue, 181 cast(void*)this, 182 null, 183 connectFlags); 184 connectedSignals["change-value"] = 1; 185 } 186 onChangeValueListeners ~= dlg; 187 } 188 extern(C) static gboolean callBackChangeValue(GtkRange* rangeStruct, GtkScrollType scroll, gdouble value, Range _range) 189 { 190 foreach ( bool delegate(GtkScrollType, gdouble, Range) dlg ; _range.onChangeValueListeners ) 191 { 192 if ( dlg(scroll, value, _range) ) 193 { 194 return 1; 195 } 196 } 197 198 return 0; 199 } 200 201 void delegate(GtkScrollType, Range)[] onMoveSliderListeners; 202 /** 203 * Virtual function that moves the slider. Used for keybindings. 204 */ 205 void addOnMoveSlider(void delegate(GtkScrollType, Range) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 206 { 207 if ( !("move-slider" in connectedSignals) ) 208 { 209 Signals.connectData( 210 getStruct(), 211 "move-slider", 212 cast(GCallback)&callBackMoveSlider, 213 cast(void*)this, 214 null, 215 connectFlags); 216 connectedSignals["move-slider"] = 1; 217 } 218 onMoveSliderListeners ~= dlg; 219 } 220 extern(C) static void callBackMoveSlider(GtkRange* rangeStruct, GtkScrollType step, Range _range) 221 { 222 foreach ( void delegate(GtkScrollType, Range) dlg ; _range.onMoveSliderListeners ) 223 { 224 dlg(step, _range); 225 } 226 } 227 228 void delegate(Range)[] onValueChangedListeners; 229 /** 230 * Emitted when the range value changes. 231 */ 232 void addOnValueChanged(void delegate(Range) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 233 { 234 if ( !("value-changed" in connectedSignals) ) 235 { 236 Signals.connectData( 237 getStruct(), 238 "value-changed", 239 cast(GCallback)&callBackValueChanged, 240 cast(void*)this, 241 null, 242 connectFlags); 243 connectedSignals["value-changed"] = 1; 244 } 245 onValueChangedListeners ~= dlg; 246 } 247 extern(C) static void callBackValueChanged(GtkRange* rangeStruct, Range _range) 248 { 249 foreach ( void delegate(Range) dlg ; _range.onValueChangedListeners ) 250 { 251 dlg(_range); 252 } 253 } 254 255 256 /** 257 * Gets the current position of the fill level indicator. 258 * Since 2.12 259 * Returns: The current fill level 260 */ 261 public double getFillLevel() 262 { 263 // gdouble gtk_range_get_fill_level (GtkRange *range); 264 return gtk_range_get_fill_level(gtkRange); 265 } 266 267 /** 268 * Gets whether the range is restricted to the fill level. 269 * Since 2.12 270 * Returns: TRUE if range is restricted to the fill level. 271 */ 272 public int getRestrictToFillLevel() 273 { 274 // gboolean gtk_range_get_restrict_to_fill_level (GtkRange *range); 275 return gtk_range_get_restrict_to_fill_level(gtkRange); 276 } 277 278 /** 279 * Gets whether the range displays the fill level graphically. 280 * Since 2.12 281 * Returns: TRUE if range shows the fill level. 282 */ 283 public int getShowFillLevel() 284 { 285 // gboolean gtk_range_get_show_fill_level (GtkRange *range); 286 return gtk_range_get_show_fill_level(gtkRange); 287 } 288 289 /** 290 * Set the new position of the fill level indicator. 291 * The "fill level" is probably best described by its most prominent 292 * use case, which is an indicator for the amount of pre-buffering in 293 * a streaming media player. In that use case, the value of the range 294 * would indicate the current play position, and the fill level would 295 * be the position up to which the file/stream has been downloaded. 296 * This amount of prebuffering can be displayed on the range's trough 297 * and is themeable separately from the trough. To enable fill level 298 * display, use gtk_range_set_show_fill_level(). The range defaults 299 * to not showing the fill level. 300 * Additionally, it's possible to restrict the range's slider position 301 * to values which are smaller than the fill level. This is controller 302 * by gtk_range_set_restrict_to_fill_level() and is by default 303 * enabled. 304 * Since 2.12 305 * Params: 306 * fillLevel = the new position of the fill level indicator 307 */ 308 public void setFillLevel(double fillLevel) 309 { 310 // void gtk_range_set_fill_level (GtkRange *range, gdouble fill_level); 311 gtk_range_set_fill_level(gtkRange, fillLevel); 312 } 313 314 /** 315 * Sets whether the slider is restricted to the fill level. See 316 * gtk_range_set_fill_level() for a general description of the fill 317 * level concept. 318 * Since 2.12 319 * Params: 320 * restrictToFillLevel = Whether the fill level restricts slider movement. 321 */ 322 public void setRestrictToFillLevel(int restrictToFillLevel) 323 { 324 // void gtk_range_set_restrict_to_fill_level (GtkRange *range, gboolean restrict_to_fill_level); 325 gtk_range_set_restrict_to_fill_level(gtkRange, restrictToFillLevel); 326 } 327 328 /** 329 * Sets whether a graphical fill level is show on the trough. See 330 * gtk_range_set_fill_level() for a general description of the fill 331 * level concept. 332 * Since 2.12 333 * Params: 334 * showFillLevel = Whether a fill level indicator graphics is shown. 335 */ 336 public void setShowFillLevel(int showFillLevel) 337 { 338 // void gtk_range_set_show_fill_level (GtkRange *range, gboolean show_fill_level); 339 gtk_range_set_show_fill_level(gtkRange, showFillLevel); 340 } 341 342 /** 343 * Get the GtkAdjustment which is the "model" object for GtkRange. 344 * See gtk_range_set_adjustment() for details. 345 * The return value does not have a reference added, so should not 346 * be unreferenced. 347 * Returns: a GtkAdjustment. [transfer none] 348 */ 349 public Adjustment getAdjustment() 350 { 351 // GtkAdjustment * gtk_range_get_adjustment (GtkRange *range); 352 auto p = gtk_range_get_adjustment(gtkRange); 353 354 if(p is null) 355 { 356 return null; 357 } 358 359 return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p); 360 } 361 362 /** 363 * Sets the adjustment to be used as the "model" object for this range 364 * widget. The adjustment indicates the current range value, the 365 * minimum and maximum range values, the step/page increments used 366 * for keybindings and scrolling, and the page size. The page size 367 * is normally 0 for GtkScale and nonzero for GtkScrollbar, and 368 * indicates the size of the visible area of the widget being scrolled. 369 * The page size affects the size of the scrollbar slider. 370 * Params: 371 * adjustment = a GtkAdjustment 372 */ 373 public void setAdjustment(Adjustment adjustment) 374 { 375 // void gtk_range_set_adjustment (GtkRange *range, GtkAdjustment *adjustment); 376 gtk_range_set_adjustment(gtkRange, (adjustment is null) ? null : adjustment.getAdjustmentStruct()); 377 } 378 379 /** 380 * Gets the value set by gtk_range_set_inverted(). 381 * Returns: TRUE if the range is inverted 382 */ 383 public int getInverted() 384 { 385 // gboolean gtk_range_get_inverted (GtkRange *range); 386 return gtk_range_get_inverted(gtkRange); 387 } 388 389 /** 390 * Ranges normally move from lower to higher values as the 391 * slider moves from top to bottom or left to right. Inverted 392 * ranges have higher values at the top or on the right rather than 393 * on the bottom or left. 394 * Params: 395 * setting = TRUE to invert the range 396 */ 397 public void setInverted(int setting) 398 { 399 // void gtk_range_set_inverted (GtkRange *range, gboolean setting); 400 gtk_range_set_inverted(gtkRange, setting); 401 } 402 403 /** 404 * Gets the current value of the range. 405 * Returns: current value of the range. 406 */ 407 public double getValue() 408 { 409 // gdouble gtk_range_get_value (GtkRange *range); 410 return gtk_range_get_value(gtkRange); 411 } 412 413 /** 414 * Sets the current value of the range; if the value is outside the 415 * minimum or maximum range values, it will be clamped to fit inside 416 * them. The range emits the "value-changed" signal if the 417 * value changes. 418 * Params: 419 * value = new value of the range 420 */ 421 public void setValue(double value) 422 { 423 // void gtk_range_set_value (GtkRange *range, gdouble value); 424 gtk_range_set_value(gtkRange, value); 425 } 426 427 /** 428 * Sets the step and page sizes for the range. 429 * The step size is used when the user clicks the GtkScrollbar 430 * arrows or moves GtkScale via arrow keys. The page size 431 * is used for example when moving via Page Up or Page Down keys. 432 * Params: 433 * step = step size 434 * page = page size 435 */ 436 public void setIncrements(double step, double page) 437 { 438 // void gtk_range_set_increments (GtkRange *range, gdouble step, gdouble page); 439 gtk_range_set_increments(gtkRange, step, page); 440 } 441 442 /** 443 * Sets the allowable values in the GtkRange, and clamps the range 444 * value to be between min and max. (If the range has a non-zero 445 * page size, it is clamped between min and max - page-size.) 446 * Params: 447 * min = minimum range value 448 * max = maximum range value 449 */ 450 public void setRange(double min, double max) 451 { 452 // void gtk_range_set_range (GtkRange *range, gdouble min, gdouble max); 453 gtk_range_set_range(gtkRange, min, max); 454 } 455 456 /** 457 * Gets the number of digits to round the value to when 458 * it changes. See "change-value". 459 * Since 2.24 460 * Returns: the number of digits to round to 461 */ 462 public int getRoundDigits() 463 { 464 // gint gtk_range_get_round_digits (GtkRange *range); 465 return gtk_range_get_round_digits(gtkRange); 466 } 467 468 /** 469 * Sets the number of digits to round the value to when 470 * it changes. See "change-value". 471 * Since 2.24 472 * Params: 473 * roundDigits = the precision in digits, or -1 474 */ 475 public void setRoundDigits(int roundDigits) 476 { 477 // void gtk_range_set_round_digits (GtkRange *range, gint round_digits); 478 gtk_range_set_round_digits(gtkRange, roundDigits); 479 } 480 481 /** 482 * Sets the sensitivity policy for the stepper that points to the 483 * 'lower' end of the GtkRange's adjustment. 484 * Since 2.10 485 * Params: 486 * sensitivity = the lower stepper's sensitivity policy. 487 */ 488 public void setLowerStepperSensitivity(GtkSensitivityType sensitivity) 489 { 490 // void gtk_range_set_lower_stepper_sensitivity (GtkRange *range, GtkSensitivityType sensitivity); 491 gtk_range_set_lower_stepper_sensitivity(gtkRange, sensitivity); 492 } 493 494 /** 495 * Gets the sensitivity policy for the stepper that points to the 496 * 'lower' end of the GtkRange's adjustment. 497 * Since 2.10 498 * Returns: The lower stepper's sensitivity policy. 499 */ 500 public GtkSensitivityType getLowerStepperSensitivity() 501 { 502 // GtkSensitivityType gtk_range_get_lower_stepper_sensitivity (GtkRange *range); 503 return gtk_range_get_lower_stepper_sensitivity(gtkRange); 504 } 505 506 /** 507 * Sets the sensitivity policy for the stepper that points to the 508 * 'upper' end of the GtkRange's adjustment. 509 * Since 2.10 510 * Params: 511 * sensitivity = the upper stepper's sensitivity policy. 512 */ 513 public void setUpperStepperSensitivity(GtkSensitivityType sensitivity) 514 { 515 // void gtk_range_set_upper_stepper_sensitivity (GtkRange *range, GtkSensitivityType sensitivity); 516 gtk_range_set_upper_stepper_sensitivity(gtkRange, sensitivity); 517 } 518 519 /** 520 * Gets the sensitivity policy for the stepper that points to the 521 * 'upper' end of the GtkRange's adjustment. 522 * Since 2.10 523 * Returns: The upper stepper's sensitivity policy. 524 */ 525 public GtkSensitivityType getUpperStepperSensitivity() 526 { 527 // GtkSensitivityType gtk_range_get_upper_stepper_sensitivity (GtkRange *range); 528 return gtk_range_get_upper_stepper_sensitivity(gtkRange); 529 } 530 531 /** 532 * Gets the value set by gtk_range_set_flippable(). 533 * Since 2.18 534 * Returns: TRUE if the range is flippable 535 */ 536 public int getFlippable() 537 { 538 // gboolean gtk_range_get_flippable (GtkRange *range); 539 return gtk_range_get_flippable(gtkRange); 540 } 541 542 /** 543 * If a range is flippable, it will switch its direction if it is 544 * horizontal and its direction is GTK_TEXT_DIR_RTL. 545 * See gtk_widget_get_direction(). 546 * Since 2.18 547 * Params: 548 * flippable = TRUE to make the range flippable 549 */ 550 public void setFlippable(int flippable) 551 { 552 // void gtk_range_set_flippable (GtkRange *range, gboolean flippable); 553 gtk_range_set_flippable(gtkRange, flippable); 554 } 555 556 /** 557 * This function is useful mainly for GtkRange subclasses. 558 * See gtk_range_set_min_slider_size(). 559 * Since 2.20 560 * Returns: The minimum size of the range's slider. 561 */ 562 public int getMinSliderSize() 563 { 564 // gint gtk_range_get_min_slider_size (GtkRange *range); 565 return gtk_range_get_min_slider_size(gtkRange); 566 } 567 568 /** 569 * This function returns the area that contains the range's trough 570 * and its steppers, in widget->window coordinates. 571 * This function is useful mainly for GtkRange subclasses. 572 * Since 2.20 573 * Params: 574 * range = a GtkRange 575 * rangeRect = return location for the range rectangle. [out] 576 */ 577 public void getRangeRect(out Rectangle rangeRect) 578 { 579 // void gtk_range_get_range_rect (GtkRange *range, GdkRectangle *range_rect); 580 gtk_range_get_range_rect(gtkRange, &rangeRect); 581 } 582 583 /** 584 * This function returns sliders range along the long dimension, 585 * in widget->window coordinates. 586 * This function is useful mainly for GtkRange subclasses. 587 * Since 2.20 588 * Params: 589 * sliderStart = return location for the slider's 590 * start, or NULL. [out][allow-none] 591 * sliderEnd = return location for the slider's 592 * end, or NULL. [out][allow-none] 593 */ 594 public void getSliderRange(out int sliderStart, out int sliderEnd) 595 { 596 // void gtk_range_get_slider_range (GtkRange *range, gint *slider_start, gint *slider_end); 597 gtk_range_get_slider_range(gtkRange, &sliderStart, &sliderEnd); 598 } 599 600 /** 601 * This function is useful mainly for GtkRange subclasses. 602 * See gtk_range_set_slider_size_fixed(). 603 * Since 2.20 604 * Returns: whether the range's slider has a fixed size. 605 */ 606 public int getSliderSizeFixed() 607 { 608 // gboolean gtk_range_get_slider_size_fixed (GtkRange *range); 609 return gtk_range_get_slider_size_fixed(gtkRange); 610 } 611 612 /** 613 * Sets the minimum size of the range's slider. 614 * This function is useful mainly for GtkRange subclasses. 615 * Since 2.20 616 * Params: 617 * minSize = The slider's minimum size 618 */ 619 public void setMinSliderSize(int minSize) 620 { 621 // void gtk_range_set_min_slider_size (GtkRange *range, gint min_size); 622 gtk_range_set_min_slider_size(gtkRange, minSize); 623 } 624 625 /** 626 * Sets whether the range's slider has a fixed size, or a size that 627 * depends on its adjustment's page size. 628 * This function is useful mainly for GtkRange subclasses. 629 * Since 2.20 630 * Params: 631 * sizeFixed = TRUE to make the slider size constant 632 */ 633 public void setSliderSizeFixed(int sizeFixed) 634 { 635 // void gtk_range_set_slider_size_fixed (GtkRange *range, gboolean size_fixed); 636 gtk_range_set_slider_size_fixed(gtkRange, sizeFixed); 637 } 638 }