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.
23 #include "gtkthemes.h"
24 #include "gtkwidget.h"
25 #include "gtkthemes.h"
26 #include "gtkprivate.h"
27 #include "gdk/gdkprivate.h"
30 #define LIGHTNESS_MULT 1.3
31 #define DARKNESS_MULT 0.7
33 static void gtk_style_init (GtkStyle *style,
34 GdkColormap *colormap,
36 static void gtk_style_destroy (GtkStyle *style);
38 static void gtk_default_draw_hline (GtkStyle *style,
40 GtkStateType state_type,
47 static void gtk_default_draw_vline (GtkStyle *style,
49 GtkStateType state_type,
56 static void gtk_default_draw_shadow (GtkStyle *style,
58 GtkStateType state_type,
59 GtkShadowType shadow_type,
67 static void gtk_default_draw_shadow (GtkStyle *style,
69 GtkStateType state_type,
70 GtkShadowType shadow_type,
78 static void gtk_default_draw_polygon (GtkStyle *style,
80 GtkStateType state_type,
81 GtkShadowType shadow_type,
88 static void gtk_default_draw_arrow (GtkStyle *style,
90 GtkStateType state_type,
91 GtkShadowType shadow_type,
95 GtkArrowType arrow_type,
101 static void gtk_default_draw_diamond (GtkStyle *style,
103 GtkStateType state_type,
104 GtkShadowType shadow_type,
112 static void gtk_default_draw_oval (GtkStyle *style,
114 GtkStateType state_type,
115 GtkShadowType shadow_type,
123 static void gtk_default_draw_string (GtkStyle *style,
125 GtkStateType state_type,
131 const gchar *string);
132 static void gtk_default_draw_box (GtkStyle *style,
134 GtkStateType state_type,
135 GtkShadowType shadow_type,
143 static void gtk_default_draw_flat_box (GtkStyle *style,
145 GtkStateType state_type,
146 GtkShadowType shadow_type,
154 static void gtk_default_draw_check (GtkStyle *style,
156 GtkStateType state_type,
157 GtkShadowType shadow_type,
165 static void gtk_default_draw_option (GtkStyle *style,
167 GtkStateType state_type,
168 GtkShadowType shadow_type,
176 static void gtk_default_draw_cross (GtkStyle *style,
178 GtkStateType state_type,
179 GtkShadowType shadow_type,
187 static void gtk_default_draw_ramp (GtkStyle *style,
189 GtkStateType state_type,
190 GtkShadowType shadow_type,
194 GtkArrowType arrow_type,
199 static void gtk_default_draw_tab (GtkStyle *style,
201 GtkStateType state_type,
202 GtkShadowType shadow_type,
210 static void gtk_default_draw_shadow_gap (GtkStyle *style,
212 GtkStateType state_type,
213 GtkShadowType shadow_type,
221 GtkPositionType gap_side,
224 static void gtk_default_draw_box_gap (GtkStyle *style,
226 GtkStateType state_type,
227 GtkShadowType shadow_type,
235 GtkPositionType gap_side,
238 static void gtk_default_draw_extension (GtkStyle *style,
240 GtkStateType state_type,
241 GtkShadowType shadow_type,
249 GtkPositionType gap_side);
250 static void gtk_default_draw_focus (GtkStyle *style,
259 static void gtk_default_draw_slider (GtkStyle *style,
261 GtkStateType state_type,
262 GtkShadowType shadow_type,
270 GtkOrientation orientation);
271 static void gtk_default_draw_handle (GtkStyle *style,
273 GtkStateType state_type,
274 GtkShadowType shadow_type,
282 GtkOrientation orientation);
285 static void gtk_style_shade (GdkColor *a, GdkColor *b, gdouble k);
286 static void rgb_to_hls (gdouble *r, gdouble *g, gdouble *b);
287 static void hls_to_rgb (gdouble *h, gdouble *l, gdouble *s);
289 static void gtk_reset_window_and_children(GtkWidget *widget,
293 GtkStyleClass default_class =
297 gtk_default_draw_hline,
298 gtk_default_draw_vline,
299 gtk_default_draw_shadow,
300 gtk_default_draw_polygon,
301 gtk_default_draw_arrow,
302 gtk_default_draw_diamond,
303 gtk_default_draw_oval,
304 gtk_default_draw_string,
305 gtk_default_draw_box,
306 gtk_default_draw_flat_box,
307 gtk_default_draw_check,
308 gtk_default_draw_option,
309 gtk_default_draw_cross,
310 gtk_default_draw_ramp,
311 gtk_default_draw_tab,
312 gtk_default_draw_shadow_gap,
313 gtk_default_draw_box_gap,
314 gtk_default_draw_extension,
315 gtk_default_draw_focus,
316 gtk_default_draw_slider,
317 gtk_default_draw_handle
319 GdkFont *default_font = NULL;
321 static GdkColor gtk_default_normal_fg = { 0, 0, 0, 0 };
322 static GdkColor gtk_default_active_fg = { 0, 0, 0, 0 };
323 static GdkColor gtk_default_prelight_fg = { 0, 0, 0, 0 };
324 static GdkColor gtk_default_selected_fg = { 0, 0xffff, 0xffff, 0xffff };
325 static GdkColor gtk_default_insensitive_fg = { 0, 0x7530, 0x7530, 0x7530 };
327 static GdkColor gtk_default_normal_bg = { 0, 0xd6d6, 0xd6d6, 0xd6d6 };
328 static GdkColor gtk_default_active_bg = { 0, 0xc350, 0xc350, 0xc350 };
329 static GdkColor gtk_default_prelight_bg = { 0, 0xea60, 0xea60, 0xea60 };
330 static GdkColor gtk_default_selected_bg = { 0, 0, 0, 0x9c40 };
331 static GdkColor gtk_default_insensitive_bg = { 0, 0xd6d6, 0xd6d6, 0xd6d6 };
334 gtk_reset_window_and_children(GtkWidget *widget, GdkWindow *window)
336 GdkWindowPrivate *private;
341 g_return_if_fail (window != NULL);
343 private = (GdkWindowPrivate *)window;
345 if (private->destroyed)
347 gdk_window_get_user_data(window, &data);
348 if ((data) && (data != widget))
350 gdk_window_shape_combine_mask(window, NULL, 0, 0);
351 if (private->children)
353 num = g_list_length(private->children);
354 for(i = 0; i < num; i++)
356 list = g_list_nth(private->children, i);
357 gtk_reset_window_and_children(widget, (GdkWindow *)list->data);
363 gtk_reset_widget_shapes(GtkWidget *widget)
365 g_return_if_fail (widget != NULL);
367 if (!GTK_WIDGET_HAS_SHAPE_MASK(GTK_OBJECT(widget)))
368 gtk_reset_window_and_children(widget, widget->window);
372 gtk_style_copy (GtkStyle *style)
377 g_return_val_if_fail (style != NULL, NULL);
379 new_style = gtk_style_new ();
381 for (i = 0; i < 5; i++)
383 new_style->fg[i] = style->fg[i];
384 new_style->bg[i] = style->bg[i];
385 new_style->text[i] = style->text[i];
386 new_style->base[i] = style->base[i];
388 new_style->bg_pixmap[i] = style->bg_pixmap[i];
391 new_style->font = style->font;
392 gdk_font_ref (new_style->font);
398 gtk_style_duplicate (GtkStyle *style)
402 g_return_val_if_fail (style != NULL, NULL);
404 new_style = gtk_style_copy (style);
406 style->styles = g_slist_append (style->styles, new_style);
407 new_style->styles = style->styles;
411 new_style->rc_style = style->rc_style;
412 gtk_rc_style_ref (style->rc_style);
417 new_style->engine = style->engine;
418 new_style->engine->duplicate_style (new_style, style);
430 style = g_new0 (GtkStyle, 1);
434 gdk_font_load ("-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*");
436 style->font = default_font;
437 gdk_font_ref (style->font);
439 style->ref_count = 1;
440 style->attach_count = 0;
441 style->colormap = NULL;
443 style->klass = &default_class;
445 style->black.red = 0;
446 style->black.green = 0;
447 style->black.blue = 0;
449 style->white.red = 65535;
450 style->white.green = 65535;
451 style->white.blue = 65535;
453 style->black_gc = NULL;
454 style->white_gc = NULL;
456 style->fg[GTK_STATE_NORMAL] = gtk_default_normal_fg;
457 style->fg[GTK_STATE_ACTIVE] = gtk_default_active_fg;
458 style->fg[GTK_STATE_PRELIGHT] = gtk_default_prelight_fg;
459 style->fg[GTK_STATE_SELECTED] = gtk_default_selected_fg;
460 style->fg[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_fg;
462 style->bg[GTK_STATE_NORMAL] = gtk_default_normal_bg;
463 style->bg[GTK_STATE_ACTIVE] = gtk_default_active_bg;
464 style->bg[GTK_STATE_PRELIGHT] = gtk_default_prelight_bg;
465 style->bg[GTK_STATE_SELECTED] = gtk_default_selected_bg;
466 style->bg[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_bg;
468 for (i = 0; i < 4; i++)
470 style->text[i] = style->fg[i];
471 style->base[i] = style->white;
474 style->base[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_bg;
475 style->text[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_bg;
477 for (i = 0; i < 5; i++)
478 style->bg_pixmap[i] = NULL;
480 style->engine = NULL;
481 style->engine_data = NULL;
483 style->rc_style = NULL;
485 for (i = 0; i < 5; i++)
487 style->fg_gc[i] = NULL;
488 style->bg_gc[i] = NULL;
489 style->light_gc[i] = NULL;
490 style->dark_gc[i] = NULL;
491 style->mid_gc[i] = NULL;
492 style->text_gc[i] = NULL;
493 style->base_gc[i] = NULL;
500 gtk_style_attach (GtkStyle *style,
504 GtkStyle *new_style = NULL;
505 GdkColormap *colormap;
508 g_return_val_if_fail (style != NULL, NULL);
509 g_return_val_if_fail (window != NULL, NULL);
511 colormap = gdk_window_get_colormap (window);
512 depth = gdk_window_get_visual (window)->depth;
515 style->styles = g_slist_append (NULL, style);
517 styles = style->styles;
520 new_style = styles->data;
522 if (new_style->attach_count == 0)
524 gtk_style_init (new_style, colormap, depth);
527 else if ((new_style->colormap == colormap) &&
528 (new_style->depth == depth))
532 styles = styles->next;
537 new_style = gtk_style_duplicate (style);
538 gtk_style_init (new_style, colormap, depth);
541 if (new_style->attach_count == 0)
542 gtk_style_ref (new_style);
546 new_style->attach_count++;
552 gtk_style_detach (GtkStyle *style)
556 g_return_if_fail (style != NULL);
558 style->attach_count -= 1;
559 if (style->attach_count == 0)
562 style->engine->unrealize_style (style);
564 gtk_gc_release (style->black_gc);
565 gtk_gc_release (style->white_gc);
567 for (i = 0; i < 5; i++)
569 gtk_gc_release (style->fg_gc[i]);
570 gtk_gc_release (style->bg_gc[i]);
571 gtk_gc_release (style->light_gc[i]);
572 gtk_gc_release (style->dark_gc[i]);
573 gtk_gc_release (style->mid_gc[i]);
574 gtk_gc_release (style->text_gc[i]);
575 gtk_gc_release (style->base_gc[i]);
578 gtk_style_unref (style);
583 gtk_style_ref (GtkStyle *style)
585 g_return_val_if_fail (style != NULL, NULL);
587 style->ref_count += 1;
592 gtk_style_unref (GtkStyle *style)
594 g_return_if_fail (style != NULL);
596 style->ref_count -= 1;
597 if (style->ref_count == 0)
598 gtk_style_destroy (style);
602 gtk_style_init (GtkStyle *style,
603 GdkColormap *colormap,
606 GdkGCValues gc_values;
607 GdkGCValuesMask gc_values_mask;
610 g_return_if_fail (style != NULL);
612 style->colormap = colormap;
613 style->depth = depth;
615 for (i = 0; i < 5; i++)
617 gtk_style_shade (&style->bg[i], &style->light[i], LIGHTNESS_MULT);
618 gtk_style_shade (&style->bg[i], &style->dark[i], DARKNESS_MULT);
620 style->mid[i].red = (style->light[i].red + style->dark[i].red) / 2;
621 style->mid[i].green = (style->light[i].green + style->dark[i].green) / 2;
622 style->mid[i].blue = (style->light[i].blue + style->dark[i].blue) / 2;
625 gdk_color_black (colormap, &style->black);
626 gdk_color_white (colormap, &style->white);
628 gc_values_mask = GDK_GC_FOREGROUND | GDK_GC_FONT;
629 if (style->font->type == GDK_FONT_FONT)
631 gc_values.font = style->font;
633 else if (style->font->type == GDK_FONT_FONTSET)
635 gc_values.font = default_font;
638 gc_values.foreground = style->black;
639 style->black_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
641 gc_values.foreground = style->white;
642 style->white_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
644 for (i = 0; i < 5; i++)
646 if (style->rc_style && style->rc_style->bg_pixmap_name[i])
647 style->bg_pixmap[i] = gtk_rc_load_image (style->colormap,
649 style->rc_style->bg_pixmap_name[i]);
651 if (!gdk_color_alloc (colormap, &style->fg[i]))
652 g_warning ("unable to allocate color: ( %d %d %d )",
653 style->fg[i].red, style->fg[i].green, style->fg[i].blue);
654 if (!gdk_color_alloc (colormap, &style->bg[i]))
655 g_warning ("unable to allocate color: ( %d %d %d )",
656 style->bg[i].red, style->bg[i].green, style->bg[i].blue);
657 if (!gdk_color_alloc (colormap, &style->light[i]))
658 g_warning ("unable to allocate color: ( %d %d %d )",
659 style->light[i].red, style->light[i].green, style->light[i].blue);
660 if (!gdk_color_alloc (colormap, &style->dark[i]))
661 g_warning ("unable to allocate color: ( %d %d %d )",
662 style->dark[i].red, style->dark[i].green, style->dark[i].blue);
663 if (!gdk_color_alloc (colormap, &style->mid[i]))
664 g_warning ("unable to allocate color: ( %d %d %d )",
665 style->mid[i].red, style->mid[i].green, style->mid[i].blue);
666 if (!gdk_color_alloc (colormap, &style->text[i]))
667 g_warning ("unable to allocate color: ( %d %d %d )",
668 style->text[i].red, style->text[i].green, style->text[i].blue);
669 if (!gdk_color_alloc (colormap, &style->base[i]))
670 g_warning ("unable to allocate color: ( %d %d %d )",
671 style->base[i].red, style->base[i].green, style->base[i].blue);
673 gc_values.foreground = style->fg[i];
674 style->fg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
676 gc_values.foreground = style->bg[i];
677 style->bg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
679 gc_values.foreground = style->light[i];
680 style->light_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
682 gc_values.foreground = style->dark[i];
683 style->dark_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
685 gc_values.foreground = style->mid[i];
686 style->mid_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
688 gc_values.foreground = style->text[i];
689 style->text_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
691 gc_values.foreground = style->base[i];
692 style->base_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
695 style->engine->realize_style (style);
699 gtk_style_destroy (GtkStyle *style)
701 g_return_if_fail (style->attach_count == 0);
705 if (style->styles->data != style)
706 g_slist_remove (style->styles, style);
709 GSList *tmp_list = style->styles->next;
712 ((GtkStyle *)tmp_list->data)->styles = style->styles->next;
713 tmp_list = tmp_list->next;
715 g_slist_free_1 (style->styles);
721 style->engine->destroy_style (style);
722 gtk_theme_engine_unref (style->engine);
725 gdk_font_unref (style->font);
727 gtk_rc_style_unref (style->rc_style);
733 gtk_style_set_background (GtkStyle *style,
735 GtkStateType state_type)
738 gint parent_relative;
740 if (style->engine && style->engine->set_background)
742 (*style->engine->set_background) (style, window, state_type);
746 g_return_if_fail (style != NULL);
747 g_return_if_fail (window != NULL);
749 if (style->bg_pixmap[state_type])
751 if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
754 parent_relative = TRUE;
758 pixmap = style->bg_pixmap[state_type];
759 parent_relative = FALSE;
762 gdk_window_set_back_pixmap (window, pixmap, parent_relative);
765 gdk_window_set_background (window, &style->bg[state_type]);
770 gtk_draw_hline (GtkStyle *style,
772 GtkStateType state_type,
777 g_return_if_fail (style != NULL);
778 g_return_if_fail (style->klass != NULL);
779 g_return_if_fail (style->klass->draw_hline != NULL);
781 (*style->klass->draw_hline) (style, window, state_type, NULL, NULL, NULL, x1, x2, y);
786 gtk_draw_vline (GtkStyle *style,
788 GtkStateType state_type,
793 g_return_if_fail (style != NULL);
794 g_return_if_fail (style->klass != NULL);
795 g_return_if_fail (style->klass->draw_vline != NULL);
797 (*style->klass->draw_vline) (style, window, state_type, NULL, NULL, NULL, y1, y2, x);
802 gtk_draw_shadow (GtkStyle *style,
804 GtkStateType state_type,
805 GtkShadowType shadow_type,
811 g_return_if_fail (style != NULL);
812 g_return_if_fail (style->klass != NULL);
813 g_return_if_fail (style->klass->draw_shadow != NULL);
815 (*style->klass->draw_shadow) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
819 gtk_draw_polygon (GtkStyle *style,
821 GtkStateType state_type,
822 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_shadow != NULL);
831 (*style->klass->draw_polygon) (style, window, state_type, shadow_type, NULL, NULL, NULL, points, npoints, fill);
835 gtk_draw_arrow (GtkStyle *style,
837 GtkStateType state_type,
838 GtkShadowType shadow_type,
839 GtkArrowType arrow_type,
846 g_return_if_fail (style != NULL);
847 g_return_if_fail (style->klass != NULL);
848 g_return_if_fail (style->klass->draw_arrow != NULL);
850 (*style->klass->draw_arrow) (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, fill, x, y, width, height);
855 gtk_draw_diamond (GtkStyle *style,
857 GtkStateType state_type,
858 GtkShadowType shadow_type,
864 g_return_if_fail (style != NULL);
865 g_return_if_fail (style->klass != NULL);
866 g_return_if_fail (style->klass->draw_diamond != NULL);
868 (*style->klass->draw_diamond) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
873 gtk_draw_oval (GtkStyle *style,
875 GtkStateType state_type,
876 GtkShadowType shadow_type,
882 g_return_if_fail (style != NULL);
883 g_return_if_fail (style->klass != NULL);
884 g_return_if_fail (style->klass->draw_oval != NULL);
886 (*style->klass->draw_oval) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
890 gtk_draw_string (GtkStyle *style,
892 GtkStateType state_type,
897 g_return_if_fail (style != NULL);
898 g_return_if_fail (style->klass != NULL);
899 g_return_if_fail (style->klass->draw_oval != NULL);
901 (*style->klass->draw_string) (style, window, state_type, NULL, NULL, NULL, x, y, string);
905 gtk_draw_box (GtkStyle *style,
907 GtkStateType state_type,
908 GtkShadowType shadow_type,
914 g_return_if_fail (style != NULL);
915 g_return_if_fail (style->klass != NULL);
916 g_return_if_fail (style->klass->draw_box != NULL);
918 (*style->klass->draw_box) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
922 gtk_draw_flat_box (GtkStyle *style,
924 GtkStateType state_type,
925 GtkShadowType shadow_type,
931 g_return_if_fail (style != NULL);
932 g_return_if_fail (style->klass != NULL);
933 g_return_if_fail (style->klass->draw_flat_box != NULL);
935 (*style->klass->draw_flat_box) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
939 gtk_draw_check (GtkStyle *style,
941 GtkStateType state_type,
942 GtkShadowType shadow_type,
948 g_return_if_fail (style != NULL);
949 g_return_if_fail (style->klass != NULL);
950 g_return_if_fail (style->klass->draw_check != NULL);
952 (*style->klass->draw_check) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
956 gtk_draw_option (GtkStyle *style,
958 GtkStateType state_type,
959 GtkShadowType shadow_type,
965 g_return_if_fail (style != NULL);
966 g_return_if_fail (style->klass != NULL);
967 g_return_if_fail (style->klass->draw_option != NULL);
969 (*style->klass->draw_option) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
973 gtk_draw_cross (GtkStyle *style,
975 GtkStateType state_type,
976 GtkShadowType shadow_type,
982 g_return_if_fail (style != NULL);
983 g_return_if_fail (style->klass != NULL);
984 g_return_if_fail (style->klass->draw_cross != NULL);
986 (*style->klass->draw_cross) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
990 gtk_draw_ramp (GtkStyle *style,
992 GtkStateType state_type,
993 GtkShadowType shadow_type,
994 GtkArrowType arrow_type,
1000 g_return_if_fail (style != NULL);
1001 g_return_if_fail (style->klass != NULL);
1002 g_return_if_fail (style->klass->draw_ramp != NULL);
1004 (*style->klass->draw_ramp) (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, x, y, width, height);
1008 gtk_draw_tab (GtkStyle *style,
1010 GtkStateType state_type,
1011 GtkShadowType shadow_type,
1017 g_return_if_fail (style != NULL);
1018 g_return_if_fail (style->klass != NULL);
1019 g_return_if_fail (style->klass->draw_tab != NULL);
1021 (*style->klass->draw_tab) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
1025 gtk_draw_shadow_gap (GtkStyle *style,
1027 GtkStateType state_type,
1028 GtkShadowType shadow_type,
1033 GtkPositionType gap_side,
1037 g_return_if_fail (style != NULL);
1038 g_return_if_fail (style->klass != NULL);
1039 g_return_if_fail (style->klass->draw_shadow_gap != NULL);
1041 (*style->klass->draw_shadow_gap) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width);
1045 gtk_draw_box_gap (GtkStyle *style,
1047 GtkStateType state_type,
1048 GtkShadowType shadow_type,
1053 GtkPositionType gap_side,
1057 g_return_if_fail (style != NULL);
1058 g_return_if_fail (style->klass != NULL);
1059 g_return_if_fail (style->klass->draw_box_gap != NULL);
1061 (*style->klass->draw_box_gap) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width);
1065 gtk_draw_extension (GtkStyle *style,
1067 GtkStateType state_type,
1068 GtkShadowType shadow_type,
1073 GtkPositionType gap_side)
1075 g_return_if_fail (style != NULL);
1076 g_return_if_fail (style->klass != NULL);
1077 g_return_if_fail (style->klass->draw_extension != NULL);
1079 (*style->klass->draw_extension) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side);
1083 gtk_draw_focus (GtkStyle *style,
1090 g_return_if_fail (style != NULL);
1091 g_return_if_fail (style->klass != NULL);
1092 g_return_if_fail (style->klass->draw_focus != NULL);
1094 (*style->klass->draw_focus) (style, window, NULL, NULL, NULL, x, y, width, height);
1098 gtk_draw_slider (GtkStyle *style,
1100 GtkStateType state_type,
1101 GtkShadowType shadow_type,
1106 GtkOrientation orientation)
1108 g_return_if_fail (style != NULL);
1109 g_return_if_fail (style->klass != NULL);
1110 g_return_if_fail (style->klass->draw_slider != NULL);
1112 (*style->klass->draw_slider) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
1116 gtk_draw_handle (GtkStyle *style,
1118 GtkStateType state_type,
1119 GtkShadowType shadow_type,
1124 GtkOrientation orientation)
1126 g_return_if_fail (style != NULL);
1127 g_return_if_fail (style->klass != NULL);
1128 g_return_if_fail (style->klass->draw_handle != NULL);
1130 (*style->klass->draw_handle) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
1133 /* Default functions */
1135 gtk_style_apply_default_pixmap(GtkStyle *style,
1137 GtkStateType state_type,
1144 GdkRectangle new_rect, old_rect;
1147 if ((!style->bg_pixmap[state_type]) ||
1148 (gdk_window_get_type(window) == GDK_WINDOW_PIXMAP))
1150 gc = style->bg_gc[state_type];
1154 old_rect.width = width;
1155 old_rect.height = height;
1159 if (gdk_rectangle_intersect(area, &old_rect, &new_rect))
1160 gdk_draw_rectangle(window, gc, TRUE,
1161 new_rect.x, new_rect.y, new_rect.width, new_rect.height);
1164 gdk_draw_rectangle(window, gc, TRUE,
1165 x, y, width, height);
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);
1176 old_rect.width = width;
1177 old_rect.height = height;
1179 if ((area) && (gdk_rectangle_intersect(area, &old_rect, &new_rect)))
1180 gdk_window_clear_area(window, new_rect.x, new_rect.y, new_rect.width, new_rect.height);
1182 gdk_window_clear_area(window, x, y, width, height);
1187 gtk_default_draw_hline (GtkStyle *style,
1189 GtkStateType state_type,
1197 gint thickness_light;
1198 gint thickness_dark;
1201 g_return_if_fail (style != NULL);
1202 g_return_if_fail (window != NULL);
1204 thickness_light = style->klass->ythickness / 2;
1205 thickness_dark = style->klass->ythickness - thickness_light;
1209 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1210 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1213 if (detail && !strcmp (detail, "label"))
1215 if (state_type == GTK_STATE_INSENSITIVE)
1216 gdk_draw_line (window, style->white_gc, x1 + 1, y + 1, x2 + 1, y + 1);
1217 gdk_draw_line (window, style->fg_gc[state_type], x1, y, x2, y);
1221 for (i = 0; i < thickness_dark; i++)
1223 gdk_draw_line (window, style->light_gc[state_type], x2 - i - 1, y + i, x2, y + i);
1224 gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x2 - i - 1, y + i);
1227 y += thickness_dark;
1228 for (i = 0; i < thickness_light; i++)
1230 gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x1 + thickness_light - i - 1, y + i);
1231 gdk_draw_line (window, style->light_gc[state_type], x1 + thickness_light - i - 1, y + i, x2, y + i);
1237 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
1238 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
1244 gtk_default_draw_vline (GtkStyle *style,
1246 GtkStateType state_type,
1254 gint thickness_light;
1255 gint thickness_dark;
1258 g_return_if_fail (style != NULL);
1259 g_return_if_fail (window != NULL);
1261 thickness_light = style->klass->xthickness / 2;
1262 thickness_dark = style->klass->xthickness - thickness_light;
1266 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1267 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1269 for (i = 0; i < thickness_dark; i++)
1271 gdk_draw_line (window, style->light_gc[state_type], x + i, y2 - i - 1, x + i, y2);
1272 gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y2 - i - 1);
1275 x += thickness_dark;
1276 for (i = 0; i < thickness_light; i++)
1278 gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y1 + thickness_light - i);
1279 gdk_draw_line (window, style->light_gc[state_type], x + i, y1 + thickness_light - i, x + i, y2);
1283 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
1284 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
1290 gtk_default_draw_shadow (GtkStyle *style,
1292 GtkStateType state_type,
1293 GtkShadowType shadow_type,
1304 gint thickness_light;
1305 gint thickness_dark;
1308 g_return_if_fail (style != NULL);
1309 g_return_if_fail (window != NULL);
1311 if ((width == -1) && (height == -1))
1312 gdk_window_get_size (window, &width, &height);
1313 else if (width == -1)
1314 gdk_window_get_size (window, &width, NULL);
1315 else if (height == -1)
1316 gdk_window_get_size (window, NULL, &height);
1318 switch (shadow_type)
1320 case GTK_SHADOW_NONE:
1323 case GTK_SHADOW_ETCHED_IN:
1324 gc1 = style->light_gc[state_type];
1325 gc2 = style->dark_gc[state_type];
1327 case GTK_SHADOW_OUT:
1328 case GTK_SHADOW_ETCHED_OUT:
1329 gc1 = style->dark_gc[state_type];
1330 gc2 = style->light_gc[state_type];
1336 gdk_gc_set_clip_rectangle (gc1, area);
1337 gdk_gc_set_clip_rectangle (gc2, area);
1338 if ((shadow_type == GTK_SHADOW_IN) ||
1339 (shadow_type == GTK_SHADOW_OUT))
1341 gdk_gc_set_clip_rectangle (style->black_gc, area);
1342 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
1345 switch (shadow_type)
1347 case GTK_SHADOW_NONE:
1351 gdk_draw_line (window, gc1,
1352 x, y + height - 1, x + width - 1, y + height - 1);
1353 gdk_draw_line (window, gc1,
1354 x + width - 1, y, x + width - 1, y + height - 1);
1356 gdk_draw_line (window, style->bg_gc[state_type],
1357 x + 1, y + height - 2, x + width - 2, y + height - 2);
1358 gdk_draw_line (window, style->bg_gc[state_type],
1359 x + width - 2, y + 1, x + width - 2, y + height - 2);
1361 gdk_draw_line (window, style->black_gc,
1362 x + 1, y + 1, x + width - 2, y + 1);
1363 gdk_draw_line (window, style->black_gc,
1364 x + 1, y + 1, x + 1, y + height - 2);
1366 gdk_draw_line (window, gc2,
1367 x, y, x + width - 1, y);
1368 gdk_draw_line (window, gc2,
1369 x, y, x, y + height - 1);
1372 case GTK_SHADOW_OUT:
1373 gdk_draw_line (window, gc1,
1374 x + 1, y + height - 2, x + width - 2, y + height - 2);
1375 gdk_draw_line (window, gc1,
1376 x + width - 2, y + 1, x + width - 2, y + height - 2);
1378 gdk_draw_line (window, gc2,
1379 x, y, x + width - 1, y);
1380 gdk_draw_line (window, gc2,
1381 x, y, x, y + height - 1);
1383 gdk_draw_line (window, style->bg_gc[state_type],
1384 x + 1, y + 1, x + width - 2, y + 1);
1385 gdk_draw_line (window, style->bg_gc[state_type],
1386 x + 1, y + 1, x + 1, y + height - 2);
1388 gdk_draw_line (window, style->black_gc,
1389 x, y + height - 1, x + width - 1, y + height - 1);
1390 gdk_draw_line (window, style->black_gc,
1391 x + width - 1, y, x + width - 1, y + height - 1);
1394 case GTK_SHADOW_ETCHED_IN:
1395 case GTK_SHADOW_ETCHED_OUT:
1396 thickness_light = 1;
1399 for (i = 0; i < thickness_dark; i++)
1401 gdk_draw_line (window, gc1,
1405 y + height - i - 1);
1406 gdk_draw_line (window, gc1,
1410 y + height - i - 1);
1412 gdk_draw_line (window, gc2,
1417 gdk_draw_line (window, gc2,
1421 y + height - i - 2);
1424 for (i = 0; i < thickness_light; i++)
1426 gdk_draw_line (window, gc1,
1427 x + thickness_dark + i,
1428 y + thickness_dark + i,
1429 x + width - thickness_dark - i - 1,
1430 y + thickness_dark + i);
1431 gdk_draw_line (window, gc1,
1432 x + thickness_dark + i,
1433 y + thickness_dark + i,
1434 x + thickness_dark + i,
1435 y + height - thickness_dark - i - 1);
1437 gdk_draw_line (window, gc2,
1438 x + thickness_dark + i,
1439 y + height - thickness_light - i - 1,
1440 x + width - thickness_light - 1,
1441 y + height - thickness_light - i - 1);
1442 gdk_draw_line (window, gc2,
1443 x + width - thickness_light - i - 1,
1444 y + thickness_dark + i,
1445 x + width - thickness_light - i - 1,
1446 y + height - thickness_light - 1);
1452 gdk_gc_set_clip_rectangle (gc1, NULL);
1453 gdk_gc_set_clip_rectangle (gc2, NULL);
1454 if ((shadow_type == GTK_SHADOW_IN) ||
1455 (shadow_type == GTK_SHADOW_OUT))
1457 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
1458 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
1465 gtk_default_draw_polygon (GtkStyle *style,
1467 GtkStateType state_type,
1468 GtkShadowType shadow_type,
1477 #define M_PI 3.14159265358979323846
1480 #define M_PI_4 0.78539816339744830962
1483 static const gdouble pi_over_4 = M_PI_4;
1484 static const gdouble pi_3_over_4 = M_PI_4 * 3;
1495 g_return_if_fail (style != NULL);
1496 g_return_if_fail (window != NULL);
1497 g_return_if_fail (points != NULL);
1499 switch (shadow_type)
1502 gc1 = style->bg_gc[state_type];
1503 gc2 = style->dark_gc[state_type];
1504 gc3 = style->light_gc[state_type];
1505 gc4 = style->black_gc;
1507 case GTK_SHADOW_ETCHED_IN:
1508 gc1 = style->light_gc[state_type];
1509 gc2 = style->dark_gc[state_type];
1510 gc3 = style->dark_gc[state_type];
1511 gc4 = style->light_gc[state_type];
1513 case GTK_SHADOW_OUT:
1514 gc1 = style->dark_gc[state_type];
1515 gc2 = style->light_gc[state_type];
1516 gc3 = style->black_gc;
1517 gc4 = style->bg_gc[state_type];
1519 case GTK_SHADOW_ETCHED_OUT:
1520 gc1 = style->dark_gc[state_type];
1521 gc2 = style->light_gc[state_type];
1522 gc3 = style->light_gc[state_type];
1523 gc4 = style->dark_gc[state_type];
1531 gdk_gc_set_clip_rectangle (gc1, area);
1532 gdk_gc_set_clip_rectangle (gc2, area);
1533 gdk_gc_set_clip_rectangle (gc3, area);
1534 gdk_gc_set_clip_rectangle (gc4, area);
1538 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, npoints);
1542 for (i = 0; i < npoints; i++)
1544 if ((points[i].x == points[i+1].x) &&
1545 (points[i].y == points[i+1].y))
1551 angle = atan2 (points[i+1].y - points[i].y,
1552 points[i+1].x - points[i].x);
1555 if ((angle > -pi_3_over_4) && (angle < pi_over_4))
1557 if (angle > -pi_over_4)
1568 gdk_draw_line (window, gc1,
1569 points[i].x-xadjust, points[i].y-yadjust,
1570 points[i+1].x-xadjust, points[i+1].y-yadjust);
1571 gdk_draw_line (window, gc3,
1572 points[i].x, points[i].y,
1573 points[i+1].x, points[i+1].y);
1577 if ((angle < -pi_3_over_4) || (angle > pi_3_over_4))
1588 gdk_draw_line (window, gc4,
1589 points[i].x+xadjust, points[i].y+yadjust,
1590 points[i+1].x+xadjust, points[i+1].y+yadjust);
1591 gdk_draw_line (window, gc2,
1592 points[i].x, points[i].y,
1593 points[i+1].x, points[i+1].y);
1598 gdk_gc_set_clip_rectangle (gc1, NULL);
1599 gdk_gc_set_clip_rectangle (gc2, NULL);
1600 gdk_gc_set_clip_rectangle (gc3, NULL);
1601 gdk_gc_set_clip_rectangle (gc4, NULL);
1606 gtk_default_draw_arrow (GtkStyle *style,
1608 GtkStateType state_type,
1609 GtkShadowType shadow_type,
1613 GtkArrowType arrow_type,
1628 g_return_if_fail (style != NULL);
1629 g_return_if_fail (window != NULL);
1631 switch (shadow_type)
1634 gc1 = style->bg_gc[state_type];
1635 gc2 = style->dark_gc[state_type];
1636 gc3 = style->light_gc[state_type];
1637 gc4 = style->black_gc;
1639 case GTK_SHADOW_OUT:
1640 gc1 = style->dark_gc[state_type];
1641 gc2 = style->light_gc[state_type];
1642 gc3 = style->black_gc;
1643 gc4 = style->bg_gc[state_type];
1645 case GTK_SHADOW_ETCHED_IN:
1646 gc1 = style->light_gc[state_type];
1647 gc2 = style->dark_gc[state_type];
1651 case GTK_SHADOW_ETCHED_OUT:
1652 gc1 = style->dark_gc[state_type];
1653 gc2 = style->light_gc[state_type];
1661 if ((width == -1) && (height == -1))
1662 gdk_window_get_size (window, &width, &height);
1663 else if (width == -1)
1664 gdk_window_get_size (window, &width, NULL);
1665 else if (height == -1)
1666 gdk_window_get_size (window, NULL, &height);
1668 half_width = width / 2;
1669 half_height = height / 2;
1673 gdk_gc_set_clip_rectangle (gc1, area);
1674 gdk_gc_set_clip_rectangle (gc2, area);
1677 gdk_gc_set_clip_rectangle (gc3, area);
1678 gdk_gc_set_clip_rectangle (gc4, area);
1687 points[0].x = x + half_width;
1690 points[1].y = y + height - 1;
1691 points[2].x = x + width - 1;
1692 points[2].y = y + height - 1;
1694 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1697 switch (shadow_type)
1700 case GTK_SHADOW_OUT:
1702 gdk_draw_line (window, gc1,
1703 x + 1, y + height - 2,
1704 x + width - 2, y + height - 2);
1705 gdk_draw_line (window, gc3,
1706 x + 0, y + height - 1,
1707 x + width - 1, y + height - 1);
1709 gdk_draw_line (window, gc1,
1710 x + width - 2, y + height - 1,
1711 x + half_width, y + 1);
1712 gdk_draw_line (window, gc3,
1713 x + width - 1, y + height - 1,
1716 gdk_draw_line (window, gc4,
1717 x + half_width, y + 1,
1718 x + 1, y + height - 1);
1719 gdk_draw_line (window, gc2,
1724 case GTK_SHADOW_ETCHED_IN:
1725 case GTK_SHADOW_ETCHED_OUT:
1726 gdk_draw_line (window, gc1,
1727 x + half_width, y + 1,
1728 x + 1, y + height - 1);
1729 gdk_draw_line (window, gc1,
1730 x + 1, y + height - 1,
1731 x + width - 1, y + height - 1);
1732 gdk_draw_line (window, gc1,
1733 x + width - 1, y + height - 1,
1734 x + half_width + 1, y + 1);
1736 points[0].x = x + half_width;
1739 points[1].y = y + height - 2;
1740 points[2].x = x + width - 2;
1741 points[2].y = y + height - 2;
1743 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1751 case GTK_ARROW_DOWN:
1754 points[0].x = x + width - 1;
1758 points[2].x = x + half_width;
1759 points[2].y = y + height - 1;
1761 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1763 switch (shadow_type)
1766 case GTK_SHADOW_OUT:
1767 gdk_draw_line (window, gc4,
1769 y + 1, x + 1, y + 1);
1770 gdk_draw_line (window, gc2,
1774 gdk_draw_line (window, gc4,
1776 x + half_width, y + height - 2);
1777 gdk_draw_line (window, gc2,
1779 x + half_width, y + height - 1);
1781 gdk_draw_line (window, gc1,
1782 x + half_width, y + height - 2,
1784 gdk_draw_line (window, gc3,
1785 x + half_width, y + height - 1,
1789 case GTK_SHADOW_ETCHED_IN:
1790 case GTK_SHADOW_ETCHED_OUT:
1791 gdk_draw_line (window, gc1,
1792 x + width - 1, y + 1,
1794 gdk_draw_line (window, gc1,
1796 x + half_width + 1, y + height - 1);
1797 gdk_draw_line (window, gc1,
1798 x + half_width + 1, y + height - 2,
1801 points[0].x = x + width - 2;
1805 points[2].x = x + half_width;
1806 points[2].y = y + height - 2;
1808 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1815 case GTK_ARROW_LEFT:
1819 points[0].y = y + half_height;
1820 points[1].x = x + width - 1;
1821 points[1].y = y + height - 1;
1822 points[2].x = x + width - 1;
1825 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1828 switch (shadow_type)
1831 case GTK_SHADOW_OUT:
1832 gdk_draw_line (window, gc1,
1833 x + 1, y + half_height,
1834 x + width - 1, y + height - 1);
1835 gdk_draw_line (window, gc3,
1837 x + width - 1, y + height - 1);
1839 gdk_draw_line (window, gc1,
1840 x + width - 2, y + height - 1,
1841 x + width - 2, y + 1);
1842 gdk_draw_line (window, gc3,
1843 x + width - 1, y + height - 1,
1846 gdk_draw_line (window, gc4,
1847 x + width - 1, y + 1,
1848 x + 1, y + half_height);
1849 gdk_draw_line (window, gc2,
1851 x, y + half_height);
1854 case GTK_SHADOW_ETCHED_IN:
1855 case GTK_SHADOW_ETCHED_OUT:
1856 gdk_draw_line (window, gc1,
1857 x + width - 1, y + 1,
1858 x + 1, y + half_height);
1859 gdk_draw_line (window, gc1,
1860 x + 1, y + half_height + 1,
1861 x + width - 1, y + height - 1);
1862 gdk_draw_line (window, gc1,
1863 x + width - 1, y + height - 1,
1864 x + width - 1, y + 1);
1866 points[0].x = x + width - 2;
1869 points[1].y = y + half_height;
1870 points[2].x = x + width - 2;
1871 points[2].y = y + height - 2;
1873 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1880 case GTK_ARROW_RIGHT:
1883 points[0].x = x + width - 1;
1884 points[0].y = y + half_height;
1888 points[2].y = y + height - 1;
1890 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1893 switch (shadow_type)
1896 case GTK_SHADOW_OUT:
1897 gdk_draw_line (window, gc4,
1898 x + width - 1, y + half_height,
1900 gdk_draw_line (window, gc2,
1901 x + width - 1, y + half_height,
1903 gdk_draw_line (window, gc4,
1905 x + 1, y + height - 2);
1906 gdk_draw_line (window, gc2,
1910 gdk_draw_line (window, gc1,
1911 x + 1, y + height - 2,
1912 x + width - 1, y + half_height);
1913 gdk_draw_line (window, gc3,
1915 x + width - 1, y + half_height);
1918 case GTK_SHADOW_ETCHED_IN:
1919 case GTK_SHADOW_ETCHED_OUT:
1920 gdk_draw_line (window, gc1,
1921 x + width - 1, y + half_height + 1,
1923 gdk_draw_line (window, gc1,
1925 x + 1, y + height - 1);
1926 gdk_draw_line (window, gc1,
1927 x + 1, y + height - 1,
1928 x + width - 1, y + half_height + 1);
1930 points[0].x = x + width - 2;
1931 points[0].y = y + half_height;
1935 points[2].y = y + height - 1;
1937 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1947 gdk_gc_set_clip_rectangle (gc1, NULL);
1948 gdk_gc_set_clip_rectangle (gc2, NULL);
1951 gdk_gc_set_clip_rectangle (gc3, NULL);
1952 gdk_gc_set_clip_rectangle (gc4, NULL);
1958 gtk_default_draw_diamond (GtkStyle *style,
1960 GtkStateType state_type,
1961 GtkShadowType shadow_type,
1973 g_return_if_fail (style != NULL);
1974 g_return_if_fail (window != NULL);
1976 if ((width == -1) && (height == -1))
1977 gdk_window_get_size (window, &width, &height);
1978 else if (width == -1)
1979 gdk_window_get_size (window, &width, NULL);
1980 else if (height == -1)
1981 gdk_window_get_size (window, NULL, &height);
1983 half_width = width / 2;
1984 half_height = height / 2;
1988 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1989 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
1990 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1991 gdk_gc_set_clip_rectangle (style->black_gc, area);
1993 switch (shadow_type)
1996 gdk_draw_line (window, style->bg_gc[state_type],
1997 x + 2, y + half_height,
1998 x + half_width, y + height - 2);
1999 gdk_draw_line (window, style->bg_gc[state_type],
2000 x + half_width, y + height - 2,
2001 x + width - 2, y + half_height);
2002 gdk_draw_line (window, style->light_gc[state_type],
2003 x + 1, y + half_height,
2004 x + half_width, y + height - 1);
2005 gdk_draw_line (window, style->light_gc[state_type],
2006 x + half_width, y + height - 1,
2007 x + width - 1, y + half_height);
2008 gdk_draw_line (window, style->light_gc[state_type],
2010 x + half_width, y + height);
2011 gdk_draw_line (window, style->light_gc[state_type],
2012 x + half_width, y + height,
2013 x + width, y + half_height);
2015 gdk_draw_line (window, style->black_gc,
2016 x + 2, y + half_height,
2017 x + half_width, y + 2);
2018 gdk_draw_line (window, style->black_gc,
2019 x + half_width, y + 2,
2020 x + width - 2, y + half_height);
2021 gdk_draw_line (window, style->dark_gc[state_type],
2022 x + 1, y + half_height,
2023 x + half_width, y + 1);
2024 gdk_draw_line (window, style->dark_gc[state_type],
2025 x + half_width, y + 1,
2026 x + width - 1, y + half_height);
2027 gdk_draw_line (window, style->dark_gc[state_type],
2030 gdk_draw_line (window, style->dark_gc[state_type],
2032 x + width, y + half_height);
2034 case GTK_SHADOW_OUT:
2035 gdk_draw_line (window, style->dark_gc[state_type],
2036 x + 2, y + half_height,
2037 x + half_width, y + height - 2);
2038 gdk_draw_line (window, style->dark_gc[state_type],
2039 x + half_width, y + height - 2,
2040 x + width - 2, y + half_height);
2041 gdk_draw_line (window, style->dark_gc[state_type],
2042 x + 1, y + half_height,
2043 x + half_width, y + height - 1);
2044 gdk_draw_line (window, style->dark_gc[state_type],
2045 x + half_width, y + height - 1,
2046 x + width - 1, y + half_height);
2047 gdk_draw_line (window, style->black_gc,
2049 x + half_width, y + height);
2050 gdk_draw_line (window, style->black_gc,
2051 x + half_width, y + height,
2052 x + width, y + half_height);
2054 gdk_draw_line (window, style->bg_gc[state_type],
2055 x + 2, y + half_height,
2056 x + half_width, y + 2);
2057 gdk_draw_line (window, style->bg_gc[state_type],
2058 x + half_width, y + 2,
2059 x + width - 2, y + half_height);
2060 gdk_draw_line (window, style->light_gc[state_type],
2061 x + 1, y + half_height,
2062 x + half_width, y + 1);
2063 gdk_draw_line (window, style->light_gc[state_type],
2064 x + half_width, y + 1,
2065 x + width - 1, y + half_height);
2066 gdk_draw_line (window, style->light_gc[state_type],
2069 gdk_draw_line (window, style->light_gc[state_type],
2071 x + width, y + half_height);
2078 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
2079 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2080 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
2081 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2087 gtk_default_draw_oval (GtkStyle *style,
2089 GtkStateType state_type,
2090 GtkShadowType shadow_type,
2099 g_return_if_fail (style != NULL);
2100 g_return_if_fail (window != NULL);
2104 gtk_default_draw_string (GtkStyle *style,
2106 GtkStateType state_type,
2112 const gchar *string)
2114 g_return_if_fail (style != NULL);
2115 g_return_if_fail (window != NULL);
2119 gdk_gc_set_clip_rectangle (style->white_gc, area);
2120 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], area);
2122 if (state_type == GTK_STATE_INSENSITIVE)
2123 gdk_draw_string (window, style->font, style->white_gc, x + 1, y + 1, string);
2124 gdk_draw_string (window, style->font, style->fg_gc[state_type], x, y, string);
2127 gdk_gc_set_clip_rectangle (style->white_gc, NULL);
2128 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], NULL);
2133 gtk_default_draw_box (GtkStyle *style,
2135 GtkStateType state_type,
2136 GtkShadowType shadow_type,
2145 g_return_if_fail (style != NULL);
2146 g_return_if_fail (window != NULL);
2148 if ((width == -1) && (height == -1))
2149 gdk_window_get_size (window, &width, &height);
2150 else if (width == -1)
2151 gdk_window_get_size (window, &width, NULL);
2152 else if (height == -1)
2153 gdk_window_get_size (window, NULL, &height);
2155 if ((!style->bg_pixmap[state_type]) ||
2156 (gdk_window_get_type(window) == GDK_WINDOW_PIXMAP))
2160 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
2162 gdk_draw_rectangle(window, style->bg_gc[state_type], TRUE,
2163 x, y, width, height);
2166 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2170 gtk_style_apply_default_pixmap(style, window, state_type, area, x, y, width, height);
2171 gtk_paint_shadow (style, window, state_type, shadow_type, area, widget, detail,
2172 x, y, width, height);
2176 gtk_default_draw_flat_box (GtkStyle *style,
2178 GtkStateType state_type,
2179 GtkShadowType shadow_type,
2190 g_return_if_fail (style != NULL);
2191 g_return_if_fail (window != NULL);
2193 if ((width == -1) && (height == -1))
2194 gdk_window_get_size (window, &width, &height);
2195 else if (width == -1)
2196 gdk_window_get_size (window, &width, NULL);
2197 else if (height == -1)
2198 gdk_window_get_size (window, NULL, &height);
2200 if ((detail) && (!strcmp("text",detail)) && (state_type == GTK_STATE_SELECTED))
2201 gc1 = style->bg_gc[GTK_STATE_SELECTED];
2202 else if ((detail) && (!strcmp("viewportbin",detail)))
2203 gc1 = style->bg_gc[GTK_STATE_NORMAL];
2204 else if ((detail) && (!strcmp("entry_bg",detail)))
2205 gc1 = style->base_gc[state_type];
2207 gc1 = style->bg_gc[state_type];
2209 if ((!style->bg_pixmap[state_type]) || (gc1 != style->bg_gc[state_type]) ||
2210 (gdk_window_get_type(window) == GDK_WINDOW_PIXMAP))
2214 gdk_gc_set_clip_rectangle (gc1, area);
2216 gdk_draw_rectangle (window, gc1, TRUE,
2217 x, y, width, height);
2218 if ((detail) && (!strcmp("tooltip",detail)))
2219 gdk_draw_rectangle (window, style->black_gc, FALSE,
2220 x, y, width - 1, height - 1);
2223 gdk_gc_set_clip_rectangle (gc1, NULL);
2227 gtk_style_apply_default_pixmap(style, window, state_type, area, x, y, width, height);
2231 gtk_default_draw_check (GtkStyle *style,
2233 GtkStateType state_type,
2234 GtkShadowType shadow_type,
2243 gtk_paint_box (style, window, state_type, shadow_type, area, widget, detail,
2244 x, y, width, height);
2248 gtk_default_draw_option (GtkStyle *style,
2250 GtkStateType state_type,
2251 GtkShadowType shadow_type,
2260 gtk_paint_diamond (style, window, state_type, shadow_type, area, widget,
2261 detail, x, y, width, height);
2265 gtk_default_draw_cross (GtkStyle *style,
2267 GtkStateType state_type,
2268 GtkShadowType shadow_type,
2277 g_return_if_fail (style != NULL);
2278 g_return_if_fail (window != NULL);
2282 gtk_default_draw_ramp (GtkStyle *style,
2284 GtkStateType state_type,
2285 GtkShadowType shadow_type,
2289 GtkArrowType arrow_type,
2295 g_return_if_fail (style != NULL);
2296 g_return_if_fail (window != NULL);
2299 static void gtk_default_draw_tab (GtkStyle *style,
2301 GtkStateType state_type,
2302 GtkShadowType shadow_type,
2311 g_return_if_fail (style != NULL);
2312 g_return_if_fail (window != NULL);
2314 gtk_paint_box (style, window, state_type, shadow_type, area, widget, detail,
2315 x, y, width, height);
2319 gtk_default_draw_shadow_gap (GtkStyle *style,
2321 GtkStateType state_type,
2322 GtkShadowType shadow_type,
2330 GtkPositionType gap_side,
2339 g_return_if_fail (style != NULL);
2340 g_return_if_fail (window != NULL);
2342 if ((width == -1) && (height == -1))
2343 gdk_window_get_size (window, &width, &height);
2344 else if (width == -1)
2345 gdk_window_get_size (window, &width, NULL);
2346 else if (height == -1)
2347 gdk_window_get_size (window, NULL, &height);
2349 switch (shadow_type)
2351 case GTK_SHADOW_NONE:
2354 gc1 = style->dark_gc[state_type];
2355 gc2 = style->black_gc;
2356 gc3 = style->bg_gc[state_type];
2357 gc4 = style->light_gc[state_type];
2359 case GTK_SHADOW_ETCHED_IN:
2360 gc1 = style->dark_gc[state_type];
2361 gc2 = style->light_gc[state_type];
2362 gc3 = style->dark_gc[state_type];
2363 gc4 = style->light_gc[state_type];
2365 case GTK_SHADOW_OUT:
2366 gc1 = style->light_gc[state_type];
2367 gc2 = style->bg_gc[state_type];
2368 gc3 = style->dark_gc[state_type];
2369 gc4 = style->black_gc;
2371 case GTK_SHADOW_ETCHED_OUT:
2372 gc1 = style->light_gc[state_type];
2373 gc2 = style->dark_gc[state_type];
2374 gc3 = style->light_gc[state_type];
2375 gc4 = style->dark_gc[state_type];
2380 gdk_gc_set_clip_rectangle (gc1, area);
2381 gdk_gc_set_clip_rectangle (gc2, area);
2382 gdk_gc_set_clip_rectangle (gc3, area);
2383 gdk_gc_set_clip_rectangle (gc4, area);
2386 switch (shadow_type)
2388 case GTK_SHADOW_NONE:
2390 case GTK_SHADOW_OUT:
2391 case GTK_SHADOW_ETCHED_IN:
2392 case GTK_SHADOW_ETCHED_OUT:
2396 gdk_draw_line (window, gc1,
2397 x, y, x, y + height - 1);
2398 gdk_draw_line (window, gc2,
2399 x + 1, y, x + 1, y + height - 2);
2401 gdk_draw_line (window, gc3,
2402 x + 1, y + height - 2, x + width - 2, y + height - 2);
2403 gdk_draw_line (window, gc3,
2404 x + width - 2, y, x + width - 2, y + height - 2);
2405 gdk_draw_line (window, gc4,
2406 x, y + height - 1, x + width - 1, y + height - 1);
2407 gdk_draw_line (window, gc4,
2408 x + width - 1, y, x + width - 1, y + height - 1);
2411 gdk_draw_line (window, gc1,
2412 x, y, x + gap_x - 1, y);
2413 gdk_draw_line (window, gc2,
2414 x + 1, y + 1, x + gap_x - 1, y + 1);
2415 gdk_draw_line (window, gc2,
2416 x + gap_x, y, x + gap_x, y);
2418 if ((width - (gap_x + gap_width)) > 0)
2420 gdk_draw_line (window, gc1,
2421 x + gap_x + gap_width, y, x + width - 2, y);
2422 gdk_draw_line (window, gc2,
2423 x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
2424 gdk_draw_line (window, gc2,
2425 x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
2428 case GTK_POS_BOTTOM:
2429 gdk_draw_line (window, gc1,
2430 x, y, x + width - 1, y);
2431 gdk_draw_line (window, gc1,
2432 x, y, x, y + height - 1);
2433 gdk_draw_line (window, gc2,
2434 x + 1, y + 1, x + width - 2, y + 1);
2435 gdk_draw_line (window, gc2,
2436 x + 1, y + 1, x + 1, y + height - 1);
2438 gdk_draw_line (window, gc3,
2439 x + width - 2, y + 1, x + width - 2, y + height - 1);
2440 gdk_draw_line (window, gc4,
2441 x + width - 1, y, x + width - 1, y + height - 1);
2444 gdk_draw_line (window, gc4,
2445 x, y + height - 1, x + gap_x - 1, y + height - 1);
2446 gdk_draw_line (window, gc3,
2447 x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
2448 gdk_draw_line (window, gc3,
2449 x + gap_x, y + height - 1, x + gap_x, y + height - 1);
2451 if ((width - (gap_x + gap_width)) > 0)
2453 gdk_draw_line (window, gc4,
2454 x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
2455 gdk_draw_line (window, gc3,
2456 x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
2457 gdk_draw_line (window, gc3,
2458 x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
2462 gdk_draw_line (window, gc1,
2463 x, y, x + width - 1, y);
2464 gdk_draw_line (window, gc2,
2465 x, y + 1, x + width - 2, y + 1);
2467 gdk_draw_line (window, gc3,
2468 x, y + height - 2, x + width - 2, y + height - 2);
2469 gdk_draw_line (window, gc3,
2470 x + width - 2, y + 1, x + width - 2, y + height - 2);
2471 gdk_draw_line (window, gc4,
2472 x, y + height - 1, x + width - 1, y + height - 1);
2473 gdk_draw_line (window, gc4,
2474 x + width - 1, y, x + width - 1, y + height - 1);
2477 gdk_draw_line (window, gc1,
2478 x, y, x, y + gap_x - 1);
2479 gdk_draw_line (window, gc2,
2480 x + 1, y + 1, x + 1, y + gap_x - 1);
2481 gdk_draw_line (window, gc2,
2482 x, y + gap_x, x, y + gap_x);
2484 if ((width - (gap_x + gap_width)) > 0)
2486 gdk_draw_line (window, gc1,
2487 x, y + gap_x + gap_width, x, y + height - 2);
2488 gdk_draw_line (window, gc2,
2489 x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
2490 gdk_draw_line (window, gc2,
2491 x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
2495 gdk_draw_line (window, gc1,
2496 x, y, x + width - 1, y);
2497 gdk_draw_line (window, gc1,
2498 x, y, x, y + height - 1);
2499 gdk_draw_line (window, gc2,
2500 x + 1, y + 1, x + width - 1, y + 1);
2501 gdk_draw_line (window, gc2,
2502 x + 1, y + 1, x + 1, y + height - 2);
2504 gdk_draw_line (window, gc3,
2505 x + 1, y + height - 2, x + width - 1, y + height - 2);
2506 gdk_draw_line (window, gc4,
2507 x, y + height - 1, x + width - 1, y + height - 1);
2510 gdk_draw_line (window, gc4,
2511 x + width - 1, y, x + width - 1, y + gap_x - 1);
2512 gdk_draw_line (window, gc3,
2513 x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
2514 gdk_draw_line (window, gc3,
2515 x + width - 1, y + gap_x, x + width - 1, y + gap_x);
2517 if ((width - (gap_x + gap_width)) > 0)
2519 gdk_draw_line (window, gc4,
2520 x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
2521 gdk_draw_line (window, gc3,
2522 x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
2523 gdk_draw_line (window, gc3,
2524 x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
2531 gdk_gc_set_clip_rectangle (gc1, NULL);
2532 gdk_gc_set_clip_rectangle (gc2, NULL);
2533 gdk_gc_set_clip_rectangle (gc3, NULL);
2534 gdk_gc_set_clip_rectangle (gc4, NULL);
2539 gtk_default_draw_box_gap (GtkStyle *style,
2541 GtkStateType state_type,
2542 GtkShadowType shadow_type,
2550 GtkPositionType gap_side,
2559 g_return_if_fail (style != NULL);
2560 g_return_if_fail (window != NULL);
2562 gtk_style_apply_default_pixmap(style, window, state_type, area,
2563 x, y, width, height);
2565 if ((width == -1) && (height == -1))
2566 gdk_window_get_size (window, &width, &height);
2567 else if (width == -1)
2568 gdk_window_get_size (window, &width, NULL);
2569 else if (height == -1)
2570 gdk_window_get_size (window, NULL, &height);
2572 switch (shadow_type)
2574 case GTK_SHADOW_NONE:
2577 gc1 = style->dark_gc[state_type];
2578 gc2 = style->black_gc;
2579 gc3 = style->bg_gc[state_type];
2580 gc4 = style->light_gc[state_type];
2582 case GTK_SHADOW_ETCHED_IN:
2583 gc1 = style->dark_gc[state_type];
2584 gc2 = style->light_gc[state_type];
2585 gc3 = style->dark_gc[state_type];
2586 gc4 = style->light_gc[state_type];
2588 case GTK_SHADOW_OUT:
2589 gc1 = style->light_gc[state_type];
2590 gc2 = style->bg_gc[state_type];
2591 gc3 = style->dark_gc[state_type];
2592 gc4 = style->black_gc;
2594 case GTK_SHADOW_ETCHED_OUT:
2595 gc1 = style->light_gc[state_type];
2596 gc2 = style->dark_gc[state_type];
2597 gc3 = style->light_gc[state_type];
2598 gc4 = style->dark_gc[state_type];
2603 gdk_gc_set_clip_rectangle (gc1, area);
2604 gdk_gc_set_clip_rectangle (gc2, area);
2605 gdk_gc_set_clip_rectangle (gc3, area);
2606 gdk_gc_set_clip_rectangle (gc4, area);
2609 switch (shadow_type)
2611 case GTK_SHADOW_NONE:
2613 case GTK_SHADOW_OUT:
2614 case GTK_SHADOW_ETCHED_IN:
2615 case GTK_SHADOW_ETCHED_OUT:
2619 gdk_draw_line (window, gc1,
2620 x, y, x, y + height - 1);
2621 gdk_draw_line (window, gc2,
2622 x + 1, y, x + 1, y + height - 2);
2624 gdk_draw_line (window, gc3,
2625 x + 1, y + height - 2, x + width - 2, y + height - 2);
2626 gdk_draw_line (window, gc3,
2627 x + width - 2, y, x + width - 2, y + height - 2);
2628 gdk_draw_line (window, gc4,
2629 x, y + height - 1, x + width - 1, y + height - 1);
2630 gdk_draw_line (window, gc4,
2631 x + width - 1, y, x + width - 1, y + height - 1);
2634 gdk_draw_line (window, gc1,
2635 x, y, x + gap_x - 1, y);
2636 gdk_draw_line (window, gc2,
2637 x + 1, y + 1, x + gap_x - 1, y + 1);
2638 gdk_draw_line (window, gc2,
2639 x + gap_x, y, x + gap_x, y);
2641 if ((width - (gap_x + gap_width)) > 0)
2643 gdk_draw_line (window, gc1,
2644 x + gap_x + gap_width, y, x + width - 2, y);
2645 gdk_draw_line (window, gc2,
2646 x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
2647 gdk_draw_line (window, gc2,
2648 x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
2651 case GTK_POS_BOTTOM:
2652 gdk_draw_line (window, gc1,
2653 x, y, x + width - 1, y);
2654 gdk_draw_line (window, gc1,
2655 x, y, x, y + height - 1);
2656 gdk_draw_line (window, gc2,
2657 x + 1, y + 1, x + width - 2, y + 1);
2658 gdk_draw_line (window, gc2,
2659 x + 1, y + 1, x + 1, y + height - 1);
2661 gdk_draw_line (window, gc3,
2662 x + width - 2, y + 1, x + width - 2, y + height - 1);
2663 gdk_draw_line (window, gc4,
2664 x + width - 1, y, x + width - 1, y + height - 1);
2667 gdk_draw_line (window, gc4,
2668 x, y + height - 1, x + gap_x - 1, y + height - 1);
2669 gdk_draw_line (window, gc3,
2670 x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
2671 gdk_draw_line (window, gc3,
2672 x + gap_x, y + height - 1, x + gap_x, y + height - 1);
2674 if ((width - (gap_x + gap_width)) > 0)
2676 gdk_draw_line (window, gc4,
2677 x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
2678 gdk_draw_line (window, gc3,
2679 x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
2680 gdk_draw_line (window, gc3,
2681 x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
2685 gdk_draw_line (window, gc1,
2686 x, y, x + width - 1, y);
2687 gdk_draw_line (window, gc2,
2688 x, y + 1, x + width - 2, y + 1);
2690 gdk_draw_line (window, gc3,
2691 x, y + height - 2, x + width - 2, y + height - 2);
2692 gdk_draw_line (window, gc3,
2693 x + width - 2, y + 1, x + width - 2, y + height - 2);
2694 gdk_draw_line (window, gc4,
2695 x, y + height - 1, x + width - 1, y + height - 1);
2696 gdk_draw_line (window, gc4,
2697 x + width - 1, y, x + width - 1, y + height - 1);
2700 gdk_draw_line (window, gc1,
2701 x, y, x, y + gap_x - 1);
2702 gdk_draw_line (window, gc2,
2703 x + 1, y + 1, x + 1, y + gap_x - 1);
2704 gdk_draw_line (window, gc2,
2705 x, y + gap_x, x, y + gap_x);
2707 if ((width - (gap_x + gap_width)) > 0)
2709 gdk_draw_line (window, gc1,
2710 x, y + gap_x + gap_width, x, y + height - 2);
2711 gdk_draw_line (window, gc2,
2712 x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
2713 gdk_draw_line (window, gc2,
2714 x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
2718 gdk_draw_line (window, gc1,
2719 x, y, x + width - 1, y);
2720 gdk_draw_line (window, gc1,
2721 x, y, x, y + height - 1);
2722 gdk_draw_line (window, gc2,
2723 x + 1, y + 1, x + width - 1, y + 1);
2724 gdk_draw_line (window, gc2,
2725 x + 1, y + 1, x + 1, y + height - 2);
2727 gdk_draw_line (window, gc3,
2728 x + 1, y + height - 2, x + width - 1, y + height - 2);
2729 gdk_draw_line (window, gc4,
2730 x, y + height - 1, x + width - 1, y + height - 1);
2733 gdk_draw_line (window, gc4,
2734 x + width - 1, y, x + width - 1, y + gap_x - 1);
2735 gdk_draw_line (window, gc3,
2736 x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
2737 gdk_draw_line (window, gc3,
2738 x + width - 1, y + gap_x, x + width - 1, y + gap_x);
2740 if ((width - (gap_x + gap_width)) > 0)
2742 gdk_draw_line (window, gc4,
2743 x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
2744 gdk_draw_line (window, gc3,
2745 x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
2746 gdk_draw_line (window, gc3,
2747 x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
2754 gdk_gc_set_clip_rectangle (gc1, NULL);
2755 gdk_gc_set_clip_rectangle (gc2, NULL);
2756 gdk_gc_set_clip_rectangle (gc3, NULL);
2757 gdk_gc_set_clip_rectangle (gc4, NULL);
2762 gtk_default_draw_extension (GtkStyle *style,
2764 GtkStateType state_type,
2765 GtkShadowType shadow_type,
2773 GtkPositionType gap_side)
2780 g_return_if_fail (style != NULL);
2781 g_return_if_fail (window != NULL);
2783 gtk_style_apply_default_pixmap(style, window, GTK_STATE_NORMAL, area,
2784 x, y, width, height);
2786 if ((width == -1) && (height == -1))
2787 gdk_window_get_size (window, &width, &height);
2788 else if (width == -1)
2789 gdk_window_get_size (window, &width, NULL);
2790 else if (height == -1)
2791 gdk_window_get_size (window, NULL, &height);
2793 switch (shadow_type)
2795 case GTK_SHADOW_NONE:
2798 gc1 = style->dark_gc[state_type];
2799 gc2 = style->black_gc;
2800 gc3 = style->bg_gc[state_type];
2801 gc4 = style->light_gc[state_type];
2803 case GTK_SHADOW_ETCHED_IN:
2804 gc1 = style->dark_gc[state_type];
2805 gc2 = style->light_gc[state_type];
2806 gc3 = style->dark_gc[state_type];
2807 gc4 = style->light_gc[state_type];
2809 case GTK_SHADOW_OUT:
2810 gc1 = style->light_gc[state_type];
2811 gc2 = style->bg_gc[state_type];
2812 gc3 = style->dark_gc[state_type];
2813 gc4 = style->black_gc;
2815 case GTK_SHADOW_ETCHED_OUT:
2816 gc1 = style->light_gc[state_type];
2817 gc2 = style->dark_gc[state_type];
2818 gc3 = style->light_gc[state_type];
2819 gc4 = style->dark_gc[state_type];
2824 gdk_gc_set_clip_rectangle (gc1, area);
2825 gdk_gc_set_clip_rectangle (gc2, area);
2826 gdk_gc_set_clip_rectangle (gc3, area);
2827 gdk_gc_set_clip_rectangle (gc4, area);
2829 switch (shadow_type)
2831 case GTK_SHADOW_NONE:
2833 case GTK_SHADOW_OUT:
2834 case GTK_SHADOW_ETCHED_IN:
2835 case GTK_SHADOW_ETCHED_OUT:
2839 gtk_style_apply_default_pixmap(style, window, state_type, area,
2840 x + style->klass->xthickness,
2842 width - (2 * style->klass->xthickness),
2843 height - (style->klass->ythickness));
2844 gdk_draw_line (window, gc1,
2845 x, y, x, y + height - 2);
2846 gdk_draw_line (window, gc2,
2847 x + 1, y, x + 1, y + height - 2);
2849 gdk_draw_line (window, gc3,
2850 x + 2, y + height - 2, x + width - 2, y + height - 2);
2851 gdk_draw_line (window, gc3,
2852 x + width - 2, y, x + width - 2, y + height - 2);
2853 gdk_draw_line (window, gc4,
2854 x + 1, y + height - 1, x + width - 2, y + height - 1);
2855 gdk_draw_line (window, gc4,
2856 x + width - 1, y, x + width - 1, y + height - 2);
2858 case GTK_POS_BOTTOM:
2859 gtk_style_apply_default_pixmap(style, window, state_type, area,
2860 x + style->klass->xthickness,
2861 y + style->klass->ythickness,
2862 width - (2 * style->klass->xthickness),
2863 height - (style->klass->ythickness));
2864 gdk_draw_line (window, gc1,
2865 x + 1, y, x + width - 2, y);
2866 gdk_draw_line (window, gc1,
2867 x, y + 1, x, y + height - 1);
2868 gdk_draw_line (window, gc2,
2869 x + 1, y + 1, x + width - 2, y + 1);
2870 gdk_draw_line (window, gc2,
2871 x + 1, y + 1, x + 1, y + height - 1);
2873 gdk_draw_line (window, gc3,
2874 x + width - 2, y + 2, x + width - 2, y + height - 1);
2875 gdk_draw_line (window, gc4,
2876 x + width - 1, y + 1, x + width - 1, y + height - 1);
2879 gtk_style_apply_default_pixmap(style, window, state_type, area,
2881 y + style->klass->ythickness,
2882 width - (style->klass->xthickness),
2883 height - (2 * style->klass->ythickness));
2884 gdk_draw_line (window, gc1,
2885 x, y, x + width - 2, y);
2886 gdk_draw_line (window, gc2,
2887 x + 1, y + 1, x + width - 2, y + 1);
2889 gdk_draw_line (window, gc3,
2890 x, y + height - 2, x + width - 2, y + height - 2);
2891 gdk_draw_line (window, gc3,
2892 x + width - 2, y + 2, x + width - 2, y + height - 2);
2893 gdk_draw_line (window, gc4,
2894 x, y + height - 1, x + width - 2, y + height - 1);
2895 gdk_draw_line (window, gc4,
2896 x + width - 1, y + 1, x + width - 1, y + height - 2);
2899 gtk_style_apply_default_pixmap(style, window, state_type, area,
2900 x + style->klass->xthickness,
2901 y + style->klass->ythickness,
2902 width - (style->klass->xthickness),
2903 height - (2 * style->klass->ythickness));
2904 gdk_draw_line (window, gc1,
2905 x + 1, y, x + width - 1, y);
2906 gdk_draw_line (window, gc1,
2907 x, y + 1, x, y + height - 2);
2908 gdk_draw_line (window, gc2,
2909 x + 1, y + 1, x + width - 1, y + 1);
2910 gdk_draw_line (window, gc2,
2911 x + 1, y + 1, x + 1, y + height - 2);
2913 gdk_draw_line (window, gc3,
2914 x + 2, y + height - 2, x + width - 1, y + height - 2);
2915 gdk_draw_line (window, gc4,
2916 x + 1, y + height - 1, x + width - 1, y + height - 1);
2922 gdk_gc_set_clip_rectangle (gc1, NULL);
2923 gdk_gc_set_clip_rectangle (gc2, NULL);
2924 gdk_gc_set_clip_rectangle (gc3, NULL);
2925 gdk_gc_set_clip_rectangle (gc4, NULL);
2930 gtk_default_draw_focus (GtkStyle *style,
2940 g_return_if_fail (style != NULL);
2941 g_return_if_fail (window != NULL);
2943 if ((width == -1) && (height == -1))
2945 gdk_window_get_size (window, &width, &height);
2949 else if (width == -1)
2951 gdk_window_get_size (window, &width, NULL);
2954 else if (height == -1)
2956 gdk_window_get_size (window, NULL, &height);
2961 gdk_gc_set_clip_rectangle (style->black_gc, area);
2963 if (detail && !strcmp (detail, "add-mode"))
2965 gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_ON_OFF_DASH, 0, 0);
2966 gdk_gc_set_dashes (style->black_gc, 0, "\4\4", 2);
2968 gdk_draw_rectangle (window,
2969 style->black_gc, FALSE,
2970 x, y, width, height);
2972 gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_SOLID, 0, 0);
2976 gdk_draw_rectangle (window,
2977 style->black_gc, FALSE,
2978 x, y, width, height);
2982 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2987 gtk_default_draw_slider (GtkStyle *style,
2989 GtkStateType state_type,
2990 GtkShadowType shadow_type,
2998 GtkOrientation orientation)
3000 g_return_if_fail (style != NULL);
3001 g_return_if_fail (window != NULL);
3003 if ((width == -1) && (height == -1))
3004 gdk_window_get_size (window, &width, &height);
3005 else if (width == -1)
3006 gdk_window_get_size (window, &width, NULL);
3007 else if (height == -1)
3008 gdk_window_get_size (window, NULL, &height);
3010 gtk_paint_box (style, window, state_type, shadow_type,
3011 area, widget, detail, x, y, width, height);
3012 if (orientation == GTK_ORIENTATION_HORIZONTAL)
3013 gtk_paint_vline (style, window, state_type, area, widget, detail,
3014 style->klass->ythickness,
3015 height - style->klass->ythickness - 1, width / 2);
3017 gtk_paint_hline (style, window, state_type, area, widget, detail,
3018 style->klass->xthickness,
3019 width - style->klass->xthickness - 1, height / 2);
3023 gtk_default_draw_handle (GtkStyle *style,
3025 GtkStateType state_type,
3026 GtkShadowType shadow_type,
3034 GtkOrientation orientation)
3037 gint xthick, ythick;
3038 GdkGC *light_gc, *dark_gc;
3041 g_return_if_fail (style != NULL);
3042 g_return_if_fail (window != NULL);
3044 if ((width == -1) && (height == -1))
3045 gdk_window_get_size (window, &width, &height);
3046 else if (width == -1)
3047 gdk_window_get_size (window, &width, NULL);
3048 else if (height == -1)
3049 gdk_window_get_size (window, NULL, &height);
3051 gtk_paint_box (style, window, state_type, shadow_type, area, widget,
3052 detail, x, y, width, height);
3054 light_gc = style->light_gc[state_type];
3055 dark_gc = style->dark_gc[state_type];
3057 xthick = style->klass->xthickness;
3058 ythick = style->klass->ythickness;
3060 dest.x = x + xthick;
3061 dest.y = y + ythick;
3062 dest.width = width - (xthick * 2);
3063 dest.height = height - (ythick * 2);
3065 gdk_gc_set_clip_rectangle (light_gc, &dest);
3066 gdk_gc_set_clip_rectangle (dark_gc, &dest);
3068 for (yy = y + ythick; yy < (y + height - ythick); yy += 3)
3069 for (xx = x + xthick; xx < (x + width - xthick); xx += 6)
3071 gdk_draw_point (window, light_gc, xx, yy);
3072 gdk_draw_point (window, dark_gc, xx + 1, yy + 1);
3074 gdk_draw_point (window, light_gc, xx + 3, yy + 1);
3075 gdk_draw_point (window, dark_gc, xx + 4, yy + 2);
3077 gdk_gc_set_clip_rectangle (light_gc, NULL);
3078 gdk_gc_set_clip_rectangle (dark_gc, NULL);
3082 gtk_style_shade (GdkColor *a,
3090 red = (gdouble) a->red / 65535.0;
3091 green = (gdouble) a->green / 65535.0;
3092 blue = (gdouble) a->blue / 65535.0;
3094 rgb_to_hls (&red, &green, &blue);
3099 else if (green < 0.0)
3105 else if (blue < 0.0)
3108 hls_to_rgb (&red, &green, &blue);
3110 b->red = red * 65535.0;
3111 b->green = green * 65535.0;
3112 b->blue = blue * 65535.0;
3116 rgb_to_hls (gdouble *r,
3157 l = (max + min) / 2;
3164 s = (max - min) / (max + min);
3166 s = (max - min) / (2 - max - min);
3170 h = (green - blue) / delta;
3171 else if (green == max)
3172 h = 2 + (blue - red) / delta;
3173 else if (blue == max)
3174 h = 4 + (red - green) / delta;
3187 hls_to_rgb (gdouble *h,
3200 if (lightness <= 0.5)
3201 m2 = lightness * (1 + saturation);
3203 m2 = lightness + saturation - lightness * saturation;
3204 m1 = 2 * lightness - m2;
3206 if (saturation == 0)
3221 r = m1 + (m2 - m1) * hue / 60;
3225 r = m1 + (m2 - m1) * (240 - hue) / 60;
3236 g = m1 + (m2 - m1) * hue / 60;
3240 g = m1 + (m2 - m1) * (240 - hue) / 60;
3251 b = m1 + (m2 - m1) * hue / 60;
3255 b = m1 + (m2 - m1) * (240 - hue) / 60;
3266 gtk_paint_hline (GtkStyle *style,
3268 GtkStateType state_type,
3276 g_return_if_fail (style != NULL);
3277 g_return_if_fail (style->klass != NULL);
3278 g_return_if_fail (style->klass->draw_hline != NULL);
3280 (*style->klass->draw_hline) (style, window, state_type, area, widget, detail, x1, x2, y);
3284 gtk_paint_vline (GtkStyle *style,
3286 GtkStateType state_type,
3294 g_return_if_fail (style != NULL);
3295 g_return_if_fail (style->klass != NULL);
3296 g_return_if_fail (style->klass->draw_vline != NULL);
3298 (*style->klass->draw_vline) (style, window, state_type, area, widget, detail, y1, y2, x);
3302 gtk_paint_shadow (GtkStyle *style,
3304 GtkStateType state_type,
3305 GtkShadowType shadow_type,
3314 g_return_if_fail (style != NULL);
3315 g_return_if_fail (style->klass != NULL);
3316 g_return_if_fail (style->klass->draw_shadow != NULL);
3318 (*style->klass->draw_shadow) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3322 gtk_paint_polygon (GtkStyle *style,
3324 GtkStateType state_type,
3325 GtkShadowType shadow_type,
3333 g_return_if_fail (style != NULL);
3334 g_return_if_fail (style->klass != NULL);
3335 g_return_if_fail (style->klass->draw_shadow != NULL);
3337 (*style->klass->draw_polygon) (style, window, state_type, shadow_type, area, widget, detail, points, npoints, fill);
3341 gtk_paint_arrow (GtkStyle *style,
3343 GtkStateType state_type,
3344 GtkShadowType shadow_type,
3348 GtkArrowType arrow_type,
3355 g_return_if_fail (style != NULL);
3356 g_return_if_fail (style->klass != NULL);
3357 g_return_if_fail (style->klass->draw_arrow != NULL);
3359 (*style->klass->draw_arrow) (style, window, state_type, shadow_type, area, widget, detail, arrow_type, fill, x, y, width, height);
3363 gtk_paint_diamond (GtkStyle *style,
3365 GtkStateType state_type,
3366 GtkShadowType shadow_type,
3375 g_return_if_fail (style != NULL);
3376 g_return_if_fail (style->klass != NULL);
3377 g_return_if_fail (style->klass->draw_diamond != NULL);
3379 (*style->klass->draw_diamond) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3383 gtk_paint_oval (GtkStyle *style,
3385 GtkStateType state_type,
3386 GtkShadowType shadow_type,
3395 g_return_if_fail (style != NULL);
3396 g_return_if_fail (style->klass != NULL);
3397 g_return_if_fail (style->klass->draw_oval != NULL);
3399 (*style->klass->draw_oval) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3403 gtk_paint_string (GtkStyle *style,
3405 GtkStateType state_type,
3411 const gchar *string)
3413 g_return_if_fail (style != NULL);
3414 g_return_if_fail (style->klass != NULL);
3415 g_return_if_fail (style->klass->draw_oval != NULL);
3417 (*style->klass->draw_string) (style, window, state_type, area, widget, detail, x, y, string);
3421 gtk_paint_box (GtkStyle *style,
3423 GtkStateType state_type,
3424 GtkShadowType shadow_type,
3433 g_return_if_fail (style != NULL);
3434 g_return_if_fail (style->klass != NULL);
3435 g_return_if_fail (style->klass->draw_box != NULL);
3437 (*style->klass->draw_box) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3441 gtk_paint_flat_box (GtkStyle *style,
3443 GtkStateType state_type,
3444 GtkShadowType shadow_type,
3453 g_return_if_fail (style != NULL);
3454 g_return_if_fail (style->klass != NULL);
3455 g_return_if_fail (style->klass->draw_flat_box != NULL);
3457 (*style->klass->draw_flat_box) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3461 gtk_paint_check (GtkStyle *style,
3463 GtkStateType state_type,
3464 GtkShadowType shadow_type,
3473 g_return_if_fail (style != NULL);
3474 g_return_if_fail (style->klass != NULL);
3475 g_return_if_fail (style->klass->draw_check != NULL);
3477 (*style->klass->draw_check) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3481 gtk_paint_option (GtkStyle *style,
3483 GtkStateType state_type,
3484 GtkShadowType shadow_type,
3493 g_return_if_fail (style != NULL);
3494 g_return_if_fail (style->klass != NULL);
3495 g_return_if_fail (style->klass->draw_option != NULL);
3497 (*style->klass->draw_option) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3501 gtk_paint_cross (GtkStyle *style,
3503 GtkStateType state_type,
3504 GtkShadowType shadow_type,
3513 g_return_if_fail (style != NULL);
3514 g_return_if_fail (style->klass != NULL);
3515 g_return_if_fail (style->klass->draw_cross != NULL);
3517 (*style->klass->draw_cross) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3521 gtk_paint_ramp (GtkStyle *style,
3523 GtkStateType state_type,
3524 GtkShadowType shadow_type,
3528 GtkArrowType arrow_type,
3534 g_return_if_fail (style != NULL);
3535 g_return_if_fail (style->klass != NULL);
3536 g_return_if_fail (style->klass->draw_ramp != NULL);
3538 (*style->klass->draw_ramp) (style, window, state_type, shadow_type, area, widget, detail, arrow_type, x, y, width, height);
3542 gtk_paint_tab (GtkStyle *style,
3544 GtkStateType state_type,
3545 GtkShadowType shadow_type,
3554 g_return_if_fail (style != NULL);
3555 g_return_if_fail (style->klass != NULL);
3556 g_return_if_fail (style->klass->draw_tab != NULL);
3558 (*style->klass->draw_tab) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3562 gtk_paint_shadow_gap (GtkStyle *style,
3564 GtkStateType state_type,
3565 GtkShadowType shadow_type,
3573 GtkPositionType gap_side,
3577 g_return_if_fail (style != NULL);
3578 g_return_if_fail (style->klass != NULL);
3579 g_return_if_fail (style->klass->draw_shadow_gap != NULL);
3581 (*style->klass->draw_shadow_gap) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
3586 gtk_paint_box_gap (GtkStyle *style,
3588 GtkStateType state_type,
3589 GtkShadowType shadow_type,
3597 GtkPositionType gap_side,
3601 g_return_if_fail (style != NULL);
3602 g_return_if_fail (style->klass != NULL);
3603 g_return_if_fail (style->klass->draw_box_gap != NULL);
3605 (*style->klass->draw_box_gap) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
3609 gtk_paint_extension (GtkStyle *style,
3611 GtkStateType state_type,
3612 GtkShadowType shadow_type,
3620 GtkPositionType gap_side)
3622 g_return_if_fail (style != NULL);
3623 g_return_if_fail (style->klass != NULL);
3624 g_return_if_fail (style->klass->draw_extension != NULL);
3626 (*style->klass->draw_extension) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side);
3630 gtk_paint_focus (GtkStyle *style,
3640 g_return_if_fail (style != NULL);
3641 g_return_if_fail (style->klass != NULL);
3642 g_return_if_fail (style->klass->draw_focus != NULL);
3644 (*style->klass->draw_focus) (style, window, area, widget, detail, x, y, width, height);
3648 gtk_paint_slider (GtkStyle *style,
3650 GtkStateType state_type,
3651 GtkShadowType shadow_type,
3659 GtkOrientation orientation)
3661 g_return_if_fail (style != NULL);
3662 g_return_if_fail (style->klass != NULL);
3663 g_return_if_fail (style->klass->draw_slider != NULL);
3665 (*style->klass->draw_slider) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
3669 gtk_paint_handle (GtkStyle *style,
3671 GtkStateType state_type,
3672 GtkShadowType shadow_type,
3680 GtkOrientation orientation)
3682 g_return_if_fail (style != NULL);
3683 g_return_if_fail (style->klass != NULL);
3684 g_return_if_fail (style->klass->draw_handle != NULL);
3686 (*style->klass->draw_handle) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);