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 private import gtk.c.functions; 34 public import gtk.c.types; 35 private import std.algorithm; 36 37 38 /** 39 * `GtkRange` is the common base class for widgets which visualize an 40 * adjustment. 41 * 42 * Widgets that are derived from `GtkRange` include 43 * [class@Gtk.Scale] and [class@Gtk.Scrollbar]. 44 * 45 * Apart from signals for monitoring the parameters of the adjustment, 46 * `GtkRange` provides properties and methods for setting a 47 * “fill level” on range widgets. See [method@Gtk.Range.set_fill_level]. 48 */ 49 public class Range : Widget, OrientableIF 50 { 51 /** the main Gtk struct */ 52 protected GtkRange* gtkRange; 53 54 /** Get the main Gtk struct */ 55 public GtkRange* getRangeStruct(bool transferOwnership = false) 56 { 57 if (transferOwnership) 58 ownedRef = false; 59 return gtkRange; 60 } 61 62 /** the main Gtk struct as a void* */ 63 protected override void* getStruct() 64 { 65 return cast(void*)gtkRange; 66 } 67 68 /** 69 * Sets our main struct and passes it to the parent class. 70 */ 71 public this (GtkRange* gtkRange, bool ownedRef = false) 72 { 73 this.gtkRange = gtkRange; 74 super(cast(GtkWidget*)gtkRange, ownedRef); 75 } 76 77 // add the Orientable capabilities 78 mixin OrientableT!(GtkRange); 79 80 81 /** */ 82 public static GType getType() 83 { 84 return gtk_range_get_type(); 85 } 86 87 /** 88 * Get the adjustment which is the “model” object for `GtkRange`. 89 * 90 * Returns: a `GtkAdjustment` 91 */ 92 public Adjustment getAdjustment() 93 { 94 auto __p = gtk_range_get_adjustment(gtkRange); 95 96 if(__p is null) 97 { 98 return null; 99 } 100 101 return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) __p); 102 } 103 104 /** 105 * Gets the current position of the fill level indicator. 106 * 107 * Returns: The current fill level 108 */ 109 public double getFillLevel() 110 { 111 return gtk_range_get_fill_level(gtkRange); 112 } 113 114 /** 115 * Gets whether the `GtkRange` respects text direction. 116 * 117 * See [method@Gtk.Range.set_flippable]. 118 * 119 * Returns: %TRUE if the range is flippable 120 */ 121 public bool getFlippable() 122 { 123 return gtk_range_get_flippable(gtkRange) != 0; 124 } 125 126 /** 127 * Gets whether the range is inverted. 128 * 129 * See [method@Gtk.Range.set_inverted]. 130 * 131 * Returns: %TRUE if the range is inverted 132 */ 133 public bool getInverted() 134 { 135 return gtk_range_get_inverted(gtkRange) != 0; 136 } 137 138 /** 139 * This function returns the area that contains the range’s trough, 140 * in coordinates relative to @range's origin. 141 * 142 * This function is useful mainly for `GtkRange` subclasses. 143 * 144 * Params: 145 * rangeRect = return location for the range rectangle 146 */ 147 public void getRangeRect(out GdkRectangle rangeRect) 148 { 149 gtk_range_get_range_rect(gtkRange, &rangeRect); 150 } 151 152 /** 153 * Gets whether the range is restricted to the fill level. 154 * 155 * Returns: %TRUE if @range is restricted to the fill level. 156 */ 157 public bool getRestrictToFillLevel() 158 { 159 return gtk_range_get_restrict_to_fill_level(gtkRange) != 0; 160 } 161 162 /** 163 * Gets the number of digits to round the value to when 164 * it changes. 165 * 166 * See [signal@Gtk.Range::change-value]. 167 * 168 * Returns: the number of digits to round to 169 */ 170 public int getRoundDigits() 171 { 172 return gtk_range_get_round_digits(gtkRange); 173 } 174 175 /** 176 * Gets whether the range displays the fill level graphically. 177 * 178 * Returns: %TRUE if @range shows the fill level. 179 */ 180 public bool getShowFillLevel() 181 { 182 return gtk_range_get_show_fill_level(gtkRange) != 0; 183 } 184 185 /** 186 * This function returns sliders range along the long dimension, 187 * in widget->window coordinates. 188 * 189 * This function is useful mainly for `GtkRange` subclasses. 190 * 191 * Params: 192 * sliderStart = return location for the slider's 193 * start, or %NULL 194 * sliderEnd = return location for the slider's 195 * end, or %NULL 196 */ 197 public void getSliderRange(out int sliderStart, out int sliderEnd) 198 { 199 gtk_range_get_slider_range(gtkRange, &sliderStart, &sliderEnd); 200 } 201 202 /** 203 * This function is useful mainly for `GtkRange` subclasses. 204 * 205 * See [method@Gtk.Range.set_slider_size_fixed]. 206 * 207 * Returns: whether the range’s slider has a fixed size. 208 */ 209 public bool getSliderSizeFixed() 210 { 211 return gtk_range_get_slider_size_fixed(gtkRange) != 0; 212 } 213 214 /** 215 * Gets the current value of the range. 216 * 217 * Returns: current value of the range. 218 */ 219 public double getValue() 220 { 221 return gtk_range_get_value(gtkRange); 222 } 223 224 /** 225 * Sets the adjustment to be used as the “model” object for the `GtkRange` 226 * 227 * The adjustment indicates the current range value, the minimum and 228 * maximum range values, the step/page increments used for keybindings 229 * and scrolling, and the page size. 230 * 231 * The page size is normally 0 for `GtkScale` and nonzero for `GtkScrollbar`, 232 * and indicates the size of the visible area of the widget being scrolled. 233 * The page size affects the size of the scrollbar slider. 234 * 235 * Params: 236 * adjustment = a `GtkAdjustment` 237 */ 238 public void setAdjustment(Adjustment adjustment) 239 { 240 gtk_range_set_adjustment(gtkRange, (adjustment is null) ? null : adjustment.getAdjustmentStruct()); 241 } 242 243 /** 244 * Set the new position of the fill level indicator. 245 * 246 * The “fill level” is probably best described by its most prominent 247 * use case, which is an indicator for the amount of pre-buffering in 248 * a streaming media player. In that use case, the value of the range 249 * would indicate the current play position, and the fill level would 250 * be the position up to which the file/stream has been downloaded. 251 * 252 * This amount of prebuffering can be displayed on the range’s trough 253 * and is themeable separately from the trough. To enable fill level 254 * display, use [method@Gtk.Range.set_show_fill_level]. The range defaults 255 * to not showing the fill level. 256 * 257 * Additionally, it’s possible to restrict the range’s slider position 258 * to values which are smaller than the fill level. This is controlled 259 * by [method@Gtk.Range.set_restrict_to_fill_level] and is by default 260 * enabled. 261 * 262 * Params: 263 * fillLevel = the new position of the fill level indicator 264 */ 265 public void setFillLevel(double fillLevel) 266 { 267 gtk_range_set_fill_level(gtkRange, fillLevel); 268 } 269 270 /** 271 * Sets whether the `GtkRange` respects text direction. 272 * 273 * If a range is flippable, it will switch its direction 274 * if it is horizontal and its direction is %GTK_TEXT_DIR_RTL. 275 * 276 * See [method@Gtk.Widget.get_direction]. 277 * 278 * Params: 279 * flippable = %TRUE to make the range flippable 280 */ 281 public void setFlippable(bool flippable) 282 { 283 gtk_range_set_flippable(gtkRange, flippable); 284 } 285 286 /** 287 * Sets the step and page sizes for the range. 288 * 289 * The step size is used when the user clicks the `GtkScrollbar` 290 * arrows or moves a `GtkScale` via arrow keys. The page size 291 * is used for example when moving via Page Up or Page Down keys. 292 * 293 * Params: 294 * step = step size 295 * page = page size 296 */ 297 public void setIncrements(double step, double page) 298 { 299 gtk_range_set_increments(gtkRange, step, page); 300 } 301 302 /** 303 * Sets whether to invert the range. 304 * 305 * Ranges normally move from lower to higher values as the 306 * slider moves from top to bottom or left to right. Inverted 307 * ranges have higher values at the top or on the right rather 308 * than on the bottom or left. 309 * 310 * Params: 311 * setting = %TRUE to invert the range 312 */ 313 public void setInverted(bool setting) 314 { 315 gtk_range_set_inverted(gtkRange, setting); 316 } 317 318 /** 319 * Sets the allowable values in the `GtkRange`. 320 * 321 * The range value is clamped to be between @min and @max. 322 * (If the range has a non-zero page size, it is clamped 323 * between @min and @max - page-size.) 324 * 325 * Params: 326 * min = minimum range value 327 * max = maximum range value 328 */ 329 public void setRange(double min, double max) 330 { 331 gtk_range_set_range(gtkRange, min, max); 332 } 333 334 /** 335 * Sets whether the slider is restricted to the fill level. 336 * 337 * See [method@Gtk.Range.set_fill_level] for a general description 338 * of the fill level concept. 339 * 340 * Params: 341 * restrictToFillLevel = Whether the fill level restricts slider movement. 342 */ 343 public void setRestrictToFillLevel(bool restrictToFillLevel) 344 { 345 gtk_range_set_restrict_to_fill_level(gtkRange, restrictToFillLevel); 346 } 347 348 /** 349 * Sets the number of digits to round the value to when 350 * it changes. 351 * 352 * See [signal@Gtk.Range::change-value]. 353 * 354 * Params: 355 * roundDigits = the precision in digits, or -1 356 */ 357 public void setRoundDigits(int roundDigits) 358 { 359 gtk_range_set_round_digits(gtkRange, roundDigits); 360 } 361 362 /** 363 * Sets whether a graphical fill level is show on the trough. 364 * 365 * See [method@Gtk.Range.set_fill_level] for a general description 366 * of the fill level concept. 367 * 368 * Params: 369 * showFillLevel = Whether a fill level indicator graphics is shown. 370 */ 371 public void setShowFillLevel(bool showFillLevel) 372 { 373 gtk_range_set_show_fill_level(gtkRange, showFillLevel); 374 } 375 376 /** 377 * Sets whether the range’s slider has a fixed size, or a size that 378 * depends on its adjustment’s page size. 379 * 380 * This function is useful mainly for `GtkRange` subclasses. 381 * 382 * Params: 383 * sizeFixed = %TRUE to make the slider size constant 384 */ 385 public void setSliderSizeFixed(bool sizeFixed) 386 { 387 gtk_range_set_slider_size_fixed(gtkRange, sizeFixed); 388 } 389 390 /** 391 * Sets the current value of the range. 392 * 393 * If the value is outside the minimum or maximum range values, 394 * it will be clamped to fit inside them. The range emits the 395 * [signal@Gtk.Range::value-changed] signal if the value changes. 396 * 397 * Params: 398 * value = new value of the range 399 */ 400 public void setValue(double value) 401 { 402 gtk_range_set_value(gtkRange, value); 403 } 404 405 /** 406 * Emitted before clamping a value, to give the application a 407 * chance to adjust the bounds. 408 * 409 * Params: 410 * value = the value before we clamp 411 */ 412 gulong addOnAdjustBounds(void delegate(double, Range) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 413 { 414 return Signals.connect(this, "adjust-bounds", dlg, connectFlags ^ ConnectFlags.SWAPPED); 415 } 416 417 /** 418 * Emitted when a scroll action is performed on a range. 419 * 420 * It allows an application to determine the type of scroll event 421 * that occurred and the resultant new value. The application can 422 * handle the event itself and return %TRUE to prevent further 423 * processing. Or, by returning %FALSE, it can pass the event to 424 * other handlers until the default GTK handler is reached. 425 * 426 * The value parameter is unrounded. An application that overrides 427 * the ::change-value signal is responsible for clamping the value 428 * to the desired number of decimal digits; the default GTK 429 * handler clamps the value based on [property@Gtk.Range:round-digits]. 430 * 431 * Params: 432 * scroll = the type of scroll action that was performed 433 * value = the new value resulting from the scroll action 434 * 435 * Returns: %TRUE to prevent other handlers from being invoked for 436 * the signal, %FALSE to propagate the signal further 437 */ 438 gulong addOnChangeValue(bool delegate(GtkScrollType, double, Range) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 439 { 440 return Signals.connect(this, "change-value", dlg, connectFlags ^ ConnectFlags.SWAPPED); 441 } 442 443 /** 444 * Virtual function that moves the slider. 445 * 446 * Used for keybindings. 447 * 448 * Params: 449 * step = how to move the slider 450 */ 451 gulong addOnMoveSlider(void delegate(GtkScrollType, Range) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 452 { 453 return Signals.connect(this, "move-slider", dlg, connectFlags ^ ConnectFlags.SWAPPED); 454 } 455 456 /** 457 * Emitted when the range value changes. 458 */ 459 gulong addOnValueChanged(void delegate(Range) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 460 { 461 return Signals.connect(this, "value-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 462 } 463 }