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 public static GType getType() 155 { 156 return gtk_style_context_get_type(); 157 } 158 159 /** 160 * Creates a standalone #GtkStyleContext, this style context 161 * won’t be attached to any widget, so you may want 162 * to call gtk_style_context_set_path() yourself. 163 * 164 * This function is only useful when using the theming layer 165 * separated from GTK+, if you are using #GtkStyleContext to 166 * theme #GtkWidgets, use gtk_widget_get_style_context() 167 * in order to get a style context ready to theme the widget. 168 * 169 * Return: A newly created #GtkStyleContext. 170 * 171 * Throws: ConstructionException GTK+ fails to create the object. 172 */ 173 public this() 174 { 175 auto p = gtk_style_context_new(); 176 177 if(p is null) 178 { 179 throw new ConstructionException("null returned by new"); 180 } 181 182 this(cast(GtkStyleContext*) p, true); 183 } 184 185 /** 186 * Adds a global style provider to @screen, which will be used 187 * in style construction for all #GtkStyleContexts under @screen. 188 * 189 * GTK+ uses this to make styling information from #GtkSettings 190 * available. 191 * 192 * Note: If both priorities are the same, A #GtkStyleProvider 193 * added through gtk_style_context_add_provider() takes precedence 194 * over another added through this function. 195 * 196 * Params: 197 * screen = a #GdkScreen 198 * provider = a #GtkStyleProvider 199 * priority = the priority of the style provider. The lower 200 * it is, the earlier it will be used in the style 201 * construction. Typically this will be in the range 202 * between %GTK_STYLE_PROVIDER_PRIORITY_FALLBACK and 203 * %GTK_STYLE_PROVIDER_PRIORITY_USER 204 * 205 * Since: 3.0 206 */ 207 public static void addProviderForScreen(Screen screen, StyleProviderIF provider, uint priority) 208 { 209 gtk_style_context_add_provider_for_screen((screen is null) ? null : screen.getScreenStruct(), (provider is null) ? null : provider.getStyleProviderStruct(), priority); 210 } 211 212 /** 213 * Removes @provider from the global style providers list in @screen. 214 * 215 * Params: 216 * screen = a #GdkScreen 217 * provider = a #GtkStyleProvider 218 * 219 * Since: 3.0 220 */ 221 public static void removeProviderForScreen(Screen screen, StyleProviderIF provider) 222 { 223 gtk_style_context_remove_provider_for_screen((screen is null) ? null : screen.getScreenStruct(), (provider is null) ? null : provider.getStyleProviderStruct()); 224 } 225 226 /** 227 * This function recomputes the styles for all widgets under a particular 228 * #GdkScreen. This is useful when some global parameter has changed that 229 * affects the appearance of all widgets, because when a widget gets a new 230 * style, it will both redraw and recompute any cached information about 231 * its appearance. As an example, it is used when the color scheme changes 232 * in the related #GtkSettings object. 233 * 234 * Params: 235 * screen = a #GdkScreen 236 * 237 * Since: 3.0 238 */ 239 public static void resetWidgets(Screen screen) 240 { 241 gtk_style_context_reset_widgets((screen is null) ? null : screen.getScreenStruct()); 242 } 243 244 /** 245 * Adds a style class to @context, so posterior calls to 246 * gtk_style_context_get() or any of the gtk_render_*() 247 * functions will make use of this new class for styling. 248 * 249 * In the CSS file format, a #GtkEntry defining an “entry” 250 * class, would be matched by: 251 * 252 * |[ 253 * GtkEntry.entry { ... } 254 * ]| 255 * 256 * While any widget defining an “entry” class would be 257 * matched by: 258 * |[ 259 * .entry { ... } 260 * ]| 261 * 262 * Params: 263 * className = class name to use in styling 264 * 265 * Since: 3.0 266 */ 267 public void addClass(string className) 268 { 269 gtk_style_context_add_class(gtkStyleContext, Str.toStringz(className)); 270 } 271 272 /** 273 * Adds a style provider to @context, to be used in style construction. 274 * Note that a style provider added by this function only affects 275 * the style of the widget to which @context belongs. If you want 276 * to affect the style of all widgets, use 277 * gtk_style_context_add_provider_for_screen(). 278 * 279 * Note: If both priorities are the same, a #GtkStyleProvider 280 * added through this function takes precedence over another added 281 * through gtk_style_context_add_provider_for_screen(). 282 * 283 * Params: 284 * provider = a #GtkStyleProvider 285 * priority = the priority of the style provider. The lower 286 * it is, the earlier it will be used in the style 287 * construction. Typically this will be in the range 288 * between %GTK_STYLE_PROVIDER_PRIORITY_FALLBACK and 289 * %GTK_STYLE_PROVIDER_PRIORITY_USER 290 * 291 * Since: 3.0 292 */ 293 public void addProvider(StyleProviderIF provider, uint priority) 294 { 295 gtk_style_context_add_provider(gtkStyleContext, (provider is null) ? null : provider.getStyleProviderStruct(), priority); 296 } 297 298 /** 299 * Adds a region to @context, so posterior calls to 300 * gtk_style_context_get() or any of the gtk_render_*() 301 * functions will make use of this new region for styling. 302 * 303 * In the CSS file format, a #GtkTreeView defining a “row” 304 * region, would be matched by: 305 * 306 * |[ 307 * GtkTreeView row { ... } 308 * ]| 309 * 310 * Pseudo-classes are used for matching @flags, so the two 311 * following rules: 312 * |[ 313 * GtkTreeView row:nth-child(even) { ... } 314 * GtkTreeView row:nth-child(odd) { ... } 315 * ]| 316 * 317 * would apply to even and odd rows, respectively. 318 * 319 * Region names must only contain lowercase letters 320 * and “-”, starting always with a lowercase letter. 321 * 322 * Params: 323 * regionName = region name to use in styling 324 * flags = flags that apply to the region 325 * 326 * Since: 3.0 327 */ 328 public void addRegion(string regionName, GtkRegionFlags flags) 329 { 330 gtk_style_context_add_region(gtkStyleContext, Str.toStringz(regionName), flags); 331 } 332 333 /** 334 * Stops all running animations for @region_id and all animatable 335 * regions underneath. 336 * 337 * A %NULL @region_id will stop all ongoing animations in @context, 338 * when dealing with a #GtkStyleContext obtained through 339 * gtk_widget_get_style_context(), this is normally done for you 340 * in all circumstances you would expect all widget to be stopped, 341 * so this should be only used in complex widgets with different 342 * animatable regions. 343 * 344 * Deprecated: This function does nothing. 345 * 346 * Params: 347 * regionId = animatable region to stop, or %NULL. 348 * See gtk_style_context_push_animatable_region() 349 * 350 * Since: 3.0 351 */ 352 public void cancelAnimations(void* regionId) 353 { 354 gtk_style_context_cancel_animations(gtkStyleContext, regionId); 355 } 356 357 /** 358 * Gets the background color for a given state. 359 * 360 * This function is far less useful than it seems, and it should not be used in 361 * newly written code. CSS has no concept of "background color", as a background 362 * can be an image, or a gradient, or any other pattern including solid colors. 363 * 364 * The only reason why you would call gtk_style_context_get_background_color() is 365 * to use the returned value to draw the background with it; the correct way to 366 * achieve this result is to use gtk_render_background() instead, along with CSS 367 * style classes to modify the color to be rendered. 368 * 369 * Deprecated: Use gtk_render_background() instead. 370 * 371 * Params: 372 * state = state to retrieve the color for 373 * color = return value for the background color 374 * 375 * Since: 3.0 376 */ 377 public void getBackgroundColor(GtkStateFlags state, out RGBA color) 378 { 379 GdkRGBA* outcolor = gMalloc!GdkRGBA(); 380 381 gtk_style_context_get_background_color(gtkStyleContext, state, outcolor); 382 383 color = ObjectG.getDObject!(RGBA)(outcolor); 384 } 385 386 /** 387 * Gets the border for a given state as a #GtkBorder. 388 * See %GTK_STYLE_PROPERTY_BORDER_WIDTH. 389 * 390 * Params: 391 * state = state to retrieve the border for 392 * border = return value for the border settings 393 * 394 * Since: 3.0 395 */ 396 public void getBorder(GtkStateFlags state, out Border border) 397 { 398 GtkBorder* outborder = gMalloc!GtkBorder(); 399 400 gtk_style_context_get_border(gtkStyleContext, state, outborder); 401 402 border = ObjectG.getDObject!(Border)(outborder); 403 } 404 405 /** 406 * Gets the border color for a given state. 407 * 408 * Deprecated: Use gtk_render_border() instead. 409 * 410 * Params: 411 * state = state to retrieve the color for 412 * color = return value for the border color 413 * 414 * Since: 3.0 415 */ 416 public void getBorderColor(GtkStateFlags state, out RGBA color) 417 { 418 GdkRGBA* outcolor = gMalloc!GdkRGBA(); 419 420 gtk_style_context_get_border_color(gtkStyleContext, state, outcolor); 421 422 color = ObjectG.getDObject!(RGBA)(outcolor); 423 } 424 425 /** 426 * Gets the foreground color for a given state. 427 * 428 * Params: 429 * state = state to retrieve the color for 430 * color = return value for the foreground color 431 * 432 * Since: 3.0 433 */ 434 public void getColor(GtkStateFlags state, out RGBA color) 435 { 436 GdkRGBA* outcolor = gMalloc!GdkRGBA(); 437 438 gtk_style_context_get_color(gtkStyleContext, state, outcolor); 439 440 color = ObjectG.getDObject!(RGBA)(outcolor); 441 } 442 443 /** 444 * Returns the widget direction used for rendering. 445 * 446 * Deprecated: Use gtk_style_context_get_state() and 447 * check for #GTK_STATE_FLAG_DIR_LTR and 448 * #GTK_STATE_FLAG_DIR_RTL instead. 449 * 450 * Return: the widget direction 451 * 452 * Since: 3.0 453 */ 454 public GtkTextDirection getDirection() 455 { 456 return gtk_style_context_get_direction(gtkStyleContext); 457 } 458 459 /** 460 * Returns the font description for a given state. The returned 461 * object is const and will remain valid until the 462 * #GtkStyleContext::changed signal happens. 463 * 464 * Deprecated: Use gtk_style_context_get() for "font" or 465 * subproperties instead. 466 * 467 * Params: 468 * state = state to retrieve the font for 469 * 470 * Return: the #PangoFontDescription for the given 471 * state. This object is owned by GTK+ and should not be 472 * freed. 473 * 474 * Since: 3.0 475 */ 476 public PgFontDescription getFont(GtkStateFlags state) 477 { 478 auto p = gtk_style_context_get_font(gtkStyleContext, state); 479 480 if(p is null) 481 { 482 return null; 483 } 484 485 return ObjectG.getDObject!(PgFontDescription)(cast(PangoFontDescription*) p); 486 } 487 488 /** 489 * Returns the #GdkFrameClock to which @context is attached. 490 * 491 * Return: a #GdkFrameClock, or %NULL 492 * if @context does not have an attached frame clock. 493 * 494 * Since: 3.8 495 */ 496 public FrameClock getFrameClock() 497 { 498 auto p = gtk_style_context_get_frame_clock(gtkStyleContext); 499 500 if(p is null) 501 { 502 return null; 503 } 504 505 return ObjectG.getDObject!(FrameClock)(cast(GdkFrameClock*) p); 506 } 507 508 /** 509 * Returns the sides where rendered elements connect visually with others. 510 * 511 * Return: the junction sides 512 * 513 * Since: 3.0 514 */ 515 public GtkJunctionSides getJunctionSides() 516 { 517 return gtk_style_context_get_junction_sides(gtkStyleContext); 518 } 519 520 /** 521 * Gets the margin for a given state as a #GtkBorder. 522 * See %GTK_STYLE_PROPERTY_MARGIN. 523 * 524 * Params: 525 * state = state to retrieve the border for 526 * margin = return value for the margin settings 527 * 528 * Since: 3.0 529 */ 530 public void getMargin(GtkStateFlags state, out Border margin) 531 { 532 GtkBorder* outmargin = gMalloc!GtkBorder(); 533 534 gtk_style_context_get_margin(gtkStyleContext, state, outmargin); 535 536 margin = ObjectG.getDObject!(Border)(outmargin); 537 } 538 539 /** 540 * Gets the padding for a given state as a #GtkBorder. 541 * See %GTK_STYLE_PROPERTY_PADDING. 542 * 543 * Params: 544 * state = state to retrieve the padding for 545 * padding = return value for the padding settings 546 * 547 * Since: 3.0 548 */ 549 public void getPadding(GtkStateFlags state, out Border padding) 550 { 551 GtkBorder* outpadding = gMalloc!GtkBorder(); 552 553 gtk_style_context_get_padding(gtkStyleContext, state, outpadding); 554 555 padding = ObjectG.getDObject!(Border)(outpadding); 556 } 557 558 /** 559 * Gets the parent context set via gtk_style_context_set_parent(). 560 * See that function for details. 561 * 562 * Return: the parent context or %NULL 563 * 564 * Since: 3.4 565 */ 566 public StyleContext getParent() 567 { 568 auto p = gtk_style_context_get_parent(gtkStyleContext); 569 570 if(p is null) 571 { 572 return null; 573 } 574 575 return ObjectG.getDObject!(StyleContext)(cast(GtkStyleContext*) p); 576 } 577 578 /** 579 * Returns the widget path used for style matching. 580 * 581 * Return: A #GtkWidgetPath 582 * 583 * Since: 3.0 584 */ 585 public WidgetPath getPath() 586 { 587 auto p = gtk_style_context_get_path(gtkStyleContext); 588 589 if(p is null) 590 { 591 return null; 592 } 593 594 return ObjectG.getDObject!(WidgetPath)(cast(GtkWidgetPath*) p); 595 } 596 597 /** 598 * Gets a style property from @context for the given state. 599 * 600 * When @value is no longer needed, g_value_unset() must be called 601 * to free any allocated memory. 602 * 603 * Params: 604 * property = style property name 605 * state = state to retrieve the property value for 606 * value = return location for the style property value 607 * 608 * Since: 3.0 609 */ 610 public void getProperty(string property, GtkStateFlags state, out Value value) 611 { 612 GValue* outvalue = gMalloc!GValue(); 613 614 gtk_style_context_get_property(gtkStyleContext, Str.toStringz(property), state, outvalue); 615 616 value = ObjectG.getDObject!(Value)(outvalue); 617 } 618 619 /** 620 * Returns the scale used for assets. 621 * 622 * Return: the scale 623 * 624 * Since: 3.10 625 */ 626 public int getScale() 627 { 628 return gtk_style_context_get_scale(gtkStyleContext); 629 } 630 631 /** 632 * Returns the #GdkScreen to which @context is attached. 633 * 634 * Return: a #GdkScreen. 635 */ 636 public Screen getScreen() 637 { 638 auto p = gtk_style_context_get_screen(gtkStyleContext); 639 640 if(p is null) 641 { 642 return null; 643 } 644 645 return ObjectG.getDObject!(Screen)(cast(GdkScreen*) p); 646 } 647 648 /** 649 * Queries the location in the CSS where @property was defined for the 650 * current @context. Note that the state to be queried is taken from 651 * gtk_style_context_get_state(). 652 * 653 * If the location is not available, %NULL will be returned. The 654 * location might not be available for various reasons, such as the 655 * property being overridden, @property not naming a supported CSS 656 * property or tracking of definitions being disabled for performance 657 * reasons. 658 * 659 * Shorthand CSS properties cannot be queried for a location and will 660 * always return %NULL. 661 * 662 * Params: 663 * property = style property name 664 * 665 * Return: %NULL or the section where value was defined 666 */ 667 public CssSection getSection(string property) 668 { 669 auto p = gtk_style_context_get_section(gtkStyleContext, Str.toStringz(property)); 670 671 if(p is null) 672 { 673 return null; 674 } 675 676 return ObjectG.getDObject!(CssSection)(cast(GtkCssSection*) p); 677 } 678 679 /** 680 * Returns the state used when rendering. 681 * 682 * Return: the state flags 683 * 684 * Since: 3.0 685 */ 686 public GtkStateFlags getState() 687 { 688 return gtk_style_context_get_state(gtkStyleContext); 689 } 690 691 /** 692 * Gets the value for a widget style property. 693 * 694 * When @value is no longer needed, g_value_unset() must be called 695 * to free any allocated memory. 696 * 697 * Params: 698 * propertyName = the name of the widget style property 699 * value = Return location for the property value 700 */ 701 public void getStyleProperty(string propertyName, Value value) 702 { 703 gtk_style_context_get_style_property(gtkStyleContext, Str.toStringz(propertyName), (value is null) ? null : value.getValueStruct()); 704 } 705 706 /** 707 * Retrieves several widget style properties from @context according to the 708 * current style. 709 * 710 * Params: 711 * args = va_list of property name/return location pairs, followed by %NULL 712 * 713 * Since: 3.0 714 */ 715 public void getStyleValist(void* args) 716 { 717 gtk_style_context_get_style_valist(gtkStyleContext, args); 718 } 719 720 /** 721 * Retrieves several style property values from @context for a given state. 722 * 723 * Params: 724 * state = state to retrieve the property values for 725 * args = va_list of property name/return location pairs, followed by %NULL 726 * 727 * Since: 3.0 728 */ 729 public void getValist(GtkStateFlags state, void* args) 730 { 731 gtk_style_context_get_valist(gtkStyleContext, state, args); 732 } 733 734 /** 735 * Returns %TRUE if @context currently has defined the 736 * given class name 737 * 738 * Params: 739 * className = a class name 740 * 741 * Return: %TRUE if @context has @class_name defined 742 * 743 * Since: 3.0 744 */ 745 public bool hasClass(string className) 746 { 747 return gtk_style_context_has_class(gtkStyleContext, Str.toStringz(className)) != 0; 748 } 749 750 /** 751 * Returns %TRUE if @context has the region defined. 752 * If @flags_return is not %NULL, it is set to the flags 753 * affecting the region. 754 * 755 * Params: 756 * regionName = a region name 757 * flagsReturn = return location for region flags 758 * 759 * Return: %TRUE if region is defined 760 * 761 * Since: 3.0 762 */ 763 public bool hasRegion(string regionName, out GtkRegionFlags flagsReturn) 764 { 765 return gtk_style_context_has_region(gtkStyleContext, Str.toStringz(regionName), &flagsReturn) != 0; 766 } 767 768 /** 769 * Invalidates @context style information, so it will be reconstructed 770 * again. It is useful if you modify the @context and need the new 771 * information immediately. 772 * 773 * Deprecated: Style contexts are invalidated automatically. 774 * 775 * Since: 3.0 776 */ 777 public void invalidate() 778 { 779 gtk_style_context_invalidate(gtkStyleContext); 780 } 781 782 /** 783 * Returns the list of classes currently defined in @context. 784 * 785 * Return: a #GList of 786 * strings with the currently defined classes. The contents 787 * of the list are owned by GTK+, but you must free the list 788 * itself with g_list_free() when you are done with it. 789 * 790 * Since: 3.0 791 */ 792 public ListG listClasses() 793 { 794 auto p = gtk_style_context_list_classes(gtkStyleContext); 795 796 if(p is null) 797 { 798 return null; 799 } 800 801 return new ListG(cast(GList*) p); 802 } 803 804 /** 805 * Returns the list of regions currently defined in @context. 806 * 807 * Return: a #GList of 808 * strings with the currently defined regions. The contents 809 * of the list are owned by GTK+, but you must free the list 810 * itself with g_list_free() when you are done with it. 811 * 812 * Since: 3.0 813 */ 814 public ListG listRegions() 815 { 816 auto p = gtk_style_context_list_regions(gtkStyleContext); 817 818 if(p is null) 819 { 820 return null; 821 } 822 823 return new ListG(cast(GList*) p); 824 } 825 826 /** 827 * Looks up and resolves a color name in the @context color map. 828 * 829 * Params: 830 * colorName = color name to lookup 831 * color = Return location for the looked up color 832 * 833 * Return: %TRUE if @color_name was found and resolved, %FALSE otherwise 834 */ 835 public bool lookupColor(string colorName, out RGBA color) 836 { 837 GdkRGBA* outcolor = gMalloc!GdkRGBA(); 838 839 auto p = gtk_style_context_lookup_color(gtkStyleContext, Str.toStringz(colorName), outcolor) != 0; 840 841 color = ObjectG.getDObject!(RGBA)(outcolor); 842 843 return p; 844 } 845 846 /** 847 * Looks up @stock_id in the icon factories associated to @context and 848 * the default icon factory, returning an icon set if found, otherwise 849 * %NULL. 850 * 851 * Deprecated: Use gtk_icon_theme_lookup_icon() instead. 852 * 853 * Params: 854 * stockId = an icon name 855 * 856 * Return: The looked up %GtkIconSet, or %NULL 857 */ 858 public IconSet lookupIconSet(string stockId) 859 { 860 auto p = gtk_style_context_lookup_icon_set(gtkStyleContext, Str.toStringz(stockId)); 861 862 if(p is null) 863 { 864 return null; 865 } 866 867 return ObjectG.getDObject!(IconSet)(cast(GtkIconSet*) p); 868 } 869 870 /** 871 * Notifies a state change on @context, so if the current style makes use 872 * of transition animations, one will be started so all rendered elements 873 * under @region_id are animated for state @state being set to value 874 * @state_value. 875 * 876 * The @window parameter is used in order to invalidate the rendered area 877 * as the animation runs, so make sure it is the same window that is being 878 * rendered on by the gtk_render_*() functions. 879 * 880 * If @region_id is %NULL, all rendered elements using @context will be 881 * affected by this state transition. 882 * 883 * As a practical example, a #GtkButton notifying a state transition on 884 * the prelight state: 885 * |[<!-- language="C" --> 886 * gtk_style_context_notify_state_change (context, 887 * gtk_widget_get_window (widget), 888 * NULL, 889 * GTK_STATE_PRELIGHT, 890 * button->in_button); 891 * ]| 892 * 893 * Can be handled in the CSS file like this: 894 * |[ 895 * GtkButton { 896 * background-color: #f00 897 * } 898 * 899 * GtkButton:hover { 900 * background-color: #fff; 901 * transition: 200ms linear 902 * } 903 * ]| 904 * 905 * This combination will animate the button background from red to white 906 * if a pointer enters the button, and back to red if the pointer leaves 907 * the button. 908 * 909 * Note that @state is used when finding the transition parameters, which 910 * is why the style places the transition under the :hover pseudo-class. 911 * 912 * Deprecated: This function does nothing. 913 * 914 * Params: 915 * window = a #GdkWindow 916 * regionId = animatable region to notify on, or %NULL. 917 * See gtk_style_context_push_animatable_region() 918 * state = state to trigger transition for 919 * stateValue = %TRUE if @state is the state we are changing to, 920 * %FALSE if we are changing away from it 921 * 922 * Since: 3.0 923 */ 924 public void notifyStateChange(Window window, void* regionId, GtkStateType state, bool stateValue) 925 { 926 gtk_style_context_notify_state_change(gtkStyleContext, (window is null) ? null : window.getWindowStruct(), regionId, state, stateValue); 927 } 928 929 /** 930 * Pops an animatable region from @context. 931 * See gtk_style_context_push_animatable_region(). 932 * 933 * Deprecated: This function does nothing. 934 * 935 * Since: 3.0 936 */ 937 public void popAnimatableRegion() 938 { 939 gtk_style_context_pop_animatable_region(gtkStyleContext); 940 } 941 942 /** 943 * Pushes an animatable region, so all further gtk_render_*() calls between 944 * this call and the following gtk_style_context_pop_animatable_region() 945 * will potentially show transition animations for this region if 946 * gtk_style_context_notify_state_change() is called for a given state, 947 * and the current theme/style defines transition animations for state 948 * changes. 949 * 950 * The @region_id used must be unique in @context so the themes 951 * can uniquely identify rendered elements subject to a state transition. 952 * 953 * Deprecated: This function does nothing. 954 * 955 * Params: 956 * regionId = unique identifier for the animatable region 957 * 958 * Since: 3.0 959 */ 960 public void pushAnimatableRegion(void* regionId) 961 { 962 gtk_style_context_push_animatable_region(gtkStyleContext, regionId); 963 } 964 965 /** 966 * Removes @class_name from @context. 967 * 968 * Params: 969 * className = class name to remove 970 * 971 * Since: 3.0 972 */ 973 public void removeClass(string className) 974 { 975 gtk_style_context_remove_class(gtkStyleContext, Str.toStringz(className)); 976 } 977 978 /** 979 * Removes @provider from the style providers list in @context. 980 * 981 * Params: 982 * provider = a #GtkStyleProvider 983 * 984 * Since: 3.0 985 */ 986 public void removeProvider(StyleProviderIF provider) 987 { 988 gtk_style_context_remove_provider(gtkStyleContext, (provider is null) ? null : provider.getStyleProviderStruct()); 989 } 990 991 /** 992 * Removes a region from @context. 993 * 994 * Params: 995 * regionName = region name to unset 996 * 997 * Since: 3.0 998 */ 999 public void removeRegion(string regionName) 1000 { 1001 gtk_style_context_remove_region(gtkStyleContext, Str.toStringz(regionName)); 1002 } 1003 1004 /** 1005 * Restores @context state to a previous stage. 1006 * See gtk_style_context_save(). 1007 * 1008 * Since: 3.0 1009 */ 1010 public void restore() 1011 { 1012 gtk_style_context_restore(gtkStyleContext); 1013 } 1014 1015 /** 1016 * Saves the @context state, so temporary modifications done through 1017 * gtk_style_context_add_class(), gtk_style_context_remove_class(), 1018 * gtk_style_context_set_state(), etc. can quickly be reverted 1019 * in one go through gtk_style_context_restore(). 1020 * 1021 * The matching call to gtk_style_context_restore() must be done 1022 * before GTK returns to the main loop. 1023 * 1024 * Since: 3.0 1025 */ 1026 public void save() 1027 { 1028 gtk_style_context_save(gtkStyleContext); 1029 } 1030 1031 /** 1032 * This function is analogous to gdk_window_scroll(), and 1033 * should be called together with it so the invalidation 1034 * areas for any ongoing animation are scrolled together 1035 * with it. 1036 * 1037 * Deprecated: This function does nothing. 1038 * 1039 * Params: 1040 * window = a #GdkWindow used previously in 1041 * gtk_style_context_notify_state_change() 1042 * dx = Amount to scroll in the X axis 1043 * dy = Amount to scroll in the Y axis 1044 * 1045 * Since: 3.0 1046 */ 1047 public void scrollAnimations(Window window, int dx, int dy) 1048 { 1049 gtk_style_context_scroll_animations(gtkStyleContext, (window is null) ? null : window.getWindowStruct(), dx, dy); 1050 } 1051 1052 /** 1053 * Sets the background of @window to the background pattern or 1054 * color specified in @context for its current state. 1055 * 1056 * Deprecated: Use gtk_render_background() instead. 1057 * Note that clients still using this function are now responsible 1058 * for calling this function again whenever @context is invalidated. 1059 * 1060 * Params: 1061 * window = a #GdkWindow 1062 * 1063 * Since: 3.0 1064 */ 1065 public void setBackground(Window window) 1066 { 1067 gtk_style_context_set_background(gtkStyleContext, (window is null) ? null : window.getWindowStruct()); 1068 } 1069 1070 /** 1071 * Sets the reading direction for rendering purposes. 1072 * 1073 * If you are using a #GtkStyleContext returned from 1074 * gtk_widget_get_style_context(), you do not need to 1075 * call this yourself. 1076 * 1077 * Deprecated: Use gtk_style_context_set_state() with 1078 * #GTK_STATE_FLAG_DIR_LTR and #GTK_STATE_FLAG_DIR_RTL 1079 * instead. 1080 * 1081 * Params: 1082 * direction = the new direction. 1083 * 1084 * Since: 3.0 1085 */ 1086 public void setDirection(GtkTextDirection direction) 1087 { 1088 gtk_style_context_set_direction(gtkStyleContext, direction); 1089 } 1090 1091 /** 1092 * Attaches @context to the given frame clock. 1093 * 1094 * The frame clock is used for the timing of animations. 1095 * 1096 * If you are using a #GtkStyleContext returned from 1097 * gtk_widget_get_style_context(), you do not need to 1098 * call this yourself. 1099 * 1100 * Params: 1101 * frameClock = a #GdkFrameClock 1102 * 1103 * Since: 3.8 1104 */ 1105 public void setFrameClock(FrameClock frameClock) 1106 { 1107 gtk_style_context_set_frame_clock(gtkStyleContext, (frameClock is null) ? null : frameClock.getFrameClockStruct()); 1108 } 1109 1110 /** 1111 * Sets the sides where rendered elements (mostly through 1112 * gtk_render_frame()) will visually connect with other visual elements. 1113 * 1114 * This is merely a hint that may or may not be honored 1115 * by themes. 1116 * 1117 * Container widgets are expected to set junction hints as appropriate 1118 * for their children, so it should not normally be necessary to call 1119 * this function manually. 1120 * 1121 * Params: 1122 * sides = sides where rendered elements are visually connected to 1123 * other elements 1124 * 1125 * Since: 3.0 1126 */ 1127 public void setJunctionSides(GtkJunctionSides sides) 1128 { 1129 gtk_style_context_set_junction_sides(gtkStyleContext, sides); 1130 } 1131 1132 /** 1133 * Sets the parent style context for @context. The parent style 1134 * context is used to implement 1135 * [inheritance](http://www.w3.org/TR/css3-cascade/#inheritance) 1136 * of properties. 1137 * 1138 * If you are using a #GtkStyleContext returned from 1139 * gtk_widget_get_style_context(), the parent will be set for you. 1140 * 1141 * Params: 1142 * parent = the new parent or %NULL 1143 * 1144 * Since: 3.4 1145 */ 1146 public void setParent(StyleContext parent) 1147 { 1148 gtk_style_context_set_parent(gtkStyleContext, (parent is null) ? null : parent.getStyleContextStruct()); 1149 } 1150 1151 /** 1152 * Sets the #GtkWidgetPath used for style matching. As a 1153 * consequence, the style will be regenerated to match 1154 * the new given path. 1155 * 1156 * If you are using a #GtkStyleContext returned from 1157 * gtk_widget_get_style_context(), you do not need to call 1158 * this yourself. 1159 * 1160 * Params: 1161 * path = a #GtkWidgetPath 1162 * 1163 * Since: 3.0 1164 */ 1165 public void setPath(WidgetPath path) 1166 { 1167 gtk_style_context_set_path(gtkStyleContext, (path is null) ? null : path.getWidgetPathStruct()); 1168 } 1169 1170 /** 1171 * Sets the scale to use when getting image assets for the style . 1172 * 1173 * Params: 1174 * scale = scale 1175 * 1176 * Since: 3.10 1177 */ 1178 public void setScale(int scale) 1179 { 1180 gtk_style_context_set_scale(gtkStyleContext, scale); 1181 } 1182 1183 /** 1184 * Attaches @context to the given screen. 1185 * 1186 * The screen is used to add style information from “global” style 1187 * providers, such as the screens #GtkSettings instance. 1188 * 1189 * If you are using a #GtkStyleContext returned from 1190 * gtk_widget_get_style_context(), you do not need to 1191 * call this yourself. 1192 * 1193 * Params: 1194 * screen = a #GdkScreen 1195 * 1196 * Since: 3.0 1197 */ 1198 public void setScreen(Screen screen) 1199 { 1200 gtk_style_context_set_screen(gtkStyleContext, (screen is null) ? null : screen.getScreenStruct()); 1201 } 1202 1203 /** 1204 * Sets the state to be used when rendering with any 1205 * of the gtk_render_*() functions. 1206 * 1207 * Params: 1208 * flags = state to represent 1209 * 1210 * Since: 3.0 1211 */ 1212 public void setState(GtkStateFlags flags) 1213 { 1214 gtk_style_context_set_state(gtkStyleContext, flags); 1215 } 1216 1217 /** 1218 * Returns %TRUE if there is a transition animation running for the 1219 * current region (see gtk_style_context_push_animatable_region()). 1220 * 1221 * If @progress is not %NULL, the animation progress will be returned 1222 * there, 0.0 means the state is closest to being unset, while 1.0 means 1223 * it’s closest to being set. This means transition animation will 1224 * run from 0 to 1 when @state is being set and from 1 to 0 when 1225 * it’s being unset. 1226 * 1227 * Deprecated: This function always returns %FALSE 1228 * 1229 * Params: 1230 * state = a widget state 1231 * progress = return location for the transition progress 1232 * 1233 * Return: %TRUE if there is a running transition animation for @state. 1234 * 1235 * Since: 3.0 1236 */ 1237 public bool stateIsRunning(GtkStateType state, out double progress) 1238 { 1239 return gtk_style_context_state_is_running(gtkStyleContext, state, &progress) != 0; 1240 } 1241 1242 int[string] connectedSignals; 1243 1244 void delegate(StyleContext)[] onChangedListeners; 1245 /** */ 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⁄2 π;, π; and 3⁄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 * This function will render the icon in @pixbuf at exactly its size, 1510 * regardless of scaling factors, which may not be appropriate when 1511 * drawing on displays with high pixel densities. 1512 * 1513 * You probably want to use gtk_render_icon_surface() instead, if you 1514 * already have a Cairo surface. 1515 * 1516 * Params: 1517 * context = a #GtkStyleContext 1518 * cr = a #cairo_t 1519 * pixbuf = a #GdkPixbuf containing the icon to draw 1520 * x = X position for the @pixbuf 1521 * y = Y position for the @pixbuf 1522 * 1523 * Since: 3.2 1524 */ 1525 public static void renderIcon(StyleContext context, Context cr, Pixbuf pixbuf, double x, double y) 1526 { 1527 gtk_render_icon((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), (pixbuf is null) ? null : pixbuf.getPixbufStruct(), x, y); 1528 } 1529 1530 /** 1531 * Renders the icon specified by @source at the given @size, returning the result 1532 * in a pixbuf. 1533 * 1534 * Deprecated: Use gtk_icon_theme_load_icon() instead. 1535 * 1536 * Params: 1537 * context = a #GtkStyleContext 1538 * source = the #GtkIconSource specifying the icon to render 1539 * size = the size to render the icon at. A size of (GtkIconSize) -1 1540 * means render at the size of the source and don’t scale. 1541 * 1542 * Return: a newly-created #GdkPixbuf containing the rendered icon 1543 * 1544 * Since: 3.0 1545 */ 1546 public static Pixbuf renderIconPixbuf(StyleContext context, IconSource source, GtkIconSize size) 1547 { 1548 auto p = gtk_render_icon_pixbuf((context is null) ? null : context.getStyleContextStruct(), (source is null) ? null : source.getIconSourceStruct(), size); 1549 1550 if(p is null) 1551 { 1552 return null; 1553 } 1554 1555 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true); 1556 } 1557 1558 /** 1559 * Renders the icon in @surface at the specified @x and @y coordinates. 1560 * 1561 * Params: 1562 * context = a #GtkStyleContext 1563 * cr = a #cairo_t 1564 * surface = a #cairo_surface_t containing the icon to draw 1565 * x = X position for the @icon 1566 * y = Y position for the @incon 1567 * 1568 * Since: 3.10 1569 */ 1570 public static void renderIconSurface(StyleContext context, Context cr, Surface surface, double x, double y) 1571 { 1572 gtk_render_icon_surface((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), (surface is null) ? null : surface.getSurfaceStruct(), x, y); 1573 } 1574 1575 /** 1576 * Draws a text caret on @cr at the specified index of @layout. 1577 * 1578 * Params: 1579 * context = a #GtkStyleContext 1580 * cr = a #cairo_t 1581 * x = X origin 1582 * y = Y origin 1583 * layout = the #PangoLayout of the text 1584 * index = the index in the #PangoLayout 1585 * direction = the #PangoDirection of the text 1586 * 1587 * Since: 3.4 1588 */ 1589 public static void renderInsertionCursor(StyleContext context, Context cr, double x, double y, PgLayout layout, int index, PangoDirection direction) 1590 { 1591 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); 1592 } 1593 1594 /** 1595 * Renders @layout on the coordinates @x, @y 1596 * 1597 * Params: 1598 * context = a #GtkStyleContext 1599 * cr = a #cairo_t 1600 * x = X origin 1601 * y = Y origin 1602 * layout = the #PangoLayout to render 1603 * 1604 * Since: 3.0 1605 */ 1606 public static void renderLayout(StyleContext context, Context cr, double x, double y, PgLayout layout) 1607 { 1608 gtk_render_layout((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x, y, (layout is null) ? null : layout.getPgLayoutStruct()); 1609 } 1610 1611 /** 1612 * Renders a line from (x0, y0) to (x1, y1). 1613 * 1614 * Params: 1615 * context = a #GtkStyleContext 1616 * cr = a #cairo_t 1617 * x0 = X coordinate for the origin of the line 1618 * y0 = Y coordinate for the origin of the line 1619 * x1 = X coordinate for the end of the line 1620 * y1 = Y coordinate for the end of the line 1621 * 1622 * Since: 3.0 1623 */ 1624 public static void renderLine(StyleContext context, Context cr, double x0, double y0, double x1, double y1) 1625 { 1626 gtk_render_line((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x0, y0, x1, y1); 1627 } 1628 1629 /** 1630 * Renders an option mark (as in a #GtkRadioButton), the %GTK_STATE_FLAG_CHECKED 1631 * state will determine whether the option is on or off, and 1632 * %GTK_STATE_FLAG_INCONSISTENT whether it should be marked as undefined. 1633 * 1634 * Typical option mark rendering: 1635 * 1636 * ![](options.png) 1637 * 1638 * Params: 1639 * context = a #GtkStyleContext 1640 * cr = a #cairo_t 1641 * x = X origin of the rectangle 1642 * y = Y origin of the rectangle 1643 * width = rectangle width 1644 * height = rectangle height 1645 * 1646 * Since: 3.0 1647 */ 1648 public static void renderOption(StyleContext context, Context cr, double x, double y, double width, double height) 1649 { 1650 gtk_render_option((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x, y, width, height); 1651 } 1652 1653 /** 1654 * Renders a slider (as in #GtkScale) in the rectangle defined by @x, @y, 1655 * @width, @height. @orientation defines whether the slider is vertical 1656 * or horizontal. 1657 * 1658 * Typical slider rendering: 1659 * 1660 * ![](sliders.png) 1661 * 1662 * Params: 1663 * context = a #GtkStyleContext 1664 * cr = a #cairo_t 1665 * x = X origin of the rectangle 1666 * y = Y origin of the rectangle 1667 * width = rectangle width 1668 * height = rectangle height 1669 * orientation = orientation of the slider 1670 * 1671 * Since: 3.0 1672 */ 1673 public static void renderSlider(StyleContext context, Context cr, double x, double y, double width, double height, GtkOrientation orientation) 1674 { 1675 gtk_render_slider((context is null) ? null : context.getStyleContextStruct(), (cr is null) ? null : cr.getContextStruct(), x, y, width, height, orientation); 1676 } 1677 }