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