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