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