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