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  = gtk3-GtkSymbolicColor.html
27  * outPack = gtk
28  * outFile = SymbolicColor
29  * strct   = GtkSymbolicColor
30  * realStrct=
31  * ctorStrct=
32  * clss    = SymbolicColor
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_symbolic_color_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * 	- gtk_symbolic_color_new_shade
45  * 	- gtk_symbolic_color_new_alpha
46  * omit signals:
47  * imports:
48  * 	- glib.Str
49  * 	- gdk.RGBA
50  * 	- gtk.StyleProperties
51  * 	- gtkc.Loader
52  * 	- gtkc.paths
53  * structWrap:
54  * 	- GdkRGBA* -> RGBA
55  * 	- GtkStyleProperties* -> StyleProperties
56  * 	- GtkSymbolicColor* -> SymbolicColor
57  * module aliases:
58  * local aliases:
59  * overrides:
60  * 	- toString
61  */
62 
63 module gtk.SymbolicColor;
64 
65 public  import gtkc.gtktypes;
66 
67 private import gtkc.gtk;
68 private import glib.ConstructionException;
69 private import gobject.ObjectG;
70 
71 
72 private import glib.Str;
73 private import gdk.RGBA;
74 private import gtk.StyleProperties;
75 private import gtkc.Loader;
76 private import gtkc.paths;
77 
78 
79 
80 
81 /**
82  * GtkSymbolicColor is a boxed type that represents a symbolic color.
83  * It is the result of parsing a
84  * color expression.
85  * To obtain the color represented by a GtkSymbolicColor, it has to
86  * be resolved with gtk_symbolic_color_resolve(), which replaces all
87  * symbolic color references by the colors they refer to (in a given
88  * context) and evaluates mix, shade and other expressions, resulting
89  * in a GdkRGBA value.
90  *
91  * It is not normally necessary to deal directly with GtkSymbolicColors,
92  * since they are mostly used behind the scenes by GtkStyleContext and
93  * GtkCssProvider.
94  *
95  * GtkSymbolicColor is deprecated. Symbolic colors are considered an
96  * implementation detail of GTK+.
97  */
98 public class SymbolicColor
99 {
100 	
101 	/** the main Gtk struct */
102 	protected GtkSymbolicColor* gtkSymbolicColor;
103 	
104 	
105 	public GtkSymbolicColor* getSymbolicColorStruct()
106 	{
107 		return gtkSymbolicColor;
108 	}
109 	
110 	
111 	/** the main Gtk struct as a void* */
112 	protected void* getStruct()
113 	{
114 		return cast(void*)gtkSymbolicColor;
115 	}
116 	
117 	/**
118 	 * Sets our main struct and passes it to the parent class
119 	 */
120 	public this (GtkSymbolicColor* gtkSymbolicColor)
121 	{
122 		this.gtkSymbolicColor = gtkSymbolicColor;
123 	}
124 	
125 	~this ()
126 	{
127 		if (  Linker.isLoaded(LIBRARY.GTK) && gtkSymbolicColor !is null )
128 		{
129 			gtk_symbolic_color_unref(gtkSymbolicColor);
130 		}
131 	}
132 	
133 	/**
134 	 * Creates a symbolic color defined as a shade of another color.
135 	 * A factor > 1.0 would resolve to a brighter or more transparent color,
136 	 * while < 1.0 would resolve to a darker or more opaque color.
137 	 *
138 	 * Params:
139 	 *     color    = another GtkSymbolicColor.
140 	 *     factor   = shading factor to apply to color.
141 	 *     useAlpha = if true change the relative alpha value of the color,
142 	 *                otherwise change the shade.
143 	 *
144 	 * Throws: ConstructionException GTK+ fails to create the object.
145 	 */
146 	public this (SymbolicColor color, double factor, bool useAlpha = true)
147 	{
148 		GtkSymbolicColor* p;
149 		
150 		if ( useAlpha )
151 		{
152 			p = gtk_symbolic_color_new_alpha((color is null) ? null : color.getSymbolicColorStruct(), factor);
153 		}
154 		else
155 		{
156 			p = gtk_symbolic_color_new_shade((color is null) ? null : color.getSymbolicColorStruct(), factor);
157 		}
158 		
159 		if(p is null)
160 		{
161 			throw new ConstructionException("null returned by gtk_symbolic_color_new_shade((color is null) ? null : color.getSymbolicColorStruct(), factor)");
162 		}
163 		
164 		this(cast(GtkSymbolicColor*) p);
165 	}
166 	
167 	/**
168 	 */
169 	
170 	/**
171 	 * Warning
172 	 * gtk_symbolic_color_new_literal has been deprecated since version 3.8 and should not be used in newly-written code. GtkSymbolicColor is deprecated.
173 	 * Creates a symbolic color pointing to a literal color.
174 	 * Params:
175 	 * color = a GdkRGBA
176 	 * Throws: ConstructionException GTK+ fails to create the object.
177 	 */
178 	public this (RGBA color)
179 	{
180 		// GtkSymbolicColor * gtk_symbolic_color_new_literal (const GdkRGBA *color);
181 		auto p = gtk_symbolic_color_new_literal((color is null) ? null : color.getRGBAStruct());
182 		if(p is null)
183 		{
184 			throw new ConstructionException("null returned by gtk_symbolic_color_new_literal((color is null) ? null : color.getRGBAStruct())");
185 		}
186 		this(cast(GtkSymbolicColor*) p);
187 	}
188 	
189 	/**
190 	 * Warning
191 	 * gtk_symbolic_color_new_name has been deprecated since version 3.8 and should not be used in newly-written code. GtkSymbolicColor is deprecated.
192 	 * Creates a symbolic color pointing to an unresolved named
193 	 * color. See gtk_style_context_lookup_color() and
194 	 * gtk_style_properties_lookup_color().
195 	 * Params:
196 	 * name = color name
197 	 * Throws: ConstructionException GTK+ fails to create the object.
198 	 */
199 	public this (string name)
200 	{
201 		// GtkSymbolicColor * gtk_symbolic_color_new_name (const gchar *name);
202 		auto p = gtk_symbolic_color_new_name(Str.toStringz(name));
203 		if(p is null)
204 		{
205 			throw new ConstructionException("null returned by gtk_symbolic_color_new_name(Str.toStringz(name))");
206 		}
207 		this(cast(GtkSymbolicColor*) p);
208 	}
209 	
210 	/**
211 	 * Warning
212 	 * gtk_symbolic_color_new_mix has been deprecated since version 3.8 and should not be used in newly-written code. GtkSymbolicColor is deprecated.
213 	 * Creates a symbolic color defined as a mix of another
214 	 * two colors. a mix factor of 0 would resolve to color1,
215 	 * while a factor of 1 would resolve to color2.
216 	 * Params:
217 	 * color1 = color to mix
218 	 * color2 = another color to mix
219 	 * factor = mix factor
220 	 * Throws: ConstructionException GTK+ fails to create the object.
221 	 */
222 	public this (SymbolicColor color1, SymbolicColor color2, double factor)
223 	{
224 		// GtkSymbolicColor * gtk_symbolic_color_new_mix (GtkSymbolicColor *color1,  GtkSymbolicColor *color2,  gdouble factor);
225 		auto p = gtk_symbolic_color_new_mix((color1 is null) ? null : color1.getSymbolicColorStruct(), (color2 is null) ? null : color2.getSymbolicColorStruct(), factor);
226 		if(p is null)
227 		{
228 			throw new ConstructionException("null returned by gtk_symbolic_color_new_mix((color1 is null) ? null : color1.getSymbolicColorStruct(), (color2 is null) ? null : color2.getSymbolicColorStruct(), factor)");
229 		}
230 		this(cast(GtkSymbolicColor*) p);
231 	}
232 	
233 	/**
234 	 * Warning
235 	 * gtk_symbolic_color_new_win32 has been deprecated since version 3.8 and should not be used in newly-written code. GtkSymbolicColor is deprecated.
236 	 * Creates a symbolic color based on the current win32
237 	 * theme.
238 	 * Note that while this call is available on all platforms
239 	 * the actual value returned is not reliable on non-win32
240 	 * platforms.
241 	 * Params:
242 	 * themeClass = The theme class to pull color from
243 	 * id = The color id
244 	 * Throws: ConstructionException GTK+ fails to create the object.
245 	 */
246 	public this (string themeClass, int id)
247 	{
248 		// GtkSymbolicColor * gtk_symbolic_color_new_win32 (const gchar *theme_class,  gint id);
249 		auto p = gtk_symbolic_color_new_win32(Str.toStringz(themeClass), id);
250 		if(p is null)
251 		{
252 			throw new ConstructionException("null returned by gtk_symbolic_color_new_win32(Str.toStringz(themeClass), id)");
253 		}
254 		this(cast(GtkSymbolicColor*) p);
255 	}
256 	
257 	/**
258 	 * Warning
259 	 * gtk_symbolic_color_ref has been deprecated since version 3.8 and should not be used in newly-written code. GtkSymbolicColor is deprecated.
260 	 * Increases the reference count of color
261 	 * Returns: the same color Since 3.0
262 	 */
263 	public SymbolicColor doref()
264 	{
265 		// GtkSymbolicColor * gtk_symbolic_color_ref (GtkSymbolicColor *color);
266 		auto p = gtk_symbolic_color_ref(gtkSymbolicColor);
267 		
268 		if(p is null)
269 		{
270 			return null;
271 		}
272 		
273 		return ObjectG.getDObject!(SymbolicColor)(cast(GtkSymbolicColor*) p);
274 	}
275 	
276 	/**
277 	 * Warning
278 	 * gtk_symbolic_color_unref has been deprecated since version 3.8 and should not be used in newly-written code. GtkSymbolicColor is deprecated.
279 	 * Decreases the reference count of color, freeing its memory if the
280 	 * reference count reaches 0.
281 	 */
282 	public void unref()
283 	{
284 		// void gtk_symbolic_color_unref (GtkSymbolicColor *color);
285 		gtk_symbolic_color_unref(gtkSymbolicColor);
286 	}
287 	
288 	/**
289 	 * Warning
290 	 * gtk_symbolic_color_resolve has been deprecated since version 3.8 and should not be used in newly-written code. GtkSymbolicColor is deprecated.
291 	 * If color is resolvable, resolved_color will be filled in
292 	 * with the resolved color, and TRUE will be returned. Generally,
293 	 * if color can't be resolved, it is due to it being defined on
294 	 * top of a named color that doesn't exist in props.
295 	 * When props is NULL, resolving of named colors will fail, so if
296 	 * your color is or references such a color, this function will
297 	 * return FALSE.
298 	 * Params:
299 	 * props = GtkStyleProperties to use when resolving
300 	 * named colors, or NULL. [allow-none]
301 	 * resolvedColor = return location for the resolved color. [out]
302 	 * Returns: TRUE if the color has been resolved Since 3.0
303 	 */
304 	public int resolve(StyleProperties props, RGBA resolvedColor)
305 	{
306 		// gboolean gtk_symbolic_color_resolve (GtkSymbolicColor *color,  GtkStyleProperties *props,  GdkRGBA *resolved_color);
307 		return gtk_symbolic_color_resolve(gtkSymbolicColor, (props is null) ? null : props.getStylePropertiesStruct(), (resolvedColor is null) ? null : resolvedColor.getRGBAStruct());
308 	}
309 	
310 	/**
311 	 * Warning
312 	 * gtk_symbolic_color_to_string has been deprecated since version 3.8 and should not be used in newly-written code. GtkSymbolicColor is deprecated.
313 	 * Converts the given color to a string representation. This is useful
314 	 * both for debugging and for serialization of strings. The format of
315 	 * the string may change between different versions of GTK, but it is
316 	 * guaranteed that the GTK css parser is able to read the string and
317 	 * create the same symbolic color from it.
318 	 * Returns: a new string representing color
319 	 */
320 	public override string toString()
321 	{
322 		// char * gtk_symbolic_color_to_string (GtkSymbolicColor *color);
323 		return Str.toString(gtk_symbolic_color_to_string(gtkSymbolicColor));
324 	}
325 }