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);
290 static const GtkStyleClass default_class =
294 gtk_default_draw_hline,
295 gtk_default_draw_vline,
296 gtk_default_draw_shadow,
297 gtk_default_draw_polygon,
298 gtk_default_draw_arrow,
299 gtk_default_draw_diamond,
300 gtk_default_draw_oval,
301 gtk_default_draw_string,
302 gtk_default_draw_box,
303 gtk_default_draw_flat_box,
304 gtk_default_draw_check,
305 gtk_default_draw_option,
306 gtk_default_draw_cross,
307 gtk_default_draw_ramp,
308 gtk_default_draw_tab,
309 gtk_default_draw_shadow_gap,
310 gtk_default_draw_box_gap,
311 gtk_default_draw_extension,
312 gtk_default_draw_focus,
313 gtk_default_draw_slider,
314 gtk_default_draw_handle
316 GdkFont *default_font = NULL;
318 static GdkColor gtk_default_normal_fg = { 0, 0, 0, 0 };
319 static GdkColor gtk_default_active_fg = { 0, 0, 0, 0 };
320 static GdkColor gtk_default_prelight_fg = { 0, 0, 0, 0 };
321 static GdkColor gtk_default_selected_fg = { 0, 0xffff, 0xffff, 0xffff };
322 static GdkColor gtk_default_insensitive_fg = { 0, 0x7530, 0x7530, 0x7530 };
324 static GdkColor gtk_default_normal_bg = { 0, 0xd6d6, 0xd6d6, 0xd6d6 };
325 static GdkColor gtk_default_active_bg = { 0, 0xc350, 0xc350, 0xc350 };
326 static GdkColor gtk_default_prelight_bg = { 0, 0xea60, 0xea60, 0xea60 };
327 static GdkColor gtk_default_selected_bg = { 0, 0, 0, 0x9c40 };
328 static GdkColor gtk_default_insensitive_bg = { 0, 0xd6d6, 0xd6d6, 0xd6d6 };
331 gtk_style_copy (GtkStyle *style)
336 g_return_val_if_fail (style != NULL, NULL);
338 new_style = gtk_style_new ();
340 for (i = 0; i < 5; i++)
342 new_style->fg[i] = style->fg[i];
343 new_style->bg[i] = style->bg[i];
344 new_style->text[i] = style->text[i];
345 new_style->base[i] = style->base[i];
347 new_style->bg_pixmap[i] = style->bg_pixmap[i];
350 new_style->font = style->font;
351 gdk_font_ref (new_style->font);
357 gtk_style_duplicate (GtkStyle *style)
361 g_return_val_if_fail (style != NULL, NULL);
363 new_style = gtk_style_copy (style);
365 style->styles = g_slist_append (style->styles, new_style);
366 new_style->styles = style->styles;
370 new_style->rc_style = style->rc_style;
371 gtk_rc_style_ref (style->rc_style);
376 new_style->engine = style->engine;
377 new_style->engine->duplicate_style (new_style, style);
389 style = g_new0 (GtkStyle, 1);
393 gdk_font_load ("-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*");
395 style->font = default_font;
396 gdk_font_ref (style->font);
398 style->ref_count = 1;
399 style->attach_count = 0;
400 style->colormap = NULL;
402 style->klass = &default_class;
404 style->black.red = 0;
405 style->black.green = 0;
406 style->black.blue = 0;
408 style->white.red = 65535;
409 style->white.green = 65535;
410 style->white.blue = 65535;
412 style->black_gc = NULL;
413 style->white_gc = NULL;
415 style->fg[GTK_STATE_NORMAL] = gtk_default_normal_fg;
416 style->fg[GTK_STATE_ACTIVE] = gtk_default_active_fg;
417 style->fg[GTK_STATE_PRELIGHT] = gtk_default_prelight_fg;
418 style->fg[GTK_STATE_SELECTED] = gtk_default_selected_fg;
419 style->fg[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_fg;
421 style->bg[GTK_STATE_NORMAL] = gtk_default_normal_bg;
422 style->bg[GTK_STATE_ACTIVE] = gtk_default_active_bg;
423 style->bg[GTK_STATE_PRELIGHT] = gtk_default_prelight_bg;
424 style->bg[GTK_STATE_SELECTED] = gtk_default_selected_bg;
425 style->bg[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_bg;
427 for (i = 0; i < 4; i++)
429 style->text[i] = style->fg[i];
430 style->base[i] = style->white;
433 style->base[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_bg;
434 style->text[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_bg;
436 for (i = 0; i < 5; i++)
437 style->bg_pixmap[i] = NULL;
439 style->engine = NULL;
440 style->engine_data = NULL;
442 style->rc_style = NULL;
444 for (i = 0; i < 5; i++)
446 style->fg_gc[i] = NULL;
447 style->bg_gc[i] = NULL;
448 style->light_gc[i] = NULL;
449 style->dark_gc[i] = NULL;
450 style->mid_gc[i] = NULL;
451 style->text_gc[i] = NULL;
452 style->base_gc[i] = NULL;
459 gtk_style_attach (GtkStyle *style,
463 GtkStyle *new_style = NULL;
464 GdkColormap *colormap;
467 g_return_val_if_fail (style != NULL, NULL);
468 g_return_val_if_fail (window != NULL, NULL);
470 colormap = gdk_window_get_colormap (window);
471 depth = gdk_window_get_visual (window)->depth;
474 style->styles = g_slist_append (NULL, style);
476 styles = style->styles;
479 new_style = styles->data;
481 if (new_style->attach_count == 0)
483 gtk_style_init (new_style, colormap, depth);
486 else if ((new_style->colormap == colormap) &&
487 (new_style->depth == depth))
491 styles = styles->next;
496 new_style = gtk_style_duplicate (style);
497 gtk_style_init (new_style, colormap, depth);
500 if (new_style->attach_count == 0)
501 gtk_style_ref (new_style);
505 new_style->attach_count++;
511 gtk_style_detach (GtkStyle *style)
515 g_return_if_fail (style != NULL);
517 style->attach_count -= 1;
518 if (style->attach_count == 0)
521 style->engine->unrealize_style (style);
523 gtk_gc_release (style->black_gc);
524 gtk_gc_release (style->white_gc);
526 for (i = 0; i < 5; i++)
528 gtk_gc_release (style->fg_gc[i]);
529 gtk_gc_release (style->bg_gc[i]);
530 gtk_gc_release (style->light_gc[i]);
531 gtk_gc_release (style->dark_gc[i]);
532 gtk_gc_release (style->mid_gc[i]);
533 gtk_gc_release (style->text_gc[i]);
534 gtk_gc_release (style->base_gc[i]);
537 gtk_style_unref (style);
542 gtk_style_ref (GtkStyle *style)
544 g_return_val_if_fail (style != NULL, NULL);
546 style->ref_count += 1;
551 gtk_style_unref (GtkStyle *style)
553 g_return_if_fail (style != NULL);
555 style->ref_count -= 1;
556 if (style->ref_count == 0)
557 gtk_style_destroy (style);
561 gtk_style_init (GtkStyle *style,
562 GdkColormap *colormap,
565 GdkGCValues gc_values;
566 GdkGCValuesMask gc_values_mask;
569 g_return_if_fail (style != NULL);
571 style->colormap = colormap;
572 style->depth = depth;
574 for (i = 0; i < 5; i++)
576 gtk_style_shade (&style->bg[i], &style->light[i], LIGHTNESS_MULT);
577 gtk_style_shade (&style->bg[i], &style->dark[i], DARKNESS_MULT);
579 style->mid[i].red = (style->light[i].red + style->dark[i].red) / 2;
580 style->mid[i].green = (style->light[i].green + style->dark[i].green) / 2;
581 style->mid[i].blue = (style->light[i].blue + style->dark[i].blue) / 2;
584 gdk_color_black (colormap, &style->black);
585 gdk_color_white (colormap, &style->white);
587 gc_values_mask = GDK_GC_FOREGROUND | GDK_GC_FONT;
588 if (style->font->type == GDK_FONT_FONT)
590 gc_values.font = style->font;
592 else if (style->font->type == GDK_FONT_FONTSET)
594 gc_values.font = default_font;
597 gc_values.foreground = style->black;
598 style->black_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
600 gc_values.foreground = style->white;
601 style->white_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
603 for (i = 0; i < 5; i++)
605 if (style->rc_style && style->rc_style->bg_pixmap_name[i])
606 style->bg_pixmap[i] = gtk_rc_load_image (style->colormap,
608 style->rc_style->bg_pixmap_name[i]);
610 if (!gdk_color_alloc (colormap, &style->fg[i]))
611 g_warning ("unable to allocate color: ( %d %d %d )",
612 style->fg[i].red, style->fg[i].green, style->fg[i].blue);
613 if (!gdk_color_alloc (colormap, &style->bg[i]))
614 g_warning ("unable to allocate color: ( %d %d %d )",
615 style->bg[i].red, style->bg[i].green, style->bg[i].blue);
616 if (!gdk_color_alloc (colormap, &style->light[i]))
617 g_warning ("unable to allocate color: ( %d %d %d )",
618 style->light[i].red, style->light[i].green, style->light[i].blue);
619 if (!gdk_color_alloc (colormap, &style->dark[i]))
620 g_warning ("unable to allocate color: ( %d %d %d )",
621 style->dark[i].red, style->dark[i].green, style->dark[i].blue);
622 if (!gdk_color_alloc (colormap, &style->mid[i]))
623 g_warning ("unable to allocate color: ( %d %d %d )",
624 style->mid[i].red, style->mid[i].green, style->mid[i].blue);
625 if (!gdk_color_alloc (colormap, &style->text[i]))
626 g_warning ("unable to allocate color: ( %d %d %d )",
627 style->text[i].red, style->text[i].green, style->text[i].blue);
628 if (!gdk_color_alloc (colormap, &style->base[i]))
629 g_warning ("unable to allocate color: ( %d %d %d )",
630 style->base[i].red, style->base[i].green, style->base[i].blue);
632 gc_values.foreground = style->fg[i];
633 style->fg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
635 gc_values.foreground = style->bg[i];
636 style->bg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
638 gc_values.foreground = style->light[i];
639 style->light_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
641 gc_values.foreground = style->dark[i];
642 style->dark_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
644 gc_values.foreground = style->mid[i];
645 style->mid_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
647 gc_values.foreground = style->text[i];
648 style->text_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
650 gc_values.foreground = style->base[i];
651 style->base_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
654 style->engine->realize_style (style);
658 gtk_style_destroy (GtkStyle *style)
660 g_return_if_fail (style->attach_count == 0);
664 if (style->styles->data != style)
665 g_slist_remove (style->styles, style);
668 GSList *tmp_list = style->styles->next;
671 ((GtkStyle *)tmp_list->data)->styles = style->styles->next;
672 tmp_list = tmp_list->next;
674 g_slist_free_1 (style->styles);
680 style->engine->destroy_style (style);
681 gtk_theme_engine_unref (style->engine);
684 gdk_font_unref (style->font);
686 gtk_rc_style_unref (style->rc_style);
692 gtk_style_set_background (GtkStyle *style,
694 GtkStateType state_type)
697 gint parent_relative;
699 if (style->engine && style->engine->set_background)
701 (*style->engine->set_background) (style, window, state_type);
705 g_return_if_fail (style != NULL);
706 g_return_if_fail (window != NULL);
708 if (style->bg_pixmap[state_type])
710 if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
713 parent_relative = TRUE;
717 pixmap = style->bg_pixmap[state_type];
718 parent_relative = FALSE;
721 gdk_window_set_back_pixmap (window, pixmap, parent_relative);
724 gdk_window_set_background (window, &style->bg[state_type]);
729 gtk_draw_hline (GtkStyle *style,
731 GtkStateType state_type,
736 g_return_if_fail (style != NULL);
737 g_return_if_fail (style->klass != NULL);
738 g_return_if_fail (style->klass->draw_hline != NULL);
740 (*style->klass->draw_hline) (style, window, state_type, NULL, NULL, NULL, x1, x2, y);
745 gtk_draw_vline (GtkStyle *style,
747 GtkStateType state_type,
752 g_return_if_fail (style != NULL);
753 g_return_if_fail (style->klass != NULL);
754 g_return_if_fail (style->klass->draw_vline != NULL);
756 (*style->klass->draw_vline) (style, window, state_type, NULL, NULL, NULL, y1, y2, x);
761 gtk_draw_shadow (GtkStyle *style,
763 GtkStateType state_type,
764 GtkShadowType shadow_type,
770 g_return_if_fail (style != NULL);
771 g_return_if_fail (style->klass != NULL);
772 g_return_if_fail (style->klass->draw_shadow != NULL);
774 (*style->klass->draw_shadow) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
778 gtk_draw_polygon (GtkStyle *style,
780 GtkStateType state_type,
781 GtkShadowType shadow_type,
786 g_return_if_fail (style != NULL);
787 g_return_if_fail (style->klass != NULL);
788 g_return_if_fail (style->klass->draw_shadow != NULL);
790 (*style->klass->draw_polygon) (style, window, state_type, shadow_type, NULL, NULL, NULL, points, npoints, fill);
794 gtk_draw_arrow (GtkStyle *style,
796 GtkStateType state_type,
797 GtkShadowType shadow_type,
798 GtkArrowType arrow_type,
805 g_return_if_fail (style != NULL);
806 g_return_if_fail (style->klass != NULL);
807 g_return_if_fail (style->klass->draw_arrow != NULL);
809 (*style->klass->draw_arrow) (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, fill, x, y, width, height);
814 gtk_draw_diamond (GtkStyle *style,
816 GtkStateType state_type,
817 GtkShadowType shadow_type,
823 g_return_if_fail (style != NULL);
824 g_return_if_fail (style->klass != NULL);
825 g_return_if_fail (style->klass->draw_diamond != NULL);
827 (*style->klass->draw_diamond) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
832 gtk_draw_oval (GtkStyle *style,
834 GtkStateType state_type,
835 GtkShadowType shadow_type,
841 g_return_if_fail (style != NULL);
842 g_return_if_fail (style->klass != NULL);
843 g_return_if_fail (style->klass->draw_oval != NULL);
845 (*style->klass->draw_oval) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
849 gtk_draw_string (GtkStyle *style,
851 GtkStateType state_type,
856 g_return_if_fail (style != NULL);
857 g_return_if_fail (style->klass != NULL);
858 g_return_if_fail (style->klass->draw_oval != NULL);
860 (*style->klass->draw_string) (style, window, state_type, NULL, NULL, NULL, x, y, string);
864 gtk_draw_box (GtkStyle *style,
866 GtkStateType state_type,
867 GtkShadowType shadow_type,
873 g_return_if_fail (style != NULL);
874 g_return_if_fail (style->klass != NULL);
875 g_return_if_fail (style->klass->draw_box != NULL);
877 (*style->klass->draw_box) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
881 gtk_draw_flat_box (GtkStyle *style,
883 GtkStateType state_type,
884 GtkShadowType shadow_type,
890 g_return_if_fail (style != NULL);
891 g_return_if_fail (style->klass != NULL);
892 g_return_if_fail (style->klass->draw_flat_box != NULL);
894 (*style->klass->draw_flat_box) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
898 gtk_draw_check (GtkStyle *style,
900 GtkStateType state_type,
901 GtkShadowType shadow_type,
907 g_return_if_fail (style != NULL);
908 g_return_if_fail (style->klass != NULL);
909 g_return_if_fail (style->klass->draw_check != NULL);
911 (*style->klass->draw_check) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
915 gtk_draw_option (GtkStyle *style,
917 GtkStateType state_type,
918 GtkShadowType shadow_type,
924 g_return_if_fail (style != NULL);
925 g_return_if_fail (style->klass != NULL);
926 g_return_if_fail (style->klass->draw_option != NULL);
928 (*style->klass->draw_option) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
932 gtk_draw_cross (GtkStyle *style,
934 GtkStateType state_type,
935 GtkShadowType shadow_type,
941 g_return_if_fail (style != NULL);
942 g_return_if_fail (style->klass != NULL);
943 g_return_if_fail (style->klass->draw_cross != NULL);
945 (*style->klass->draw_cross) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
949 gtk_draw_ramp (GtkStyle *style,
951 GtkStateType state_type,
952 GtkShadowType shadow_type,
953 GtkArrowType arrow_type,
959 g_return_if_fail (style != NULL);
960 g_return_if_fail (style->klass != NULL);
961 g_return_if_fail (style->klass->draw_ramp != NULL);
963 (*style->klass->draw_ramp) (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, x, y, width, height);
967 gtk_draw_tab (GtkStyle *style,
969 GtkStateType state_type,
970 GtkShadowType shadow_type,
976 g_return_if_fail (style != NULL);
977 g_return_if_fail (style->klass != NULL);
978 g_return_if_fail (style->klass->draw_tab != NULL);
980 (*style->klass->draw_tab) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
984 gtk_draw_shadow_gap (GtkStyle *style,
986 GtkStateType state_type,
987 GtkShadowType shadow_type,
992 GtkPositionType gap_side,
996 g_return_if_fail (style != NULL);
997 g_return_if_fail (style->klass != NULL);
998 g_return_if_fail (style->klass->draw_shadow_gap != NULL);
1000 (*style->klass->draw_shadow_gap) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width);
1004 gtk_draw_box_gap (GtkStyle *style,
1006 GtkStateType state_type,
1007 GtkShadowType shadow_type,
1012 GtkPositionType gap_side,
1016 g_return_if_fail (style != NULL);
1017 g_return_if_fail (style->klass != NULL);
1018 g_return_if_fail (style->klass->draw_box_gap != NULL);
1020 (*style->klass->draw_box_gap) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width);
1024 gtk_draw_extension (GtkStyle *style,
1026 GtkStateType state_type,
1027 GtkShadowType shadow_type,
1032 GtkPositionType gap_side)
1034 g_return_if_fail (style != NULL);
1035 g_return_if_fail (style->klass != NULL);
1036 g_return_if_fail (style->klass->draw_extension != NULL);
1038 (*style->klass->draw_extension) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side);
1042 gtk_draw_focus (GtkStyle *style,
1049 g_return_if_fail (style != NULL);
1050 g_return_if_fail (style->klass != NULL);
1051 g_return_if_fail (style->klass->draw_focus != NULL);
1053 (*style->klass->draw_focus) (style, window, NULL, NULL, NULL, x, y, width, height);
1057 gtk_draw_slider (GtkStyle *style,
1059 GtkStateType state_type,
1060 GtkShadowType shadow_type,
1065 GtkOrientation orientation)
1067 g_return_if_fail (style != NULL);
1068 g_return_if_fail (style->klass != NULL);
1069 g_return_if_fail (style->klass->draw_slider != NULL);
1071 (*style->klass->draw_slider) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
1075 gtk_draw_handle (GtkStyle *style,
1077 GtkStateType state_type,
1078 GtkShadowType shadow_type,
1083 GtkOrientation orientation)
1085 g_return_if_fail (style != NULL);
1086 g_return_if_fail (style->klass != NULL);
1087 g_return_if_fail (style->klass->draw_handle != NULL);
1089 (*style->klass->draw_handle) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
1092 /* Default functions */
1094 gtk_style_apply_default_pixmap(GtkStyle *style,
1096 GtkStateType state_type,
1103 GdkRectangle new_rect, old_rect;
1106 if ((!style->bg_pixmap[state_type]) ||
1107 (gdk_window_get_type(window) == GDK_WINDOW_PIXMAP))
1109 gc = style->bg_gc[state_type];
1113 old_rect.width = width;
1114 old_rect.height = height;
1118 if (gdk_rectangle_intersect(area, &old_rect, &new_rect))
1119 gdk_draw_rectangle(window, gc, TRUE,
1120 new_rect.x, new_rect.y, new_rect.width, new_rect.height);
1123 gdk_draw_rectangle(window, gc, TRUE,
1124 x, y, width, height);
1128 if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
1129 gdk_window_set_back_pixmap(window, NULL, TRUE);
1131 gdk_window_set_back_pixmap(window, style->bg_pixmap[state_type], FALSE);
1135 old_rect.width = width;
1136 old_rect.height = height;
1138 if ((area) && (gdk_rectangle_intersect(area, &old_rect, &new_rect)))
1139 gdk_window_clear_area(window, new_rect.x, new_rect.y, new_rect.width, new_rect.height);
1141 gdk_window_clear_area(window, x, y, width, height);
1146 gtk_default_draw_hline (GtkStyle *style,
1148 GtkStateType state_type,
1156 gint thickness_light;
1157 gint thickness_dark;
1160 g_return_if_fail (style != NULL);
1161 g_return_if_fail (window != NULL);
1163 thickness_light = style->klass->ythickness / 2;
1164 thickness_dark = style->klass->ythickness - thickness_light;
1168 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1169 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1172 if (detail && !strcmp (detail, "label"))
1174 if (state_type == GTK_STATE_INSENSITIVE)
1175 gdk_draw_line (window, style->white_gc, x1 + 1, y + 1, x2 + 1, y + 1);
1176 gdk_draw_line (window, style->fg_gc[state_type], x1, y, x2, y);
1180 for (i = 0; i < thickness_dark; i++)
1182 gdk_draw_line (window, style->light_gc[state_type], x2 - i - 1, y + i, x2, y + i);
1183 gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x2 - i - 1, y + i);
1186 y += thickness_dark;
1187 for (i = 0; i < thickness_light; i++)
1189 gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x1 + thickness_light - i - 1, y + i);
1190 gdk_draw_line (window, style->light_gc[state_type], x1 + thickness_light - i - 1, y + i, x2, y + i);
1196 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
1197 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
1203 gtk_default_draw_vline (GtkStyle *style,
1205 GtkStateType state_type,
1213 gint thickness_light;
1214 gint thickness_dark;
1217 g_return_if_fail (style != NULL);
1218 g_return_if_fail (window != NULL);
1220 thickness_light = style->klass->xthickness / 2;
1221 thickness_dark = style->klass->xthickness - thickness_light;
1225 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1226 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1228 for (i = 0; i < thickness_dark; i++)
1230 gdk_draw_line (window, style->light_gc[state_type], x + i, y2 - i - 1, x + i, y2);
1231 gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y2 - i - 1);
1234 x += thickness_dark;
1235 for (i = 0; i < thickness_light; i++)
1237 gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y1 + thickness_light - i);
1238 gdk_draw_line (window, style->light_gc[state_type], x + i, y1 + thickness_light - i, x + i, y2);
1242 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
1243 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
1249 gtk_default_draw_shadow (GtkStyle *style,
1251 GtkStateType state_type,
1252 GtkShadowType shadow_type,
1263 gint thickness_light;
1264 gint thickness_dark;
1267 g_return_if_fail (style != NULL);
1268 g_return_if_fail (window != NULL);
1270 if ((width == -1) && (height == -1))
1271 gdk_window_get_size (window, &width, &height);
1272 else if (width == -1)
1273 gdk_window_get_size (window, &width, NULL);
1274 else if (height == -1)
1275 gdk_window_get_size (window, NULL, &height);
1277 switch (shadow_type)
1279 case GTK_SHADOW_NONE:
1282 case GTK_SHADOW_ETCHED_IN:
1283 gc1 = style->light_gc[state_type];
1284 gc2 = style->dark_gc[state_type];
1286 case GTK_SHADOW_OUT:
1287 case GTK_SHADOW_ETCHED_OUT:
1288 gc1 = style->dark_gc[state_type];
1289 gc2 = style->light_gc[state_type];
1295 gdk_gc_set_clip_rectangle (gc1, area);
1296 gdk_gc_set_clip_rectangle (gc2, area);
1297 if ((shadow_type == GTK_SHADOW_IN) ||
1298 (shadow_type == GTK_SHADOW_OUT))
1300 gdk_gc_set_clip_rectangle (style->black_gc, area);
1301 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
1304 switch (shadow_type)
1306 case GTK_SHADOW_NONE:
1310 gdk_draw_line (window, gc1,
1311 x, y + height - 1, x + width - 1, y + height - 1);
1312 gdk_draw_line (window, gc1,
1313 x + width - 1, y, x + width - 1, y + height - 1);
1315 gdk_draw_line (window, style->bg_gc[state_type],
1316 x + 1, y + height - 2, x + width - 2, y + height - 2);
1317 gdk_draw_line (window, style->bg_gc[state_type],
1318 x + width - 2, y + 1, x + width - 2, y + height - 2);
1320 gdk_draw_line (window, style->black_gc,
1321 x + 1, y + 1, x + width - 2, y + 1);
1322 gdk_draw_line (window, style->black_gc,
1323 x + 1, y + 1, x + 1, y + height - 2);
1325 gdk_draw_line (window, gc2,
1326 x, y, x + width - 1, y);
1327 gdk_draw_line (window, gc2,
1328 x, y, x, y + height - 1);
1331 case GTK_SHADOW_OUT:
1332 gdk_draw_line (window, gc1,
1333 x + 1, y + height - 2, x + width - 2, y + height - 2);
1334 gdk_draw_line (window, gc1,
1335 x + width - 2, y + 1, x + width - 2, y + height - 2);
1337 gdk_draw_line (window, gc2,
1338 x, y, x + width - 1, y);
1339 gdk_draw_line (window, gc2,
1340 x, y, x, y + height - 1);
1342 gdk_draw_line (window, style->bg_gc[state_type],
1343 x + 1, y + 1, x + width - 2, y + 1);
1344 gdk_draw_line (window, style->bg_gc[state_type],
1345 x + 1, y + 1, x + 1, y + height - 2);
1347 gdk_draw_line (window, style->black_gc,
1348 x, y + height - 1, x + width - 1, y + height - 1);
1349 gdk_draw_line (window, style->black_gc,
1350 x + width - 1, y, x + width - 1, y + height - 1);
1353 case GTK_SHADOW_ETCHED_IN:
1354 case GTK_SHADOW_ETCHED_OUT:
1355 thickness_light = 1;
1358 for (i = 0; i < thickness_dark; i++)
1360 gdk_draw_line (window, gc1,
1364 y + height - i - 1);
1365 gdk_draw_line (window, gc1,
1369 y + height - i - 1);
1371 gdk_draw_line (window, gc2,
1376 gdk_draw_line (window, gc2,
1380 y + height - i - 2);
1383 for (i = 0; i < thickness_light; i++)
1385 gdk_draw_line (window, gc1,
1386 x + thickness_dark + i,
1387 y + thickness_dark + i,
1388 x + width - thickness_dark - i - 1,
1389 y + thickness_dark + i);
1390 gdk_draw_line (window, gc1,
1391 x + thickness_dark + i,
1392 y + thickness_dark + i,
1393 x + thickness_dark + i,
1394 y + height - thickness_dark - i - 1);
1396 gdk_draw_line (window, gc2,
1397 x + thickness_dark + i,
1398 y + height - thickness_light - i - 1,
1399 x + width - thickness_light - 1,
1400 y + height - thickness_light - i - 1);
1401 gdk_draw_line (window, gc2,
1402 x + width - thickness_light - i - 1,
1403 y + thickness_dark + i,
1404 x + width - thickness_light - i - 1,
1405 y + height - thickness_light - 1);
1411 gdk_gc_set_clip_rectangle (gc1, NULL);
1412 gdk_gc_set_clip_rectangle (gc2, NULL);
1413 if ((shadow_type == GTK_SHADOW_IN) ||
1414 (shadow_type == GTK_SHADOW_OUT))
1416 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
1417 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
1424 gtk_default_draw_polygon (GtkStyle *style,
1426 GtkStateType state_type,
1427 GtkShadowType shadow_type,
1436 #define M_PI 3.14159265358979323846
1439 #define M_PI_4 0.78539816339744830962
1442 static const gdouble pi_over_4 = M_PI_4;
1443 static const gdouble pi_3_over_4 = M_PI_4 * 3;
1454 g_return_if_fail (style != NULL);
1455 g_return_if_fail (window != NULL);
1456 g_return_if_fail (points != NULL);
1458 switch (shadow_type)
1461 gc1 = style->bg_gc[state_type];
1462 gc2 = style->dark_gc[state_type];
1463 gc3 = style->light_gc[state_type];
1464 gc4 = style->black_gc;
1466 case GTK_SHADOW_ETCHED_IN:
1467 gc1 = style->light_gc[state_type];
1468 gc2 = style->dark_gc[state_type];
1469 gc3 = style->dark_gc[state_type];
1470 gc4 = style->light_gc[state_type];
1472 case GTK_SHADOW_OUT:
1473 gc1 = style->dark_gc[state_type];
1474 gc2 = style->light_gc[state_type];
1475 gc3 = style->black_gc;
1476 gc4 = style->bg_gc[state_type];
1478 case GTK_SHADOW_ETCHED_OUT:
1479 gc1 = style->dark_gc[state_type];
1480 gc2 = style->light_gc[state_type];
1481 gc3 = style->light_gc[state_type];
1482 gc4 = style->dark_gc[state_type];
1490 gdk_gc_set_clip_rectangle (gc1, area);
1491 gdk_gc_set_clip_rectangle (gc2, area);
1492 gdk_gc_set_clip_rectangle (gc3, area);
1493 gdk_gc_set_clip_rectangle (gc4, area);
1497 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, npoints);
1501 for (i = 0; i < npoints; i++)
1503 if ((points[i].x == points[i+1].x) &&
1504 (points[i].y == points[i+1].y))
1510 angle = atan2 (points[i+1].y - points[i].y,
1511 points[i+1].x - points[i].x);
1514 if ((angle > -pi_3_over_4) && (angle < pi_over_4))
1516 if (angle > -pi_over_4)
1527 gdk_draw_line (window, gc1,
1528 points[i].x-xadjust, points[i].y-yadjust,
1529 points[i+1].x-xadjust, points[i+1].y-yadjust);
1530 gdk_draw_line (window, gc3,
1531 points[i].x, points[i].y,
1532 points[i+1].x, points[i+1].y);
1536 if ((angle < -pi_3_over_4) || (angle > pi_3_over_4))
1547 gdk_draw_line (window, gc4,
1548 points[i].x+xadjust, points[i].y+yadjust,
1549 points[i+1].x+xadjust, points[i+1].y+yadjust);
1550 gdk_draw_line (window, gc2,
1551 points[i].x, points[i].y,
1552 points[i+1].x, points[i+1].y);
1557 gdk_gc_set_clip_rectangle (gc1, NULL);
1558 gdk_gc_set_clip_rectangle (gc2, NULL);
1559 gdk_gc_set_clip_rectangle (gc3, NULL);
1560 gdk_gc_set_clip_rectangle (gc4, NULL);
1565 gtk_default_draw_arrow (GtkStyle *style,
1567 GtkStateType state_type,
1568 GtkShadowType shadow_type,
1572 GtkArrowType arrow_type,
1587 g_return_if_fail (style != NULL);
1588 g_return_if_fail (window != NULL);
1590 switch (shadow_type)
1593 gc1 = style->bg_gc[state_type];
1594 gc2 = style->dark_gc[state_type];
1595 gc3 = style->light_gc[state_type];
1596 gc4 = style->black_gc;
1598 case GTK_SHADOW_OUT:
1599 gc1 = style->dark_gc[state_type];
1600 gc2 = style->light_gc[state_type];
1601 gc3 = style->black_gc;
1602 gc4 = style->bg_gc[state_type];
1604 case GTK_SHADOW_ETCHED_IN:
1605 gc1 = style->light_gc[state_type];
1606 gc2 = style->dark_gc[state_type];
1610 case GTK_SHADOW_ETCHED_OUT:
1611 gc1 = style->dark_gc[state_type];
1612 gc2 = style->light_gc[state_type];
1620 if ((width == -1) && (height == -1))
1621 gdk_window_get_size (window, &width, &height);
1622 else if (width == -1)
1623 gdk_window_get_size (window, &width, NULL);
1624 else if (height == -1)
1625 gdk_window_get_size (window, NULL, &height);
1627 half_width = width / 2;
1628 half_height = height / 2;
1632 gdk_gc_set_clip_rectangle (gc1, area);
1633 gdk_gc_set_clip_rectangle (gc2, area);
1636 gdk_gc_set_clip_rectangle (gc3, area);
1637 gdk_gc_set_clip_rectangle (gc4, area);
1646 points[0].x = x + half_width;
1649 points[1].y = y + height - 1;
1650 points[2].x = x + width - 1;
1651 points[2].y = y + height - 1;
1653 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1656 switch (shadow_type)
1659 case GTK_SHADOW_OUT:
1661 gdk_draw_line (window, gc1,
1662 x + 1, y + height - 2,
1663 x + width - 2, y + height - 2);
1664 gdk_draw_line (window, gc3,
1665 x + 0, y + height - 1,
1666 x + width - 1, y + height - 1);
1668 gdk_draw_line (window, gc1,
1669 x + width - 2, y + height - 1,
1670 x + half_width, y + 1);
1671 gdk_draw_line (window, gc3,
1672 x + width - 1, y + height - 1,
1675 gdk_draw_line (window, gc4,
1676 x + half_width, y + 1,
1677 x + 1, y + height - 1);
1678 gdk_draw_line (window, gc2,
1683 case GTK_SHADOW_ETCHED_IN:
1684 case GTK_SHADOW_ETCHED_OUT:
1685 gdk_draw_line (window, gc1,
1686 x + half_width, y + 1,
1687 x + 1, y + height - 1);
1688 gdk_draw_line (window, gc1,
1689 x + 1, y + height - 1,
1690 x + width - 1, y + height - 1);
1691 gdk_draw_line (window, gc1,
1692 x + width - 1, y + height - 1,
1693 x + half_width + 1, y + 1);
1695 points[0].x = x + half_width;
1698 points[1].y = y + height - 2;
1699 points[2].x = x + width - 2;
1700 points[2].y = y + height - 2;
1702 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1710 case GTK_ARROW_DOWN:
1713 points[0].x = x + width - 1;
1717 points[2].x = x + half_width;
1718 points[2].y = y + height - 1;
1720 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1722 switch (shadow_type)
1725 case GTK_SHADOW_OUT:
1726 gdk_draw_line (window, gc4,
1728 y + 1, x + 1, y + 1);
1729 gdk_draw_line (window, gc2,
1733 gdk_draw_line (window, gc4,
1735 x + half_width, y + height - 2);
1736 gdk_draw_line (window, gc2,
1738 x + half_width, y + height - 1);
1740 gdk_draw_line (window, gc1,
1741 x + half_width, y + height - 2,
1743 gdk_draw_line (window, gc3,
1744 x + half_width, y + height - 1,
1748 case GTK_SHADOW_ETCHED_IN:
1749 case GTK_SHADOW_ETCHED_OUT:
1750 gdk_draw_line (window, gc1,
1751 x + width - 1, y + 1,
1753 gdk_draw_line (window, gc1,
1755 x + half_width + 1, y + height - 1);
1756 gdk_draw_line (window, gc1,
1757 x + half_width + 1, y + height - 2,
1760 points[0].x = x + width - 2;
1764 points[2].x = x + half_width;
1765 points[2].y = y + height - 2;
1767 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1774 case GTK_ARROW_LEFT:
1778 points[0].y = y + half_height;
1779 points[1].x = x + width - 1;
1780 points[1].y = y + height - 1;
1781 points[2].x = x + width - 1;
1784 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1787 switch (shadow_type)
1790 case GTK_SHADOW_OUT:
1791 gdk_draw_line (window, gc1,
1792 x + 1, y + half_height,
1793 x + width - 1, y + height - 1);
1794 gdk_draw_line (window, gc3,
1796 x + width - 1, y + height - 1);
1798 gdk_draw_line (window, gc1,
1799 x + width - 2, y + height - 1,
1800 x + width - 2, y + 1);
1801 gdk_draw_line (window, gc3,
1802 x + width - 1, y + height - 1,
1805 gdk_draw_line (window, gc4,
1806 x + width - 1, y + 1,
1807 x + 1, y + half_height);
1808 gdk_draw_line (window, gc2,
1810 x, y + half_height);
1813 case GTK_SHADOW_ETCHED_IN:
1814 case GTK_SHADOW_ETCHED_OUT:
1815 gdk_draw_line (window, gc1,
1816 x + width - 1, y + 1,
1817 x + 1, y + half_height);
1818 gdk_draw_line (window, gc1,
1819 x + 1, y + half_height + 1,
1820 x + width - 1, y + height - 1);
1821 gdk_draw_line (window, gc1,
1822 x + width - 1, y + height - 1,
1823 x + width - 1, y + 1);
1825 points[0].x = x + width - 2;
1828 points[1].y = y + half_height;
1829 points[2].x = x + width - 2;
1830 points[2].y = y + height - 2;
1832 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1839 case GTK_ARROW_RIGHT:
1842 points[0].x = x + width - 1;
1843 points[0].y = y + half_height;
1847 points[2].y = y + height - 1;
1849 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1852 switch (shadow_type)
1855 case GTK_SHADOW_OUT:
1856 gdk_draw_line (window, gc4,
1857 x + width - 1, y + half_height,
1859 gdk_draw_line (window, gc2,
1860 x + width - 1, y + half_height,
1862 gdk_draw_line (window, gc4,
1864 x + 1, y + height - 2);
1865 gdk_draw_line (window, gc2,
1869 gdk_draw_line (window, gc1,
1870 x + 1, y + height - 2,
1871 x + width - 1, y + half_height);
1872 gdk_draw_line (window, gc3,
1874 x + width - 1, y + half_height);
1877 case GTK_SHADOW_ETCHED_IN:
1878 case GTK_SHADOW_ETCHED_OUT:
1879 gdk_draw_line (window, gc1,
1880 x + width - 1, y + half_height + 1,
1882 gdk_draw_line (window, gc1,
1884 x + 1, y + height - 1);
1885 gdk_draw_line (window, gc1,
1886 x + 1, y + height - 1,
1887 x + width - 1, y + half_height + 1);
1889 points[0].x = x + width - 2;
1890 points[0].y = y + half_height;
1894 points[2].y = y + height - 1;
1896 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1906 gdk_gc_set_clip_rectangle (gc1, NULL);
1907 gdk_gc_set_clip_rectangle (gc2, NULL);
1910 gdk_gc_set_clip_rectangle (gc3, NULL);
1911 gdk_gc_set_clip_rectangle (gc4, NULL);
1917 gtk_default_draw_diamond (GtkStyle *style,
1919 GtkStateType state_type,
1920 GtkShadowType shadow_type,
1932 g_return_if_fail (style != NULL);
1933 g_return_if_fail (window != NULL);
1935 if ((width == -1) && (height == -1))
1936 gdk_window_get_size (window, &width, &height);
1937 else if (width == -1)
1938 gdk_window_get_size (window, &width, NULL);
1939 else if (height == -1)
1940 gdk_window_get_size (window, NULL, &height);
1942 half_width = width / 2;
1943 half_height = height / 2;
1947 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1948 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
1949 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1950 gdk_gc_set_clip_rectangle (style->black_gc, area);
1952 switch (shadow_type)
1955 gdk_draw_line (window, style->bg_gc[state_type],
1956 x + 2, y + half_height,
1957 x + half_width, y + height - 2);
1958 gdk_draw_line (window, style->bg_gc[state_type],
1959 x + half_width, y + height - 2,
1960 x + width - 2, y + half_height);
1961 gdk_draw_line (window, style->light_gc[state_type],
1962 x + 1, y + half_height,
1963 x + half_width, y + height - 1);
1964 gdk_draw_line (window, style->light_gc[state_type],
1965 x + half_width, y + height - 1,
1966 x + width - 1, y + half_height);
1967 gdk_draw_line (window, style->light_gc[state_type],
1969 x + half_width, y + height);
1970 gdk_draw_line (window, style->light_gc[state_type],
1971 x + half_width, y + height,
1972 x + width, y + half_height);
1974 gdk_draw_line (window, style->black_gc,
1975 x + 2, y + half_height,
1976 x + half_width, y + 2);
1977 gdk_draw_line (window, style->black_gc,
1978 x + half_width, y + 2,
1979 x + width - 2, y + half_height);
1980 gdk_draw_line (window, style->dark_gc[state_type],
1981 x + 1, y + half_height,
1982 x + half_width, y + 1);
1983 gdk_draw_line (window, style->dark_gc[state_type],
1984 x + half_width, y + 1,
1985 x + width - 1, y + half_height);
1986 gdk_draw_line (window, style->dark_gc[state_type],
1989 gdk_draw_line (window, style->dark_gc[state_type],
1991 x + width, y + half_height);
1993 case GTK_SHADOW_OUT:
1994 gdk_draw_line (window, style->dark_gc[state_type],
1995 x + 2, y + half_height,
1996 x + half_width, y + height - 2);
1997 gdk_draw_line (window, style->dark_gc[state_type],
1998 x + half_width, y + height - 2,
1999 x + width - 2, y + half_height);
2000 gdk_draw_line (window, style->dark_gc[state_type],
2001 x + 1, y + half_height,
2002 x + half_width, y + height - 1);
2003 gdk_draw_line (window, style->dark_gc[state_type],
2004 x + half_width, y + height - 1,
2005 x + width - 1, y + half_height);
2006 gdk_draw_line (window, style->black_gc,
2008 x + half_width, y + height);
2009 gdk_draw_line (window, style->black_gc,
2010 x + half_width, y + height,
2011 x + width, y + half_height);
2013 gdk_draw_line (window, style->bg_gc[state_type],
2014 x + 2, y + half_height,
2015 x + half_width, y + 2);
2016 gdk_draw_line (window, style->bg_gc[state_type],
2017 x + half_width, y + 2,
2018 x + width - 2, y + half_height);
2019 gdk_draw_line (window, style->light_gc[state_type],
2020 x + 1, y + half_height,
2021 x + half_width, y + 1);
2022 gdk_draw_line (window, style->light_gc[state_type],
2023 x + half_width, y + 1,
2024 x + width - 1, y + half_height);
2025 gdk_draw_line (window, style->light_gc[state_type],
2028 gdk_draw_line (window, style->light_gc[state_type],
2030 x + width, y + half_height);
2037 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
2038 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2039 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
2040 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2046 gtk_default_draw_oval (GtkStyle *style,
2048 GtkStateType state_type,
2049 GtkShadowType shadow_type,
2058 g_return_if_fail (style != NULL);
2059 g_return_if_fail (window != NULL);
2063 gtk_default_draw_string (GtkStyle *style,
2065 GtkStateType state_type,
2071 const gchar *string)
2073 g_return_if_fail (style != NULL);
2074 g_return_if_fail (window != NULL);
2078 gdk_gc_set_clip_rectangle (style->white_gc, area);
2079 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], area);
2081 if (state_type == GTK_STATE_INSENSITIVE)
2082 gdk_draw_string (window, style->font, style->white_gc, x + 1, y + 1, string);
2083 gdk_draw_string (window, style->font, style->fg_gc[state_type], x, y, string);
2086 gdk_gc_set_clip_rectangle (style->white_gc, NULL);
2087 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], NULL);
2092 gtk_default_draw_box (GtkStyle *style,
2094 GtkStateType state_type,
2095 GtkShadowType shadow_type,
2104 g_return_if_fail (style != NULL);
2105 g_return_if_fail (window != NULL);
2107 if ((width == -1) && (height == -1))
2108 gdk_window_get_size (window, &width, &height);
2109 else if (width == -1)
2110 gdk_window_get_size (window, &width, NULL);
2111 else if (height == -1)
2112 gdk_window_get_size (window, NULL, &height);
2114 if ((!style->bg_pixmap[state_type]) ||
2115 (gdk_window_get_type(window) == GDK_WINDOW_PIXMAP))
2119 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
2121 gdk_draw_rectangle(window, style->bg_gc[state_type], TRUE,
2122 x, y, width, height);
2125 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2129 gtk_style_apply_default_pixmap(style, window, state_type, area, x, y, width, height);
2130 gtk_paint_shadow (style, window, state_type, shadow_type, area, widget, detail,
2131 x, y, width, height);
2135 gtk_default_draw_flat_box (GtkStyle *style,
2137 GtkStateType state_type,
2138 GtkShadowType shadow_type,
2149 g_return_if_fail (style != NULL);
2150 g_return_if_fail (window != NULL);
2152 if ((width == -1) && (height == -1))
2153 gdk_window_get_size (window, &width, &height);
2154 else if (width == -1)
2155 gdk_window_get_size (window, &width, NULL);
2156 else if (height == -1)
2157 gdk_window_get_size (window, NULL, &height);
2159 if ((detail) && (!strcmp("text",detail)) && (state_type == GTK_STATE_SELECTED))
2160 gc1 = style->bg_gc[GTK_STATE_SELECTED];
2161 else if ((detail) && (!strcmp("viewportbin",detail)))
2162 gc1 = style->bg_gc[GTK_STATE_NORMAL];
2163 else if ((detail) && (!strcmp("entry_bg",detail)))
2164 gc1 = style->base_gc[state_type];
2166 gc1 = style->bg_gc[state_type];
2168 if ((!style->bg_pixmap[state_type]) || (gc1 != style->bg_gc[state_type]) ||
2169 (gdk_window_get_type(window) == GDK_WINDOW_PIXMAP))
2173 gdk_gc_set_clip_rectangle (gc1, area);
2175 gdk_draw_rectangle (window, gc1, TRUE,
2176 x, y, width, height);
2177 if ((detail) && (!strcmp("tooltip",detail)))
2178 gdk_draw_rectangle (window, style->black_gc, FALSE,
2179 x, y, width - 1, height - 1);
2182 gdk_gc_set_clip_rectangle (gc1, NULL);
2186 gtk_style_apply_default_pixmap(style, window, state_type, area, x, y, width, height);
2190 gtk_default_draw_check (GtkStyle *style,
2192 GtkStateType state_type,
2193 GtkShadowType shadow_type,
2202 gtk_paint_box (style, window, state_type, shadow_type, area, widget, detail,
2203 x, y, width, height);
2207 gtk_default_draw_option (GtkStyle *style,
2209 GtkStateType state_type,
2210 GtkShadowType shadow_type,
2219 gtk_paint_diamond (style, window, state_type, shadow_type, area, widget,
2220 detail, x, y, width, height);
2224 gtk_default_draw_cross (GtkStyle *style,
2226 GtkStateType state_type,
2227 GtkShadowType shadow_type,
2236 g_return_if_fail (style != NULL);
2237 g_return_if_fail (window != NULL);
2241 gtk_default_draw_ramp (GtkStyle *style,
2243 GtkStateType state_type,
2244 GtkShadowType shadow_type,
2248 GtkArrowType arrow_type,
2254 g_return_if_fail (style != NULL);
2255 g_return_if_fail (window != NULL);
2258 static void gtk_default_draw_tab (GtkStyle *style,
2260 GtkStateType state_type,
2261 GtkShadowType shadow_type,
2270 g_return_if_fail (style != NULL);
2271 g_return_if_fail (window != NULL);
2273 gtk_paint_box (style, window, state_type, shadow_type, area, widget, detail,
2274 x, y, width, height);
2278 gtk_default_draw_shadow_gap (GtkStyle *style,
2280 GtkStateType state_type,
2281 GtkShadowType shadow_type,
2289 GtkPositionType gap_side,
2298 g_return_if_fail (style != NULL);
2299 g_return_if_fail (window != NULL);
2301 if ((width == -1) && (height == -1))
2302 gdk_window_get_size (window, &width, &height);
2303 else if (width == -1)
2304 gdk_window_get_size (window, &width, NULL);
2305 else if (height == -1)
2306 gdk_window_get_size (window, NULL, &height);
2308 switch (shadow_type)
2310 case GTK_SHADOW_NONE:
2313 gc1 = style->dark_gc[state_type];
2314 gc2 = style->black_gc;
2315 gc3 = style->bg_gc[state_type];
2316 gc4 = style->light_gc[state_type];
2318 case GTK_SHADOW_ETCHED_IN:
2319 gc1 = style->dark_gc[state_type];
2320 gc2 = style->light_gc[state_type];
2321 gc3 = style->dark_gc[state_type];
2322 gc4 = style->light_gc[state_type];
2324 case GTK_SHADOW_OUT:
2325 gc1 = style->light_gc[state_type];
2326 gc2 = style->bg_gc[state_type];
2327 gc3 = style->dark_gc[state_type];
2328 gc4 = style->black_gc;
2330 case GTK_SHADOW_ETCHED_OUT:
2331 gc1 = style->light_gc[state_type];
2332 gc2 = style->dark_gc[state_type];
2333 gc3 = style->light_gc[state_type];
2334 gc4 = style->dark_gc[state_type];
2339 gdk_gc_set_clip_rectangle (gc1, area);
2340 gdk_gc_set_clip_rectangle (gc2, area);
2341 gdk_gc_set_clip_rectangle (gc3, area);
2342 gdk_gc_set_clip_rectangle (gc4, area);
2345 switch (shadow_type)
2347 case GTK_SHADOW_NONE:
2349 case GTK_SHADOW_OUT:
2350 case GTK_SHADOW_ETCHED_IN:
2351 case GTK_SHADOW_ETCHED_OUT:
2355 gdk_draw_line (window, gc1,
2356 x, y, x, y + height - 1);
2357 gdk_draw_line (window, gc2,
2358 x + 1, y, x + 1, y + height - 2);
2360 gdk_draw_line (window, gc3,
2361 x + 1, y + height - 2, x + width - 2, y + height - 2);
2362 gdk_draw_line (window, gc3,
2363 x + width - 2, y, x + width - 2, y + height - 2);
2364 gdk_draw_line (window, gc4,
2365 x, y + height - 1, x + width - 1, y + height - 1);
2366 gdk_draw_line (window, gc4,
2367 x + width - 1, y, x + width - 1, y + height - 1);
2370 gdk_draw_line (window, gc1,
2371 x, y, x + gap_x - 1, y);
2372 gdk_draw_line (window, gc2,
2373 x + 1, y + 1, x + gap_x - 1, y + 1);
2374 gdk_draw_line (window, gc2,
2375 x + gap_x, y, x + gap_x, y);
2377 if ((width - (gap_x + gap_width)) > 0)
2379 gdk_draw_line (window, gc1,
2380 x + gap_x + gap_width, y, x + width - 2, y);
2381 gdk_draw_line (window, gc2,
2382 x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
2383 gdk_draw_line (window, gc2,
2384 x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
2387 case GTK_POS_BOTTOM:
2388 gdk_draw_line (window, gc1,
2389 x, y, x + width - 1, y);
2390 gdk_draw_line (window, gc1,
2391 x, y, x, y + height - 1);
2392 gdk_draw_line (window, gc2,
2393 x + 1, y + 1, x + width - 2, y + 1);
2394 gdk_draw_line (window, gc2,
2395 x + 1, y + 1, x + 1, y + height - 1);
2397 gdk_draw_line (window, gc3,
2398 x + width - 2, y + 1, x + width - 2, y + height - 1);
2399 gdk_draw_line (window, gc4,
2400 x + width - 1, y, x + width - 1, y + height - 1);
2403 gdk_draw_line (window, gc4,
2404 x, y + height - 1, x + gap_x - 1, y + height - 1);
2405 gdk_draw_line (window, gc3,
2406 x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
2407 gdk_draw_line (window, gc3,
2408 x + gap_x, y + height - 1, x + gap_x, y + height - 1);
2410 if ((width - (gap_x + gap_width)) > 0)
2412 gdk_draw_line (window, gc4,
2413 x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
2414 gdk_draw_line (window, gc3,
2415 x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
2416 gdk_draw_line (window, gc3,
2417 x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
2421 gdk_draw_line (window, gc1,
2422 x, y, x + width - 1, y);
2423 gdk_draw_line (window, gc2,
2424 x, y + 1, x + width - 2, y + 1);
2426 gdk_draw_line (window, gc3,
2427 x, y + height - 2, x + width - 2, y + height - 2);
2428 gdk_draw_line (window, gc3,
2429 x + width - 2, y + 1, x + width - 2, y + height - 2);
2430 gdk_draw_line (window, gc4,
2431 x, y + height - 1, x + width - 1, y + height - 1);
2432 gdk_draw_line (window, gc4,
2433 x + width - 1, y, x + width - 1, y + height - 1);
2436 gdk_draw_line (window, gc1,
2437 x, y, x, y + gap_x - 1);
2438 gdk_draw_line (window, gc2,
2439 x + 1, y + 1, x + 1, y + gap_x - 1);
2440 gdk_draw_line (window, gc2,
2441 x, y + gap_x, x, y + gap_x);
2443 if ((width - (gap_x + gap_width)) > 0)
2445 gdk_draw_line (window, gc1,
2446 x, y + gap_x + gap_width, x, y + height - 2);
2447 gdk_draw_line (window, gc2,
2448 x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
2449 gdk_draw_line (window, gc2,
2450 x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
2454 gdk_draw_line (window, gc1,
2455 x, y, x + width - 1, y);
2456 gdk_draw_line (window, gc1,
2457 x, y, x, y + height - 1);
2458 gdk_draw_line (window, gc2,
2459 x + 1, y + 1, x + width - 1, y + 1);
2460 gdk_draw_line (window, gc2,
2461 x + 1, y + 1, x + 1, y + height - 2);
2463 gdk_draw_line (window, gc3,
2464 x + 1, y + height - 2, x + width - 1, y + height - 2);
2465 gdk_draw_line (window, gc4,
2466 x, y + height - 1, x + width - 1, y + height - 1);
2469 gdk_draw_line (window, gc4,
2470 x + width - 1, y, x + width - 1, y + gap_x - 1);
2471 gdk_draw_line (window, gc3,
2472 x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
2473 gdk_draw_line (window, gc3,
2474 x + width - 1, y + gap_x, x + width - 1, y + gap_x);
2476 if ((width - (gap_x + gap_width)) > 0)
2478 gdk_draw_line (window, gc4,
2479 x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
2480 gdk_draw_line (window, gc3,
2481 x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
2482 gdk_draw_line (window, gc3,
2483 x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
2490 gdk_gc_set_clip_rectangle (gc1, NULL);
2491 gdk_gc_set_clip_rectangle (gc2, NULL);
2492 gdk_gc_set_clip_rectangle (gc3, NULL);
2493 gdk_gc_set_clip_rectangle (gc4, NULL);
2498 gtk_default_draw_box_gap (GtkStyle *style,
2500 GtkStateType state_type,
2501 GtkShadowType shadow_type,
2509 GtkPositionType gap_side,
2518 g_return_if_fail (style != NULL);
2519 g_return_if_fail (window != NULL);
2521 gtk_style_apply_default_pixmap(style, window, state_type, area,
2522 x, y, width, height);
2524 if ((width == -1) && (height == -1))
2525 gdk_window_get_size (window, &width, &height);
2526 else if (width == -1)
2527 gdk_window_get_size (window, &width, NULL);
2528 else if (height == -1)
2529 gdk_window_get_size (window, NULL, &height);
2531 switch (shadow_type)
2533 case GTK_SHADOW_NONE:
2536 gc1 = style->dark_gc[state_type];
2537 gc2 = style->black_gc;
2538 gc3 = style->bg_gc[state_type];
2539 gc4 = style->light_gc[state_type];
2541 case GTK_SHADOW_ETCHED_IN:
2542 gc1 = style->dark_gc[state_type];
2543 gc2 = style->light_gc[state_type];
2544 gc3 = style->dark_gc[state_type];
2545 gc4 = style->light_gc[state_type];
2547 case GTK_SHADOW_OUT:
2548 gc1 = style->light_gc[state_type];
2549 gc2 = style->bg_gc[state_type];
2550 gc3 = style->dark_gc[state_type];
2551 gc4 = style->black_gc;
2553 case GTK_SHADOW_ETCHED_OUT:
2554 gc1 = style->light_gc[state_type];
2555 gc2 = style->dark_gc[state_type];
2556 gc3 = style->light_gc[state_type];
2557 gc4 = style->dark_gc[state_type];
2562 gdk_gc_set_clip_rectangle (gc1, area);
2563 gdk_gc_set_clip_rectangle (gc2, area);
2564 gdk_gc_set_clip_rectangle (gc3, area);
2565 gdk_gc_set_clip_rectangle (gc4, area);
2568 switch (shadow_type)
2570 case GTK_SHADOW_NONE:
2572 case GTK_SHADOW_OUT:
2573 case GTK_SHADOW_ETCHED_IN:
2574 case GTK_SHADOW_ETCHED_OUT:
2578 gdk_draw_line (window, gc1,
2579 x, y, x, y + height - 1);
2580 gdk_draw_line (window, gc2,
2581 x + 1, y, x + 1, y + height - 2);
2583 gdk_draw_line (window, gc3,
2584 x + 1, y + height - 2, x + width - 2, y + height - 2);
2585 gdk_draw_line (window, gc3,
2586 x + width - 2, y, x + width - 2, y + height - 2);
2587 gdk_draw_line (window, gc4,
2588 x, y + height - 1, x + width - 1, y + height - 1);
2589 gdk_draw_line (window, gc4,
2590 x + width - 1, y, x + width - 1, y + height - 1);
2593 gdk_draw_line (window, gc1,
2594 x, y, x + gap_x - 1, y);
2595 gdk_draw_line (window, gc2,
2596 x + 1, y + 1, x + gap_x - 1, y + 1);
2597 gdk_draw_line (window, gc2,
2598 x + gap_x, y, x + gap_x, y);
2600 if ((width - (gap_x + gap_width)) > 0)
2602 gdk_draw_line (window, gc1,
2603 x + gap_x + gap_width, y, x + width - 2, y);
2604 gdk_draw_line (window, gc2,
2605 x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
2606 gdk_draw_line (window, gc2,
2607 x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
2610 case GTK_POS_BOTTOM:
2611 gdk_draw_line (window, gc1,
2612 x, y, x + width - 1, y);
2613 gdk_draw_line (window, gc1,
2614 x, y, x, y + height - 1);
2615 gdk_draw_line (window, gc2,
2616 x + 1, y + 1, x + width - 2, y + 1);
2617 gdk_draw_line (window, gc2,
2618 x + 1, y + 1, x + 1, y + height - 1);
2620 gdk_draw_line (window, gc3,
2621 x + width - 2, y + 1, x + width - 2, y + height - 1);
2622 gdk_draw_line (window, gc4,
2623 x + width - 1, y, x + width - 1, y + height - 1);
2626 gdk_draw_line (window, gc4,
2627 x, y + height - 1, x + gap_x - 1, y + height - 1);
2628 gdk_draw_line (window, gc3,
2629 x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
2630 gdk_draw_line (window, gc3,
2631 x + gap_x, y + height - 1, x + gap_x, y + height - 1);
2633 if ((width - (gap_x + gap_width)) > 0)
2635 gdk_draw_line (window, gc4,
2636 x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
2637 gdk_draw_line (window, gc3,
2638 x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
2639 gdk_draw_line (window, gc3,
2640 x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
2644 gdk_draw_line (window, gc1,
2645 x, y, x + width - 1, y);
2646 gdk_draw_line (window, gc2,
2647 x, y + 1, x + width - 2, y + 1);
2649 gdk_draw_line (window, gc3,
2650 x, y + height - 2, x + width - 2, y + height - 2);
2651 gdk_draw_line (window, gc3,
2652 x + width - 2, y + 1, x + width - 2, y + height - 2);
2653 gdk_draw_line (window, gc4,
2654 x, y + height - 1, x + width - 1, y + height - 1);
2655 gdk_draw_line (window, gc4,
2656 x + width - 1, y, x + width - 1, y + height - 1);
2659 gdk_draw_line (window, gc1,
2660 x, y, x, y + gap_x - 1);
2661 gdk_draw_line (window, gc2,
2662 x + 1, y + 1, x + 1, y + gap_x - 1);
2663 gdk_draw_line (window, gc2,
2664 x, y + gap_x, x, y + gap_x);
2666 if ((width - (gap_x + gap_width)) > 0)
2668 gdk_draw_line (window, gc1,
2669 x, y + gap_x + gap_width, x, y + height - 2);
2670 gdk_draw_line (window, gc2,
2671 x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
2672 gdk_draw_line (window, gc2,
2673 x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
2677 gdk_draw_line (window, gc1,
2678 x, y, x + width - 1, y);
2679 gdk_draw_line (window, gc1,
2680 x, y, x, y + height - 1);
2681 gdk_draw_line (window, gc2,
2682 x + 1, y + 1, x + width - 1, y + 1);
2683 gdk_draw_line (window, gc2,
2684 x + 1, y + 1, x + 1, y + height - 2);
2686 gdk_draw_line (window, gc3,
2687 x + 1, y + height - 2, x + width - 1, y + height - 2);
2688 gdk_draw_line (window, gc4,
2689 x, y + height - 1, x + width - 1, y + height - 1);
2692 gdk_draw_line (window, gc4,
2693 x + width - 1, y, x + width - 1, y + gap_x - 1);
2694 gdk_draw_line (window, gc3,
2695 x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
2696 gdk_draw_line (window, gc3,
2697 x + width - 1, y + gap_x, x + width - 1, y + gap_x);
2699 if ((width - (gap_x + gap_width)) > 0)
2701 gdk_draw_line (window, gc4,
2702 x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
2703 gdk_draw_line (window, gc3,
2704 x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
2705 gdk_draw_line (window, gc3,
2706 x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
2713 gdk_gc_set_clip_rectangle (gc1, NULL);
2714 gdk_gc_set_clip_rectangle (gc2, NULL);
2715 gdk_gc_set_clip_rectangle (gc3, NULL);
2716 gdk_gc_set_clip_rectangle (gc4, NULL);
2721 gtk_default_draw_extension (GtkStyle *style,
2723 GtkStateType state_type,
2724 GtkShadowType shadow_type,
2732 GtkPositionType gap_side)
2739 g_return_if_fail (style != NULL);
2740 g_return_if_fail (window != NULL);
2742 gtk_style_apply_default_pixmap(style, window, GTK_STATE_NORMAL, area,
2743 x, y, width, height);
2745 if ((width == -1) && (height == -1))
2746 gdk_window_get_size (window, &width, &height);
2747 else if (width == -1)
2748 gdk_window_get_size (window, &width, NULL);
2749 else if (height == -1)
2750 gdk_window_get_size (window, NULL, &height);
2752 switch (shadow_type)
2754 case GTK_SHADOW_NONE:
2757 gc1 = style->dark_gc[state_type];
2758 gc2 = style->black_gc;
2759 gc3 = style->bg_gc[state_type];
2760 gc4 = style->light_gc[state_type];
2762 case GTK_SHADOW_ETCHED_IN:
2763 gc1 = style->dark_gc[state_type];
2764 gc2 = style->light_gc[state_type];
2765 gc3 = style->dark_gc[state_type];
2766 gc4 = style->light_gc[state_type];
2768 case GTK_SHADOW_OUT:
2769 gc1 = style->light_gc[state_type];
2770 gc2 = style->bg_gc[state_type];
2771 gc3 = style->dark_gc[state_type];
2772 gc4 = style->black_gc;
2774 case GTK_SHADOW_ETCHED_OUT:
2775 gc1 = style->light_gc[state_type];
2776 gc2 = style->dark_gc[state_type];
2777 gc3 = style->light_gc[state_type];
2778 gc4 = style->dark_gc[state_type];
2783 gdk_gc_set_clip_rectangle (gc1, area);
2784 gdk_gc_set_clip_rectangle (gc2, area);
2785 gdk_gc_set_clip_rectangle (gc3, area);
2786 gdk_gc_set_clip_rectangle (gc4, area);
2788 switch (shadow_type)
2790 case GTK_SHADOW_NONE:
2792 case GTK_SHADOW_OUT:
2793 case GTK_SHADOW_ETCHED_IN:
2794 case GTK_SHADOW_ETCHED_OUT:
2798 gtk_style_apply_default_pixmap(style, window, state_type, area,
2799 x + style->klass->xthickness,
2801 width - (2 * style->klass->xthickness),
2802 height - (style->klass->ythickness));
2803 gdk_draw_line (window, gc1,
2804 x, y, x, y + height - 2);
2805 gdk_draw_line (window, gc2,
2806 x + 1, y, x + 1, y + height - 2);
2808 gdk_draw_line (window, gc3,
2809 x + 2, y + height - 2, x + width - 2, y + height - 2);
2810 gdk_draw_line (window, gc3,
2811 x + width - 2, y, x + width - 2, y + height - 2);
2812 gdk_draw_line (window, gc4,
2813 x + 1, y + height - 1, x + width - 2, y + height - 1);
2814 gdk_draw_line (window, gc4,
2815 x + width - 1, y, x + width - 1, y + height - 2);
2817 case GTK_POS_BOTTOM:
2818 gtk_style_apply_default_pixmap(style, window, state_type, area,
2819 x + style->klass->xthickness,
2820 y + style->klass->ythickness,
2821 width - (2 * style->klass->xthickness),
2822 height - (style->klass->ythickness));
2823 gdk_draw_line (window, gc1,
2824 x + 1, y, x + width - 2, y);
2825 gdk_draw_line (window, gc1,
2826 x, y + 1, x, y + height - 1);
2827 gdk_draw_line (window, gc2,
2828 x + 1, y + 1, x + width - 2, y + 1);
2829 gdk_draw_line (window, gc2,
2830 x + 1, y + 1, x + 1, y + height - 1);
2832 gdk_draw_line (window, gc3,
2833 x + width - 2, y + 2, x + width - 2, y + height - 1);
2834 gdk_draw_line (window, gc4,
2835 x + width - 1, y + 1, x + width - 1, y + height - 1);
2838 gtk_style_apply_default_pixmap(style, window, state_type, area,
2840 y + style->klass->ythickness,
2841 width - (style->klass->xthickness),
2842 height - (2 * style->klass->ythickness));
2843 gdk_draw_line (window, gc1,
2844 x, y, x + width - 2, y);
2845 gdk_draw_line (window, gc2,
2846 x + 1, y + 1, x + width - 2, y + 1);
2848 gdk_draw_line (window, gc3,
2849 x, y + height - 2, x + width - 2, y + height - 2);
2850 gdk_draw_line (window, gc3,
2851 x + width - 2, y + 2, x + width - 2, y + height - 2);
2852 gdk_draw_line (window, gc4,
2853 x, y + height - 1, x + width - 2, y + height - 1);
2854 gdk_draw_line (window, gc4,
2855 x + width - 1, y + 1, x + width - 1, y + height - 2);
2858 gtk_style_apply_default_pixmap(style, window, state_type, area,
2859 x + style->klass->xthickness,
2860 y + style->klass->ythickness,
2861 width - (style->klass->xthickness),
2862 height - (2 * style->klass->ythickness));
2863 gdk_draw_line (window, gc1,
2864 x + 1, y, x + width - 1, y);
2865 gdk_draw_line (window, gc1,
2866 x, y + 1, x, y + height - 2);
2867 gdk_draw_line (window, gc2,
2868 x + 1, y + 1, x + width - 1, y + 1);
2869 gdk_draw_line (window, gc2,
2870 x + 1, y + 1, x + 1, y + height - 2);
2872 gdk_draw_line (window, gc3,
2873 x + 2, y + height - 2, x + width - 1, y + height - 2);
2874 gdk_draw_line (window, gc4,
2875 x + 1, y + height - 1, x + width - 1, y + height - 1);
2881 gdk_gc_set_clip_rectangle (gc1, NULL);
2882 gdk_gc_set_clip_rectangle (gc2, NULL);
2883 gdk_gc_set_clip_rectangle (gc3, NULL);
2884 gdk_gc_set_clip_rectangle (gc4, NULL);
2889 gtk_default_draw_focus (GtkStyle *style,
2899 g_return_if_fail (style != NULL);
2900 g_return_if_fail (window != NULL);
2902 if ((width == -1) && (height == -1))
2904 gdk_window_get_size (window, &width, &height);
2908 else if (width == -1)
2910 gdk_window_get_size (window, &width, NULL);
2913 else if (height == -1)
2915 gdk_window_get_size (window, NULL, &height);
2920 gdk_gc_set_clip_rectangle (style->black_gc, area);
2922 if (detail && !strcmp (detail, "add-mode"))
2924 gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_ON_OFF_DASH, 0, 0);
2925 gdk_gc_set_dashes (style->black_gc, 0, "\4\4", 2);
2927 gdk_draw_rectangle (window,
2928 style->black_gc, FALSE,
2929 x, y, width, height);
2931 gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_SOLID, 0, 0);
2935 gdk_draw_rectangle (window,
2936 style->black_gc, FALSE,
2937 x, y, width, height);
2941 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2946 gtk_default_draw_slider (GtkStyle *style,
2948 GtkStateType state_type,
2949 GtkShadowType shadow_type,
2957 GtkOrientation orientation)
2959 g_return_if_fail (style != NULL);
2960 g_return_if_fail (window != NULL);
2962 if ((width == -1) && (height == -1))
2963 gdk_window_get_size (window, &width, &height);
2964 else if (width == -1)
2965 gdk_window_get_size (window, &width, NULL);
2966 else if (height == -1)
2967 gdk_window_get_size (window, NULL, &height);
2969 gtk_paint_box (style, window, state_type, shadow_type,
2970 area, widget, detail, x, y, width, height);
2971 if (orientation == GTK_ORIENTATION_HORIZONTAL)
2972 gtk_paint_vline (style, window, state_type, area, widget, detail,
2973 style->klass->ythickness,
2974 height - style->klass->ythickness - 1, width / 2);
2976 gtk_paint_hline (style, window, state_type, area, widget, detail,
2977 style->klass->xthickness,
2978 width - style->klass->xthickness - 1, height / 2);
2982 gtk_default_draw_handle (GtkStyle *style,
2984 GtkStateType state_type,
2985 GtkShadowType shadow_type,
2993 GtkOrientation orientation)
2996 gint xthick, ythick;
2997 GdkGC *light_gc, *dark_gc;
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, area, widget,
3011 detail, x, y, width, height);
3013 light_gc = style->light_gc[state_type];
3014 dark_gc = style->dark_gc[state_type];
3016 xthick = style->klass->xthickness;
3017 ythick = style->klass->ythickness;
3019 dest.x = x + xthick;
3020 dest.y = y + ythick;
3021 dest.width = width - (xthick * 2);
3022 dest.height = height - (ythick * 2);
3024 gdk_gc_set_clip_rectangle (light_gc, &dest);
3025 gdk_gc_set_clip_rectangle (dark_gc, &dest);
3027 for (yy = y + ythick; yy < (y + height - ythick); yy += 3)
3028 for (xx = x + xthick; xx < (x + width - xthick); xx += 6)
3030 gdk_draw_point (window, light_gc, xx, yy);
3031 gdk_draw_point (window, dark_gc, xx + 1, yy + 1);
3033 gdk_draw_point (window, light_gc, xx + 3, yy + 1);
3034 gdk_draw_point (window, dark_gc, xx + 4, yy + 2);
3036 gdk_gc_set_clip_rectangle (light_gc, NULL);
3037 gdk_gc_set_clip_rectangle (dark_gc, NULL);
3041 gtk_style_shade (GdkColor *a,
3049 red = (gdouble) a->red / 65535.0;
3050 green = (gdouble) a->green / 65535.0;
3051 blue = (gdouble) a->blue / 65535.0;
3053 rgb_to_hls (&red, &green, &blue);
3058 else if (green < 0.0)
3064 else if (blue < 0.0)
3067 hls_to_rgb (&red, &green, &blue);
3069 b->red = red * 65535.0;
3070 b->green = green * 65535.0;
3071 b->blue = blue * 65535.0;
3075 rgb_to_hls (gdouble *r,
3116 l = (max + min) / 2;
3123 s = (max - min) / (max + min);
3125 s = (max - min) / (2 - max - min);
3129 h = (green - blue) / delta;
3130 else if (green == max)
3131 h = 2 + (blue - red) / delta;
3132 else if (blue == max)
3133 h = 4 + (red - green) / delta;
3146 hls_to_rgb (gdouble *h,
3159 if (lightness <= 0.5)
3160 m2 = lightness * (1 + saturation);
3162 m2 = lightness + saturation - lightness * saturation;
3163 m1 = 2 * lightness - m2;
3165 if (saturation == 0)
3180 r = m1 + (m2 - m1) * hue / 60;
3184 r = m1 + (m2 - m1) * (240 - hue) / 60;
3195 g = m1 + (m2 - m1) * hue / 60;
3199 g = m1 + (m2 - m1) * (240 - hue) / 60;
3210 b = m1 + (m2 - m1) * hue / 60;
3214 b = m1 + (m2 - m1) * (240 - hue) / 60;
3225 gtk_paint_hline (GtkStyle *style,
3227 GtkStateType state_type,
3235 g_return_if_fail (style != NULL);
3236 g_return_if_fail (style->klass != NULL);
3237 g_return_if_fail (style->klass->draw_hline != NULL);
3239 (*style->klass->draw_hline) (style, window, state_type, area, widget, detail, x1, x2, y);
3243 gtk_paint_vline (GtkStyle *style,
3245 GtkStateType state_type,
3253 g_return_if_fail (style != NULL);
3254 g_return_if_fail (style->klass != NULL);
3255 g_return_if_fail (style->klass->draw_vline != NULL);
3257 (*style->klass->draw_vline) (style, window, state_type, area, widget, detail, y1, y2, x);
3261 gtk_paint_shadow (GtkStyle *style,
3263 GtkStateType state_type,
3264 GtkShadowType shadow_type,
3273 g_return_if_fail (style != NULL);
3274 g_return_if_fail (style->klass != NULL);
3275 g_return_if_fail (style->klass->draw_shadow != NULL);
3277 (*style->klass->draw_shadow) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3281 gtk_paint_polygon (GtkStyle *style,
3283 GtkStateType state_type,
3284 GtkShadowType shadow_type,
3292 g_return_if_fail (style != NULL);
3293 g_return_if_fail (style->klass != NULL);
3294 g_return_if_fail (style->klass->draw_shadow != NULL);
3296 (*style->klass->draw_polygon) (style, window, state_type, shadow_type, area, widget, detail, points, npoints, fill);
3300 gtk_paint_arrow (GtkStyle *style,
3302 GtkStateType state_type,
3303 GtkShadowType shadow_type,
3307 GtkArrowType arrow_type,
3314 g_return_if_fail (style != NULL);
3315 g_return_if_fail (style->klass != NULL);
3316 g_return_if_fail (style->klass->draw_arrow != NULL);
3318 (*style->klass->draw_arrow) (style, window, state_type, shadow_type, area, widget, detail, arrow_type, fill, x, y, width, height);
3322 gtk_paint_diamond (GtkStyle *style,
3324 GtkStateType state_type,
3325 GtkShadowType shadow_type,
3334 g_return_if_fail (style != NULL);
3335 g_return_if_fail (style->klass != NULL);
3336 g_return_if_fail (style->klass->draw_diamond != NULL);
3338 (*style->klass->draw_diamond) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3342 gtk_paint_oval (GtkStyle *style,
3344 GtkStateType state_type,
3345 GtkShadowType shadow_type,
3354 g_return_if_fail (style != NULL);
3355 g_return_if_fail (style->klass != NULL);
3356 g_return_if_fail (style->klass->draw_oval != NULL);
3358 (*style->klass->draw_oval) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3362 gtk_paint_string (GtkStyle *style,
3364 GtkStateType state_type,
3370 const gchar *string)
3372 g_return_if_fail (style != NULL);
3373 g_return_if_fail (style->klass != NULL);
3374 g_return_if_fail (style->klass->draw_oval != NULL);
3376 (*style->klass->draw_string) (style, window, state_type, area, widget, detail, x, y, string);
3380 gtk_paint_box (GtkStyle *style,
3382 GtkStateType state_type,
3383 GtkShadowType shadow_type,
3392 g_return_if_fail (style != NULL);
3393 g_return_if_fail (style->klass != NULL);
3394 g_return_if_fail (style->klass->draw_box != NULL);
3396 (*style->klass->draw_box) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3400 gtk_paint_flat_box (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_flat_box != NULL);
3416 (*style->klass->draw_flat_box) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3420 gtk_paint_check (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_check != NULL);
3436 (*style->klass->draw_check) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3440 gtk_paint_option (GtkStyle *style,
3442 GtkStateType state_type,
3443 GtkShadowType shadow_type,
3452 g_return_if_fail (style != NULL);
3453 g_return_if_fail (style->klass != NULL);
3454 g_return_if_fail (style->klass->draw_option != NULL);
3456 (*style->klass->draw_option) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3460 gtk_paint_cross (GtkStyle *style,
3462 GtkStateType state_type,
3463 GtkShadowType shadow_type,
3472 g_return_if_fail (style != NULL);
3473 g_return_if_fail (style->klass != NULL);
3474 g_return_if_fail (style->klass->draw_cross != NULL);
3476 (*style->klass->draw_cross) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3480 gtk_paint_ramp (GtkStyle *style,
3482 GtkStateType state_type,
3483 GtkShadowType shadow_type,
3487 GtkArrowType arrow_type,
3493 g_return_if_fail (style != NULL);
3494 g_return_if_fail (style->klass != NULL);
3495 g_return_if_fail (style->klass->draw_ramp != NULL);
3497 (*style->klass->draw_ramp) (style, window, state_type, shadow_type, area, widget, detail, arrow_type, x, y, width, height);
3501 gtk_paint_tab (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_tab != NULL);
3517 (*style->klass->draw_tab) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3521 gtk_paint_shadow_gap (GtkStyle *style,
3523 GtkStateType state_type,
3524 GtkShadowType shadow_type,
3532 GtkPositionType gap_side,
3536 g_return_if_fail (style != NULL);
3537 g_return_if_fail (style->klass != NULL);
3538 g_return_if_fail (style->klass->draw_shadow_gap != NULL);
3540 (*style->klass->draw_shadow_gap) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
3545 gtk_paint_box_gap (GtkStyle *style,
3547 GtkStateType state_type,
3548 GtkShadowType shadow_type,
3556 GtkPositionType gap_side,
3560 g_return_if_fail (style != NULL);
3561 g_return_if_fail (style->klass != NULL);
3562 g_return_if_fail (style->klass->draw_box_gap != NULL);
3564 (*style->klass->draw_box_gap) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
3568 gtk_paint_extension (GtkStyle *style,
3570 GtkStateType state_type,
3571 GtkShadowType shadow_type,
3579 GtkPositionType gap_side)
3581 g_return_if_fail (style != NULL);
3582 g_return_if_fail (style->klass != NULL);
3583 g_return_if_fail (style->klass->draw_extension != NULL);
3585 (*style->klass->draw_extension) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side);
3589 gtk_paint_focus (GtkStyle *style,
3599 g_return_if_fail (style != NULL);
3600 g_return_if_fail (style->klass != NULL);
3601 g_return_if_fail (style->klass->draw_focus != NULL);
3603 (*style->klass->draw_focus) (style, window, area, widget, detail, x, y, width, height);
3607 gtk_paint_slider (GtkStyle *style,
3609 GtkStateType state_type,
3610 GtkShadowType shadow_type,
3618 GtkOrientation orientation)
3620 g_return_if_fail (style != NULL);
3621 g_return_if_fail (style->klass != NULL);
3622 g_return_if_fail (style->klass->draw_slider != NULL);
3624 (*style->klass->draw_slider) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
3628 gtk_paint_handle (GtkStyle *style,
3630 GtkStateType state_type,
3631 GtkShadowType shadow_type,
3639 GtkOrientation orientation)
3641 g_return_if_fail (style != NULL);
3642 g_return_if_fail (style->klass != NULL);
3643 g_return_if_fail (style->klass->draw_handle != NULL);
3645 (*style->klass->draw_handle) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);