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