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  = GtkHSV.html
27  * outPack = gtk
28  * outFile = HSV
29  * strct   = GtkHSV
30  * realStrct=
31  * ctorStrct=
32  * clss    = HSV
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_hsv_
41  * 	- gtk_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * structWrap:
48  * module aliases:
49  * local aliases:
50  * overrides:
51  */
52 
53 module gtk.HSV;
54 
55 public  import gtkc.gtktypes;
56 
57 private import gtkc.gtk;
58 private import glib.ConstructionException;
59 private import gobject.ObjectG;
60 
61 private import gobject.Signals;
62 public  import gtkc.gdktypes;
63 
64 
65 
66 
67 private import gtk.Widget;
68 
69 /**
70  * GtkHSV is the 'color wheel' part of a complete color selector widget.
71  * It allows to select a color by determining its HSV components in an
72  * intuitive way. Moving the selection around the outer ring changes the hue,
73  * and moving the selection point inside the inner triangle changes value and
74  * saturation.
75  *
76  * GtkHSV has been deprecated together with GtkColorSelection, where
77  * it was used.
78  */
79 public class HSV : Widget
80 {
81 	
82 	/** the main Gtk struct */
83 	protected GtkHSV* gtkHSV;
84 	
85 	
86 	public GtkHSV* getHSVStruct()
87 	{
88 		return gtkHSV;
89 	}
90 	
91 	
92 	/** the main Gtk struct as a void* */
93 	protected override void* getStruct()
94 	{
95 		return cast(void*)gtkHSV;
96 	}
97 	
98 	/**
99 	 * Sets our main struct and passes it to the parent class
100 	 */
101 	public this (GtkHSV* gtkHSV)
102 	{
103 		super(cast(GtkWidget*)gtkHSV);
104 		this.gtkHSV = gtkHSV;
105 	}
106 	
107 	protected override void setStruct(GObject* obj)
108 	{
109 		super.setStruct(obj);
110 		gtkHSV = cast(GtkHSV*)obj;
111 	}
112 	
113 	/**
114 	 */
115 	int[string] connectedSignals;
116 	
117 	void delegate(HSV)[] onChangedListeners;
118 	/**
119 	 */
120 	void addOnChanged(void delegate(HSV) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
121 	{
122 		if ( !("changed" in connectedSignals) )
123 		{
124 			Signals.connectData(
125 			getStruct(),
126 			"changed",
127 			cast(GCallback)&callBackChanged,
128 			cast(void*)this,
129 			null,
130 			connectFlags);
131 			connectedSignals["changed"] = 1;
132 		}
133 		onChangedListeners ~= dlg;
134 	}
135 	extern(C) static void callBackChanged(GtkHSV* hsvStruct, HSV _hSV)
136 	{
137 		foreach ( void delegate(HSV) dlg ; _hSV.onChangedListeners )
138 		{
139 			dlg(_hSV);
140 		}
141 	}
142 	
143 	void delegate(GtkDirectionType, HSV)[] onMoveListeners;
144 	/**
145 	 * See Also
146 	 * GtkColorSelection, GtkColorSelectionDialog
147 	 */
148 	void addOnMove(void delegate(GtkDirectionType, HSV) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
149 	{
150 		if ( !("move" in connectedSignals) )
151 		{
152 			Signals.connectData(
153 			getStruct(),
154 			"move",
155 			cast(GCallback)&callBackMove,
156 			cast(void*)this,
157 			null,
158 			connectFlags);
159 			connectedSignals["move"] = 1;
160 		}
161 		onMoveListeners ~= dlg;
162 	}
163 	extern(C) static void callBackMove(GtkHSV* hsvStruct, GtkDirectionType arg1, HSV _hSV)
164 	{
165 		foreach ( void delegate(GtkDirectionType, HSV) dlg ; _hSV.onMoveListeners )
166 		{
167 			dlg(arg1, _hSV);
168 		}
169 	}
170 	
171 	
172 	/**
173 	 * Creates a new HSV color selector.
174 	 * Since 2.14
175 	 * Throws: ConstructionException GTK+ fails to create the object.
176 	 */
177 	public this ()
178 	{
179 		// GtkWidget * gtk_hsv_new (void);
180 		auto p = gtk_hsv_new();
181 		if(p is null)
182 		{
183 			throw new ConstructionException("null returned by gtk_hsv_new()");
184 		}
185 		this(cast(GtkHSV*) p);
186 	}
187 	
188 	/**
189 	 * Sets the current color in an HSV color selector.
190 	 * Color component values must be in the [0.0, 1.0] range.
191 	 * Since 2.14
192 	 * Params:
193 	 * h = Hue
194 	 * s = Saturation
195 	 * v = Value
196 	 */
197 	public void setColor(double h, double s, double v)
198 	{
199 		// void gtk_hsv_set_color (GtkHSV *hsv,  double h,  double s,  double v);
200 		gtk_hsv_set_color(gtkHSV, h, s, v);
201 	}
202 	
203 	/**
204 	 * Queries the current color in an HSV color selector.
205 	 * Returned values will be in the [0.0, 1.0] range.
206 	 * Since 2.14
207 	 * Params:
208 	 * h = Return value for the hue. [out]
209 	 * s = Return value for the saturation. [out]
210 	 * v = Return value for the value. [out]
211 	 */
212 	public void getColor(out double h, out double s, out double v)
213 	{
214 		// void gtk_hsv_get_color (GtkHSV *hsv,  gdouble *h,  gdouble *s,  gdouble *v);
215 		gtk_hsv_get_color(gtkHSV, &h, &s, &v);
216 	}
217 	
218 	/**
219 	 * Sets the size and ring width of an HSV color selector.
220 	 * Since 2.14
221 	 * Params:
222 	 * size = Diameter for the hue ring
223 	 * ringWidth = Width of the hue ring
224 	 */
225 	public void setMetrics(int size, int ringWidth)
226 	{
227 		// void gtk_hsv_set_metrics (GtkHSV *hsv,  gint size,  gint ring_width);
228 		gtk_hsv_set_metrics(gtkHSV, size, ringWidth);
229 	}
230 	
231 	/**
232 	 * Queries the size and ring width of an HSV color selector.
233 	 * Since 2.14
234 	 * Params:
235 	 * size = Return value for the diameter of the hue ring. [out]
236 	 * ringWidth = Return value for the width of the hue ring. [out]
237 	 */
238 	public void getMetrics(out int size, out int ringWidth)
239 	{
240 		// void gtk_hsv_get_metrics (GtkHSV *hsv,  gint *size,  gint *ring_width);
241 		gtk_hsv_get_metrics(gtkHSV, &size, &ringWidth);
242 	}
243 	
244 	/**
245 	 * An HSV color selector can be said to be adjusting if multiple rapid
246 	 * changes are being made to its value, for example, when the user is
247 	 * adjusting the value with the mouse. This function queries whether
248 	 * the HSV color selector is being adjusted or not.
249 	 * Since 2.14
250 	 * Returns: TRUE if clients can ignore changes to the color value, since they may be transitory, or FALSE if they should consider the color value status to be final.
251 	 */
252 	public int isAdjusting()
253 	{
254 		// gboolean gtk_hsv_is_adjusting (GtkHSV *hsv);
255 		return gtk_hsv_is_adjusting(gtkHSV);
256 	}
257 	
258 	/**
259 	 * Converts a color from HSV space to RGB.
260 	 * Input values must be in the [0.0, 1.0] range;
261 	 * output values will be in the same range.
262 	 * Since 2.14
263 	 * Params:
264 	 * h = Hue
265 	 * s = Saturation
266 	 * v = Value
267 	 * r = Return value for the red component. [out]
268 	 * g = Return value for the green component. [out]
269 	 * b = Return value for the blue component. [out]
270 	 */
271 	public static void toRgb(double h, double s, double v, out double r, out double g, out double b)
272 	{
273 		// void gtk_hsv_to_rgb (gdouble h,  gdouble s,  gdouble v,  gdouble *r,  gdouble *g,  gdouble *b);
274 		gtk_hsv_to_rgb(h, s, v, &r, &g, &b);
275 	}
276 	
277 	/**
278 	 * Converts a color from RGB space to HSV.
279 	 * Input values must be in the [0.0, 1.0] range;
280 	 * output values will be in the same range.
281 	 * Since 2.14
282 	 * Signal Details
283 	 * The "changed" signal
284 	 * void user_function (GtkHSV *hsv,
285 	 *  gpointer user_data) : Run First
286 	 * Params:
287 	 * r = Red
288 	 * g = Green
289 	 * b = Blue
290 	 * h = Return value for the hue component. [out]
291 	 * s = Return value for the saturation component. [out]
292 	 * v = Return value for the value component. [out]
293 	 */
294 	public static void rgbToHsv(double r, double g, double b, out double h, out double s, out double v)
295 	{
296 		// void gtk_rgb_to_hsv (gdouble r,  gdouble g,  gdouble b,  gdouble *h,  gdouble *s,  gdouble *v);
297 		gtk_rgb_to_hsv(r, g, b, &h, &s, &v);
298 	}
299 }