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