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