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