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