1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
31 #include <gobject/gvaluecollector.h>
32 #include "gtkmarshalers.h"
35 #include "gtkspinbutton.h"
37 #include "gtkstylecontextprivate.h"
38 #include "gtkwidget.h"
39 #include "gtkiconfactory.h"
42 #include "gtkspinner.h"
43 #include "gtkborder.h"
47 * @Short_description: Deprecated object that holds style information
51 * A #GtkStyle object encapsulates the information that provides the look and
55 * In GTK+ 3.0, GtkStyle has been deprecated and replaced by #GtkStyleContext.
58 * Each #GtkWidget has an associated #GtkStyle object that is used when
59 * rendering that widget. Also, a #GtkStyle holds information for the five
60 * possible widget states though not every widget supports all five
61 * states; see #GtkStateType.
63 * Usually the #GtkStyle for a widget is the same as the default style that
64 * is set by GTK+ and modified the theme engine.
66 * Usually applications should not need to use or modify the #GtkStyle of
71 #define LIGHTNESS_MULT 1.3
72 #define DARKNESS_MULT 0.7
74 /* --- typedefs & structures --- */
81 #define GTK_STYLE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_STYLE, GtkStylePrivate))
83 typedef struct _GtkStylePrivate GtkStylePrivate;
85 struct _GtkStylePrivate {
86 GtkStyleContext *context;
87 gulong context_changed_id;
95 /* --- prototypes --- */
96 static void gtk_style_finalize (GObject *object);
97 static void gtk_style_constructed (GObject *object);
98 static void gtk_style_set_property (GObject *object,
102 static void gtk_style_get_property (GObject *object,
107 static void gtk_style_real_realize (GtkStyle *style);
108 static void gtk_style_real_unrealize (GtkStyle *style);
109 static void gtk_style_real_copy (GtkStyle *style,
111 static void gtk_style_real_set_background (GtkStyle *style,
113 GtkStateType state_type);
114 static GtkStyle *gtk_style_real_clone (GtkStyle *style);
115 static void gtk_style_real_init_from_rc (GtkStyle *style,
116 GtkRcStyle *rc_style);
117 static GdkPixbuf *gtk_default_render_icon (GtkStyle *style,
118 const GtkIconSource *source,
119 GtkTextDirection direction,
123 const gchar *detail);
124 static void gtk_default_draw_hline (GtkStyle *style,
126 GtkStateType state_type,
132 static void gtk_default_draw_vline (GtkStyle *style,
134 GtkStateType state_type,
140 static void gtk_default_draw_shadow (GtkStyle *style,
142 GtkStateType state_type,
143 GtkShadowType shadow_type,
150 static void gtk_default_draw_arrow (GtkStyle *style,
152 GtkStateType state_type,
153 GtkShadowType shadow_type,
156 GtkArrowType arrow_type,
162 static void gtk_default_draw_diamond (GtkStyle *style,
164 GtkStateType state_type,
165 GtkShadowType shadow_type,
172 static void gtk_default_draw_box (GtkStyle *style,
174 GtkStateType state_type,
175 GtkShadowType shadow_type,
182 static void gtk_default_draw_flat_box (GtkStyle *style,
184 GtkStateType state_type,
185 GtkShadowType shadow_type,
192 static void gtk_default_draw_check (GtkStyle *style,
194 GtkStateType state_type,
195 GtkShadowType shadow_type,
202 static void gtk_default_draw_option (GtkStyle *style,
204 GtkStateType state_type,
205 GtkShadowType shadow_type,
212 static void gtk_default_draw_tab (GtkStyle *style,
214 GtkStateType state_type,
215 GtkShadowType shadow_type,
222 static void gtk_default_draw_shadow_gap (GtkStyle *style,
224 GtkStateType state_type,
225 GtkShadowType shadow_type,
232 GtkPositionType gap_side,
235 static void gtk_default_draw_box_gap (GtkStyle *style,
237 GtkStateType state_type,
238 GtkShadowType shadow_type,
245 GtkPositionType gap_side,
248 static void gtk_default_draw_extension (GtkStyle *style,
250 GtkStateType state_type,
251 GtkShadowType shadow_type,
258 GtkPositionType gap_side);
259 static void gtk_default_draw_focus (GtkStyle *style,
261 GtkStateType state_type,
268 static void gtk_default_draw_slider (GtkStyle *style,
270 GtkStateType state_type,
271 GtkShadowType shadow_type,
278 GtkOrientation orientation);
279 static void gtk_default_draw_handle (GtkStyle *style,
281 GtkStateType state_type,
282 GtkShadowType shadow_type,
289 GtkOrientation orientation);
290 static void gtk_default_draw_expander (GtkStyle *style,
292 GtkStateType state_type,
297 GtkExpanderStyle expander_style);
298 static void gtk_default_draw_layout (GtkStyle *style,
300 GtkStateType state_type,
306 PangoLayout *layout);
307 static void gtk_default_draw_resize_grip (GtkStyle *style,
309 GtkStateType state_type,
317 static void gtk_default_draw_spinner (GtkStyle *style,
319 GtkStateType state_type,
328 static void rgb_to_hls (gdouble *r,
331 static void hls_to_rgb (gdouble *h,
335 static void transform_detail_string (const gchar *detail,
336 GtkStyleContext *context);
339 * Data for default check and radio buttons
342 static const GtkRequisition default_option_indicator_size = { 7, 13 };
343 static const GtkBorder default_option_indicator_spacing = { 7, 5, 2, 2 };
345 #define GTK_GRAY 0xdcdc, 0xdada, 0xd5d5
346 #define GTK_DARK_GRAY 0xc4c4, 0xc2c2, 0xbdbd
347 #define GTK_LIGHT_GRAY 0xeeee, 0xebeb, 0xe7e7
348 #define GTK_WHITE 0xffff, 0xffff, 0xffff
349 #define GTK_BLUE 0x4b4b, 0x6969, 0x8383
350 #define GTK_VERY_DARK_GRAY 0x9c9c, 0x9a9a, 0x9494
351 #define GTK_BLACK 0x0000, 0x0000, 0x0000
352 #define GTK_WEAK_GRAY 0x7530, 0x7530, 0x7530
354 /* --- variables --- */
355 static const GdkColor gtk_default_normal_fg = { 0, GTK_BLACK };
356 static const GdkColor gtk_default_active_fg = { 0, GTK_BLACK };
357 static const GdkColor gtk_default_prelight_fg = { 0, GTK_BLACK };
358 static const GdkColor gtk_default_selected_fg = { 0, GTK_WHITE };
359 static const GdkColor gtk_default_insensitive_fg = { 0, GTK_WEAK_GRAY };
361 static const GdkColor gtk_default_normal_bg = { 0, GTK_GRAY };
362 static const GdkColor gtk_default_active_bg = { 0, GTK_DARK_GRAY };
363 static const GdkColor gtk_default_prelight_bg = { 0, GTK_LIGHT_GRAY };
364 static const GdkColor gtk_default_selected_bg = { 0, GTK_BLUE };
365 static const GdkColor gtk_default_insensitive_bg = { 0, GTK_GRAY };
366 static const GdkColor gtk_default_selected_base = { 0, GTK_BLUE };
367 static const GdkColor gtk_default_active_base = { 0, GTK_VERY_DARK_GRAY };
369 /* --- signals --- */
370 static guint realize_signal = 0;
371 static guint unrealize_signal = 0;
373 G_DEFINE_TYPE (GtkStyle, gtk_style, G_TYPE_OBJECT)
375 /* --- functions --- */
378 gtk_style_init (GtkStyle *style)
382 style->font_desc = pango_font_description_from_string ("Sans 10");
384 style->attach_count = 0;
386 style->black.red = 0;
387 style->black.green = 0;
388 style->black.blue = 0;
390 style->white.red = 65535;
391 style->white.green = 65535;
392 style->white.blue = 65535;
394 style->fg[GTK_STATE_NORMAL] = gtk_default_normal_fg;
395 style->fg[GTK_STATE_ACTIVE] = gtk_default_active_fg;
396 style->fg[GTK_STATE_PRELIGHT] = gtk_default_prelight_fg;
397 style->fg[GTK_STATE_SELECTED] = gtk_default_selected_fg;
398 style->fg[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_fg;
400 style->bg[GTK_STATE_NORMAL] = gtk_default_normal_bg;
401 style->bg[GTK_STATE_ACTIVE] = gtk_default_active_bg;
402 style->bg[GTK_STATE_PRELIGHT] = gtk_default_prelight_bg;
403 style->bg[GTK_STATE_SELECTED] = gtk_default_selected_bg;
404 style->bg[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_bg;
406 for (i = 0; i < 4; i++)
408 style->text[i] = style->fg[i];
409 style->base[i] = style->white;
412 style->base[GTK_STATE_SELECTED] = gtk_default_selected_base;
413 style->text[GTK_STATE_SELECTED] = style->white;
414 style->base[GTK_STATE_ACTIVE] = gtk_default_active_base;
415 style->text[GTK_STATE_ACTIVE] = style->white;
416 style->base[GTK_STATE_INSENSITIVE] = gtk_default_prelight_bg;
417 style->text[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_fg;
419 style->rc_style = NULL;
421 style->xthickness = 2;
422 style->ythickness = 2;
424 style->property_cache = NULL;
428 gtk_style_class_init (GtkStyleClass *klass)
430 GObjectClass *object_class = G_OBJECT_CLASS (klass);
432 object_class->finalize = gtk_style_finalize;
433 object_class->set_property = gtk_style_set_property;
434 object_class->get_property = gtk_style_get_property;
435 object_class->constructed = gtk_style_constructed;
437 klass->clone = gtk_style_real_clone;
438 klass->copy = gtk_style_real_copy;
439 klass->init_from_rc = gtk_style_real_init_from_rc;
440 klass->realize = gtk_style_real_realize;
441 klass->unrealize = gtk_style_real_unrealize;
442 klass->set_background = gtk_style_real_set_background;
443 klass->render_icon = gtk_default_render_icon;
445 klass->draw_hline = gtk_default_draw_hline;
446 klass->draw_vline = gtk_default_draw_vline;
447 klass->draw_shadow = gtk_default_draw_shadow;
448 klass->draw_arrow = gtk_default_draw_arrow;
449 klass->draw_diamond = gtk_default_draw_diamond;
450 klass->draw_box = gtk_default_draw_box;
451 klass->draw_flat_box = gtk_default_draw_flat_box;
452 klass->draw_check = gtk_default_draw_check;
453 klass->draw_option = gtk_default_draw_option;
454 klass->draw_tab = gtk_default_draw_tab;
455 klass->draw_shadow_gap = gtk_default_draw_shadow_gap;
456 klass->draw_box_gap = gtk_default_draw_box_gap;
457 klass->draw_extension = gtk_default_draw_extension;
458 klass->draw_focus = gtk_default_draw_focus;
459 klass->draw_slider = gtk_default_draw_slider;
460 klass->draw_handle = gtk_default_draw_handle;
461 klass->draw_expander = gtk_default_draw_expander;
462 klass->draw_layout = gtk_default_draw_layout;
463 klass->draw_resize_grip = gtk_default_draw_resize_grip;
464 klass->draw_spinner = gtk_default_draw_spinner;
466 g_type_class_add_private (object_class, sizeof (GtkStylePrivate));
468 g_object_class_install_property (object_class,
470 g_param_spec_object ("context",
472 P_("GtkStyleContext to get style from"),
473 GTK_TYPE_STYLE_CONTEXT,
474 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
478 * @style: the object which received the signal
480 * Emitted when the style has been initialized for a particular
481 * visual. Connecting to this signal is probably seldom
482 * useful since most of the time applications and widgets only
483 * deal with styles that have been already realized.
487 realize_signal = g_signal_new (I_("realize"),
488 G_TYPE_FROM_CLASS (object_class),
490 G_STRUCT_OFFSET (GtkStyleClass, realize),
492 _gtk_marshal_VOID__VOID,
495 * GtkStyle::unrealize:
496 * @style: the object which received the signal
498 * Emitted when the aspects of the style specific to a particular visual
499 * is being cleaned up. A connection to this signal can be useful
500 * if a widget wants to cache objects as object data on #GtkStyle.
501 * This signal provides a convenient place to free such cached objects.
505 unrealize_signal = g_signal_new (I_("unrealize"),
506 G_TYPE_FROM_CLASS (object_class),
508 G_STRUCT_OFFSET (GtkStyleClass, unrealize),
510 _gtk_marshal_VOID__VOID,
515 gtk_style_finalize (GObject *object)
517 GtkStyle *style = GTK_STYLE (object);
518 GtkStylePrivate *priv = GTK_STYLE_GET_PRIVATE (style);
521 g_return_if_fail (style->attach_count == 0);
523 /* All the styles in the list have the same
524 * style->styles pointer. If we delete the
525 * *first* style from the list, we need to update
526 * the style->styles pointers from all the styles.
527 * Otherwise we simply remove the node from
532 if (style->styles->data != style)
533 style->styles = g_slist_remove (style->styles, style);
536 GSList *tmp_list = style->styles->next;
540 GTK_STYLE (tmp_list->data)->styles = style->styles->next;
541 tmp_list = tmp_list->next;
543 g_slist_free_1 (style->styles);
547 g_slist_foreach (style->icon_factories, (GFunc) g_object_unref, NULL);
548 g_slist_free (style->icon_factories);
550 pango_font_description_free (style->font_desc);
552 if (style->private_font_desc)
553 pango_font_description_free (style->private_font_desc);
556 g_object_unref (style->rc_style);
560 if (priv->context_changed_id)
561 g_signal_handler_disconnect (priv->context, priv->context_changed_id);
563 g_object_unref (priv->context);
566 for (i = 0; i < 5; i++)
568 if (style->background[i])
569 cairo_pattern_destroy (style->background[i]);
572 G_OBJECT_CLASS (gtk_style_parent_class)->finalize (object);
576 gtk_style_set_property (GObject *object,
581 GtkStylePrivate *priv;
583 priv = GTK_STYLE_GET_PRIVATE (object);
588 priv->context = g_value_dup_object (value);
591 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
597 gtk_style_get_property (GObject *object,
602 GtkStylePrivate *priv;
604 priv = GTK_STYLE_GET_PRIVATE (object);
609 g_value_set_object (value, priv->context);
612 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
618 set_color (GtkStyle *style,
619 GtkStyleContext *context,
624 GdkRGBA *color = NULL;
625 GdkColor *dest = { 0 }; /* Shut up gcc */
629 case GTK_STATE_ACTIVE:
630 flags = GTK_STATE_FLAG_ACTIVE;
632 case GTK_STATE_PRELIGHT:
633 flags = GTK_STATE_FLAG_PRELIGHT;
635 case GTK_STATE_SELECTED:
636 flags = GTK_STATE_FLAG_SELECTED;
638 case GTK_STATE_INSENSITIVE:
639 flags = GTK_STATE_FLAG_INSENSITIVE;
648 gtk_style_context_get (context, flags,
649 "background-color", &color,
651 dest = &style->bg[state];
654 gtk_style_context_get (context, flags,
657 dest = &style->fg[state];
660 gtk_style_context_get (context, flags,
663 dest = &style->text[state];
666 gtk_style_context_get (context, flags,
667 "background-color", &color,
669 dest = &style->base[state];
676 dest->red = CLAMP ((guint) (color->red * 65535), 0, 65535);
677 dest->green = CLAMP ((guint) (color->green * 65535), 0, 65535);
678 dest->blue = CLAMP ((guint) (color->blue * 65535), 0, 65535);
679 gdk_rgba_free (color);
684 gtk_style_update_from_context (GtkStyle *style)
686 GtkStylePrivate *priv;
691 priv = GTK_STYLE_GET_PRIVATE (style);
693 for (state = GTK_STATE_NORMAL; state <= GTK_STATE_INSENSITIVE; state++)
695 if (gtk_style_context_has_class (priv->context, "entry"))
697 gtk_style_context_save (priv->context);
698 gtk_style_context_remove_class (priv->context, "entry");
699 set_color (style, priv->context, state, GTK_RC_BG);
700 set_color (style, priv->context, state, GTK_RC_FG);
701 gtk_style_context_restore (priv->context);
703 set_color (style, priv->context, state, GTK_RC_BASE);
704 set_color (style, priv->context, state, GTK_RC_TEXT);
708 gtk_style_context_save (priv->context);
709 gtk_style_context_add_class (priv->context, "entry");
710 set_color (style, priv->context, state, GTK_RC_BASE);
711 set_color (style, priv->context, state, GTK_RC_TEXT);
712 gtk_style_context_restore (priv->context);
714 set_color (style, priv->context, state, GTK_RC_BG);
715 set_color (style, priv->context, state, GTK_RC_FG);
719 if (style->font_desc)
720 pango_font_description_free (style->font_desc);
722 gtk_style_context_get (priv->context, 0,
723 "font", &style->font_desc,
725 gtk_style_context_get_padding (priv->context, 0, &padding);
727 style->xthickness = padding.left;
728 style->ythickness = padding.top;
730 for (i = 0; i < 5; i++)
732 _gtk_style_shade (&style->bg[i], &style->light[i], LIGHTNESS_MULT);
733 _gtk_style_shade (&style->bg[i], &style->dark[i], DARKNESS_MULT);
735 style->mid[i].red = (style->light[i].red + style->dark[i].red) / 2;
736 style->mid[i].green = (style->light[i].green + style->dark[i].green) / 2;
737 style->mid[i].blue = (style->light[i].blue + style->dark[i].blue) / 2;
739 style->text_aa[i].red = (style->text[i].red + style->base[i].red) / 2;
740 style->text_aa[i].green = (style->text[i].green + style->base[i].green) / 2;
741 style->text_aa[i].blue = (style->text[i].blue + style->base[i].blue) / 2;
744 style->black.red = 0x0000;
745 style->black.green = 0x0000;
746 style->black.blue = 0x0000;
748 style->white.red = 0xffff;
749 style->white.green = 0xffff;
750 style->white.blue = 0xffff;
752 for (i = 0; i < 5; i++)
754 if (style->background[i])
755 cairo_pattern_destroy (style->background[i]);
757 style->background[i] = cairo_pattern_create_rgb (style->bg[i].red / 65535.0,
758 style->bg[i].green / 65535.0,
759 style->bg[i].blue / 65535.0);
764 style_context_changed (GtkStyleContext *context,
767 gtk_style_update_from_context (GTK_STYLE (user_data));
771 gtk_style_constructed (GObject *object)
773 GtkStylePrivate *priv;
775 priv = GTK_STYLE_GET_PRIVATE (object);
779 gtk_style_update_from_context (GTK_STYLE (object));
781 priv->context_changed_id = g_signal_connect (priv->context, "changed",
782 G_CALLBACK (style_context_changed), object);
788 * @style: a #GtkStyle
790 * Creates a copy of the passed in #GtkStyle object.
792 * Returns: (transfer full): a copy of @style
794 * Deprecated:3.0: Use #GtkStyleContext instead
797 gtk_style_copy (GtkStyle *style)
801 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
803 new_style = GTK_STYLE_GET_CLASS (style)->clone (style);
804 GTK_STYLE_GET_CLASS (style)->copy (new_style, style);
810 _gtk_style_new_for_path (GdkScreen *screen,
813 GtkStyleContext *context;
816 context = gtk_style_context_new ();
819 gtk_style_context_set_screen (context, screen);
821 gtk_style_context_set_path (context, path);
823 style = g_object_new (GTK_TYPE_STYLE,
827 g_object_unref (context);
835 * Creates a new #GtkStyle.
837 * Returns: a new #GtkStyle.
839 * Deprecated: 3.0: Use #GtkStyleContext
847 path = gtk_widget_path_new ();
848 gtk_widget_path_append_type (path, GTK_TYPE_WIDGET);
850 style = _gtk_style_new_for_path (gdk_screen_get_default (), path);
852 gtk_widget_path_free (path);
858 * gtk_style_has_context:
859 * @style: a #GtkStyle
861 * Returns whether @style has an associated #GtkStyleContext.
863 * Returns: %TRUE if @style has a #GtkStyleContext
868 gtk_style_has_context (GtkStyle *style)
870 GtkStylePrivate *priv;
872 priv = GTK_STYLE_GET_PRIVATE (style);
874 return priv->context != NULL;
878 * gtk_style_attach: (skip)
879 * @style: a #GtkStyle.
880 * @window: a #GdkWindow.
882 * Attaches a style to a window; this process allocates the
883 * colors and creates the GC's for the style - it specializes
884 * it to a particular visual. The process may involve the creation
885 * of a new style if the style has already been attached to a
886 * window with a different style and visual.
888 * Since this function may return a new object, you have to use it
889 * in the following way:
890 * <literal>style = gtk_style_attach (style, window)</literal>
892 * Returns: Either @style, or a newly-created #GtkStyle.
893 * If the style is newly created, the style parameter
894 * will be unref'ed, and the new style will have
895 * a reference count belonging to the caller.
897 * Deprecated:3.0: Use gtk_widget_style_attach() instead
900 gtk_style_attach (GtkStyle *style,
903 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
904 g_return_val_if_fail (window != NULL, NULL);
911 * @style: a #GtkStyle
913 * Detaches a style from a window. If the style is not attached
914 * to any windows anymore, it is unrealized. See gtk_style_attach().
916 * Deprecated:3.0: Use #GtkStyleContext instead
919 gtk_style_detach (GtkStyle *style)
921 g_return_if_fail (GTK_IS_STYLE (style));
925 * gtk_style_lookup_icon_set:
926 * @style: a #GtkStyle
927 * @stock_id: an icon name
929 * Looks up @stock_id in the icon factories associated with @style
930 * and the default icon factory, returning an icon set if found,
933 * Return value: (transfer none): icon set of @stock_id
935 * Deprecated:3.0: Use gtk_style_context_lookup_icon_set() instead
938 gtk_style_lookup_icon_set (GtkStyle *style,
939 const char *stock_id)
941 GtkStylePrivate *priv;
943 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
944 g_return_val_if_fail (stock_id != NULL, NULL);
946 priv = GTK_STYLE_GET_PRIVATE (style);
949 return gtk_style_context_lookup_icon_set (priv->context, stock_id);
951 return gtk_icon_factory_lookup_default (stock_id);
955 * gtk_style_lookup_color:
956 * @style: a #GtkStyle
957 * @color_name: the name of the logical color to look up
958 * @color: (out): the #GdkColor to fill in
960 * Looks up @color_name in the style's logical color mappings,
961 * filling in @color and returning %TRUE if found, otherwise
962 * returning %FALSE. Do not cache the found mapping, because
963 * it depends on the #GtkStyle and might change when a theme
966 * Return value: %TRUE if the mapping was found.
970 * Deprecated:3.0: Use gtk_style_context_lookup_color() instead
973 gtk_style_lookup_color (GtkStyle *style,
974 const char *color_name,
977 GtkStylePrivate *priv;
981 g_return_val_if_fail (GTK_IS_STYLE (style), FALSE);
982 g_return_val_if_fail (color_name != NULL, FALSE);
983 g_return_val_if_fail (color != NULL, FALSE);
985 priv = GTK_STYLE_GET_PRIVATE (style);
990 result = gtk_style_context_lookup_color (priv->context, color_name, &rgba);
994 color->red = (guint16) (rgba.red * 65535);
995 color->green = (guint16) (rgba.green * 65535);
996 color->blue = (guint16) (rgba.blue * 65535);
1004 * gtk_style_set_background:
1005 * @style: a #GtkStyle
1006 * @window: a #GdkWindow
1007 * @state_type: a state
1009 * Sets the background of @window to the background color or pixmap
1010 * specified by @style for the given state.
1012 * Deprecated:3.0: Use gtk_style_context_set_background() instead
1015 gtk_style_set_background (GtkStyle *style,
1017 GtkStateType state_type)
1019 g_return_if_fail (GTK_IS_STYLE (style));
1020 g_return_if_fail (window != NULL);
1022 GTK_STYLE_GET_CLASS (style)->set_background (style, window, state_type);
1025 /* Default functions */
1027 gtk_style_real_clone (GtkStyle *style)
1029 GtkStylePrivate *priv;
1031 priv = GTK_STYLE_GET_PRIVATE (style);
1033 return g_object_new (G_OBJECT_TYPE (style),
1034 "context", priv->context,
1039 gtk_style_real_copy (GtkStyle *style,
1044 for (i = 0; i < 5; i++)
1046 style->fg[i] = src->fg[i];
1047 style->bg[i] = src->bg[i];
1048 style->text[i] = src->text[i];
1049 style->base[i] = src->base[i];
1051 if (style->background[i])
1052 cairo_pattern_destroy (style->background[i]),
1053 style->background[i] = src->background[i];
1054 if (style->background[i])
1055 cairo_pattern_reference (style->background[i]);
1058 if (style->font_desc)
1059 pango_font_description_free (style->font_desc);
1061 style->font_desc = pango_font_description_copy (src->font_desc);
1063 style->font_desc = NULL;
1065 style->xthickness = src->xthickness;
1066 style->ythickness = src->ythickness;
1068 if (style->rc_style)
1069 g_object_unref (style->rc_style);
1070 style->rc_style = src->rc_style;
1072 g_object_ref (src->rc_style);
1074 g_slist_foreach (style->icon_factories, (GFunc) g_object_unref, NULL);
1075 g_slist_free (style->icon_factories);
1076 style->icon_factories = g_slist_copy (src->icon_factories);
1077 g_slist_foreach (style->icon_factories, (GFunc) g_object_ref, NULL);
1081 gtk_style_real_init_from_rc (GtkStyle *style,
1082 GtkRcStyle *rc_style)
1087 * gtk_style_get_style_property:
1088 * @style: a #GtkStyle
1089 * @widget_type: the #GType of a descendant of #GtkWidget
1090 * @property_name: the name of the style property to get
1091 * @value: a #GValue where the value of the property being
1092 * queried will be stored
1094 * Queries the value of a style property corresponding to a
1095 * widget class is in the given style.
1100 gtk_style_get_style_property (GtkStyle *style,
1102 const gchar *property_name,
1105 GtkStylePrivate *priv;
1106 GtkWidgetClass *klass;
1108 const GValue *peek_value;
1110 klass = g_type_class_ref (widget_type);
1111 pspec = gtk_widget_class_find_style_property (klass, property_name);
1112 g_type_class_unref (klass);
1116 g_warning ("%s: widget class `%s' has no property named `%s'",
1118 g_type_name (widget_type),
1123 priv = GTK_STYLE_GET_PRIVATE (style);
1124 peek_value = _gtk_style_context_peek_style_property (priv->context,
1128 if (G_VALUE_TYPE (value) == G_PARAM_SPEC_VALUE_TYPE (pspec))
1129 g_value_copy (peek_value, value);
1130 else if (g_value_type_transformable (G_PARAM_SPEC_VALUE_TYPE (pspec), G_VALUE_TYPE (value)))
1131 g_value_transform (peek_value, value);
1133 g_warning ("can't retrieve style property `%s' of type `%s' as value of type `%s'",
1135 g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
1136 G_VALUE_TYPE_NAME (value));
1140 * gtk_style_get_valist:
1141 * @style: a #GtkStyle
1142 * @widget_type: the #GType of a descendant of #GtkWidget
1143 * @first_property_name: the name of the first style property to get
1144 * @var_args: a <type>va_list</type> of pairs of property names and
1145 * locations to return the property values, starting with the
1146 * location for @first_property_name.
1148 * Non-vararg variant of gtk_style_get().
1149 * Used primarily by language bindings.
1154 gtk_style_get_valist (GtkStyle *style,
1156 const gchar *first_property_name,
1159 GtkStylePrivate *priv;
1160 const char *property_name;
1161 GtkWidgetClass *klass;
1163 g_return_if_fail (GTK_IS_STYLE (style));
1165 klass = g_type_class_ref (widget_type);
1167 priv = GTK_STYLE_GET_PRIVATE (style);
1168 property_name = first_property_name;
1169 while (property_name)
1172 const GValue *peek_value;
1175 pspec = gtk_widget_class_find_style_property (klass, property_name);
1179 g_warning ("%s: widget class `%s' has no property named `%s'",
1181 g_type_name (widget_type),
1186 peek_value = _gtk_style_context_peek_style_property (priv->context, widget_type,
1188 G_VALUE_LCOPY (peek_value, var_args, 0, &error);
1191 g_warning ("%s: %s", G_STRLOC, error);
1196 property_name = va_arg (var_args, gchar*);
1199 g_type_class_unref (klass);
1204 * @style: a #GtkStyle
1205 * @widget_type: the #GType of a descendant of #GtkWidget
1206 * @first_property_name: the name of the first style property to get
1207 * @...: pairs of property names and locations to
1208 * return the property values, starting with the location for
1209 * @first_property_name, terminated by %NULL.
1211 * Gets the values of a multiple style properties for @widget_type
1217 gtk_style_get (GtkStyle *style,
1219 const gchar *first_property_name,
1224 va_start (var_args, first_property_name);
1225 gtk_style_get_valist (style, widget_type, first_property_name, var_args);
1230 gtk_style_real_realize (GtkStyle *style)
1235 gtk_style_real_unrealize (GtkStyle *style)
1240 gtk_style_real_set_background (GtkStyle *style,
1242 GtkStateType state_type)
1244 gdk_window_set_background_pattern (window, style->background[state_type]);
1248 * gtk_style_render_icon:
1249 * @style: a #GtkStyle
1250 * @source: the #GtkIconSource specifying the icon to render
1251 * @direction: a text direction
1253 * @size: (type int): the size to render the icon at. A size of
1254 * (GtkIconSize)-1 means render at the size of the source and
1256 * @widget: (allow-none): the widget
1257 * @detail: (allow-none): a style detail
1259 * Renders the icon specified by @source at the given @size
1260 * according to the given parameters and returns the result in a
1263 * Return value: (transfer full): a newly-created #GdkPixbuf
1264 * containing the rendered icon
1266 * Deprecated:3.0: Use gtk_render_icon_pixbuf() instead
1269 gtk_style_render_icon (GtkStyle *style,
1270 const GtkIconSource *source,
1271 GtkTextDirection direction,
1275 const gchar *detail)
1279 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
1280 g_return_val_if_fail (GTK_STYLE_GET_CLASS (style)->render_icon != NULL, NULL);
1282 pixbuf = GTK_STYLE_GET_CLASS (style)->render_icon (style, source, direction, state,
1283 size, widget, detail);
1285 g_return_val_if_fail (pixbuf != NULL, NULL);
1290 /* Default functions */
1293 * gtk_style_apply_default_background:
1303 * Deprecated:3.0: Use #GtkStyleContext instead
1306 gtk_style_apply_default_background (GtkStyle *style,
1309 GtkStateType state_type,
1317 if (style->background[state_type] == NULL)
1319 GdkWindow *parent = gdk_window_get_parent (window);
1320 int x_offset, y_offset;
1324 gdk_window_get_position (window, &x_offset, &y_offset);
1325 cairo_translate (cr, -x_offset, -y_offset);
1326 gtk_style_apply_default_background (style, cr,
1328 x + x_offset, y + y_offset,
1333 gdk_cairo_set_source_color (cr, &style->bg[state_type]);
1336 cairo_set_source (cr, style->background[state_type]);
1338 cairo_rectangle (cr, x, y, width, height);
1346 gtk_default_render_icon (GtkStyle *style,
1347 const GtkIconSource *source,
1348 GtkTextDirection direction,
1352 const gchar *detail)
1354 GtkStyleContext *context;
1355 GtkStylePrivate *priv;
1356 GtkStateFlags flags = 0;
1360 context = gtk_widget_get_style_context (widget);
1363 priv = GTK_STYLE_GET_PRIVATE (style);
1364 context = priv->context;
1370 gtk_style_context_save (context);
1373 transform_detail_string (detail, context);
1377 case GTK_STATE_PRELIGHT:
1378 flags |= GTK_STATE_FLAG_PRELIGHT;
1380 case GTK_STATE_INSENSITIVE:
1381 flags |= GTK_STATE_FLAG_INSENSITIVE;
1387 gtk_style_context_set_state (context, flags);
1389 pixbuf = gtk_render_icon_pixbuf (context, source, size);
1391 gtk_style_context_restore (context);
1397 _cairo_draw_line (cairo_t *cr,
1406 gdk_cairo_set_source_color (cr, color);
1407 cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
1409 cairo_move_to (cr, x1 + 0.5, y1 + 0.5);
1410 cairo_line_to (cr, x2 + 0.5, y2 + 0.5);
1417 transform_detail_string (const gchar *detail,
1418 GtkStyleContext *context)
1423 if (strcmp (detail, "arrow") == 0)
1424 gtk_style_context_add_class (context, "arrow");
1425 else if (strcmp (detail, "button") == 0)
1426 gtk_style_context_add_class (context, "button");
1427 else if (strcmp (detail, "buttondefault") == 0)
1429 gtk_style_context_add_class (context, "button");
1430 gtk_style_context_add_class (context, "default");
1432 else if (strcmp (detail, "calendar") == 0)
1433 gtk_style_context_add_class (context, "calendar");
1434 else if (strcmp (detail, "cellcheck") == 0)
1436 gtk_style_context_add_class (context, "cell");
1437 gtk_style_context_add_class (context, "check");
1439 else if (strcmp (detail, "cellradio") == 0)
1441 gtk_style_context_add_class (context, "cell");
1442 gtk_style_context_add_class (context, "radio");
1444 else if (strcmp (detail, "checkbutton") == 0)
1445 gtk_style_context_add_class (context, "check");
1446 else if (strcmp (detail, "check") == 0)
1448 gtk_style_context_add_class (context, "check");
1449 gtk_style_context_add_class (context, "menu");
1451 else if (strcmp (detail, "radiobutton") == 0)
1453 gtk_style_context_add_class (context, "radio");
1455 else if (strcmp (detail, "option") == 0)
1457 gtk_style_context_add_class (context, "radio");
1458 gtk_style_context_add_class (context, "menu");
1460 else if (strcmp (detail, "entry") == 0 ||
1461 strcmp (detail, "entry_bg") == 0)
1462 gtk_style_context_add_class (context, "entry");
1463 else if (strcmp (detail, "expander") == 0)
1464 gtk_style_context_add_class (context, "expander");
1465 else if (strcmp (detail, "tooltip") == 0)
1466 gtk_style_context_add_class (context, "tooltip");
1467 else if (strcmp (detail, "frame") == 0)
1468 gtk_style_context_add_class (context, "frame");
1469 else if (strcmp (detail, "scrolled_window") == 0)
1470 gtk_style_context_add_class (context, "scrolled-window");
1471 else if (strcmp (detail, "viewport") == 0 ||
1472 strcmp (detail, "viewportbin") == 0)
1473 gtk_style_context_add_class (context, "viewport");
1474 else if (strncmp (detail, "trough", 6) == 0)
1475 gtk_style_context_add_class (context, "trough");
1476 else if (strcmp (detail, "spinbutton") == 0)
1477 gtk_style_context_add_class (context, "spinbutton");
1478 else if (strcmp (detail, "spinbutton_up") == 0)
1480 gtk_style_context_add_class (context, "spinbutton");
1481 gtk_style_context_add_class (context, "button");
1482 gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM);
1484 else if (strcmp (detail, "spinbutton_down") == 0)
1486 gtk_style_context_add_class (context, "spinbutton");
1487 gtk_style_context_add_class (context, "button");
1488 gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);
1490 else if ((detail[0] == 'h' || detail[0] == 'v') &&
1491 strncmp (&detail[1], "scrollbar_", 10) == 0)
1493 gtk_style_context_add_class (context, "button");
1494 gtk_style_context_add_class (context, "scrollbar");
1496 else if (strcmp (detail, "slider") == 0)
1498 gtk_style_context_add_class (context, "slider");
1499 gtk_style_context_add_class (context, "scrollbar");
1501 else if (strcmp (detail, "vscale") == 0 ||
1502 strcmp (detail, "hscale") == 0)
1504 gtk_style_context_add_class (context, "slider");
1505 gtk_style_context_add_class (context, "scale");
1507 else if (strcmp (detail, "menuitem") == 0)
1509 gtk_style_context_add_class (context, "menuitem");
1510 gtk_style_context_add_class (context, "menu");
1512 else if (strcmp (detail, "menu") == 0)
1514 gtk_style_context_add_class (context, "popup");
1515 gtk_style_context_add_class (context, "menu");
1517 else if (strcmp (detail, "accellabel") == 0)
1518 gtk_style_context_add_class (context, "accelerator");
1519 else if (strcmp (detail, "menubar") == 0)
1520 gtk_style_context_add_class (context, "menubar");
1521 else if (strcmp (detail, "base") == 0)
1522 gtk_style_context_add_class (context, "background");
1523 else if (strcmp (detail, "bar") == 0 ||
1524 strcmp (detail, "progressbar") == 0)
1525 gtk_style_context_add_class (context, "progressbar");
1526 else if (strcmp (detail, "toolbar") == 0)
1527 gtk_style_context_add_class (context, "toolbar");
1528 else if (strcmp (detail, "handlebox_bin") == 0)
1529 gtk_style_context_add_class (context, "dock");
1530 else if (strcmp (detail, "notebook") == 0)
1531 gtk_style_context_add_class (context, "notebook");
1532 else if (strcmp (detail, "tab") == 0)
1534 gtk_style_context_add_class (context, "notebook");
1535 gtk_style_context_add_region (context, GTK_STYLE_REGION_TAB, 0);
1537 else if (g_str_has_prefix (detail, "cell"))
1539 GtkRegionFlags row, col;
1540 gboolean ruled = FALSE;
1544 tokens = g_strsplit (detail, "_", -1);
1550 if (strcmp (tokens[i], "even") == 0)
1551 row |= GTK_REGION_EVEN;
1552 else if (strcmp (tokens[i], "odd") == 0)
1553 row |= GTK_REGION_ODD;
1554 else if (strcmp (tokens[i], "start") == 0)
1555 col |= GTK_REGION_FIRST;
1556 else if (strcmp (tokens[i], "end") == 0)
1557 col |= GTK_REGION_LAST;
1558 else if (strcmp (tokens[i], "ruled") == 0)
1560 else if (strcmp (tokens[i], "sorted") == 0)
1561 col |= GTK_REGION_SORTED;
1567 row &= ~(GTK_REGION_EVEN | GTK_REGION_ODD);
1569 gtk_style_context_add_class (context, "cell");
1570 gtk_style_context_add_region (context, "row", row);
1571 gtk_style_context_add_region (context, "column", col);
1573 g_strfreev (tokens);
1578 gtk_default_draw_hline (GtkStyle *style,
1580 GtkStateType state_type,
1582 const gchar *detail,
1587 GtkStyleContext *context;
1588 GtkStylePrivate *priv;
1591 context = gtk_widget_get_style_context (widget);
1594 priv = GTK_STYLE_GET_PRIVATE (style);
1595 context = priv->context;
1598 gtk_style_context_save (context);
1601 transform_detail_string (detail, context);
1605 gtk_render_line (context, cr,
1610 gtk_style_context_restore (context);
1615 gtk_default_draw_vline (GtkStyle *style,
1617 GtkStateType state_type,
1619 const gchar *detail,
1624 GtkStyleContext *context;
1625 GtkStylePrivate *priv;
1628 context = gtk_widget_get_style_context (widget);
1631 priv = GTK_STYLE_GET_PRIVATE (style);
1632 context = priv->context;
1635 gtk_style_context_save (context);
1638 transform_detail_string (detail, context);
1642 gtk_render_line (context, cr,
1646 gtk_style_context_restore (context);
1650 gtk_default_draw_shadow (GtkStyle *style,
1652 GtkStateType state_type,
1653 GtkShadowType shadow_type,
1655 const gchar *detail,
1661 GtkStyleContext *context;
1662 GtkStylePrivate *priv;
1664 if (shadow_type == GTK_SHADOW_NONE)
1668 context = gtk_widget_get_style_context (widget);
1671 priv = GTK_STYLE_GET_PRIVATE (style);
1672 context = priv->context;
1675 gtk_style_context_save (context);
1678 transform_detail_string (detail, context);
1682 gtk_render_frame (context, cr,
1689 gtk_style_context_restore (context);
1693 draw_arrow (cairo_t *cr,
1695 GtkArrowType arrow_type,
1701 gdk_cairo_set_source_color (cr, color);
1704 if (arrow_type == GTK_ARROW_DOWN)
1706 cairo_move_to (cr, x, y);
1707 cairo_line_to (cr, x + width, y);
1708 cairo_line_to (cr, x + width / 2., y + height);
1710 else if (arrow_type == GTK_ARROW_UP)
1712 cairo_move_to (cr, x, y + height);
1713 cairo_line_to (cr, x + width / 2., y);
1714 cairo_line_to (cr, x + width, y + height);
1716 else if (arrow_type == GTK_ARROW_LEFT)
1718 cairo_move_to (cr, x + width, y);
1719 cairo_line_to (cr, x + width, y + height);
1720 cairo_line_to (cr, x, y + height / 2.);
1722 else if (arrow_type == GTK_ARROW_RIGHT)
1724 cairo_move_to (cr, x, y);
1725 cairo_line_to (cr, x + width, y + height / 2.);
1726 cairo_line_to (cr, x, y + height);
1729 cairo_close_path (cr);
1736 gtk_default_draw_arrow (GtkStyle *style,
1739 GtkShadowType shadow,
1741 const gchar *detail,
1742 GtkArrowType arrow_type,
1749 GtkStyleContext *context;
1750 GtkStylePrivate *priv;
1751 GtkStateFlags flags = 0;
1752 gdouble angle, size;
1754 if (arrow_type == GTK_ARROW_NONE)
1758 context = gtk_widget_get_style_context (widget);
1761 priv = GTK_STYLE_GET_PRIVATE (style);
1762 context = priv->context;
1765 gtk_style_context_save (context);
1768 transform_detail_string (detail, context);
1776 case GTK_ARROW_RIGHT:
1780 case GTK_ARROW_DOWN:
1784 case GTK_ARROW_LEFT:
1785 angle = 3 * (G_PI / 2);
1789 g_assert_not_reached ();
1794 case GTK_STATE_PRELIGHT:
1795 flags |= GTK_STATE_FLAG_PRELIGHT;
1797 case GTK_STATE_SELECTED:
1798 flags |= GTK_STATE_FLAG_SELECTED;
1800 case GTK_STATE_INSENSITIVE:
1801 flags |= GTK_STATE_FLAG_INSENSITIVE;
1803 case GTK_STATE_ACTIVE:
1804 flags |= GTK_STATE_FLAG_ACTIVE;
1810 gtk_style_context_set_state (context, flags);
1814 gtk_render_arrow (context,
1821 gtk_style_context_restore (context);
1825 gtk_default_draw_diamond (GtkStyle *style,
1827 GtkStateType state_type,
1828 GtkShadowType shadow_type,
1830 const gchar *detail,
1838 GdkColor *outer_nw = NULL;
1839 GdkColor *outer_ne = NULL;
1840 GdkColor *outer_sw = NULL;
1841 GdkColor *outer_se = NULL;
1842 GdkColor *middle_nw = NULL;
1843 GdkColor *middle_ne = NULL;
1844 GdkColor *middle_sw = NULL;
1845 GdkColor *middle_se = NULL;
1846 GdkColor *inner_nw = NULL;
1847 GdkColor *inner_ne = NULL;
1848 GdkColor *inner_sw = NULL;
1849 GdkColor *inner_se = NULL;
1851 half_width = width / 2;
1852 half_height = height / 2;
1854 switch (shadow_type)
1857 inner_sw = inner_se = &style->bg[state_type];
1858 middle_sw = middle_se = &style->light[state_type];
1859 outer_sw = outer_se = &style->light[state_type];
1860 inner_nw = inner_ne = &style->black;
1861 middle_nw = middle_ne = &style->dark[state_type];
1862 outer_nw = outer_ne = &style->dark[state_type];
1865 case GTK_SHADOW_OUT:
1866 inner_sw = inner_se = &style->dark[state_type];
1867 middle_sw = middle_se = &style->dark[state_type];
1868 outer_sw = outer_se = &style->black;
1869 inner_nw = inner_ne = &style->bg[state_type];
1870 middle_nw = middle_ne = &style->light[state_type];
1871 outer_nw = outer_ne = &style->light[state_type];
1874 case GTK_SHADOW_ETCHED_IN:
1875 inner_sw = inner_se = &style->bg[state_type];
1876 middle_sw = middle_se = &style->dark[state_type];
1877 outer_sw = outer_se = &style->light[state_type];
1878 inner_nw = inner_ne = &style->bg[state_type];
1879 middle_nw = middle_ne = &style->light[state_type];
1880 outer_nw = outer_ne = &style->dark[state_type];
1883 case GTK_SHADOW_ETCHED_OUT:
1884 inner_sw = inner_se = &style->bg[state_type];
1885 middle_sw = middle_se = &style->light[state_type];
1886 outer_sw = outer_se = &style->dark[state_type];
1887 inner_nw = inner_ne = &style->bg[state_type];
1888 middle_nw = middle_ne = &style->dark[state_type];
1889 outer_nw = outer_ne = &style->light[state_type];
1899 _cairo_draw_line (cr, inner_sw,
1900 x + 2, y + half_height,
1901 x + half_width, y + height - 2);
1902 _cairo_draw_line (cr, inner_se,
1903 x + half_width, y + height - 2,
1904 x + width - 2, y + half_height);
1905 _cairo_draw_line (cr, middle_sw,
1906 x + 1, y + half_height,
1907 x + half_width, y + height - 1);
1908 _cairo_draw_line (cr, middle_se,
1909 x + half_width, y + height - 1,
1910 x + width - 1, y + half_height);
1911 _cairo_draw_line (cr, outer_sw,
1913 x + half_width, y + height);
1914 _cairo_draw_line (cr, outer_se,
1915 x + half_width, y + height,
1916 x + width, y + half_height);
1918 _cairo_draw_line (cr, inner_nw,
1919 x + 2, y + half_height,
1920 x + half_width, y + 2);
1921 _cairo_draw_line (cr, inner_ne,
1922 x + half_width, y + 2,
1923 x + width - 2, y + half_height);
1924 _cairo_draw_line (cr, middle_nw,
1925 x + 1, y + half_height,
1926 x + half_width, y + 1);
1927 _cairo_draw_line (cr, middle_ne,
1928 x + half_width, y + 1,
1929 x + width - 1, y + half_height);
1930 _cairo_draw_line (cr, outer_nw,
1933 _cairo_draw_line (cr, outer_ne,
1935 x + width, y + half_height);
1940 option_menu_get_props (GtkWidget *widget,
1941 GtkRequisition *indicator_size,
1942 GtkBorder *indicator_spacing)
1944 GtkRequisition *tmp_size = NULL;
1945 GtkBorder *tmp_spacing = NULL;
1949 *indicator_size = *tmp_size;
1950 gtk_requisition_free (tmp_size);
1953 *indicator_size = default_option_indicator_size;
1957 *indicator_spacing = *tmp_spacing;
1958 gtk_border_free (tmp_spacing);
1961 *indicator_spacing = default_option_indicator_spacing;
1965 gtk_default_draw_box (GtkStyle *style,
1967 GtkStateType state_type,
1968 GtkShadowType shadow_type,
1970 const gchar *detail,
1976 GtkStyleContext *context;
1977 GtkStylePrivate *priv;
1978 GtkStateFlags flags = 0;
1981 context = gtk_widget_get_style_context (widget);
1984 priv = GTK_STYLE_GET_PRIVATE (style);
1985 context = priv->context;
1988 gtk_style_context_save (context);
1991 transform_detail_string (detail, context);
1995 case GTK_STATE_ACTIVE:
1996 flags |= GTK_STATE_FLAG_ACTIVE;
1998 case GTK_STATE_PRELIGHT:
1999 flags |= GTK_STATE_FLAG_PRELIGHT;
2001 case GTK_STATE_SELECTED:
2002 flags |= GTK_STATE_FLAG_SELECTED;
2004 case GTK_STATE_INSENSITIVE:
2005 flags |= GTK_STATE_FLAG_INSENSITIVE;
2011 if (shadow_type == GTK_SHADOW_IN)
2012 flags |= GTK_STATE_FLAG_ACTIVE;
2014 gtk_style_context_set_state (context, flags);
2018 if (gtk_style_context_has_class (context, GTK_STYLE_CLASS_PROGRESSBAR))
2019 gtk_render_activity (context, cr, x, y, width, height);
2022 gtk_render_background (context, cr, x, y, width, height);
2024 if (shadow_type != GTK_SHADOW_NONE)
2025 gtk_render_frame (context, cr, x, y, width, height);
2029 gtk_style_context_restore (context);
2033 gtk_default_draw_flat_box (GtkStyle *style,
2035 GtkStateType state_type,
2036 GtkShadowType shadow_type,
2038 const gchar *detail,
2044 GtkStyleContext *context;
2045 GtkStylePrivate *priv;
2046 GtkStateFlags flags = 0;
2049 context = gtk_widget_get_style_context (widget);
2052 priv = GTK_STYLE_GET_PRIVATE (style);
2053 context = priv->context;
2056 gtk_style_context_save (context);
2059 transform_detail_string (detail, context);
2063 case GTK_STATE_PRELIGHT:
2064 flags |= GTK_STATE_FLAG_PRELIGHT;
2066 case GTK_STATE_SELECTED:
2067 flags |= GTK_STATE_FLAG_SELECTED;
2069 case GTK_STATE_INSENSITIVE:
2070 flags |= GTK_STATE_FLAG_INSENSITIVE;
2072 case GTK_STATE_ACTIVE:
2073 flags |= GTK_STATE_FLAG_ACTIVE;
2075 case GTK_STATE_FOCUSED:
2076 flags |= GTK_STATE_FLAG_FOCUSED;
2082 gtk_style_context_set_state (context, flags);
2086 gtk_render_background (context, cr,
2093 gtk_style_context_restore (context);
2097 gtk_default_draw_check (GtkStyle *style,
2099 GtkStateType state_type,
2100 GtkShadowType shadow_type,
2102 const gchar *detail,
2108 GtkStyleContext *context;
2109 GtkStylePrivate *priv;
2110 GtkStateFlags flags = 0;
2113 context = gtk_widget_get_style_context (widget);
2116 priv = GTK_STYLE_GET_PRIVATE (style);
2117 context = priv->context;
2120 gtk_style_context_save (context);
2123 transform_detail_string (detail, context);
2127 case GTK_STATE_PRELIGHT:
2128 flags |= GTK_STATE_FLAG_PRELIGHT;
2130 case GTK_STATE_SELECTED:
2131 flags |= GTK_STATE_FLAG_SELECTED;
2133 case GTK_STATE_INSENSITIVE:
2134 flags |= GTK_STATE_FLAG_INSENSITIVE;
2140 if (shadow_type == GTK_SHADOW_IN)
2141 flags |= GTK_STATE_FLAG_ACTIVE;
2142 else if (shadow_type == GTK_SHADOW_ETCHED_IN)
2143 flags |= GTK_STATE_FLAG_INCONSISTENT;
2145 gtk_style_context_set_state (context, flags);
2149 gtk_render_check (context,
2154 gtk_style_context_restore (context);
2158 gtk_default_draw_option (GtkStyle *style,
2160 GtkStateType state_type,
2161 GtkShadowType shadow_type,
2163 const gchar *detail,
2169 GtkStyleContext *context;
2170 GtkStylePrivate *priv;
2171 GtkStateFlags flags = 0;
2174 context = gtk_widget_get_style_context (widget);
2177 priv = GTK_STYLE_GET_PRIVATE (style);
2178 context = priv->context;
2181 gtk_style_context_save (context);
2184 transform_detail_string (detail, context);
2188 case GTK_STATE_PRELIGHT:
2189 flags |= GTK_STATE_FLAG_PRELIGHT;
2191 case GTK_STATE_SELECTED:
2192 flags |= GTK_STATE_FLAG_SELECTED;
2194 case GTK_STATE_INSENSITIVE:
2195 flags |= GTK_STATE_FLAG_INSENSITIVE;
2201 if (shadow_type == GTK_SHADOW_IN)
2202 flags |= GTK_STATE_FLAG_ACTIVE;
2203 else if (shadow_type == GTK_SHADOW_ETCHED_IN)
2204 flags |= GTK_STATE_FLAG_INCONSISTENT;
2206 gtk_style_context_set_state (context, flags);
2209 gtk_render_option (context, cr,
2216 gtk_style_context_restore (context);
2220 gtk_default_draw_tab (GtkStyle *style,
2222 GtkStateType state_type,
2223 GtkShadowType shadow_type,
2225 const gchar *detail,
2231 #define ARROW_SPACE 4
2233 GtkRequisition indicator_size;
2234 GtkBorder indicator_spacing;
2237 option_menu_get_props (widget, &indicator_size, &indicator_spacing);
2239 indicator_size.width += (indicator_size.width % 2) - 1;
2240 arrow_height = indicator_size.width / 2 + 1;
2242 x += (width - indicator_size.width) / 2;
2243 y += (height - (2 * arrow_height + ARROW_SPACE)) / 2;
2245 if (state_type == GTK_STATE_INSENSITIVE)
2247 draw_arrow (cr, &style->white,
2248 GTK_ARROW_UP, x + 1, y + 1,
2249 indicator_size.width, arrow_height);
2251 draw_arrow (cr, &style->white,
2252 GTK_ARROW_DOWN, x + 1, y + arrow_height + ARROW_SPACE + 1,
2253 indicator_size.width, arrow_height);
2256 draw_arrow (cr, &style->fg[state_type],
2258 indicator_size.width, arrow_height);
2261 draw_arrow (cr, &style->fg[state_type],
2262 GTK_ARROW_DOWN, x, y + arrow_height + ARROW_SPACE,
2263 indicator_size.width, arrow_height);
2267 gtk_default_draw_shadow_gap (GtkStyle *style,
2269 GtkStateType state_type,
2270 GtkShadowType shadow_type,
2272 const gchar *detail,
2277 GtkPositionType gap_side,
2281 GtkStyleContext *context;
2282 GtkStylePrivate *priv;
2283 GtkStateFlags flags = 0;
2285 if (shadow_type == GTK_SHADOW_NONE)
2289 context = gtk_widget_get_style_context (widget);
2292 priv = GTK_STYLE_GET_PRIVATE (style);
2293 context = priv->context;
2296 gtk_style_context_save (context);
2299 transform_detail_string (detail, context);
2303 case GTK_STATE_ACTIVE:
2304 flags |= GTK_STATE_FLAG_ACTIVE;
2306 case GTK_STATE_PRELIGHT:
2307 flags |= GTK_STATE_FLAG_PRELIGHT;
2309 case GTK_STATE_SELECTED:
2310 flags |= GTK_STATE_FLAG_SELECTED;
2312 case GTK_STATE_INSENSITIVE:
2313 flags |= GTK_STATE_FLAG_INSENSITIVE;
2319 gtk_style_context_set_state (context, flags);
2322 gtk_render_frame_gap (context, cr,
2329 (gdouble) gap_x + gap_width);
2332 gtk_style_context_restore (context);
2336 gtk_default_draw_box_gap (GtkStyle *style,
2338 GtkStateType state_type,
2339 GtkShadowType shadow_type,
2341 const gchar *detail,
2346 GtkPositionType gap_side,
2350 GtkStyleContext *context;
2351 GtkStylePrivate *priv;
2352 GtkStateFlags flags = 0;
2355 context = gtk_widget_get_style_context (widget);
2358 priv = GTK_STYLE_GET_PRIVATE (style);
2359 context = priv->context;
2362 gtk_style_context_save (context);
2365 transform_detail_string (detail, context);
2369 case GTK_STATE_ACTIVE:
2370 flags |= GTK_STATE_FLAG_ACTIVE;
2372 case GTK_STATE_PRELIGHT:
2373 flags |= GTK_STATE_FLAG_PRELIGHT;
2375 case GTK_STATE_SELECTED:
2376 flags |= GTK_STATE_FLAG_SELECTED;
2378 case GTK_STATE_INSENSITIVE:
2379 flags |= GTK_STATE_FLAG_INSENSITIVE;
2385 gtk_style_context_set_state (context, flags);
2388 gtk_render_background (context, cr,
2395 if (shadow_type != GTK_SHADOW_NONE)
2396 gtk_render_frame_gap (context, cr,
2403 (gdouble) gap_x + gap_width);
2406 gtk_style_context_restore (context);
2410 gtk_default_draw_extension (GtkStyle *style,
2412 GtkStateType state_type,
2413 GtkShadowType shadow_type,
2415 const gchar *detail,
2420 GtkPositionType gap_side)
2422 GtkStyleContext *context;
2423 GtkStylePrivate *priv;
2424 GtkStateFlags flags = 0;
2427 context = gtk_widget_get_style_context (widget);
2430 priv = GTK_STYLE_GET_PRIVATE (style);
2431 context = priv->context;
2434 gtk_style_context_save (context);
2437 transform_detail_string (detail, context);
2441 case GTK_STATE_ACTIVE:
2442 flags |= GTK_STATE_FLAG_ACTIVE;
2444 case GTK_STATE_PRELIGHT:
2445 flags |= GTK_STATE_FLAG_PRELIGHT;
2447 case GTK_STATE_SELECTED:
2448 flags |= GTK_STATE_FLAG_SELECTED;
2450 case GTK_STATE_INSENSITIVE:
2451 flags |= GTK_STATE_FLAG_INSENSITIVE;
2457 gtk_style_context_set_state (context, flags);
2461 gtk_render_extension (context, cr,
2469 gtk_style_context_restore (context);
2473 gtk_default_draw_focus (GtkStyle *style,
2475 GtkStateType state_type,
2477 const gchar *detail,
2483 GtkStyleContext *context;
2484 GtkStylePrivate *priv;
2487 context = gtk_widget_get_style_context (widget);
2490 priv = GTK_STYLE_GET_PRIVATE (style);
2491 context = priv->context;
2494 gtk_style_context_save (context);
2497 transform_detail_string (detail, context);
2501 gtk_render_focus (context, cr,
2508 gtk_style_context_restore (context);
2512 gtk_default_draw_slider (GtkStyle *style,
2514 GtkStateType state_type,
2515 GtkShadowType shadow_type,
2517 const gchar *detail,
2522 GtkOrientation orientation)
2524 GtkStyleContext *context;
2525 GtkStylePrivate *priv;
2526 GtkStateFlags flags = 0;
2529 context = gtk_widget_get_style_context (widget);
2532 priv = GTK_STYLE_GET_PRIVATE (style);
2533 context = priv->context;
2536 gtk_style_context_save (context);
2539 transform_detail_string (detail, context);
2543 case GTK_STATE_PRELIGHT:
2544 flags |= GTK_STATE_FLAG_PRELIGHT;
2546 case GTK_STATE_SELECTED:
2547 flags |= GTK_STATE_FLAG_SELECTED;
2549 case GTK_STATE_INSENSITIVE:
2550 flags |= GTK_STATE_FLAG_INSENSITIVE;
2556 gtk_style_context_set_state (context, flags);
2560 gtk_render_slider (context, cr, x, y, width, height, orientation);
2563 gtk_style_context_restore (context);
2567 gtk_default_draw_handle (GtkStyle *style,
2569 GtkStateType state_type,
2570 GtkShadowType shadow_type,
2572 const gchar *detail,
2577 GtkOrientation orientation)
2579 GtkStyleContext *context;
2580 GtkStylePrivate *priv;
2581 GtkStateFlags flags = 0;
2584 context = gtk_widget_get_style_context (widget);
2587 priv = GTK_STYLE_GET_PRIVATE (style);
2588 context = priv->context;
2591 gtk_style_context_save (context);
2594 transform_detail_string (detail, context);
2598 case GTK_STATE_PRELIGHT:
2599 flags |= GTK_STATE_FLAG_PRELIGHT;
2601 case GTK_STATE_SELECTED:
2602 flags |= GTK_STATE_FLAG_SELECTED;
2604 case GTK_STATE_INSENSITIVE:
2605 flags |= GTK_STATE_FLAG_INSENSITIVE;
2611 gtk_style_context_set_state (context, flags);
2615 gtk_render_handle (context, cr,
2622 gtk_style_context_restore (context);
2626 gtk_default_draw_expander (GtkStyle *style,
2628 GtkStateType state_type,
2630 const gchar *detail,
2633 GtkExpanderStyle expander_style)
2635 GtkStyleContext *context;
2636 GtkStylePrivate *priv;
2637 GtkStateFlags flags = 0;
2641 context = gtk_widget_get_style_context (widget);
2644 priv = GTK_STYLE_GET_PRIVATE (style);
2645 context = priv->context;
2648 gtk_style_context_save (context);
2651 transform_detail_string (detail, context);
2653 gtk_style_context_add_class (context, "expander");
2657 case GTK_STATE_PRELIGHT:
2658 flags |= GTK_STATE_FLAG_PRELIGHT;
2660 case GTK_STATE_SELECTED:
2661 flags |= GTK_STATE_FLAG_SELECTED;
2663 case GTK_STATE_INSENSITIVE:
2664 flags |= GTK_STATE_FLAG_INSENSITIVE;
2671 gtk_widget_class_find_style_property (GTK_WIDGET_GET_CLASS (widget),
2673 gtk_widget_style_get (widget, "expander-size", &size, NULL);
2677 if (expander_style == GTK_EXPANDER_EXPANDED)
2678 flags |= GTK_STATE_FLAG_ACTIVE;
2680 gtk_style_context_set_state (context, flags);
2684 gtk_render_expander (context, cr,
2685 (gdouble) x - (size / 2),
2686 (gdouble) y - (size / 2),
2691 gtk_style_context_restore (context);
2695 gtk_default_draw_layout (GtkStyle *style,
2697 GtkStateType state_type,
2700 const gchar *detail,
2703 PangoLayout *layout)
2705 GtkStyleContext *context;
2706 GtkStylePrivate *priv;
2707 GtkStateFlags flags = 0;
2710 context = gtk_widget_get_style_context (widget);
2713 priv = GTK_STYLE_GET_PRIVATE (style);
2714 context = priv->context;
2717 gtk_style_context_save (context);
2720 transform_detail_string (detail, context);
2724 case GTK_STATE_PRELIGHT:
2725 flags |= GTK_STATE_FLAG_PRELIGHT;
2727 case GTK_STATE_SELECTED:
2728 flags |= GTK_STATE_FLAG_SELECTED;
2730 case GTK_STATE_INSENSITIVE:
2731 flags |= GTK_STATE_FLAG_INSENSITIVE;
2737 gtk_style_context_set_state (context, flags);
2741 gtk_render_layout (context, cr,
2747 gtk_style_context_restore (context);
2751 gtk_default_draw_resize_grip (GtkStyle *style,
2753 GtkStateType state_type,
2755 const gchar *detail,
2762 GtkStyleContext *context;
2763 GtkStylePrivate *priv;
2764 GtkStateFlags flags = 0;
2765 GtkJunctionSides sides = 0;
2768 context = gtk_widget_get_style_context (widget);
2771 priv = GTK_STYLE_GET_PRIVATE (style);
2772 context = priv->context;
2775 gtk_style_context_save (context);
2778 transform_detail_string (detail, context);
2780 gtk_style_context_add_class (context, "grip");
2784 case GTK_STATE_PRELIGHT:
2785 flags |= GTK_STATE_FLAG_PRELIGHT;
2787 case GTK_STATE_SELECTED:
2788 flags |= GTK_STATE_FLAG_SELECTED;
2790 case GTK_STATE_INSENSITIVE:
2791 flags |= GTK_STATE_FLAG_INSENSITIVE;
2797 gtk_style_context_set_state (context, flags);
2801 case GDK_WINDOW_EDGE_NORTH_WEST:
2802 sides = GTK_JUNCTION_CORNER_TOPLEFT;
2804 case GDK_WINDOW_EDGE_NORTH:
2805 sides = GTK_JUNCTION_TOP;
2807 case GDK_WINDOW_EDGE_NORTH_EAST:
2808 sides = GTK_JUNCTION_CORNER_TOPRIGHT;
2810 case GDK_WINDOW_EDGE_WEST:
2811 sides = GTK_JUNCTION_LEFT;
2813 case GDK_WINDOW_EDGE_EAST:
2814 sides = GTK_JUNCTION_RIGHT;
2816 case GDK_WINDOW_EDGE_SOUTH_WEST:
2817 sides = GTK_JUNCTION_CORNER_BOTTOMLEFT;
2819 case GDK_WINDOW_EDGE_SOUTH:
2820 sides = GTK_JUNCTION_BOTTOM;
2822 case GDK_WINDOW_EDGE_SOUTH_EAST:
2823 sides = GTK_JUNCTION_CORNER_BOTTOMRIGHT;
2827 gtk_style_context_set_junction_sides (context, sides);
2831 gtk_render_handle (context, cr,
2838 gtk_style_context_restore (context);
2842 gtk_default_draw_spinner (GtkStyle *style,
2844 GtkStateType state_type,
2846 const gchar *detail,
2862 real_step = step % num_steps;
2864 /* set a clip region for the expose event */
2865 cairo_rectangle (cr, x, y, width, height);
2868 cairo_translate (cr, x, y);
2870 /* draw clip region */
2871 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
2873 color = &style->fg[state_type];
2876 radius = MIN (width / 2, height / 2);
2877 half = num_steps / 2;
2879 for (i = 0; i < num_steps; i++)
2881 gint inset = 0.7 * radius;
2883 /* transparency is a function of time and intial value */
2884 gdouble t = (gdouble) ((i + num_steps - real_step)
2885 % num_steps) / num_steps;
2889 cairo_set_source_rgba (cr,
2890 color->red / 65535.,
2891 color->green / 65535.,
2892 color->blue / 65535.,
2895 cairo_set_line_width (cr, 2.0);
2897 dx + (radius - inset) * cos (i * G_PI / half),
2898 dy + (radius - inset) * sin (i * G_PI / half));
2900 dx + radius * cos (i * G_PI / half),
2901 dy + radius * sin (i * G_PI / half));
2909 _gtk_style_shade (const GdkColor *a,
2917 red = (gdouble) a->red / 65535.0;
2918 green = (gdouble) a->green / 65535.0;
2919 blue = (gdouble) a->blue / 65535.0;
2921 rgb_to_hls (&red, &green, &blue);
2926 else if (green < 0.0)
2932 else if (blue < 0.0)
2935 hls_to_rgb (&red, &green, &blue);
2937 b->red = red * 65535.0;
2938 b->green = green * 65535.0;
2939 b->blue = blue * 65535.0;
2943 rgb_to_hls (gdouble *r,
2984 l = (max + min) / 2;
2991 s = (max - min) / (max + min);
2993 s = (max - min) / (2 - max - min);
2997 h = (green - blue) / delta;
2998 else if (green == max)
2999 h = 2 + (blue - red) / delta;
3000 else if (blue == max)
3001 h = 4 + (red - green) / delta;
3014 hls_to_rgb (gdouble *h,
3027 if (lightness <= 0.5)
3028 m2 = lightness * (1 + saturation);
3030 m2 = lightness + saturation - lightness * saturation;
3031 m1 = 2 * lightness - m2;
3033 if (saturation == 0)
3048 r = m1 + (m2 - m1) * hue / 60;
3052 r = m1 + (m2 - m1) * (240 - hue) / 60;
3063 g = m1 + (m2 - m1) * hue / 60;
3067 g = m1 + (m2 - m1) * (240 - hue) / 60;
3078 b = m1 + (m2 - m1) * hue / 60;
3082 b = m1 + (m2 - m1) * (240 - hue) / 60;
3095 * @style: a #GtkStyle
3097 * @state_type: a state
3098 * @widget: (allow-none): the widget
3099 * @detail: (allow-none): a style detail
3100 * @x1: the starting x coordinate
3101 * @x2: the ending x coordinate
3102 * @y: the y coordinate
3104 * Draws a horizontal line from (@x1, @y) to (@x2, @y) in @cr
3105 * using the given style and state.
3107 * Deprecated:3.0: Use gtk_render_line() instead
3110 gtk_paint_hline (GtkStyle *style,
3112 GtkStateType state_type,
3114 const gchar *detail,
3119 g_return_if_fail (GTK_IS_STYLE (style));
3120 g_return_if_fail (cr != NULL);
3121 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_hline != NULL);
3125 GTK_STYLE_GET_CLASS (style)->draw_hline (style, cr, state_type,
3134 * @style: a #GtkStyle
3136 * @state_type: a state
3137 * @widget: (allow-none): the widget
3138 * @detail: (allow-none): a style detail
3139 * @y1_: the starting y coordinate
3140 * @y2_: the ending y coordinate
3141 * @x: the x coordinate
3143 * Draws a vertical line from (@x, @y1_) to (@x, @y2_) in @cr
3144 * using the given style and state.
3146 * Deprecated:3.0: Use gtk_render_line() instead
3149 gtk_paint_vline (GtkStyle *style,
3151 GtkStateType state_type,
3153 const gchar *detail,
3158 g_return_if_fail (GTK_IS_STYLE (style));
3159 g_return_if_fail (cr != NULL);
3160 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_vline != NULL);
3164 GTK_STYLE_GET_CLASS (style)->draw_vline (style, cr, state_type,
3173 * @style: a #GtkStyle
3175 * @state_type: a state
3176 * @shadow_type: type of shadow to draw
3177 * @widget: (allow-none): the widget
3178 * @detail: (allow-none): a style detail
3179 * @x: x origin of the rectangle
3180 * @y: y origin of the rectangle
3181 * @width: width of the rectangle
3182 * @height: width of the rectangle
3184 * Draws a shadow around the given rectangle in @cr
3185 * using the given style and state and shadow type.
3187 * Deprecated:3.0: Use gtk_render_frame() instead
3190 gtk_paint_shadow (GtkStyle *style,
3192 GtkStateType state_type,
3193 GtkShadowType shadow_type,
3195 const gchar *detail,
3201 g_return_if_fail (GTK_IS_STYLE (style));
3202 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow != NULL);
3203 g_return_if_fail (cr != NULL);
3204 g_return_if_fail (width >= 0);
3205 g_return_if_fail (height >= 0);
3209 GTK_STYLE_GET_CLASS (style)->draw_shadow (style, cr, state_type, shadow_type,
3211 x, y, width, height);
3218 * @style: a #GtkStyle
3220 * @state_type: a state
3221 * @shadow_type: the type of shadow to draw
3222 * @widget: (allow-none): the widget
3223 * @detail: (allow-none): a style detail
3224 * @arrow_type: the type of arrow to draw
3225 * @fill: %TRUE if the arrow tip should be filled
3226 * @x: x origin of the rectangle to draw the arrow in
3227 * @y: y origin of the rectangle to draw the arrow in
3228 * @width: width of the rectangle to draw the arrow in
3229 * @height: height of the rectangle to draw the arrow in
3231 * Draws an arrow in the given rectangle on @cr using the given
3232 * parameters. @arrow_type determines the direction of the arrow.
3234 * Deprecated:3.0: Use gtk_render_arrow() instead
3237 gtk_paint_arrow (GtkStyle *style,
3239 GtkStateType state_type,
3240 GtkShadowType shadow_type,
3242 const gchar *detail,
3243 GtkArrowType arrow_type,
3250 g_return_if_fail (GTK_IS_STYLE (style));
3251 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_arrow != NULL);
3252 g_return_if_fail (cr != NULL);
3253 g_return_if_fail (width >= 0);
3254 g_return_if_fail (height >= 0);
3258 GTK_STYLE_GET_CLASS (style)->draw_arrow (style, cr, state_type, shadow_type,
3260 arrow_type, fill, x, y, width, height);
3266 * gtk_paint_diamond:
3267 * @style: a #GtkStyle
3269 * @state_type: a state
3270 * @shadow_type: the type of shadow to draw
3271 * @widget: (allow-none): the widget
3272 * @detail: (allow-none): a style detail
3273 * @x: x origin of the rectangle to draw the diamond in
3274 * @y: y origin of the rectangle to draw the diamond in
3275 * @width: width of the rectangle to draw the diamond in
3276 * @height: height of the rectangle to draw the diamond in
3278 * Draws a diamond in the given rectangle on @window using the given
3281 * Deprecated:3.0: Use cairo instead
3284 gtk_paint_diamond (GtkStyle *style,
3286 GtkStateType state_type,
3287 GtkShadowType shadow_type,
3289 const gchar *detail,
3295 g_return_if_fail (GTK_IS_STYLE (style));
3296 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_diamond != NULL);
3297 g_return_if_fail (cr != NULL);
3298 g_return_if_fail (width >= 0);
3299 g_return_if_fail (height >= 0);
3303 GTK_STYLE_GET_CLASS (style)->draw_diamond (style, cr, state_type, shadow_type,
3305 x, y, width, height);
3312 * @style: a #GtkStyle
3314 * @state_type: a state
3315 * @shadow_type: the type of shadow to draw
3316 * @widget: (allow-none): the widget
3317 * @detail: (allow-none): a style detail
3318 * @x: x origin of the box
3319 * @y: y origin of the box
3320 * @width: the width of the box
3321 * @height: the height of the box
3323 * Draws a box on @cr with the given parameters.
3325 * Deprecated:3.0: Use gtk_render_frame() and gtk_render_background() instead
3328 gtk_paint_box (GtkStyle *style,
3330 GtkStateType state_type,
3331 GtkShadowType shadow_type,
3333 const gchar *detail,
3339 g_return_if_fail (GTK_IS_STYLE (style));
3340 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box != NULL);
3341 g_return_if_fail (cr != NULL);
3345 GTK_STYLE_GET_CLASS (style)->draw_box (style, cr, state_type, shadow_type,
3347 x, y, width, height);
3353 * gtk_paint_flat_box:
3354 * @style: a #GtkStyle
3356 * @state_type: a state
3357 * @shadow_type: the type of shadow to draw
3358 * @widget: (allow-none): the widget
3359 * @detail: (allow-none): a style detail
3360 * @x: x origin of the box
3361 * @y: y origin of the box
3362 * @width: the width of the box
3363 * @height: the height of the box
3365 * Draws a flat box on @cr with the given parameters.
3367 * Deprecated:3.0: Use gtk_render_frame() and gtk_render_background() instead
3370 gtk_paint_flat_box (GtkStyle *style,
3372 GtkStateType state_type,
3373 GtkShadowType shadow_type,
3375 const gchar *detail,
3381 g_return_if_fail (GTK_IS_STYLE (style));
3382 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_flat_box != NULL);
3383 g_return_if_fail (cr != NULL);
3384 g_return_if_fail (width >= 0);
3385 g_return_if_fail (height >= 0);
3389 GTK_STYLE_GET_CLASS (style)->draw_flat_box (style, cr, state_type, shadow_type,
3391 x, y, width, height);
3398 * @style: a #GtkStyle
3400 * @state_type: a state
3401 * @shadow_type: the type of shadow to draw
3402 * @widget: (allow-none): the widget
3403 * @detail: (allow-none): a style detail
3404 * @x: x origin of the rectangle to draw the check in
3405 * @y: y origin of the rectangle to draw the check in
3406 * @width: the width of the rectangle to draw the check in
3407 * @height: the height of the rectangle to draw the check in
3409 * Draws a check button indicator in the given rectangle on @cr with
3410 * the given parameters.
3412 * Deprecated:3.0: Use gtk_render_check() instead
3415 gtk_paint_check (GtkStyle *style,
3417 GtkStateType state_type,
3418 GtkShadowType shadow_type,
3420 const gchar *detail,
3426 g_return_if_fail (GTK_IS_STYLE (style));
3427 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_check != NULL);
3428 g_return_if_fail (cr != NULL);
3432 GTK_STYLE_GET_CLASS (style)->draw_check (style, cr, state_type, shadow_type,
3434 x, y, width, height);
3441 * @style: a #GtkStyle
3443 * @state_type: a state
3444 * @shadow_type: the type of shadow to draw
3445 * @widget: (allow-none): the widget
3446 * @detail: (allow-none): a style detail
3447 * @x: x origin of the rectangle to draw the option in
3448 * @y: y origin of the rectangle to draw the option in
3449 * @width: the width of the rectangle to draw the option in
3450 * @height: the height of the rectangle to draw the option in
3452 * Draws a radio button indicator in the given rectangle on @cr with
3453 * the given parameters.
3455 * Deprecated:3.0: Use gtk_render_option() instead
3458 gtk_paint_option (GtkStyle *style,
3460 GtkStateType state_type,
3461 GtkShadowType shadow_type,
3463 const gchar *detail,
3469 g_return_if_fail (GTK_IS_STYLE (style));
3470 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_option != NULL);
3471 g_return_if_fail (cr != NULL);
3475 GTK_STYLE_GET_CLASS (style)->draw_option (style, cr, state_type, shadow_type,
3477 x, y, width, height);
3484 * @style: a #GtkStyle
3486 * @state_type: a state
3487 * @shadow_type: the type of shadow to draw
3488 * @widget: (allow-none): the widget
3489 * @detail: (allow-none): a style detail
3490 * @x: x origin of the rectangle to draw the tab in
3491 * @y: y origin of the rectangle to draw the tab in
3492 * @width: the width of the rectangle to draw the tab in
3493 * @height: the height of the rectangle to draw the tab in
3495 * Draws an option menu tab (i.e. the up and down pointing arrows)
3496 * in the given rectangle on @cr using the given parameters.
3498 * Deprecated:3.0: Use cairo instead
3501 gtk_paint_tab (GtkStyle *style,
3503 GtkStateType state_type,
3504 GtkShadowType shadow_type,
3506 const gchar *detail,
3512 g_return_if_fail (GTK_IS_STYLE (style));
3513 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_tab != NULL);
3514 g_return_if_fail (cr != NULL);
3518 GTK_STYLE_GET_CLASS (style)->draw_tab (style, cr, state_type, shadow_type,
3520 x, y, width, height);
3526 * gtk_paint_shadow_gap:
3527 * @style: a #GtkStyle
3529 * @state_type: a state
3530 * @shadow_type: type of shadow to draw
3531 * @widget: (allow-none): the widget
3532 * @detail: (allow-none): a style detail
3533 * @x: x origin of the rectangle
3534 * @y: y origin of the rectangle
3535 * @width: width of the rectangle
3536 * @height: width of the rectangle
3537 * @gap_side: side in which to leave the gap
3538 * @gap_x: starting position of the gap
3539 * @gap_width: width of the gap
3541 * Draws a shadow around the given rectangle in @cr
3542 * using the given style and state and shadow type, leaving a
3545 * Deprecated:3.0: Use gtk_render_frame_gap() instead
3548 gtk_paint_shadow_gap (GtkStyle *style,
3550 GtkStateType state_type,
3551 GtkShadowType shadow_type,
3553 const gchar *detail,
3558 GtkPositionType gap_side,
3562 g_return_if_fail (GTK_IS_STYLE (style));
3563 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow_gap != NULL);
3564 g_return_if_fail (cr != NULL);
3565 g_return_if_fail (width >= 0);
3566 g_return_if_fail (height >= 0);
3570 GTK_STYLE_GET_CLASS (style)->draw_shadow_gap (style, cr, state_type, shadow_type,
3572 x, y, width, height, gap_side, gap_x, gap_width);
3578 * gtk_paint_box_gap:
3579 * @style: a #GtkStyle
3581 * @state_type: a state
3582 * @shadow_type: type of shadow to draw
3583 * @widget: (allow-none): the widget
3584 * @detail: (allow-none): a style detail
3585 * @x: x origin of the rectangle
3586 * @y: y origin of the rectangle
3587 * @width: width of the rectangle
3588 * @height: width of the rectangle
3589 * @gap_side: side in which to leave the gap
3590 * @gap_x: starting position of the gap
3591 * @gap_width: width of the gap
3593 * Draws a box in @cr using the given style and state and shadow type,
3594 * leaving a gap in one side.
3596 * Deprecated:3.0: Use gtk_render_frame_gap() instead
3599 gtk_paint_box_gap (GtkStyle *style,
3601 GtkStateType state_type,
3602 GtkShadowType shadow_type,
3604 const gchar *detail,
3609 GtkPositionType gap_side,
3613 g_return_if_fail (GTK_IS_STYLE (style));
3614 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box_gap != NULL);
3615 g_return_if_fail (cr != NULL);
3616 g_return_if_fail (width >= 0);
3617 g_return_if_fail (height >= 0);
3621 GTK_STYLE_GET_CLASS (style)->draw_box_gap (style, cr, state_type, shadow_type,
3623 x, y, width, height, gap_side, gap_x, gap_width);
3629 * gtk_paint_extension:
3630 * @style: a #GtkStyle
3632 * @state_type: a state
3633 * @shadow_type: type of shadow to draw
3634 * @widget: (allow-none): the widget
3635 * @detail: (allow-none): a style detail
3636 * @x: x origin of the extension
3637 * @y: y origin of the extension
3638 * @width: width of the extension
3639 * @height: width of the extension
3640 * @gap_side: the side on to which the extension is attached
3642 * Draws an extension, i.e. a notebook tab.
3644 * Deprecated:3.0: Use gtk_render_extension() instead
3647 gtk_paint_extension (GtkStyle *style,
3649 GtkStateType state_type,
3650 GtkShadowType shadow_type,
3652 const gchar *detail,
3657 GtkPositionType gap_side)
3659 g_return_if_fail (GTK_IS_STYLE (style));
3660 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_extension != NULL);
3661 g_return_if_fail (cr != NULL);
3662 g_return_if_fail (width >= 0);
3663 g_return_if_fail (height >= 0);
3667 GTK_STYLE_GET_CLASS (style)->draw_extension (style, cr, state_type, shadow_type,
3669 x, y, width, height, gap_side);
3676 * @style: a #GtkStyle
3678 * @state_type: a state
3679 * @widget: (allow-none): the widget
3680 * @detail: (allow-none): a style detail
3681 * @x: the x origin of the rectangle around which to draw a focus indicator
3682 * @y: the y origin of the rectangle around which to draw a focus indicator
3683 * @width: the width of the rectangle around which to draw a focus indicator
3684 * @height: the height of the rectangle around which to draw a focus indicator
3686 * Draws a focus indicator around the given rectangle on @cr using the
3689 * Deprecated:3.0: Use gtk_render_focus() instead
3692 gtk_paint_focus (GtkStyle *style,
3694 GtkStateType state_type,
3696 const gchar *detail,
3702 g_return_if_fail (GTK_IS_STYLE (style));
3703 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_focus != NULL);
3704 g_return_if_fail (cr != NULL);
3705 g_return_if_fail (width >= 0);
3706 g_return_if_fail (height >= 0);
3710 GTK_STYLE_GET_CLASS (style)->draw_focus (style, cr, state_type,
3712 x, y, width, height);
3719 * @style: a #GtkStyle
3721 * @state_type: a state
3722 * @shadow_type: a shadow
3723 * @widget: (allow-none): the widget
3724 * @detail: (allow-none): a style detail
3725 * @x: the x origin of the rectangle in which to draw a slider
3726 * @y: the y origin of the rectangle in which to draw a slider
3727 * @width: the width of the rectangle in which to draw a slider
3728 * @height: the height of the rectangle in which to draw a slider
3729 * @orientation: the orientation to be used
3731 * Draws a slider in the given rectangle on @cr using the
3732 * given style and orientation.
3734 * Deprecated:3.0: Use gtk_render_slider() instead
3737 gtk_paint_slider (GtkStyle *style,
3739 GtkStateType state_type,
3740 GtkShadowType shadow_type,
3742 const gchar *detail,
3747 GtkOrientation orientation)
3749 g_return_if_fail (GTK_IS_STYLE (style));
3750 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_slider != NULL);
3751 g_return_if_fail (cr != NULL);
3752 g_return_if_fail (width >= 0);
3753 g_return_if_fail (height >= 0);
3757 GTK_STYLE_GET_CLASS (style)->draw_slider (style, cr, state_type, shadow_type,
3759 x, y, width, height, orientation);
3766 * @style: a #GtkStyle
3768 * @state_type: a state
3769 * @shadow_type: type of shadow to draw
3770 * @widget: (allow-none): the widget
3771 * @detail: (allow-none): a style detail
3772 * @x: x origin of the handle
3773 * @y: y origin of the handle
3774 * @width: with of the handle
3775 * @height: height of the handle
3776 * @orientation: the orientation of the handle
3778 * Draws a handle as used in #GtkHandleBox and #GtkPaned.
3780 * Deprecated:3.0: Use gtk_render_handle() instead
3783 gtk_paint_handle (GtkStyle *style,
3785 GtkStateType state_type,
3786 GtkShadowType shadow_type,
3788 const gchar *detail,
3793 GtkOrientation orientation)
3795 g_return_if_fail (GTK_IS_STYLE (style));
3796 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_handle != NULL);
3797 g_return_if_fail (cr != NULL);
3798 g_return_if_fail (width >= 0);
3799 g_return_if_fail (height >= 0);
3803 GTK_STYLE_GET_CLASS (style)->draw_handle (style, cr, state_type, shadow_type,
3805 x, y, width, height, orientation);
3811 * gtk_paint_expander:
3812 * @style: a #GtkStyle
3814 * @state_type: a state
3815 * @widget: (allow-none): the widget
3816 * @detail: (allow-none): a style detail
3817 * @x: the x position to draw the expander at
3818 * @y: the y position to draw the expander at
3819 * @expander_style: the style to draw the expander in; determines
3820 * whether the expander is collapsed, expanded, or in an
3821 * intermediate state.
3823 * Draws an expander as used in #GtkTreeView. @x and @y specify the
3824 * center the expander. The size of the expander is determined by the
3825 * "expander-size" style property of @widget. (If widget is not
3826 * specified or doesn't have an "expander-size" property, an
3827 * unspecified default size will be used, since the caller doesn't
3828 * have sufficient information to position the expander, this is
3829 * likely not useful.) The expander is expander_size pixels tall
3830 * in the collapsed position and expander_size pixels wide in the
3831 * expanded position.
3833 * Deprecated:3.0: Use gtk_render_expander() instead
3836 gtk_paint_expander (GtkStyle *style,
3838 GtkStateType state_type,
3840 const gchar *detail,
3843 GtkExpanderStyle expander_style)
3845 g_return_if_fail (GTK_IS_STYLE (style));
3846 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_expander != NULL);
3847 g_return_if_fail (cr != NULL);
3851 GTK_STYLE_GET_CLASS (style)->draw_expander (style, cr, state_type,
3853 x, y, expander_style);
3860 * @style: a #GtkStyle
3862 * @state_type: a state
3863 * @use_text: whether to use the text or foreground
3864 * graphics context of @style
3865 * @widget: (allow-none): the widget
3866 * @detail: (allow-none): a style detail
3869 * @layout: the layout to draw
3871 * Draws a layout on @cr using the given parameters.
3873 * Deprecated:3.0: Use gtk_render_layout() instead
3876 gtk_paint_layout (GtkStyle *style,
3878 GtkStateType state_type,
3881 const gchar *detail,
3884 PangoLayout *layout)
3886 g_return_if_fail (GTK_IS_STYLE (style));
3887 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_layout != NULL);
3888 g_return_if_fail (cr != NULL);
3892 GTK_STYLE_GET_CLASS (style)->draw_layout (style, cr, state_type, use_text,
3900 * gtk_paint_resize_grip:
3901 * @style: a #GtkStyle
3903 * @state_type: a state
3904 * @widget: (allow-none): the widget
3905 * @detail: (allow-none): a style detail
3906 * @edge: the edge in which to draw the resize grip
3907 * @x: the x origin of the rectangle in which to draw the resize grip
3908 * @y: the y origin of the rectangle in which to draw the resize grip
3909 * @width: the width of the rectangle in which to draw the resize grip
3910 * @height: the height of the rectangle in which to draw the resize grip
3912 * Draws a resize grip in the given rectangle on @cr using the given
3915 * Deprecated:3.0: Use gtk_render_handle() instead
3918 gtk_paint_resize_grip (GtkStyle *style,
3920 GtkStateType state_type,
3922 const gchar *detail,
3929 g_return_if_fail (GTK_IS_STYLE (style));
3930 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_resize_grip != NULL);
3931 g_return_if_fail (cr != NULL);
3935 GTK_STYLE_GET_CLASS (style)->draw_resize_grip (style, cr, state_type,
3937 edge, x, y, width, height);
3942 * gtk_paint_spinner:
3943 * @style: a #GtkStyle
3945 * @state_type: a state
3946 * @widget: (allow-none): the widget (may be %NULL)
3947 * @detail: (allow-none): a style detail (may be %NULL)
3948 * @step: the nth step, a value between 0 and #GtkSpinner:num-steps
3949 * @x: the x origin of the rectangle in which to draw the spinner
3950 * @y: the y origin of the rectangle in which to draw the spinner
3951 * @width: the width of the rectangle in which to draw the spinner
3952 * @height: the height of the rectangle in which to draw the spinner
3954 * Draws a spinner on @window using the given parameters.
3956 * Deprecated:3.0: Use gtk_render_activity() instead
3959 gtk_paint_spinner (GtkStyle *style,
3961 GtkStateType state_type,
3963 const gchar *detail,
3970 g_return_if_fail (GTK_IS_STYLE (style));
3971 g_return_if_fail (cr != NULL);
3972 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_spinner != NULL);
3976 GTK_STYLE_GET_CLASS (style)->draw_spinner (style, cr, state_type,
3978 step, x, y, width, height);