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.HSV;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import gobject.Signals;
30 private import gtk.Widget;
31 private import gtk.c.functions;
32 public  import gtk.c.types;
33 public  import gtkc.gtktypes;
34 private import std.algorithm;
35 
36 
37 /**
38  * #GtkHSV is the “color wheel” part of a complete color selector widget.
39  * It allows to select a color by determining its HSV components in an
40  * intuitive way. Moving the selection around the outer ring changes the hue,
41  * and moving the selection point inside the inner triangle changes value and
42  * saturation.
43  * 
44  * #GtkHSV has been deprecated together with #GtkColorSelection, where
45  * it was used.
46  */
47 public class HSV : Widget
48 {
49 	/** the main Gtk struct */
50 	protected GtkHSV* gtkHSV;
51 
52 	/** Get the main Gtk struct */
53 	public GtkHSV* getHSVStruct(bool transferOwnership = false)
54 	{
55 		if (transferOwnership)
56 			ownedRef = false;
57 		return gtkHSV;
58 	}
59 
60 	/** the main Gtk struct as a void* */
61 	protected override void* getStruct()
62 	{
63 		return cast(void*)gtkHSV;
64 	}
65 
66 	/**
67 	 * Sets our main struct and passes it to the parent class.
68 	 */
69 	public this (GtkHSV* gtkHSV, bool ownedRef = false)
70 	{
71 		this.gtkHSV = gtkHSV;
72 		super(cast(GtkWidget*)gtkHSV, ownedRef);
73 	}
74 
75 
76 	/** */
77 	public static GType getType()
78 	{
79 		return gtk_hsv_get_type();
80 	}
81 
82 	/**
83 	 * Creates a new HSV color selector.
84 	 *
85 	 * Returns: A newly-created HSV color selector.
86 	 *
87 	 * Since: 2.14
88 	 *
89 	 * Throws: ConstructionException GTK+ fails to create the object.
90 	 */
91 	public this()
92 	{
93 		auto p = gtk_hsv_new();
94 
95 		if(p is null)
96 		{
97 			throw new ConstructionException("null returned by new");
98 		}
99 
100 		this(cast(GtkHSV*) p);
101 	}
102 
103 	/**
104 	 * Converts a color from HSV space to RGB.
105 	 *
106 	 * Input values must be in the [0.0, 1.0] range;
107 	 * output values will be in the same range.
108 	 *
109 	 * Params:
110 	 *     h = Hue
111 	 *     s = Saturation
112 	 *     v = Value
113 	 *     r = Return value for the red component
114 	 *     g = Return value for the green component
115 	 *     b = Return value for the blue component
116 	 *
117 	 * Since: 2.14
118 	 */
119 	public static void toRgb(double h, double s, double v, out double r, out double g, out double b)
120 	{
121 		gtk_hsv_to_rgb(h, s, v, &r, &g, &b);
122 	}
123 
124 	/**
125 	 * Queries the current color in an HSV color selector.
126 	 * Returned values will be in the [0.0, 1.0] range.
127 	 *
128 	 * Params:
129 	 *     h = Return value for the hue
130 	 *     s = Return value for the saturation
131 	 *     v = Return value for the value
132 	 *
133 	 * Since: 2.14
134 	 */
135 	public void getColor(out double h, out double s, out double v)
136 	{
137 		gtk_hsv_get_color(gtkHSV, &h, &s, &v);
138 	}
139 
140 	/**
141 	 * Queries the size and ring width of an HSV color selector.
142 	 *
143 	 * Params:
144 	 *     size = Return value for the diameter of the hue ring
145 	 *     ringWidth = Return value for the width of the hue ring
146 	 *
147 	 * Since: 2.14
148 	 */
149 	public void getMetrics(out int size, out int ringWidth)
150 	{
151 		gtk_hsv_get_metrics(gtkHSV, &size, &ringWidth);
152 	}
153 
154 	/**
155 	 * An HSV color selector can be said to be adjusting if multiple rapid
156 	 * changes are being made to its value, for example, when the user is
157 	 * adjusting the value with the mouse. This function queries whether
158 	 * the HSV color selector is being adjusted or not.
159 	 *
160 	 * Returns: %TRUE if clients can ignore changes to the color value,
161 	 *     since they may be transitory, or %FALSE if they should consider
162 	 *     the color value status to be final.
163 	 *
164 	 * Since: 2.14
165 	 */
166 	public bool isAdjusting()
167 	{
168 		return gtk_hsv_is_adjusting(gtkHSV) != 0;
169 	}
170 
171 	/**
172 	 * Sets the current color in an HSV color selector.
173 	 * Color component values must be in the [0.0, 1.0] range.
174 	 *
175 	 * Params:
176 	 *     h = Hue
177 	 *     s = Saturation
178 	 *     v = Value
179 	 *
180 	 * Since: 2.14
181 	 */
182 	public void setColor(double h, double s, double v)
183 	{
184 		gtk_hsv_set_color(gtkHSV, h, s, v);
185 	}
186 
187 	/**
188 	 * Sets the size and ring width of an HSV color selector.
189 	 *
190 	 * Params:
191 	 *     size = Diameter for the hue ring
192 	 *     ringWidth = Width of the hue ring
193 	 *
194 	 * Since: 2.14
195 	 */
196 	public void setMetrics(int size, int ringWidth)
197 	{
198 		gtk_hsv_set_metrics(gtkHSV, size, ringWidth);
199 	}
200 
201 	/** */
202 	gulong addOnChanged(void delegate(HSV) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
203 	{
204 		return Signals.connect(this, "changed", dlg, connectFlags ^ ConnectFlags.SWAPPED);
205 	}
206 
207 	/** */
208 	gulong addOnMove(void delegate(GtkDirectionType, HSV) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
209 	{
210 		return Signals.connect(this, "move", dlg, connectFlags ^ ConnectFlags.SWAPPED);
211 	}
212 
213 	/**
214 	 * Converts a color from RGB space to HSV.
215 	 *
216 	 * Input values must be in the [0.0, 1.0] range;
217 	 * output values will be in the same range.
218 	 *
219 	 * Params:
220 	 *     r = Red
221 	 *     g = Green
222 	 *     b = Blue
223 	 *     h = Return value for the hue component
224 	 *     s = Return value for the saturation component
225 	 *     v = Return value for the value component
226 	 *
227 	 * Since: 2.14
228 	 */
229 	public static void rgbToHsv(double r, double g, double b, out double h, out double s, out double v)
230 	{
231 		gtk_rgb_to_hsv(r, g, b, &h, &s, &v);
232 	}
233 }