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/.
32 #include "gtkwidget.h"
33 #include "gtkthemes.h"
34 #include "gtkiconfactory.h"
36 #define LIGHTNESS_MULT 1.3
37 #define DARKNESS_MULT 0.7
39 /* actually glib should do that for us */
41 #define M_PI 3.14159265358979323846
44 #define M_PI_4 0.78539816339744830962
47 static void gtk_style_realize (GtkStyle *style,
48 GdkColormap *colormap);
50 static void gtk_style_real_realize (GtkStyle *style);
51 static void gtk_style_real_unrealize (GtkStyle *style);
52 static void gtk_style_real_copy (GtkStyle *style,
54 static void gtk_style_real_set_background (GtkStyle *style,
56 GtkStateType state_type);
57 static GtkStyle *gtk_style_real_clone (GtkStyle *style);
58 static void gtk_style_real_init_from_rc (GtkStyle *style,
59 GtkRcStyle *rc_style);
62 static GdkPixbuf *gtk_default_render_icon (GtkStyle *style,
63 const GtkIconSource *source,
64 GtkTextDirection direction,
70 static void gtk_default_draw_hline (GtkStyle *style,
72 GtkStateType state_type,
79 static void gtk_default_draw_vline (GtkStyle *style,
81 GtkStateType state_type,
88 static void gtk_default_draw_shadow (GtkStyle *style,
90 GtkStateType state_type,
91 GtkShadowType shadow_type,
99 static void gtk_default_draw_shadow (GtkStyle *style,
101 GtkStateType state_type,
102 GtkShadowType shadow_type,
110 static void gtk_default_draw_polygon (GtkStyle *style,
112 GtkStateType state_type,
113 GtkShadowType shadow_type,
120 static void gtk_default_draw_arrow (GtkStyle *style,
122 GtkStateType state_type,
123 GtkShadowType shadow_type,
127 GtkArrowType arrow_type,
133 static void gtk_default_draw_diamond (GtkStyle *style,
135 GtkStateType state_type,
136 GtkShadowType shadow_type,
144 static void gtk_default_draw_string (GtkStyle *style,
146 GtkStateType state_type,
152 const gchar *string);
153 static void gtk_default_draw_box (GtkStyle *style,
155 GtkStateType state_type,
156 GtkShadowType shadow_type,
164 static void gtk_default_draw_flat_box (GtkStyle *style,
166 GtkStateType state_type,
167 GtkShadowType shadow_type,
175 static void gtk_default_draw_check (GtkStyle *style,
177 GtkStateType state_type,
178 GtkShadowType shadow_type,
186 static void gtk_default_draw_option (GtkStyle *style,
188 GtkStateType state_type,
189 GtkShadowType shadow_type,
197 static void gtk_default_draw_tab (GtkStyle *style,
199 GtkStateType state_type,
200 GtkShadowType shadow_type,
208 static void gtk_default_draw_shadow_gap (GtkStyle *style,
210 GtkStateType state_type,
211 GtkShadowType shadow_type,
219 GtkPositionType gap_side,
222 static void gtk_default_draw_box_gap (GtkStyle *style,
224 GtkStateType state_type,
225 GtkShadowType shadow_type,
233 GtkPositionType gap_side,
236 static void gtk_default_draw_extension (GtkStyle *style,
238 GtkStateType state_type,
239 GtkShadowType shadow_type,
247 GtkPositionType gap_side);
248 static void gtk_default_draw_focus (GtkStyle *style,
257 static void gtk_default_draw_slider (GtkStyle *style,
259 GtkStateType state_type,
260 GtkShadowType shadow_type,
268 GtkOrientation orientation);
269 static void gtk_default_draw_handle (GtkStyle *style,
271 GtkStateType state_type,
272 GtkShadowType shadow_type,
280 GtkOrientation orientation);
281 static void gtk_default_draw_expander (GtkStyle *style,
283 GtkStateType state_type,
290 static void gtk_default_draw_layout (GtkStyle *style,
292 GtkStateType state_type,
298 PangoLayout *layout);
300 static void gtk_style_shade (GdkColor *a, GdkColor *b, gdouble k);
301 static void rgb_to_hls (gdouble *r, gdouble *g, gdouble *b);
302 static void hls_to_rgb (gdouble *h, gdouble *l, gdouble *s);
304 GdkFont *default_font = NULL;
306 static GdkColor gtk_default_normal_fg = { 0, 0, 0, 0 };
307 static GdkColor gtk_default_active_fg = { 0, 0, 0, 0 };
308 static GdkColor gtk_default_prelight_fg = { 0, 0, 0, 0 };
309 static GdkColor gtk_default_selected_fg = { 0, 0xffff, 0xffff, 0xffff };
310 static GdkColor gtk_default_insensitive_fg = { 0, 0x7530, 0x7530, 0x7530 };
312 static GdkColor gtk_default_normal_bg = { 0, 0xd6d6, 0xd6d6, 0xd6d6 };
313 static GdkColor gtk_default_active_bg = { 0, 0xc350, 0xc350, 0xc350 };
314 static GdkColor gtk_default_prelight_bg = { 0, 0xea60, 0xea60, 0xea60 };
315 static GdkColor gtk_default_selected_bg = { 0, 0, 0, 0x9c40 };
316 static GdkColor gtk_default_insensitive_bg = { 0, 0xd6d6, 0xd6d6, 0xd6d6 };
318 static gpointer parent_class = NULL;
320 static void gtk_style_init (GtkStyle *style);
321 static void gtk_style_class_init (GtkStyleClass *klass);
322 static void gtk_style_finalize (GObject *object);
325 gtk_style_get_type (void)
327 static GType object_type = 0;
331 static const GTypeInfo object_info =
333 sizeof (GtkStyleClass),
334 (GBaseInitFunc) NULL,
335 (GBaseFinalizeFunc) NULL,
336 (GClassInitFunc) gtk_style_class_init,
337 NULL, /* class_finalize */
338 NULL, /* class_data */
341 (GInstanceInitFunc) gtk_style_init,
344 object_type = g_type_register_static (G_TYPE_OBJECT,
353 gtk_style_init (GtkStyle *style)
357 style->font_desc = pango_font_description_from_string ("Sans 10");
361 default_font = gdk_font_from_description (style->font_desc);
364 default_font = gdk_font_load ("fixed");
367 g_error ("Unable to load \"fixed\" font!");
370 style->font = default_font;
371 gdk_font_ref (style->font);
373 style->attach_count = 0;
374 style->colormap = NULL;
377 style->black.red = 0;
378 style->black.green = 0;
379 style->black.blue = 0;
381 style->white.red = 65535;
382 style->white.green = 65535;
383 style->white.blue = 65535;
385 style->black_gc = NULL;
386 style->white_gc = NULL;
388 style->fg[GTK_STATE_NORMAL] = gtk_default_normal_fg;
389 style->fg[GTK_STATE_ACTIVE] = gtk_default_active_fg;
390 style->fg[GTK_STATE_PRELIGHT] = gtk_default_prelight_fg;
391 style->fg[GTK_STATE_SELECTED] = gtk_default_selected_fg;
392 style->fg[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_fg;
394 style->bg[GTK_STATE_NORMAL] = gtk_default_normal_bg;
395 style->bg[GTK_STATE_ACTIVE] = gtk_default_active_bg;
396 style->bg[GTK_STATE_PRELIGHT] = gtk_default_prelight_bg;
397 style->bg[GTK_STATE_SELECTED] = gtk_default_selected_bg;
398 style->bg[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_bg;
400 for (i = 0; i < 4; i++)
402 style->text[i] = style->fg[i];
403 style->base[i] = style->white;
406 style->base[GTK_STATE_INSENSITIVE] = gtk_default_prelight_bg;
407 style->text[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_fg;
409 for (i = 0; i < 5; i++)
410 style->bg_pixmap[i] = NULL;
412 style->rc_style = NULL;
414 for (i = 0; i < 5; i++)
416 style->fg_gc[i] = NULL;
417 style->bg_gc[i] = NULL;
418 style->light_gc[i] = NULL;
419 style->dark_gc[i] = NULL;
420 style->mid_gc[i] = NULL;
421 style->text_gc[i] = NULL;
422 style->base_gc[i] = NULL;
425 style->xthickness = 2;
426 style->ythickness = 2;
430 gtk_style_class_init (GtkStyleClass *klass)
432 GObjectClass *object_class = G_OBJECT_CLASS (klass);
434 parent_class = g_type_class_peek_parent (klass);
436 object_class->finalize = gtk_style_finalize;
438 klass->clone = gtk_style_real_clone;
439 klass->copy = gtk_style_real_copy;
440 klass->init_from_rc = gtk_style_real_init_from_rc;
441 klass->realize = gtk_style_real_realize;
442 klass->unrealize = gtk_style_real_unrealize;
443 klass->set_background = gtk_style_real_set_background;
444 klass->render_icon = gtk_default_render_icon;
446 klass->draw_hline = gtk_default_draw_hline;
447 klass->draw_vline = gtk_default_draw_vline;
448 klass->draw_shadow = gtk_default_draw_shadow;
449 klass->draw_polygon = gtk_default_draw_polygon;
450 klass->draw_arrow = gtk_default_draw_arrow;
451 klass->draw_diamond = gtk_default_draw_diamond;
452 klass->draw_string = gtk_default_draw_string;
453 klass->draw_box = gtk_default_draw_box;
454 klass->draw_flat_box = gtk_default_draw_flat_box;
455 klass->draw_check = gtk_default_draw_check;
456 klass->draw_option = gtk_default_draw_option;
457 klass->draw_tab = gtk_default_draw_tab;
458 klass->draw_shadow_gap = gtk_default_draw_shadow_gap;
459 klass->draw_box_gap = gtk_default_draw_box_gap;
460 klass->draw_extension = gtk_default_draw_extension;
461 klass->draw_focus = gtk_default_draw_focus;
462 klass->draw_slider = gtk_default_draw_slider;
463 klass->draw_handle = gtk_default_draw_handle;
464 klass->draw_expander = gtk_default_draw_expander;
465 klass->draw_layout = gtk_default_draw_layout;
469 gtk_style_finalize (GObject *object)
471 GtkStyle *style = GTK_STYLE (object);
473 g_return_if_fail (style->attach_count == 0);
477 if (style->styles->data != style)
478 g_slist_remove (style->styles, style);
481 GSList *tmp_list = style->styles->next;
485 ((GtkStyle*) tmp_list->data)->styles = style->styles->next;
486 tmp_list = tmp_list->next;
488 g_slist_free_1 (style->styles);
492 gdk_font_unref (style->font);
493 pango_font_description_free (style->font_desc);
496 gtk_rc_style_unref (style->rc_style);
498 G_OBJECT_CLASS (parent_class)->finalize (object);
503 gtk_style_copy (GtkStyle *style)
507 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
509 new_style = GTK_STYLE_GET_CLASS (style)->clone (style);
510 GTK_STYLE_GET_CLASS (style)->copy (new_style, style);
516 gtk_style_duplicate (GtkStyle *style)
520 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
522 new_style = gtk_style_copy (style);
524 style->styles = g_slist_append (style->styles, new_style);
525 new_style->styles = style->styles;
535 style = g_object_new (GTK_TYPE_STYLE, NULL);
540 /*************************************************************
542 * Attach a style to a window; this process allocates the
543 * colors and creates the GC's for the style - it specializes
544 * it to a particular visual and colormap. The process
545 * may involve the creation of a new style if the style
546 * has already been attached to a window with a different
547 * style and colormap.
552 * Either the style parameter, or a newly created style.
553 * If the style is newly created, the style parameter
554 * will be dereferenced, and the new style will have
555 * a reference count belonging to the caller.
557 * FIXME: The sequence -
558 * create a style => s1
559 * attach s1 to v1, c1 => s1
560 * attach s1 to v2, c2 => s2
561 * detach s1 from v1, c1
562 * attach s1 to v2, c2 => s3
563 * results in two separate, unlinked styles s2 and s3 which
564 * are identical and could be shared. To fix this, we would
565 * want to never remove a style from the list of linked
566 * styles as long as as it has a reference count. However, the
567 * disadvantage of doing it this way means that we would need two
568 * passes through the linked list when attaching (one to check for
569 * matching styles, one to look for empty unattached styles - but
570 * it will almost never be longer than 2 elements.
571 *************************************************************/
574 gtk_style_attach (GtkStyle *style,
578 GtkStyle *new_style = NULL;
579 GdkColormap *colormap;
581 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
582 g_return_val_if_fail (window != NULL, NULL);
584 colormap = gdk_window_get_colormap (window);
587 style->styles = g_slist_append (NULL, style);
589 styles = style->styles;
592 new_style = styles->data;
594 if (new_style->attach_count == 0)
596 gtk_style_realize (new_style, colormap);
599 else if (new_style->colormap == colormap)
603 styles = styles->next;
608 new_style = gtk_style_duplicate (style);
609 gtk_style_realize (new_style, colormap);
612 /* A style gets a refcount from being attached */
613 if (new_style->attach_count == 0)
614 gtk_style_ref (new_style);
616 /* Another refcount belongs to the parent */
617 if (style != new_style)
619 gtk_style_unref (style);
620 gtk_style_ref (new_style);
623 new_style->attach_count++;
629 gtk_style_detach (GtkStyle *style)
631 g_return_if_fail (GTK_IS_STYLE (style));
633 style->attach_count -= 1;
634 if (style->attach_count == 0)
636 GTK_STYLE_GET_CLASS (style)->unrealize (style);
638 gdk_colormap_unref (style->colormap);
639 style->colormap = NULL;
641 gtk_style_unref (style);
646 gtk_style_ref (GtkStyle *style)
648 return (GtkStyle *) g_object_ref (G_OBJECT (style));
652 gtk_style_unref (GtkStyle *style)
654 g_object_unref (G_OBJECT (style));
658 gtk_style_realize (GtkStyle *style,
659 GdkColormap *colormap)
661 g_return_if_fail (GTK_IS_STYLE (style));
663 style->colormap = gdk_colormap_ref (colormap);
664 style->depth = gdk_colormap_get_visual (colormap)->depth;
666 GTK_STYLE_GET_CLASS (style)->realize (style);
670 gtk_style_lookup_icon_set (GtkStyle *style,
671 const char *stock_id)
675 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
676 g_return_val_if_fail (stock_id != NULL, NULL);
678 iter = style->icon_factories;
681 GtkIconSet *icon_set =
682 gtk_icon_factory_lookup (GTK_ICON_FACTORY (iter->data),
688 iter = g_slist_next (iter);
691 return gtk_icon_factory_lookup_default (stock_id);
695 gtk_draw_hline (GtkStyle *style,
697 GtkStateType state_type,
702 g_return_if_fail (GTK_IS_STYLE (style));
703 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_hline != NULL);
705 GTK_STYLE_GET_CLASS (style)->draw_hline (style, window, state_type, NULL, NULL, NULL, x1, x2, y);
710 gtk_draw_vline (GtkStyle *style,
712 GtkStateType state_type,
717 g_return_if_fail (GTK_IS_STYLE (style));
718 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_vline != NULL);
720 GTK_STYLE_GET_CLASS (style)->draw_vline (style, window, state_type, NULL, NULL, NULL, y1, y2, x);
725 gtk_draw_shadow (GtkStyle *style,
727 GtkStateType state_type,
728 GtkShadowType shadow_type,
734 g_return_if_fail (GTK_IS_STYLE (style));
735 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow != NULL);
737 GTK_STYLE_GET_CLASS (style)->draw_shadow (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
741 gtk_draw_polygon (GtkStyle *style,
743 GtkStateType state_type,
744 GtkShadowType shadow_type,
749 g_return_if_fail (GTK_IS_STYLE (style));
750 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_polygon != NULL);
752 GTK_STYLE_GET_CLASS (style)->draw_polygon (style, window, state_type, shadow_type, NULL, NULL, NULL, points, npoints, fill);
756 gtk_draw_arrow (GtkStyle *style,
758 GtkStateType state_type,
759 GtkShadowType shadow_type,
760 GtkArrowType arrow_type,
767 g_return_if_fail (GTK_IS_STYLE (style));
768 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_arrow != NULL);
770 GTK_STYLE_GET_CLASS (style)->draw_arrow (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, fill, x, y, width, height);
775 gtk_draw_diamond (GtkStyle *style,
777 GtkStateType state_type,
778 GtkShadowType shadow_type,
784 g_return_if_fail (GTK_IS_STYLE (style));
785 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_diamond != NULL);
787 GTK_STYLE_GET_CLASS (style)->draw_diamond (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
792 gtk_draw_string (GtkStyle *style,
794 GtkStateType state_type,
799 g_return_if_fail (GTK_IS_STYLE (style));
800 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_string != NULL);
802 GTK_STYLE_GET_CLASS (style)->draw_string (style, window, state_type, NULL, NULL, NULL, x, y, string);
806 gtk_draw_box (GtkStyle *style,
808 GtkStateType state_type,
809 GtkShadowType shadow_type,
815 g_return_if_fail (GTK_IS_STYLE (style));
816 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box != NULL);
818 GTK_STYLE_GET_CLASS (style)->draw_box (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
822 gtk_draw_flat_box (GtkStyle *style,
824 GtkStateType state_type,
825 GtkShadowType shadow_type,
831 g_return_if_fail (GTK_IS_STYLE (style));
832 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_flat_box != NULL);
834 GTK_STYLE_GET_CLASS (style)->draw_flat_box (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
838 gtk_draw_check (GtkStyle *style,
840 GtkStateType state_type,
841 GtkShadowType shadow_type,
847 g_return_if_fail (GTK_IS_STYLE (style));
848 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_check != NULL);
850 GTK_STYLE_GET_CLASS (style)->draw_check (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
854 gtk_draw_option (GtkStyle *style,
856 GtkStateType state_type,
857 GtkShadowType shadow_type,
863 g_return_if_fail (GTK_IS_STYLE (style));
864 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_option != NULL);
866 GTK_STYLE_GET_CLASS (style)->draw_option (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
870 gtk_draw_tab (GtkStyle *style,
872 GtkStateType state_type,
873 GtkShadowType shadow_type,
879 g_return_if_fail (GTK_IS_STYLE (style));
880 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_tab != NULL);
882 GTK_STYLE_GET_CLASS (style)->draw_tab (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
886 gtk_draw_shadow_gap (GtkStyle *style,
888 GtkStateType state_type,
889 GtkShadowType shadow_type,
894 GtkPositionType gap_side,
898 g_return_if_fail (GTK_IS_STYLE (style));
899 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow_gap != NULL);
901 GTK_STYLE_GET_CLASS (style)->draw_shadow_gap (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width);
905 gtk_draw_box_gap (GtkStyle *style,
907 GtkStateType state_type,
908 GtkShadowType shadow_type,
913 GtkPositionType gap_side,
917 g_return_if_fail (GTK_IS_STYLE (style));
918 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box_gap != NULL);
920 GTK_STYLE_GET_CLASS (style)->draw_box_gap (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width);
924 gtk_draw_extension (GtkStyle *style,
926 GtkStateType state_type,
927 GtkShadowType shadow_type,
932 GtkPositionType gap_side)
934 g_return_if_fail (GTK_IS_STYLE (style));
935 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_extension != NULL);
937 GTK_STYLE_GET_CLASS (style)->draw_extension (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side);
941 gtk_draw_focus (GtkStyle *style,
948 g_return_if_fail (GTK_IS_STYLE (style));
949 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_focus != NULL);
951 GTK_STYLE_GET_CLASS (style)->draw_focus (style, window, NULL, NULL, NULL, x, y, width, height);
955 gtk_draw_slider (GtkStyle *style,
957 GtkStateType state_type,
958 GtkShadowType shadow_type,
963 GtkOrientation orientation)
965 g_return_if_fail (GTK_IS_STYLE (style));
966 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_slider != NULL);
968 GTK_STYLE_GET_CLASS (style)->draw_slider (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
972 gtk_draw_handle (GtkStyle *style,
974 GtkStateType state_type,
975 GtkShadowType shadow_type,
980 GtkOrientation orientation)
982 g_return_if_fail (GTK_IS_STYLE (style));
983 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_handle != NULL);
985 GTK_STYLE_GET_CLASS (style)->draw_handle (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
989 gtk_draw_expander (GtkStyle *style,
991 GtkStateType state_type,
996 g_return_if_fail (GTK_IS_STYLE (style));
997 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_expander != NULL);
999 GTK_STYLE_GET_CLASS (style)->draw_expander (style, window, state_type,
1005 gtk_draw_layout (GtkStyle *style,
1007 GtkStateType state_type,
1010 PangoLayout *layout)
1012 g_return_if_fail (GTK_IS_STYLE (style));
1013 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_layout != NULL);
1015 GTK_STYLE_GET_CLASS (style)->draw_layout (style, window, state_type,
1021 gtk_style_set_background (GtkStyle *style,
1023 GtkStateType state_type)
1025 g_return_if_fail (GTK_IS_STYLE (style));
1026 g_return_if_fail (window != NULL);
1028 GTK_STYLE_GET_CLASS (style)->set_background (style, window, state_type);
1031 /* Default functions */
1033 gtk_style_real_clone (GtkStyle *style)
1035 return GTK_STYLE (g_object_new (G_OBJECT_TYPE (style), NULL));
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 style->bg_pixmap[i] = src->bg_pixmap[i];
1055 gdk_font_unref (style->font);
1056 style->font = src->font;
1058 gdk_font_ref (style->font);
1060 if (style->font_desc)
1061 pango_font_description_free (style->font_desc);
1063 style->font_desc = pango_font_description_copy (src->font_desc);
1065 style->font_desc = NULL;
1067 style->xthickness = src->xthickness;
1068 style->ythickness = src->ythickness;
1070 if (style->rc_style)
1071 gtk_rc_style_unref (style->rc_style);
1072 style->rc_style = src->rc_style;
1074 gtk_rc_style_ref (src->rc_style);
1078 gtk_style_real_init_from_rc (GtkStyle *style,
1079 GtkRcStyle *rc_style)
1084 if (rc_style->font_desc)
1086 pango_font_description_free (style->font_desc);
1087 style->font_desc = pango_font_description_copy (rc_style->font_desc);
1089 old_font = style->font;
1090 style->font = gdk_font_from_description (style->font_desc);
1092 gdk_font_unref (old_font);
1094 style->font = old_font;
1097 for (i = 0; i < 5; i++)
1099 if (rc_style->color_flags[i] & GTK_RC_FG)
1100 style->fg[i] = rc_style->fg[i];
1101 if (rc_style->color_flags[i] & GTK_RC_BG)
1102 style->bg[i] = rc_style->bg[i];
1103 if (rc_style->color_flags[i] & GTK_RC_TEXT)
1104 style->text[i] = rc_style->text[i];
1105 if (rc_style->color_flags[i] & GTK_RC_BASE)
1106 style->base[i] = rc_style->base[i];
1109 if (rc_style->xthickness >= 0)
1110 style->xthickness = rc_style->xthickness;
1111 if (rc_style->ythickness >= 0)
1112 style->ythickness = rc_style->ythickness;
1115 if (rc_style->icon_factories)
1119 style->icon_factories = g_slist_copy (rc_style->icon_factories);
1121 iter = style->icon_factories;
1122 while (iter != NULL)
1124 g_object_ref (G_OBJECT (iter->data));
1126 iter = g_slist_next (iter);
1132 gtk_style_real_realize (GtkStyle *style)
1134 GdkGCValues gc_values;
1135 GdkGCValuesMask gc_values_mask;
1139 for (i = 0; i < 5; i++)
1141 gtk_style_shade (&style->bg[i], &style->light[i], LIGHTNESS_MULT);
1142 gtk_style_shade (&style->bg[i], &style->dark[i], DARKNESS_MULT);
1144 style->mid[i].red = (style->light[i].red + style->dark[i].red) / 2;
1145 style->mid[i].green = (style->light[i].green + style->dark[i].green) / 2;
1146 style->mid[i].blue = (style->light[i].blue + style->dark[i].blue) / 2;
1149 gdk_color_black (style->colormap, &style->black);
1150 gdk_color_white (style->colormap, &style->white);
1152 gc_values_mask = GDK_GC_FOREGROUND | GDK_GC_FONT;
1153 if (style->font->type == GDK_FONT_FONT)
1155 gc_values.font = style->font;
1157 else if (style->font->type == GDK_FONT_FONTSET)
1159 gc_values.font = default_font;
1162 gc_values.foreground = style->black;
1163 style->black_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1165 gc_values.foreground = style->white;
1166 style->white_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1168 for (i = 0; i < 5; i++)
1170 if (style->rc_style && style->rc_style->bg_pixmap_name[i])
1171 style->bg_pixmap[i] = gtk_rc_load_image (style->colormap,
1173 style->rc_style->bg_pixmap_name[i]);
1175 if (!gdk_color_alloc (style->colormap, &style->fg[i]))
1176 g_warning ("unable to allocate color: ( %d %d %d )",
1177 style->fg[i].red, style->fg[i].green, style->fg[i].blue);
1178 if (!gdk_color_alloc (style->colormap, &style->bg[i]))
1179 g_warning ("unable to allocate color: ( %d %d %d )",
1180 style->bg[i].red, style->bg[i].green, style->bg[i].blue);
1181 if (!gdk_color_alloc (style->colormap, &style->light[i]))
1182 g_warning ("unable to allocate color: ( %d %d %d )",
1183 style->light[i].red, style->light[i].green, style->light[i].blue);
1184 if (!gdk_color_alloc (style->colormap, &style->dark[i]))
1185 g_warning ("unable to allocate color: ( %d %d %d )",
1186 style->dark[i].red, style->dark[i].green, style->dark[i].blue);
1187 if (!gdk_color_alloc (style->colormap, &style->mid[i]))
1188 g_warning ("unable to allocate color: ( %d %d %d )",
1189 style->mid[i].red, style->mid[i].green, style->mid[i].blue);
1190 if (!gdk_color_alloc (style->colormap, &style->text[i]))
1191 g_warning ("unable to allocate color: ( %d %d %d )",
1192 style->text[i].red, style->text[i].green, style->text[i].blue);
1193 if (!gdk_color_alloc (style->colormap, &style->base[i]))
1194 g_warning ("unable to allocate color: ( %d %d %d )",
1195 style->base[i].red, style->base[i].green, style->base[i].blue);
1197 gc_values.foreground = style->fg[i];
1198 style->fg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1200 gc_values.foreground = style->bg[i];
1201 style->bg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1203 gc_values.foreground = style->light[i];
1204 style->light_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1206 gc_values.foreground = style->dark[i];
1207 style->dark_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1209 gc_values.foreground = style->mid[i];
1210 style->mid_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1212 gc_values.foreground = style->text[i];
1213 style->text_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1215 gc_values.foreground = style->base[i];
1216 style->base_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1221 gtk_style_real_unrealize (GtkStyle *style)
1225 gtk_gc_release (style->black_gc);
1226 gtk_gc_release (style->white_gc);
1228 for (i = 0; i < 5; i++)
1230 gtk_gc_release (style->fg_gc[i]);
1231 gtk_gc_release (style->bg_gc[i]);
1232 gtk_gc_release (style->light_gc[i]);
1233 gtk_gc_release (style->dark_gc[i]);
1234 gtk_gc_release (style->mid_gc[i]);
1235 gtk_gc_release (style->text_gc[i]);
1236 gtk_gc_release (style->base_gc[i]);
1238 if (style->bg_pixmap[i] && style->bg_pixmap[i] != (GdkPixmap*) GDK_PARENT_RELATIVE)
1239 gdk_pixmap_unref (style->bg_pixmap[i]);
1242 gdk_colormap_free_colors (style->colormap, style->fg, 5);
1243 gdk_colormap_free_colors (style->colormap, style->bg, 5);
1244 gdk_colormap_free_colors (style->colormap, style->light, 5);
1245 gdk_colormap_free_colors (style->colormap, style->dark, 5);
1246 gdk_colormap_free_colors (style->colormap, style->mid, 5);
1247 gdk_colormap_free_colors (style->colormap, style->text, 5);
1248 gdk_colormap_free_colors (style->colormap, style->base, 5);
1252 gtk_style_real_set_background (GtkStyle *style,
1254 GtkStateType state_type)
1257 gint parent_relative;
1259 if (style->bg_pixmap[state_type])
1261 if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
1264 parent_relative = TRUE;
1268 pixmap = style->bg_pixmap[state_type];
1269 parent_relative = FALSE;
1272 gdk_window_set_back_pixmap (window, pixmap, parent_relative);
1275 gdk_window_set_background (window, &style->bg[state_type]);
1279 gtk_style_render_icon (GtkStyle *style,
1280 const GtkIconSource *source,
1281 GtkTextDirection direction,
1285 const gchar *detail)
1289 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
1290 g_return_val_if_fail (GTK_STYLE_GET_CLASS (style)->render_icon != NULL, NULL);
1292 pixbuf = GTK_STYLE_GET_CLASS (style)->render_icon (style, source, direction, state,
1293 size, widget, detail);
1295 g_return_val_if_fail (pixbuf != NULL, NULL);
1300 /* Default functions */
1302 gtk_style_apply_default_background (GtkStyle *style,
1305 GtkStateType state_type,
1312 GdkRectangle new_rect, old_rect;
1318 old_rect.width = width;
1319 old_rect.height = height;
1321 if (!gdk_rectangle_intersect (area, &old_rect, &new_rect))
1328 new_rect.width = width;
1329 new_rect.height = height;
1332 if (!style->bg_pixmap[state_type] ||
1333 GDK_IS_PIXMAP (window) ||
1334 (!set_bg && style->bg_pixmap[state_type] != (GdkPixmap*) GDK_PARENT_RELATIVE))
1336 GdkGC *gc = style->bg_gc[state_type];
1338 if (style->bg_pixmap[state_type])
1340 gdk_gc_set_fill (gc, GDK_TILED);
1341 gdk_gc_set_tile (gc, style->bg_pixmap[state_type]);
1344 gdk_draw_rectangle (window, gc, TRUE,
1345 new_rect.x, new_rect.y, new_rect.width, new_rect.height);
1346 if (style->bg_pixmap[state_type])
1347 gdk_gc_set_fill (gc, GDK_SOLID);
1353 if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
1354 gdk_window_set_back_pixmap (window, NULL, TRUE);
1356 gdk_window_set_back_pixmap (window, style->bg_pixmap[state_type], FALSE);
1359 gdk_window_clear_area (window,
1360 new_rect.x, new_rect.y,
1361 new_rect.width, new_rect.height);
1366 scale_or_ref (GdkPixbuf *src,
1370 if (width == gdk_pixbuf_get_width (src) &&
1371 height == gdk_pixbuf_get_height (src))
1373 gdk_pixbuf_ref (src);
1378 return gdk_pixbuf_scale_simple (src,
1380 GDK_INTERP_BILINEAR);
1385 gtk_default_render_icon (GtkStyle *style,
1386 const GtkIconSource *source,
1387 GtkTextDirection direction,
1391 const gchar *detail)
1398 /* Oddly, style can be NULL in this function, because
1399 * GtkIconSet can be used without a style and if so
1400 * it uses this function.
1403 g_return_val_if_fail (source->pixbuf != NULL, NULL);
1405 if (!gtk_icon_size_lookup (size, &width, &height))
1407 g_warning ("Bad icon size '%s' passed to render_icon", size);
1411 /* If the size was wildcarded, then scale; otherwise, leave it
1414 if (source->any_size)
1415 scaled = scale_or_ref (source->pixbuf, width, height);
1417 scaled = GDK_PIXBUF (g_object_ref (G_OBJECT (source->pixbuf)));
1419 /* If the state was wildcarded, then generate a state. */
1420 if (source->any_state)
1422 if (state == GTK_STATE_INSENSITIVE)
1424 stated = gdk_pixbuf_copy (scaled);
1426 gdk_pixbuf_saturate_and_pixelate (scaled, stated,
1429 gdk_pixbuf_unref (scaled);
1431 else if (state == GTK_STATE_PRELIGHT)
1433 stated = gdk_pixbuf_copy (scaled);
1435 gdk_pixbuf_saturate_and_pixelate (scaled, stated,
1438 gdk_pixbuf_unref (scaled);
1452 gtk_default_draw_hline (GtkStyle *style,
1454 GtkStateType state_type,
1457 const gchar *detail,
1462 gint thickness_light;
1463 gint thickness_dark;
1466 g_return_if_fail (GTK_IS_STYLE (style));
1467 g_return_if_fail (window != NULL);
1469 thickness_light = style->ythickness / 2;
1470 thickness_dark = style->ythickness - thickness_light;
1474 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1475 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1478 if (detail && !strcmp (detail, "label"))
1480 if (state_type == GTK_STATE_INSENSITIVE)
1481 gdk_draw_line (window, style->white_gc, x1 + 1, y + 1, x2 + 1, y + 1);
1482 gdk_draw_line (window, style->fg_gc[state_type], x1, y, x2, y);
1486 for (i = 0; i < thickness_dark; i++)
1488 gdk_draw_line (window, style->light_gc[state_type], x2 - i - 1, y + i, x2, y + i);
1489 gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x2 - i - 1, y + i);
1492 y += thickness_dark;
1493 for (i = 0; i < thickness_light; i++)
1495 gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x1 + thickness_light - i - 1, y + i);
1496 gdk_draw_line (window, style->light_gc[state_type], x1 + thickness_light - i - 1, y + i, x2, y + i);
1502 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
1503 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
1509 gtk_default_draw_vline (GtkStyle *style,
1511 GtkStateType state_type,
1514 const gchar *detail,
1519 gint thickness_light;
1520 gint thickness_dark;
1523 g_return_if_fail (GTK_IS_STYLE (style));
1524 g_return_if_fail (window != NULL);
1526 thickness_light = style->xthickness / 2;
1527 thickness_dark = style->xthickness - thickness_light;
1531 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1532 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1534 for (i = 0; i < thickness_dark; i++)
1536 gdk_draw_line (window, style->light_gc[state_type], x + i, y2 - i - 1, x + i, y2);
1537 gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y2 - i - 1);
1540 x += thickness_dark;
1541 for (i = 0; i < thickness_light; i++)
1543 gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y1 + thickness_light - i);
1544 gdk_draw_line (window, style->light_gc[state_type], x + i, y1 + thickness_light - i, x + i, y2);
1548 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
1549 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
1555 gtk_default_draw_shadow (GtkStyle *style,
1557 GtkStateType state_type,
1558 GtkShadowType shadow_type,
1561 const gchar *detail,
1569 gint thickness_light;
1570 gint thickness_dark;
1573 g_return_if_fail (GTK_IS_STYLE (style));
1574 g_return_if_fail (window != NULL);
1576 if ((width == -1) && (height == -1))
1577 gdk_window_get_size (window, &width, &height);
1578 else if (width == -1)
1579 gdk_window_get_size (window, &width, NULL);
1580 else if (height == -1)
1581 gdk_window_get_size (window, NULL, &height);
1583 switch (shadow_type)
1585 case GTK_SHADOW_NONE:
1588 case GTK_SHADOW_ETCHED_IN:
1589 gc1 = style->light_gc[state_type];
1590 gc2 = style->dark_gc[state_type];
1592 case GTK_SHADOW_OUT:
1593 case GTK_SHADOW_ETCHED_OUT:
1594 gc1 = style->dark_gc[state_type];
1595 gc2 = style->light_gc[state_type];
1601 gdk_gc_set_clip_rectangle (gc1, area);
1602 gdk_gc_set_clip_rectangle (gc2, area);
1603 if (shadow_type == GTK_SHADOW_IN ||
1604 shadow_type == GTK_SHADOW_OUT)
1606 gdk_gc_set_clip_rectangle (style->black_gc, area);
1607 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
1611 switch (shadow_type)
1613 case GTK_SHADOW_NONE:
1617 gdk_draw_line (window, gc1,
1618 x, y + height - 1, x + width - 1, y + height - 1);
1619 gdk_draw_line (window, gc1,
1620 x + width - 1, y, x + width - 1, y + height - 1);
1622 gdk_draw_line (window, style->bg_gc[state_type],
1623 x + 1, y + height - 2, x + width - 2, y + height - 2);
1624 gdk_draw_line (window, style->bg_gc[state_type],
1625 x + width - 2, y + 1, x + width - 2, y + height - 2);
1627 gdk_draw_line (window, style->black_gc,
1628 x + 1, y + 1, x + width - 2, y + 1);
1629 gdk_draw_line (window, style->black_gc,
1630 x + 1, y + 1, x + 1, y + height - 2);
1632 gdk_draw_line (window, gc2,
1633 x, y, x + width - 1, y);
1634 gdk_draw_line (window, gc2,
1635 x, y, x, y + height - 1);
1638 case GTK_SHADOW_OUT:
1639 gdk_draw_line (window, gc1,
1640 x + 1, y + height - 2, x + width - 2, y + height - 2);
1641 gdk_draw_line (window, gc1,
1642 x + width - 2, y + 1, x + width - 2, y + height - 2);
1644 gdk_draw_line (window, gc2,
1645 x, y, x + width - 1, y);
1646 gdk_draw_line (window, gc2,
1647 x, y, x, y + height - 1);
1649 gdk_draw_line (window, style->bg_gc[state_type],
1650 x + 1, y + 1, x + width - 2, y + 1);
1651 gdk_draw_line (window, style->bg_gc[state_type],
1652 x + 1, y + 1, x + 1, y + height - 2);
1654 gdk_draw_line (window, style->black_gc,
1655 x, y + height - 1, x + width - 1, y + height - 1);
1656 gdk_draw_line (window, style->black_gc,
1657 x + width - 1, y, x + width - 1, y + height - 1);
1660 case GTK_SHADOW_ETCHED_IN:
1661 case GTK_SHADOW_ETCHED_OUT:
1662 thickness_light = 1;
1665 for (i = 0; i < thickness_dark; i++)
1667 gdk_draw_line (window, gc1,
1671 y + height - i - 1);
1672 gdk_draw_line (window, gc1,
1676 y + height - i - 1);
1678 gdk_draw_line (window, gc2,
1683 gdk_draw_line (window, gc2,
1687 y + height - i - 2);
1690 for (i = 0; i < thickness_light; i++)
1692 gdk_draw_line (window, gc1,
1693 x + thickness_dark + i,
1694 y + thickness_dark + i,
1695 x + width - thickness_dark - i - 1,
1696 y + thickness_dark + i);
1697 gdk_draw_line (window, gc1,
1698 x + thickness_dark + i,
1699 y + thickness_dark + i,
1700 x + thickness_dark + i,
1701 y + height - thickness_dark - i - 1);
1703 gdk_draw_line (window, gc2,
1704 x + thickness_dark + i,
1705 y + height - thickness_light - i - 1,
1706 x + width - thickness_light - 1,
1707 y + height - thickness_light - i - 1);
1708 gdk_draw_line (window, gc2,
1709 x + width - thickness_light - i - 1,
1710 y + thickness_dark + i,
1711 x + width - thickness_light - i - 1,
1712 y + height - thickness_light - 1);
1718 gdk_gc_set_clip_rectangle (gc1, NULL);
1719 gdk_gc_set_clip_rectangle (gc2, NULL);
1720 if (shadow_type == GTK_SHADOW_IN ||
1721 shadow_type == GTK_SHADOW_OUT)
1723 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
1724 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
1730 gtk_default_draw_polygon (GtkStyle *style,
1732 GtkStateType state_type,
1733 GtkShadowType shadow_type,
1736 const gchar *detail,
1741 static const gdouble pi_over_4 = M_PI_4;
1742 static const gdouble pi_3_over_4 = M_PI_4 * 3;
1752 g_return_if_fail (GTK_IS_STYLE (style));
1753 g_return_if_fail (window != NULL);
1754 g_return_if_fail (points != NULL);
1756 switch (shadow_type)
1759 gc1 = style->bg_gc[state_type];
1760 gc2 = style->dark_gc[state_type];
1761 gc3 = style->light_gc[state_type];
1762 gc4 = style->black_gc;
1764 case GTK_SHADOW_ETCHED_IN:
1765 gc1 = style->light_gc[state_type];
1766 gc2 = style->dark_gc[state_type];
1767 gc3 = style->dark_gc[state_type];
1768 gc4 = style->light_gc[state_type];
1770 case GTK_SHADOW_OUT:
1771 gc1 = style->dark_gc[state_type];
1772 gc2 = style->light_gc[state_type];
1773 gc3 = style->black_gc;
1774 gc4 = style->bg_gc[state_type];
1776 case GTK_SHADOW_ETCHED_OUT:
1777 gc1 = style->dark_gc[state_type];
1778 gc2 = style->light_gc[state_type];
1779 gc3 = style->light_gc[state_type];
1780 gc4 = style->dark_gc[state_type];
1788 gdk_gc_set_clip_rectangle (gc1, area);
1789 gdk_gc_set_clip_rectangle (gc2, area);
1790 gdk_gc_set_clip_rectangle (gc3, area);
1791 gdk_gc_set_clip_rectangle (gc4, area);
1795 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, npoints);
1799 for (i = 0; i < npoints; i++)
1801 if ((points[i].x == points[i+1].x) &&
1802 (points[i].y == points[i+1].y))
1808 angle = atan2 (points[i+1].y - points[i].y,
1809 points[i+1].x - points[i].x);
1812 if ((angle > -pi_3_over_4) && (angle < pi_over_4))
1814 if (angle > -pi_over_4)
1825 gdk_draw_line (window, gc1,
1826 points[i].x-xadjust, points[i].y-yadjust,
1827 points[i+1].x-xadjust, points[i+1].y-yadjust);
1828 gdk_draw_line (window, gc3,
1829 points[i].x, points[i].y,
1830 points[i+1].x, points[i+1].y);
1834 if ((angle < -pi_3_over_4) || (angle > pi_3_over_4))
1845 gdk_draw_line (window, gc4,
1846 points[i].x+xadjust, points[i].y+yadjust,
1847 points[i+1].x+xadjust, points[i+1].y+yadjust);
1848 gdk_draw_line (window, gc2,
1849 points[i].x, points[i].y,
1850 points[i+1].x, points[i+1].y);
1856 gdk_gc_set_clip_rectangle (gc1, NULL);
1857 gdk_gc_set_clip_rectangle (gc2, NULL);
1858 gdk_gc_set_clip_rectangle (gc3, NULL);
1859 gdk_gc_set_clip_rectangle (gc4, NULL);
1864 gtk_default_draw_arrow (GtkStyle *style,
1866 GtkStateType state_type,
1867 GtkShadowType shadow_type,
1870 const gchar *detail,
1871 GtkArrowType arrow_type,
1886 g_return_if_fail (GTK_IS_STYLE (style));
1887 g_return_if_fail (window != NULL);
1889 switch (shadow_type)
1892 gc1 = style->bg_gc[state_type];
1893 gc2 = style->dark_gc[state_type];
1894 gc3 = style->light_gc[state_type];
1895 gc4 = style->black_gc;
1897 case GTK_SHADOW_OUT:
1898 gc1 = style->dark_gc[state_type];
1899 gc2 = style->light_gc[state_type];
1900 gc3 = style->black_gc;
1901 gc4 = style->bg_gc[state_type];
1903 case GTK_SHADOW_ETCHED_IN:
1904 gc1 = style->light_gc[state_type];
1905 gc2 = style->dark_gc[state_type];
1909 case GTK_SHADOW_ETCHED_OUT:
1910 gc1 = style->dark_gc[state_type];
1911 gc2 = style->light_gc[state_type];
1919 if ((width == -1) && (height == -1))
1920 gdk_window_get_size (window, &width, &height);
1921 else if (width == -1)
1922 gdk_window_get_size (window, &width, NULL);
1923 else if (height == -1)
1924 gdk_window_get_size (window, NULL, &height);
1926 half_width = width / 2;
1927 half_height = height / 2;
1931 gdk_gc_set_clip_rectangle (gc1, area);
1932 gdk_gc_set_clip_rectangle (gc2, area);
1935 gdk_gc_set_clip_rectangle (gc3, area);
1936 gdk_gc_set_clip_rectangle (gc4, area);
1945 points[0].x = x + half_width;
1948 points[1].y = y + height - 1;
1949 points[2].x = x + width - 1;
1950 points[2].y = y + height - 1;
1952 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1955 switch (shadow_type)
1958 case GTK_SHADOW_OUT:
1960 gdk_draw_line (window, gc1,
1961 x + 1, y + height - 2,
1962 x + width - 2, y + height - 2);
1963 gdk_draw_line (window, gc3,
1964 x + 0, y + height - 1,
1965 x + width - 1, y + height - 1);
1967 gdk_draw_line (window, gc1,
1968 x + width - 2, y + height - 1,
1969 x + half_width, y + 1);
1970 gdk_draw_line (window, gc3,
1971 x + width - 1, y + height - 1,
1974 gdk_draw_line (window, gc4,
1975 x + half_width, y + 1,
1976 x + 1, y + height - 1);
1977 gdk_draw_line (window, gc2,
1982 case GTK_SHADOW_ETCHED_IN:
1983 case GTK_SHADOW_ETCHED_OUT:
1984 gdk_draw_line (window, gc1,
1985 x + half_width, y + 1,
1986 x + 1, y + height - 1);
1987 gdk_draw_line (window, gc1,
1988 x + 1, y + height - 1,
1989 x + width - 1, y + height - 1);
1990 gdk_draw_line (window, gc1,
1991 x + width - 1, y + height - 1,
1992 x + half_width + 1, y + 1);
1994 points[0].x = x + half_width;
1997 points[1].y = y + height - 2;
1998 points[2].x = x + width - 2;
1999 points[2].y = y + height - 2;
2001 gdk_draw_polygon (window, gc2, FALSE, points, 3);
2009 case GTK_ARROW_DOWN:
2012 points[0].x = x + width - 1;
2016 points[2].x = x + half_width;
2017 points[2].y = y + height - 1;
2019 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
2021 switch (shadow_type)
2024 case GTK_SHADOW_OUT:
2025 gdk_draw_line (window, gc4,
2027 y + 1, x + 1, y + 1);
2028 gdk_draw_line (window, gc2,
2032 gdk_draw_line (window, gc4,
2034 x + half_width, y + height - 2);
2035 gdk_draw_line (window, gc2,
2037 x + half_width, y + height - 1);
2039 gdk_draw_line (window, gc1,
2040 x + half_width, y + height - 2,
2042 gdk_draw_line (window, gc3,
2043 x + half_width, y + height - 1,
2047 case GTK_SHADOW_ETCHED_IN:
2048 case GTK_SHADOW_ETCHED_OUT:
2049 gdk_draw_line (window, gc1,
2050 x + width - 1, y + 1,
2052 gdk_draw_line (window, gc1,
2054 x + half_width + 1, y + height - 1);
2055 gdk_draw_line (window, gc1,
2056 x + half_width + 1, y + height - 2,
2059 points[0].x = x + width - 2;
2063 points[2].x = x + half_width;
2064 points[2].y = y + height - 2;
2066 gdk_draw_polygon (window, gc2, FALSE, points, 3);
2073 case GTK_ARROW_LEFT:
2077 points[0].y = y + half_height;
2078 points[1].x = x + width - 1;
2079 points[1].y = y + height - 1;
2080 points[2].x = x + width - 1;
2083 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
2086 switch (shadow_type)
2089 case GTK_SHADOW_OUT:
2090 gdk_draw_line (window, gc1,
2091 x + 1, y + half_height,
2092 x + width - 1, y + height - 1);
2093 gdk_draw_line (window, gc3,
2095 x + width - 1, y + height - 1);
2097 gdk_draw_line (window, gc1,
2098 x + width - 2, y + height - 1,
2099 x + width - 2, y + 1);
2100 gdk_draw_line (window, gc3,
2101 x + width - 1, y + height - 1,
2104 gdk_draw_line (window, gc4,
2105 x + width - 1, y + 1,
2106 x + 1, y + half_height);
2107 gdk_draw_line (window, gc2,
2109 x, y + half_height);
2112 case GTK_SHADOW_ETCHED_IN:
2113 case GTK_SHADOW_ETCHED_OUT:
2114 gdk_draw_line (window, gc1,
2115 x + width - 1, y + 1,
2116 x + 1, y + half_height);
2117 gdk_draw_line (window, gc1,
2118 x + 1, y + half_height + 1,
2119 x + width - 1, y + height - 1);
2120 gdk_draw_line (window, gc1,
2121 x + width - 1, y + height - 1,
2122 x + width - 1, y + 1);
2124 points[0].x = x + width - 2;
2127 points[1].y = y + half_height;
2128 points[2].x = x + width - 2;
2129 points[2].y = y + height - 2;
2131 gdk_draw_polygon (window, gc2, FALSE, points, 3);
2138 case GTK_ARROW_RIGHT:
2141 points[0].x = x + width - 1;
2142 points[0].y = y + half_height;
2146 points[2].y = y + height - 1;
2148 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
2151 switch (shadow_type)
2154 case GTK_SHADOW_OUT:
2155 gdk_draw_line (window, gc4,
2156 x + width - 1, y + half_height,
2158 gdk_draw_line (window, gc2,
2159 x + width - 1, y + half_height,
2161 gdk_draw_line (window, gc4,
2163 x + 1, y + height - 2);
2164 gdk_draw_line (window, gc2,
2168 gdk_draw_line (window, gc1,
2169 x + 1, y + height - 2,
2170 x + width - 1, y + half_height);
2171 gdk_draw_line (window, gc3,
2173 x + width - 1, y + half_height);
2176 case GTK_SHADOW_ETCHED_IN:
2177 case GTK_SHADOW_ETCHED_OUT:
2178 gdk_draw_line (window, gc1,
2179 x + width - 1, y + half_height + 1,
2181 gdk_draw_line (window, gc1,
2183 x + 1, y + height - 1);
2184 gdk_draw_line (window, gc1,
2185 x + 1, y + height - 1,
2186 x + width - 1, y + half_height + 1);
2188 points[0].x = x + width - 2;
2189 points[0].y = y + half_height;
2193 points[2].y = y + height - 1;
2195 gdk_draw_polygon (window, gc2, FALSE, points, 3);
2206 gdk_gc_set_clip_rectangle (gc1, NULL);
2207 gdk_gc_set_clip_rectangle (gc2, NULL);
2210 gdk_gc_set_clip_rectangle (gc3, NULL);
2211 gdk_gc_set_clip_rectangle (gc4, NULL);
2217 gtk_default_draw_diamond (GtkStyle *style,
2219 GtkStateType state_type,
2220 GtkShadowType shadow_type,
2223 const gchar *detail,
2232 g_return_if_fail (GTK_IS_STYLE (style));
2233 g_return_if_fail (window != NULL);
2235 if ((width == -1) && (height == -1))
2236 gdk_window_get_size (window, &width, &height);
2237 else if (width == -1)
2238 gdk_window_get_size (window, &width, NULL);
2239 else if (height == -1)
2240 gdk_window_get_size (window, NULL, &height);
2242 half_width = width / 2;
2243 half_height = height / 2;
2247 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
2248 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
2249 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
2250 gdk_gc_set_clip_rectangle (style->black_gc, area);
2252 switch (shadow_type)
2255 gdk_draw_line (window, style->bg_gc[state_type],
2256 x + 2, y + half_height,
2257 x + half_width, y + height - 2);
2258 gdk_draw_line (window, style->bg_gc[state_type],
2259 x + half_width, y + height - 2,
2260 x + width - 2, y + half_height);
2261 gdk_draw_line (window, style->light_gc[state_type],
2262 x + 1, y + half_height,
2263 x + half_width, y + height - 1);
2264 gdk_draw_line (window, style->light_gc[state_type],
2265 x + half_width, y + height - 1,
2266 x + width - 1, y + half_height);
2267 gdk_draw_line (window, style->light_gc[state_type],
2269 x + half_width, y + height);
2270 gdk_draw_line (window, style->light_gc[state_type],
2271 x + half_width, y + height,
2272 x + width, y + half_height);
2274 gdk_draw_line (window, style->black_gc,
2275 x + 2, y + half_height,
2276 x + half_width, y + 2);
2277 gdk_draw_line (window, style->black_gc,
2278 x + half_width, y + 2,
2279 x + width - 2, y + half_height);
2280 gdk_draw_line (window, style->dark_gc[state_type],
2281 x + 1, y + half_height,
2282 x + half_width, y + 1);
2283 gdk_draw_line (window, style->dark_gc[state_type],
2284 x + half_width, y + 1,
2285 x + width - 1, y + half_height);
2286 gdk_draw_line (window, style->dark_gc[state_type],
2289 gdk_draw_line (window, style->dark_gc[state_type],
2291 x + width, y + half_height);
2293 case GTK_SHADOW_OUT:
2294 gdk_draw_line (window, style->dark_gc[state_type],
2295 x + 2, y + half_height,
2296 x + half_width, y + height - 2);
2297 gdk_draw_line (window, style->dark_gc[state_type],
2298 x + half_width, y + height - 2,
2299 x + width - 2, y + half_height);
2300 gdk_draw_line (window, style->dark_gc[state_type],
2301 x + 1, y + half_height,
2302 x + half_width, y + height - 1);
2303 gdk_draw_line (window, style->dark_gc[state_type],
2304 x + half_width, y + height - 1,
2305 x + width - 1, y + half_height);
2306 gdk_draw_line (window, style->black_gc,
2308 x + half_width, y + height);
2309 gdk_draw_line (window, style->black_gc,
2310 x + half_width, y + height,
2311 x + width, y + half_height);
2313 gdk_draw_line (window, style->bg_gc[state_type],
2314 x + 2, y + half_height,
2315 x + half_width, y + 2);
2316 gdk_draw_line (window, style->bg_gc[state_type],
2317 x + half_width, y + 2,
2318 x + width - 2, y + half_height);
2319 gdk_draw_line (window, style->light_gc[state_type],
2320 x + 1, y + half_height,
2321 x + half_width, y + 1);
2322 gdk_draw_line (window, style->light_gc[state_type],
2323 x + half_width, y + 1,
2324 x + width - 1, y + half_height);
2325 gdk_draw_line (window, style->light_gc[state_type],
2328 gdk_draw_line (window, style->light_gc[state_type],
2330 x + width, y + half_height);
2337 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
2338 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2339 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
2340 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2345 gtk_default_draw_string (GtkStyle *style,
2347 GtkStateType state_type,
2350 const gchar *detail,
2353 const gchar *string)
2355 g_return_if_fail (GTK_IS_STYLE (style));
2356 g_return_if_fail (window != NULL);
2360 gdk_gc_set_clip_rectangle (style->white_gc, area);
2361 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], area);
2364 if (state_type == GTK_STATE_INSENSITIVE)
2365 gdk_draw_string (window, style->font, style->white_gc, x + 1, y + 1, string);
2367 gdk_draw_string (window, style->font, style->fg_gc[state_type], x, y, string);
2371 gdk_gc_set_clip_rectangle (style->white_gc, NULL);
2372 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], NULL);
2377 gtk_default_draw_box (GtkStyle *style,
2379 GtkStateType state_type,
2380 GtkShadowType shadow_type,
2383 const gchar *detail,
2389 g_return_if_fail (GTK_IS_STYLE (style));
2390 g_return_if_fail (window != NULL);
2392 if (width == -1 && height == -1)
2393 gdk_window_get_size (window, &width, &height);
2394 else if (width == -1)
2395 gdk_window_get_size (window, &width, NULL);
2396 else if (height == -1)
2397 gdk_window_get_size (window, NULL, &height);
2399 if (!style->bg_pixmap[state_type] ||
2400 GDK_IS_PIXMAP (window))
2403 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
2405 gdk_draw_rectangle (window, style->bg_gc[state_type], TRUE,
2406 x, y, width, height);
2408 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2411 gtk_style_apply_default_background (style, window,
2412 widget && !GTK_WIDGET_NO_WINDOW (widget),
2413 state_type, area, x, y, width, height);
2415 gtk_paint_shadow (style, window, state_type, shadow_type, area, widget, detail,
2416 x, y, width, height);
2420 gtk_default_draw_flat_box (GtkStyle *style,
2422 GtkStateType state_type,
2423 GtkShadowType shadow_type,
2426 const gchar *detail,
2434 g_return_if_fail (GTK_IS_STYLE (style));
2435 g_return_if_fail (window != NULL);
2437 if (width == -1 && height == -1)
2438 gdk_window_get_size (window, &width, &height);
2439 else if (width == -1)
2440 gdk_window_get_size (window, &width, NULL);
2441 else if (height == -1)
2442 gdk_window_get_size (window, NULL, &height);
2446 if (!strcmp ("text", detail) && state_type == GTK_STATE_SELECTED)
2447 gc1 = style->bg_gc[GTK_STATE_SELECTED];
2448 else if (!strcmp ("viewportbin", detail))
2449 gc1 = style->bg_gc[GTK_STATE_NORMAL];
2450 else if (!strcmp ("entry_bg", detail))
2451 gc1 = style->base_gc[state_type];
2453 gc1 = style->bg_gc[state_type];
2456 gc1 = style->bg_gc[state_type];
2458 if (!style->bg_pixmap[state_type] || gc1 != style->bg_gc[state_type] ||
2459 GDK_IS_PIXMAP (window))
2462 gdk_gc_set_clip_rectangle (gc1, area);
2464 gdk_draw_rectangle (window, gc1, TRUE,
2465 x, y, width, height);
2467 if (detail && !strcmp ("tooltip", detail))
2468 gdk_draw_rectangle (window, style->black_gc, FALSE,
2469 x, y, width - 1, height - 1);
2472 gdk_gc_set_clip_rectangle (gc1, NULL);
2475 gtk_style_apply_default_background (style, window,
2476 widget && !GTK_WIDGET_NO_WINDOW (widget),
2477 state_type, area, x, y, width, height);
2481 gtk_default_draw_check (GtkStyle *style,
2483 GtkStateType state_type,
2484 GtkShadowType shadow_type,
2487 const gchar *detail,
2493 if (detail && strcmp (detail, "cellcheck") == 0)
2495 gdk_draw_rectangle (window,
2496 widget->style->fg_gc[state_type],
2501 if (shadow_type == GTK_SHADOW_IN)
2503 gdk_draw_line (window,
2504 widget->style->fg_gc[state_type],
2508 gdk_draw_line (window,
2509 widget->style->fg_gc[state_type],
2518 gtk_paint_box (style, window, state_type, shadow_type, area, widget, detail,
2519 x, y, width, height);
2524 gtk_default_draw_option (GtkStyle *style,
2526 GtkStateType state_type,
2527 GtkShadowType shadow_type,
2530 const gchar *detail,
2536 if (detail && strcmp (detail, "cellradio") == 0)
2538 gdk_draw_arc (window,
2539 widget->style->fg_gc[state_type],
2546 if (shadow_type == GTK_SHADOW_IN)
2548 gdk_draw_arc (window,
2549 widget->style->fg_gc[state_type],
2560 gtk_paint_diamond (style, window, state_type, shadow_type, area, widget,
2561 detail, x, y, width, height);
2566 gtk_default_draw_tab (GtkStyle *style,
2568 GtkStateType state_type,
2569 GtkShadowType shadow_type,
2572 const gchar *detail,
2578 g_return_if_fail (GTK_IS_STYLE (style));
2579 g_return_if_fail (window != NULL);
2581 gtk_paint_box (style, window, state_type, shadow_type, area, widget, detail,
2582 x, y, width, height);
2586 gtk_default_draw_shadow_gap (GtkStyle *style,
2588 GtkStateType state_type,
2589 GtkShadowType shadow_type,
2592 const gchar *detail,
2597 GtkPositionType gap_side,
2606 g_return_if_fail (GTK_IS_STYLE (style));
2607 g_return_if_fail (window != NULL);
2609 if (width == -1 && height == -1)
2610 gdk_window_get_size (window, &width, &height);
2611 else if (width == -1)
2612 gdk_window_get_size (window, &width, NULL);
2613 else if (height == -1)
2614 gdk_window_get_size (window, NULL, &height);
2616 switch (shadow_type)
2618 case GTK_SHADOW_NONE:
2621 gc1 = style->dark_gc[state_type];
2622 gc2 = style->black_gc;
2623 gc3 = style->bg_gc[state_type];
2624 gc4 = style->light_gc[state_type];
2626 case GTK_SHADOW_ETCHED_IN:
2627 gc1 = style->dark_gc[state_type];
2628 gc2 = style->light_gc[state_type];
2629 gc3 = style->dark_gc[state_type];
2630 gc4 = style->light_gc[state_type];
2632 case GTK_SHADOW_OUT:
2633 gc1 = style->light_gc[state_type];
2634 gc2 = style->bg_gc[state_type];
2635 gc3 = style->dark_gc[state_type];
2636 gc4 = style->black_gc;
2638 case GTK_SHADOW_ETCHED_OUT:
2639 gc1 = style->light_gc[state_type];
2640 gc2 = style->dark_gc[state_type];
2641 gc3 = style->light_gc[state_type];
2642 gc4 = style->dark_gc[state_type];
2647 gdk_gc_set_clip_rectangle (gc1, area);
2648 gdk_gc_set_clip_rectangle (gc2, area);
2649 gdk_gc_set_clip_rectangle (gc3, area);
2650 gdk_gc_set_clip_rectangle (gc4, area);
2653 switch (shadow_type)
2655 case GTK_SHADOW_NONE:
2657 case GTK_SHADOW_OUT:
2658 case GTK_SHADOW_ETCHED_IN:
2659 case GTK_SHADOW_ETCHED_OUT:
2663 gdk_draw_line (window, gc1,
2664 x, y, x, y + height - 1);
2665 gdk_draw_line (window, gc2,
2666 x + 1, y, x + 1, y + height - 2);
2668 gdk_draw_line (window, gc3,
2669 x + 1, y + height - 2, x + width - 2, y + height - 2);
2670 gdk_draw_line (window, gc3,
2671 x + width - 2, y, x + width - 2, y + height - 2);
2672 gdk_draw_line (window, gc4,
2673 x, y + height - 1, x + width - 1, y + height - 1);
2674 gdk_draw_line (window, gc4,
2675 x + width - 1, y, x + width - 1, y + height - 1);
2678 gdk_draw_line (window, gc1,
2679 x, y, x + gap_x - 1, y);
2680 gdk_draw_line (window, gc2,
2681 x + 1, y + 1, x + gap_x - 1, y + 1);
2682 gdk_draw_line (window, gc2,
2683 x + gap_x, y, x + gap_x, y);
2685 if ((width - (gap_x + gap_width)) > 0)
2687 gdk_draw_line (window, gc1,
2688 x + gap_x + gap_width, y, x + width - 2, y);
2689 gdk_draw_line (window, gc2,
2690 x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
2691 gdk_draw_line (window, gc2,
2692 x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
2695 case GTK_POS_BOTTOM:
2696 gdk_draw_line (window, gc1,
2697 x, y, x + width - 1, y);
2698 gdk_draw_line (window, gc1,
2699 x, y, x, y + height - 1);
2700 gdk_draw_line (window, gc2,
2701 x + 1, y + 1, x + width - 2, y + 1);
2702 gdk_draw_line (window, gc2,
2703 x + 1, y + 1, x + 1, y + height - 1);
2705 gdk_draw_line (window, gc3,
2706 x + width - 2, y + 1, x + width - 2, y + height - 1);
2707 gdk_draw_line (window, gc4,
2708 x + width - 1, y, x + width - 1, y + height - 1);
2711 gdk_draw_line (window, gc4,
2712 x, y + height - 1, x + gap_x - 1, y + height - 1);
2713 gdk_draw_line (window, gc3,
2714 x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
2715 gdk_draw_line (window, gc3,
2716 x + gap_x, y + height - 1, x + gap_x, y + height - 1);
2718 if ((width - (gap_x + gap_width)) > 0)
2720 gdk_draw_line (window, gc4,
2721 x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
2722 gdk_draw_line (window, gc3,
2723 x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
2724 gdk_draw_line (window, gc3,
2725 x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
2729 gdk_draw_line (window, gc1,
2730 x, y, x + width - 1, y);
2731 gdk_draw_line (window, gc2,
2732 x, y + 1, x + width - 2, y + 1);
2734 gdk_draw_line (window, gc3,
2735 x, y + height - 2, x + width - 2, y + height - 2);
2736 gdk_draw_line (window, gc3,
2737 x + width - 2, y + 1, x + width - 2, y + height - 2);
2738 gdk_draw_line (window, gc4,
2739 x, y + height - 1, x + width - 1, y + height - 1);
2740 gdk_draw_line (window, gc4,
2741 x + width - 1, y, x + width - 1, y + height - 1);
2744 gdk_draw_line (window, gc1,
2745 x, y, x, y + gap_x - 1);
2746 gdk_draw_line (window, gc2,
2747 x + 1, y + 1, x + 1, y + gap_x - 1);
2748 gdk_draw_line (window, gc2,
2749 x, y + gap_x, x, y + gap_x);
2751 if ((width - (gap_x + gap_width)) > 0)
2753 gdk_draw_line (window, gc1,
2754 x, y + gap_x + gap_width, x, y + height - 2);
2755 gdk_draw_line (window, gc2,
2756 x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
2757 gdk_draw_line (window, gc2,
2758 x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
2762 gdk_draw_line (window, gc1,
2763 x, y, x + width - 1, y);
2764 gdk_draw_line (window, gc1,
2765 x, y, x, y + height - 1);
2766 gdk_draw_line (window, gc2,
2767 x + 1, y + 1, x + width - 1, y + 1);
2768 gdk_draw_line (window, gc2,
2769 x + 1, y + 1, x + 1, y + height - 2);
2771 gdk_draw_line (window, gc3,
2772 x + 1, y + height - 2, x + width - 1, y + height - 2);
2773 gdk_draw_line (window, gc4,
2774 x, y + height - 1, x + width - 1, y + height - 1);
2777 gdk_draw_line (window, gc4,
2778 x + width - 1, y, x + width - 1, y + gap_x - 1);
2779 gdk_draw_line (window, gc3,
2780 x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
2781 gdk_draw_line (window, gc3,
2782 x + width - 1, y + gap_x, x + width - 1, y + gap_x);
2784 if ((width - (gap_x + gap_width)) > 0)
2786 gdk_draw_line (window, gc4,
2787 x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
2788 gdk_draw_line (window, gc3,
2789 x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
2790 gdk_draw_line (window, gc3,
2791 x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
2799 gdk_gc_set_clip_rectangle (gc1, NULL);
2800 gdk_gc_set_clip_rectangle (gc2, NULL);
2801 gdk_gc_set_clip_rectangle (gc3, NULL);
2802 gdk_gc_set_clip_rectangle (gc4, NULL);
2807 gtk_default_draw_box_gap (GtkStyle *style,
2809 GtkStateType state_type,
2810 GtkShadowType shadow_type,
2813 const gchar *detail,
2818 GtkPositionType gap_side,
2827 g_return_if_fail (GTK_IS_STYLE (style));
2828 g_return_if_fail (window != NULL);
2830 gtk_style_apply_default_background (style, window,
2831 widget && !GTK_WIDGET_NO_WINDOW (widget),
2832 state_type, area, x, y, width, height);
2834 if (width == -1 && height == -1)
2835 gdk_window_get_size (window, &width, &height);
2836 else if (width == -1)
2837 gdk_window_get_size (window, &width, NULL);
2838 else if (height == -1)
2839 gdk_window_get_size (window, NULL, &height);
2841 switch (shadow_type)
2843 case GTK_SHADOW_NONE:
2846 gc1 = style->dark_gc[state_type];
2847 gc2 = style->black_gc;
2848 gc3 = style->bg_gc[state_type];
2849 gc4 = style->light_gc[state_type];
2851 case GTK_SHADOW_ETCHED_IN:
2852 gc1 = style->dark_gc[state_type];
2853 gc2 = style->light_gc[state_type];
2854 gc3 = style->dark_gc[state_type];
2855 gc4 = style->light_gc[state_type];
2857 case GTK_SHADOW_OUT:
2858 gc1 = style->light_gc[state_type];
2859 gc2 = style->bg_gc[state_type];
2860 gc3 = style->dark_gc[state_type];
2861 gc4 = style->black_gc;
2863 case GTK_SHADOW_ETCHED_OUT:
2864 gc1 = style->light_gc[state_type];
2865 gc2 = style->dark_gc[state_type];
2866 gc3 = style->light_gc[state_type];
2867 gc4 = style->dark_gc[state_type];
2873 gdk_gc_set_clip_rectangle (gc1, area);
2874 gdk_gc_set_clip_rectangle (gc2, area);
2875 gdk_gc_set_clip_rectangle (gc3, area);
2876 gdk_gc_set_clip_rectangle (gc4, area);
2879 switch (shadow_type)
2881 case GTK_SHADOW_NONE:
2883 case GTK_SHADOW_OUT:
2884 case GTK_SHADOW_ETCHED_IN:
2885 case GTK_SHADOW_ETCHED_OUT:
2889 gdk_draw_line (window, gc1,
2890 x, y, x, y + height - 1);
2891 gdk_draw_line (window, gc2,
2892 x + 1, y, x + 1, y + height - 2);
2894 gdk_draw_line (window, gc3,
2895 x + 1, y + height - 2, x + width - 2, y + height - 2);
2896 gdk_draw_line (window, gc3,
2897 x + width - 2, y, x + width - 2, y + height - 2);
2898 gdk_draw_line (window, gc4,
2899 x, y + height - 1, x + width - 1, y + height - 1);
2900 gdk_draw_line (window, gc4,
2901 x + width - 1, y, x + width - 1, y + height - 1);
2904 gdk_draw_line (window, gc1,
2905 x, y, x + gap_x - 1, y);
2906 gdk_draw_line (window, gc2,
2907 x + 1, y + 1, x + gap_x - 1, y + 1);
2908 gdk_draw_line (window, gc2,
2909 x + gap_x, y, x + gap_x, y);
2911 if ((width - (gap_x + gap_width)) > 0)
2913 gdk_draw_line (window, gc1,
2914 x + gap_x + gap_width, y, x + width - 2, y);
2915 gdk_draw_line (window, gc2,
2916 x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
2917 gdk_draw_line (window, gc2,
2918 x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
2921 case GTK_POS_BOTTOM:
2922 gdk_draw_line (window, gc1,
2923 x, y, x + width - 1, y);
2924 gdk_draw_line (window, gc1,
2925 x, y, x, y + height - 1);
2926 gdk_draw_line (window, gc2,
2927 x + 1, y + 1, x + width - 2, y + 1);
2928 gdk_draw_line (window, gc2,
2929 x + 1, y + 1, x + 1, y + height - 1);
2931 gdk_draw_line (window, gc3,
2932 x + width - 2, y + 1, x + width - 2, y + height - 1);
2933 gdk_draw_line (window, gc4,
2934 x + width - 1, y, x + width - 1, y + height - 1);
2937 gdk_draw_line (window, gc4,
2938 x, y + height - 1, x + gap_x - 1, y + height - 1);
2939 gdk_draw_line (window, gc3,
2940 x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
2941 gdk_draw_line (window, gc3,
2942 x + gap_x, y + height - 1, x + gap_x, y + height - 1);
2944 if ((width - (gap_x + gap_width)) > 0)
2946 gdk_draw_line (window, gc4,
2947 x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
2948 gdk_draw_line (window, gc3,
2949 x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
2950 gdk_draw_line (window, gc3,
2951 x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
2955 gdk_draw_line (window, gc1,
2956 x, y, x + width - 1, y);
2957 gdk_draw_line (window, gc2,
2958 x, y + 1, x + width - 2, y + 1);
2960 gdk_draw_line (window, gc3,
2961 x, y + height - 2, x + width - 2, y + height - 2);
2962 gdk_draw_line (window, gc3,
2963 x + width - 2, y + 1, x + width - 2, y + height - 2);
2964 gdk_draw_line (window, gc4,
2965 x, y + height - 1, x + width - 1, y + height - 1);
2966 gdk_draw_line (window, gc4,
2967 x + width - 1, y, x + width - 1, y + height - 1);
2970 gdk_draw_line (window, gc1,
2971 x, y, x, y + gap_x - 1);
2972 gdk_draw_line (window, gc2,
2973 x + 1, y + 1, x + 1, y + gap_x - 1);
2974 gdk_draw_line (window, gc2,
2975 x, y + gap_x, x, y + gap_x);
2977 if ((width - (gap_x + gap_width)) > 0)
2979 gdk_draw_line (window, gc1,
2980 x, y + gap_x + gap_width, x, y + height - 2);
2981 gdk_draw_line (window, gc2,
2982 x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
2983 gdk_draw_line (window, gc2,
2984 x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
2988 gdk_draw_line (window, gc1,
2989 x, y, x + width - 1, y);
2990 gdk_draw_line (window, gc1,
2991 x, y, x, y + height - 1);
2992 gdk_draw_line (window, gc2,
2993 x + 1, y + 1, x + width - 1, y + 1);
2994 gdk_draw_line (window, gc2,
2995 x + 1, y + 1, x + 1, y + height - 2);
2997 gdk_draw_line (window, gc3,
2998 x + 1, y + height - 2, x + width - 1, y + height - 2);
2999 gdk_draw_line (window, gc4,
3000 x, y + height - 1, x + width - 1, y + height - 1);
3003 gdk_draw_line (window, gc4,
3004 x + width - 1, y, x + width - 1, y + gap_x - 1);
3005 gdk_draw_line (window, gc3,
3006 x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
3007 gdk_draw_line (window, gc3,
3008 x + width - 1, y + gap_x, x + width - 1, y + gap_x);
3010 if ((width - (gap_x + gap_width)) > 0)
3012 gdk_draw_line (window, gc4,
3013 x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
3014 gdk_draw_line (window, gc3,
3015 x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
3016 gdk_draw_line (window, gc3,
3017 x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
3025 gdk_gc_set_clip_rectangle (gc1, NULL);
3026 gdk_gc_set_clip_rectangle (gc2, NULL);
3027 gdk_gc_set_clip_rectangle (gc3, NULL);
3028 gdk_gc_set_clip_rectangle (gc4, NULL);
3033 gtk_default_draw_extension (GtkStyle *style,
3035 GtkStateType state_type,
3036 GtkShadowType shadow_type,
3039 const gchar *detail,
3044 GtkPositionType gap_side)
3051 g_return_if_fail (GTK_IS_STYLE (style));
3052 g_return_if_fail (window != NULL);
3054 gtk_style_apply_default_background (style, window,
3055 widget && !GTK_WIDGET_NO_WINDOW (widget),
3056 GTK_STATE_NORMAL, area, x, y, width, height);
3058 if (width == -1 && height == -1)
3059 gdk_window_get_size (window, &width, &height);
3060 else if (width == -1)
3061 gdk_window_get_size (window, &width, NULL);
3062 else if (height == -1)
3063 gdk_window_get_size (window, NULL, &height);
3065 switch (shadow_type)
3067 case GTK_SHADOW_NONE:
3070 gc1 = style->dark_gc[state_type];
3071 gc2 = style->black_gc;
3072 gc3 = style->bg_gc[state_type];
3073 gc4 = style->light_gc[state_type];
3075 case GTK_SHADOW_ETCHED_IN:
3076 gc1 = style->dark_gc[state_type];
3077 gc2 = style->light_gc[state_type];
3078 gc3 = style->dark_gc[state_type];
3079 gc4 = style->light_gc[state_type];
3081 case GTK_SHADOW_OUT:
3082 gc1 = style->light_gc[state_type];
3083 gc2 = style->bg_gc[state_type];
3084 gc3 = style->dark_gc[state_type];
3085 gc4 = style->black_gc;
3087 case GTK_SHADOW_ETCHED_OUT:
3088 gc1 = style->light_gc[state_type];
3089 gc2 = style->dark_gc[state_type];
3090 gc3 = style->light_gc[state_type];
3091 gc4 = style->dark_gc[state_type];
3097 gdk_gc_set_clip_rectangle (gc1, area);
3098 gdk_gc_set_clip_rectangle (gc2, area);
3099 gdk_gc_set_clip_rectangle (gc3, area);
3100 gdk_gc_set_clip_rectangle (gc4, area);
3103 switch (shadow_type)
3105 case GTK_SHADOW_NONE:
3107 case GTK_SHADOW_OUT:
3108 case GTK_SHADOW_ETCHED_IN:
3109 case GTK_SHADOW_ETCHED_OUT:
3113 gtk_style_apply_default_background (style, window,
3114 widget && !GTK_WIDGET_NO_WINDOW (widget),
3116 x + style->xthickness,
3118 width - (2 * style->xthickness),
3119 height - (style->ythickness));
3120 gdk_draw_line (window, gc1,
3121 x, y, x, y + height - 2);
3122 gdk_draw_line (window, gc2,
3123 x + 1, y, x + 1, y + height - 2);
3125 gdk_draw_line (window, gc3,
3126 x + 2, y + height - 2, x + width - 2, y + height - 2);
3127 gdk_draw_line (window, gc3,
3128 x + width - 2, y, x + width - 2, y + height - 2);
3129 gdk_draw_line (window, gc4,
3130 x + 1, y + height - 1, x + width - 2, y + height - 1);
3131 gdk_draw_line (window, gc4,
3132 x + width - 1, y, x + width - 1, y + height - 2);
3134 case GTK_POS_BOTTOM:
3135 gtk_style_apply_default_background (style, window,
3136 widget && !GTK_WIDGET_NO_WINDOW (widget),
3138 x + style->xthickness,
3139 y + style->ythickness,
3140 width - (2 * style->xthickness),
3141 height - (style->ythickness));
3142 gdk_draw_line (window, gc1,
3143 x + 1, y, x + width - 2, y);
3144 gdk_draw_line (window, gc1,
3145 x, y + 1, x, y + height - 1);
3146 gdk_draw_line (window, gc2,
3147 x + 1, y + 1, x + width - 2, y + 1);
3148 gdk_draw_line (window, gc2,
3149 x + 1, y + 1, x + 1, y + height - 1);
3151 gdk_draw_line (window, gc3,
3152 x + width - 2, y + 2, x + width - 2, y + height - 1);
3153 gdk_draw_line (window, gc4,
3154 x + width - 1, y + 1, x + width - 1, y + height - 1);
3157 gtk_style_apply_default_background (style, window,
3158 widget && !GTK_WIDGET_NO_WINDOW (widget),
3161 y + style->ythickness,
3162 width - (style->xthickness),
3163 height - (2 * style->ythickness));
3164 gdk_draw_line (window, gc1,
3165 x, y, x + width - 2, y);
3166 gdk_draw_line (window, gc2,
3167 x + 1, y + 1, x + width - 2, y + 1);
3169 gdk_draw_line (window, gc3,
3170 x, y + height - 2, x + width - 2, y + height - 2);
3171 gdk_draw_line (window, gc3,
3172 x + width - 2, y + 2, x + width - 2, y + height - 2);
3173 gdk_draw_line (window, gc4,
3174 x, y + height - 1, x + width - 2, y + height - 1);
3175 gdk_draw_line (window, gc4,
3176 x + width - 1, y + 1, x + width - 1, y + height - 2);
3179 gtk_style_apply_default_background (style, window,
3180 widget && !GTK_WIDGET_NO_WINDOW (widget),
3182 x + style->xthickness,
3183 y + style->ythickness,
3184 width - (style->xthickness),
3185 height - (2 * style->ythickness));
3186 gdk_draw_line (window, gc1,
3187 x + 1, y, x + width - 1, y);
3188 gdk_draw_line (window, gc1,
3189 x, y + 1, x, y + height - 2);
3190 gdk_draw_line (window, gc2,
3191 x + 1, y + 1, x + width - 1, y + 1);
3192 gdk_draw_line (window, gc2,
3193 x + 1, y + 1, x + 1, y + height - 2);
3195 gdk_draw_line (window, gc3,
3196 x + 2, y + height - 2, x + width - 1, y + height - 2);
3197 gdk_draw_line (window, gc4,
3198 x + 1, y + height - 1, x + width - 1, y + height - 1);
3205 gdk_gc_set_clip_rectangle (gc1, NULL);
3206 gdk_gc_set_clip_rectangle (gc2, NULL);
3207 gdk_gc_set_clip_rectangle (gc3, NULL);
3208 gdk_gc_set_clip_rectangle (gc4, NULL);
3213 gtk_default_draw_focus (GtkStyle *style,
3217 const gchar *detail,
3223 g_return_if_fail (GTK_IS_STYLE (style));
3224 g_return_if_fail (window != NULL);
3226 if (width == -1 && height == -1)
3228 gdk_window_get_size (window, &width, &height);
3232 else if (width == -1)
3234 gdk_window_get_size (window, &width, NULL);
3237 else if (height == -1)
3239 gdk_window_get_size (window, NULL, &height);
3244 gdk_gc_set_clip_rectangle (style->black_gc, area);
3246 if (detail && !strcmp (detail, "add-mode"))
3248 gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_ON_OFF_DASH, 0, 0);
3249 gdk_gc_set_dashes (style->black_gc, 0, "\4\4", 2);
3251 gdk_draw_rectangle (window,
3252 style->black_gc, FALSE,
3253 x, y, width, height);
3255 gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_SOLID, 0, 0);
3259 gdk_draw_rectangle (window,
3260 style->black_gc, FALSE,
3261 x, y, width, height);
3265 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
3269 gtk_default_draw_slider (GtkStyle *style,
3271 GtkStateType state_type,
3272 GtkShadowType shadow_type,
3275 const gchar *detail,
3280 GtkOrientation orientation)
3282 g_return_if_fail (GTK_IS_STYLE (style));
3283 g_return_if_fail (window != NULL);
3285 if (width == -1 && height == -1)
3286 gdk_window_get_size (window, &width, &height);
3287 else if (width == -1)
3288 gdk_window_get_size (window, &width, NULL);
3289 else if (height == -1)
3290 gdk_window_get_size (window, NULL, &height);
3292 gtk_paint_box (style, window, state_type, shadow_type,
3293 area, widget, detail, x, y, width, height);
3295 if (orientation == GTK_ORIENTATION_HORIZONTAL)
3296 gtk_paint_vline (style, window, state_type, area, widget, detail,
3298 height - style->ythickness - 1, width / 2);
3300 gtk_paint_hline (style, window, state_type, area, widget, detail,
3302 width - style->xthickness - 1, height / 2);
3306 draw_dot (GdkWindow *window,
3314 size = CLAMP (size, 2, 3);
3318 gdk_draw_point (window, light_gc, x, y);
3319 gdk_draw_point (window, light_gc, x+1, y+1);
3321 else if (size == 3);
3323 gdk_draw_point (window, light_gc, x, y);
3324 gdk_draw_point (window, light_gc, x+1, y);
3325 gdk_draw_point (window, light_gc, x, y+1);
3326 gdk_draw_point (window, dark_gc, x+1, y+2);
3327 gdk_draw_point (window, dark_gc, x+2, y+1);
3328 gdk_draw_point (window, dark_gc, x+2, y+2);
3333 gtk_default_draw_handle (GtkStyle *style,
3335 GtkStateType state_type,
3336 GtkShadowType shadow_type,
3339 const gchar *detail,
3344 GtkOrientation orientation)
3347 gint xthick, ythick;
3348 GdkGC *light_gc, *dark_gc;
3353 g_return_if_fail (GTK_IS_STYLE (style));
3354 g_return_if_fail (window != NULL);
3356 if (width == -1 && height == -1)
3357 gdk_window_get_size (window, &width, &height);
3358 else if (width == -1)
3359 gdk_window_get_size (window, &width, NULL);
3360 else if (height == -1)
3361 gdk_window_get_size (window, NULL, &height);
3363 gtk_paint_box (style, window, state_type, shadow_type, area, widget,
3364 detail, x, y, width, height);
3367 if (!strcmp (detail, "paned"))
3369 /* we want to ignore the shadow border in paned widgets */
3373 light_gc = style->light_gc[state_type];
3374 dark_gc = style->black_gc;
3378 xthick = style->xthickness;
3379 ythick = style->ythickness;
3381 light_gc = style->light_gc[state_type];
3382 dark_gc = style->dark_gc[state_type];
3385 rect.x = x + xthick;
3386 rect.y = y + ythick;
3387 rect.width = width - (xthick * 2);
3388 rect.height = height - (ythick * 2);
3391 intersect = gdk_rectangle_intersect (area, &rect, &dest);
3401 gdk_gc_set_clip_rectangle (light_gc, &dest);
3402 gdk_gc_set_clip_rectangle (dark_gc, &dest);
3404 if (!strcmp (detail, "paned"))
3409 gdk_window_get_size (window, &window_width, &window_height);
3411 if (orientation == GTK_ORIENTATION_HORIZONTAL)
3412 for (xx = window_width/2 - 15; xx <= window_width/2 + 15; xx += 5)
3413 draw_dot (window, light_gc, dark_gc, xx, window_height/2 - 1, 3);
3415 for (yy = window_height/2 - 15; yy <= window_height/2 + 15; yy += 5)
3416 draw_dot (window, light_gc, dark_gc, window_width/2 - 1, yy, 3);
3420 for (yy = y + ythick; yy < (y + height - ythick); yy += 3)
3421 for (xx = x + xthick; xx < (x + width - xthick); xx += 6)
3423 draw_dot (window, light_gc, dark_gc, xx, yy, 2);
3424 draw_dot (window, light_gc, dark_gc, xx + 3, yy + 1, 2);
3428 gdk_gc_set_clip_rectangle (light_gc, NULL);
3429 gdk_gc_set_clip_rectangle (dark_gc, NULL);
3433 gtk_default_draw_expander (GtkStyle *style,
3435 GtkStateType state_type,
3438 const gchar *detail,
3443 /* FIXME replace macro with a style property */
3450 gdk_gc_set_clip_rectangle (style->fg_gc[GTK_STATE_NORMAL], area);
3451 gdk_gc_set_clip_rectangle (style->base_gc[GTK_STATE_NORMAL], area);
3457 points[0].y = y + (PM_SIZE + 2) / 6;
3458 points[1].x = points[0].x + 1 * (PM_SIZE + 2);
3459 points[1].y = points[0].y;
3460 points[2].x = (points[0].x + 1 * (PM_SIZE + 2) / 2);
3461 points[2].y = y + 2 * (PM_SIZE + 2) / 3;
3465 points[0].x = x + 1 * ((PM_SIZE + 2) / 6 + 2);
3466 points[0].y = y - 1;
3467 points[1].x = points[0].x;
3468 points[1].y = points[0].y + (PM_SIZE + 2);
3469 points[2].x = (points[0].x + 1 * (2 * (PM_SIZE + 2) / 3 - 1));
3470 points[2].y = points[0].y + (PM_SIZE + 2) / 2;
3473 gdk_draw_polygon (window, style->base_gc[GTK_STATE_NORMAL],
3475 gdk_draw_polygon (window, style->fg_gc[GTK_STATE_NORMAL],
3481 gdk_gc_set_clip_rectangle (style->fg_gc[GTK_STATE_NORMAL], NULL);
3482 gdk_gc_set_clip_rectangle (style->base_gc[GTK_STATE_NORMAL], NULL);
3488 typedef struct _ByteRange ByteRange;
3497 range_new (guint start,
3500 ByteRange *br = g_new (ByteRange, 1);
3509 get_insensitive_layout (PangoLayout *layout)
3511 GSList *embossed_ranges = NULL;
3512 GSList *stippled_ranges = NULL;
3513 PangoLayoutIter *iter;
3514 GSList *tmp_list = NULL;
3515 PangoLayout *new_layout;
3516 PangoAttrList *attrs;
3517 GdkBitmap *stipple = NULL;
3519 iter = pango_layout_get_iter (layout);
3523 PangoLayoutRun *run;
3524 PangoAttribute *attr;
3525 gboolean need_stipple = FALSE;
3528 run = pango_layout_iter_get_run (iter);
3532 tmp_list = run->item->extra_attrs;
3534 while (tmp_list != NULL)
3536 attr = tmp_list->data;
3537 switch (attr->klass->type)
3539 case PANGO_ATTR_FOREGROUND:
3540 case PANGO_ATTR_BACKGROUND:
3541 need_stipple = TRUE;
3551 tmp_list = g_slist_next (tmp_list);
3554 br = range_new (run->item->offset, run->item->offset + run->item->length);
3557 stippled_ranges = g_slist_prepend (stippled_ranges, br);
3559 embossed_ranges = g_slist_prepend (embossed_ranges, br);
3562 while (pango_layout_iter_next_run (iter));
3564 pango_layout_iter_free (iter);
3566 new_layout = pango_layout_copy (layout);
3568 attrs = pango_layout_get_attributes (new_layout);
3572 /* Create attr list if there wasn't one */
3573 attrs = pango_attr_list_new ();
3574 pango_layout_set_attributes (new_layout, attrs);
3575 pango_attr_list_unref (attrs);
3578 tmp_list = embossed_ranges;
3579 while (tmp_list != NULL)
3581 PangoAttribute *attr;
3582 ByteRange *br = tmp_list->data;
3584 attr = gdk_pango_attr_embossed_new (TRUE);
3586 attr->start_index = br->start;
3587 attr->end_index = br->end;
3589 pango_attr_list_change (attrs, attr);
3593 tmp_list = g_slist_next (tmp_list);
3596 g_slist_free (embossed_ranges);
3598 tmp_list = stippled_ranges;
3599 while (tmp_list != NULL)
3601 PangoAttribute *attr;
3602 ByteRange *br = tmp_list->data;
3604 if (stipple == NULL)
3606 #define gray50_width 2
3607 #define gray50_height 2
3608 static char gray50_bits[] = {
3612 stipple = gdk_bitmap_create_from_data (NULL,
3613 gray50_bits, gray50_width,
3617 attr = gdk_pango_attr_stipple_new (stipple);
3619 attr->start_index = br->start;
3620 attr->end_index = br->end;
3622 pango_attr_list_change (attrs, attr);
3626 tmp_list = g_slist_next (tmp_list);
3629 g_slist_free (stippled_ranges);
3632 g_object_unref (G_OBJECT (stipple));
3638 gtk_default_draw_layout (GtkStyle *style,
3640 GtkStateType state_type,
3643 const gchar *detail,
3646 PangoLayout *layout)
3648 g_return_if_fail (GTK_IS_STYLE (style));
3649 g_return_if_fail (window != NULL);
3652 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], area);
3654 if (state_type == GTK_STATE_INSENSITIVE)
3658 ins = get_insensitive_layout (layout);
3660 gdk_draw_layout (window, style->fg_gc[state_type], x, y, ins);
3662 g_object_unref (G_OBJECT (ins));
3666 gdk_draw_layout (window, style->fg_gc[state_type], x, y, layout);
3670 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], NULL);
3674 gtk_style_shade (GdkColor *a,
3682 red = (gdouble) a->red / 65535.0;
3683 green = (gdouble) a->green / 65535.0;
3684 blue = (gdouble) a->blue / 65535.0;
3686 rgb_to_hls (&red, &green, &blue);
3691 else if (green < 0.0)
3697 else if (blue < 0.0)
3700 hls_to_rgb (&red, &green, &blue);
3702 b->red = red * 65535.0;
3703 b->green = green * 65535.0;
3704 b->blue = blue * 65535.0;
3708 rgb_to_hls (gdouble *r,
3749 l = (max + min) / 2;
3756 s = (max - min) / (max + min);
3758 s = (max - min) / (2 - max - min);
3762 h = (green - blue) / delta;
3763 else if (green == max)
3764 h = 2 + (blue - red) / delta;
3765 else if (blue == max)
3766 h = 4 + (red - green) / delta;
3779 hls_to_rgb (gdouble *h,
3792 if (lightness <= 0.5)
3793 m2 = lightness * (1 + saturation);
3795 m2 = lightness + saturation - lightness * saturation;
3796 m1 = 2 * lightness - m2;
3798 if (saturation == 0)
3813 r = m1 + (m2 - m1) * hue / 60;
3817 r = m1 + (m2 - m1) * (240 - hue) / 60;
3828 g = m1 + (m2 - m1) * hue / 60;
3832 g = m1 + (m2 - m1) * (240 - hue) / 60;
3843 b = m1 + (m2 - m1) * hue / 60;
3847 b = m1 + (m2 - m1) * (240 - hue) / 60;
3858 gtk_paint_hline (GtkStyle *style,
3860 GtkStateType state_type,
3863 const gchar *detail,
3868 g_return_if_fail (GTK_IS_STYLE (style));
3869 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_hline != NULL);
3871 GTK_STYLE_GET_CLASS (style)->draw_hline (style, window, state_type, area, widget, detail, x1, x2, y);
3875 gtk_paint_vline (GtkStyle *style,
3877 GtkStateType state_type,
3880 const gchar *detail,
3885 g_return_if_fail (GTK_IS_STYLE (style));
3886 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_vline != NULL);
3888 GTK_STYLE_GET_CLASS (style)->draw_vline (style, window, state_type, area, widget, detail, y1, y2, x);
3892 gtk_paint_shadow (GtkStyle *style,
3894 GtkStateType state_type,
3895 GtkShadowType shadow_type,
3898 const gchar *detail,
3904 g_return_if_fail (GTK_IS_STYLE (style));
3905 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow != NULL);
3907 GTK_STYLE_GET_CLASS (style)->draw_shadow (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3911 gtk_paint_polygon (GtkStyle *style,
3913 GtkStateType state_type,
3914 GtkShadowType shadow_type,
3917 const gchar *detail,
3922 g_return_if_fail (GTK_IS_STYLE (style));
3923 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow != NULL);
3925 GTK_STYLE_GET_CLASS (style)->draw_polygon (style, window, state_type, shadow_type, area, widget, detail, points, npoints, fill);
3929 gtk_paint_arrow (GtkStyle *style,
3931 GtkStateType state_type,
3932 GtkShadowType shadow_type,
3935 const gchar *detail,
3936 GtkArrowType arrow_type,
3943 g_return_if_fail (GTK_IS_STYLE (style));
3944 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_arrow != NULL);
3946 GTK_STYLE_GET_CLASS (style)->draw_arrow (style, window, state_type, shadow_type, area, widget, detail, arrow_type, fill, x, y, width, height);
3950 gtk_paint_diamond (GtkStyle *style,
3952 GtkStateType state_type,
3953 GtkShadowType shadow_type,
3956 const gchar *detail,
3962 g_return_if_fail (GTK_IS_STYLE (style));
3963 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_diamond != NULL);
3965 GTK_STYLE_GET_CLASS (style)->draw_diamond (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3969 gtk_paint_string (GtkStyle *style,
3971 GtkStateType state_type,
3974 const gchar *detail,
3977 const gchar *string)
3979 g_return_if_fail (GTK_IS_STYLE (style));
3980 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_string != NULL);
3982 GTK_STYLE_GET_CLASS (style)->draw_string (style, window, state_type, area, widget, detail, x, y, string);
3986 gtk_paint_box (GtkStyle *style,
3988 GtkStateType state_type,
3989 GtkShadowType shadow_type,
3992 const gchar *detail,
3998 g_return_if_fail (GTK_IS_STYLE (style));
3999 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box != NULL);
4001 GTK_STYLE_GET_CLASS (style)->draw_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4005 gtk_paint_flat_box (GtkStyle *style,
4007 GtkStateType state_type,
4008 GtkShadowType shadow_type,
4011 const gchar *detail,
4017 g_return_if_fail (GTK_IS_STYLE (style));
4018 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_flat_box != NULL);
4020 GTK_STYLE_GET_CLASS (style)->draw_flat_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4024 gtk_paint_check (GtkStyle *style,
4026 GtkStateType state_type,
4027 GtkShadowType shadow_type,
4030 const gchar *detail,
4036 g_return_if_fail (GTK_IS_STYLE (style));
4037 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_check != NULL);
4039 GTK_STYLE_GET_CLASS (style)->draw_check (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4043 gtk_paint_option (GtkStyle *style,
4045 GtkStateType state_type,
4046 GtkShadowType shadow_type,
4049 const gchar *detail,
4055 g_return_if_fail (GTK_IS_STYLE (style));
4056 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_option != NULL);
4058 GTK_STYLE_GET_CLASS (style)->draw_option (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4062 gtk_paint_tab (GtkStyle *style,
4064 GtkStateType state_type,
4065 GtkShadowType shadow_type,
4068 const gchar *detail,
4074 g_return_if_fail (GTK_IS_STYLE (style));
4075 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_tab != NULL);
4077 GTK_STYLE_GET_CLASS (style)->draw_tab (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4081 gtk_paint_shadow_gap (GtkStyle *style,
4083 GtkStateType state_type,
4084 GtkShadowType shadow_type,
4092 GtkPositionType gap_side,
4096 g_return_if_fail (GTK_IS_STYLE (style));
4097 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow_gap != NULL);
4099 GTK_STYLE_GET_CLASS (style)->draw_shadow_gap (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
4104 gtk_paint_box_gap (GtkStyle *style,
4106 GtkStateType state_type,
4107 GtkShadowType shadow_type,
4115 GtkPositionType gap_side,
4119 g_return_if_fail (GTK_IS_STYLE (style));
4120 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box_gap != NULL);
4122 GTK_STYLE_GET_CLASS (style)->draw_box_gap (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
4126 gtk_paint_extension (GtkStyle *style,
4128 GtkStateType state_type,
4129 GtkShadowType shadow_type,
4137 GtkPositionType gap_side)
4139 g_return_if_fail (GTK_IS_STYLE (style));
4140 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_extension != NULL);
4142 GTK_STYLE_GET_CLASS (style)->draw_extension (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side);
4146 gtk_paint_focus (GtkStyle *style,
4150 const gchar *detail,
4156 g_return_if_fail (GTK_IS_STYLE (style));
4157 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_focus != NULL);
4159 GTK_STYLE_GET_CLASS (style)->draw_focus (style, window, area, widget, detail, x, y, width, height);
4163 gtk_paint_slider (GtkStyle *style,
4165 GtkStateType state_type,
4166 GtkShadowType shadow_type,
4169 const gchar *detail,
4174 GtkOrientation orientation)
4176 g_return_if_fail (GTK_IS_STYLE (style));
4177 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_slider != NULL);
4179 GTK_STYLE_GET_CLASS (style)->draw_slider (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
4183 gtk_paint_handle (GtkStyle *style,
4185 GtkStateType state_type,
4186 GtkShadowType shadow_type,
4189 const gchar *detail,
4194 GtkOrientation orientation)
4196 g_return_if_fail (GTK_IS_STYLE (style));
4197 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_handle != NULL);
4199 GTK_STYLE_GET_CLASS (style)->draw_handle (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
4203 gtk_paint_expander (GtkStyle *style,
4205 GtkStateType state_type,
4208 const gchar *detail,
4213 g_return_if_fail (GTK_IS_STYLE (style));
4214 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_expander != NULL);
4216 GTK_STYLE_GET_CLASS (style)->draw_expander (style, window, state_type, area,
4217 widget, detail, x, y, is_open);
4221 gtk_paint_layout (GtkStyle *style,
4223 GtkStateType state_type,
4226 const gchar *detail,
4229 PangoLayout *layout)
4231 g_return_if_fail (GTK_IS_STYLE (style));
4232 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_layout != NULL);
4234 GTK_STYLE_GET_CLASS (style)->draw_layout (style, window, state_type, area,
4235 widget, detail, x, y, layout);