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