1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 2010 Carlos Garnacho <carlosg@gnome.org>
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.
25 #include <gtk/gtkthemingengine.h>
26 #include <gtk/gtkstylecontext.h>
27 #include <gtk/gtkintl.h>
31 typedef struct GtkThemingEnginePrivate GtkThemingEnginePrivate;
40 struct GtkThemingEnginePrivate
42 GtkStyleContext *context;
45 #define GTK_THEMING_ENGINE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_THEMING_ENGINE, GtkThemingEnginePrivate))
47 static void gtk_theming_engine_render_check (GtkThemingEngine *engine,
53 static void gtk_theming_engine_render_option (GtkThemingEngine *engine,
59 static void gtk_theming_engine_render_arrow (GtkThemingEngine *engine,
65 static void gtk_theming_engine_render_background (GtkThemingEngine *engine,
71 static void gtk_theming_engine_render_frame (GtkThemingEngine *engine,
77 static void gtk_theming_engine_render_expander (GtkThemingEngine *engine,
83 static void gtk_theming_engine_render_focus (GtkThemingEngine *engine,
89 static void gtk_theming_engine_render_layout (GtkThemingEngine *engine,
94 static void gtk_theming_engine_render_line (GtkThemingEngine *engine,
100 static void gtk_theming_engine_render_slider (GtkThemingEngine *engine,
106 GtkOrientation orientation);
107 static void gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine,
113 GtkPositionType gap_side,
116 static void gtk_theming_engine_render_extension (GtkThemingEngine *engine,
122 GtkPositionType gap_side);
123 static void gtk_theming_engine_render_handle (GtkThemingEngine *engine,
129 GtkOrientation orientation);
131 G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT)
134 typedef struct GtkThemingModule GtkThemingModule;
135 typedef struct GtkThemingModuleClass GtkThemingModuleClass;
137 struct GtkThemingModule
139 GTypeModule parent_instance;
142 GtkThemingEngine * (*create_engine) (void);
145 struct GtkThemingModuleClass
147 GTypeModuleClass parent_class;
150 #define GTK_TYPE_THEMING_MODULE (gtk_theming_module_get_type ())
151 #define GTK_THEMING_MODULE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_THEMING_MODULE, GtkThemingModule))
152 #define GTK_IS_THEMING_MODULE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_THEMING_MODULE))
154 G_DEFINE_TYPE (GtkThemingModule, gtk_theming_module, G_TYPE_TYPE_MODULE);
157 gtk_theming_engine_class_init (GtkThemingEngineClass *klass)
159 GObjectClass *object_class = G_OBJECT_CLASS (klass);
161 klass->render_check = gtk_theming_engine_render_check;
162 klass->render_option = gtk_theming_engine_render_option;
163 klass->render_arrow = gtk_theming_engine_render_arrow;
164 klass->render_background = gtk_theming_engine_render_background;
165 klass->render_frame = gtk_theming_engine_render_frame;
166 klass->render_expander = gtk_theming_engine_render_expander;
167 klass->render_focus = gtk_theming_engine_render_focus;
168 klass->render_layout = gtk_theming_engine_render_layout;
169 klass->render_line = gtk_theming_engine_render_line;
170 klass->render_slider = gtk_theming_engine_render_slider;
171 klass->render_frame_gap = gtk_theming_engine_render_frame_gap;
172 klass->render_extension = gtk_theming_engine_render_extension;
173 klass->render_handle = gtk_theming_engine_render_handle;
175 g_type_class_add_private (object_class, sizeof (GtkThemingEnginePrivate));
179 gtk_theming_engine_init (GtkThemingEngine *engine)
181 engine->priv = GTK_THEMING_ENGINE_GET_PRIVATE (engine);
185 _gtk_theming_engine_set_context (GtkThemingEngine *engine,
186 GtkStyleContext *context)
188 GtkThemingEnginePrivate *priv;
190 g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
191 g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
194 priv->context = context;
198 gtk_theming_engine_register_property (GtkThemingEngine *engine,
199 const gchar *property_name,
201 const GValue *default_value,
202 GtkStylePropertyParser parse_func)
206 g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
207 g_return_if_fail (property_name != NULL);
208 g_return_if_fail (type != G_TYPE_INVALID);
209 g_return_if_fail (default_value != NULL && G_IS_VALUE (default_value));
211 name = g_strdup_printf ("-%s-%s", G_OBJECT_TYPE_NAME (engine), property_name);
212 gtk_style_set_register_property (name, type, default_value, parse_func);
217 gtk_theming_engine_get_property (GtkThemingEngine *engine,
218 const gchar *property,
222 GtkThemingEnginePrivate *priv;
224 g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
225 g_return_if_fail (property != NULL);
226 g_return_if_fail (state < GTK_STATE_LAST);
227 g_return_if_fail (value != NULL);
230 gtk_style_context_get_property (priv->context, property, state, value);
234 gtk_theming_engine_get_valist (GtkThemingEngine *engine,
238 GtkThemingEnginePrivate *priv;
240 g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
241 g_return_if_fail (state < GTK_STATE_LAST);
244 gtk_style_context_get_valist (priv->context, state, args);
248 gtk_theming_engine_get (GtkThemingEngine *engine,
252 GtkThemingEnginePrivate *priv;
255 g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
256 g_return_if_fail (state < GTK_STATE_LAST);
260 va_start (args, state);
261 gtk_style_context_get_valist (priv->context, state, args);
266 gtk_theming_engine_get_style_property (GtkThemingEngine *engine,
267 const gchar *property_name,
270 GtkThemingEnginePrivate *priv;
272 g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
273 g_return_if_fail (property_name != NULL);
276 gtk_style_context_get_style_property (priv->context, property_name, value);
280 gtk_theming_engine_get_style_valist (GtkThemingEngine *engine,
283 GtkThemingEnginePrivate *priv;
285 g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
288 gtk_style_context_get_style_valist (priv->context, args);
292 gtk_theming_engine_get_style (GtkThemingEngine *engine,
295 GtkThemingEnginePrivate *priv;
298 g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
302 va_start (args, engine);
303 gtk_style_context_get_style_valist (priv->context, args);
308 gtk_theming_engine_get_state (GtkThemingEngine *engine)
310 GtkThemingEnginePrivate *priv;
312 g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), 0);
315 return gtk_style_context_get_state (priv->context);
319 gtk_theming_engine_is_state_set (GtkThemingEngine *engine,
322 GtkThemingEnginePrivate *priv;
324 g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), 0);
327 return gtk_style_context_is_state_set (priv->context, state);
330 G_CONST_RETURN GtkWidgetPath *
331 gtk_theming_engine_get_path (GtkThemingEngine *engine)
333 GtkThemingEnginePrivate *priv;
335 g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), NULL);
338 return gtk_style_context_get_path (priv->context);
342 gtk_theming_engine_has_class (GtkThemingEngine *engine,
343 const gchar *style_class)
345 GtkThemingEnginePrivate *priv;
347 g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), FALSE);
350 return gtk_style_context_has_class (priv->context, style_class);
354 gtk_theming_engine_has_child_class (GtkThemingEngine *engine,
355 const gchar *style_class,
356 GtkChildClassFlags *flags)
358 GtkThemingEnginePrivate *priv;
363 g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), FALSE);
366 return gtk_style_context_has_child_class (priv->context, style_class, flags);
370 gtk_theming_engine_get_direction (GtkThemingEngine *engine)
372 GtkThemingEnginePrivate *priv;
374 g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), GTK_TEXT_DIR_LTR);
377 return gtk_style_context_get_direction (priv->context);
381 gtk_theming_engine_get_junction_sides (GtkThemingEngine *engine)
383 GtkThemingEnginePrivate *priv;
385 g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), 0);
388 return gtk_style_context_get_junction_sides (priv->context);
391 /* GtkThemingModule */
394 gtk_theming_module_load (GTypeModule *type_module)
396 GtkThemingModule *theming_module;
398 gchar *name, *module_path;
400 theming_module = GTK_THEMING_MODULE (type_module);
401 name = theming_module->name;
402 module_path = _gtk_find_module (name, "theming-engines");
406 g_warning (_("Unable to locate theme engine in module path: \"%s\","), name);
410 module = g_module_open (module_path, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
411 g_free (module_path);
415 g_warning ("%s", g_module_error ());
419 if (!g_module_symbol (module, "create_engine",
420 (gpointer *) &theming_module->create_engine))
422 g_warning ("%s", g_module_error());
423 g_module_close (module);
428 g_module_make_resident (module);
434 gtk_theming_module_class_init (GtkThemingModuleClass *klass)
436 GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS (klass);
438 module_class->load = gtk_theming_module_load;
442 gtk_theming_module_init (GtkThemingModule *module)
446 G_CONST_RETURN GtkThemingEngine *
447 gtk_theming_engine_load (const gchar *name)
449 static GHashTable *engines = NULL;
450 static GtkThemingEngine *default_engine;
451 GtkThemingEngine *engine = NULL;
456 engines = g_hash_table_new (g_str_hash, g_str_equal);
458 engine = g_hash_table_lookup (engines, name);
462 GtkThemingModule *module;
464 module = g_object_new (GTK_TYPE_THEMING_MODULE, NULL);
465 g_type_module_set_name (G_TYPE_MODULE (module), name);
466 module->name = g_strdup (name);
468 if (module && g_type_module_use (G_TYPE_MODULE (module)))
470 engine = (module->create_engine) ();
473 g_hash_table_insert (engines, module->name, engine);
480 if (G_UNLIKELY (!default_engine))
481 default_engine = g_object_new (GTK_TYPE_THEMING_ENGINE, NULL);
483 engine = default_engine;
490 gtk_theming_engine_get_screen (GtkThemingEngine *engine)
492 GtkThemingEnginePrivate *priv;
494 g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), NULL);
497 return gtk_style_context_get_screen (priv->context);
500 /* Paint method implementations */
502 gtk_theming_engine_render_check (GtkThemingEngine *engine,
509 GdkColor *fg_color, *base_color, *text_color;
510 const GtkWidgetPath *path;
513 gint exterior_size, interior_size, thickness, pad;
515 flags = gtk_theming_engine_get_state (engine);
516 path = gtk_theming_engine_get_path (engine);
519 if (flags & GTK_STATE_FLAG_PRELIGHT)
520 state = GTK_STATE_PRELIGHT;
522 state = GTK_STATE_NORMAL;
524 gtk_theming_engine_get (engine, state,
525 "foreground-color", &fg_color,
526 "base-color", &base_color,
527 "text-color", &text_color,
530 exterior_size = MIN (width, height);
532 if (exterior_size % 2 == 0) /* Ensure odd */
535 /* FIXME: thickness */
537 pad = thickness + MAX (1, (exterior_size - 2 * thickness) / 9);
538 interior_size = MAX (1, exterior_size - 2 * pad);
540 if (interior_size < 7)
543 pad = MAX (0, (exterior_size - interior_size) / 2);
546 x -= (1 + exterior_size - (gint) width) / 2;
547 y -= (1 + exterior_size - (gint) height) / 2;
549 if (!gtk_theming_engine_has_class (engine, "menu"))
551 cairo_set_line_width (cr, 1.0);
553 cairo_rectangle (cr, x + 0.5, y + 0.5, exterior_size - 1, exterior_size - 1);
554 gdk_cairo_set_source_color (cr, base_color);
555 cairo_fill_preserve (cr);
557 if (gtk_theming_engine_has_class (engine, "cell"))
558 gdk_cairo_set_source_color (cr, text_color);
560 gdk_cairo_set_source_color (cr, fg_color);
565 if (gtk_theming_engine_has_class (engine, "menu"))
566 gdk_cairo_set_source_color (cr, fg_color);
568 gdk_cairo_set_source_color (cr, text_color);
570 if (gtk_theming_engine_is_state_set (engine, GTK_STATE_INCONSISTENT))
572 int line_thickness = MAX (1, (3 + interior_size * 2) / 7);
576 y + pad + (1 + interior_size - line_thickness) / 2,
581 else if (gtk_theming_engine_is_state_set (engine, GTK_STATE_ACTIVE))
586 cairo_scale (cr, interior_size / 7., interior_size / 7.);
588 cairo_move_to (cr, 7.0, 0.0);
589 cairo_line_to (cr, 7.5, 1.0);
590 cairo_curve_to (cr, 5.3, 2.0,
593 cairo_curve_to (cr, 3.0, 5.7,
596 cairo_line_to (cr, 0.2, 3.5);
597 cairo_curve_to (cr, 1.1, 3.5,
600 cairo_curve_to (cr, 1.0, 3.9,
603 cairo_curve_to (cr, 3.5, 3.1,
612 gdk_color_free (fg_color);
613 gdk_color_free (base_color);
614 gdk_color_free (text_color);
618 gtk_theming_engine_render_option (GtkThemingEngine *engine,
626 GdkColor *base_color, *fg_color, *text_color;
627 const GtkWidgetPath *path;
629 gint exterior_size, interior_size, pad, thickness;
632 /* FIXME: set clipping */
634 flags = gtk_theming_engine_get_state (engine);
635 path = gtk_theming_engine_get_path (engine);
636 radius = MIN (width, height) / 2 - 0.5;
640 if (flags & GTK_STATE_FLAG_PRELIGHT)
641 state = GTK_STATE_PRELIGHT;
643 state = GTK_STATE_NORMAL;
645 gtk_theming_engine_get (engine, state,
646 "foreground-color", &fg_color,
647 "base-color", &base_color,
648 "text-color", &text_color,
651 exterior_size = MIN (width, height);
653 if (exterior_size % 2 == 0) /* Ensure odd */
656 x -= (1 + exterior_size - width) / 2;
657 y -= (1 + exterior_size - height) / 2;
659 if (!gtk_theming_engine_has_class (engine, "menu"))
661 gdk_cairo_set_source_color (cr, base_color);
664 x + exterior_size / 2.,
665 y + exterior_size / 2.,
666 (exterior_size - 1) / 2.,
669 cairo_fill_preserve (cr);
671 if (gtk_theming_engine_has_class (engine, "cell"))
672 gdk_cairo_set_source_color (cr, text_color);
674 gdk_cairo_set_source_color (cr, fg_color);
676 cairo_set_line_width (cr, 1.);
680 if (gtk_theming_engine_has_class (engine, "menu"))
681 gdk_cairo_set_source_color (cr, fg_color);
683 gdk_cairo_set_source_color (cr, text_color);
685 /* FIXME: thickness */
688 if (gtk_theming_engine_is_state_set (engine, GTK_STATE_INCONSISTENT))
692 pad = thickness + MAX (1, (exterior_size - 2 * thickness) / 9);
693 interior_size = MAX (1, exterior_size - 2 * pad);
695 if (interior_size < 7)
698 pad = MAX (0, (exterior_size - interior_size) / 2);
701 line_thickness = MAX (1, (3 + interior_size * 2) / 7);
705 y + pad + (interior_size - line_thickness) / 2.,
710 if (gtk_theming_engine_is_state_set (engine, GTK_STATE_ACTIVE))
712 pad = thickness + MAX (1, 2 * (exterior_size - 2 * thickness) / 9);
713 interior_size = MAX (1, exterior_size - 2 * pad);
715 if (interior_size < 5)
718 pad = MAX (0, (exterior_size - interior_size) / 2);
722 x + pad + interior_size / 2.,
723 y + pad + interior_size / 2.,
733 add_path_arrow (cairo_t *cr,
741 cairo_translate (cr, x + (size / 2), y + (size / 2));
742 cairo_rotate (cr, angle);
744 cairo_move_to (cr, 0, - (size / 4));
745 cairo_line_to (cr, - (size / 2), (size / 4));
746 cairo_line_to (cr, (size / 2), (size / 4));
747 cairo_close_path (cr);
753 gtk_theming_engine_render_arrow (GtkThemingEngine *engine,
766 flags = gtk_theming_engine_get_state (engine);
768 if (flags & GTK_STATE_FLAG_PRELIGHT)
769 state = GTK_STATE_PRELIGHT;
770 else if (flags & GTK_STATE_FLAG_INSENSITIVE)
771 state = GTK_STATE_INSENSITIVE;
773 state = GTK_STATE_NORMAL;
775 gtk_theming_engine_get (engine, state,
776 "foreground-color", &fg_color,
779 if (flags & GTK_STATE_FLAG_INSENSITIVE)
781 add_path_arrow (cr, angle, x + 1, y + 1, size);
782 cairo_set_source_rgb (cr, 1, 1, 1);
786 add_path_arrow (cr, angle, x, y, size);
787 gdk_cairo_set_source_color (cr, fg_color);
792 gdk_color_free (fg_color);
796 add_path_line (cairo_t *cr,
802 /* Adjust endpoints */
816 cairo_move_to (cr, x1, y1);
817 cairo_line_to (cr, x2, y2);
821 add_path_rectangle_sides (cairo_t *cr,
828 if (sides & SIDE_TOP)
830 cairo_move_to (cr, x, y + 0.5);
831 cairo_line_to (cr, x + width, y + 0.5);
834 if (sides & SIDE_RIGHT)
836 cairo_move_to (cr, x + width - 0.5, y);
837 cairo_line_to (cr, x + width - 0.5, y + height);
840 if (sides & SIDE_BOTTOM)
842 cairo_move_to (cr, x, y + height - 0.5);
843 cairo_line_to (cr, x + width, y + height - 0.5);
846 if (sides & SIDE_LEFT)
848 cairo_move_to (cr, x + 0.5, y + height);
849 cairo_line_to (cr, x + 0.5, y);
854 add_path_gap_side (cairo_t *cr,
855 GtkPositionType gap_side,
866 add_path_line (cr, x, y, x + xy0_gap, y);
867 add_path_line (cr, x + xy1_gap, y, x + width, y);
870 add_path_line (cr, x, y + height, x + xy0_gap, y + height);
871 add_path_line (cr, x + xy1_gap, y + height, x + width, y + height);
874 add_path_line (cr, x, y, x, y + xy0_gap);
875 add_path_line (cr, x, y + xy1_gap, x, y + height);
878 add_path_line (cr, x + width, y, x + width, y + xy0_gap);
879 add_path_line (cr, x + width, y + xy1_gap, x + width, y + height);
885 color_shade (const GdkColor *color,
887 GdkColor *color_return)
889 color_return->red = CLAMP (color->red * factor, 0, 65535);
890 color_return->green = CLAMP (color->green * factor, 0, 65535);
891 color_return->blue = CLAMP (color->blue * factor, 0, 65535);
895 gtk_theming_engine_render_background (GtkThemingEngine *engine,
907 flags = gtk_theming_engine_get_state (engine);
909 if (flags & GTK_STATE_FLAG_ACTIVE)
910 state = GTK_STATE_ACTIVE;
911 else if (flags & GTK_STATE_FLAG_SELECTED)
912 state = GTK_STATE_SELECTED;
913 else if (flags & GTK_STATE_FLAG_PRELIGHT)
914 state = GTK_STATE_PRELIGHT;
915 else if (flags & GTK_STATE_FLAG_INSENSITIVE)
916 state = GTK_STATE_INSENSITIVE;
918 state = GTK_STATE_NORMAL;
920 if (gtk_theming_engine_has_class (engine, "entry"))
921 gtk_theming_engine_get (engine, state,
922 "base-color", &color,
925 gtk_theming_engine_get (engine, state,
926 "background-color", &color,
929 gdk_cairo_set_source_color (cr, color);
931 if (gtk_theming_engine_has_class (engine, "spinbutton") &&
932 gtk_theming_engine_has_class (engine, "button"))
933 cairo_rectangle (cr, x + 2, y + 2, width - 4, height - 4);
935 cairo_rectangle (cr, x, y, width, height);
937 if (gtk_theming_engine_has_class (engine, "tooltip"))
939 cairo_fill_preserve (cr);
941 cairo_set_source_rgb (cr, 0, 0, 0);
949 gdk_color_free (color);
953 gtk_theming_engine_render_frame (GtkThemingEngine *engine,
962 GdkColor lighter, darker;
966 flags = gtk_theming_engine_get_state (engine);
968 if (flags & GTK_STATE_FLAG_PRELIGHT)
969 state = GTK_STATE_PRELIGHT;
970 else if (flags & GTK_STATE_FLAG_INSENSITIVE)
971 state = GTK_STATE_INSENSITIVE;
973 state = GTK_STATE_NORMAL;
975 cairo_set_line_width (cr, 1);
977 gtk_theming_engine_get (engine, state,
978 "background-color", &bg_color,
980 color_shade (bg_color, 0.7, &darker);
981 color_shade (bg_color, 1.3, &lighter);
983 if (gtk_theming_engine_has_class (engine, "entry") ||
984 gtk_theming_engine_has_class (engine, "scrolled-window") ||
985 gtk_theming_engine_has_class (engine, "viewport"))
987 gdk_cairo_set_source_color (cr, bg_color);
988 add_path_rectangle_sides (cr, x + 1, y + 1, width - 2, height - 2,
989 SIDE_BOTTOM | SIDE_RIGHT);
992 cairo_set_source_rgb (cr, 0, 0, 0);
993 add_path_rectangle_sides (cr, x + 1, y + 1, width - 2, height - 2,
994 SIDE_TOP | SIDE_LEFT);
997 cairo_set_source_rgb (cr, 1, 1, 1);
998 add_path_rectangle_sides (cr, x, y, width, height,
999 SIDE_BOTTOM | SIDE_RIGHT);
1002 gdk_cairo_set_source_color (cr, &darker);
1003 add_path_rectangle_sides (cr, x, y, width, height,
1004 SIDE_TOP | SIDE_LEFT);
1007 else if (gtk_theming_engine_has_class (engine, "button") &&
1008 gtk_theming_engine_has_class (engine, "default"))
1010 cairo_set_source_rgb (cr, 0, 0, 0);
1011 cairo_rectangle (cr, x + 0.5, x + 0.5, width - 1, height - 1);
1014 else if (gtk_theming_engine_has_class (engine, "scrollbar") &&
1015 gtk_theming_engine_has_class (engine, "trough"))
1017 gdk_cairo_set_source_color (cr, &darker);
1018 add_path_rectangle_sides (cr, x, y, width, height,
1019 SIDE_TOP | SIDE_LEFT);
1022 gdk_cairo_set_source_color (cr, &lighter);
1023 add_path_rectangle_sides (cr, x, y, width, height,
1024 SIDE_BOTTOM | SIDE_RIGHT);
1027 else if (gtk_theming_engine_has_class (engine, "spinbutton"))
1029 if (gtk_theming_engine_has_class (engine, "button"))
1031 GtkJunctionSides sides;
1033 sides = gtk_theming_engine_get_junction_sides (engine);
1035 if (sides & GTK_JUNCTION_BOTTOM)
1041 if (gtk_theming_engine_get_direction (engine) == GTK_TEXT_DIR_RTL)
1046 gdk_cairo_set_source_color (cr, &lighter);
1047 add_path_rectangle_sides (cr, x, y, width, height, SIDE_TOP);
1050 gdk_cairo_set_source_color (cr, &darker);
1051 add_path_rectangle_sides (cr, x, y, width, height, SIDE_BOTTOM);
1056 gdk_cairo_set_source_color (cr, &lighter);
1057 add_path_rectangle_sides (cr, x, y, width, height,
1058 SIDE_BOTTOM | SIDE_RIGHT);
1061 gdk_cairo_set_source_color (cr, &darker);
1062 add_path_rectangle_sides (cr, x, y, width, height, SIDE_TOP);
1065 gdk_cairo_set_source_color (cr, bg_color);
1066 add_path_rectangle_sides (cr, x, y, width - 1, height - 1, SIDE_BOTTOM);
1069 cairo_set_source_rgb (cr, 0, 0, 0);
1070 add_path_rectangle_sides (cr, x, y + 1, width - 1, height - 3,
1071 SIDE_TOP | SIDE_LEFT | SIDE_RIGHT);
1077 if (flags & GTK_STATE_FLAG_ACTIVE)
1079 cairo_set_source_rgb (cr, 0, 0, 0);
1080 add_path_rectangle_sides (cr, x + 1, y + 1, width - 2, height - 2,
1081 SIDE_TOP | SIDE_LEFT);
1084 gdk_cairo_set_source_color (cr, &lighter);
1085 add_path_rectangle_sides (cr, x, y, width, height,
1086 SIDE_BOTTOM | SIDE_RIGHT);
1089 gdk_cairo_set_source_color (cr, &darker);
1090 add_path_rectangle_sides (cr, x, y, width, height,
1091 SIDE_TOP | SIDE_LEFT);
1096 gdk_cairo_set_source_color (cr, &darker);
1097 add_path_rectangle_sides (cr, x, y, width - 1, height - 1,
1098 SIDE_BOTTOM | SIDE_RIGHT);
1101 gdk_cairo_set_source_color (cr, &lighter);
1102 add_path_rectangle_sides (cr, x, y, width, height,
1103 SIDE_TOP | SIDE_LEFT);
1106 cairo_set_source_rgb (cr, 0, 0, 0);
1107 add_path_rectangle_sides (cr, x, y, width, height,
1108 SIDE_BOTTOM | SIDE_RIGHT);
1115 gdk_color_free (bg_color);
1119 gtk_theming_engine_render_expander (GtkThemingEngine *engine,
1126 GtkStateFlags flags;
1127 GdkColor *bg_color, *fg_color, *base_color;
1129 double vertical_overshoot;
1132 double interp; /* interpolation factor for center position */
1133 double x_double_horz, y_double_horz;
1134 double x_double_vert, y_double_vert;
1135 double x_double, y_double;
1140 flags = gtk_theming_engine_get_state (engine);
1142 if (flags & GTK_STATE_FLAG_PRELIGHT)
1143 state = GTK_STATE_PRELIGHT;
1144 else if (flags & GTK_STATE_FLAG_INSENSITIVE)
1145 state = GTK_STATE_INSENSITIVE;
1147 state = GTK_STATE_NORMAL;
1149 gtk_theming_engine_get (engine, state,
1150 "foreground-color", &fg_color,
1151 "background-color", &bg_color,
1152 "base-color", &base_color,
1157 /* FIXME: LTR/RTL */
1158 if (flags & GTK_STATE_FLAG_ACTIVE)
1169 /* Compute distance that the stroke extends beyonds the end
1170 * of the triangle we draw.
1172 vertical_overshoot = line_width / 2.0 * (1. / tan (G_PI / 8));
1174 /* For odd line widths, we end the vertical line of the triangle
1175 * at a half pixel, so we round differently.
1177 if (line_width % 2 == 1)
1178 vertical_overshoot = ceil (0.5 + vertical_overshoot) - 0.5;
1180 vertical_overshoot = ceil (vertical_overshoot);
1182 /* Adjust the size of the triangle we draw so that the entire stroke fits
1184 diameter = (gint) MAX (3, width - 2 * vertical_overshoot);
1186 /* If the line width is odd, we want the diameter to be even,
1187 * and vice versa, so force the sum to be odd. This relationship
1188 * makes the point of the triangle look right.
1190 diameter -= (1 - (diameter + line_width) % 2);
1192 radius = diameter / 2.;
1194 /* Adjust the center so that the stroke is properly aligned with
1195 * the pixel grid. The center adjustment is different for the
1196 * horizontal and vertical orientations. For intermediate positions
1197 * we interpolate between the two.
1199 x_double_vert = floor ((x + width / 2) - (radius + line_width) / 2.) + (radius + line_width) / 2.;
1200 y_double_vert = (y + height / 2) - 0.5;
1202 x_double_horz = (x + width / 2) - 0.5;
1203 y_double_horz = floor ((y + height / 2) - (radius + line_width) / 2.) + (radius + line_width) / 2.;
1205 x_double = x_double_vert * (1 - interp) + x_double_horz * interp;
1206 y_double = y_double_vert * (1 - interp) + y_double_horz * interp;
1208 cairo_translate (cr, x_double, y_double);
1209 cairo_rotate (cr, angle);
1211 cairo_move_to (cr, - radius / 2., - radius);
1212 cairo_line_to (cr, radius / 2., 0);
1213 cairo_line_to (cr, - radius / 2., radius);
1214 cairo_close_path (cr);
1216 cairo_set_line_width (cr, line_width);
1218 if (flags & GTK_STATE_FLAG_PRELIGHT)
1219 gdk_cairo_set_source_color (cr, fg_color);
1221 gdk_cairo_set_source_color (cr, base_color);
1223 cairo_fill_preserve (cr);
1225 gdk_cairo_set_source_color (cr, fg_color);
1230 gdk_color_free (base_color);
1231 gdk_color_free (fg_color);
1232 gdk_color_free (bg_color);
1236 gtk_theming_engine_render_focus (GtkThemingEngine *engine,
1243 GtkStateFlags flags;
1250 flags = gtk_theming_engine_get_state (engine);
1252 if (flags & GTK_STATE_FLAG_PRELIGHT)
1253 state = GTK_STATE_PRELIGHT;
1254 else if (flags & GTK_STATE_FLAG_INSENSITIVE)
1255 state = GTK_STATE_INSENSITIVE;
1257 state = GTK_STATE_NORMAL;
1259 gtk_theming_engine_get (engine, state,
1260 "foreground-color", &color,
1263 gtk_theming_engine_get_style (engine,
1264 "focus-line-width", &line_width,
1265 "focus-line-pattern", (gchar *) &dash_list,
1268 cairo_set_line_width (cr, (gdouble) line_width);
1272 gint n_dashes = strlen ((const gchar *) dash_list);
1273 gdouble *dashes = g_new (gdouble, n_dashes);
1274 gdouble total_length = 0;
1275 gdouble dash_offset;
1278 for (i = 0; i < n_dashes; i++)
1280 dashes[i] = dash_list[i];
1281 total_length += dash_list[i];
1284 /* The dash offset here aligns the pattern to integer pixels
1285 * by starting the dash at the right side of the left border
1286 * Negative dash offsets in cairo don't work
1287 * (https://bugs.freedesktop.org/show_bug.cgi?id=2729)
1289 dash_offset = - line_width / 2.;
1291 while (dash_offset < 0)
1292 dash_offset += total_length;
1294 cairo_set_dash (cr, dashes, n_dashes, dash_offset);
1298 cairo_rectangle (cr,
1299 x + line_width / 2.,
1300 y + line_width / 2.,
1302 height - line_width);
1304 gdk_cairo_set_source_color (cr, color);
1309 gdk_color_free (color);
1314 gtk_theming_engine_render_line (GtkThemingEngine *engine,
1321 GdkColor *bg_color, darker, lighter;
1322 GtkStateFlags flags;
1324 gint i, thickness, thickness_dark, thickness_light, len;
1325 cairo_matrix_t matrix;
1328 /* FIXME: thickness */
1330 thickness_dark = thickness / 2;
1331 thickness_light = thickness - thickness_dark;
1333 flags = gtk_theming_engine_get_state (engine);
1336 if (flags & GTK_STATE_FLAG_PRELIGHT)
1337 state = GTK_STATE_PRELIGHT;
1338 else if (flags & GTK_STATE_FLAG_INSENSITIVE)
1339 state = GTK_STATE_INSENSITIVE;
1341 state = GTK_STATE_NORMAL;
1343 gtk_theming_engine_get (engine, state,
1344 "background-color", &bg_color,
1346 color_shade (bg_color, 0.7, &darker);
1347 color_shade (bg_color, 1.3, &lighter);
1349 cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
1350 cairo_set_line_width (cr, 1);
1352 angle = atan2 (x1 - x0, y1 - y0);
1353 angle = (2 * G_PI) - angle;
1356 cairo_get_matrix (cr, &matrix);
1357 cairo_matrix_translate (&matrix, x0, y0);
1358 cairo_matrix_rotate (&matrix, angle);
1359 cairo_set_matrix (cr, &matrix);
1364 len = (gint) sqrt ((x1 * x1) + (y1 * y1));
1366 y0 = -thickness_dark;
1368 for (i = 0; i < thickness_dark; i++)
1370 gdk_cairo_set_source_color (cr, &lighter);
1371 add_path_line (cr, len - i - 1.5, y0, len - 0.5, y0);
1374 gdk_cairo_set_source_color (cr, &darker);
1375 add_path_line (cr, 0.5, y0, len - i - 1.5, y0);
1381 for (i = 0; i < thickness_light; i++)
1383 gdk_cairo_set_source_color (cr, &darker);
1384 add_path_line (cr, 0.5, y0, thickness_light - i + 0.5, y0);
1387 gdk_cairo_set_source_color (cr, &lighter);
1388 add_path_line (cr, thickness_light - i + 0.5, y0, len - 0.5, y0);
1397 typedef struct _ByteRange ByteRange;
1406 range_new (guint start,
1409 ByteRange *br = g_new (ByteRange, 1);
1418 get_insensitive_layout (PangoLayout *layout)
1420 GSList *embossed_ranges = NULL;
1421 GSList *shaded_ranges = NULL;
1422 PangoLayoutIter *iter;
1423 GSList *tmp_list = NULL;
1424 PangoLayout *new_layout;
1425 PangoAttrList *attrs;
1427 iter = pango_layout_get_iter (layout);
1431 PangoLayoutRun *run;
1432 PangoAttribute *attr;
1433 gboolean need_shade = FALSE;
1436 run = pango_layout_iter_get_run_readonly (iter);
1440 tmp_list = run->item->analysis.extra_attrs;
1442 while (tmp_list != NULL)
1444 attr = tmp_list->data;
1445 switch (attr->klass->type)
1447 case PANGO_ATTR_FOREGROUND:
1448 case PANGO_ATTR_BACKGROUND:
1459 tmp_list = g_slist_next (tmp_list);
1462 br = range_new (run->item->offset, run->item->offset + run->item->length);
1465 shaded_ranges = g_slist_prepend (shaded_ranges, br);
1467 embossed_ranges = g_slist_prepend (embossed_ranges, br);
1470 while (pango_layout_iter_next_run (iter));
1472 pango_layout_iter_free (iter);
1474 new_layout = pango_layout_copy (layout);
1476 attrs = pango_layout_get_attributes (new_layout);
1480 /* Create attr list if there wasn't one */
1481 attrs = pango_attr_list_new ();
1482 pango_layout_set_attributes (new_layout, attrs);
1483 pango_attr_list_unref (attrs);
1486 tmp_list = embossed_ranges;
1487 while (tmp_list != NULL)
1489 PangoAttribute *attr;
1490 ByteRange *br = tmp_list->data;
1492 attr = gdk_pango_attr_embossed_new (TRUE);
1494 attr->start_index = br->start;
1495 attr->end_index = br->end;
1497 pango_attr_list_change (attrs, attr);
1501 tmp_list = g_slist_next (tmp_list);
1504 g_slist_free (embossed_ranges);
1506 tmp_list = shaded_ranges;
1507 while (tmp_list != NULL)
1509 PangoAttribute *attr;
1510 ByteRange *br = tmp_list->data;
1512 attr = gdk_pango_attr_shade_new (0.7);
1514 attr->start_index = br->start;
1515 attr->end_index = br->end;
1517 pango_attr_list_change (attrs, attr);
1521 tmp_list = g_slist_next (tmp_list);
1524 g_slist_free (shaded_ranges);
1530 gtk_theming_engine_render_layout (GtkThemingEngine *engine,
1534 PangoLayout *layout)
1537 GtkStateFlags flags;
1542 flags = gtk_theming_engine_get_state (engine);
1544 /* FIXME: Set clipping */
1546 if (flags & GTK_STATE_FLAG_ACTIVE)
1547 state = GTK_STATE_ACTIVE;
1548 else if (flags & GTK_STATE_FLAG_SELECTED)
1549 state = GTK_STATE_SELECTED;
1550 else if (flags & GTK_STATE_FLAG_PRELIGHT)
1551 state = GTK_STATE_PRELIGHT;
1552 else if (flags & GTK_STATE_FLAG_INSENSITIVE)
1553 state = GTK_STATE_INSENSITIVE;
1555 state = GTK_STATE_NORMAL;
1557 gtk_theming_engine_get (engine, state,
1558 "foreground-color", &fg_color,
1561 screen = gtk_theming_engine_get_screen (engine);
1563 if (state == GTK_STATE_INSENSITIVE)
1565 PangoLayout *insensitive_layout;
1567 insensitive_layout = get_insensitive_layout (layout);
1568 gdk_pango_show_layout (screen,
1572 g_object_unref (insensitive_layout);
1575 gdk_pango_show_layout (screen, cr, x, y, layout,
1580 gdk_color_free (fg_color);
1584 gtk_theming_engine_render_slider (GtkThemingEngine *engine,
1590 GtkOrientation orientation)
1592 const GtkWidgetPath *path;
1595 path = gtk_theming_engine_get_path (engine);
1597 gtk_theming_engine_render_background (engine, cr, x, y, width, height);
1598 gtk_theming_engine_render_frame (engine, cr, x, y, width, height);
1600 /* FIXME: thickness */
1603 if (gtk_widget_path_is_type (path, GTK_TYPE_SCALE))
1605 if (orientation == GTK_ORIENTATION_VERTICAL)
1606 gtk_theming_engine_render_line (engine, cr,
1608 y + (gint) height / 2,
1609 x + width - thickness - 1,
1610 y + (gint) height / 2);
1612 gtk_theming_engine_render_line (engine, cr,
1613 x + (gint) width / 2,
1615 x + (gint) width / 2,
1616 y + height - thickness - 1);
1621 gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine,
1627 GtkPositionType gap_side,
1631 GtkStateFlags flags;
1634 GdkColor lighter, darker;
1638 flags = gtk_theming_engine_get_state (engine);
1640 if (flags & GTK_STATE_FLAG_PRELIGHT)
1641 state = GTK_STATE_PRELIGHT;
1642 else if (flags & GTK_STATE_FLAG_INSENSITIVE)
1643 state = GTK_STATE_INSENSITIVE;
1645 state = GTK_STATE_NORMAL;
1647 cairo_set_line_width (cr, 1);
1649 gtk_theming_engine_get (engine, state,
1650 "background-color", &bg_color,
1652 color_shade (bg_color, 0.7, &darker);
1653 color_shade (bg_color, 1.3, &lighter);
1655 if (gtk_theming_engine_has_class (engine, "frame"))
1657 if (gap_side == GTK_POS_RIGHT)
1658 sides = SIDE_BOTTOM;
1659 else if (gap_side == GTK_POS_BOTTOM)
1662 sides = SIDE_BOTTOM | SIDE_RIGHT;
1664 gdk_cairo_set_source_color (cr, &lighter);
1665 add_path_rectangle_sides (cr, x , y, width , height, sides);
1668 gdk_cairo_set_source_color (cr, &darker);
1669 add_path_rectangle_sides (cr, x, y, width - 1, height - 1, sides);
1672 if (gap_side == GTK_POS_RIGHT ||
1673 gap_side == GTK_POS_BOTTOM)
1675 gdk_cairo_set_source_color (cr, &darker);
1676 add_path_gap_side (cr, gap_side,
1677 x + 1, y + 1, width - 4, height - 4,
1681 gdk_cairo_set_source_color (cr, &lighter);
1682 add_path_gap_side (cr, gap_side,
1683 x, y, width, height,
1688 if (gap_side == GTK_POS_LEFT)
1690 else if (gap_side == GTK_POS_TOP)
1693 sides = SIDE_TOP | SIDE_LEFT;
1695 gdk_cairo_set_source_color (cr, &lighter);
1696 add_path_rectangle_sides (cr, x + 1, y + 1, width - 2, height - 3, sides);
1699 gdk_cairo_set_source_color (cr, &darker);
1700 add_path_rectangle_sides (cr, x, y, width - 1, height - 1, sides);
1703 if (gap_side == GTK_POS_LEFT ||
1704 gap_side == GTK_POS_TOP)
1706 gdk_cairo_set_source_color (cr, &lighter);
1707 add_path_gap_side (cr, gap_side,
1708 x + 1, y + 1, width - 4, height - 4,
1712 gdk_cairo_set_source_color (cr, &darker);
1713 add_path_gap_side (cr, gap_side,
1714 x, y, width - 2, height - 2,
1721 if (gap_side == GTK_POS_RIGHT)
1722 sides = SIDE_BOTTOM;
1723 else if (gap_side == GTK_POS_BOTTOM)
1726 sides = SIDE_BOTTOM | SIDE_RIGHT;
1728 gdk_cairo_set_source_color (cr, &darker);
1729 add_path_rectangle_sides (cr, x + 1, y, width - 2, height, sides);
1730 add_path_rectangle_sides (cr, x, y + 1, width, height - 2, sides);
1733 cairo_set_source_rgb (cr, 0, 0, 0);
1734 add_path_rectangle_sides (cr, x, y, width, height, sides);
1737 if (gap_side == GTK_POS_RIGHT ||
1738 gap_side == GTK_POS_BOTTOM)
1740 gdk_cairo_set_source_color (cr, &darker);
1741 add_path_gap_side (cr, gap_side,
1742 x, y, width - 2, height - 2,
1746 cairo_set_source_rgb (cr, 0, 0, 0);
1747 add_path_gap_side (cr, gap_side,
1748 x, y, width - 1, height - 1,
1753 if (gap_side == GTK_POS_LEFT)
1755 else if (gap_side == GTK_POS_TOP)
1758 sides = SIDE_TOP | SIDE_LEFT;
1760 gdk_cairo_set_source_color (cr, &lighter);
1761 add_path_rectangle_sides (cr, x, y, width, height, sides);
1764 if (gap_side == GTK_POS_LEFT ||
1765 gap_side == GTK_POS_TOP)
1767 add_path_gap_side (cr, gap_side,
1768 x, y, width, height,
1776 gdk_color_free (bg_color);
1780 gtk_theming_engine_render_extension (GtkThemingEngine *engine,
1786 GtkPositionType gap_side)
1788 GtkStateFlags flags;
1791 GdkColor lighter, darker;
1794 flags = gtk_theming_engine_get_state (engine);
1796 if (flags & GTK_STATE_FLAG_ACTIVE)
1797 state = GTK_STATE_ACTIVE;
1798 else if (flags & GTK_STATE_FLAG_PRELIGHT)
1799 state = GTK_STATE_PRELIGHT;
1800 else if (flags & GTK_STATE_FLAG_INSENSITIVE)
1801 state = GTK_STATE_INSENSITIVE;
1803 state = GTK_STATE_NORMAL;
1805 cairo_set_line_width (cr, 1);
1807 gtk_theming_engine_get (engine, state,
1808 "background-color", &bg_color,
1810 color_shade (bg_color, 0.7, &darker);
1811 color_shade (bg_color, 1.3, &lighter);
1816 gdk_cairo_set_source_color (cr, bg_color);
1817 cairo_rectangle (cr, x + 1, y, width - 2, height);
1820 gdk_cairo_set_source_color (cr, &lighter);
1821 add_path_line (cr, x, y, x, y + height - 2);
1824 gdk_cairo_set_source_color (cr, bg_color);
1825 add_path_line (cr, x + 1, y, x + 1, y + height - 2);
1828 gdk_cairo_set_source_color (cr, &darker);
1829 add_path_line (cr, x + 2, y + height - 2, x + width - 2, y + height - 2);
1830 add_path_line (cr, x + width - 2, y, x + width - 2, y + height - 2);
1833 cairo_set_source_rgb (cr, 0, 0, 0);
1834 add_path_line (cr, x + 1, y + height - 1, x + width - 2, y + height - 1);
1835 add_path_line (cr, x + width - 1, y, x + width - 1, y + height - 2);
1839 case GTK_POS_BOTTOM:
1840 gdk_cairo_set_source_color (cr, bg_color);
1841 cairo_rectangle (cr, x + 1, y, width - 2, height);
1844 gdk_cairo_set_source_color (cr, &lighter);
1845 add_path_line (cr, x + 1, y, x + width - 2, y);
1846 add_path_line (cr, x, y + 1, x, y + height - 1);
1849 gdk_cairo_set_source_color (cr, bg_color);
1850 add_path_line (cr, x + 1, y + 1, x + width - 2, y + 1);
1851 add_path_line (cr, x + 1, y + 1, x + 1, y + height - 1);
1854 gdk_cairo_set_source_color (cr, &darker);
1855 add_path_line (cr, x + width - 2, y + 2, x + width - 2, y + height - 1);
1858 cairo_set_source_rgb (cr, 0, 0, 0);
1859 add_path_line (cr, x + width - 1, y + 1, x + width - 1, y + height - 1);
1864 gdk_cairo_set_source_color (cr, bg_color);
1865 cairo_rectangle (cr, x, y + 1, width, height - 2);
1868 gdk_cairo_set_source_color (cr, &lighter);
1869 add_path_line (cr, x, y, x + width - 2, y);
1872 gdk_cairo_set_source_color (cr, bg_color);
1873 add_path_line (cr, x + 1, y + 1, x + width - 2, y + 1);
1876 gdk_cairo_set_source_color (cr, &darker);
1877 add_path_line (cr, x, y + height - 2, x + width - 2, y + height - 2);
1878 add_path_line (cr, x + width - 2, y + 2, x + width - 2, y + height - 2);
1881 cairo_set_source_rgb (cr, 0, 0, 0);
1882 add_path_line (cr, x, y + height - 1, x + width - 2, y + height - 1);
1883 add_path_line (cr, x + width - 1, y + 1, x + width - 1, y + height - 2);
1888 gdk_cairo_set_source_color (cr, bg_color);
1889 cairo_rectangle (cr, x, y + 1, width, height - 2);
1892 gdk_cairo_set_source_color (cr, &lighter);
1893 add_path_line (cr, x + 1, y, x + width - 1, y);
1894 add_path_line (cr, x, y + 1, x, y + height - 2);
1897 gdk_cairo_set_source_color (cr, bg_color);
1898 add_path_line (cr, x + 1, y + 1, x + width - 1, y + 1);
1899 add_path_line (cr, x + 1, y + 1, x + 1, y + height - 2);
1902 gdk_cairo_set_source_color (cr, &darker);
1903 add_path_line (cr, x + 2, y + height - 2, x + width - 1, y + height - 2);
1906 cairo_set_source_rgb (cr, 0, 0, 0);
1907 add_path_line (cr, x + 1, y + height - 1, x + width - 1, y + height - 1);
1915 gdk_color_free (bg_color);
1919 render_dot (cairo_t *cr,
1920 const GdkColor *lighter,
1921 const GdkColor *darker,
1926 size = CLAMP ((gint) size, 2, 3);
1930 gdk_cairo_set_source_color (cr, lighter);
1931 cairo_rectangle (cr, x, y, 1, 1);
1932 cairo_rectangle (cr, x + 1, y + 1, 1, 1);
1937 gdk_cairo_set_source_color (cr, lighter);
1938 cairo_rectangle (cr, x, y, 2, 1);
1939 cairo_rectangle (cr, x, y, 1, 2);
1942 gdk_cairo_set_source_color (cr, darker);
1943 cairo_rectangle (cr, x + 1, y + 1, 2, 1);
1944 cairo_rectangle (cr, x + 2, y, 1, 2);
1950 gtk_theming_engine_render_handle (GtkThemingEngine *engine,
1956 GtkOrientation orientation)
1958 GtkStateFlags flags;
1961 GdkColor lighter, darker;
1965 flags = gtk_theming_engine_get_state (engine);
1967 if (flags & GTK_STATE_FLAG_ACTIVE)
1968 state = GTK_STATE_ACTIVE;
1969 else if (flags & GTK_STATE_FLAG_PRELIGHT)
1970 state = GTK_STATE_PRELIGHT;
1971 else if (flags & GTK_STATE_FLAG_INSENSITIVE)
1972 state = GTK_STATE_INSENSITIVE;
1974 state = GTK_STATE_NORMAL;
1976 cairo_set_line_width (cr, 1);
1978 gtk_theming_engine_get (engine, state,
1979 "background-color", &bg_color,
1981 color_shade (bg_color, 0.7, &darker);
1982 color_shade (bg_color, 1.3, &lighter);
1984 gdk_cairo_set_source_color (cr, bg_color);
1985 cairo_rectangle (cr, x, y, width, height);
1988 if (gtk_theming_engine_has_class (engine, "paned"))
1990 if (orientation == GTK_ORIENTATION_HORIZONTAL)
1991 for (xx = x + width / 2 - 15; xx <= x + width / 2 + 15; xx += 5)
1992 render_dot (cr, &lighter, &darker, xx, y + height / 2 - 1, 3);
1994 for (yy = y + height / 2 - 15; yy <= y + height / 2 + 15; yy += 5)
1995 render_dot (cr, &lighter, &darker, x + width / 2 - 1, yy, 3);
1999 for (yy = y; yy < y + height; yy += 3)
2000 for (xx = x; xx < x + width; xx += 6)
2002 render_dot (cr, &lighter, &darker, xx, yy, 2);
2003 render_dot (cr, &lighter, &darker, xx + 3, yy + 1, 2);
2009 gdk_color_free (bg_color);
2012 #define __GTK_THEMING_ENGINE_C__
2013 #include "gtkaliasdef.c"