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