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 Library 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 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library 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-1999. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
31 #include "gtkthemes.h"
32 #include "gtkwidget.h"
33 #include "gtkthemes.h"
34 #include "gdkprivate.h"
37 #define LIGHTNESS_MULT 1.3
38 #define DARKNESS_MULT 0.7
40 /* actually glib should do that for us */
42 #define M_PI 3.14159265358979323846
45 #define M_PI_4 0.78539816339744830962
48 static void gtk_style_init (GtkStyle *style,
49 GdkColormap *colormap,
51 static void gtk_style_destroy (GtkStyle *style);
53 static void gtk_default_draw_hline (GtkStyle *style,
55 GtkStateType state_type,
62 static void gtk_default_draw_vline (GtkStyle *style,
64 GtkStateType state_type,
71 static void gtk_default_draw_shadow (GtkStyle *style,
73 GtkStateType state_type,
74 GtkShadowType shadow_type,
82 static void gtk_default_draw_shadow (GtkStyle *style,
84 GtkStateType state_type,
85 GtkShadowType shadow_type,
93 static void gtk_default_draw_polygon (GtkStyle *style,
95 GtkStateType state_type,
96 GtkShadowType shadow_type,
103 static void gtk_default_draw_arrow (GtkStyle *style,
105 GtkStateType state_type,
106 GtkShadowType shadow_type,
110 GtkArrowType arrow_type,
116 static void gtk_default_draw_diamond (GtkStyle *style,
118 GtkStateType state_type,
119 GtkShadowType shadow_type,
127 static void gtk_default_draw_oval (GtkStyle *style,
129 GtkStateType state_type,
130 GtkShadowType shadow_type,
138 static void gtk_default_draw_string (GtkStyle *style,
140 GtkStateType state_type,
146 const gchar *string);
147 static void gtk_default_draw_box (GtkStyle *style,
149 GtkStateType state_type,
150 GtkShadowType shadow_type,
158 static void gtk_default_draw_flat_box (GtkStyle *style,
160 GtkStateType state_type,
161 GtkShadowType shadow_type,
169 static void gtk_default_draw_check (GtkStyle *style,
171 GtkStateType state_type,
172 GtkShadowType shadow_type,
180 static void gtk_default_draw_option (GtkStyle *style,
182 GtkStateType state_type,
183 GtkShadowType shadow_type,
191 static void gtk_default_draw_cross (GtkStyle *style,
193 GtkStateType state_type,
194 GtkShadowType shadow_type,
202 static void gtk_default_draw_ramp (GtkStyle *style,
204 GtkStateType state_type,
205 GtkShadowType shadow_type,
209 GtkArrowType arrow_type,
214 static void gtk_default_draw_tab (GtkStyle *style,
216 GtkStateType state_type,
217 GtkShadowType shadow_type,
225 static void gtk_default_draw_shadow_gap (GtkStyle *style,
227 GtkStateType state_type,
228 GtkShadowType shadow_type,
236 GtkPositionType gap_side,
239 static void gtk_default_draw_box_gap (GtkStyle *style,
241 GtkStateType state_type,
242 GtkShadowType shadow_type,
250 GtkPositionType gap_side,
253 static void gtk_default_draw_extension (GtkStyle *style,
255 GtkStateType state_type,
256 GtkShadowType shadow_type,
264 GtkPositionType gap_side);
265 static void gtk_default_draw_focus (GtkStyle *style,
274 static void gtk_default_draw_slider (GtkStyle *style,
276 GtkStateType state_type,
277 GtkShadowType shadow_type,
285 GtkOrientation orientation);
286 static void gtk_default_draw_handle (GtkStyle *style,
288 GtkStateType state_type,
289 GtkShadowType shadow_type,
297 GtkOrientation orientation);
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);
305 static const GtkStyleClass default_class =
309 gtk_default_draw_hline,
310 gtk_default_draw_vline,
311 gtk_default_draw_shadow,
312 gtk_default_draw_polygon,
313 gtk_default_draw_arrow,
314 gtk_default_draw_diamond,
315 gtk_default_draw_oval,
316 gtk_default_draw_string,
317 gtk_default_draw_box,
318 gtk_default_draw_flat_box,
319 gtk_default_draw_check,
320 gtk_default_draw_option,
321 gtk_default_draw_cross,
322 gtk_default_draw_ramp,
323 gtk_default_draw_tab,
324 gtk_default_draw_shadow_gap,
325 gtk_default_draw_box_gap,
326 gtk_default_draw_extension,
327 gtk_default_draw_focus,
328 gtk_default_draw_slider,
329 gtk_default_draw_handle
331 GdkFont *default_font = NULL;
333 static GdkColor gtk_default_normal_fg = { 0, 0, 0, 0 };
334 static GdkColor gtk_default_active_fg = { 0, 0, 0, 0 };
335 static GdkColor gtk_default_prelight_fg = { 0, 0, 0, 0 };
336 static GdkColor gtk_default_selected_fg = { 0, 0xffff, 0xffff, 0xffff };
337 static GdkColor gtk_default_insensitive_fg = { 0, 0x7530, 0x7530, 0x7530 };
339 static GdkColor gtk_default_normal_bg = { 0, 0xd6d6, 0xd6d6, 0xd6d6 };
340 static GdkColor gtk_default_active_bg = { 0, 0xc350, 0xc350, 0xc350 };
341 static GdkColor gtk_default_prelight_bg = { 0, 0xea60, 0xea60, 0xea60 };
342 static GdkColor gtk_default_selected_bg = { 0, 0, 0, 0x9c40 };
343 static GdkColor gtk_default_insensitive_bg = { 0, 0xd6d6, 0xd6d6, 0xd6d6 };
346 gtk_style_copy (GtkStyle *style)
351 g_return_val_if_fail (style != NULL, NULL);
353 new_style = gtk_style_new ();
355 for (i = 0; i < 5; i++)
357 new_style->fg[i] = style->fg[i];
358 new_style->bg[i] = style->bg[i];
359 new_style->text[i] = style->text[i];
360 new_style->base[i] = style->base[i];
362 new_style->bg_pixmap[i] = style->bg_pixmap[i];
365 gdk_font_unref (new_style->font);
366 new_style->font = style->font;
367 gdk_font_ref (new_style->font);
371 new_style->rc_style = style->rc_style;
372 gtk_rc_style_ref (style->rc_style);
377 new_style->engine = style->engine;
378 gtk_theme_engine_ref(new_style->engine);
379 new_style->engine->duplicate_style (new_style, style);
386 gtk_style_duplicate (GtkStyle *style)
390 g_return_val_if_fail (style != NULL, NULL);
392 new_style = gtk_style_copy (style);
394 style->styles = g_slist_append (style->styles, new_style);
395 new_style->styles = style->styles;
406 style = g_new0 (GtkStyle, 1);
411 gdk_font_load ("-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*");
413 default_font = gdk_font_load ("fixed");
415 g_error ("Unable to load default font.");
418 style->font = default_font;
419 gdk_font_ref (style->font);
421 style->ref_count = 1;
422 style->attach_count = 0;
423 style->colormap = NULL;
425 style->klass = &default_class;
427 style->black.red = 0;
428 style->black.green = 0;
429 style->black.blue = 0;
431 style->white.red = 65535;
432 style->white.green = 65535;
433 style->white.blue = 65535;
435 style->black_gc = NULL;
436 style->white_gc = NULL;
438 style->fg[GTK_STATE_NORMAL] = gtk_default_normal_fg;
439 style->fg[GTK_STATE_ACTIVE] = gtk_default_active_fg;
440 style->fg[GTK_STATE_PRELIGHT] = gtk_default_prelight_fg;
441 style->fg[GTK_STATE_SELECTED] = gtk_default_selected_fg;
442 style->fg[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_fg;
444 style->bg[GTK_STATE_NORMAL] = gtk_default_normal_bg;
445 style->bg[GTK_STATE_ACTIVE] = gtk_default_active_bg;
446 style->bg[GTK_STATE_PRELIGHT] = gtk_default_prelight_bg;
447 style->bg[GTK_STATE_SELECTED] = gtk_default_selected_bg;
448 style->bg[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_bg;
450 for (i = 0; i < 4; i++)
452 style->text[i] = style->fg[i];
453 style->base[i] = style->white;
456 style->base[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_bg;
457 style->text[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_bg;
459 for (i = 0; i < 5; i++)
460 style->bg_pixmap[i] = NULL;
462 style->engine = NULL;
463 style->engine_data = NULL;
465 style->rc_style = NULL;
467 for (i = 0; i < 5; i++)
469 style->fg_gc[i] = NULL;
470 style->bg_gc[i] = NULL;
471 style->light_gc[i] = NULL;
472 style->dark_gc[i] = NULL;
473 style->mid_gc[i] = NULL;
474 style->text_gc[i] = NULL;
475 style->base_gc[i] = NULL;
482 gtk_style_attach (GtkStyle *style,
486 GtkStyle *new_style = NULL;
487 GdkColormap *colormap;
490 g_return_val_if_fail (style != NULL, NULL);
491 g_return_val_if_fail (window != NULL, NULL);
493 colormap = gdk_window_get_colormap (window);
494 depth = gdk_window_get_visual (window)->depth;
497 style->styles = g_slist_append (NULL, style);
499 styles = style->styles;
502 new_style = styles->data;
504 if (new_style->attach_count == 0)
506 gtk_style_init (new_style, colormap, depth);
509 else if (new_style->colormap == colormap &&
510 new_style->depth == depth)
514 styles = styles->next;
519 new_style = gtk_style_duplicate (style);
520 gtk_style_init (new_style, colormap, depth);
523 if (new_style->attach_count == 0)
524 gtk_style_ref (new_style);
526 new_style->attach_count++;
532 gtk_style_detach (GtkStyle *style)
536 g_return_if_fail (style != NULL);
538 style->attach_count -= 1;
539 if (style->attach_count == 0)
542 style->engine->unrealize_style (style);
544 gtk_gc_release (style->black_gc);
545 gtk_gc_release (style->white_gc);
547 for (i = 0; i < 5; i++)
549 gtk_gc_release (style->fg_gc[i]);
550 gtk_gc_release (style->bg_gc[i]);
551 gtk_gc_release (style->light_gc[i]);
552 gtk_gc_release (style->dark_gc[i]);
553 gtk_gc_release (style->mid_gc[i]);
554 gtk_gc_release (style->text_gc[i]);
555 gtk_gc_release (style->base_gc[i]);
558 gtk_style_unref (style);
563 gtk_style_ref (GtkStyle *style)
565 g_return_val_if_fail (style != NULL, NULL);
567 style->ref_count += 1;
572 gtk_style_unref (GtkStyle *style)
574 g_return_if_fail (style != NULL);
576 style->ref_count -= 1;
577 if (style->ref_count == 0)
578 gtk_style_destroy (style);
582 gtk_style_init (GtkStyle *style,
583 GdkColormap *colormap,
586 GdkGCValues gc_values;
587 GdkGCValuesMask gc_values_mask;
590 g_return_if_fail (style != NULL);
592 style->colormap = colormap;
593 style->depth = depth;
595 for (i = 0; i < 5; i++)
597 gtk_style_shade (&style->bg[i], &style->light[i], LIGHTNESS_MULT);
598 gtk_style_shade (&style->bg[i], &style->dark[i], DARKNESS_MULT);
600 style->mid[i].red = (style->light[i].red + style->dark[i].red) / 2;
601 style->mid[i].green = (style->light[i].green + style->dark[i].green) / 2;
602 style->mid[i].blue = (style->light[i].blue + style->dark[i].blue) / 2;
605 gdk_color_black (colormap, &style->black);
606 gdk_color_white (colormap, &style->white);
608 gc_values_mask = GDK_GC_FOREGROUND | GDK_GC_FONT;
609 if (style->font->type == GDK_FONT_FONT)
611 gc_values.font = style->font;
613 else if (style->font->type == GDK_FONT_FONTSET)
615 gc_values.font = default_font;
618 gc_values.foreground = style->black;
619 style->black_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
621 gc_values.foreground = style->white;
622 style->white_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
624 for (i = 0; i < 5; i++)
626 if (style->rc_style && style->rc_style->bg_pixmap_name[i])
627 style->bg_pixmap[i] = gtk_rc_load_image (style->colormap,
629 style->rc_style->bg_pixmap_name[i]);
631 if (!gdk_color_alloc (colormap, &style->fg[i]))
632 g_warning ("unable to allocate color: ( %d %d %d )",
633 style->fg[i].red, style->fg[i].green, style->fg[i].blue);
634 if (!gdk_color_alloc (colormap, &style->bg[i]))
635 g_warning ("unable to allocate color: ( %d %d %d )",
636 style->bg[i].red, style->bg[i].green, style->bg[i].blue);
637 if (!gdk_color_alloc (colormap, &style->light[i]))
638 g_warning ("unable to allocate color: ( %d %d %d )",
639 style->light[i].red, style->light[i].green, style->light[i].blue);
640 if (!gdk_color_alloc (colormap, &style->dark[i]))
641 g_warning ("unable to allocate color: ( %d %d %d )",
642 style->dark[i].red, style->dark[i].green, style->dark[i].blue);
643 if (!gdk_color_alloc (colormap, &style->mid[i]))
644 g_warning ("unable to allocate color: ( %d %d %d )",
645 style->mid[i].red, style->mid[i].green, style->mid[i].blue);
646 if (!gdk_color_alloc (colormap, &style->text[i]))
647 g_warning ("unable to allocate color: ( %d %d %d )",
648 style->text[i].red, style->text[i].green, style->text[i].blue);
649 if (!gdk_color_alloc (colormap, &style->base[i]))
650 g_warning ("unable to allocate color: ( %d %d %d )",
651 style->base[i].red, style->base[i].green, style->base[i].blue);
653 gc_values.foreground = style->fg[i];
654 style->fg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
656 gc_values.foreground = style->bg[i];
657 style->bg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
659 gc_values.foreground = style->light[i];
660 style->light_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
662 gc_values.foreground = style->dark[i];
663 style->dark_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
665 gc_values.foreground = style->mid[i];
666 style->mid_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
668 gc_values.foreground = style->text[i];
669 style->text_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
671 gc_values.foreground = style->base[i];
672 style->base_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
676 style->engine->realize_style (style);
680 gtk_style_destroy (GtkStyle *style)
682 g_return_if_fail (style->attach_count == 0);
686 if (style->styles->data != style)
687 g_slist_remove (style->styles, style);
690 GSList *tmp_list = style->styles->next;
694 ((GtkStyle*) tmp_list->data)->styles = style->styles->next;
695 tmp_list = tmp_list->next;
697 g_slist_free_1 (style->styles);
703 style->engine->destroy_style (style);
704 gtk_theme_engine_unref (style->engine);
707 gdk_font_unref (style->font);
709 gtk_rc_style_unref (style->rc_style);
715 gtk_draw_hline (GtkStyle *style,
717 GtkStateType state_type,
722 g_return_if_fail (style != NULL);
723 g_return_if_fail (style->klass != NULL);
724 g_return_if_fail (style->klass->draw_hline != NULL);
726 style->klass->draw_hline (style, window, state_type, NULL, NULL, NULL, x1, x2, y);
731 gtk_draw_vline (GtkStyle *style,
733 GtkStateType state_type,
738 g_return_if_fail (style != NULL);
739 g_return_if_fail (style->klass != NULL);
740 g_return_if_fail (style->klass->draw_vline != NULL);
742 style->klass->draw_vline (style, window, state_type, NULL, NULL, NULL, y1, y2, x);
747 gtk_draw_shadow (GtkStyle *style,
749 GtkStateType state_type,
750 GtkShadowType shadow_type,
756 g_return_if_fail (style != NULL);
757 g_return_if_fail (style->klass != NULL);
758 g_return_if_fail (style->klass->draw_shadow != NULL);
760 style->klass->draw_shadow (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
764 gtk_draw_polygon (GtkStyle *style,
766 GtkStateType state_type,
767 GtkShadowType shadow_type,
772 g_return_if_fail (style != NULL);
773 g_return_if_fail (style->klass != NULL);
774 g_return_if_fail (style->klass->draw_polygon != NULL);
776 style->klass->draw_polygon (style, window, state_type, shadow_type, NULL, NULL, NULL, points, npoints, fill);
780 gtk_draw_arrow (GtkStyle *style,
782 GtkStateType state_type,
783 GtkShadowType shadow_type,
784 GtkArrowType arrow_type,
791 g_return_if_fail (style != NULL);
792 g_return_if_fail (style->klass != NULL);
793 g_return_if_fail (style->klass->draw_arrow != NULL);
795 style->klass->draw_arrow (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, fill, x, y, width, height);
800 gtk_draw_diamond (GtkStyle *style,
802 GtkStateType state_type,
803 GtkShadowType shadow_type,
809 g_return_if_fail (style != NULL);
810 g_return_if_fail (style->klass != NULL);
811 g_return_if_fail (style->klass->draw_diamond != NULL);
813 style->klass->draw_diamond (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
818 gtk_draw_oval (GtkStyle *style,
820 GtkStateType state_type,
821 GtkShadowType shadow_type,
827 g_return_if_fail (style != NULL);
828 g_return_if_fail (style->klass != NULL);
829 g_return_if_fail (style->klass->draw_oval != NULL);
831 style->klass->draw_oval (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
835 gtk_draw_string (GtkStyle *style,
837 GtkStateType state_type,
842 g_return_if_fail (style != NULL);
843 g_return_if_fail (style->klass != NULL);
844 g_return_if_fail (style->klass->draw_string != NULL);
846 style->klass->draw_string (style, window, state_type, NULL, NULL, NULL, x, y, string);
850 gtk_draw_box (GtkStyle *style,
852 GtkStateType state_type,
853 GtkShadowType shadow_type,
859 g_return_if_fail (style != NULL);
860 g_return_if_fail (style->klass != NULL);
861 g_return_if_fail (style->klass->draw_box != NULL);
863 style->klass->draw_box (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
867 gtk_draw_flat_box (GtkStyle *style,
869 GtkStateType state_type,
870 GtkShadowType shadow_type,
876 g_return_if_fail (style != NULL);
877 g_return_if_fail (style->klass != NULL);
878 g_return_if_fail (style->klass->draw_flat_box != NULL);
880 style->klass->draw_flat_box (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
884 gtk_draw_check (GtkStyle *style,
886 GtkStateType state_type,
887 GtkShadowType shadow_type,
893 g_return_if_fail (style != NULL);
894 g_return_if_fail (style->klass != NULL);
895 g_return_if_fail (style->klass->draw_check != NULL);
897 style->klass->draw_check (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
901 gtk_draw_option (GtkStyle *style,
903 GtkStateType state_type,
904 GtkShadowType shadow_type,
910 g_return_if_fail (style != NULL);
911 g_return_if_fail (style->klass != NULL);
912 g_return_if_fail (style->klass->draw_option != NULL);
914 style->klass->draw_option (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
918 gtk_draw_cross (GtkStyle *style,
920 GtkStateType state_type,
921 GtkShadowType shadow_type,
927 g_return_if_fail (style != NULL);
928 g_return_if_fail (style->klass != NULL);
929 g_return_if_fail (style->klass->draw_cross != NULL);
931 style->klass->draw_cross (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
935 gtk_draw_ramp (GtkStyle *style,
937 GtkStateType state_type,
938 GtkShadowType shadow_type,
939 GtkArrowType arrow_type,
945 g_return_if_fail (style != NULL);
946 g_return_if_fail (style->klass != NULL);
947 g_return_if_fail (style->klass->draw_ramp != NULL);
949 style->klass->draw_ramp (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, x, y, width, height);
953 gtk_draw_tab (GtkStyle *style,
955 GtkStateType state_type,
956 GtkShadowType shadow_type,
962 g_return_if_fail (style != NULL);
963 g_return_if_fail (style->klass != NULL);
964 g_return_if_fail (style->klass->draw_tab != NULL);
966 style->klass->draw_tab (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
970 gtk_draw_shadow_gap (GtkStyle *style,
972 GtkStateType state_type,
973 GtkShadowType shadow_type,
978 GtkPositionType gap_side,
982 g_return_if_fail (style != NULL);
983 g_return_if_fail (style->klass != NULL);
984 g_return_if_fail (style->klass->draw_shadow_gap != NULL);
986 style->klass->draw_shadow_gap (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width);
990 gtk_draw_box_gap (GtkStyle *style,
992 GtkStateType state_type,
993 GtkShadowType shadow_type,
998 GtkPositionType gap_side,
1002 g_return_if_fail (style != NULL);
1003 g_return_if_fail (style->klass != NULL);
1004 g_return_if_fail (style->klass->draw_box_gap != NULL);
1006 style->klass->draw_box_gap (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width);
1010 gtk_draw_extension (GtkStyle *style,
1012 GtkStateType state_type,
1013 GtkShadowType shadow_type,
1018 GtkPositionType gap_side)
1020 g_return_if_fail (style != NULL);
1021 g_return_if_fail (style->klass != NULL);
1022 g_return_if_fail (style->klass->draw_extension != NULL);
1024 style->klass->draw_extension (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side);
1028 gtk_draw_focus (GtkStyle *style,
1035 g_return_if_fail (style != NULL);
1036 g_return_if_fail (style->klass != NULL);
1037 g_return_if_fail (style->klass->draw_focus != NULL);
1039 style->klass->draw_focus (style, window, NULL, NULL, NULL, x, y, width, height);
1043 gtk_draw_slider (GtkStyle *style,
1045 GtkStateType state_type,
1046 GtkShadowType shadow_type,
1051 GtkOrientation orientation)
1053 g_return_if_fail (style != NULL);
1054 g_return_if_fail (style->klass != NULL);
1055 g_return_if_fail (style->klass->draw_slider != NULL);
1057 style->klass->draw_slider (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
1061 gtk_draw_handle (GtkStyle *style,
1063 GtkStateType state_type,
1064 GtkShadowType shadow_type,
1069 GtkOrientation orientation)
1071 g_return_if_fail (style != NULL);
1072 g_return_if_fail (style->klass != NULL);
1073 g_return_if_fail (style->klass->draw_handle != NULL);
1075 style->klass->draw_handle (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
1079 gtk_style_set_background (GtkStyle *style,
1081 GtkStateType state_type)
1084 gint parent_relative;
1086 g_return_if_fail (style != NULL);
1087 g_return_if_fail (window != NULL);
1089 if (style->engine && style->engine->set_background)
1091 style->engine->set_background (style, window, state_type);
1096 if (style->bg_pixmap[state_type])
1098 if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
1101 parent_relative = TRUE;
1105 pixmap = style->bg_pixmap[state_type];
1106 parent_relative = FALSE;
1109 gdk_window_set_back_pixmap (window, pixmap, parent_relative);
1112 gdk_window_set_background (window, &style->bg[state_type]);
1116 /* Default functions */
1118 gtk_style_apply_default_background (GtkStyle *style,
1121 GtkStateType state_type,
1128 GdkRectangle new_rect, old_rect;
1134 old_rect.width = width;
1135 old_rect.height = height;
1137 if (!gdk_rectangle_intersect (area, &old_rect, &new_rect))
1144 new_rect.width = width;
1145 new_rect.height = height;
1148 if (!style->bg_pixmap[state_type] ||
1149 gdk_window_get_type (window) == GDK_WINDOW_PIXMAP ||
1150 (!set_bg && style->bg_pixmap[state_type] != (GdkPixmap*) GDK_PARENT_RELATIVE))
1152 GdkGC *gc = style->bg_gc[state_type];
1154 if (style->bg_pixmap[state_type])
1156 gdk_gc_set_fill (gc, GDK_TILED);
1157 gdk_gc_set_tile (gc, style->bg_pixmap[state_type]);
1160 gdk_draw_rectangle (window, gc, TRUE,
1161 new_rect.x, new_rect.y, new_rect.width, new_rect.height);
1162 if (style->bg_pixmap[state_type])
1163 gdk_gc_set_fill (gc, GDK_SOLID);
1169 if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
1170 gdk_window_set_back_pixmap (window, NULL, TRUE);
1172 gdk_window_set_back_pixmap (window, style->bg_pixmap[state_type], FALSE);
1175 gdk_window_clear_area (window,
1176 new_rect.x, new_rect.y,
1177 new_rect.width, new_rect.height);
1182 gtk_default_draw_hline (GtkStyle *style,
1184 GtkStateType state_type,
1192 gint thickness_light;
1193 gint thickness_dark;
1196 g_return_if_fail (style != NULL);
1197 g_return_if_fail (window != NULL);
1199 thickness_light = style->klass->ythickness / 2;
1200 thickness_dark = style->klass->ythickness - thickness_light;
1204 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1205 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1208 if (detail && !strcmp (detail, "label"))
1210 if (state_type == GTK_STATE_INSENSITIVE)
1211 gdk_draw_line (window, style->white_gc, x1 + 1, y + 1, x2 + 1, y + 1);
1212 gdk_draw_line (window, style->fg_gc[state_type], x1, y, x2, y);
1216 for (i = 0; i < thickness_dark; i++)
1218 gdk_draw_line (window, style->light_gc[state_type], x2 - i - 1, y + i, x2, y + i);
1219 gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x2 - i - 1, y + i);
1222 y += thickness_dark;
1223 for (i = 0; i < thickness_light; i++)
1225 gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x1 + thickness_light - i - 1, y + i);
1226 gdk_draw_line (window, style->light_gc[state_type], x1 + thickness_light - i - 1, y + i, x2, y + i);
1232 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
1233 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
1239 gtk_default_draw_vline (GtkStyle *style,
1241 GtkStateType state_type,
1249 gint thickness_light;
1250 gint thickness_dark;
1253 g_return_if_fail (style != NULL);
1254 g_return_if_fail (window != NULL);
1256 thickness_light = style->klass->xthickness / 2;
1257 thickness_dark = style->klass->xthickness - thickness_light;
1261 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1262 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1264 for (i = 0; i < thickness_dark; i++)
1266 gdk_draw_line (window, style->light_gc[state_type], x + i, y2 - i - 1, x + i, y2);
1267 gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y2 - i - 1);
1270 x += thickness_dark;
1271 for (i = 0; i < thickness_light; i++)
1273 gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y1 + thickness_light - i);
1274 gdk_draw_line (window, style->light_gc[state_type], x + i, y1 + thickness_light - i, x + i, y2);
1278 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
1279 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
1285 gtk_default_draw_shadow (GtkStyle *style,
1287 GtkStateType state_type,
1288 GtkShadowType shadow_type,
1299 gint thickness_light;
1300 gint thickness_dark;
1303 g_return_if_fail (style != NULL);
1304 g_return_if_fail (window != NULL);
1306 if ((width == -1) && (height == -1))
1307 gdk_window_get_size (window, &width, &height);
1308 else if (width == -1)
1309 gdk_window_get_size (window, &width, NULL);
1310 else if (height == -1)
1311 gdk_window_get_size (window, NULL, &height);
1313 switch (shadow_type)
1315 case GTK_SHADOW_NONE:
1318 case GTK_SHADOW_ETCHED_IN:
1319 gc1 = style->light_gc[state_type];
1320 gc2 = style->dark_gc[state_type];
1322 case GTK_SHADOW_OUT:
1323 case GTK_SHADOW_ETCHED_OUT:
1324 gc1 = style->dark_gc[state_type];
1325 gc2 = style->light_gc[state_type];
1331 gdk_gc_set_clip_rectangle (gc1, area);
1332 gdk_gc_set_clip_rectangle (gc2, area);
1333 if (shadow_type == GTK_SHADOW_IN ||
1334 shadow_type == GTK_SHADOW_OUT)
1336 gdk_gc_set_clip_rectangle (style->black_gc, area);
1337 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
1341 switch (shadow_type)
1343 case GTK_SHADOW_NONE:
1347 gdk_draw_line (window, gc1,
1348 x, y + height - 1, x + width - 1, y + height - 1);
1349 gdk_draw_line (window, gc1,
1350 x + width - 1, y, x + width - 1, y + height - 1);
1352 gdk_draw_line (window, style->bg_gc[state_type],
1353 x + 1, y + height - 2, x + width - 2, y + height - 2);
1354 gdk_draw_line (window, style->bg_gc[state_type],
1355 x + width - 2, y + 1, x + width - 2, y + height - 2);
1357 gdk_draw_line (window, style->black_gc,
1358 x + 1, y + 1, x + width - 2, y + 1);
1359 gdk_draw_line (window, style->black_gc,
1360 x + 1, y + 1, x + 1, y + height - 2);
1362 gdk_draw_line (window, gc2,
1363 x, y, x + width - 1, y);
1364 gdk_draw_line (window, gc2,
1365 x, y, x, y + height - 1);
1368 case GTK_SHADOW_OUT:
1369 gdk_draw_line (window, gc1,
1370 x + 1, y + height - 2, x + width - 2, y + height - 2);
1371 gdk_draw_line (window, gc1,
1372 x + width - 2, y + 1, x + width - 2, y + height - 2);
1374 gdk_draw_line (window, gc2,
1375 x, y, x + width - 1, y);
1376 gdk_draw_line (window, gc2,
1377 x, y, x, y + height - 1);
1379 gdk_draw_line (window, style->bg_gc[state_type],
1380 x + 1, y + 1, x + width - 2, y + 1);
1381 gdk_draw_line (window, style->bg_gc[state_type],
1382 x + 1, y + 1, x + 1, y + height - 2);
1384 gdk_draw_line (window, style->black_gc,
1385 x, y + height - 1, x + width - 1, y + height - 1);
1386 gdk_draw_line (window, style->black_gc,
1387 x + width - 1, y, x + width - 1, y + height - 1);
1390 case GTK_SHADOW_ETCHED_IN:
1391 case GTK_SHADOW_ETCHED_OUT:
1392 thickness_light = 1;
1395 for (i = 0; i < thickness_dark; i++)
1397 gdk_draw_line (window, gc1,
1401 y + height - i - 1);
1402 gdk_draw_line (window, gc1,
1406 y + height - i - 1);
1408 gdk_draw_line (window, gc2,
1413 gdk_draw_line (window, gc2,
1417 y + height - i - 2);
1420 for (i = 0; i < thickness_light; i++)
1422 gdk_draw_line (window, gc1,
1423 x + thickness_dark + i,
1424 y + thickness_dark + i,
1425 x + width - thickness_dark - i - 1,
1426 y + thickness_dark + i);
1427 gdk_draw_line (window, gc1,
1428 x + thickness_dark + i,
1429 y + thickness_dark + i,
1430 x + thickness_dark + i,
1431 y + height - thickness_dark - i - 1);
1433 gdk_draw_line (window, gc2,
1434 x + thickness_dark + i,
1435 y + height - thickness_light - i - 1,
1436 x + width - thickness_light - 1,
1437 y + height - thickness_light - i - 1);
1438 gdk_draw_line (window, gc2,
1439 x + width - thickness_light - i - 1,
1440 y + thickness_dark + i,
1441 x + width - thickness_light - i - 1,
1442 y + height - thickness_light - 1);
1448 gdk_gc_set_clip_rectangle (gc1, NULL);
1449 gdk_gc_set_clip_rectangle (gc2, NULL);
1450 if (shadow_type == GTK_SHADOW_IN ||
1451 shadow_type == GTK_SHADOW_OUT)
1453 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
1454 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
1460 gtk_default_draw_polygon (GtkStyle *style,
1462 GtkStateType state_type,
1463 GtkShadowType shadow_type,
1471 static const gdouble pi_over_4 = M_PI_4;
1472 static const gdouble pi_3_over_4 = M_PI_4 * 3;
1482 g_return_if_fail (style != NULL);
1483 g_return_if_fail (window != NULL);
1484 g_return_if_fail (points != NULL);
1486 switch (shadow_type)
1489 gc1 = style->bg_gc[state_type];
1490 gc2 = style->dark_gc[state_type];
1491 gc3 = style->light_gc[state_type];
1492 gc4 = style->black_gc;
1494 case GTK_SHADOW_ETCHED_IN:
1495 gc1 = style->light_gc[state_type];
1496 gc2 = style->dark_gc[state_type];
1497 gc3 = style->dark_gc[state_type];
1498 gc4 = style->light_gc[state_type];
1500 case GTK_SHADOW_OUT:
1501 gc1 = style->dark_gc[state_type];
1502 gc2 = style->light_gc[state_type];
1503 gc3 = style->black_gc;
1504 gc4 = style->bg_gc[state_type];
1506 case GTK_SHADOW_ETCHED_OUT:
1507 gc1 = style->dark_gc[state_type];
1508 gc2 = style->light_gc[state_type];
1509 gc3 = style->light_gc[state_type];
1510 gc4 = style->dark_gc[state_type];
1518 gdk_gc_set_clip_rectangle (gc1, area);
1519 gdk_gc_set_clip_rectangle (gc2, area);
1520 gdk_gc_set_clip_rectangle (gc3, area);
1521 gdk_gc_set_clip_rectangle (gc4, area);
1525 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, npoints);
1529 for (i = 0; i < npoints; i++)
1531 if ((points[i].x == points[i+1].x) &&
1532 (points[i].y == points[i+1].y))
1538 angle = atan2 (points[i+1].y - points[i].y,
1539 points[i+1].x - points[i].x);
1542 if ((angle > -pi_3_over_4) && (angle < pi_over_4))
1544 if (angle > -pi_over_4)
1555 gdk_draw_line (window, gc1,
1556 points[i].x-xadjust, points[i].y-yadjust,
1557 points[i+1].x-xadjust, points[i+1].y-yadjust);
1558 gdk_draw_line (window, gc3,
1559 points[i].x, points[i].y,
1560 points[i+1].x, points[i+1].y);
1564 if ((angle < -pi_3_over_4) || (angle > pi_3_over_4))
1575 gdk_draw_line (window, gc4,
1576 points[i].x+xadjust, points[i].y+yadjust,
1577 points[i+1].x+xadjust, points[i+1].y+yadjust);
1578 gdk_draw_line (window, gc2,
1579 points[i].x, points[i].y,
1580 points[i+1].x, points[i+1].y);
1586 gdk_gc_set_clip_rectangle (gc1, NULL);
1587 gdk_gc_set_clip_rectangle (gc2, NULL);
1588 gdk_gc_set_clip_rectangle (gc3, NULL);
1589 gdk_gc_set_clip_rectangle (gc4, NULL);
1594 gtk_default_draw_arrow (GtkStyle *style,
1596 GtkStateType state_type,
1597 GtkShadowType shadow_type,
1601 GtkArrowType arrow_type,
1616 g_return_if_fail (style != NULL);
1617 g_return_if_fail (window != NULL);
1619 switch (shadow_type)
1622 gc1 = style->bg_gc[state_type];
1623 gc2 = style->dark_gc[state_type];
1624 gc3 = style->light_gc[state_type];
1625 gc4 = style->black_gc;
1627 case GTK_SHADOW_OUT:
1628 gc1 = style->dark_gc[state_type];
1629 gc2 = style->light_gc[state_type];
1630 gc3 = style->black_gc;
1631 gc4 = style->bg_gc[state_type];
1633 case GTK_SHADOW_ETCHED_IN:
1634 gc1 = style->light_gc[state_type];
1635 gc2 = style->dark_gc[state_type];
1639 case GTK_SHADOW_ETCHED_OUT:
1640 gc1 = style->dark_gc[state_type];
1641 gc2 = style->light_gc[state_type];
1649 if ((width == -1) && (height == -1))
1650 gdk_window_get_size (window, &width, &height);
1651 else if (width == -1)
1652 gdk_window_get_size (window, &width, NULL);
1653 else if (height == -1)
1654 gdk_window_get_size (window, NULL, &height);
1656 half_width = width / 2;
1657 half_height = height / 2;
1661 gdk_gc_set_clip_rectangle (gc1, area);
1662 gdk_gc_set_clip_rectangle (gc2, area);
1665 gdk_gc_set_clip_rectangle (gc3, area);
1666 gdk_gc_set_clip_rectangle (gc4, area);
1675 points[0].x = x + half_width;
1678 points[1].y = y + height - 1;
1679 points[2].x = x + width - 1;
1680 points[2].y = y + height - 1;
1682 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1685 switch (shadow_type)
1688 case GTK_SHADOW_OUT:
1690 gdk_draw_line (window, gc1,
1691 x + 1, y + height - 2,
1692 x + width - 2, y + height - 2);
1693 gdk_draw_line (window, gc3,
1694 x + 0, y + height - 1,
1695 x + width - 1, y + height - 1);
1697 gdk_draw_line (window, gc1,
1698 x + width - 2, y + height - 1,
1699 x + half_width, y + 1);
1700 gdk_draw_line (window, gc3,
1701 x + width - 1, y + height - 1,
1704 gdk_draw_line (window, gc4,
1705 x + half_width, y + 1,
1706 x + 1, y + height - 1);
1707 gdk_draw_line (window, gc2,
1712 case GTK_SHADOW_ETCHED_IN:
1713 case GTK_SHADOW_ETCHED_OUT:
1714 gdk_draw_line (window, gc1,
1715 x + half_width, y + 1,
1716 x + 1, y + height - 1);
1717 gdk_draw_line (window, gc1,
1718 x + 1, y + height - 1,
1719 x + width - 1, y + height - 1);
1720 gdk_draw_line (window, gc1,
1721 x + width - 1, y + height - 1,
1722 x + half_width + 1, y + 1);
1724 points[0].x = x + half_width;
1727 points[1].y = y + height - 2;
1728 points[2].x = x + width - 2;
1729 points[2].y = y + height - 2;
1731 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1739 case GTK_ARROW_DOWN:
1742 points[0].x = x + width - 1;
1746 points[2].x = x + half_width;
1747 points[2].y = y + height - 1;
1749 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1751 switch (shadow_type)
1754 case GTK_SHADOW_OUT:
1755 gdk_draw_line (window, gc4,
1757 y + 1, x + 1, y + 1);
1758 gdk_draw_line (window, gc2,
1762 gdk_draw_line (window, gc4,
1764 x + half_width, y + height - 2);
1765 gdk_draw_line (window, gc2,
1767 x + half_width, y + height - 1);
1769 gdk_draw_line (window, gc1,
1770 x + half_width, y + height - 2,
1772 gdk_draw_line (window, gc3,
1773 x + half_width, y + height - 1,
1777 case GTK_SHADOW_ETCHED_IN:
1778 case GTK_SHADOW_ETCHED_OUT:
1779 gdk_draw_line (window, gc1,
1780 x + width - 1, y + 1,
1782 gdk_draw_line (window, gc1,
1784 x + half_width + 1, y + height - 1);
1785 gdk_draw_line (window, gc1,
1786 x + half_width + 1, y + height - 2,
1789 points[0].x = x + width - 2;
1793 points[2].x = x + half_width;
1794 points[2].y = y + height - 2;
1796 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1803 case GTK_ARROW_LEFT:
1807 points[0].y = y + half_height;
1808 points[1].x = x + width - 1;
1809 points[1].y = y + height - 1;
1810 points[2].x = x + width - 1;
1813 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1816 switch (shadow_type)
1819 case GTK_SHADOW_OUT:
1820 gdk_draw_line (window, gc1,
1821 x + 1, y + half_height,
1822 x + width - 1, y + height - 1);
1823 gdk_draw_line (window, gc3,
1825 x + width - 1, y + height - 1);
1827 gdk_draw_line (window, gc1,
1828 x + width - 2, y + height - 1,
1829 x + width - 2, y + 1);
1830 gdk_draw_line (window, gc3,
1831 x + width - 1, y + height - 1,
1834 gdk_draw_line (window, gc4,
1835 x + width - 1, y + 1,
1836 x + 1, y + half_height);
1837 gdk_draw_line (window, gc2,
1839 x, y + half_height);
1842 case GTK_SHADOW_ETCHED_IN:
1843 case GTK_SHADOW_ETCHED_OUT:
1844 gdk_draw_line (window, gc1,
1845 x + width - 1, y + 1,
1846 x + 1, y + half_height);
1847 gdk_draw_line (window, gc1,
1848 x + 1, y + half_height + 1,
1849 x + width - 1, y + height - 1);
1850 gdk_draw_line (window, gc1,
1851 x + width - 1, y + height - 1,
1852 x + width - 1, y + 1);
1854 points[0].x = x + width - 2;
1857 points[1].y = y + half_height;
1858 points[2].x = x + width - 2;
1859 points[2].y = y + height - 2;
1861 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1868 case GTK_ARROW_RIGHT:
1871 points[0].x = x + width - 1;
1872 points[0].y = y + half_height;
1876 points[2].y = y + height - 1;
1878 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1881 switch (shadow_type)
1884 case GTK_SHADOW_OUT:
1885 gdk_draw_line (window, gc4,
1886 x + width - 1, y + half_height,
1888 gdk_draw_line (window, gc2,
1889 x + width - 1, y + half_height,
1891 gdk_draw_line (window, gc4,
1893 x + 1, y + height - 2);
1894 gdk_draw_line (window, gc2,
1898 gdk_draw_line (window, gc1,
1899 x + 1, y + height - 2,
1900 x + width - 1, y + half_height);
1901 gdk_draw_line (window, gc3,
1903 x + width - 1, y + half_height);
1906 case GTK_SHADOW_ETCHED_IN:
1907 case GTK_SHADOW_ETCHED_OUT:
1908 gdk_draw_line (window, gc1,
1909 x + width - 1, y + half_height + 1,
1911 gdk_draw_line (window, gc1,
1913 x + 1, y + height - 1);
1914 gdk_draw_line (window, gc1,
1915 x + 1, y + height - 1,
1916 x + width - 1, y + half_height + 1);
1918 points[0].x = x + width - 2;
1919 points[0].y = y + half_height;
1923 points[2].y = y + height - 1;
1925 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1936 gdk_gc_set_clip_rectangle (gc1, NULL);
1937 gdk_gc_set_clip_rectangle (gc2, NULL);
1940 gdk_gc_set_clip_rectangle (gc3, NULL);
1941 gdk_gc_set_clip_rectangle (gc4, NULL);
1947 gtk_default_draw_diamond (GtkStyle *style,
1949 GtkStateType state_type,
1950 GtkShadowType shadow_type,
1962 g_return_if_fail (style != NULL);
1963 g_return_if_fail (window != NULL);
1965 if ((width == -1) && (height == -1))
1966 gdk_window_get_size (window, &width, &height);
1967 else if (width == -1)
1968 gdk_window_get_size (window, &width, NULL);
1969 else if (height == -1)
1970 gdk_window_get_size (window, NULL, &height);
1972 half_width = width / 2;
1973 half_height = height / 2;
1977 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1978 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
1979 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1980 gdk_gc_set_clip_rectangle (style->black_gc, area);
1982 switch (shadow_type)
1985 gdk_draw_line (window, style->bg_gc[state_type],
1986 x + 2, y + half_height,
1987 x + half_width, y + height - 2);
1988 gdk_draw_line (window, style->bg_gc[state_type],
1989 x + half_width, y + height - 2,
1990 x + width - 2, y + half_height);
1991 gdk_draw_line (window, style->light_gc[state_type],
1992 x + 1, y + half_height,
1993 x + half_width, y + height - 1);
1994 gdk_draw_line (window, style->light_gc[state_type],
1995 x + half_width, y + height - 1,
1996 x + width - 1, y + half_height);
1997 gdk_draw_line (window, style->light_gc[state_type],
1999 x + half_width, y + height);
2000 gdk_draw_line (window, style->light_gc[state_type],
2001 x + half_width, y + height,
2002 x + width, y + half_height);
2004 gdk_draw_line (window, style->black_gc,
2005 x + 2, y + half_height,
2006 x + half_width, y + 2);
2007 gdk_draw_line (window, style->black_gc,
2008 x + half_width, y + 2,
2009 x + width - 2, y + half_height);
2010 gdk_draw_line (window, style->dark_gc[state_type],
2011 x + 1, y + half_height,
2012 x + half_width, y + 1);
2013 gdk_draw_line (window, style->dark_gc[state_type],
2014 x + half_width, y + 1,
2015 x + width - 1, y + half_height);
2016 gdk_draw_line (window, style->dark_gc[state_type],
2019 gdk_draw_line (window, style->dark_gc[state_type],
2021 x + width, y + half_height);
2023 case GTK_SHADOW_OUT:
2024 gdk_draw_line (window, style->dark_gc[state_type],
2025 x + 2, y + half_height,
2026 x + half_width, y + height - 2);
2027 gdk_draw_line (window, style->dark_gc[state_type],
2028 x + half_width, y + height - 2,
2029 x + width - 2, y + half_height);
2030 gdk_draw_line (window, style->dark_gc[state_type],
2031 x + 1, y + half_height,
2032 x + half_width, y + height - 1);
2033 gdk_draw_line (window, style->dark_gc[state_type],
2034 x + half_width, y + height - 1,
2035 x + width - 1, y + half_height);
2036 gdk_draw_line (window, style->black_gc,
2038 x + half_width, y + height);
2039 gdk_draw_line (window, style->black_gc,
2040 x + half_width, y + height,
2041 x + width, y + half_height);
2043 gdk_draw_line (window, style->bg_gc[state_type],
2044 x + 2, y + half_height,
2045 x + half_width, y + 2);
2046 gdk_draw_line (window, style->bg_gc[state_type],
2047 x + half_width, y + 2,
2048 x + width - 2, y + half_height);
2049 gdk_draw_line (window, style->light_gc[state_type],
2050 x + 1, y + half_height,
2051 x + half_width, y + 1);
2052 gdk_draw_line (window, style->light_gc[state_type],
2053 x + half_width, y + 1,
2054 x + width - 1, y + half_height);
2055 gdk_draw_line (window, style->light_gc[state_type],
2058 gdk_draw_line (window, style->light_gc[state_type],
2060 x + width, y + half_height);
2067 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
2068 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2069 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
2070 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2075 gtk_default_draw_oval (GtkStyle *style,
2077 GtkStateType state_type,
2078 GtkShadowType shadow_type,
2087 g_return_if_fail (style != NULL);
2088 g_return_if_fail (window != NULL);
2090 g_warning ("gtk_default_draw_oval(): FIXME, this function is currently unimplemented");
2094 gtk_default_draw_string (GtkStyle *style,
2096 GtkStateType state_type,
2102 const gchar *string)
2104 g_return_if_fail (style != NULL);
2105 g_return_if_fail (window != NULL);
2109 gdk_gc_set_clip_rectangle (style->white_gc, area);
2110 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], area);
2113 if (state_type == GTK_STATE_INSENSITIVE)
2114 gdk_draw_string (window, style->font, style->white_gc, x + 1, y + 1, string);
2116 gdk_draw_string (window, style->font, style->fg_gc[state_type], x, y, string);
2120 gdk_gc_set_clip_rectangle (style->white_gc, NULL);
2121 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], NULL);
2126 gtk_default_draw_box (GtkStyle *style,
2128 GtkStateType state_type,
2129 GtkShadowType shadow_type,
2138 g_return_if_fail (style != NULL);
2139 g_return_if_fail (window != NULL);
2141 if (width == -1 && height == -1)
2142 gdk_window_get_size (window, &width, &height);
2143 else if (width == -1)
2144 gdk_window_get_size (window, &width, NULL);
2145 else if (height == -1)
2146 gdk_window_get_size (window, NULL, &height);
2148 if (!style->bg_pixmap[state_type] ||
2149 gdk_window_get_type (window) == GDK_WINDOW_PIXMAP)
2152 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
2154 gdk_draw_rectangle (window, style->bg_gc[state_type], TRUE,
2155 x, y, width, height);
2157 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2160 gtk_style_apply_default_background (style, window,
2161 widget && !GTK_WIDGET_NO_WINDOW (widget),
2162 state_type, area, x, y, width, height);
2164 gtk_paint_shadow (style, window, state_type, shadow_type, area, widget, detail,
2165 x, y, width, height);
2169 gtk_default_draw_flat_box (GtkStyle *style,
2171 GtkStateType state_type,
2172 GtkShadowType shadow_type,
2183 g_return_if_fail (style != NULL);
2184 g_return_if_fail (window != NULL);
2186 if (width == -1 && height == -1)
2187 gdk_window_get_size (window, &width, &height);
2188 else if (width == -1)
2189 gdk_window_get_size (window, &width, NULL);
2190 else if (height == -1)
2191 gdk_window_get_size (window, NULL, &height);
2195 if (!strcmp ("text", detail) && state_type == GTK_STATE_SELECTED)
2196 gc1 = style->bg_gc[GTK_STATE_SELECTED];
2197 else if (!strcmp ("viewportbin", detail))
2198 gc1 = style->bg_gc[GTK_STATE_NORMAL];
2199 else if (!strcmp ("entry_bg", detail))
2200 gc1 = style->base_gc[state_type];
2202 gc1 = style->bg_gc[state_type];
2205 gc1 = style->bg_gc[state_type];
2207 if (!style->bg_pixmap[state_type] || gc1 != style->bg_gc[state_type] ||
2208 gdk_window_get_type (window) == GDK_WINDOW_PIXMAP)
2211 gdk_gc_set_clip_rectangle (gc1, area);
2213 gdk_draw_rectangle (window, gc1, TRUE,
2214 x, y, width, height);
2216 if (detail && !strcmp ("tooltip", detail))
2217 gdk_draw_rectangle (window, style->black_gc, FALSE,
2218 x, y, width - 1, height - 1);
2221 gdk_gc_set_clip_rectangle (gc1, NULL);
2224 gtk_style_apply_default_background (style, window,
2225 widget && !GTK_WIDGET_NO_WINDOW (widget),
2226 state_type, area, x, y, width, height);
2230 gtk_default_draw_check (GtkStyle *style,
2232 GtkStateType state_type,
2233 GtkShadowType shadow_type,
2242 gtk_paint_box (style, window, state_type, shadow_type, area, widget, detail,
2243 x, y, width, height);
2247 gtk_default_draw_option (GtkStyle *style,
2249 GtkStateType state_type,
2250 GtkShadowType shadow_type,
2259 gtk_paint_diamond (style, window, state_type, shadow_type, area, widget,
2260 detail, x, y, width, height);
2264 gtk_default_draw_cross (GtkStyle *style,
2266 GtkStateType state_type,
2267 GtkShadowType shadow_type,
2276 g_return_if_fail (style != NULL);
2277 g_return_if_fail (window != NULL);
2279 g_warning ("gtk_default_draw_cross(): FIXME, this function is currently unimplemented");
2283 gtk_default_draw_ramp (GtkStyle *style,
2285 GtkStateType state_type,
2286 GtkShadowType shadow_type,
2290 GtkArrowType arrow_type,
2296 g_return_if_fail (style != NULL);
2297 g_return_if_fail (window != NULL);
2299 g_warning ("gtk_default_draw_ramp(): FIXME, this function is currently unimplemented");
2303 gtk_default_draw_tab (GtkStyle *style,
2305 GtkStateType state_type,
2306 GtkShadowType shadow_type,
2315 g_return_if_fail (style != NULL);
2316 g_return_if_fail (window != NULL);
2318 gtk_paint_box (style, window, state_type, shadow_type, area, widget, detail,
2319 x, y, width, height);
2323 gtk_default_draw_shadow_gap (GtkStyle *style,
2325 GtkStateType state_type,
2326 GtkShadowType shadow_type,
2334 GtkPositionType gap_side,
2343 g_return_if_fail (style != NULL);
2344 g_return_if_fail (window != NULL);
2346 if (width == -1 && height == -1)
2347 gdk_window_get_size (window, &width, &height);
2348 else if (width == -1)
2349 gdk_window_get_size (window, &width, NULL);
2350 else if (height == -1)
2351 gdk_window_get_size (window, NULL, &height);
2353 switch (shadow_type)
2355 case GTK_SHADOW_NONE:
2358 gc1 = style->dark_gc[state_type];
2359 gc2 = style->black_gc;
2360 gc3 = style->bg_gc[state_type];
2361 gc4 = style->light_gc[state_type];
2363 case GTK_SHADOW_ETCHED_IN:
2364 gc1 = style->dark_gc[state_type];
2365 gc2 = style->light_gc[state_type];
2366 gc3 = style->dark_gc[state_type];
2367 gc4 = style->light_gc[state_type];
2369 case GTK_SHADOW_OUT:
2370 gc1 = style->light_gc[state_type];
2371 gc2 = style->bg_gc[state_type];
2372 gc3 = style->dark_gc[state_type];
2373 gc4 = style->black_gc;
2375 case GTK_SHADOW_ETCHED_OUT:
2376 gc1 = style->light_gc[state_type];
2377 gc2 = style->dark_gc[state_type];
2378 gc3 = style->light_gc[state_type];
2379 gc4 = style->dark_gc[state_type];
2384 gdk_gc_set_clip_rectangle (gc1, area);
2385 gdk_gc_set_clip_rectangle (gc2, area);
2386 gdk_gc_set_clip_rectangle (gc3, area);
2387 gdk_gc_set_clip_rectangle (gc4, area);
2390 switch (shadow_type)
2392 case GTK_SHADOW_NONE:
2394 case GTK_SHADOW_OUT:
2395 case GTK_SHADOW_ETCHED_IN:
2396 case GTK_SHADOW_ETCHED_OUT:
2400 gdk_draw_line (window, gc1,
2401 x, y, x, y + height - 1);
2402 gdk_draw_line (window, gc2,
2403 x + 1, y, x + 1, y + height - 2);
2405 gdk_draw_line (window, gc3,
2406 x + 1, y + height - 2, x + width - 2, y + height - 2);
2407 gdk_draw_line (window, gc3,
2408 x + width - 2, y, x + width - 2, y + height - 2);
2409 gdk_draw_line (window, gc4,
2410 x, y + height - 1, x + width - 1, y + height - 1);
2411 gdk_draw_line (window, gc4,
2412 x + width - 1, y, x + width - 1, y + height - 1);
2415 gdk_draw_line (window, gc1,
2416 x, y, x + gap_x - 1, y);
2417 gdk_draw_line (window, gc2,
2418 x + 1, y + 1, x + gap_x - 1, y + 1);
2419 gdk_draw_line (window, gc2,
2420 x + gap_x, y, x + gap_x, y);
2422 if ((width - (gap_x + gap_width)) > 0)
2424 gdk_draw_line (window, gc1,
2425 x + gap_x + gap_width, y, x + width - 2, y);
2426 gdk_draw_line (window, gc2,
2427 x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
2428 gdk_draw_line (window, gc2,
2429 x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
2432 case GTK_POS_BOTTOM:
2433 gdk_draw_line (window, gc1,
2434 x, y, x + width - 1, y);
2435 gdk_draw_line (window, gc1,
2436 x, y, x, y + height - 1);
2437 gdk_draw_line (window, gc2,
2438 x + 1, y + 1, x + width - 2, y + 1);
2439 gdk_draw_line (window, gc2,
2440 x + 1, y + 1, x + 1, y + height - 1);
2442 gdk_draw_line (window, gc3,
2443 x + width - 2, y + 1, x + width - 2, y + height - 1);
2444 gdk_draw_line (window, gc4,
2445 x + width - 1, y, x + width - 1, y + height - 1);
2448 gdk_draw_line (window, gc4,
2449 x, y + height - 1, x + gap_x - 1, y + height - 1);
2450 gdk_draw_line (window, gc3,
2451 x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
2452 gdk_draw_line (window, gc3,
2453 x + gap_x, y + height - 1, x + gap_x, y + height - 1);
2455 if ((width - (gap_x + gap_width)) > 0)
2457 gdk_draw_line (window, gc4,
2458 x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
2459 gdk_draw_line (window, gc3,
2460 x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
2461 gdk_draw_line (window, gc3,
2462 x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
2466 gdk_draw_line (window, gc1,
2467 x, y, x + width - 1, y);
2468 gdk_draw_line (window, gc2,
2469 x, y + 1, x + width - 2, y + 1);
2471 gdk_draw_line (window, gc3,
2472 x, y + height - 2, x + width - 2, y + height - 2);
2473 gdk_draw_line (window, gc3,
2474 x + width - 2, y + 1, x + width - 2, y + height - 2);
2475 gdk_draw_line (window, gc4,
2476 x, y + height - 1, x + width - 1, y + height - 1);
2477 gdk_draw_line (window, gc4,
2478 x + width - 1, y, x + width - 1, y + height - 1);
2481 gdk_draw_line (window, gc1,
2482 x, y, x, y + gap_x - 1);
2483 gdk_draw_line (window, gc2,
2484 x + 1, y + 1, x + 1, y + gap_x - 1);
2485 gdk_draw_line (window, gc2,
2486 x, y + gap_x, x, y + gap_x);
2488 if ((width - (gap_x + gap_width)) > 0)
2490 gdk_draw_line (window, gc1,
2491 x, y + gap_x + gap_width, x, y + height - 2);
2492 gdk_draw_line (window, gc2,
2493 x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
2494 gdk_draw_line (window, gc2,
2495 x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
2499 gdk_draw_line (window, gc1,
2500 x, y, x + width - 1, y);
2501 gdk_draw_line (window, gc1,
2502 x, y, x, y + height - 1);
2503 gdk_draw_line (window, gc2,
2504 x + 1, y + 1, x + width - 1, y + 1);
2505 gdk_draw_line (window, gc2,
2506 x + 1, y + 1, x + 1, y + height - 2);
2508 gdk_draw_line (window, gc3,
2509 x + 1, y + height - 2, x + width - 1, y + height - 2);
2510 gdk_draw_line (window, gc4,
2511 x, y + height - 1, x + width - 1, y + height - 1);
2514 gdk_draw_line (window, gc4,
2515 x + width - 1, y, x + width - 1, y + gap_x - 1);
2516 gdk_draw_line (window, gc3,
2517 x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
2518 gdk_draw_line (window, gc3,
2519 x + width - 1, y + gap_x, x + width - 1, y + gap_x);
2521 if ((width - (gap_x + gap_width)) > 0)
2523 gdk_draw_line (window, gc4,
2524 x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
2525 gdk_draw_line (window, gc3,
2526 x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
2527 gdk_draw_line (window, gc3,
2528 x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
2536 gdk_gc_set_clip_rectangle (gc1, NULL);
2537 gdk_gc_set_clip_rectangle (gc2, NULL);
2538 gdk_gc_set_clip_rectangle (gc3, NULL);
2539 gdk_gc_set_clip_rectangle (gc4, NULL);
2544 gtk_default_draw_box_gap (GtkStyle *style,
2546 GtkStateType state_type,
2547 GtkShadowType shadow_type,
2555 GtkPositionType gap_side,
2564 g_return_if_fail (style != NULL);
2565 g_return_if_fail (window != NULL);
2567 gtk_style_apply_default_background (style, window,
2568 widget && !GTK_WIDGET_NO_WINDOW (widget),
2569 state_type, area, x, y, width, height);
2571 if (width == -1 && height == -1)
2572 gdk_window_get_size (window, &width, &height);
2573 else if (width == -1)
2574 gdk_window_get_size (window, &width, NULL);
2575 else if (height == -1)
2576 gdk_window_get_size (window, NULL, &height);
2578 switch (shadow_type)
2580 case GTK_SHADOW_NONE:
2583 gc1 = style->dark_gc[state_type];
2584 gc2 = style->black_gc;
2585 gc3 = style->bg_gc[state_type];
2586 gc4 = style->light_gc[state_type];
2588 case GTK_SHADOW_ETCHED_IN:
2589 gc1 = style->dark_gc[state_type];
2590 gc2 = style->light_gc[state_type];
2591 gc3 = style->dark_gc[state_type];
2592 gc4 = style->light_gc[state_type];
2594 case GTK_SHADOW_OUT:
2595 gc1 = style->light_gc[state_type];
2596 gc2 = style->bg_gc[state_type];
2597 gc3 = style->dark_gc[state_type];
2598 gc4 = style->black_gc;
2600 case GTK_SHADOW_ETCHED_OUT:
2601 gc1 = style->light_gc[state_type];
2602 gc2 = style->dark_gc[state_type];
2603 gc3 = style->light_gc[state_type];
2604 gc4 = style->dark_gc[state_type];
2610 gdk_gc_set_clip_rectangle (gc1, area);
2611 gdk_gc_set_clip_rectangle (gc2, area);
2612 gdk_gc_set_clip_rectangle (gc3, area);
2613 gdk_gc_set_clip_rectangle (gc4, area);
2616 switch (shadow_type)
2618 case GTK_SHADOW_NONE:
2620 case GTK_SHADOW_OUT:
2621 case GTK_SHADOW_ETCHED_IN:
2622 case GTK_SHADOW_ETCHED_OUT:
2626 gdk_draw_line (window, gc1,
2627 x, y, x, y + height - 1);
2628 gdk_draw_line (window, gc2,
2629 x + 1, y, x + 1, y + height - 2);
2631 gdk_draw_line (window, gc3,
2632 x + 1, y + height - 2, x + width - 2, y + height - 2);
2633 gdk_draw_line (window, gc3,
2634 x + width - 2, y, x + width - 2, y + height - 2);
2635 gdk_draw_line (window, gc4,
2636 x, y + height - 1, x + width - 1, y + height - 1);
2637 gdk_draw_line (window, gc4,
2638 x + width - 1, y, x + width - 1, y + height - 1);
2641 gdk_draw_line (window, gc1,
2642 x, y, x + gap_x - 1, y);
2643 gdk_draw_line (window, gc2,
2644 x + 1, y + 1, x + gap_x - 1, y + 1);
2645 gdk_draw_line (window, gc2,
2646 x + gap_x, y, x + gap_x, y);
2648 if ((width - (gap_x + gap_width)) > 0)
2650 gdk_draw_line (window, gc1,
2651 x + gap_x + gap_width, y, x + width - 2, y);
2652 gdk_draw_line (window, gc2,
2653 x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
2654 gdk_draw_line (window, gc2,
2655 x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
2658 case GTK_POS_BOTTOM:
2659 gdk_draw_line (window, gc1,
2660 x, y, x + width - 1, y);
2661 gdk_draw_line (window, gc1,
2662 x, y, x, y + height - 1);
2663 gdk_draw_line (window, gc2,
2664 x + 1, y + 1, x + width - 2, y + 1);
2665 gdk_draw_line (window, gc2,
2666 x + 1, y + 1, x + 1, y + height - 1);
2668 gdk_draw_line (window, gc3,
2669 x + width - 2, y + 1, x + width - 2, y + height - 1);
2670 gdk_draw_line (window, gc4,
2671 x + width - 1, y, x + width - 1, y + height - 1);
2674 gdk_draw_line (window, gc4,
2675 x, y + height - 1, x + gap_x - 1, y + height - 1);
2676 gdk_draw_line (window, gc3,
2677 x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
2678 gdk_draw_line (window, gc3,
2679 x + gap_x, y + height - 1, x + gap_x, y + height - 1);
2681 if ((width - (gap_x + gap_width)) > 0)
2683 gdk_draw_line (window, gc4,
2684 x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
2685 gdk_draw_line (window, gc3,
2686 x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
2687 gdk_draw_line (window, gc3,
2688 x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
2692 gdk_draw_line (window, gc1,
2693 x, y, x + width - 1, y);
2694 gdk_draw_line (window, gc2,
2695 x, y + 1, x + width - 2, y + 1);
2697 gdk_draw_line (window, gc3,
2698 x, y + height - 2, x + width - 2, y + height - 2);
2699 gdk_draw_line (window, gc3,
2700 x + width - 2, y + 1, x + width - 2, y + height - 2);
2701 gdk_draw_line (window, gc4,
2702 x, y + height - 1, x + width - 1, y + height - 1);
2703 gdk_draw_line (window, gc4,
2704 x + width - 1, y, x + width - 1, y + height - 1);
2707 gdk_draw_line (window, gc1,
2708 x, y, x, y + gap_x - 1);
2709 gdk_draw_line (window, gc2,
2710 x + 1, y + 1, x + 1, y + gap_x - 1);
2711 gdk_draw_line (window, gc2,
2712 x, y + gap_x, x, y + gap_x);
2714 if ((width - (gap_x + gap_width)) > 0)
2716 gdk_draw_line (window, gc1,
2717 x, y + gap_x + gap_width, x, y + height - 2);
2718 gdk_draw_line (window, gc2,
2719 x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
2720 gdk_draw_line (window, gc2,
2721 x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
2725 gdk_draw_line (window, gc1,
2726 x, y, x + width - 1, y);
2727 gdk_draw_line (window, gc1,
2728 x, y, x, y + height - 1);
2729 gdk_draw_line (window, gc2,
2730 x + 1, y + 1, x + width - 1, y + 1);
2731 gdk_draw_line (window, gc2,
2732 x + 1, y + 1, x + 1, y + height - 2);
2734 gdk_draw_line (window, gc3,
2735 x + 1, y + height - 2, x + width - 1, y + height - 2);
2736 gdk_draw_line (window, gc4,
2737 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 + gap_x - 1);
2742 gdk_draw_line (window, gc3,
2743 x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
2744 gdk_draw_line (window, gc3,
2745 x + width - 1, y + gap_x, x + width - 1, y + gap_x);
2747 if ((width - (gap_x + gap_width)) > 0)
2749 gdk_draw_line (window, gc4,
2750 x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
2751 gdk_draw_line (window, gc3,
2752 x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
2753 gdk_draw_line (window, gc3,
2754 x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
2762 gdk_gc_set_clip_rectangle (gc1, NULL);
2763 gdk_gc_set_clip_rectangle (gc2, NULL);
2764 gdk_gc_set_clip_rectangle (gc3, NULL);
2765 gdk_gc_set_clip_rectangle (gc4, NULL);
2770 gtk_default_draw_extension (GtkStyle *style,
2772 GtkStateType state_type,
2773 GtkShadowType shadow_type,
2781 GtkPositionType gap_side)
2788 g_return_if_fail (style != NULL);
2789 g_return_if_fail (window != NULL);
2791 gtk_style_apply_default_background (style, window,
2792 widget && !GTK_WIDGET_NO_WINDOW (widget),
2793 GTK_STATE_NORMAL, area, x, y, width, height);
2795 if (width == -1 && height == -1)
2796 gdk_window_get_size (window, &width, &height);
2797 else if (width == -1)
2798 gdk_window_get_size (window, &width, NULL);
2799 else if (height == -1)
2800 gdk_window_get_size (window, NULL, &height);
2802 switch (shadow_type)
2804 case GTK_SHADOW_NONE:
2807 gc1 = style->dark_gc[state_type];
2808 gc2 = style->black_gc;
2809 gc3 = style->bg_gc[state_type];
2810 gc4 = style->light_gc[state_type];
2812 case GTK_SHADOW_ETCHED_IN:
2813 gc1 = style->dark_gc[state_type];
2814 gc2 = style->light_gc[state_type];
2815 gc3 = style->dark_gc[state_type];
2816 gc4 = style->light_gc[state_type];
2818 case GTK_SHADOW_OUT:
2819 gc1 = style->light_gc[state_type];
2820 gc2 = style->bg_gc[state_type];
2821 gc3 = style->dark_gc[state_type];
2822 gc4 = style->black_gc;
2824 case GTK_SHADOW_ETCHED_OUT:
2825 gc1 = style->light_gc[state_type];
2826 gc2 = style->dark_gc[state_type];
2827 gc3 = style->light_gc[state_type];
2828 gc4 = style->dark_gc[state_type];
2834 gdk_gc_set_clip_rectangle (gc1, area);
2835 gdk_gc_set_clip_rectangle (gc2, area);
2836 gdk_gc_set_clip_rectangle (gc3, area);
2837 gdk_gc_set_clip_rectangle (gc4, area);
2840 switch (shadow_type)
2842 case GTK_SHADOW_NONE:
2844 case GTK_SHADOW_OUT:
2845 case GTK_SHADOW_ETCHED_IN:
2846 case GTK_SHADOW_ETCHED_OUT:
2850 gtk_style_apply_default_background (style, window,
2851 widget && !GTK_WIDGET_NO_WINDOW (widget),
2853 x + style->klass->xthickness,
2855 width - (2 * style->klass->xthickness),
2856 height - (style->klass->ythickness));
2857 gdk_draw_line (window, gc1,
2858 x, y, x, y + height - 2);
2859 gdk_draw_line (window, gc2,
2860 x + 1, y, x + 1, y + height - 2);
2862 gdk_draw_line (window, gc3,
2863 x + 2, y + height - 2, x + width - 2, y + height - 2);
2864 gdk_draw_line (window, gc3,
2865 x + width - 2, y, x + width - 2, y + height - 2);
2866 gdk_draw_line (window, gc4,
2867 x + 1, y + height - 1, x + width - 2, y + height - 1);
2868 gdk_draw_line (window, gc4,
2869 x + width - 1, y, x + width - 1, y + height - 2);
2871 case GTK_POS_BOTTOM:
2872 gtk_style_apply_default_background (style, window,
2873 widget && !GTK_WIDGET_NO_WINDOW (widget),
2875 x + style->klass->xthickness,
2876 y + style->klass->ythickness,
2877 width - (2 * style->klass->xthickness),
2878 height - (style->klass->ythickness));
2879 gdk_draw_line (window, gc1,
2880 x + 1, y, x + width - 2, y);
2881 gdk_draw_line (window, gc1,
2882 x, y + 1, x, y + height - 1);
2883 gdk_draw_line (window, gc2,
2884 x + 1, y + 1, x + width - 2, y + 1);
2885 gdk_draw_line (window, gc2,
2886 x + 1, y + 1, x + 1, y + height - 1);
2888 gdk_draw_line (window, gc3,
2889 x + width - 2, y + 2, x + width - 2, y + height - 1);
2890 gdk_draw_line (window, gc4,
2891 x + width - 1, y + 1, x + width - 1, y + height - 1);
2894 gtk_style_apply_default_background (style, window,
2895 widget && !GTK_WIDGET_NO_WINDOW (widget),
2898 y + style->klass->ythickness,
2899 width - (style->klass->xthickness),
2900 height - (2 * style->klass->ythickness));
2901 gdk_draw_line (window, gc1,
2902 x, y, x + width - 2, y);
2903 gdk_draw_line (window, gc2,
2904 x + 1, y + 1, x + width - 2, y + 1);
2906 gdk_draw_line (window, gc3,
2907 x, y + height - 2, x + width - 2, y + height - 2);
2908 gdk_draw_line (window, gc3,
2909 x + width - 2, y + 2, x + width - 2, y + height - 2);
2910 gdk_draw_line (window, gc4,
2911 x, y + height - 1, x + width - 2, y + height - 1);
2912 gdk_draw_line (window, gc4,
2913 x + width - 1, y + 1, x + width - 1, y + height - 2);
2916 gtk_style_apply_default_background (style, window,
2917 widget && !GTK_WIDGET_NO_WINDOW (widget),
2919 x + style->klass->xthickness,
2920 y + style->klass->ythickness,
2921 width - (style->klass->xthickness),
2922 height - (2 * style->klass->ythickness));
2923 gdk_draw_line (window, gc1,
2924 x + 1, y, x + width - 1, y);
2925 gdk_draw_line (window, gc1,
2926 x, y + 1, x, y + height - 2);
2927 gdk_draw_line (window, gc2,
2928 x + 1, y + 1, x + width - 1, y + 1);
2929 gdk_draw_line (window, gc2,
2930 x + 1, y + 1, x + 1, y + height - 2);
2932 gdk_draw_line (window, gc3,
2933 x + 2, y + height - 2, x + width - 1, y + height - 2);
2934 gdk_draw_line (window, gc4,
2935 x + 1, y + height - 1, x + width - 1, y + height - 1);
2942 gdk_gc_set_clip_rectangle (gc1, NULL);
2943 gdk_gc_set_clip_rectangle (gc2, NULL);
2944 gdk_gc_set_clip_rectangle (gc3, NULL);
2945 gdk_gc_set_clip_rectangle (gc4, NULL);
2950 gtk_default_draw_focus (GtkStyle *style,
2960 g_return_if_fail (style != NULL);
2961 g_return_if_fail (window != NULL);
2963 if (width == -1 && height == -1)
2965 gdk_window_get_size (window, &width, &height);
2969 else if (width == -1)
2971 gdk_window_get_size (window, &width, NULL);
2974 else if (height == -1)
2976 gdk_window_get_size (window, NULL, &height);
2981 gdk_gc_set_clip_rectangle (style->black_gc, area);
2983 if (detail && !strcmp (detail, "add-mode"))
2985 gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_ON_OFF_DASH, 0, 0);
2986 gdk_gc_set_dashes (style->black_gc, 0, "\4\4", 2);
2988 gdk_draw_rectangle (window,
2989 style->black_gc, FALSE,
2990 x, y, width, height);
2992 gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_SOLID, 0, 0);
2996 gdk_draw_rectangle (window,
2997 style->black_gc, FALSE,
2998 x, y, width, height);
3002 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
3006 gtk_default_draw_slider (GtkStyle *style,
3008 GtkStateType state_type,
3009 GtkShadowType shadow_type,
3017 GtkOrientation orientation)
3019 g_return_if_fail (style != NULL);
3020 g_return_if_fail (window != NULL);
3022 if (width == -1 && height == -1)
3023 gdk_window_get_size (window, &width, &height);
3024 else if (width == -1)
3025 gdk_window_get_size (window, &width, NULL);
3026 else if (height == -1)
3027 gdk_window_get_size (window, NULL, &height);
3029 gtk_paint_box (style, window, state_type, shadow_type,
3030 area, widget, detail, x, y, width, height);
3032 if (orientation == GTK_ORIENTATION_HORIZONTAL)
3033 gtk_paint_vline (style, window, state_type, area, widget, detail,
3034 style->klass->ythickness,
3035 height - style->klass->ythickness - 1, width / 2);
3037 gtk_paint_hline (style, window, state_type, area, widget, detail,
3038 style->klass->xthickness,
3039 width - style->klass->xthickness - 1, height / 2);
3043 gtk_default_draw_handle (GtkStyle *style,
3045 GtkStateType state_type,
3046 GtkShadowType shadow_type,
3054 GtkOrientation orientation)
3057 gint xthick, ythick;
3058 GdkGC *light_gc, *dark_gc;
3063 g_return_if_fail (style != NULL);
3064 g_return_if_fail (window != NULL);
3066 if (width == -1 && height == -1)
3067 gdk_window_get_size (window, &width, &height);
3068 else if (width == -1)
3069 gdk_window_get_size (window, &width, NULL);
3070 else if (height == -1)
3071 gdk_window_get_size (window, NULL, &height);
3073 gtk_paint_box (style, window, state_type, shadow_type, area, widget,
3074 detail, x, y, width, height);
3076 light_gc = style->light_gc[state_type];
3077 dark_gc = style->dark_gc[state_type];
3079 xthick = style->klass->xthickness;
3080 ythick = style->klass->ythickness;
3082 rect.x = x + xthick;
3083 rect.y = y + ythick;
3084 rect.width = width - (xthick * 2);
3085 rect.height = height - (ythick * 2);
3088 intersect = gdk_rectangle_intersect (area, &rect, &dest);
3098 #define DRAW_POINT(w, gc, clip, xx, yy) \
3100 if ((xx) >= (clip).x \
3101 && (yy) >= (clip).y \
3102 && (xx) < (clip).x + (clip).width \
3103 && (yy) < (clip).y + (clip).height) \
3104 gdk_draw_point ((w), (gc), (xx), (yy)); \
3107 for (yy = y + ythick; yy < (y + height - ythick); yy += 3)
3108 for (xx = x + xthick; xx < (x + width - xthick); xx += 6)
3110 DRAW_POINT (window, light_gc, dest, xx, yy);
3111 DRAW_POINT (window, dark_gc, dest, xx + 1, yy + 1);
3113 DRAW_POINT (window, light_gc, dest, xx + 3, yy + 1);
3114 DRAW_POINT (window, dark_gc, dest, xx + 4, yy + 2);
3119 gtk_style_shade (GdkColor *a,
3127 red = (gdouble) a->red / 65535.0;
3128 green = (gdouble) a->green / 65535.0;
3129 blue = (gdouble) a->blue / 65535.0;
3131 rgb_to_hls (&red, &green, &blue);
3136 else if (green < 0.0)
3142 else if (blue < 0.0)
3145 hls_to_rgb (&red, &green, &blue);
3147 b->red = red * 65535.0;
3148 b->green = green * 65535.0;
3149 b->blue = blue * 65535.0;
3153 rgb_to_hls (gdouble *r,
3194 l = (max + min) / 2;
3201 s = (max - min) / (max + min);
3203 s = (max - min) / (2 - max - min);
3207 h = (green - blue) / delta;
3208 else if (green == max)
3209 h = 2 + (blue - red) / delta;
3210 else if (blue == max)
3211 h = 4 + (red - green) / delta;
3224 hls_to_rgb (gdouble *h,
3237 if (lightness <= 0.5)
3238 m2 = lightness * (1 + saturation);
3240 m2 = lightness + saturation - lightness * saturation;
3241 m1 = 2 * lightness - m2;
3243 if (saturation == 0)
3258 r = m1 + (m2 - m1) * hue / 60;
3262 r = m1 + (m2 - m1) * (240 - hue) / 60;
3273 g = m1 + (m2 - m1) * hue / 60;
3277 g = m1 + (m2 - m1) * (240 - hue) / 60;
3288 b = m1 + (m2 - m1) * hue / 60;
3292 b = m1 + (m2 - m1) * (240 - hue) / 60;
3303 gtk_paint_hline (GtkStyle *style,
3305 GtkStateType state_type,
3313 g_return_if_fail (style != NULL);
3314 g_return_if_fail (style->klass != NULL);
3315 g_return_if_fail (style->klass->draw_hline != NULL);
3317 style->klass->draw_hline (style, window, state_type, area, widget, detail, x1, x2, y);
3321 gtk_paint_vline (GtkStyle *style,
3323 GtkStateType state_type,
3331 g_return_if_fail (style != NULL);
3332 g_return_if_fail (style->klass != NULL);
3333 g_return_if_fail (style->klass->draw_vline != NULL);
3335 style->klass->draw_vline (style, window, state_type, area, widget, detail, y1, y2, x);
3339 gtk_paint_shadow (GtkStyle *style,
3341 GtkStateType state_type,
3342 GtkShadowType shadow_type,
3351 g_return_if_fail (style != NULL);
3352 g_return_if_fail (style->klass != NULL);
3353 g_return_if_fail (style->klass->draw_shadow != NULL);
3355 style->klass->draw_shadow (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3359 gtk_paint_polygon (GtkStyle *style,
3361 GtkStateType state_type,
3362 GtkShadowType shadow_type,
3370 g_return_if_fail (style != NULL);
3371 g_return_if_fail (style->klass != NULL);
3372 g_return_if_fail (style->klass->draw_shadow != NULL);
3374 style->klass->draw_polygon (style, window, state_type, shadow_type, area, widget, detail, points, npoints, fill);
3378 gtk_paint_arrow (GtkStyle *style,
3380 GtkStateType state_type,
3381 GtkShadowType shadow_type,
3385 GtkArrowType arrow_type,
3392 g_return_if_fail (style != NULL);
3393 g_return_if_fail (style->klass != NULL);
3394 g_return_if_fail (style->klass->draw_arrow != NULL);
3396 style->klass->draw_arrow (style, window, state_type, shadow_type, area, widget, detail, arrow_type, fill, x, y, width, height);
3400 gtk_paint_diamond (GtkStyle *style,
3402 GtkStateType state_type,
3403 GtkShadowType shadow_type,
3412 g_return_if_fail (style != NULL);
3413 g_return_if_fail (style->klass != NULL);
3414 g_return_if_fail (style->klass->draw_diamond != NULL);
3416 style->klass->draw_diamond (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3420 gtk_paint_oval (GtkStyle *style,
3422 GtkStateType state_type,
3423 GtkShadowType shadow_type,
3432 g_return_if_fail (style != NULL);
3433 g_return_if_fail (style->klass != NULL);
3434 g_return_if_fail (style->klass->draw_oval != NULL);
3436 style->klass->draw_oval (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3440 gtk_paint_string (GtkStyle *style,
3442 GtkStateType state_type,
3448 const gchar *string)
3450 g_return_if_fail (style != NULL);
3451 g_return_if_fail (style->klass != NULL);
3452 g_return_if_fail (style->klass->draw_string != NULL);
3454 style->klass->draw_string (style, window, state_type, area, widget, detail, x, y, string);
3458 gtk_paint_box (GtkStyle *style,
3460 GtkStateType state_type,
3461 GtkShadowType shadow_type,
3470 g_return_if_fail (style != NULL);
3471 g_return_if_fail (style->klass != NULL);
3472 g_return_if_fail (style->klass->draw_box != NULL);
3474 style->klass->draw_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3478 gtk_paint_flat_box (GtkStyle *style,
3480 GtkStateType state_type,
3481 GtkShadowType shadow_type,
3490 g_return_if_fail (style != NULL);
3491 g_return_if_fail (style->klass != NULL);
3492 g_return_if_fail (style->klass->draw_flat_box != NULL);
3494 style->klass->draw_flat_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3498 gtk_paint_check (GtkStyle *style,
3500 GtkStateType state_type,
3501 GtkShadowType shadow_type,
3510 g_return_if_fail (style != NULL);
3511 g_return_if_fail (style->klass != NULL);
3512 g_return_if_fail (style->klass->draw_check != NULL);
3514 style->klass->draw_check (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3518 gtk_paint_option (GtkStyle *style,
3520 GtkStateType state_type,
3521 GtkShadowType shadow_type,
3530 g_return_if_fail (style != NULL);
3531 g_return_if_fail (style->klass != NULL);
3532 g_return_if_fail (style->klass->draw_option != NULL);
3534 style->klass->draw_option (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3538 gtk_paint_cross (GtkStyle *style,
3540 GtkStateType state_type,
3541 GtkShadowType shadow_type,
3550 g_return_if_fail (style != NULL);
3551 g_return_if_fail (style->klass != NULL);
3552 g_return_if_fail (style->klass->draw_cross != NULL);
3554 style->klass->draw_cross (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3558 gtk_paint_ramp (GtkStyle *style,
3560 GtkStateType state_type,
3561 GtkShadowType shadow_type,
3565 GtkArrowType arrow_type,
3571 g_return_if_fail (style != NULL);
3572 g_return_if_fail (style->klass != NULL);
3573 g_return_if_fail (style->klass->draw_ramp != NULL);
3575 style->klass->draw_ramp (style, window, state_type, shadow_type, area, widget, detail, arrow_type, x, y, width, height);
3579 gtk_paint_tab (GtkStyle *style,
3581 GtkStateType state_type,
3582 GtkShadowType shadow_type,
3591 g_return_if_fail (style != NULL);
3592 g_return_if_fail (style->klass != NULL);
3593 g_return_if_fail (style->klass->draw_tab != NULL);
3595 style->klass->draw_tab (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3599 gtk_paint_shadow_gap (GtkStyle *style,
3601 GtkStateType state_type,
3602 GtkShadowType shadow_type,
3610 GtkPositionType gap_side,
3614 g_return_if_fail (style != NULL);
3615 g_return_if_fail (style->klass != NULL);
3616 g_return_if_fail (style->klass->draw_shadow_gap != NULL);
3618 style->klass->draw_shadow_gap (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
3623 gtk_paint_box_gap (GtkStyle *style,
3625 GtkStateType state_type,
3626 GtkShadowType shadow_type,
3634 GtkPositionType gap_side,
3638 g_return_if_fail (style != NULL);
3639 g_return_if_fail (style->klass != NULL);
3640 g_return_if_fail (style->klass->draw_box_gap != NULL);
3642 style->klass->draw_box_gap (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
3646 gtk_paint_extension (GtkStyle *style,
3648 GtkStateType state_type,
3649 GtkShadowType shadow_type,
3657 GtkPositionType gap_side)
3659 g_return_if_fail (style != NULL);
3660 g_return_if_fail (style->klass != NULL);
3661 g_return_if_fail (style->klass->draw_extension != NULL);
3663 style->klass->draw_extension (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side);
3667 gtk_paint_focus (GtkStyle *style,
3677 g_return_if_fail (style != NULL);
3678 g_return_if_fail (style->klass != NULL);
3679 g_return_if_fail (style->klass->draw_focus != NULL);
3681 style->klass->draw_focus (style, window, area, widget, detail, x, y, width, height);
3685 gtk_paint_slider (GtkStyle *style,
3687 GtkStateType state_type,
3688 GtkShadowType shadow_type,
3696 GtkOrientation orientation)
3698 g_return_if_fail (style != NULL);
3699 g_return_if_fail (style->klass != NULL);
3700 g_return_if_fail (style->klass->draw_slider != NULL);
3702 style->klass->draw_slider (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
3706 gtk_paint_handle (GtkStyle *style,
3708 GtkStateType state_type,
3709 GtkShadowType shadow_type,
3717 GtkOrientation orientation)
3719 g_return_if_fail (style != NULL);
3720 g_return_if_fail (style->klass != NULL);
3721 g_return_if_fail (style->klass->draw_handle != NULL);
3723 style->klass->draw_handle (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);