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