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