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