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