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