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-GtkStyleProperties.html
27  * outPack = gtk
28  * outFile = StyleProperties
29  * strct   = GtkStyleProperties
30  * realStrct=
31  * ctorStrct=
32  * clss    = StyleProperties
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = GObject
38  * implements:
39  * prefixes:
40  * 	- gtk_style_properties_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- std.stdarg
47  * 	- glib.Str
48  * 	- glib.ErrorG
49  * 	- glib.GException
50  * 	- gobject.ParamSpec
51  * 	- gobject.Value
52  * 	- gtk.SymbolicColor
53  * structWrap:
54  * 	- GParamSpec* -> ParamSpec
55  * 	- GValue* -> Value
56  * 	- GtkStyleProperties* -> StyleProperties
57  * 	- GtkSymbolicColor* -> SymbolicColor
58  * module aliases:
59  * local aliases:
60  * 	- getProperty -> getStyleProperty
61  * 	- getValist -> getStyleValist
62  * 	- setProperty -> setStyleProperty
63  * 	- setValist -> setStyleValist
64  * overrides:
65  */
66 
67 module gtk.StyleProperties;
68 
69 public  import gtkc.gtktypes;
70 
71 private import gtkc.gtk;
72 private import glib.ConstructionException;
73 private import gobject.ObjectG;
74 
75 
76 private import glib.Str;
77 private import glib.ErrorG;
78 private import glib.GException;
79 private import gobject.ParamSpec;
80 private import gobject.Value;
81 private import gtk.SymbolicColor;
82 
83 
84 version(Tango) {
85 	private import tango.core.Vararg;
86 
87 	version = druntime;
88 } else version(D_Version2) {
89 	private import core.vararg;
90 
91 	version = druntime;
92 } else {
93 	private import std.stdarg;
94 }
95 
96 
97 private import gobject.ObjectG;
98 
99 /**
100  * GtkStyleProperties provides the storage for style information
101  * that is used by GtkStyleContext and other GtkStyleProvider
102  * implementations.
103  *
104  * Before style properties can be stored in GtkStyleProperties, they
105  * must be registered with gtk_style_properties_register_property().
106  *
107  * Unless you are writing a GtkStyleProvider implementation, you
108  * are unlikely to use this API directly, as gtk_style_context_get()
109  * and its variants are the preferred way to access styling information
110  * from widget implementations and theming engine implementations
111  * should use the APIs provided by GtkThemingEngine instead.
112  */
113 public class StyleProperties : ObjectG
114 {
115 	
116 	/** the main Gtk struct */
117 	protected GtkStyleProperties* gtkStyleProperties;
118 	
119 	
120 	public GtkStyleProperties* getStylePropertiesStruct()
121 	{
122 		return gtkStyleProperties;
123 	}
124 	
125 	
126 	/** the main Gtk struct as a void* */
127 	protected override void* getStruct()
128 	{
129 		return cast(void*)gtkStyleProperties;
130 	}
131 	
132 	/**
133 	 * Sets our main struct and passes it to the parent class
134 	 */
135 	public this (GtkStyleProperties* gtkStyleProperties)
136 	{
137 		super(cast(GObject*)gtkStyleProperties);
138 		this.gtkStyleProperties = gtkStyleProperties;
139 	}
140 	
141 	protected override void setStruct(GObject* obj)
142 	{
143 		super.setStruct(obj);
144 		gtkStyleProperties = cast(GtkStyleProperties*)obj;
145 	}
146 	
147 	/**
148 	 */
149 	
150 	/**
151 	 * Clears all style information from props.
152 	 */
153 	public void clear()
154 	{
155 		// void gtk_style_properties_clear (GtkStyleProperties *props);
156 		gtk_style_properties_clear(gtkStyleProperties);
157 	}
158 	
159 	/**
160 	 * Gets a style property from props for the given state. When done with value,
161 	 * g_value_unset() needs to be called to free any allocated memory.
162 	 * Params:
163 	 * property = style property name
164 	 * state = state to retrieve the property value for
165 	 * value = return location for the style property value. [out][transfer full]
166 	 * Returns: TRUE if the property exists in props, FALSE otherwise Since 3.0
167 	 */
168 	public int getStyleProperty(string property, GtkStateFlags state, Value value)
169 	{
170 		// gboolean gtk_style_properties_get_property (GtkStyleProperties *props,  const gchar *property,  GtkStateFlags state,  GValue *value);
171 		return gtk_style_properties_get_property(gtkStyleProperties, Str.toStringz(property), state, (value is null) ? null : value.getValueStruct());
172 	}
173 	
174 	/**
175 	 * Retrieves several style property values from props for a given state.
176 	 * Params:
177 	 * state = state to retrieve the property values for
178 	 * args = va_list of property name/return location pairs, followed by NULL
179 	 * Since 3.0
180 	 */
181 	public void getStyleValist(GtkStateFlags state, void* args)
182 	{
183 		// void gtk_style_properties_get_valist (GtkStyleProperties *props,  GtkStateFlags state,  va_list args);
184 		gtk_style_properties_get_valist(gtkStyleProperties, state, args);
185 	}
186 	
187 	/**
188 	 * Warning
189 	 * gtk_style_properties_lookup_color has been deprecated since version 3.8 and should not be used in newly-written code. GtkSymbolicColor is deprecated.
190 	 * Returns the symbolic color that is mapped
191 	 * to name.
192 	 * Params:
193 	 * name = color name to lookup
194 	 * Returns: The mapped color. [transfer none] Since 3.0
195 	 */
196 	public SymbolicColor lookupColor(string name)
197 	{
198 		// GtkSymbolicColor * gtk_style_properties_lookup_color (GtkStyleProperties *props,  const gchar *name);
199 		auto p = gtk_style_properties_lookup_color(gtkStyleProperties, Str.toStringz(name));
200 		
201 		if(p is null)
202 		{
203 			return null;
204 		}
205 		
206 		return ObjectG.getDObject!(SymbolicColor)(cast(GtkSymbolicColor*) p);
207 	}
208 	
209 	/**
210 	 * Warning
211 	 * gtk_style_properties_lookup_property has been deprecated since version 3.8 and should not be used in newly-written code. This code could only look up custom properties and
212 	 *  those are deprecated.
213 	 * Returns TRUE if a property has been registered, if pspec or
214 	 * parse_func are not NULL, the GParamSpec and parsing function
215 	 * will be respectively returned.
216 	 * Params:
217 	 * propertyName = property name to look up
218 	 * parseFunc = return location for the parse function. [out]
219 	 * pspec = return location for the GParamSpec. [out][transfer none]
220 	 * Returns: TRUE if the property is registered, FALSE otherwise Since 3.0
221 	 */
222 	public static int lookupProperty(string propertyName, out GtkStylePropertyParser parseFunc, out ParamSpec pspec)
223 	{
224 		// gboolean gtk_style_properties_lookup_property  (const gchar *property_name,  GtkStylePropertyParser *parse_func,  GParamSpec **pspec);
225 		GParamSpec* outpspec = null;
226 		
227 		auto p = gtk_style_properties_lookup_property(Str.toStringz(propertyName), &parseFunc, &outpspec);
228 		
229 		pspec = ObjectG.getDObject!(ParamSpec)(outpspec);
230 		return p;
231 	}
232 	
233 	/**
234 	 * Warning
235 	 * gtk_style_properties_map_color has been deprecated since version 3.8 and should not be used in newly-written code. GtkSymbolicColor is deprecated.
236 	 * Maps color so it can be referenced by name. See
237 	 * gtk_style_properties_lookup_color()
238 	 * Params:
239 	 * name = color name
240 	 * color = GtkSymbolicColor to map name to
241 	 * Since 3.0
242 	 */
243 	public void mapColor(string name, SymbolicColor color)
244 	{
245 		// void gtk_style_properties_map_color (GtkStyleProperties *props,  const gchar *name,  GtkSymbolicColor *color);
246 		gtk_style_properties_map_color(gtkStyleProperties, Str.toStringz(name), (color is null) ? null : color.getSymbolicColorStruct());
247 	}
248 	
249 	/**
250 	 * Merges into props all the style information contained
251 	 * in props_to_merge. If replace is TRUE, the values
252 	 * will be overwritten, if it is FALSE, the older values
253 	 * will prevail.
254 	 * Params:
255 	 * props = a GtkStyleProperties
256 	 * propsToMerge = a second GtkStyleProperties
257 	 * replace = whether to replace values or not
258 	 * Since 3.0
259 	 */
260 	public void merge(StyleProperties propsToMerge, int replace)
261 	{
262 		// void gtk_style_properties_merge (GtkStyleProperties *props,  const GtkStyleProperties *props_to_merge,  gboolean replace);
263 		gtk_style_properties_merge(gtkStyleProperties, (propsToMerge is null) ? null : propsToMerge.getStylePropertiesStruct(), replace);
264 	}
265 	
266 	/**
267 	 * Returns a newly created GtkStyleProperties
268 	 * Throws: ConstructionException GTK+ fails to create the object.
269 	 */
270 	public this ()
271 	{
272 		// GtkStyleProperties * gtk_style_properties_new (void);
273 		auto p = gtk_style_properties_new();
274 		if(p is null)
275 		{
276 			throw new ConstructionException("null returned by gtk_style_properties_new()");
277 		}
278 		this(cast(GtkStyleProperties*) p);
279 	}
280 	
281 	/**
282 	 * Warning
283 	 * gtk_style_properties_register_property has been deprecated since version 3.8 and should not be used in newly-written code. Code should use the default properties provided by CSS.
284 	 * Registers a property so it can be used in the CSS file format.
285 	 * This function is the low-level equivalent of
286 	 * gtk_theming_engine_register_property(), if you are implementing
287 	 * a theming engine, you want to use that function instead.
288 	 * Params:
289 	 * parseFunc = parsing function to use, or NULL
290 	 * pspec = the GParamSpec for the new property
291 	 * Since 3.0
292 	 */
293 	public static void registerProperty(GtkStylePropertyParser parseFunc, ParamSpec pspec)
294 	{
295 		// void gtk_style_properties_register_property  (GtkStylePropertyParser parse_func,  GParamSpec *pspec);
296 		gtk_style_properties_register_property(parseFunc, (pspec is null) ? null : pspec.getParamSpecStruct());
297 	}
298 	
299 	/**
300 	 * Sets a styling property in props.
301 	 * Params:
302 	 * property = styling property to set
303 	 * state = state to set the value for
304 	 * value = new value for the property
305 	 * Since 3.0
306 	 */
307 	public void setStyleProperty(string property, GtkStateFlags state, Value value)
308 	{
309 		// void gtk_style_properties_set_property (GtkStyleProperties *props,  const gchar *property,  GtkStateFlags state,  const GValue *value);
310 		gtk_style_properties_set_property(gtkStyleProperties, Str.toStringz(property), state, (value is null) ? null : value.getValueStruct());
311 	}
312 	
313 	/**
314 	 * Sets several style properties on props.
315 	 * Params:
316 	 * state = state to set the values for
317 	 * args = va_list of property name/value pairs, followed by NULL
318 	 * Since 3.0
319 	 */
320 	public void setStyleValist(GtkStateFlags state, void* args)
321 	{
322 		// void gtk_style_properties_set_valist (GtkStyleProperties *props,  GtkStateFlags state,  va_list args);
323 		gtk_style_properties_set_valist(gtkStyleProperties, state, args);
324 	}
325 	
326 	/**
327 	 * Unsets a style property in props.
328 	 * Params:
329 	 * property = property to unset
330 	 * state = state to unset
331 	 * Since 3.0
332 	 */
333 	public void unsetProperty(string property, GtkStateFlags state)
334 	{
335 		// void gtk_style_properties_unset_property (GtkStyleProperties *props,  const gchar *property,  GtkStateFlags state);
336 		gtk_style_properties_unset_property(gtkStyleProperties, Str.toStringz(property), state);
337 	}
338 }