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-GtkGradient.html
27  * outPack = gtk
28  * outFile = Gradient
29  * strct   = GtkGradient
30  * realStrct=
31  * ctorStrct=
32  * clss    = Gradient
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_gradient_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- cairo.Pattern
48  * 	- gtk.StyleContext
49  * 	- gtk.StyleProperties
50  * 	- gtk.SymbolicColor
51  * 	- gtkc.paths
52  * 	- gtkc.Loader
53  * structWrap:
54  * 	- GtkGradient* -> Gradient
55  * 	- GtkStyleContext* -> StyleContext
56  * 	- GtkStyleProperties* -> StyleProperties
57  * 	- GtkSymbolicColor* -> SymbolicColor
58  * 	- cairo_pattern_t* -> Pattern
59  * module aliases:
60  * local aliases:
61  * overrides:
62  * 	- toString
63  */
64 
65 module gtk.Gradient;
66 
67 public  import gtkc.gtktypes;
68 
69 private import gtkc.gtk;
70 private import glib.ConstructionException;
71 private import gobject.ObjectG;
72 
73 
74 private import glib.Str;
75 private import cairo.Pattern;
76 private import gtk.StyleContext;
77 private import gtk.StyleProperties;
78 private import gtk.SymbolicColor;
79 private import gtkc.paths;
80 private import gtkc.Loader;
81 
82 
83 
84 
85 /**
86  * GtkGradient is a boxed type that represents a gradient.
87  * It is the result of parsing a
88  * gradient expression.
89  * To obtain the gradient represented by a GtkGradient, it has to
90  * be resolved with gtk_gradient_resolve(), which replaces all
91  * symbolic color references by the colors they refer to (in a given
92  * context) and constructs a cairo_pattern_t value.
93  *
94  * It is not normally necessary to deal directly with GtkGradients,
95  * since they are mostly used behind the scenes by GtkStyleContext and
96  * GtkCssProvider.
97  *
98  * GtkGradient is deprecated. It was used internally by GTK's CSS engine
99  * to represent gradients. As its handling is not conforming to modern
100  * web standards, it is not used anymore. If you want to use gradients in
101  * your own code, please use Cairo directly.
102  */
103 public class Gradient
104 {
105 	
106 	/** the main Gtk struct */
107 	protected GtkGradient* gtkGradient;
108 	
109 	
110 	public GtkGradient* getGradientStruct()
111 	{
112 		return gtkGradient;
113 	}
114 	
115 	
116 	/** the main Gtk struct as a void* */
117 	protected void* getStruct()
118 	{
119 		return cast(void*)gtkGradient;
120 	}
121 	
122 	/**
123 	 * Sets our main struct and passes it to the parent class
124 	 */
125 	public this (GtkGradient* gtkGradient)
126 	{
127 		this.gtkGradient = gtkGradient;
128 	}
129 	
130 	~this ()
131 	{
132 		if (  Linker.isLoaded(LIBRARY.GTK) && gtkGradient !is null )
133 		{
134 			gtk_gradient_unref(gtkGradient);
135 		}
136 	}
137 	
138 	/**
139 	 */
140 	
141 	/**
142 	 * Warning
143 	 * gtk_gradient_new_linear has been deprecated since version 3.8 and should not be used in newly-written code. GtkGradient is deprecated.
144 	 * Creates a new linear gradient along the line defined by (x0, y0) and (x1, y1). Before using the gradient
145 	 * a number of stop colors must be added through gtk_gradient_add_color_stop().
146 	 * Params:
147 	 * x0 = X coordinate of the starting point
148 	 * y0 = Y coordinate of the starting point
149 	 * x1 = X coordinate of the end point
150 	 * y1 = Y coordinate of the end point
151 	 * Throws: ConstructionException GTK+ fails to create the object.
152 	 */
153 	public this (double x0, double y0, double x1, double y1)
154 	{
155 		// GtkGradient * gtk_gradient_new_linear (gdouble x0,  gdouble y0,  gdouble x1,  gdouble y1);
156 		auto p = gtk_gradient_new_linear(x0, y0, x1, y1);
157 		if(p is null)
158 		{
159 			throw new ConstructionException("null returned by gtk_gradient_new_linear(x0, y0, x1, y1)");
160 		}
161 		this(cast(GtkGradient*) p);
162 	}
163 	
164 	/**
165 	 * Warning
166 	 * gtk_gradient_new_radial has been deprecated since version 3.8 and should not be used in newly-written code. GtkGradient is deprecated.
167 	 * Creates a new radial gradient along the two circles defined by (x0, y0, radius0) and
168 	 * (x1, y1, radius1). Before using the gradient a number of stop colors must be added
169 	 * through gtk_gradient_add_color_stop().
170 	 * Params:
171 	 * x0 = X coordinate of the start circle
172 	 * y0 = Y coordinate of the start circle
173 	 * radius0 = radius of the start circle
174 	 * x1 = X coordinate of the end circle
175 	 * y1 = Y coordinate of the end circle
176 	 * radius1 = radius of the end circle
177 	 * Throws: ConstructionException GTK+ fails to create the object.
178 	 */
179 	public this (double x0, double y0, double radius0, double x1, double y1, double radius1)
180 	{
181 		// GtkGradient * gtk_gradient_new_radial (gdouble x0,  gdouble y0,  gdouble radius0,  gdouble x1,  gdouble y1,  gdouble radius1);
182 		auto p = gtk_gradient_new_radial(x0, y0, radius0, x1, y1, radius1);
183 		if(p is null)
184 		{
185 			throw new ConstructionException("null returned by gtk_gradient_new_radial(x0, y0, radius0, x1, y1, radius1)");
186 		}
187 		this(cast(GtkGradient*) p);
188 	}
189 	
190 	/**
191 	 * Warning
192 	 * gtk_gradient_add_color_stop has been deprecated since version 3.8 and should not be used in newly-written code. GtkGradient is deprecated.
193 	 * Adds a stop color to gradient.
194 	 * Params:
195 	 * offset = offset for the color stop
196 	 * color = color to use
197 	 * Since 3.0
198 	 */
199 	public void addColorStop(double offset, SymbolicColor color)
200 	{
201 		// void gtk_gradient_add_color_stop (GtkGradient *gradient,  gdouble offset,  GtkSymbolicColor *color);
202 		gtk_gradient_add_color_stop(gtkGradient, offset, (color is null) ? null : color.getSymbolicColorStruct());
203 	}
204 	
205 	/**
206 	 * Warning
207 	 * gtk_gradient_ref has been deprecated since version 3.8 and should not be used in newly-written code. GtkGradient is deprecated.
208 	 * Increases the reference count of gradient.
209 	 * Returns: The same gradient Since 3.0
210 	 */
211 	public Gradient doref()
212 	{
213 		// GtkGradient * gtk_gradient_ref (GtkGradient *gradient);
214 		auto p = gtk_gradient_ref(gtkGradient);
215 		
216 		if(p is null)
217 		{
218 			return null;
219 		}
220 		
221 		return ObjectG.getDObject!(Gradient)(cast(GtkGradient*) p);
222 	}
223 	
224 	/**
225 	 * Warning
226 	 * gtk_gradient_unref has been deprecated since version 3.8 and should not be used in newly-written code. GtkGradient is deprecated.
227 	 * Decreases the reference count of gradient, freeing its memory
228 	 * if the reference count reaches 0.
229 	 */
230 	public void unref()
231 	{
232 		// void gtk_gradient_unref (GtkGradient *gradient);
233 		gtk_gradient_unref(gtkGradient);
234 	}
235 	
236 	/**
237 	 * Warning
238 	 * gtk_gradient_resolve has been deprecated since version 3.8 and should not be used in newly-written code. GtkGradient is deprecated.
239 	 * If gradient is resolvable, resolved_gradient will be filled in
240 	 * with the resolved gradient as a cairo_pattern_t, and TRUE will
241 	 * be returned. Generally, if gradient can't be resolved, it is
242 	 * due to it being defined on top of a named color that doesn't
243 	 * exist in props.
244 	 * Params:
245 	 * props = GtkStyleProperties to use when resolving named colors
246 	 * resolvedGradient = return location for the resolved pattern. [out]
247 	 * Returns: TRUE if the gradient has been resolved Since 3.0
248 	 */
249 	public int resolve(StyleProperties props, out Pattern resolvedGradient)
250 	{
251 		// gboolean gtk_gradient_resolve (GtkGradient *gradient,  GtkStyleProperties *props,  cairo_pattern_t **resolved_gradient);
252 		cairo_pattern_t* outresolvedGradient = null;
253 		
254 		auto p = gtk_gradient_resolve(gtkGradient, (props is null) ? null : props.getStylePropertiesStruct(), &outresolvedGradient);
255 		
256 		resolvedGradient = ObjectG.getDObject!(Pattern)(outresolvedGradient);
257 		return p;
258 	}
259 	
260 	/**
261 	 */
262 	public Pattern resolveForContext(StyleContext context)
263 	{
264 		// cairo_pattern_t * gtk_gradient_resolve_for_context (GtkGradient *gradient,  GtkStyleContext *context);
265 		auto p = gtk_gradient_resolve_for_context(gtkGradient, (context is null) ? null : context.getStyleContextStruct());
266 		
267 		if(p is null)
268 		{
269 			return null;
270 		}
271 		
272 		return ObjectG.getDObject!(Pattern)(cast(cairo_pattern_t*) p);
273 	}
274 	
275 	/**
276 	 * Warning
277 	 * gtk_gradient_to_string has been deprecated since version 3.8 and should not be used in newly-written code. GtkGradient is deprecated.
278 	 * Creates a string representation for gradient that is suitable
279 	 * for using in GTK CSS files.
280 	 * Returns: A string representation for gradient
281 	 */
282 	public override string toString()
283 	{
284 		// char * gtk_gradient_to_string (GtkGradient *gradient);
285 		return Str.toString(gtk_gradient_to_string(gtkGradient));
286 	}
287 }