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