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