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