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