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 * Params: 1058 * window = a #GdkWindow 1059 * 1060 * Since: 3.0 1061 */ 1062 public void setBackground(Window window) 1063 { 1064 gtk_style_context_set_background(gtkStyleContext, (window is null) ? null : window.getWindowStruct()); 1065 } 1066 1067 /** 1068 * Sets the reading direction for rendering purposes. 1069 * 1070 * If you are using a #GtkStyleContext returned from 1071 * gtk_widget_get_style_context(), you do not need to 1072 * call this yourself. 1073 * 1074 * Deprecated: Use gtk_style_context_set_state() with 1075 * #GTK_STATE_FLAG_DIR_LTR and #GTK_STATE_FLAG_DIR_RTL 1076 * instead. 1077 * 1078 * Params: 1079 * direction = the new direction. 1080 * 1081 * Since: 3.0 1082 */ 1083 public void setDirection(GtkTextDirection direction) 1084 { 1085 gtk_style_context_set_direction(gtkStyleContext, direction); 1086 } 1087 1088 /** 1089 * Attaches @context to the given frame clock. 1090 * 1091 * The frame clock is used for the timing of animations. 1092 * 1093 * If you are using a #GtkStyleContext returned from 1094 * gtk_widget_get_style_context(), you do not need to 1095 * call this yourself. 1096 * 1097 * Params: 1098 * frameClock = a #GdkFrameClock 1099 * 1100 * Since: 3.8 1101 */ 1102 public void setFrameClock(FrameClock frameClock) 1103 { 1104 gtk_style_context_set_frame_clock(gtkStyleContext, (frameClock is null) ? null : frameClock.getFrameClockStruct()); 1105 } 1106 1107 /** 1108 * Sets the sides where rendered elements (mostly through 1109 * gtk_render_frame()) will visually connect with other visual elements. 1110 * 1111 * This is merely a hint that may or may not be honored 1112 * by themes. 1113 * 1114 * Container widgets are expected to set junction hints as appropriate 1115 * for their children, so it should not normally be necessary to call 1116 * this function manually. 1117 * 1118 * Params: 1119 * sides = sides where rendered elements are visually connected to 1120 * other elements 1121 * 1122 * Since: 3.0 1123 */ 1124 public void setJunctionSides(GtkJunctionSides sides) 1125 { 1126 gtk_style_context_set_junction_sides(gtkStyleContext, sides); 1127 } 1128 1129 /** 1130 * Sets the parent style context for @context. The parent style 1131 * context is used to implement 1132 * [inheritance](http://www.w3.org/TR/css3-cascade/#inheritance) 1133 * of properties. 1134 * 1135 * If you are using a #GtkStyleContext returned from 1136 * gtk_widget_get_style_context(), the parent will be set for you. 1137 * 1138 * Params: 1139 * parent = the new parent or %NULL 1140 * 1141 * Since: 3.4 1142 */ 1143 public void setParent(StyleContext parent) 1144 { 1145 gtk_style_context_set_parent(gtkStyleContext, (parent is null) ? null : parent.getStyleContextStruct()); 1146 } 1147 1148 /** 1149 * Sets the #GtkWidgetPath used for style matching. As a 1150 * consequence, the style will be regenerated to match 1151 * the new given path. 1152 * 1153 * If you are using a #GtkStyleContext returned from 1154 * gtk_widget_get_style_context(), you do not need to call 1155 * this yourself. 1156 * 1157 * Params: 1158 * path = a #GtkWidgetPath 1159 * 1160 * Since: 3.0 1161 */ 1162 public void setPath(WidgetPath path) 1163 { 1164 gtk_style_context_set_path(gtkStyleContext, (path is null) ? null : path.getWidgetPathStruct()); 1165 } 1166 1167 /** 1168 * Sets the scale to use when getting image assets for the style . 1169 * 1170 * Params: 1171 * scale = scale 1172 * 1173 * Since: 3.10 1174 */ 1175 public void setScale(int scale) 1176 { 1177 gtk_style_context_set_scale(gtkStyleContext, scale); 1178 } 1179 1180 /** 1181 * Attaches @context to the given screen. 1182 * 1183 * The screen is used to add style information from “global” style 1184 * providers, such as the screens #GtkSettings instance. 1185 * 1186 * If you are using a #GtkStyleContext returned from 1187 * gtk_widget_get_style_context(), you do not need to 1188 * call this yourself. 1189 * 1190 * Params: 1191 * screen = a #GdkScreen 1192 * 1193 * Since: 3.0 1194 */ 1195 public void setScreen(Screen screen) 1196 { 1197 gtk_style_context_set_screen(gtkStyleContext, (screen is null) ? null : screen.getScreenStruct()); 1198 } 1199 1200 /** 1201 * Sets the state to be used when rendering with any 1202 * of the gtk_render_*() functions. 1203 * 1204 * Params: 1205 * flags = state to represent 1206 * 1207 * Since: 3.0 1208 */ 1209 public void setState(GtkStateFlags flags) 1210 { 1211 gtk_style_context_set_state(gtkStyleContext, flags); 1212 } 1213 1214 /** 1215 * Returns %TRUE if there is a transition animation running for the 1216 * current region (see gtk_style_context_push_animatable_region()). 1217 * 1218 * If @progress is not %NULL, the animation progress will be returned 1219 * there, 0.0 means the state is closest to being unset, while 1.0 means 1220 * it’s closest to being set. This means transition animation will 1221 * run from 0 to 1 when @state is being set and from 1 to 0 when 1222 * it’s being unset. 1223 * 1224 * Deprecated: This function always returns %FALSE 1225 * 1226 * Params: 1227 * state = a widget state 1228 * progress = return location for the transition progress 1229 * 1230 * Return: %TRUE if there is a running transition animation for @state. 1231 * 1232 * Since: 3.0 1233 */ 1234 public bool stateIsRunning(GtkStateType state, out double progress) 1235 { 1236 return gtk_style_context_state_is_running(gtkStyleContext, state, &progress) != 0; 1237 } 1238 1239 int[string] connectedSignals; 1240 1241 void delegate(StyleContext)[] onChangedListeners; 1242 void addOnChanged(void delegate(StyleContext) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1243 { 1244 if ( "changed" !in connectedSignals ) 1245 { 1246 Signals.connectData( 1247 this, 1248 "changed", 1249 cast(GCallback)&callBackChanged, 1250 cast(void*)this, 1251 null, 1252 connectFlags); 1253 connectedSignals["changed"] = 1; 1254 } 1255 onChangedListeners ~= dlg; 1256 } 1257 extern(C) static void callBackChanged(GtkStyleContext* stylecontextStruct, StyleContext _stylecontext) 1258 { 1259 foreach ( void delegate(StyleContext) dlg; _stylecontext.onChangedListeners ) 1260 { 1261 dlg(_stylecontext); 1262 } 1263 } 1264 1265 /** 1266 * Renders an activity indicator (such as in #GtkSpinner). 1267 * The state %GTK_STATE_FLAG_CHECKED determines whether there is 1268 * activity going on. 1269 * 1270 * Params: 1271 * context = a #GtkStyleContext 1272 * cr = a #cairo_t 1273 * x = X origin of the rectangle 1274 * y = Y origin of the rectangle 1275 * width = rectangle width 1276 * height = rectangle height 1277 * 1278 * Since: 3.0 1279 */ 1280 public static void renderActivity(StyleContext context, Context cr, double x, double y, double width, double height) 1281 { 1282 gtk_render_activity((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x, y, width, height); 1283 } 1284 1285 /** 1286 * Renders an arrow pointing to @angle. 1287 * 1288 * Typical arrow rendering at 0, 1&solidus;2 π, π and 3&solidus;2 π: 1289 * 1290 * ![](arrows.png) 1291 * 1292 * Params: 1293 * context = a #GtkStyleContext 1294 * cr = a #cairo_t 1295 * angle = arrow angle from 0 to 2 * %G_PI, being 0 the arrow pointing to the north 1296 * x = X origin of the render area 1297 * y = Y origin of the render area 1298 * size = square side for render area 1299 * 1300 * Since: 3.0 1301 */ 1302 public static void renderArrow(StyleContext context, Context cr, double angle, double x, double y, double size) 1303 { 1304 gtk_render_arrow((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), angle, x, y, size); 1305 } 1306 1307 /** 1308 * Renders the background of an element. 1309 * 1310 * Typical background rendering, showing the effect of 1311 * `background-image`, `border-width` and `border-radius`: 1312 * 1313 * ![](background.png) 1314 * 1315 * Params: 1316 * context = a #GtkStyleContext 1317 * cr = a #cairo_t 1318 * x = X origin of the rectangle 1319 * y = Y origin of the rectangle 1320 * width = rectangle width 1321 * height = rectangle height 1322 * 1323 * Since: 3.0. 1324 */ 1325 public static void renderBackground(StyleContext context, Context cr, double x, double y, double width, double height) 1326 { 1327 gtk_render_background((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x, y, width, height); 1328 } 1329 1330 /** 1331 * Renders a checkmark (as in a #GtkCheckButton). 1332 * 1333 * The %GTK_STATE_FLAG_CHECKED state determines whether the check is 1334 * on or off, and %GTK_STATE_FLAG_INCONSISTENT determines whether it 1335 * should be marked as undefined. 1336 * 1337 * Typical checkmark rendering: 1338 * 1339 * ![](checks.png) 1340 * 1341 * Params: 1342 * context = a #GtkStyleContext 1343 * cr = a #cairo_t 1344 * x = X origin of the rectangle 1345 * y = Y origin of the rectangle 1346 * width = rectangle width 1347 * height = rectangle height 1348 * 1349 * Since: 3.0 1350 */ 1351 public static void renderCheck(StyleContext context, Context cr, double x, double y, double width, double height) 1352 { 1353 gtk_render_check((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x, y, width, height); 1354 } 1355 1356 /** 1357 * Renders an expander (as used in #GtkTreeView and #GtkExpander) in the area 1358 * defined by @x, @y, @width, @height. The state %GTK_STATE_FLAG_CHECKED 1359 * determines whether the expander is collapsed or expanded. 1360 * 1361 * Typical expander rendering: 1362 * 1363 * ![](expanders.png) 1364 * 1365 * Params: 1366 * context = a #GtkStyleContext 1367 * cr = a #cairo_t 1368 * x = X origin of the rectangle 1369 * y = Y origin of the rectangle 1370 * width = rectangle width 1371 * height = rectangle height 1372 * 1373 * Since: 3.0 1374 */ 1375 public static void renderExpander(StyleContext context, Context cr, double x, double y, double width, double height) 1376 { 1377 gtk_render_expander((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x, y, width, height); 1378 } 1379 1380 /** 1381 * Renders a extension (as in a #GtkNotebook tab) in the rectangle 1382 * defined by @x, @y, @width, @height. The side where the extension 1383 * connects to is defined by @gap_side. 1384 * 1385 * Typical extension rendering: 1386 * 1387 * ![](extensions.png) 1388 * 1389 * Params: 1390 * context = a #GtkStyleContext 1391 * cr = a #cairo_t 1392 * x = X origin of the rectangle 1393 * y = Y origin of the rectangle 1394 * width = rectangle width 1395 * height = rectangle height 1396 * gapSide = side where the gap is 1397 * 1398 * Since: 3.0 1399 */ 1400 public static void renderExtension(StyleContext context, Context cr, double x, double y, double width, double height, GtkPositionType gapSide) 1401 { 1402 gtk_render_extension((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x, y, width, height, gapSide); 1403 } 1404 1405 /** 1406 * Renders a focus indicator on the rectangle determined by @x, @y, @width, @height. 1407 * 1408 * Typical focus rendering: 1409 * 1410 * ![](focus.png) 1411 * 1412 * Params: 1413 * context = a #GtkStyleContext 1414 * cr = a #cairo_t 1415 * x = X origin of the rectangle 1416 * y = Y origin of the rectangle 1417 * width = rectangle width 1418 * height = rectangle height 1419 * 1420 * Since: 3.0 1421 */ 1422 public static void renderFocus(StyleContext context, Context cr, double x, double y, double width, double height) 1423 { 1424 gtk_render_focus((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x, y, width, height); 1425 } 1426 1427 /** 1428 * Renders a frame around the rectangle defined by @x, @y, @width, @height. 1429 * 1430 * Examples of frame rendering, showing the effect of `border-image`, 1431 * `border-color`, `border-width`, `border-radius` and junctions: 1432 * 1433 * ![](frames.png) 1434 * 1435 * Params: 1436 * context = a #GtkStyleContext 1437 * cr = a #cairo_t 1438 * x = X origin of the rectangle 1439 * y = Y origin of the rectangle 1440 * width = rectangle width 1441 * height = rectangle height 1442 * 1443 * Since: 3.0 1444 */ 1445 public static void renderFrame(StyleContext context, Context cr, double x, double y, double width, double height) 1446 { 1447 gtk_render_frame((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x, y, width, height); 1448 } 1449 1450 /** 1451 * Renders a frame around the rectangle defined by (@x, @y, @width, @height), 1452 * leaving a gap on one side. @xy0_gap and @xy1_gap will mean X coordinates 1453 * for %GTK_POS_TOP and %GTK_POS_BOTTOM gap sides, and Y coordinates for 1454 * %GTK_POS_LEFT and %GTK_POS_RIGHT. 1455 * 1456 * Typical rendering of a frame with a gap: 1457 * 1458 * ![](frame-gap.png) 1459 * 1460 * Params: 1461 * context = a #GtkStyleContext 1462 * cr = a #cairo_t 1463 * x = X origin of the rectangle 1464 * y = Y origin of the rectangle 1465 * width = rectangle width 1466 * height = rectangle height 1467 * gapSide = side where the gap is 1468 * xy0Gap = initial coordinate (X or Y depending on @gap_side) for the gap 1469 * xy1Gap = end coordinate (X or Y depending on @gap_side) for the gap 1470 * 1471 * Since: 3.0 1472 */ 1473 public static void renderFrameGap(StyleContext context, Context cr, double x, double y, double width, double height, GtkPositionType gapSide, double xy0Gap, double xy1Gap) 1474 { 1475 gtk_render_frame_gap((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x, y, width, height, gapSide, xy0Gap, xy1Gap); 1476 } 1477 1478 /** 1479 * Renders a handle (as in #GtkHandleBox, #GtkPaned and 1480 * #GtkWindow’s resize grip), in the rectangle 1481 * determined by @x, @y, @width, @height. 1482 * 1483 * Handles rendered for the paned and grip classes: 1484 * 1485 * ![](handles.png) 1486 * 1487 * Params: 1488 * context = a #GtkStyleContext 1489 * cr = a #cairo_t 1490 * x = X origin of the rectangle 1491 * y = Y origin of the rectangle 1492 * width = rectangle width 1493 * height = rectangle height 1494 * 1495 * Since: 3.0 1496 */ 1497 public static void renderHandle(StyleContext context, Context cr, double x, double y, double width, double height) 1498 { 1499 gtk_render_handle((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x, y, width, height); 1500 } 1501 1502 /** 1503 * Renders the icon in @pixbuf at the specified @x and @y coordinates. 1504 * 1505 * Params: 1506 * context = a #GtkStyleContext 1507 * cr = a #cairo_t 1508 * pixbuf = a #GdkPixbuf containing the icon to draw 1509 * x = X position for the @pixbuf 1510 * y = Y position for the @pixbuf 1511 * 1512 * Since: 3.2 1513 */ 1514 public static void renderIcon(StyleContext context, Context cr, Pixbuf pixbuf, double x, double y) 1515 { 1516 gtk_render_icon((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), (pixbuf is null) ? null : pixbuf.getPixbufStruct(), x, y); 1517 } 1518 1519 /** 1520 * Renders the icon specified by @source at the given @size, returning the result 1521 * in a pixbuf. 1522 * 1523 * Deprecated: Use gtk_icon_theme_load_icon() instead. 1524 * 1525 * Params: 1526 * context = a #GtkStyleContext 1527 * source = the #GtkIconSource specifying the icon to render 1528 * size = the size to render the icon at. A size of (GtkIconSize) -1 1529 * means render at the size of the source and don’t scale. 1530 * 1531 * Return: a newly-created #GdkPixbuf containing the rendered icon 1532 * 1533 * Since: 3.0 1534 */ 1535 public static Pixbuf renderIconPixbuf(StyleContext context, IconSource source, GtkIconSize size) 1536 { 1537 auto p = gtk_render_icon_pixbuf((context is null) ? null : context.getStyleContextStruct(), (source is null) ? null : source.getIconSourceStruct(), size); 1538 1539 if(p is null) 1540 { 1541 return null; 1542 } 1543 1544 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true); 1545 } 1546 1547 /** 1548 * Renders the icon in @surface at the specified @x and @y coordinates. 1549 * 1550 * Params: 1551 * context = a #GtkStyleContext 1552 * cr = a #cairo_t 1553 * surface = a #cairo_surface_t containing the icon to draw 1554 * x = X position for the @icon 1555 * y = Y position for the @incon 1556 * 1557 * Since: 3.10 1558 */ 1559 public static void renderIconSurface(StyleContext context, Context cr, Surface surface, double x, double y) 1560 { 1561 gtk_render_icon_surface((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), (surface is null) ? null : surface.getSurfaceStruct(), x, y); 1562 } 1563 1564 /** 1565 * Draws a text caret on @cr at the specified index of @layout. 1566 * 1567 * Params: 1568 * context = a #GtkStyleContext 1569 * cr = a #cairo_t 1570 * x = X origin 1571 * y = Y origin 1572 * layout = the #PangoLayout of the text 1573 * index = the index in the #PangoLayout 1574 * direction = the #PangoDirection of the text 1575 * 1576 * Since: 3.4 1577 */ 1578 public static void renderInsertionCursor(StyleContext context, Context cr, double x, double y, PgLayout layout, int index, PangoDirection direction) 1579 { 1580 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); 1581 } 1582 1583 /** 1584 * Renders @layout on the coordinates @x, @y 1585 * 1586 * Params: 1587 * context = a #GtkStyleContext 1588 * cr = a #cairo_t 1589 * x = X origin 1590 * y = Y origin 1591 * layout = the #PangoLayout to render 1592 * 1593 * Since: 3.0 1594 */ 1595 public static void renderLayout(StyleContext context, Context cr, double x, double y, PgLayout layout) 1596 { 1597 gtk_render_layout((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x, y, (layout is null) ? null : layout.getPgLayoutStruct()); 1598 } 1599 1600 /** 1601 * Renders a line from (x0, y0) to (x1, y1). 1602 * 1603 * Params: 1604 * context = a #GtkStyleContext 1605 * cr = a #cairo_t 1606 * x0 = X coordinate for the origin of the line 1607 * y0 = Y coordinate for the origin of the line 1608 * x1 = X coordinate for the end of the line 1609 * y1 = Y coordinate for the end of the line 1610 * 1611 * Since: 3.0 1612 */ 1613 public static void renderLine(StyleContext context, Context cr, double x0, double y0, double x1, double y1) 1614 { 1615 gtk_render_line((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x0, y0, x1, y1); 1616 } 1617 1618 /** 1619 * Renders an option mark (as in a #GtkRadioButton), the %GTK_STATE_FLAG_CHECKED 1620 * state will determine whether the option is on or off, and 1621 * %GTK_STATE_FLAG_INCONSISTENT whether it should be marked as undefined. 1622 * 1623 * Typical option mark rendering: 1624 * 1625 * ![](options.png) 1626 * 1627 * Params: 1628 * context = a #GtkStyleContext 1629 * cr = a #cairo_t 1630 * x = X origin of the rectangle 1631 * y = Y origin of the rectangle 1632 * width = rectangle width 1633 * height = rectangle height 1634 * 1635 * Since: 3.0 1636 */ 1637 public static void renderOption(StyleContext context, Context cr, double x, double y, double width, double height) 1638 { 1639 gtk_render_option((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x, y, width, height); 1640 } 1641 1642 /** 1643 * Renders a slider (as in #GtkScale) in the rectangle defined by @x, @y, 1644 * @width, @height. @orientation defines whether the slider is vertical 1645 * or horizontal. 1646 * 1647 * Typical slider rendering: 1648 * 1649 * ![](sliders.png) 1650 * 1651 * Params: 1652 * context = a #GtkStyleContext 1653 * cr = a #cairo_t 1654 * x = X origin of the rectangle 1655 * y = Y origin of the rectangle 1656 * width = rectangle width 1657 * height = rectangle height 1658 * orientation = orientation of the slider 1659 * 1660 * Since: 3.0 1661 */ 1662 public static void renderSlider(StyleContext context, Context cr, double x, double y, double width, double height, GtkOrientation orientation) 1663 { 1664 gtk_render_slider((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x, y, width, height, orientation); 1665 } 1666 }