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