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.StyleContext; 26 27 private import cairo.Context; 28 private import cairo.Surface; 29 private import gdk.FrameClock; 30 private import gdk.RGBA; 31 private import gdk.Screen; 32 private import gdk.Window; 33 private import gdkpixbuf.Pixbuf; 34 private import glib.ConstructionException; 35 private import glib.ListG; 36 private import glib.Str; 37 private import gobject.ObjectG; 38 private import gobject.Signals; 39 private import gobject.Value; 40 private import gtk.Border; 41 private import gtk.CssSection; 42 private import gtk.IconSet; 43 private import gtk.IconSource; 44 private import gtk.StyleProviderIF; 45 private import gtk.WidgetPath; 46 private import gtkc.gtk; 47 public import gtkc.gtktypes; 48 private import pango.PgFontDescription; 49 private import pango.PgLayout; 50 private import std.algorithm; 51 52 53 /** 54 * #GtkStyleContext is an object that stores styling information affecting 55 * a widget defined by #GtkWidgetPath. 56 * 57 * In order to construct the final style information, #GtkStyleContext 58 * queries information from all attached #GtkStyleProviders. Style providers 59 * can be either attached explicitly to the context through 60 * gtk_style_context_add_provider(), or to the screen through 61 * gtk_style_context_add_provider_for_screen(). The resulting style is a 62 * combination of all providers’ information in priority order. 63 * 64 * For GTK+ widgets, any #GtkStyleContext returned by 65 * gtk_widget_get_style_context() will already have a #GtkWidgetPath, a 66 * #GdkScreen and RTL/LTR information set. The style context will also be 67 * updated automatically if any of these settings change on the widget. 68 * 69 * If you are using the theming layer standalone, you will need to set a 70 * widget path and a screen yourself to the created style context through 71 * gtk_style_context_set_path() and gtk_style_context_set_screen(), as well 72 * as updating the context yourself using gtk_style_context_invalidate() 73 * whenever any of the conditions change, such as a change in the 74 * #GtkSettings:gtk-theme-name setting or a hierarchy change in the rendered 75 * widget. See the “Foreign drawing“ example in gtk3-demo. 76 * 77 * # Style Classes # {#gtkstylecontext-classes} 78 * 79 * Widgets can add style classes to their context, which can be used to associate 80 * different styles by class. The documentation for individual widgets lists 81 * which style classes it uses itself, and which style classes may be added by 82 * applications to affect their appearance. 83 * 84 * GTK+ defines macros for a number of style classes. 85 * 86 * # Style Regions 87 * 88 * Widgets can also add regions with flags to their context. This feature is 89 * deprecated and will be removed in a future GTK+ update. Please use style 90 * classes instead. 91 * 92 * GTK+ defines macros for a number of style regions. 93 * 94 * # Custom styling in UI libraries and applications 95 * 96 * If you are developing a library with custom #GtkWidgets that 97 * render differently than standard components, you may need to add a 98 * #GtkStyleProvider yourself with the %GTK_STYLE_PROVIDER_PRIORITY_FALLBACK 99 * priority, either a #GtkCssProvider or a custom object implementing the 100 * #GtkStyleProvider interface. This way themes may still attempt 101 * to style your UI elements in a different way if needed so. 102 * 103 * If you are using custom styling on an applications, you probably want then 104 * to make your style information prevail to the theme’s, so you must use 105 * a #GtkStyleProvider with the %GTK_STYLE_PROVIDER_PRIORITY_APPLICATION 106 * priority, keep in mind that the user settings in 107 * `XDG_CONFIG_HOME/gtk-3.0/gtk.css` will 108 * still take precedence over your changes, as it uses the 109 * %GTK_STYLE_PROVIDER_PRIORITY_USER priority. 110 */ 111 public class StyleContext : ObjectG 112 { 113 /** the main Gtk struct */ 114 protected GtkStyleContext* gtkStyleContext; 115 116 /** Get the main Gtk struct */ 117 public GtkStyleContext* getStyleContextStruct() 118 { 119 return gtkStyleContext; 120 } 121 122 /** the main Gtk struct as a void* */ 123 protected override void* getStruct() 124 { 125 return cast(void*)gtkStyleContext; 126 } 127 128 protected override void setStruct(GObject* obj) 129 { 130 gtkStyleContext = cast(GtkStyleContext*)obj; 131 super.setStruct(obj); 132 } 133 134 /** 135 * Sets our main struct and passes it to the parent class. 136 */ 137 public this (GtkStyleContext* gtkStyleContext, bool ownedRef = false) 138 { 139 this.gtkStyleContext = gtkStyleContext; 140 super(cast(GObject*)gtkStyleContext, ownedRef); 141 } 142 143 144 /** */ 145 public static GType getType() 146 { 147 return gtk_style_context_get_type(); 148 } 149 150 /** 151 * Creates a standalone #GtkStyleContext, this style context 152 * won’t be attached to any widget, so you may want 153 * to call gtk_style_context_set_path() yourself. 154 * 155 * This function is only useful when using the theming layer 156 * separated from GTK+, if you are using #GtkStyleContext to 157 * theme #GtkWidgets, use gtk_widget_get_style_context() 158 * in order to get a style context ready to theme the widget. 159 * 160 * Returns: A newly created #GtkStyleContext. 161 * 162 * Throws: ConstructionException GTK+ fails to create the object. 163 */ 164 public this() 165 { 166 auto p = gtk_style_context_new(); 167 168 if(p is null) 169 { 170 throw new ConstructionException("null returned by new"); 171 } 172 173 this(cast(GtkStyleContext*) p, true); 174 } 175 176 /** 177 * Adds a global style provider to @screen, which will be used 178 * in style construction for all #GtkStyleContexts under @screen. 179 * 180 * GTK+ uses this to make styling information from #GtkSettings 181 * available. 182 * 183 * Note: If both priorities are the same, A #GtkStyleProvider 184 * added through gtk_style_context_add_provider() takes precedence 185 * over another added through this function. 186 * 187 * Params: 188 * screen = a #GdkScreen 189 * provider = a #GtkStyleProvider 190 * priority = the priority of the style provider. The lower 191 * it is, the earlier it will be used in the style 192 * construction. Typically this will be in the range 193 * between %GTK_STYLE_PROVIDER_PRIORITY_FALLBACK and 194 * %GTK_STYLE_PROVIDER_PRIORITY_USER 195 * 196 * Since: 3.0 197 */ 198 public static void addProviderForScreen(Screen screen, StyleProviderIF provider, uint priority) 199 { 200 gtk_style_context_add_provider_for_screen((screen is null) ? null : screen.getScreenStruct(), (provider is null) ? null : provider.getStyleProviderStruct(), priority); 201 } 202 203 /** 204 * Removes @provider from the global style providers list in @screen. 205 * 206 * Params: 207 * screen = a #GdkScreen 208 * provider = a #GtkStyleProvider 209 * 210 * Since: 3.0 211 */ 212 public static void removeProviderForScreen(Screen screen, StyleProviderIF provider) 213 { 214 gtk_style_context_remove_provider_for_screen((screen is null) ? null : screen.getScreenStruct(), (provider is null) ? null : provider.getStyleProviderStruct()); 215 } 216 217 /** 218 * This function recomputes the styles for all widgets under a particular 219 * #GdkScreen. This is useful when some global parameter has changed that 220 * affects the appearance of all widgets, because when a widget gets a new 221 * style, it will both redraw and recompute any cached information about 222 * its appearance. As an example, it is used when the color scheme changes 223 * in the related #GtkSettings object. 224 * 225 * Params: 226 * screen = a #GdkScreen 227 * 228 * Since: 3.0 229 */ 230 public static void resetWidgets(Screen screen) 231 { 232 gtk_style_context_reset_widgets((screen is null) ? null : screen.getScreenStruct()); 233 } 234 235 /** 236 * Adds a style class to @context, so posterior calls to 237 * gtk_style_context_get() or any of the gtk_render_*() 238 * functions will make use of this new class for styling. 239 * 240 * In the CSS file format, a #GtkEntry defining a “search” 241 * class, would be matched by: 242 * 243 * |[ 244 * entry.search { ... } 245 * ]| 246 * 247 * While any widget defining a “search” class would be 248 * matched by: 249 * |[ 250 * .search { ... } 251 * ]| 252 * 253 * Params: 254 * className = class name to use in styling 255 * 256 * Since: 3.0 257 */ 258 public void addClass(string className) 259 { 260 gtk_style_context_add_class(gtkStyleContext, Str.toStringz(className)); 261 } 262 263 /** 264 * Adds a style provider to @context, to be used in style construction. 265 * Note that a style provider added by this function only affects 266 * the style of the widget to which @context belongs. If you want 267 * to affect the style of all widgets, use 268 * gtk_style_context_add_provider_for_screen(). 269 * 270 * Note: If both priorities are the same, a #GtkStyleProvider 271 * added through this function takes precedence over another added 272 * through gtk_style_context_add_provider_for_screen(). 273 * 274 * Params: 275 * provider = a #GtkStyleProvider 276 * priority = the priority of the style provider. The lower 277 * it is, the earlier it will be used in the style 278 * construction. Typically this will be in the range 279 * between %GTK_STYLE_PROVIDER_PRIORITY_FALLBACK and 280 * %GTK_STYLE_PROVIDER_PRIORITY_USER 281 * 282 * Since: 3.0 283 */ 284 public void addProvider(StyleProviderIF provider, uint priority) 285 { 286 gtk_style_context_add_provider(gtkStyleContext, (provider is null) ? null : provider.getStyleProviderStruct(), priority); 287 } 288 289 /** 290 * Adds a region to @context, so posterior calls to 291 * gtk_style_context_get() or any of the gtk_render_*() 292 * functions will make use of this new region for styling. 293 * 294 * In the CSS file format, a #GtkTreeView defining a “row” 295 * region, would be matched by: 296 * 297 * |[ 298 * GtkTreeView row { ... } 299 * ]| 300 * 301 * Pseudo-classes are used for matching @flags, so the two 302 * following rules: 303 * |[ 304 * GtkTreeView row:nth-child(even) { ... } 305 * GtkTreeView row:nth-child(odd) { ... } 306 * ]| 307 * 308 * would apply to even and odd rows, respectively. 309 * 310 * Region names must only contain lowercase letters 311 * and “-”, starting always with a lowercase letter. 312 * 313 * Params: 314 * regionName = region name to use in styling 315 * flags = flags that apply to the region 316 * 317 * Since: 3.0 318 */ 319 public void addRegion(string regionName, GtkRegionFlags flags) 320 { 321 gtk_style_context_add_region(gtkStyleContext, Str.toStringz(regionName), flags); 322 } 323 324 /** 325 * Stops all running animations for @region_id and all animatable 326 * regions underneath. 327 * 328 * A %NULL @region_id will stop all ongoing animations in @context, 329 * when dealing with a #GtkStyleContext obtained through 330 * gtk_widget_get_style_context(), this is normally done for you 331 * in all circumstances you would expect all widget to be stopped, 332 * so this should be only used in complex widgets with different 333 * animatable regions. 334 * 335 * Deprecated: This function does nothing. 336 * 337 * Params: 338 * regionId = animatable region to stop, or %NULL. 339 * See gtk_style_context_push_animatable_region() 340 * 341 * Since: 3.0 342 */ 343 public void cancelAnimations(void* regionId) 344 { 345 gtk_style_context_cancel_animations(gtkStyleContext, regionId); 346 } 347 348 /** 349 * Gets the background color for a given state. 350 * 351 * This function is far less useful than it seems, and it should not be used in 352 * newly written code. CSS has no concept of "background color", as a background 353 * can be an image, or a gradient, or any other pattern including solid colors. 354 * 355 * The only reason why you would call gtk_style_context_get_background_color() is 356 * to use the returned value to draw the background with it; the correct way to 357 * achieve this result is to use gtk_render_background() instead, along with CSS 358 * style classes to modify the color to be rendered. 359 * 360 * Deprecated: Use gtk_render_background() instead. 361 * 362 * Params: 363 * state = state to retrieve the color for 364 * color = return value for the background color 365 * 366 * Since: 3.0 367 */ 368 public void getBackgroundColor(GtkStateFlags state, out RGBA color) 369 { 370 GdkRGBA* outcolor = gMalloc!GdkRGBA(); 371 372 gtk_style_context_get_background_color(gtkStyleContext, state, outcolor); 373 374 color = ObjectG.getDObject!(RGBA)(outcolor, true); 375 } 376 377 /** 378 * Gets the border for a given state as a #GtkBorder. 379 * 380 * See gtk_style_context_get_property() and 381 * #GTK_STYLE_PROPERTY_BORDER_WIDTH for details. 382 * 383 * Params: 384 * state = state to retrieve the border for 385 * border = return value for the border settings 386 * 387 * Since: 3.0 388 */ 389 public void getBorder(GtkStateFlags state, out Border border) 390 { 391 GtkBorder* outborder = gMalloc!GtkBorder(); 392 393 gtk_style_context_get_border(gtkStyleContext, state, outborder); 394 395 border = ObjectG.getDObject!(Border)(outborder, true); 396 } 397 398 /** 399 * Gets the border color for a given state. 400 * 401 * Deprecated: Use gtk_render_frame() instead. 402 * 403 * Params: 404 * state = state to retrieve the color for 405 * color = return value for the border color 406 * 407 * Since: 3.0 408 */ 409 public void getBorderColor(GtkStateFlags state, out RGBA color) 410 { 411 GdkRGBA* outcolor = gMalloc!GdkRGBA(); 412 413 gtk_style_context_get_border_color(gtkStyleContext, state, outcolor); 414 415 color = ObjectG.getDObject!(RGBA)(outcolor, true); 416 } 417 418 /** 419 * Gets the foreground color for a given state. 420 * 421 * See gtk_style_context_get_property() and 422 * #GTK_STYLE_PROPERTY_COLOR for details. 423 * 424 * Params: 425 * state = state to retrieve the color for 426 * color = return value for the foreground color 427 * 428 * Since: 3.0 429 */ 430 public void getColor(GtkStateFlags state, out RGBA color) 431 { 432 GdkRGBA* outcolor = gMalloc!GdkRGBA(); 433 434 gtk_style_context_get_color(gtkStyleContext, state, outcolor); 435 436 color = ObjectG.getDObject!(RGBA)(outcolor, true); 437 } 438 439 /** 440 * Returns the widget direction used for rendering. 441 * 442 * Deprecated: Use gtk_style_context_get_state() and 443 * check for #GTK_STATE_FLAG_DIR_LTR and 444 * #GTK_STATE_FLAG_DIR_RTL instead. 445 * 446 * Returns: the widget direction 447 * 448 * Since: 3.0 449 */ 450 public GtkTextDirection getDirection() 451 { 452 return gtk_style_context_get_direction(gtkStyleContext); 453 } 454 455 /** 456 * Returns the font description for a given state. The returned 457 * object is const and will remain valid until the 458 * #GtkStyleContext::changed signal happens. 459 * 460 * Deprecated: Use gtk_style_context_get() for "font" or 461 * subproperties instead. 462 * 463 * Params: 464 * state = state to retrieve the font for 465 * 466 * Returns: the #PangoFontDescription for the given 467 * state. This object is owned by GTK+ and should not be 468 * freed. 469 * 470 * Since: 3.0 471 */ 472 public PgFontDescription getFont(GtkStateFlags state) 473 { 474 auto p = gtk_style_context_get_font(gtkStyleContext, state); 475 476 if(p is null) 477 { 478 return null; 479 } 480 481 return ObjectG.getDObject!(PgFontDescription)(cast(PangoFontDescription*) p); 482 } 483 484 /** 485 * Returns the #GdkFrameClock to which @context is attached. 486 * 487 * Returns: a #GdkFrameClock, or %NULL 488 * if @context does not have an attached frame clock. 489 * 490 * Since: 3.8 491 */ 492 public FrameClock getFrameClock() 493 { 494 auto p = gtk_style_context_get_frame_clock(gtkStyleContext); 495 496 if(p is null) 497 { 498 return null; 499 } 500 501 return ObjectG.getDObject!(FrameClock)(cast(GdkFrameClock*) p); 502 } 503 504 /** 505 * Returns the sides where rendered elements connect visually with others. 506 * 507 * Returns: the junction sides 508 * 509 * Since: 3.0 510 */ 511 public GtkJunctionSides getJunctionSides() 512 { 513 return gtk_style_context_get_junction_sides(gtkStyleContext); 514 } 515 516 /** 517 * Gets the margin for a given state as a #GtkBorder. 518 * See gtk_style_property_get() and #GTK_STYLE_PROPERTY_MARGIN 519 * for details. 520 * 521 * Params: 522 * state = state to retrieve the border for 523 * margin = return value for the margin settings 524 * 525 * Since: 3.0 526 */ 527 public void getMargin(GtkStateFlags state, out Border margin) 528 { 529 GtkBorder* outmargin = gMalloc!GtkBorder(); 530 531 gtk_style_context_get_margin(gtkStyleContext, state, outmargin); 532 533 margin = ObjectG.getDObject!(Border)(outmargin, true); 534 } 535 536 /** 537 * Gets the padding for a given state as a #GtkBorder. 538 * See gtk_style_context_get() and #GTK_STYLE_PROPERTY_PADDING 539 * for details. 540 * 541 * Params: 542 * state = state to retrieve the padding for 543 * padding = return value for the padding settings 544 * 545 * Since: 3.0 546 */ 547 public void getPadding(GtkStateFlags state, out Border padding) 548 { 549 GtkBorder* outpadding = gMalloc!GtkBorder(); 550 551 gtk_style_context_get_padding(gtkStyleContext, state, outpadding); 552 553 padding = ObjectG.getDObject!(Border)(outpadding, true); 554 } 555 556 /** 557 * Gets the parent context set via gtk_style_context_set_parent(). 558 * See that function for details. 559 * 560 * Returns: the parent context or %NULL 561 * 562 * Since: 3.4 563 */ 564 public StyleContext getParent() 565 { 566 auto p = gtk_style_context_get_parent(gtkStyleContext); 567 568 if(p is null) 569 { 570 return null; 571 } 572 573 return ObjectG.getDObject!(StyleContext)(cast(GtkStyleContext*) p); 574 } 575 576 /** 577 * Returns the widget path used for style matching. 578 * 579 * Returns: A #GtkWidgetPath 580 * 581 * Since: 3.0 582 */ 583 public WidgetPath getPath() 584 { 585 auto p = gtk_style_context_get_path(gtkStyleContext); 586 587 if(p is null) 588 { 589 return null; 590 } 591 592 return ObjectG.getDObject!(WidgetPath)(cast(GtkWidgetPath*) p); 593 } 594 595 /** 596 * Gets a style property from @context for the given state. 597 * 598 * Note that not all CSS properties that are supported by GTK+ can be 599 * retrieved in this way, since they may not be representable as #GValue. 600 * GTK+ defines macros for a number of properties that can be used 601 * with this function. 602 * 603 * Note that passing a state other than the current state of @context 604 * is not recommended unless the style context has been saved with 605 * gtk_style_context_save(). 606 * 607 * When @value is no longer needed, g_value_unset() must be called 608 * to free any allocated memory. 609 * 610 * Params: 611 * property = style property name 612 * state = state to retrieve the property value for 613 * value = return location for the style property value 614 * 615 * Since: 3.0 616 */ 617 public void getProperty(string property, GtkStateFlags state, out Value value) 618 { 619 GValue* outvalue = gMalloc!GValue(); 620 621 gtk_style_context_get_property(gtkStyleContext, Str.toStringz(property), state, outvalue); 622 623 value = ObjectG.getDObject!(Value)(outvalue, true); 624 } 625 626 /** 627 * Returns the scale used for assets. 628 * 629 * Returns: the scale 630 * 631 * Since: 3.10 632 */ 633 public int getScale() 634 { 635 return gtk_style_context_get_scale(gtkStyleContext); 636 } 637 638 /** 639 * Returns the #GdkScreen to which @context is attached. 640 * 641 * Returns: a #GdkScreen. 642 */ 643 public Screen getScreen() 644 { 645 auto p = gtk_style_context_get_screen(gtkStyleContext); 646 647 if(p is null) 648 { 649 return null; 650 } 651 652 return ObjectG.getDObject!(Screen)(cast(GdkScreen*) p); 653 } 654 655 /** 656 * Queries the location in the CSS where @property was defined for the 657 * current @context. Note that the state to be queried is taken from 658 * gtk_style_context_get_state(). 659 * 660 * If the location is not available, %NULL will be returned. The 661 * location might not be available for various reasons, such as the 662 * property being overridden, @property not naming a supported CSS 663 * property or tracking of definitions being disabled for performance 664 * reasons. 665 * 666 * Shorthand CSS properties cannot be queried for a location and will 667 * always return %NULL. 668 * 669 * Params: 670 * property = style property name 671 * 672 * Returns: %NULL or the section where a value 673 * for @property was defined 674 */ 675 public CssSection getSection(string property) 676 { 677 auto p = gtk_style_context_get_section(gtkStyleContext, Str.toStringz(property)); 678 679 if(p is null) 680 { 681 return null; 682 } 683 684 return ObjectG.getDObject!(CssSection)(cast(GtkCssSection*) p); 685 } 686 687 /** 688 * Returns the state used for style matching. 689 * 690 * This method should only be used to retrieve the #GtkStateFlags 691 * to pass to #GtkStyleContext methods, like gtk_style_context_get_padding(). 692 * If you need to retrieve the current state of a #GtkWidget, use 693 * gtk_widget_get_state_flags(). 694 * 695 * Returns: the state flags 696 * 697 * Since: 3.0 698 */ 699 public GtkStateFlags getState() 700 { 701 return gtk_style_context_get_state(gtkStyleContext); 702 } 703 704 /** 705 * Gets the value for a widget style property. 706 * 707 * When @value is no longer needed, g_value_unset() must be called 708 * to free any allocated memory. 709 * 710 * Params: 711 * propertyName = the name of the widget style property 712 * value = Return location for the property value 713 */ 714 public void getStyleProperty(string propertyName, Value value) 715 { 716 gtk_style_context_get_style_property(gtkStyleContext, Str.toStringz(propertyName), (value is null) ? null : value.getValueStruct()); 717 } 718 719 /** 720 * Retrieves several widget style properties from @context according to the 721 * current style. 722 * 723 * Params: 724 * args = va_list of property name/return location pairs, followed by %NULL 725 * 726 * Since: 3.0 727 */ 728 public void getStyleValist(void* args) 729 { 730 gtk_style_context_get_style_valist(gtkStyleContext, args); 731 } 732 733 /** 734 * Retrieves several style property values from @context for a given state. 735 * 736 * See gtk_style_context_get_property() for details. 737 * 738 * Params: 739 * state = state to retrieve the property values for 740 * args = va_list of property name/return location pairs, followed by %NULL 741 * 742 * Since: 3.0 743 */ 744 public void getValist(GtkStateFlags state, void* args) 745 { 746 gtk_style_context_get_valist(gtkStyleContext, state, args); 747 } 748 749 /** 750 * Returns %TRUE if @context currently has defined the 751 * given class name. 752 * 753 * Params: 754 * className = a class name 755 * 756 * Returns: %TRUE if @context has @class_name defined 757 * 758 * Since: 3.0 759 */ 760 public bool hasClass(string className) 761 { 762 return gtk_style_context_has_class(gtkStyleContext, Str.toStringz(className)) != 0; 763 } 764 765 /** 766 * Returns %TRUE if @context has the region defined. 767 * If @flags_return is not %NULL, it is set to the flags 768 * affecting the region. 769 * 770 * Params: 771 * regionName = a region name 772 * flagsReturn = return location for region flags 773 * 774 * Returns: %TRUE if region is defined 775 * 776 * Since: 3.0 777 */ 778 public bool hasRegion(string regionName, out GtkRegionFlags flagsReturn) 779 { 780 return gtk_style_context_has_region(gtkStyleContext, Str.toStringz(regionName), &flagsReturn) != 0; 781 } 782 783 /** 784 * Invalidates @context style information, so it will be reconstructed 785 * again. It is useful if you modify the @context and need the new 786 * information immediately. 787 * 788 * Deprecated: Style contexts are invalidated automatically. 789 * 790 * Since: 3.0 791 */ 792 public void invalidate() 793 { 794 gtk_style_context_invalidate(gtkStyleContext); 795 } 796 797 /** 798 * Returns the list of classes currently defined in @context. 799 * 800 * Returns: a #GList of 801 * strings with the currently defined classes. The contents 802 * of the list are owned by GTK+, but you must free the list 803 * itself with g_list_free() when you are done with it. 804 * 805 * Since: 3.0 806 */ 807 public ListG listClasses() 808 { 809 auto p = gtk_style_context_list_classes(gtkStyleContext); 810 811 if(p is null) 812 { 813 return null; 814 } 815 816 return new ListG(cast(GList*) p); 817 } 818 819 /** 820 * Returns the list of regions currently defined in @context. 821 * 822 * Returns: a #GList of 823 * strings with the currently defined regions. The contents 824 * of the list are owned by GTK+, but you must free the list 825 * itself with g_list_free() when you are done with it. 826 * 827 * Since: 3.0 828 */ 829 public ListG listRegions() 830 { 831 auto p = gtk_style_context_list_regions(gtkStyleContext); 832 833 if(p is null) 834 { 835 return null; 836 } 837 838 return new ListG(cast(GList*) p); 839 } 840 841 /** 842 * Looks up and resolves a color name in the @context color map. 843 * 844 * Params: 845 * colorName = color name to lookup 846 * color = Return location for the looked up color 847 * 848 * Returns: %TRUE if @color_name was found and resolved, %FALSE otherwise 849 */ 850 public bool lookupColor(string colorName, out RGBA color) 851 { 852 GdkRGBA* outcolor = gMalloc!GdkRGBA(); 853 854 auto p = gtk_style_context_lookup_color(gtkStyleContext, Str.toStringz(colorName), outcolor) != 0; 855 856 color = ObjectG.getDObject!(RGBA)(outcolor, true); 857 858 return p; 859 } 860 861 /** 862 * Looks up @stock_id in the icon factories associated to @context and 863 * the default icon factory, returning an icon set if found, otherwise 864 * %NULL. 865 * 866 * Deprecated: Use gtk_icon_theme_lookup_icon() instead. 867 * 868 * Params: 869 * stockId = an icon name 870 * 871 * Returns: The looked up %GtkIconSet, or %NULL 872 */ 873 public IconSet lookupIconSet(string stockId) 874 { 875 auto p = gtk_style_context_lookup_icon_set(gtkStyleContext, Str.toStringz(stockId)); 876 877 if(p is null) 878 { 879 return null; 880 } 881 882 return ObjectG.getDObject!(IconSet)(cast(GtkIconSet*) p); 883 } 884 885 /** 886 * Notifies a state change on @context, so if the current style makes use 887 * of transition animations, one will be started so all rendered elements 888 * under @region_id are animated for state @state being set to value 889 * @state_value. 890 * 891 * The @window parameter is used in order to invalidate the rendered area 892 * as the animation runs, so make sure it is the same window that is being 893 * rendered on by the gtk_render_*() functions. 894 * 895 * If @region_id is %NULL, all rendered elements using @context will be 896 * affected by this state transition. 897 * 898 * As a practical example, a #GtkButton notifying a state transition on 899 * the prelight state: 900 * |[<!-- language="C" --> 901 * gtk_style_context_notify_state_change (context, 902 * gtk_widget_get_window (widget), 903 * NULL, 904 * GTK_STATE_PRELIGHT, 905 * button->in_button); 906 * ]| 907 * 908 * Can be handled in the CSS file like this: 909 * |[ 910 * GtkButton { 911 * background-color: #f00 912 * } 913 * 914 * GtkButton:hover { 915 * background-color: #fff; 916 * transition: 200ms linear 917 * } 918 * ]| 919 * 920 * This combination will animate the button background from red to white 921 * if a pointer enters the button, and back to red if the pointer leaves 922 * the button. 923 * 924 * Note that @state is used when finding the transition parameters, which 925 * is why the style places the transition under the :hover pseudo-class. 926 * 927 * Deprecated: This function does nothing. 928 * 929 * Params: 930 * window = a #GdkWindow 931 * regionId = animatable region to notify on, or %NULL. 932 * See gtk_style_context_push_animatable_region() 933 * state = state to trigger transition for 934 * stateValue = %TRUE if @state is the state we are changing to, 935 * %FALSE if we are changing away from it 936 * 937 * Since: 3.0 938 */ 939 public void notifyStateChange(Window window, void* regionId, GtkStateType state, bool stateValue) 940 { 941 gtk_style_context_notify_state_change(gtkStyleContext, (window is null) ? null : window.getWindowStruct(), regionId, state, stateValue); 942 } 943 944 /** 945 * Pops an animatable region from @context. 946 * See gtk_style_context_push_animatable_region(). 947 * 948 * Deprecated: This function does nothing. 949 * 950 * Since: 3.0 951 */ 952 public void popAnimatableRegion() 953 { 954 gtk_style_context_pop_animatable_region(gtkStyleContext); 955 } 956 957 /** 958 * Pushes an animatable region, so all further gtk_render_*() calls between 959 * this call and the following gtk_style_context_pop_animatable_region() 960 * will potentially show transition animations for this region if 961 * gtk_style_context_notify_state_change() is called for a given state, 962 * and the current theme/style defines transition animations for state 963 * changes. 964 * 965 * The @region_id used must be unique in @context so the themes 966 * can uniquely identify rendered elements subject to a state transition. 967 * 968 * Deprecated: This function does nothing. 969 * 970 * Params: 971 * regionId = unique identifier for the animatable region 972 * 973 * Since: 3.0 974 */ 975 public void pushAnimatableRegion(void* regionId) 976 { 977 gtk_style_context_push_animatable_region(gtkStyleContext, regionId); 978 } 979 980 /** 981 * Removes @class_name from @context. 982 * 983 * Params: 984 * className = class name to remove 985 * 986 * Since: 3.0 987 */ 988 public void removeClass(string className) 989 { 990 gtk_style_context_remove_class(gtkStyleContext, Str.toStringz(className)); 991 } 992 993 /** 994 * Removes @provider from the style providers list in @context. 995 * 996 * Params: 997 * provider = a #GtkStyleProvider 998 * 999 * Since: 3.0 1000 */ 1001 public void removeProvider(StyleProviderIF provider) 1002 { 1003 gtk_style_context_remove_provider(gtkStyleContext, (provider is null) ? null : provider.getStyleProviderStruct()); 1004 } 1005 1006 /** 1007 * Removes a region from @context. 1008 * 1009 * Params: 1010 * regionName = region name to unset 1011 * 1012 * Since: 3.0 1013 */ 1014 public void removeRegion(string regionName) 1015 { 1016 gtk_style_context_remove_region(gtkStyleContext, Str.toStringz(regionName)); 1017 } 1018 1019 /** 1020 * Restores @context state to a previous stage. 1021 * See gtk_style_context_save(). 1022 * 1023 * Since: 3.0 1024 */ 1025 public void restore() 1026 { 1027 gtk_style_context_restore(gtkStyleContext); 1028 } 1029 1030 /** 1031 * Saves the @context state, so temporary modifications done through 1032 * gtk_style_context_add_class(), gtk_style_context_remove_class(), 1033 * gtk_style_context_set_state(), etc. can quickly be reverted 1034 * in one go through gtk_style_context_restore(). 1035 * 1036 * The matching call to gtk_style_context_restore() must be done 1037 * before GTK returns to the main loop. 1038 * 1039 * Since: 3.0 1040 */ 1041 public void save() 1042 { 1043 gtk_style_context_save(gtkStyleContext); 1044 } 1045 1046 /** 1047 * This function is analogous to gdk_window_scroll(), and 1048 * should be called together with it so the invalidation 1049 * areas for any ongoing animation are scrolled together 1050 * with it. 1051 * 1052 * Deprecated: This function does nothing. 1053 * 1054 * Params: 1055 * window = a #GdkWindow used previously in 1056 * gtk_style_context_notify_state_change() 1057 * dx = Amount to scroll in the X axis 1058 * dy = Amount to scroll in the Y axis 1059 * 1060 * Since: 3.0 1061 */ 1062 public void scrollAnimations(Window window, int dx, int dy) 1063 { 1064 gtk_style_context_scroll_animations(gtkStyleContext, (window is null) ? null : window.getWindowStruct(), dx, dy); 1065 } 1066 1067 /** 1068 * Sets the background of @window to the background pattern or 1069 * color specified in @context for its current state. 1070 * 1071 * Deprecated: Use gtk_render_background() instead. 1072 * Note that clients still using this function are now responsible 1073 * for calling this function again whenever @context is invalidated. 1074 * 1075 * Params: 1076 * window = a #GdkWindow 1077 * 1078 * Since: 3.0 1079 */ 1080 public void setBackground(Window window) 1081 { 1082 gtk_style_context_set_background(gtkStyleContext, (window is null) ? null : window.getWindowStruct()); 1083 } 1084 1085 /** 1086 * Sets the reading direction for rendering purposes. 1087 * 1088 * If you are using a #GtkStyleContext returned from 1089 * gtk_widget_get_style_context(), you do not need to 1090 * call this yourself. 1091 * 1092 * Deprecated: Use gtk_style_context_set_state() with 1093 * #GTK_STATE_FLAG_DIR_LTR and #GTK_STATE_FLAG_DIR_RTL 1094 * instead. 1095 * 1096 * Params: 1097 * direction = the new direction. 1098 * 1099 * Since: 3.0 1100 */ 1101 public void setDirection(GtkTextDirection direction) 1102 { 1103 gtk_style_context_set_direction(gtkStyleContext, direction); 1104 } 1105 1106 /** 1107 * Attaches @context to the given frame clock. 1108 * 1109 * The frame clock is used for the timing of animations. 1110 * 1111 * If you are using a #GtkStyleContext returned from 1112 * gtk_widget_get_style_context(), you do not need to 1113 * call this yourself. 1114 * 1115 * Params: 1116 * frameClock = a #GdkFrameClock 1117 * 1118 * Since: 3.8 1119 */ 1120 public void setFrameClock(FrameClock frameClock) 1121 { 1122 gtk_style_context_set_frame_clock(gtkStyleContext, (frameClock is null) ? null : frameClock.getFrameClockStruct()); 1123 } 1124 1125 /** 1126 * Sets the sides where rendered elements (mostly through 1127 * gtk_render_frame()) will visually connect with other visual elements. 1128 * 1129 * This is merely a hint that may or may not be honored 1130 * by themes. 1131 * 1132 * Container widgets are expected to set junction hints as appropriate 1133 * for their children, so it should not normally be necessary to call 1134 * this function manually. 1135 * 1136 * Params: 1137 * sides = sides where rendered elements are visually connected to 1138 * other elements 1139 * 1140 * Since: 3.0 1141 */ 1142 public void setJunctionSides(GtkJunctionSides sides) 1143 { 1144 gtk_style_context_set_junction_sides(gtkStyleContext, sides); 1145 } 1146 1147 /** 1148 * Sets the parent style context for @context. The parent style 1149 * context is used to implement 1150 * [inheritance](http://www.w3.org/TR/css3-cascade/#inheritance) 1151 * of properties. 1152 * 1153 * If you are using a #GtkStyleContext returned from 1154 * gtk_widget_get_style_context(), the parent will be set for you. 1155 * 1156 * Params: 1157 * parent = the new parent or %NULL 1158 * 1159 * Since: 3.4 1160 */ 1161 public void setParent(StyleContext parent) 1162 { 1163 gtk_style_context_set_parent(gtkStyleContext, (parent is null) ? null : parent.getStyleContextStruct()); 1164 } 1165 1166 /** 1167 * Sets the #GtkWidgetPath used for style matching. As a 1168 * consequence, the style will be regenerated to match 1169 * the new given path. 1170 * 1171 * If you are using a #GtkStyleContext returned from 1172 * gtk_widget_get_style_context(), you do not need to call 1173 * this yourself. 1174 * 1175 * Params: 1176 * path = a #GtkWidgetPath 1177 * 1178 * Since: 3.0 1179 */ 1180 public void setPath(WidgetPath path) 1181 { 1182 gtk_style_context_set_path(gtkStyleContext, (path is null) ? null : path.getWidgetPathStruct()); 1183 } 1184 1185 /** 1186 * Sets the scale to use when getting image assets for the style. 1187 * 1188 * Params: 1189 * scale = scale 1190 * 1191 * Since: 3.10 1192 */ 1193 public void setScale(int scale) 1194 { 1195 gtk_style_context_set_scale(gtkStyleContext, scale); 1196 } 1197 1198 /** 1199 * Attaches @context to the given screen. 1200 * 1201 * The screen is used to add style information from “global” style 1202 * providers, such as the screens #GtkSettings instance. 1203 * 1204 * If you are using a #GtkStyleContext returned from 1205 * gtk_widget_get_style_context(), you do not need to 1206 * call this yourself. 1207 * 1208 * Params: 1209 * screen = a #GdkScreen 1210 * 1211 * Since: 3.0 1212 */ 1213 public void setScreen(Screen screen) 1214 { 1215 gtk_style_context_set_screen(gtkStyleContext, (screen is null) ? null : screen.getScreenStruct()); 1216 } 1217 1218 /** 1219 * Sets the state to be used for style matching. 1220 * 1221 * Params: 1222 * flags = state to represent 1223 * 1224 * Since: 3.0 1225 */ 1226 public void setState(GtkStateFlags flags) 1227 { 1228 gtk_style_context_set_state(gtkStyleContext, flags); 1229 } 1230 1231 /** 1232 * Returns %TRUE if there is a transition animation running for the 1233 * current region (see gtk_style_context_push_animatable_region()). 1234 * 1235 * If @progress is not %NULL, the animation progress will be returned 1236 * there, 0.0 means the state is closest to being unset, while 1.0 means 1237 * it’s closest to being set. This means transition animation will 1238 * run from 0 to 1 when @state is being set and from 1 to 0 when 1239 * it’s being unset. 1240 * 1241 * Deprecated: This function always returns %FALSE 1242 * 1243 * Params: 1244 * state = a widget state 1245 * progress = return location for the transition progress 1246 * 1247 * Returns: %TRUE if there is a running transition animation for @state. 1248 * 1249 * Since: 3.0 1250 */ 1251 public bool stateIsRunning(GtkStateType state, out double progress) 1252 { 1253 return gtk_style_context_state_is_running(gtkStyleContext, state, &progress) != 0; 1254 } 1255 1256 /** 1257 * Converts the style context into a string representation. 1258 * 1259 * The string representation always includes information about 1260 * the name, state, id, visibility and style classes of the CSS 1261 * node that is backing @context. Depending on the flags, more 1262 * information may be included. 1263 * 1264 * This function is intended for testing and debugging of the 1265 * CSS implementation in GTK+. There are no guarantees about 1266 * the format of the returned string, it may change. 1267 * 1268 * Params: 1269 * flags = Flags that determine what to print 1270 * 1271 * Returns: a newly allocated string representing @context 1272 * 1273 * Since: 3.20 1274 */ 1275 public string toString(GtkStyleContextPrintFlags flags) 1276 { 1277 auto retStr = gtk_style_context_to_string(gtkStyleContext, flags); 1278 1279 scope(exit) Str.freeString(retStr); 1280 return Str.toString(retStr); 1281 } 1282 1283 protected class OnChangedDelegateWrapper 1284 { 1285 static OnChangedDelegateWrapper[] listeners; 1286 void delegate(StyleContext) dlg; 1287 gulong handlerId; 1288 1289 this(void delegate(StyleContext) dlg) 1290 { 1291 this.dlg = dlg; 1292 this.listeners ~= this; 1293 } 1294 1295 void remove(OnChangedDelegateWrapper source) 1296 { 1297 foreach(index, wrapper; listeners) 1298 { 1299 if (wrapper.handlerId == source.handlerId) 1300 { 1301 listeners[index] = null; 1302 listeners = std.algorithm.remove(listeners, index); 1303 break; 1304 } 1305 } 1306 } 1307 } 1308 1309 /** 1310 * The ::changed signal is emitted when there is a change in the 1311 * #GtkStyleContext. 1312 * 1313 * For a #GtkStyleContext returned by gtk_widget_get_style_context(), the 1314 * #GtkWidget::style-updated signal/vfunc might be more convenient to use. 1315 * 1316 * This signal is useful when using the theming layer standalone. 1317 * 1318 * Since: 3.0 1319 */ 1320 gulong addOnChanged(void delegate(StyleContext) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1321 { 1322 auto wrapper = new OnChangedDelegateWrapper(dlg); 1323 wrapper.handlerId = Signals.connectData( 1324 this, 1325 "changed", 1326 cast(GCallback)&callBackChanged, 1327 cast(void*)wrapper, 1328 cast(GClosureNotify)&callBackChangedDestroy, 1329 connectFlags); 1330 return wrapper.handlerId; 1331 } 1332 1333 extern(C) static void callBackChanged(GtkStyleContext* stylecontextStruct, OnChangedDelegateWrapper wrapper) 1334 { 1335 wrapper.dlg(wrapper.outer); 1336 } 1337 1338 extern(C) static void callBackChangedDestroy(OnChangedDelegateWrapper wrapper, GClosure* closure) 1339 { 1340 wrapper.remove(wrapper); 1341 } 1342 1343 /** 1344 * Renders an activity indicator (such as in #GtkSpinner). 1345 * The state %GTK_STATE_FLAG_CHECKED determines whether there is 1346 * activity going on. 1347 * 1348 * Params: 1349 * context = a #GtkStyleContext 1350 * cr = a #cairo_t 1351 * x = X origin of the rectangle 1352 * y = Y origin of the rectangle 1353 * width = rectangle width 1354 * height = rectangle height 1355 * 1356 * Since: 3.0 1357 */ 1358 public static void renderActivity(StyleContext context, Context cr, double x, double y, double width, double height) 1359 { 1360 gtk_render_activity((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x, y, width, height); 1361 } 1362 1363 /** 1364 * Renders an arrow pointing to @angle. 1365 * 1366 * Typical arrow rendering at 0, 1⁄2 π;, π; and 3⁄2 π: 1367 * 1368 * ![](arrows.png) 1369 * 1370 * Params: 1371 * context = a #GtkStyleContext 1372 * cr = a #cairo_t 1373 * angle = arrow angle from 0 to 2 * %G_PI, being 0 the arrow pointing to the north 1374 * x = X origin of the render area 1375 * y = Y origin of the render area 1376 * size = square side for render area 1377 * 1378 * Since: 3.0 1379 */ 1380 public static void renderArrow(StyleContext context, Context cr, double angle, double x, double y, double size) 1381 { 1382 gtk_render_arrow((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), angle, x, y, size); 1383 } 1384 1385 /** 1386 * Renders the background of an element. 1387 * 1388 * Typical background rendering, showing the effect of 1389 * `background-image`, `border-width` and `border-radius`: 1390 * 1391 * ![](background.png) 1392 * 1393 * Params: 1394 * context = a #GtkStyleContext 1395 * cr = a #cairo_t 1396 * x = X origin of the rectangle 1397 * y = Y origin of the rectangle 1398 * width = rectangle width 1399 * height = rectangle height 1400 * 1401 * Since: 3.0. 1402 */ 1403 public static void renderBackground(StyleContext context, Context cr, double x, double y, double width, double height) 1404 { 1405 gtk_render_background((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x, y, width, height); 1406 } 1407 1408 /** 1409 * Returns the area that will be affected (i.e. drawn to) when 1410 * calling gtk_render_background() for the given @context and 1411 * rectangle. 1412 * 1413 * Params: 1414 * context = a #GtkStyleContext 1415 * x = X origin of the rectangle 1416 * y = Y origin of the rectangle 1417 * width = rectangle width 1418 * height = rectangle height 1419 * outClip = return location for the clip 1420 * 1421 * Since: 3.20 1422 */ 1423 public static void renderBackgroundGetClip(StyleContext context, double x, double y, double width, double height, out GdkRectangle outClip) 1424 { 1425 gtk_render_background_get_clip((context is null) ? null : context.getStyleContextStruct(), x, y, width, height, &outClip); 1426 } 1427 1428 /** 1429 * Renders a checkmark (as in a #GtkCheckButton). 1430 * 1431 * The %GTK_STATE_FLAG_CHECKED state determines whether the check is 1432 * on or off, and %GTK_STATE_FLAG_INCONSISTENT determines whether it 1433 * should be marked as undefined. 1434 * 1435 * Typical checkmark rendering: 1436 * 1437 * ![](checks.png) 1438 * 1439 * Params: 1440 * context = a #GtkStyleContext 1441 * cr = a #cairo_t 1442 * x = X origin of the rectangle 1443 * y = Y origin of the rectangle 1444 * width = rectangle width 1445 * height = rectangle height 1446 * 1447 * Since: 3.0 1448 */ 1449 public static void renderCheck(StyleContext context, Context cr, double x, double y, double width, double height) 1450 { 1451 gtk_render_check((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x, y, width, height); 1452 } 1453 1454 /** 1455 * Renders an expander (as used in #GtkTreeView and #GtkExpander) in the area 1456 * defined by @x, @y, @width, @height. The state %GTK_STATE_FLAG_CHECKED 1457 * determines whether the expander is collapsed or expanded. 1458 * 1459 * Typical expander rendering: 1460 * 1461 * ![](expanders.png) 1462 * 1463 * Params: 1464 * context = a #GtkStyleContext 1465 * cr = a #cairo_t 1466 * x = X origin of the rectangle 1467 * y = Y origin of the rectangle 1468 * width = rectangle width 1469 * height = rectangle height 1470 * 1471 * Since: 3.0 1472 */ 1473 public static void renderExpander(StyleContext context, Context cr, double x, double y, double width, double height) 1474 { 1475 gtk_render_expander((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x, y, width, height); 1476 } 1477 1478 /** 1479 * Renders a extension (as in a #GtkNotebook tab) in the rectangle 1480 * defined by @x, @y, @width, @height. The side where the extension 1481 * connects to is defined by @gap_side. 1482 * 1483 * Typical extension rendering: 1484 * 1485 * ![](extensions.png) 1486 * 1487 * Params: 1488 * context = a #GtkStyleContext 1489 * cr = a #cairo_t 1490 * x = X origin of the rectangle 1491 * y = Y origin of the rectangle 1492 * width = rectangle width 1493 * height = rectangle height 1494 * gapSide = side where the gap is 1495 * 1496 * Since: 3.0 1497 */ 1498 public static void renderExtension(StyleContext context, Context cr, double x, double y, double width, double height, GtkPositionType gapSide) 1499 { 1500 gtk_render_extension((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x, y, width, height, gapSide); 1501 } 1502 1503 /** 1504 * Renders a focus indicator on the rectangle determined by @x, @y, @width, @height. 1505 * 1506 * Typical focus rendering: 1507 * 1508 * ![](focus.png) 1509 * 1510 * Params: 1511 * context = a #GtkStyleContext 1512 * cr = a #cairo_t 1513 * x = X origin of the rectangle 1514 * y = Y origin of the rectangle 1515 * width = rectangle width 1516 * height = rectangle height 1517 * 1518 * Since: 3.0 1519 */ 1520 public static void renderFocus(StyleContext context, Context cr, double x, double y, double width, double height) 1521 { 1522 gtk_render_focus((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x, y, width, height); 1523 } 1524 1525 /** 1526 * Renders a frame around the rectangle defined by @x, @y, @width, @height. 1527 * 1528 * Examples of frame rendering, showing the effect of `border-image`, 1529 * `border-color`, `border-width`, `border-radius` and junctions: 1530 * 1531 * ![](frames.png) 1532 * 1533 * Params: 1534 * context = a #GtkStyleContext 1535 * cr = a #cairo_t 1536 * x = X origin of the rectangle 1537 * y = Y origin of the rectangle 1538 * width = rectangle width 1539 * height = rectangle height 1540 * 1541 * Since: 3.0 1542 */ 1543 public static void renderFrame(StyleContext context, Context cr, double x, double y, double width, double height) 1544 { 1545 gtk_render_frame((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x, y, width, height); 1546 } 1547 1548 /** 1549 * Renders a frame around the rectangle defined by (@x, @y, @width, @height), 1550 * leaving a gap on one side. @xy0_gap and @xy1_gap will mean X coordinates 1551 * for %GTK_POS_TOP and %GTK_POS_BOTTOM gap sides, and Y coordinates for 1552 * %GTK_POS_LEFT and %GTK_POS_RIGHT. 1553 * 1554 * Typical rendering of a frame with a gap: 1555 * 1556 * ![](frame-gap.png) 1557 * 1558 * Params: 1559 * context = a #GtkStyleContext 1560 * cr = a #cairo_t 1561 * x = X origin of the rectangle 1562 * y = Y origin of the rectangle 1563 * width = rectangle width 1564 * height = rectangle height 1565 * gapSide = side where the gap is 1566 * xy0Gap = initial coordinate (X or Y depending on @gap_side) for the gap 1567 * xy1Gap = end coordinate (X or Y depending on @gap_side) for the gap 1568 * 1569 * Since: 3.0 1570 */ 1571 public static void renderFrameGap(StyleContext context, Context cr, double x, double y, double width, double height, GtkPositionType gapSide, double xy0Gap, double xy1Gap) 1572 { 1573 gtk_render_frame_gap((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x, y, width, height, gapSide, xy0Gap, xy1Gap); 1574 } 1575 1576 /** 1577 * Renders a handle (as in #GtkHandleBox, #GtkPaned and 1578 * #GtkWindow’s resize grip), in the rectangle 1579 * determined by @x, @y, @width, @height. 1580 * 1581 * Handles rendered for the paned and grip classes: 1582 * 1583 * ![](handles.png) 1584 * 1585 * Params: 1586 * context = a #GtkStyleContext 1587 * cr = a #cairo_t 1588 * x = X origin of the rectangle 1589 * y = Y origin of the rectangle 1590 * width = rectangle width 1591 * height = rectangle height 1592 * 1593 * Since: 3.0 1594 */ 1595 public static void renderHandle(StyleContext context, Context cr, double x, double y, double width, double height) 1596 { 1597 gtk_render_handle((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x, y, width, height); 1598 } 1599 1600 /** 1601 * Renders the icon in @pixbuf at the specified @x and @y coordinates. 1602 * 1603 * This function will render the icon in @pixbuf at exactly its size, 1604 * regardless of scaling factors, which may not be appropriate when 1605 * drawing on displays with high pixel densities. 1606 * 1607 * You probably want to use gtk_render_icon_surface() instead, if you 1608 * already have a Cairo surface. 1609 * 1610 * Params: 1611 * context = a #GtkStyleContext 1612 * cr = a #cairo_t 1613 * pixbuf = a #GdkPixbuf containing the icon to draw 1614 * x = X position for the @pixbuf 1615 * y = Y position for the @pixbuf 1616 * 1617 * Since: 3.2 1618 */ 1619 public static void renderIcon(StyleContext context, Context cr, Pixbuf pixbuf, double x, double y) 1620 { 1621 gtk_render_icon((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), (pixbuf is null) ? null : pixbuf.getPixbufStruct(), x, y); 1622 } 1623 1624 /** 1625 * Renders the icon specified by @source at the given @size, returning the result 1626 * in a pixbuf. 1627 * 1628 * Deprecated: Use gtk_icon_theme_load_icon() instead. 1629 * 1630 * Params: 1631 * context = a #GtkStyleContext 1632 * source = the #GtkIconSource specifying the icon to render 1633 * size = the size (#GtkIconSize) to render the icon at. 1634 * A size of `(GtkIconSize) -1` means render at the size of the source 1635 * and don’t scale. 1636 * 1637 * Returns: a newly-created #GdkPixbuf containing the rendered icon 1638 * 1639 * Since: 3.0 1640 */ 1641 public static Pixbuf renderIconPixbuf(StyleContext context, IconSource source, GtkIconSize size) 1642 { 1643 auto p = gtk_render_icon_pixbuf((context is null) ? null : context.getStyleContextStruct(), (source is null) ? null : source.getIconSourceStruct(), size); 1644 1645 if(p is null) 1646 { 1647 return null; 1648 } 1649 1650 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true); 1651 } 1652 1653 /** 1654 * Renders the icon in @surface at the specified @x and @y coordinates. 1655 * 1656 * Params: 1657 * context = a #GtkStyleContext 1658 * cr = a #cairo_t 1659 * surface = a #cairo_surface_t containing the icon to draw 1660 * x = X position for the @icon 1661 * y = Y position for the @incon 1662 * 1663 * Since: 3.10 1664 */ 1665 public static void renderIconSurface(StyleContext context, Context cr, Surface surface, double x, double y) 1666 { 1667 gtk_render_icon_surface((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), (surface is null) ? null : surface.getSurfaceStruct(), x, y); 1668 } 1669 1670 /** 1671 * Draws a text caret on @cr at the specified index of @layout. 1672 * 1673 * Params: 1674 * context = a #GtkStyleContext 1675 * cr = a #cairo_t 1676 * x = X origin 1677 * y = Y origin 1678 * layout = the #PangoLayout of the text 1679 * index = the index in the #PangoLayout 1680 * direction = the #PangoDirection of the text 1681 * 1682 * Since: 3.4 1683 */ 1684 public static void renderInsertionCursor(StyleContext context, Context cr, double x, double y, PgLayout layout, int index, PangoDirection direction) 1685 { 1686 gtk_render_insertion_cursor((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x, y, (layout is null) ? null : layout.getPgLayoutStruct(), index, direction); 1687 } 1688 1689 /** 1690 * Renders @layout on the coordinates @x, @y 1691 * 1692 * Params: 1693 * context = a #GtkStyleContext 1694 * cr = a #cairo_t 1695 * x = X origin 1696 * y = Y origin 1697 * layout = the #PangoLayout to render 1698 * 1699 * Since: 3.0 1700 */ 1701 public static void renderLayout(StyleContext context, Context cr, double x, double y, PgLayout layout) 1702 { 1703 gtk_render_layout((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x, y, (layout is null) ? null : layout.getPgLayoutStruct()); 1704 } 1705 1706 /** 1707 * Renders a line from (x0, y0) to (x1, y1). 1708 * 1709 * Params: 1710 * context = a #GtkStyleContext 1711 * cr = a #cairo_t 1712 * x0 = X coordinate for the origin of the line 1713 * y0 = Y coordinate for the origin of the line 1714 * x1 = X coordinate for the end of the line 1715 * y1 = Y coordinate for the end of the line 1716 * 1717 * Since: 3.0 1718 */ 1719 public static void renderLine(StyleContext context, Context cr, double x0, double y0, double x1, double y1) 1720 { 1721 gtk_render_line((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x0, y0, x1, y1); 1722 } 1723 1724 /** 1725 * Renders an option mark (as in a #GtkRadioButton), the %GTK_STATE_FLAG_CHECKED 1726 * state will determine whether the option is on or off, and 1727 * %GTK_STATE_FLAG_INCONSISTENT whether it should be marked as undefined. 1728 * 1729 * Typical option mark rendering: 1730 * 1731 * ![](options.png) 1732 * 1733 * Params: 1734 * context = a #GtkStyleContext 1735 * cr = a #cairo_t 1736 * x = X origin of the rectangle 1737 * y = Y origin of the rectangle 1738 * width = rectangle width 1739 * height = rectangle height 1740 * 1741 * Since: 3.0 1742 */ 1743 public static void renderOption(StyleContext context, Context cr, double x, double y, double width, double height) 1744 { 1745 gtk_render_option((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x, y, width, height); 1746 } 1747 1748 /** 1749 * Renders a slider (as in #GtkScale) in the rectangle defined by @x, @y, 1750 * @width, @height. @orientation defines whether the slider is vertical 1751 * or horizontal. 1752 * 1753 * Typical slider rendering: 1754 * 1755 * ![](sliders.png) 1756 * 1757 * Params: 1758 * context = a #GtkStyleContext 1759 * cr = a #cairo_t 1760 * x = X origin of the rectangle 1761 * y = Y origin of the rectangle 1762 * width = rectangle width 1763 * height = rectangle height 1764 * orientation = orientation of the slider 1765 * 1766 * Since: 3.0 1767 */ 1768 public static void renderSlider(StyleContext context, Context cr, double x, double y, double width, double height, GtkOrientation orientation) 1769 { 1770 gtk_render_slider((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x, y, width, height, orientation); 1771 } 1772 }