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  = GtkThemingEngine.html
27  * outPack = gtk
28  * outFile = ThemingEngine
29  * strct   = GtkThemingEngine
30  * realStrct=
31  * ctorStrct=
32  * clss    = ThemingEngine
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_theming_engine_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- core.vararg
47  * 	- glib.Str
48  * 	- gobject.ParamSpec
49  * 	- gobject.Value
50  * 	- gdk.RGBA
51  * 	- gdk.Screen
52  * 	- gtk.WidgetPath
53  * 	- pango.PgFontDescription
54  * structWrap:
55  * 	- GParamSpec* -> ParamSpec
56  * 	- GValue* -> Value
57  * 	- GdkRGBA* -> RGBA
58  * 	- GdkScreen* -> Screen
59  * 	- GtkThemingEngine* -> ThemingEngine
60  * 	- GtkWidgetPath* -> WidgetPath
61  * 	- PangoFontDescription* -> PgFontDescription
62  * module aliases:
63  * local aliases:
64  * overrides:
65  */
66 
67 module gtk.ThemingEngine;
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 gobject.ParamSpec;
78 private import gobject.Value;
79 private import gdk.RGBA;
80 private import gdk.Screen;
81 private import gtk.WidgetPath;
82 private import pango.PgFontDescription;
83 
84 
85 private import gobject.ObjectG;
86 
87 /**
88  * GtkThemingEngine is the object used for rendering themed content
89  * in GTK+ widgets. Even though GTK+ has a default implementation,
90  * it can be overridden in CSS files by enforcing a GtkThemingEngine
91  * object to be loaded as a module.
92  *
93  * In order to implement a theming engine, a GtkThemingEngine subclass
94  * must be created, alongside the CSS file that will reference it, the
95  * theming engine would be created as an .so library, and installed in
96  * $(gtk-modules-dir)/theming-engines/.
97  *
98  * GtkThemingEngines have limited access to the object they are
99  * rendering, the GtkThemingEngine API has read-only accessors to the
100  * style information contained in the rendered object's GtkStyleContext.
101  */
102 public class ThemingEngine : ObjectG
103 {
104 	
105 	/** the main Gtk struct */
106 	protected GtkThemingEngine* gtkThemingEngine;
107 	
108 	
109 	/** Get the main Gtk struct */
110 	public GtkThemingEngine* getThemingEngineStruct()
111 	{
112 		return gtkThemingEngine;
113 	}
114 	
115 	
116 	/** the main Gtk struct as a void* */
117 	protected override void* getStruct()
118 	{
119 		return cast(void*)gtkThemingEngine;
120 	}
121 	
122 	/**
123 	 * Sets our main struct and passes it to the parent class
124 	 */
125 	public this (GtkThemingEngine* gtkThemingEngine)
126 	{
127 		super(cast(GObject*)gtkThemingEngine);
128 		this.gtkThemingEngine = gtkThemingEngine;
129 	}
130 	
131 	protected override void setStruct(GObject* obj)
132 	{
133 		super.setStruct(obj);
134 		gtkThemingEngine = cast(GtkThemingEngine*)obj;
135 	}
136 	
137 	/**
138 	 */
139 	
140 	/**
141 	 * Warning
142 	 * gtk_theming_engine_get_direction has been deprecated since version 3.8 and should not be used in newly-written code. Use gtk_theming_engine_get_state() and
143 	 *  check for GTK_STATE_FLAG_DIR_LTR and
144 	 *  GTK_STATE_FLAG_DIR_RTL instead.
145 	 * Returns the widget direction used for rendering.
146 	 * Returns: the widget direction Since 3.0
147 	 */
148 	public GtkTextDirection getDirection()
149 	{
150 		// GtkTextDirection gtk_theming_engine_get_direction (GtkThemingEngine *engine);
151 		return gtk_theming_engine_get_direction(gtkThemingEngine);
152 	}
153 	
154 	/**
155 	 * Returns the widget direction used for rendering.
156 	 * Returns: the widget direction Since 3.0
157 	 */
158 	public GtkJunctionSides getJunctionSides()
159 	{
160 		// GtkJunctionSides gtk_theming_engine_get_junction_sides  (GtkThemingEngine *engine);
161 		return gtk_theming_engine_get_junction_sides(gtkThemingEngine);
162 	}
163 	
164 	/**
165 	 * Returns the widget path used for style matching.
166 	 * Returns: A GtkWidgetPath. [transfer none] Since 3.0
167 	 */
168 	public WidgetPath getPath()
169 	{
170 		// const GtkWidgetPath * gtk_theming_engine_get_path (GtkThemingEngine *engine);
171 		auto p = gtk_theming_engine_get_path(gtkThemingEngine);
172 		
173 		if(p is null)
174 		{
175 			return null;
176 		}
177 		
178 		return ObjectG.getDObject!(WidgetPath)(cast(GtkWidgetPath*) p);
179 	}
180 	
181 	/**
182 	 * Gets a property value as retrieved from the style settings that apply
183 	 * to the currently rendered element.
184 	 * Params:
185 	 * property = the property name
186 	 * state = state to retrieve the value for
187 	 * value = return location for the property value,
188 	 * you must free this memory using g_value_unset() once you are
189 	 * done with it. [out][transfer full]
190 	 * Since 3.0
191 	 */
192 	public void getProperty(string property, GtkStateFlags state, Value value)
193 	{
194 		// void gtk_theming_engine_get_property (GtkThemingEngine *engine,  const gchar *property,  GtkStateFlags state,  GValue *value);
195 		gtk_theming_engine_get_property(gtkThemingEngine, Str.toStringz(property), state, (value is null) ? null : value.getValueStruct());
196 	}
197 	
198 	/**
199 	 * Returns the GdkScreen to which engine currently rendering to.
200 	 * Returns: a GdkScreen, or NULL. [transfer none]
201 	 */
202 	public Screen getScreen()
203 	{
204 		// GdkScreen * gtk_theming_engine_get_screen (GtkThemingEngine *engine);
205 		auto p = gtk_theming_engine_get_screen(gtkThemingEngine);
206 		
207 		if(p is null)
208 		{
209 			return null;
210 		}
211 		
212 		return ObjectG.getDObject!(Screen)(cast(GdkScreen*) p);
213 	}
214 	
215 	/**
216 	 * returns the state used when rendering.
217 	 * Returns: the state flags Since 3.0
218 	 */
219 	public GtkStateFlags getState()
220 	{
221 		// GtkStateFlags gtk_theming_engine_get_state (GtkThemingEngine *engine);
222 		return gtk_theming_engine_get_state(gtkThemingEngine);
223 	}
224 	
225 	/**
226 	 * Gets the value for a widget style property.
227 	 * Params:
228 	 * propertyName = the name of the widget style property
229 	 * value = Return location for the property value, free with
230 	 * g_value_unset() after use.
231 	 * Since 3.0
232 	 */
233 	public void getStyleProperty(string propertyName, Value value)
234 	{
235 		// void gtk_theming_engine_get_style_property  (GtkThemingEngine *engine,  const gchar *property_name,  GValue *value);
236 		gtk_theming_engine_get_style_property(gtkThemingEngine, Str.toStringz(propertyName), (value is null) ? null : value.getValueStruct());
237 	}
238 	
239 	/**
240 	 * Retrieves several widget style properties from engine according to the
241 	 * currently rendered content's style.
242 	 * Params:
243 	 * args = va_list of property name/return location pairs, followed by NULL
244 	 * Since 3.0
245 	 */
246 	public void getStyleValist(void* args)
247 	{
248 		// void gtk_theming_engine_get_style_valist (GtkThemingEngine *engine,  va_list args);
249 		gtk_theming_engine_get_style_valist(gtkThemingEngine, args);
250 	}
251 	
252 	/**
253 	 * Retrieves several style property values that apply to the currently
254 	 * rendered element.
255 	 * Params:
256 	 * state = state to retrieve values for
257 	 * args = va_list of property name/return location pairs, followed by NULL
258 	 * Since 3.0
259 	 */
260 	public void getValist(GtkStateFlags state, void* args)
261 	{
262 		// void gtk_theming_engine_get_valist (GtkThemingEngine *engine,  GtkStateFlags state,  va_list args);
263 		gtk_theming_engine_get_valist(gtkThemingEngine, state, args);
264 	}
265 	
266 	/**
267 	 * Gets the foreground color for a given state.
268 	 * Params:
269 	 * state = state to retrieve the color for
270 	 * color = return value for the foreground color. [out]
271 	 * Since 3.0
272 	 */
273 	public void getColor(GtkStateFlags state, RGBA color)
274 	{
275 		// void gtk_theming_engine_get_color (GtkThemingEngine *engine,  GtkStateFlags state,  GdkRGBA *color);
276 		gtk_theming_engine_get_color(gtkThemingEngine, state, (color is null) ? null : color.getRGBAStruct());
277 	}
278 	
279 	/**
280 	 * Gets the background color for a given state.
281 	 * Params:
282 	 * state = state to retrieve the color for
283 	 * color = return value for the background color. [out]
284 	 * Since 3.0
285 	 */
286 	public void getBackgroundColor(GtkStateFlags state, RGBA color)
287 	{
288 		// void gtk_theming_engine_get_background_color  (GtkThemingEngine *engine,  GtkStateFlags state,  GdkRGBA *color);
289 		gtk_theming_engine_get_background_color(gtkThemingEngine, state, (color is null) ? null : color.getRGBAStruct());
290 	}
291 	
292 	/**
293 	 * Gets the border color for a given state.
294 	 * Params:
295 	 * state = state to retrieve the color for
296 	 * color = return value for the border color. [out]
297 	 * Since 3.0
298 	 */
299 	public void getBorderColor(GtkStateFlags state, RGBA color)
300 	{
301 		// void gtk_theming_engine_get_border_color (GtkThemingEngine *engine,  GtkStateFlags state,  GdkRGBA *color);
302 		gtk_theming_engine_get_border_color(gtkThemingEngine, state, (color is null) ? null : color.getRGBAStruct());
303 	}
304 	
305 	/**
306 	 * Gets the border for a given state as a GtkBorder.
307 	 * Params:
308 	 * state = state to retrieve the border for
309 	 * border = return value for the border settings. [out]
310 	 * Since 3.0
311 	 */
312 	public void getBorder(GtkStateFlags state, out GtkBorder border)
313 	{
314 		// void gtk_theming_engine_get_border (GtkThemingEngine *engine,  GtkStateFlags state,  GtkBorder *border);
315 		gtk_theming_engine_get_border(gtkThemingEngine, state, &border);
316 	}
317 	
318 	/**
319 	 * Gets the padding for a given state as a GtkBorder.
320 	 * Params:
321 	 * state = state to retrieve the padding for
322 	 * padding = return value for the padding settings. [out]
323 	 * Since 3.0
324 	 */
325 	public void getPadding(GtkStateFlags state, out GtkBorder padding)
326 	{
327 		// void gtk_theming_engine_get_padding (GtkThemingEngine *engine,  GtkStateFlags state,  GtkBorder *padding);
328 		gtk_theming_engine_get_padding(gtkThemingEngine, state, &padding);
329 	}
330 	
331 	/**
332 	 * Gets the margin for a given state as a GtkBorder.
333 	 * Params:
334 	 * state = state to retrieve the border for
335 	 * margin = return value for the margin settings. [out]
336 	 * Since 3.0
337 	 */
338 	public void getMargin(GtkStateFlags state, out GtkBorder margin)
339 	{
340 		// void gtk_theming_engine_get_margin (GtkThemingEngine *engine,  GtkStateFlags state,  GtkBorder *margin);
341 		gtk_theming_engine_get_margin(gtkThemingEngine, state, &margin);
342 	}
343 	
344 	/**
345 	 * Warning
346 	 * gtk_theming_engine_get_font has been deprecated since version 3.8 and should not be used in newly-written code. Use gtk_theming_engine_get()
347 	 * Returns the font description for a given state.
348 	 * Params:
349 	 * state = state to retrieve the font for
350 	 * Returns: the PangoFontDescription for the given state. This object is owned by GTK+ and should not be freed. [transfer none] Since 3.0
351 	 */
352 	public PgFontDescription getFont(GtkStateFlags state)
353 	{
354 		// const PangoFontDescription * gtk_theming_engine_get_font  (GtkThemingEngine *engine,  GtkStateFlags state);
355 		auto p = gtk_theming_engine_get_font(gtkThemingEngine, state);
356 		
357 		if(p is null)
358 		{
359 			return null;
360 		}
361 		
362 		return ObjectG.getDObject!(PgFontDescription)(cast(PangoFontDescription*) p);
363 	}
364 	
365 	/**
366 	 * Returns TRUE if the currently rendered contents have
367 	 * defined the given class name.
368 	 * Params:
369 	 * styleClass = class name to look up
370 	 * Returns: TRUE if engine has class_name defined Since 3.0
371 	 */
372 	public int hasClass(string styleClass)
373 	{
374 		// gboolean gtk_theming_engine_has_class (GtkThemingEngine *engine,  const gchar *style_class);
375 		return gtk_theming_engine_has_class(gtkThemingEngine, Str.toStringz(styleClass));
376 	}
377 	
378 	/**
379 	 * Returns TRUE if the currently rendered contents have the
380 	 * region defined. If flags_return is not NULL, it is set
381 	 * to the flags affecting the region.
382 	 * Params:
383 	 * styleRegion = a region name
384 	 * flags = return location for region flags. [out][allow-none]
385 	 * Returns: TRUE if region is defined Since 3.0
386 	 */
387 	public int hasRegion(string styleRegion, out GtkRegionFlags flags)
388 	{
389 		// gboolean gtk_theming_engine_has_region (GtkThemingEngine *engine,  const gchar *style_region,  GtkRegionFlags *flags);
390 		return gtk_theming_engine_has_region(gtkThemingEngine, Str.toStringz(styleRegion), &flags);
391 	}
392 	
393 	/**
394 	 * Looks up and resolves a color name in the current style's color map.
395 	 * Params:
396 	 * colorName = color name to lookup
397 	 * color = Return location for the looked up color. [out]
398 	 * Returns: TRUE if color_name was found and resolved, FALSE otherwise
399 	 */
400 	public int lookupColor(string colorName, RGBA color)
401 	{
402 		// gboolean gtk_theming_engine_lookup_color (GtkThemingEngine *engine,  const gchar *color_name,  GdkRGBA *color);
403 		return gtk_theming_engine_lookup_color(gtkThemingEngine, Str.toStringz(colorName), (color is null) ? null : color.getRGBAStruct());
404 	}
405 	
406 	/**
407 	 * Warning
408 	 * gtk_theming_engine_state_is_running has been deprecated since version 3.6 and should not be used in newly-written code. Always returns FALSE
409 	 * Returns TRUE if there is a transition animation running for the
410 	 * current region (see gtk_style_context_push_animatable_region()).
411 	 * If progress is not NULL, the animation progress will be returned
412 	 * there, 0.0 means the state is closest to being FALSE, while 1.0 means
413 	 * it's closest to being TRUE. This means transition animations will
414 	 * run from 0 to 1 when state is being set to TRUE and from 1 to 0 when
415 	 * it's being set to FALSE.
416 	 * Params:
417 	 * state = a widget state
418 	 * progress = return location for the transition progress. [out]
419 	 * Returns: TRUE if there is a running transition animation for state. Since 3.0
420 	 */
421 	public int stateIsRunning(GtkStateType state, out double progress)
422 	{
423 		// gboolean gtk_theming_engine_state_is_running (GtkThemingEngine *engine,  GtkStateType state,  gdouble *progress);
424 		return gtk_theming_engine_state_is_running(gtkThemingEngine, state, &progress);
425 	}
426 	
427 	/**
428 	 * Loads and initializes a theming engine module from the
429 	 * standard directories.
430 	 * Params:
431 	 * name = Theme engine name to load
432 	 * Returns: A theming engine, or NULL if the engine name doesn't exist. [transfer none]
433 	 */
434 	public static ThemingEngine load(string name)
435 	{
436 		// GtkThemingEngine * gtk_theming_engine_load (const gchar *name);
437 		auto p = gtk_theming_engine_load(Str.toStringz(name));
438 		
439 		if(p is null)
440 		{
441 			return null;
442 		}
443 		
444 		return ObjectG.getDObject!(ThemingEngine)(cast(GtkThemingEngine*) p);
445 	}
446 	
447 	/**
448 	 * Warning
449 	 * gtk_theming_engine_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.
450 	 * Registers a property so it can be used in the CSS file format,
451 	 * on the CSS file the property will look like
452 	 * "-${name_space}-${property_name}". being
453 	 * ${property_name} the given to pspec. name_space will usually
454 	 * be the theme engine name.
455 	 * For any type a parse_func may be provided, being this function
456 	 * used for turning any property value (between ':' and ';') in
457 	 * CSS to the GValue needed. For basic types there is already
458 	 * builtin parsing support, so NULL may be provided for these
459 	 * cases.
460 	 * Note
461 	 * Engines must ensure property registration happens exactly once,
462 	 * usually GTK+ deals with theming engines as singletons, so this
463 	 * should be guaranteed to happen once, but bear this in mind
464 	 * when creating GtkThemeEngines yourself.
465 	 * Note
466 	 * In order to make use of the custom registered properties in
467 	 * the CSS file, make sure the engine is loaded first by specifying
468 	 * the engine property, either in a previous rule or within the same
469 	 * one.
470 	 * * {
471 		 *  engine: someengine;
472 		 *  -SomeEngine-custom-property: 2;
473 	 * }
474 	 * Params:
475 	 * nameSpace = namespace for the property name
476 	 * parseFunc = parsing function to use, or NULL
477 	 * pspec = the GParamSpec for the new property
478 	 * Since 3.0
479 	 */
480 	public static void registerProperty(string nameSpace, GtkStylePropertyParser parseFunc, ParamSpec pspec)
481 	{
482 		// void gtk_theming_engine_register_property  (const gchar *name_space,  GtkStylePropertyParser parse_func,  GParamSpec *pspec);
483 		gtk_theming_engine_register_property(Str.toStringz(nameSpace), parseFunc, (pspec is null) ? null : pspec.getParamSpecStruct());
484 	}
485 }