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 "gdk/gdkprivate.h"
29 #define LIGHTNESS_MULT 1.3
30 #define DARKNESS_MULT 0.7
32 static void gtk_style_init (GtkStyle *style,
33 GdkColormap *colormap,
35 static void gtk_style_destroy (GtkStyle *style);
37 static void gtk_default_draw_hline (GtkStyle *style,
39 GtkStateType state_type,
46 static void gtk_default_draw_vline (GtkStyle *style,
48 GtkStateType state_type,
55 static void gtk_default_draw_shadow (GtkStyle *style,
57 GtkStateType state_type,
58 GtkShadowType shadow_type,
66 static void gtk_default_draw_shadow (GtkStyle *style,
68 GtkStateType state_type,
69 GtkShadowType shadow_type,
77 static void gtk_default_draw_polygon (GtkStyle *style,
79 GtkStateType state_type,
80 GtkShadowType shadow_type,
87 static void gtk_default_draw_arrow (GtkStyle *style,
89 GtkStateType state_type,
90 GtkShadowType shadow_type,
94 GtkArrowType arrow_type,
100 static void gtk_default_draw_diamond (GtkStyle *style,
102 GtkStateType state_type,
103 GtkShadowType shadow_type,
111 static void gtk_default_draw_oval (GtkStyle *style,
113 GtkStateType state_type,
114 GtkShadowType shadow_type,
122 static void gtk_default_draw_string (GtkStyle *style,
124 GtkStateType state_type,
130 const gchar *string);
131 static void gtk_default_draw_box (GtkStyle *style,
133 GtkStateType state_type,
134 GtkShadowType shadow_type,
142 static void gtk_default_draw_flat_box (GtkStyle *style,
144 GtkStateType state_type,
145 GtkShadowType shadow_type,
153 static void gtk_default_draw_check (GtkStyle *style,
155 GtkStateType state_type,
156 GtkShadowType shadow_type,
164 static void gtk_default_draw_option (GtkStyle *style,
166 GtkStateType state_type,
167 GtkShadowType shadow_type,
175 static void gtk_default_draw_cross (GtkStyle *style,
177 GtkStateType state_type,
178 GtkShadowType shadow_type,
186 static void gtk_default_draw_ramp (GtkStyle *style,
188 GtkStateType state_type,
189 GtkShadowType shadow_type,
193 GtkArrowType arrow_type,
198 static void gtk_default_draw_tab (GtkStyle *style,
200 GtkStateType state_type,
201 GtkShadowType shadow_type,
209 static void gtk_default_draw_shadow_gap (GtkStyle *style,
211 GtkStateType state_type,
212 GtkShadowType shadow_type,
220 GtkPositionType gap_side,
223 static void gtk_default_draw_box_gap (GtkStyle *style,
225 GtkStateType state_type,
226 GtkShadowType shadow_type,
234 GtkPositionType gap_side,
237 static void gtk_default_draw_extension (GtkStyle *style,
239 GtkStateType state_type,
240 GtkShadowType shadow_type,
248 GtkPositionType gap_side);
249 static void gtk_default_draw_focus (GtkStyle *style,
258 static void gtk_default_draw_slider (GtkStyle *style,
260 GtkStateType state_type,
261 GtkShadowType shadow_type,
269 GtkOrientation orientation);
270 static void gtk_default_draw_handle (GtkStyle *style,
272 GtkStateType state_type,
273 GtkShadowType shadow_type,
281 GtkOrientation orientation);
284 static void gtk_style_shade (GdkColor *a, GdkColor *b, gdouble k);
285 static void rgb_to_hls (gdouble *r, gdouble *g, gdouble *b);
286 static void hls_to_rgb (gdouble *h, gdouble *l, gdouble *s);
289 static const GtkStyleClass default_class =
293 gtk_default_draw_hline,
294 gtk_default_draw_vline,
295 gtk_default_draw_shadow,
296 gtk_default_draw_polygon,
297 gtk_default_draw_arrow,
298 gtk_default_draw_diamond,
299 gtk_default_draw_oval,
300 gtk_default_draw_string,
301 gtk_default_draw_box,
302 gtk_default_draw_flat_box,
303 gtk_default_draw_check,
304 gtk_default_draw_option,
305 gtk_default_draw_cross,
306 gtk_default_draw_ramp,
307 gtk_default_draw_tab,
308 gtk_default_draw_shadow_gap,
309 gtk_default_draw_box_gap,
310 gtk_default_draw_extension,
311 gtk_default_draw_focus,
312 gtk_default_draw_slider,
313 gtk_default_draw_handle
315 GdkFont *default_font = NULL;
317 static GdkColor gtk_default_normal_fg = { 0, 0, 0, 0 };
318 static GdkColor gtk_default_active_fg = { 0, 0, 0, 0 };
319 static GdkColor gtk_default_prelight_fg = { 0, 0, 0, 0 };
320 static GdkColor gtk_default_selected_fg = { 0, 0xffff, 0xffff, 0xffff };
321 static GdkColor gtk_default_insensitive_fg = { 0, 0x7530, 0x7530, 0x7530 };
323 static GdkColor gtk_default_normal_bg = { 0, 0xd6d6, 0xd6d6, 0xd6d6 };
324 static GdkColor gtk_default_active_bg = { 0, 0xc350, 0xc350, 0xc350 };
325 static GdkColor gtk_default_prelight_bg = { 0, 0xea60, 0xea60, 0xea60 };
326 static GdkColor gtk_default_selected_bg = { 0, 0, 0, 0x9c40 };
327 static GdkColor gtk_default_insensitive_bg = { 0, 0xd6d6, 0xd6d6, 0xd6d6 };
330 gtk_style_copy (GtkStyle *style)
335 g_return_val_if_fail (style != NULL, NULL);
337 new_style = gtk_style_new ();
339 for (i = 0; i < 5; i++)
341 new_style->fg[i] = style->fg[i];
342 new_style->bg[i] = style->bg[i];
343 new_style->text[i] = style->text[i];
344 new_style->base[i] = style->base[i];
346 new_style->bg_pixmap[i] = style->bg_pixmap[i];
349 new_style->font = style->font;
350 gdk_font_ref (new_style->font);
356 gtk_style_duplicate (GtkStyle *style)
360 g_return_val_if_fail (style != NULL, NULL);
362 new_style = gtk_style_copy (style);
364 style->styles = g_slist_append (style->styles, new_style);
365 new_style->styles = style->styles;
369 new_style->rc_style = style->rc_style;
370 gtk_rc_style_ref (style->rc_style);
375 new_style->engine = style->engine;
376 new_style->engine->duplicate_style (new_style, style);
388 style = g_new0 (GtkStyle, 1);
392 gdk_font_load ("-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*");
394 style->font = default_font;
395 gdk_font_ref (style->font);
397 style->ref_count = 1;
398 style->attach_count = 0;
399 style->colormap = NULL;
401 style->klass = &default_class;
403 style->black.red = 0;
404 style->black.green = 0;
405 style->black.blue = 0;
407 style->white.red = 65535;
408 style->white.green = 65535;
409 style->white.blue = 65535;
411 style->black_gc = NULL;
412 style->white_gc = NULL;
414 style->fg[GTK_STATE_NORMAL] = gtk_default_normal_fg;
415 style->fg[GTK_STATE_ACTIVE] = gtk_default_active_fg;
416 style->fg[GTK_STATE_PRELIGHT] = gtk_default_prelight_fg;
417 style->fg[GTK_STATE_SELECTED] = gtk_default_selected_fg;
418 style->fg[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_fg;
420 style->bg[GTK_STATE_NORMAL] = gtk_default_normal_bg;
421 style->bg[GTK_STATE_ACTIVE] = gtk_default_active_bg;
422 style->bg[GTK_STATE_PRELIGHT] = gtk_default_prelight_bg;
423 style->bg[GTK_STATE_SELECTED] = gtk_default_selected_bg;
424 style->bg[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_bg;
426 for (i = 0; i < 4; i++)
428 style->text[i] = style->fg[i];
429 style->base[i] = style->white;
432 style->base[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_bg;
433 style->text[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_bg;
435 for (i = 0; i < 5; i++)
436 style->bg_pixmap[i] = NULL;
438 style->engine = NULL;
439 style->engine_data = NULL;
441 style->rc_style = NULL;
443 for (i = 0; i < 5; i++)
445 style->fg_gc[i] = NULL;
446 style->bg_gc[i] = NULL;
447 style->light_gc[i] = NULL;
448 style->dark_gc[i] = NULL;
449 style->mid_gc[i] = NULL;
450 style->text_gc[i] = NULL;
451 style->base_gc[i] = NULL;
458 gtk_style_attach (GtkStyle *style,
462 GtkStyle *new_style = NULL;
463 GdkColormap *colormap;
466 g_return_val_if_fail (style != NULL, NULL);
467 g_return_val_if_fail (window != NULL, NULL);
469 colormap = gdk_window_get_colormap (window);
470 depth = gdk_window_get_visual (window)->depth;
473 style->styles = g_slist_append (NULL, style);
475 styles = style->styles;
478 new_style = styles->data;
480 if (new_style->attach_count == 0)
482 gtk_style_init (new_style, colormap, depth);
485 else if ((new_style->colormap == colormap) &&
486 (new_style->depth == depth))
490 styles = styles->next;
495 new_style = gtk_style_duplicate (style);
496 gtk_style_init (new_style, colormap, depth);
499 if (new_style->attach_count == 0)
500 gtk_style_ref (new_style);
504 new_style->attach_count++;
510 gtk_style_detach (GtkStyle *style)
514 g_return_if_fail (style != NULL);
516 style->attach_count -= 1;
517 if (style->attach_count == 0)
520 style->engine->unrealize_style (style);
522 gtk_gc_release (style->black_gc);
523 gtk_gc_release (style->white_gc);
525 for (i = 0; i < 5; i++)
527 gtk_gc_release (style->fg_gc[i]);
528 gtk_gc_release (style->bg_gc[i]);
529 gtk_gc_release (style->light_gc[i]);
530 gtk_gc_release (style->dark_gc[i]);
531 gtk_gc_release (style->mid_gc[i]);
532 gtk_gc_release (style->text_gc[i]);
533 gtk_gc_release (style->base_gc[i]);
536 gtk_style_unref (style);
541 gtk_style_ref (GtkStyle *style)
543 g_return_val_if_fail (style != NULL, NULL);
545 style->ref_count += 1;
550 gtk_style_unref (GtkStyle *style)
552 g_return_if_fail (style != NULL);
554 style->ref_count -= 1;
555 if (style->ref_count == 0)
556 gtk_style_destroy (style);
560 gtk_style_init (GtkStyle *style,
561 GdkColormap *colormap,
564 GdkGCValues gc_values;
565 GdkGCValuesMask gc_values_mask;
568 g_return_if_fail (style != NULL);
570 style->colormap = colormap;
571 style->depth = depth;
573 for (i = 0; i < 5; i++)
575 gtk_style_shade (&style->bg[i], &style->light[i], LIGHTNESS_MULT);
576 gtk_style_shade (&style->bg[i], &style->dark[i], DARKNESS_MULT);
578 style->mid[i].red = (style->light[i].red + style->dark[i].red) / 2;
579 style->mid[i].green = (style->light[i].green + style->dark[i].green) / 2;
580 style->mid[i].blue = (style->light[i].blue + style->dark[i].blue) / 2;
583 gdk_color_black (colormap, &style->black);
584 gdk_color_white (colormap, &style->white);
586 gc_values_mask = GDK_GC_FOREGROUND | GDK_GC_FONT;
587 if (style->font->type == GDK_FONT_FONT)
589 gc_values.font = style->font;
591 else if (style->font->type == GDK_FONT_FONTSET)
593 gc_values.font = default_font;
596 gc_values.foreground = style->black;
597 style->black_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
599 gc_values.foreground = style->white;
600 style->white_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
602 for (i = 0; i < 5; i++)
604 if (style->rc_style && style->rc_style->bg_pixmap_name[i])
605 style->bg_pixmap[i] = gtk_rc_load_image (style->colormap,
607 style->rc_style->bg_pixmap_name[i]);
609 if (!gdk_color_alloc (colormap, &style->fg[i]))
610 g_warning ("unable to allocate color: ( %d %d %d )",
611 style->fg[i].red, style->fg[i].green, style->fg[i].blue);
612 if (!gdk_color_alloc (colormap, &style->bg[i]))
613 g_warning ("unable to allocate color: ( %d %d %d )",
614 style->bg[i].red, style->bg[i].green, style->bg[i].blue);
615 if (!gdk_color_alloc (colormap, &style->light[i]))
616 g_warning ("unable to allocate color: ( %d %d %d )",
617 style->light[i].red, style->light[i].green, style->light[i].blue);
618 if (!gdk_color_alloc (colormap, &style->dark[i]))
619 g_warning ("unable to allocate color: ( %d %d %d )",
620 style->dark[i].red, style->dark[i].green, style->dark[i].blue);
621 if (!gdk_color_alloc (colormap, &style->mid[i]))
622 g_warning ("unable to allocate color: ( %d %d %d )",
623 style->mid[i].red, style->mid[i].green, style->mid[i].blue);
624 if (!gdk_color_alloc (colormap, &style->text[i]))
625 g_warning ("unable to allocate color: ( %d %d %d )",
626 style->text[i].red, style->text[i].green, style->text[i].blue);
627 if (!gdk_color_alloc (colormap, &style->base[i]))
628 g_warning ("unable to allocate color: ( %d %d %d )",
629 style->base[i].red, style->base[i].green, style->base[i].blue);
631 gc_values.foreground = style->fg[i];
632 style->fg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
634 gc_values.foreground = style->bg[i];
635 style->bg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
637 gc_values.foreground = style->light[i];
638 style->light_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
640 gc_values.foreground = style->dark[i];
641 style->dark_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
643 gc_values.foreground = style->mid[i];
644 style->mid_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
646 gc_values.foreground = style->text[i];
647 style->text_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
649 gc_values.foreground = style->base[i];
650 style->base_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
653 style->engine->realize_style (style);
657 gtk_style_destroy (GtkStyle *style)
659 g_return_if_fail (style->attach_count == 0);
663 if (style->styles->data != style)
664 g_slist_remove (style->styles, style);
667 GSList *tmp_list = style->styles->next;
670 ((GtkStyle *)tmp_list->data)->styles = style->styles->next;
671 tmp_list = tmp_list->next;
673 g_slist_free_1 (style->styles);
679 style->engine->destroy_style (style);
680 gtk_theme_engine_unref (style->engine);
683 gdk_font_unref (style->font);
685 gtk_rc_style_unref (style->rc_style);
691 gtk_draw_hline (GtkStyle *style,
693 GtkStateType state_type,
698 g_return_if_fail (style != NULL);
699 g_return_if_fail (style->klass != NULL);
700 g_return_if_fail (style->klass->draw_hline != NULL);
702 (*style->klass->draw_hline) (style, window, state_type, NULL, NULL, NULL, x1, x2, y);
707 gtk_draw_vline (GtkStyle *style,
709 GtkStateType state_type,
714 g_return_if_fail (style != NULL);
715 g_return_if_fail (style->klass != NULL);
716 g_return_if_fail (style->klass->draw_vline != NULL);
718 (*style->klass->draw_vline) (style, window, state_type, NULL, NULL, NULL, y1, y2, x);
723 gtk_draw_shadow (GtkStyle *style,
725 GtkStateType state_type,
726 GtkShadowType shadow_type,
732 g_return_if_fail (style != NULL);
733 g_return_if_fail (style->klass != NULL);
734 g_return_if_fail (style->klass->draw_shadow != NULL);
736 (*style->klass->draw_shadow) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
740 gtk_draw_polygon (GtkStyle *style,
742 GtkStateType state_type,
743 GtkShadowType shadow_type,
748 g_return_if_fail (style != NULL);
749 g_return_if_fail (style->klass != NULL);
750 g_return_if_fail (style->klass->draw_shadow != NULL);
752 (*style->klass->draw_polygon) (style, window, state_type, shadow_type, NULL, NULL, NULL, points, npoints, fill);
756 gtk_draw_arrow (GtkStyle *style,
758 GtkStateType state_type,
759 GtkShadowType shadow_type,
760 GtkArrowType arrow_type,
767 g_return_if_fail (style != NULL);
768 g_return_if_fail (style->klass != NULL);
769 g_return_if_fail (style->klass->draw_arrow != NULL);
771 (*style->klass->draw_arrow) (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, fill, x, y, width, height);
776 gtk_draw_diamond (GtkStyle *style,
778 GtkStateType state_type,
779 GtkShadowType shadow_type,
785 g_return_if_fail (style != NULL);
786 g_return_if_fail (style->klass != NULL);
787 g_return_if_fail (style->klass->draw_diamond != NULL);
789 (*style->klass->draw_diamond) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
794 gtk_draw_oval (GtkStyle *style,
796 GtkStateType state_type,
797 GtkShadowType shadow_type,
803 g_return_if_fail (style != NULL);
804 g_return_if_fail (style->klass != NULL);
805 g_return_if_fail (style->klass->draw_oval != NULL);
807 (*style->klass->draw_oval) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
811 gtk_draw_string (GtkStyle *style,
813 GtkStateType state_type,
818 g_return_if_fail (style != NULL);
819 g_return_if_fail (style->klass != NULL);
820 g_return_if_fail (style->klass->draw_oval != NULL);
822 (*style->klass->draw_string) (style, window, state_type, NULL, NULL, NULL, x, y, string);
826 gtk_draw_box (GtkStyle *style,
828 GtkStateType state_type,
829 GtkShadowType shadow_type,
835 g_return_if_fail (style != NULL);
836 g_return_if_fail (style->klass != NULL);
837 g_return_if_fail (style->klass->draw_box != NULL);
839 (*style->klass->draw_box) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
843 gtk_draw_flat_box (GtkStyle *style,
845 GtkStateType state_type,
846 GtkShadowType shadow_type,
852 g_return_if_fail (style != NULL);
853 g_return_if_fail (style->klass != NULL);
854 g_return_if_fail (style->klass->draw_flat_box != NULL);
856 (*style->klass->draw_flat_box) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
860 gtk_draw_check (GtkStyle *style,
862 GtkStateType state_type,
863 GtkShadowType shadow_type,
869 g_return_if_fail (style != NULL);
870 g_return_if_fail (style->klass != NULL);
871 g_return_if_fail (style->klass->draw_check != NULL);
873 (*style->klass->draw_check) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
877 gtk_draw_option (GtkStyle *style,
879 GtkStateType state_type,
880 GtkShadowType shadow_type,
886 g_return_if_fail (style != NULL);
887 g_return_if_fail (style->klass != NULL);
888 g_return_if_fail (style->klass->draw_option != NULL);
890 (*style->klass->draw_option) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
894 gtk_draw_cross (GtkStyle *style,
896 GtkStateType state_type,
897 GtkShadowType shadow_type,
903 g_return_if_fail (style != NULL);
904 g_return_if_fail (style->klass != NULL);
905 g_return_if_fail (style->klass->draw_cross != NULL);
907 (*style->klass->draw_cross) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
911 gtk_draw_ramp (GtkStyle *style,
913 GtkStateType state_type,
914 GtkShadowType shadow_type,
915 GtkArrowType arrow_type,
921 g_return_if_fail (style != NULL);
922 g_return_if_fail (style->klass != NULL);
923 g_return_if_fail (style->klass->draw_ramp != NULL);
925 (*style->klass->draw_ramp) (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, x, y, width, height);
929 gtk_draw_tab (GtkStyle *style,
931 GtkStateType state_type,
932 GtkShadowType shadow_type,
938 g_return_if_fail (style != NULL);
939 g_return_if_fail (style->klass != NULL);
940 g_return_if_fail (style->klass->draw_tab != NULL);
942 (*style->klass->draw_tab) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
946 gtk_draw_shadow_gap (GtkStyle *style,
948 GtkStateType state_type,
949 GtkShadowType shadow_type,
954 GtkPositionType gap_side,
958 g_return_if_fail (style != NULL);
959 g_return_if_fail (style->klass != NULL);
960 g_return_if_fail (style->klass->draw_shadow_gap != NULL);
962 (*style->klass->draw_shadow_gap) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width);
966 gtk_draw_box_gap (GtkStyle *style,
968 GtkStateType state_type,
969 GtkShadowType shadow_type,
974 GtkPositionType gap_side,
978 g_return_if_fail (style != NULL);
979 g_return_if_fail (style->klass != NULL);
980 g_return_if_fail (style->klass->draw_box_gap != NULL);
982 (*style->klass->draw_box_gap) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width);
986 gtk_draw_extension (GtkStyle *style,
988 GtkStateType state_type,
989 GtkShadowType shadow_type,
994 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_extension != NULL);
1000 (*style->klass->draw_extension) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side);
1004 gtk_draw_focus (GtkStyle *style,
1011 g_return_if_fail (style != NULL);
1012 g_return_if_fail (style->klass != NULL);
1013 g_return_if_fail (style->klass->draw_focus != NULL);
1015 (*style->klass->draw_focus) (style, window, NULL, NULL, NULL, x, y, width, height);
1019 gtk_draw_slider (GtkStyle *style,
1021 GtkStateType state_type,
1022 GtkShadowType shadow_type,
1027 GtkOrientation orientation)
1029 g_return_if_fail (style != NULL);
1030 g_return_if_fail (style->klass != NULL);
1031 g_return_if_fail (style->klass->draw_slider != NULL);
1033 (*style->klass->draw_slider) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
1037 gtk_draw_handle (GtkStyle *style,
1039 GtkStateType state_type,
1040 GtkShadowType shadow_type,
1045 GtkOrientation orientation)
1047 g_return_if_fail (style != NULL);
1048 g_return_if_fail (style->klass != NULL);
1049 g_return_if_fail (style->klass->draw_handle != NULL);
1051 (*style->klass->draw_handle) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
1055 gtk_style_set_background (GtkStyle *style,
1057 GtkStateType state_type)
1060 gint parent_relative;
1062 if (style->engine && style->engine->set_background)
1064 (*style->engine->set_background) (style, window, state_type);
1068 g_return_if_fail (style != NULL);
1069 g_return_if_fail (window != NULL);
1071 if (style->bg_pixmap[state_type])
1073 if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
1076 parent_relative = TRUE;
1080 pixmap = style->bg_pixmap[state_type];
1081 parent_relative = FALSE;
1084 gdk_window_set_back_pixmap (window, pixmap, parent_relative);
1087 gdk_window_set_background (window, &style->bg[state_type]);
1091 /* Default functions */
1093 gtk_style_apply_default_background (GtkStyle *style,
1096 GtkStateType state_type,
1103 GdkRectangle new_rect, old_rect;
1110 old_rect.width = width;
1111 old_rect.height = height;
1113 if (!gdk_rectangle_intersect (area, &old_rect, &new_rect))
1120 new_rect.width = width;
1121 new_rect.height = height;
1124 if (!style->bg_pixmap[state_type] ||
1125 (gdk_window_get_type (window) == GDK_WINDOW_PIXMAP) ||
1126 (!set_bg && (style->bg_pixmap[state_type] != (GdkPixmap *) GDK_PARENT_RELATIVE)))
1128 GdkGC *gc = style->bg_gc[state_type];
1130 if (style->bg_pixmap[state_type])
1132 gdk_gc_set_fill (gc, GDK_TILED);
1133 gdk_gc_set_tile (gc, style->bg_pixmap[state_type]);
1136 gdk_draw_rectangle (window, gc, TRUE,
1137 new_rect.x, new_rect.y, new_rect.width, new_rect.height);
1138 if (style->bg_pixmap[state_type])
1139 gdk_gc_set_fill (gc, GDK_SOLID);
1145 if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
1146 gdk_window_set_back_pixmap (window, NULL, TRUE);
1148 gdk_window_set_back_pixmap (window, style->bg_pixmap[state_type], FALSE);
1151 gdk_window_clear_area (window,
1152 new_rect.x, new_rect.y,
1153 new_rect.width, new_rect.height);
1158 gtk_style_apply_default_pixmap (GtkStyle *style,
1160 GtkStateType state_type,
1167 gtk_style_apply_default_background (style, window, TRUE, state_type,
1168 area, x, y, width, height);
1172 gtk_default_draw_hline (GtkStyle *style,
1174 GtkStateType state_type,
1182 gint thickness_light;
1183 gint thickness_dark;
1186 g_return_if_fail (style != NULL);
1187 g_return_if_fail (window != NULL);
1189 thickness_light = style->klass->ythickness / 2;
1190 thickness_dark = style->klass->ythickness - thickness_light;
1194 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1195 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1198 if (detail && !strcmp (detail, "label"))
1200 if (state_type == GTK_STATE_INSENSITIVE)
1201 gdk_draw_line (window, style->white_gc, x1 + 1, y + 1, x2 + 1, y + 1);
1202 gdk_draw_line (window, style->fg_gc[state_type], x1, y, x2, y);
1206 for (i = 0; i < thickness_dark; i++)
1208 gdk_draw_line (window, style->light_gc[state_type], x2 - i - 1, y + i, x2, y + i);
1209 gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x2 - i - 1, y + i);
1212 y += thickness_dark;
1213 for (i = 0; i < thickness_light; i++)
1215 gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x1 + thickness_light - i - 1, y + i);
1216 gdk_draw_line (window, style->light_gc[state_type], x1 + thickness_light - i - 1, y + i, x2, y + i);
1222 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
1223 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
1229 gtk_default_draw_vline (GtkStyle *style,
1231 GtkStateType state_type,
1239 gint thickness_light;
1240 gint thickness_dark;
1243 g_return_if_fail (style != NULL);
1244 g_return_if_fail (window != NULL);
1246 thickness_light = style->klass->xthickness / 2;
1247 thickness_dark = style->klass->xthickness - thickness_light;
1251 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1252 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1254 for (i = 0; i < thickness_dark; i++)
1256 gdk_draw_line (window, style->light_gc[state_type], x + i, y2 - i - 1, x + i, y2);
1257 gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y2 - i - 1);
1260 x += thickness_dark;
1261 for (i = 0; i < thickness_light; i++)
1263 gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y1 + thickness_light - i);
1264 gdk_draw_line (window, style->light_gc[state_type], x + i, y1 + thickness_light - i, x + i, y2);
1268 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
1269 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
1275 gtk_default_draw_shadow (GtkStyle *style,
1277 GtkStateType state_type,
1278 GtkShadowType shadow_type,
1289 gint thickness_light;
1290 gint thickness_dark;
1293 g_return_if_fail (style != NULL);
1294 g_return_if_fail (window != NULL);
1296 if ((width == -1) && (height == -1))
1297 gdk_window_get_size (window, &width, &height);
1298 else if (width == -1)
1299 gdk_window_get_size (window, &width, NULL);
1300 else if (height == -1)
1301 gdk_window_get_size (window, NULL, &height);
1303 switch (shadow_type)
1305 case GTK_SHADOW_NONE:
1308 case GTK_SHADOW_ETCHED_IN:
1309 gc1 = style->light_gc[state_type];
1310 gc2 = style->dark_gc[state_type];
1312 case GTK_SHADOW_OUT:
1313 case GTK_SHADOW_ETCHED_OUT:
1314 gc1 = style->dark_gc[state_type];
1315 gc2 = style->light_gc[state_type];
1321 gdk_gc_set_clip_rectangle (gc1, area);
1322 gdk_gc_set_clip_rectangle (gc2, area);
1323 if (shadow_type == GTK_SHADOW_IN ||
1324 shadow_type == GTK_SHADOW_OUT)
1326 gdk_gc_set_clip_rectangle (style->black_gc, area);
1327 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
1331 switch (shadow_type)
1333 case GTK_SHADOW_NONE:
1337 gdk_draw_line (window, gc1,
1338 x, y + height - 1, x + width - 1, y + height - 1);
1339 gdk_draw_line (window, gc1,
1340 x + width - 1, y, x + width - 1, y + height - 1);
1342 gdk_draw_line (window, style->bg_gc[state_type],
1343 x + 1, y + height - 2, x + width - 2, y + height - 2);
1344 gdk_draw_line (window, style->bg_gc[state_type],
1345 x + width - 2, y + 1, x + width - 2, y + height - 2);
1347 gdk_draw_line (window, style->black_gc,
1348 x + 1, y + 1, x + width - 2, y + 1);
1349 gdk_draw_line (window, style->black_gc,
1350 x + 1, y + 1, x + 1, y + height - 2);
1352 gdk_draw_line (window, gc2,
1353 x, y, x + width - 1, y);
1354 gdk_draw_line (window, gc2,
1355 x, y, x, y + height - 1);
1358 case GTK_SHADOW_OUT:
1359 gdk_draw_line (window, gc1,
1360 x + 1, y + height - 2, x + width - 2, y + height - 2);
1361 gdk_draw_line (window, gc1,
1362 x + width - 2, y + 1, x + width - 2, y + height - 2);
1364 gdk_draw_line (window, gc2,
1365 x, y, x + width - 1, y);
1366 gdk_draw_line (window, gc2,
1367 x, y, x, y + height - 1);
1369 gdk_draw_line (window, style->bg_gc[state_type],
1370 x + 1, y + 1, x + width - 2, y + 1);
1371 gdk_draw_line (window, style->bg_gc[state_type],
1372 x + 1, y + 1, x + 1, y + height - 2);
1374 gdk_draw_line (window, style->black_gc,
1375 x, y + height - 1, x + width - 1, y + height - 1);
1376 gdk_draw_line (window, style->black_gc,
1377 x + width - 1, y, x + width - 1, y + height - 1);
1380 case GTK_SHADOW_ETCHED_IN:
1381 case GTK_SHADOW_ETCHED_OUT:
1382 thickness_light = 1;
1385 for (i = 0; i < thickness_dark; i++)
1387 gdk_draw_line (window, gc1,
1391 y + height - i - 1);
1392 gdk_draw_line (window, gc1,
1396 y + height - i - 1);
1398 gdk_draw_line (window, gc2,
1403 gdk_draw_line (window, gc2,
1407 y + height - i - 2);
1410 for (i = 0; i < thickness_light; i++)
1412 gdk_draw_line (window, gc1,
1413 x + thickness_dark + i,
1414 y + thickness_dark + i,
1415 x + width - thickness_dark - i - 1,
1416 y + thickness_dark + i);
1417 gdk_draw_line (window, gc1,
1418 x + thickness_dark + i,
1419 y + thickness_dark + i,
1420 x + thickness_dark + i,
1421 y + height - thickness_dark - i - 1);
1423 gdk_draw_line (window, gc2,
1424 x + thickness_dark + i,
1425 y + height - thickness_light - i - 1,
1426 x + width - thickness_light - 1,
1427 y + height - thickness_light - i - 1);
1428 gdk_draw_line (window, gc2,
1429 x + width - thickness_light - i - 1,
1430 y + thickness_dark + i,
1431 x + width - thickness_light - i - 1,
1432 y + height - thickness_light - 1);
1438 gdk_gc_set_clip_rectangle (gc1, NULL);
1439 gdk_gc_set_clip_rectangle (gc2, NULL);
1440 if (shadow_type == GTK_SHADOW_IN ||
1441 shadow_type == GTK_SHADOW_OUT)
1443 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
1444 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
1451 gtk_default_draw_polygon (GtkStyle *style,
1453 GtkStateType state_type,
1454 GtkShadowType shadow_type,
1463 #define M_PI 3.14159265358979323846
1466 #define M_PI_4 0.78539816339744830962
1469 static const gdouble pi_over_4 = M_PI_4;
1470 static const gdouble pi_3_over_4 = M_PI_4 * 3;
1481 g_return_if_fail (style != NULL);
1482 g_return_if_fail (window != NULL);
1483 g_return_if_fail (points != NULL);
1485 switch (shadow_type)
1488 gc1 = style->bg_gc[state_type];
1489 gc2 = style->dark_gc[state_type];
1490 gc3 = style->light_gc[state_type];
1491 gc4 = style->black_gc;
1493 case GTK_SHADOW_ETCHED_IN:
1494 gc1 = style->light_gc[state_type];
1495 gc2 = style->dark_gc[state_type];
1496 gc3 = style->dark_gc[state_type];
1497 gc4 = style->light_gc[state_type];
1499 case GTK_SHADOW_OUT:
1500 gc1 = style->dark_gc[state_type];
1501 gc2 = style->light_gc[state_type];
1502 gc3 = style->black_gc;
1503 gc4 = style->bg_gc[state_type];
1505 case GTK_SHADOW_ETCHED_OUT:
1506 gc1 = style->dark_gc[state_type];
1507 gc2 = style->light_gc[state_type];
1508 gc3 = style->light_gc[state_type];
1509 gc4 = style->dark_gc[state_type];
1517 gdk_gc_set_clip_rectangle (gc1, area);
1518 gdk_gc_set_clip_rectangle (gc2, area);
1519 gdk_gc_set_clip_rectangle (gc3, area);
1520 gdk_gc_set_clip_rectangle (gc4, area);
1524 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, npoints);
1528 for (i = 0; i < npoints; i++)
1530 if ((points[i].x == points[i+1].x) &&
1531 (points[i].y == points[i+1].y))
1537 angle = atan2 (points[i+1].y - points[i].y,
1538 points[i+1].x - points[i].x);
1541 if ((angle > -pi_3_over_4) && (angle < pi_over_4))
1543 if (angle > -pi_over_4)
1554 gdk_draw_line (window, gc1,
1555 points[i].x-xadjust, points[i].y-yadjust,
1556 points[i+1].x-xadjust, points[i+1].y-yadjust);
1557 gdk_draw_line (window, gc3,
1558 points[i].x, points[i].y,
1559 points[i+1].x, points[i+1].y);
1563 if ((angle < -pi_3_over_4) || (angle > pi_3_over_4))
1574 gdk_draw_line (window, gc4,
1575 points[i].x+xadjust, points[i].y+yadjust,
1576 points[i+1].x+xadjust, points[i+1].y+yadjust);
1577 gdk_draw_line (window, gc2,
1578 points[i].x, points[i].y,
1579 points[i+1].x, points[i+1].y);
1584 gdk_gc_set_clip_rectangle (gc1, NULL);
1585 gdk_gc_set_clip_rectangle (gc2, NULL);
1586 gdk_gc_set_clip_rectangle (gc3, NULL);
1587 gdk_gc_set_clip_rectangle (gc4, NULL);
1592 gtk_default_draw_arrow (GtkStyle *style,
1594 GtkStateType state_type,
1595 GtkShadowType shadow_type,
1599 GtkArrowType arrow_type,
1614 g_return_if_fail (style != NULL);
1615 g_return_if_fail (window != NULL);
1617 switch (shadow_type)
1620 gc1 = style->bg_gc[state_type];
1621 gc2 = style->dark_gc[state_type];
1622 gc3 = style->light_gc[state_type];
1623 gc4 = style->black_gc;
1625 case GTK_SHADOW_OUT:
1626 gc1 = style->dark_gc[state_type];
1627 gc2 = style->light_gc[state_type];
1628 gc3 = style->black_gc;
1629 gc4 = style->bg_gc[state_type];
1631 case GTK_SHADOW_ETCHED_IN:
1632 gc1 = style->light_gc[state_type];
1633 gc2 = style->dark_gc[state_type];
1637 case GTK_SHADOW_ETCHED_OUT:
1638 gc1 = style->dark_gc[state_type];
1639 gc2 = style->light_gc[state_type];
1647 if ((width == -1) && (height == -1))
1648 gdk_window_get_size (window, &width, &height);
1649 else if (width == -1)
1650 gdk_window_get_size (window, &width, NULL);
1651 else if (height == -1)
1652 gdk_window_get_size (window, NULL, &height);
1654 half_width = width / 2;
1655 half_height = height / 2;
1659 gdk_gc_set_clip_rectangle (gc1, area);
1660 gdk_gc_set_clip_rectangle (gc2, area);
1663 gdk_gc_set_clip_rectangle (gc3, area);
1664 gdk_gc_set_clip_rectangle (gc4, area);
1673 points[0].x = x + half_width;
1676 points[1].y = y + height - 1;
1677 points[2].x = x + width - 1;
1678 points[2].y = y + height - 1;
1680 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1683 switch (shadow_type)
1686 case GTK_SHADOW_OUT:
1688 gdk_draw_line (window, gc1,
1689 x + 1, y + height - 2,
1690 x + width - 2, y + height - 2);
1691 gdk_draw_line (window, gc3,
1692 x + 0, y + height - 1,
1693 x + width - 1, y + height - 1);
1695 gdk_draw_line (window, gc1,
1696 x + width - 2, y + height - 1,
1697 x + half_width, y + 1);
1698 gdk_draw_line (window, gc3,
1699 x + width - 1, y + height - 1,
1702 gdk_draw_line (window, gc4,
1703 x + half_width, y + 1,
1704 x + 1, y + height - 1);
1705 gdk_draw_line (window, gc2,
1710 case GTK_SHADOW_ETCHED_IN:
1711 case GTK_SHADOW_ETCHED_OUT:
1712 gdk_draw_line (window, gc1,
1713 x + half_width, y + 1,
1714 x + 1, y + height - 1);
1715 gdk_draw_line (window, gc1,
1716 x + 1, y + height - 1,
1717 x + width - 1, y + height - 1);
1718 gdk_draw_line (window, gc1,
1719 x + width - 1, y + height - 1,
1720 x + half_width + 1, y + 1);
1722 points[0].x = x + half_width;
1725 points[1].y = y + height - 2;
1726 points[2].x = x + width - 2;
1727 points[2].y = y + height - 2;
1729 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1737 case GTK_ARROW_DOWN:
1740 points[0].x = x + width - 1;
1744 points[2].x = x + half_width;
1745 points[2].y = y + height - 1;
1747 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1749 switch (shadow_type)
1752 case GTK_SHADOW_OUT:
1753 gdk_draw_line (window, gc4,
1755 y + 1, x + 1, y + 1);
1756 gdk_draw_line (window, gc2,
1760 gdk_draw_line (window, gc4,
1762 x + half_width, y + height - 2);
1763 gdk_draw_line (window, gc2,
1765 x + half_width, y + height - 1);
1767 gdk_draw_line (window, gc1,
1768 x + half_width, y + height - 2,
1770 gdk_draw_line (window, gc3,
1771 x + half_width, y + height - 1,
1775 case GTK_SHADOW_ETCHED_IN:
1776 case GTK_SHADOW_ETCHED_OUT:
1777 gdk_draw_line (window, gc1,
1778 x + width - 1, y + 1,
1780 gdk_draw_line (window, gc1,
1782 x + half_width + 1, y + height - 1);
1783 gdk_draw_line (window, gc1,
1784 x + half_width + 1, y + height - 2,
1787 points[0].x = x + width - 2;
1791 points[2].x = x + half_width;
1792 points[2].y = y + height - 2;
1794 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1801 case GTK_ARROW_LEFT:
1805 points[0].y = y + half_height;
1806 points[1].x = x + width - 1;
1807 points[1].y = y + height - 1;
1808 points[2].x = x + width - 1;
1811 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1814 switch (shadow_type)
1817 case GTK_SHADOW_OUT:
1818 gdk_draw_line (window, gc1,
1819 x + 1, y + half_height,
1820 x + width - 1, y + height - 1);
1821 gdk_draw_line (window, gc3,
1823 x + width - 1, y + height - 1);
1825 gdk_draw_line (window, gc1,
1826 x + width - 2, y + height - 1,
1827 x + width - 2, y + 1);
1828 gdk_draw_line (window, gc3,
1829 x + width - 1, y + height - 1,
1832 gdk_draw_line (window, gc4,
1833 x + width - 1, y + 1,
1834 x + 1, y + half_height);
1835 gdk_draw_line (window, gc2,
1837 x, y + half_height);
1840 case GTK_SHADOW_ETCHED_IN:
1841 case GTK_SHADOW_ETCHED_OUT:
1842 gdk_draw_line (window, gc1,
1843 x + width - 1, y + 1,
1844 x + 1, y + half_height);
1845 gdk_draw_line (window, gc1,
1846 x + 1, y + half_height + 1,
1847 x + width - 1, y + height - 1);
1848 gdk_draw_line (window, gc1,
1849 x + width - 1, y + height - 1,
1850 x + width - 1, y + 1);
1852 points[0].x = x + width - 2;
1855 points[1].y = y + half_height;
1856 points[2].x = x + width - 2;
1857 points[2].y = y + height - 2;
1859 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1866 case GTK_ARROW_RIGHT:
1869 points[0].x = x + width - 1;
1870 points[0].y = y + half_height;
1874 points[2].y = y + height - 1;
1876 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1879 switch (shadow_type)
1882 case GTK_SHADOW_OUT:
1883 gdk_draw_line (window, gc4,
1884 x + width - 1, y + half_height,
1886 gdk_draw_line (window, gc2,
1887 x + width - 1, y + half_height,
1889 gdk_draw_line (window, gc4,
1891 x + 1, y + height - 2);
1892 gdk_draw_line (window, gc2,
1896 gdk_draw_line (window, gc1,
1897 x + 1, y + height - 2,
1898 x + width - 1, y + half_height);
1899 gdk_draw_line (window, gc3,
1901 x + width - 1, y + half_height);
1904 case GTK_SHADOW_ETCHED_IN:
1905 case GTK_SHADOW_ETCHED_OUT:
1906 gdk_draw_line (window, gc1,
1907 x + width - 1, y + half_height + 1,
1909 gdk_draw_line (window, gc1,
1911 x + 1, y + height - 1);
1912 gdk_draw_line (window, gc1,
1913 x + 1, y + height - 1,
1914 x + width - 1, y + half_height + 1);
1916 points[0].x = x + width - 2;
1917 points[0].y = y + half_height;
1921 points[2].y = y + height - 1;
1923 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1933 gdk_gc_set_clip_rectangle (gc1, NULL);
1934 gdk_gc_set_clip_rectangle (gc2, NULL);
1937 gdk_gc_set_clip_rectangle (gc3, NULL);
1938 gdk_gc_set_clip_rectangle (gc4, NULL);
1944 gtk_default_draw_diamond (GtkStyle *style,
1946 GtkStateType state_type,
1947 GtkShadowType shadow_type,
1959 g_return_if_fail (style != NULL);
1960 g_return_if_fail (window != NULL);
1962 if ((width == -1) && (height == -1))
1963 gdk_window_get_size (window, &width, &height);
1964 else if (width == -1)
1965 gdk_window_get_size (window, &width, NULL);
1966 else if (height == -1)
1967 gdk_window_get_size (window, NULL, &height);
1969 half_width = width / 2;
1970 half_height = height / 2;
1974 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1975 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
1976 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1977 gdk_gc_set_clip_rectangle (style->black_gc, area);
1979 switch (shadow_type)
1982 gdk_draw_line (window, style->bg_gc[state_type],
1983 x + 2, y + half_height,
1984 x + half_width, y + height - 2);
1985 gdk_draw_line (window, style->bg_gc[state_type],
1986 x + half_width, y + height - 2,
1987 x + width - 2, y + half_height);
1988 gdk_draw_line (window, style->light_gc[state_type],
1989 x + 1, y + half_height,
1990 x + half_width, y + height - 1);
1991 gdk_draw_line (window, style->light_gc[state_type],
1992 x + half_width, y + height - 1,
1993 x + width - 1, y + half_height);
1994 gdk_draw_line (window, style->light_gc[state_type],
1996 x + half_width, y + height);
1997 gdk_draw_line (window, style->light_gc[state_type],
1998 x + half_width, y + height,
1999 x + width, y + half_height);
2001 gdk_draw_line (window, style->black_gc,
2002 x + 2, y + half_height,
2003 x + half_width, y + 2);
2004 gdk_draw_line (window, style->black_gc,
2005 x + half_width, y + 2,
2006 x + width - 2, y + half_height);
2007 gdk_draw_line (window, style->dark_gc[state_type],
2008 x + 1, y + half_height,
2009 x + half_width, y + 1);
2010 gdk_draw_line (window, style->dark_gc[state_type],
2011 x + half_width, y + 1,
2012 x + width - 1, y + half_height);
2013 gdk_draw_line (window, style->dark_gc[state_type],
2016 gdk_draw_line (window, style->dark_gc[state_type],
2018 x + width, y + half_height);
2020 case GTK_SHADOW_OUT:
2021 gdk_draw_line (window, style->dark_gc[state_type],
2022 x + 2, y + half_height,
2023 x + half_width, y + height - 2);
2024 gdk_draw_line (window, style->dark_gc[state_type],
2025 x + half_width, y + height - 2,
2026 x + width - 2, y + half_height);
2027 gdk_draw_line (window, style->dark_gc[state_type],
2028 x + 1, y + half_height,
2029 x + half_width, y + height - 1);
2030 gdk_draw_line (window, style->dark_gc[state_type],
2031 x + half_width, y + height - 1,
2032 x + width - 1, y + half_height);
2033 gdk_draw_line (window, style->black_gc,
2035 x + half_width, y + height);
2036 gdk_draw_line (window, style->black_gc,
2037 x + half_width, y + height,
2038 x + width, y + half_height);
2040 gdk_draw_line (window, style->bg_gc[state_type],
2041 x + 2, y + half_height,
2042 x + half_width, y + 2);
2043 gdk_draw_line (window, style->bg_gc[state_type],
2044 x + half_width, y + 2,
2045 x + width - 2, y + half_height);
2046 gdk_draw_line (window, style->light_gc[state_type],
2047 x + 1, y + half_height,
2048 x + half_width, y + 1);
2049 gdk_draw_line (window, style->light_gc[state_type],
2050 x + half_width, y + 1,
2051 x + width - 1, y + half_height);
2052 gdk_draw_line (window, style->light_gc[state_type],
2055 gdk_draw_line (window, style->light_gc[state_type],
2057 x + width, y + half_height);
2064 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
2065 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2066 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
2067 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2073 gtk_default_draw_oval (GtkStyle *style,
2075 GtkStateType state_type,
2076 GtkShadowType shadow_type,
2085 g_return_if_fail (style != NULL);
2086 g_return_if_fail (window != NULL);
2090 gtk_default_draw_string (GtkStyle *style,
2092 GtkStateType state_type,
2098 const gchar *string)
2100 g_return_if_fail (style != NULL);
2101 g_return_if_fail (window != NULL);
2105 gdk_gc_set_clip_rectangle (style->white_gc, area);
2106 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], area);
2108 if (state_type == GTK_STATE_INSENSITIVE)
2109 gdk_draw_string (window, style->font, style->white_gc, x + 1, y + 1, string);
2110 gdk_draw_string (window, style->font, style->fg_gc[state_type], x, y, string);
2113 gdk_gc_set_clip_rectangle (style->white_gc, NULL);
2114 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], NULL);
2119 gtk_default_draw_box (GtkStyle *style,
2121 GtkStateType state_type,
2122 GtkShadowType shadow_type,
2131 g_return_if_fail (style != NULL);
2132 g_return_if_fail (window != NULL);
2134 if ((width == -1) && (height == -1))
2135 gdk_window_get_size (window, &width, &height);
2136 else if (width == -1)
2137 gdk_window_get_size (window, &width, NULL);
2138 else if (height == -1)
2139 gdk_window_get_size (window, NULL, &height);
2141 if (!style->bg_pixmap[state_type] ||
2142 gdk_window_get_type (window) == GDK_WINDOW_PIXMAP)
2146 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
2148 gdk_draw_rectangle (window, style->bg_gc[state_type], TRUE,
2149 x, y, width, height);
2152 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2156 gtk_style_apply_default_background (style, window,
2157 widget && !GTK_WIDGET_NO_WINDOW (widget),
2158 state_type, area, x, y, width, height);
2160 gtk_paint_shadow (style, window, state_type, shadow_type, area, widget, detail,
2161 x, y, width, height);
2165 gtk_default_draw_flat_box (GtkStyle *style,
2167 GtkStateType state_type,
2168 GtkShadowType shadow_type,
2179 g_return_if_fail (style != NULL);
2180 g_return_if_fail (window != NULL);
2182 if ((width == -1) && (height == -1))
2183 gdk_window_get_size (window, &width, &height);
2184 else if (width == -1)
2185 gdk_window_get_size (window, &width, NULL);
2186 else if (height == -1)
2187 gdk_window_get_size (window, NULL, &height);
2189 if ((detail) && (!strcmp("text",detail)) && (state_type == GTK_STATE_SELECTED))
2190 gc1 = style->bg_gc[GTK_STATE_SELECTED];
2191 else if ((detail) && (!strcmp("viewportbin",detail)))
2192 gc1 = style->bg_gc[GTK_STATE_NORMAL];
2193 else if ((detail) && (!strcmp("entry_bg",detail)))
2194 gc1 = style->base_gc[state_type];
2196 gc1 = style->bg_gc[state_type];
2198 if (!style->bg_pixmap[state_type] || gc1 != style->bg_gc[state_type] ||
2199 gdk_window_get_type (window) == GDK_WINDOW_PIXMAP)
2203 gdk_gc_set_clip_rectangle (gc1, area);
2205 gdk_draw_rectangle (window, gc1, TRUE,
2206 x, y, width, height);
2207 if ((detail) && (!strcmp("tooltip",detail)))
2208 gdk_draw_rectangle (window, style->black_gc, FALSE,
2209 x, y, width - 1, height - 1);
2212 gdk_gc_set_clip_rectangle (gc1, NULL);
2216 gtk_style_apply_default_background (style, window,
2217 widget && !GTK_WIDGET_NO_WINDOW (widget),
2218 state_type, area, x, y, width, height);
2222 gtk_default_draw_check (GtkStyle *style,
2224 GtkStateType state_type,
2225 GtkShadowType shadow_type,
2234 gtk_paint_box (style, window, state_type, shadow_type, area, widget, detail,
2235 x, y, width, height);
2239 gtk_default_draw_option (GtkStyle *style,
2241 GtkStateType state_type,
2242 GtkShadowType shadow_type,
2251 gtk_paint_diamond (style, window, state_type, shadow_type, area, widget,
2252 detail, x, y, width, height);
2256 gtk_default_draw_cross (GtkStyle *style,
2258 GtkStateType state_type,
2259 GtkShadowType shadow_type,
2268 g_return_if_fail (style != NULL);
2269 g_return_if_fail (window != NULL);
2273 gtk_default_draw_ramp (GtkStyle *style,
2275 GtkStateType state_type,
2276 GtkShadowType shadow_type,
2280 GtkArrowType arrow_type,
2286 g_return_if_fail (style != NULL);
2287 g_return_if_fail (window != NULL);
2290 static void gtk_default_draw_tab (GtkStyle *style,
2292 GtkStateType state_type,
2293 GtkShadowType shadow_type,
2302 g_return_if_fail (style != NULL);
2303 g_return_if_fail (window != NULL);
2305 gtk_paint_box (style, window, state_type, shadow_type, area, widget, detail,
2306 x, y, width, height);
2310 gtk_default_draw_shadow_gap (GtkStyle *style,
2312 GtkStateType state_type,
2313 GtkShadowType shadow_type,
2321 GtkPositionType gap_side,
2330 g_return_if_fail (style != NULL);
2331 g_return_if_fail (window != NULL);
2333 if ((width == -1) && (height == -1))
2334 gdk_window_get_size (window, &width, &height);
2335 else if (width == -1)
2336 gdk_window_get_size (window, &width, NULL);
2337 else if (height == -1)
2338 gdk_window_get_size (window, NULL, &height);
2340 switch (shadow_type)
2342 case GTK_SHADOW_NONE:
2345 gc1 = style->dark_gc[state_type];
2346 gc2 = style->black_gc;
2347 gc3 = style->bg_gc[state_type];
2348 gc4 = style->light_gc[state_type];
2350 case GTK_SHADOW_ETCHED_IN:
2351 gc1 = style->dark_gc[state_type];
2352 gc2 = style->light_gc[state_type];
2353 gc3 = style->dark_gc[state_type];
2354 gc4 = style->light_gc[state_type];
2356 case GTK_SHADOW_OUT:
2357 gc1 = style->light_gc[state_type];
2358 gc2 = style->bg_gc[state_type];
2359 gc3 = style->dark_gc[state_type];
2360 gc4 = style->black_gc;
2362 case GTK_SHADOW_ETCHED_OUT:
2363 gc1 = style->light_gc[state_type];
2364 gc2 = style->dark_gc[state_type];
2365 gc3 = style->light_gc[state_type];
2366 gc4 = style->dark_gc[state_type];
2371 gdk_gc_set_clip_rectangle (gc1, area);
2372 gdk_gc_set_clip_rectangle (gc2, area);
2373 gdk_gc_set_clip_rectangle (gc3, area);
2374 gdk_gc_set_clip_rectangle (gc4, area);
2377 switch (shadow_type)
2379 case GTK_SHADOW_NONE:
2381 case GTK_SHADOW_OUT:
2382 case GTK_SHADOW_ETCHED_IN:
2383 case GTK_SHADOW_ETCHED_OUT:
2387 gdk_draw_line (window, gc1,
2388 x, y, x, y + height - 1);
2389 gdk_draw_line (window, gc2,
2390 x + 1, y, x + 1, y + height - 2);
2392 gdk_draw_line (window, gc3,
2393 x + 1, y + height - 2, x + width - 2, y + height - 2);
2394 gdk_draw_line (window, gc3,
2395 x + width - 2, y, x + width - 2, y + height - 2);
2396 gdk_draw_line (window, gc4,
2397 x, y + height - 1, x + width - 1, y + height - 1);
2398 gdk_draw_line (window, gc4,
2399 x + width - 1, y, x + width - 1, y + height - 1);
2402 gdk_draw_line (window, gc1,
2403 x, y, x + gap_x - 1, y);
2404 gdk_draw_line (window, gc2,
2405 x + 1, y + 1, x + gap_x - 1, y + 1);
2406 gdk_draw_line (window, gc2,
2407 x + gap_x, y, x + gap_x, y);
2409 if ((width - (gap_x + gap_width)) > 0)
2411 gdk_draw_line (window, gc1,
2412 x + gap_x + gap_width, y, x + width - 2, y);
2413 gdk_draw_line (window, gc2,
2414 x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
2415 gdk_draw_line (window, gc2,
2416 x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
2419 case GTK_POS_BOTTOM:
2420 gdk_draw_line (window, gc1,
2421 x, y, x + width - 1, y);
2422 gdk_draw_line (window, gc1,
2423 x, y, x, y + height - 1);
2424 gdk_draw_line (window, gc2,
2425 x + 1, y + 1, x + width - 2, y + 1);
2426 gdk_draw_line (window, gc2,
2427 x + 1, y + 1, x + 1, y + height - 1);
2429 gdk_draw_line (window, gc3,
2430 x + width - 2, y + 1, x + width - 2, y + height - 1);
2431 gdk_draw_line (window, gc4,
2432 x + width - 1, y, x + width - 1, y + height - 1);
2435 gdk_draw_line (window, gc4,
2436 x, y + height - 1, x + gap_x - 1, y + height - 1);
2437 gdk_draw_line (window, gc3,
2438 x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
2439 gdk_draw_line (window, gc3,
2440 x + gap_x, y + height - 1, x + gap_x, y + height - 1);
2442 if ((width - (gap_x + gap_width)) > 0)
2444 gdk_draw_line (window, gc4,
2445 x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
2446 gdk_draw_line (window, gc3,
2447 x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
2448 gdk_draw_line (window, gc3,
2449 x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
2453 gdk_draw_line (window, gc1,
2454 x, y, x + width - 1, y);
2455 gdk_draw_line (window, gc2,
2456 x, y + 1, x + width - 2, y + 1);
2458 gdk_draw_line (window, gc3,
2459 x, y + height - 2, x + width - 2, y + height - 2);
2460 gdk_draw_line (window, gc3,
2461 x + width - 2, y + 1, x + width - 2, y + height - 2);
2462 gdk_draw_line (window, gc4,
2463 x, y + height - 1, x + width - 1, y + height - 1);
2464 gdk_draw_line (window, gc4,
2465 x + width - 1, y, x + width - 1, y + height - 1);
2468 gdk_draw_line (window, gc1,
2469 x, y, x, y + gap_x - 1);
2470 gdk_draw_line (window, gc2,
2471 x + 1, y + 1, x + 1, y + gap_x - 1);
2472 gdk_draw_line (window, gc2,
2473 x, y + gap_x, x, y + gap_x);
2475 if ((width - (gap_x + gap_width)) > 0)
2477 gdk_draw_line (window, gc1,
2478 x, y + gap_x + gap_width, x, y + height - 2);
2479 gdk_draw_line (window, gc2,
2480 x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
2481 gdk_draw_line (window, gc2,
2482 x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
2486 gdk_draw_line (window, gc1,
2487 x, y, x + width - 1, y);
2488 gdk_draw_line (window, gc1,
2489 x, y, x, y + height - 1);
2490 gdk_draw_line (window, gc2,
2491 x + 1, y + 1, x + width - 1, y + 1);
2492 gdk_draw_line (window, gc2,
2493 x + 1, y + 1, x + 1, y + height - 2);
2495 gdk_draw_line (window, gc3,
2496 x + 1, y + height - 2, x + width - 1, y + height - 2);
2497 gdk_draw_line (window, gc4,
2498 x, y + height - 1, x + width - 1, y + height - 1);
2501 gdk_draw_line (window, gc4,
2502 x + width - 1, y, x + width - 1, y + gap_x - 1);
2503 gdk_draw_line (window, gc3,
2504 x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
2505 gdk_draw_line (window, gc3,
2506 x + width - 1, y + gap_x, x + width - 1, y + gap_x);
2508 if ((width - (gap_x + gap_width)) > 0)
2510 gdk_draw_line (window, gc4,
2511 x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
2512 gdk_draw_line (window, gc3,
2513 x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
2514 gdk_draw_line (window, gc3,
2515 x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
2522 gdk_gc_set_clip_rectangle (gc1, NULL);
2523 gdk_gc_set_clip_rectangle (gc2, NULL);
2524 gdk_gc_set_clip_rectangle (gc3, NULL);
2525 gdk_gc_set_clip_rectangle (gc4, NULL);
2530 gtk_default_draw_box_gap (GtkStyle *style,
2532 GtkStateType state_type,
2533 GtkShadowType shadow_type,
2541 GtkPositionType gap_side,
2550 g_return_if_fail (style != NULL);
2551 g_return_if_fail (window != NULL);
2553 gtk_style_apply_default_background (style, window,
2554 widget && !GTK_WIDGET_NO_WINDOW (widget),
2555 state_type, area, x, y, width, height);
2557 if ((width == -1) && (height == -1))
2558 gdk_window_get_size (window, &width, &height);
2559 else if (width == -1)
2560 gdk_window_get_size (window, &width, NULL);
2561 else if (height == -1)
2562 gdk_window_get_size (window, NULL, &height);
2564 switch (shadow_type)
2566 case GTK_SHADOW_NONE:
2569 gc1 = style->dark_gc[state_type];
2570 gc2 = style->black_gc;
2571 gc3 = style->bg_gc[state_type];
2572 gc4 = style->light_gc[state_type];
2574 case GTK_SHADOW_ETCHED_IN:
2575 gc1 = style->dark_gc[state_type];
2576 gc2 = style->light_gc[state_type];
2577 gc3 = style->dark_gc[state_type];
2578 gc4 = style->light_gc[state_type];
2580 case GTK_SHADOW_OUT:
2581 gc1 = style->light_gc[state_type];
2582 gc2 = style->bg_gc[state_type];
2583 gc3 = style->dark_gc[state_type];
2584 gc4 = style->black_gc;
2586 case GTK_SHADOW_ETCHED_OUT:
2587 gc1 = style->light_gc[state_type];
2588 gc2 = style->dark_gc[state_type];
2589 gc3 = style->light_gc[state_type];
2590 gc4 = style->dark_gc[state_type];
2595 gdk_gc_set_clip_rectangle (gc1, area);
2596 gdk_gc_set_clip_rectangle (gc2, area);
2597 gdk_gc_set_clip_rectangle (gc3, area);
2598 gdk_gc_set_clip_rectangle (gc4, area);
2601 switch (shadow_type)
2603 case GTK_SHADOW_NONE:
2605 case GTK_SHADOW_OUT:
2606 case GTK_SHADOW_ETCHED_IN:
2607 case GTK_SHADOW_ETCHED_OUT:
2611 gdk_draw_line (window, gc1,
2612 x, y, x, y + height - 1);
2613 gdk_draw_line (window, gc2,
2614 x + 1, y, x + 1, y + height - 2);
2616 gdk_draw_line (window, gc3,
2617 x + 1, y + height - 2, x + width - 2, y + height - 2);
2618 gdk_draw_line (window, gc3,
2619 x + width - 2, y, x + width - 2, y + height - 2);
2620 gdk_draw_line (window, gc4,
2621 x, y + height - 1, x + width - 1, 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, gc1,
2627 x, y, x + gap_x - 1, y);
2628 gdk_draw_line (window, gc2,
2629 x + 1, y + 1, x + gap_x - 1, y + 1);
2630 gdk_draw_line (window, gc2,
2631 x + gap_x, y, x + gap_x, y);
2633 if ((width - (gap_x + gap_width)) > 0)
2635 gdk_draw_line (window, gc1,
2636 x + gap_x + gap_width, y, x + width - 2, y);
2637 gdk_draw_line (window, gc2,
2638 x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
2639 gdk_draw_line (window, gc2,
2640 x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
2643 case GTK_POS_BOTTOM:
2644 gdk_draw_line (window, gc1,
2645 x, y, x + width - 1, y);
2646 gdk_draw_line (window, gc1,
2647 x, y, x, y + height - 1);
2648 gdk_draw_line (window, gc2,
2649 x + 1, y + 1, x + width - 2, y + 1);
2650 gdk_draw_line (window, gc2,
2651 x + 1, y + 1, x + 1, y + height - 1);
2653 gdk_draw_line (window, gc3,
2654 x + width - 2, y + 1, x + width - 2, 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, gc4,
2660 x, y + height - 1, x + gap_x - 1, y + height - 1);
2661 gdk_draw_line (window, gc3,
2662 x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
2663 gdk_draw_line (window, gc3,
2664 x + gap_x, y + height - 1, x + gap_x, y + height - 1);
2666 if ((width - (gap_x + gap_width)) > 0)
2668 gdk_draw_line (window, gc4,
2669 x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
2670 gdk_draw_line (window, gc3,
2671 x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
2672 gdk_draw_line (window, gc3,
2673 x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
2677 gdk_draw_line (window, gc1,
2678 x, y, x + width - 1, y);
2679 gdk_draw_line (window, gc2,
2680 x, y + 1, x + width - 2, y + 1);
2682 gdk_draw_line (window, gc3,
2683 x, y + height - 2, x + width - 2, y + height - 2);
2684 gdk_draw_line (window, gc3,
2685 x + width - 2, y + 1, x + width - 2, y + height - 2);
2686 gdk_draw_line (window, gc4,
2687 x, y + height - 1, x + width - 1, y + height - 1);
2688 gdk_draw_line (window, gc4,
2689 x + width - 1, y, x + width - 1, y + height - 1);
2692 gdk_draw_line (window, gc1,
2693 x, y, x, y + gap_x - 1);
2694 gdk_draw_line (window, gc2,
2695 x + 1, y + 1, x + 1, y + gap_x - 1);
2696 gdk_draw_line (window, gc2,
2697 x, y + gap_x, x, y + gap_x);
2699 if ((width - (gap_x + gap_width)) > 0)
2701 gdk_draw_line (window, gc1,
2702 x, y + gap_x + gap_width, x, y + height - 2);
2703 gdk_draw_line (window, gc2,
2704 x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
2705 gdk_draw_line (window, gc2,
2706 x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
2710 gdk_draw_line (window, gc1,
2711 x, y, x + width - 1, y);
2712 gdk_draw_line (window, gc1,
2713 x, y, x, y + height - 1);
2714 gdk_draw_line (window, gc2,
2715 x + 1, y + 1, x + width - 1, y + 1);
2716 gdk_draw_line (window, gc2,
2717 x + 1, y + 1, x + 1, y + height - 2);
2719 gdk_draw_line (window, gc3,
2720 x + 1, y + height - 2, x + width - 1, y + height - 2);
2721 gdk_draw_line (window, gc4,
2722 x, y + height - 1, x + width - 1, y + height - 1);
2725 gdk_draw_line (window, gc4,
2726 x + width - 1, y, x + width - 1, y + gap_x - 1);
2727 gdk_draw_line (window, gc3,
2728 x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
2729 gdk_draw_line (window, gc3,
2730 x + width - 1, y + gap_x, x + width - 1, y + gap_x);
2732 if ((width - (gap_x + gap_width)) > 0)
2734 gdk_draw_line (window, gc4,
2735 x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
2736 gdk_draw_line (window, gc3,
2737 x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
2738 gdk_draw_line (window, gc3,
2739 x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
2746 gdk_gc_set_clip_rectangle (gc1, NULL);
2747 gdk_gc_set_clip_rectangle (gc2, NULL);
2748 gdk_gc_set_clip_rectangle (gc3, NULL);
2749 gdk_gc_set_clip_rectangle (gc4, NULL);
2754 gtk_default_draw_extension (GtkStyle *style,
2756 GtkStateType state_type,
2757 GtkShadowType shadow_type,
2765 GtkPositionType gap_side)
2772 g_return_if_fail (style != NULL);
2773 g_return_if_fail (window != NULL);
2775 gtk_style_apply_default_background (style, window,
2776 widget && !GTK_WIDGET_NO_WINDOW (widget),
2777 GTK_STATE_NORMAL, area, x, y, width, height);
2779 if ((width == -1) && (height == -1))
2780 gdk_window_get_size (window, &width, &height);
2781 else if (width == -1)
2782 gdk_window_get_size (window, &width, NULL);
2783 else if (height == -1)
2784 gdk_window_get_size (window, NULL, &height);
2786 switch (shadow_type)
2788 case GTK_SHADOW_NONE:
2791 gc1 = style->dark_gc[state_type];
2792 gc2 = style->black_gc;
2793 gc3 = style->bg_gc[state_type];
2794 gc4 = style->light_gc[state_type];
2796 case GTK_SHADOW_ETCHED_IN:
2797 gc1 = style->dark_gc[state_type];
2798 gc2 = style->light_gc[state_type];
2799 gc3 = style->dark_gc[state_type];
2800 gc4 = style->light_gc[state_type];
2802 case GTK_SHADOW_OUT:
2803 gc1 = style->light_gc[state_type];
2804 gc2 = style->bg_gc[state_type];
2805 gc3 = style->dark_gc[state_type];
2806 gc4 = style->black_gc;
2808 case GTK_SHADOW_ETCHED_OUT:
2809 gc1 = style->light_gc[state_type];
2810 gc2 = style->dark_gc[state_type];
2811 gc3 = style->light_gc[state_type];
2812 gc4 = style->dark_gc[state_type];
2817 gdk_gc_set_clip_rectangle (gc1, area);
2818 gdk_gc_set_clip_rectangle (gc2, area);
2819 gdk_gc_set_clip_rectangle (gc3, area);
2820 gdk_gc_set_clip_rectangle (gc4, area);
2822 switch (shadow_type)
2824 case GTK_SHADOW_NONE:
2826 case GTK_SHADOW_OUT:
2827 case GTK_SHADOW_ETCHED_IN:
2828 case GTK_SHADOW_ETCHED_OUT:
2832 gtk_style_apply_default_background (style, window,
2833 widget && !GTK_WIDGET_NO_WINDOW (widget),
2835 x + style->klass->xthickness,
2837 width - (2 * style->klass->xthickness),
2838 height - (style->klass->ythickness));
2839 gdk_draw_line (window, gc1,
2840 x, y, x, y + height - 2);
2841 gdk_draw_line (window, gc2,
2842 x + 1, y, x + 1, y + height - 2);
2844 gdk_draw_line (window, gc3,
2845 x + 2, y + height - 2, x + width - 2, y + height - 2);
2846 gdk_draw_line (window, gc3,
2847 x + width - 2, y, x + width - 2, y + height - 2);
2848 gdk_draw_line (window, gc4,
2849 x + 1, y + height - 1, x + width - 2, y + height - 1);
2850 gdk_draw_line (window, gc4,
2851 x + width - 1, y, x + width - 1, y + height - 2);
2853 case GTK_POS_BOTTOM:
2854 gtk_style_apply_default_background (style, window,
2855 widget && !GTK_WIDGET_NO_WINDOW (widget),
2857 x + style->klass->xthickness,
2858 y + style->klass->ythickness,
2859 width - (2 * style->klass->xthickness),
2860 height - (style->klass->ythickness));
2861 gdk_draw_line (window, gc1,
2862 x + 1, y, x + width - 2, y);
2863 gdk_draw_line (window, gc1,
2864 x, y + 1, x, y + height - 1);
2865 gdk_draw_line (window, gc2,
2866 x + 1, y + 1, x + width - 2, y + 1);
2867 gdk_draw_line (window, gc2,
2868 x + 1, y + 1, x + 1, y + height - 1);
2870 gdk_draw_line (window, gc3,
2871 x + width - 2, y + 2, x + width - 2, y + height - 1);
2872 gdk_draw_line (window, gc4,
2873 x + width - 1, y + 1, x + width - 1, y + height - 1);
2876 gtk_style_apply_default_background (style, window,
2877 widget && !GTK_WIDGET_NO_WINDOW (widget),
2880 y + style->klass->ythickness,
2881 width - (style->klass->xthickness),
2882 height - (2 * style->klass->ythickness));
2883 gdk_draw_line (window, gc1,
2884 x, y, x + width - 2, y);
2885 gdk_draw_line (window, gc2,
2886 x + 1, y + 1, x + width - 2, y + 1);
2888 gdk_draw_line (window, gc3,
2889 x, y + height - 2, x + width - 2, y + height - 2);
2890 gdk_draw_line (window, gc3,
2891 x + width - 2, y + 2, x + width - 2, y + height - 2);
2892 gdk_draw_line (window, gc4,
2893 x, y + height - 1, x + width - 2, y + height - 1);
2894 gdk_draw_line (window, gc4,
2895 x + width - 1, y + 1, x + width - 1, y + height - 2);
2898 gtk_style_apply_default_background (style, window,
2899 widget && !GTK_WIDGET_NO_WINDOW (widget),
2901 x + style->klass->xthickness,
2902 y + style->klass->ythickness,
2903 width - (style->klass->xthickness),
2904 height - (2 * style->klass->ythickness));
2905 gdk_draw_line (window, gc1,
2906 x + 1, y, x + width - 1, y);
2907 gdk_draw_line (window, gc1,
2908 x, y + 1, x, y + height - 2);
2909 gdk_draw_line (window, gc2,
2910 x + 1, y + 1, x + width - 1, y + 1);
2911 gdk_draw_line (window, gc2,
2912 x + 1, y + 1, x + 1, y + height - 2);
2914 gdk_draw_line (window, gc3,
2915 x + 2, y + height - 2, x + width - 1, y + height - 2);
2916 gdk_draw_line (window, gc4,
2917 x + 1, y + height - 1, x + width - 1, y + height - 1);
2923 gdk_gc_set_clip_rectangle (gc1, NULL);
2924 gdk_gc_set_clip_rectangle (gc2, NULL);
2925 gdk_gc_set_clip_rectangle (gc3, NULL);
2926 gdk_gc_set_clip_rectangle (gc4, NULL);
2931 gtk_default_draw_focus (GtkStyle *style,
2941 g_return_if_fail (style != NULL);
2942 g_return_if_fail (window != NULL);
2944 if ((width == -1) && (height == -1))
2946 gdk_window_get_size (window, &width, &height);
2950 else if (width == -1)
2952 gdk_window_get_size (window, &width, NULL);
2955 else if (height == -1)
2957 gdk_window_get_size (window, NULL, &height);
2962 gdk_gc_set_clip_rectangle (style->black_gc, area);
2964 if (detail && !strcmp (detail, "add-mode"))
2966 gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_ON_OFF_DASH, 0, 0);
2967 gdk_gc_set_dashes (style->black_gc, 0, "\4\4", 2);
2969 gdk_draw_rectangle (window,
2970 style->black_gc, FALSE,
2971 x, y, width, height);
2973 gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_SOLID, 0, 0);
2977 gdk_draw_rectangle (window,
2978 style->black_gc, FALSE,
2979 x, y, width, height);
2983 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2988 gtk_default_draw_slider (GtkStyle *style,
2990 GtkStateType state_type,
2991 GtkShadowType shadow_type,
2999 GtkOrientation orientation)
3001 g_return_if_fail (style != NULL);
3002 g_return_if_fail (window != NULL);
3004 if ((width == -1) && (height == -1))
3005 gdk_window_get_size (window, &width, &height);
3006 else if (width == -1)
3007 gdk_window_get_size (window, &width, NULL);
3008 else if (height == -1)
3009 gdk_window_get_size (window, NULL, &height);
3011 gtk_paint_box (style, window, state_type, shadow_type,
3012 area, widget, detail, x, y, width, height);
3013 if (orientation == GTK_ORIENTATION_HORIZONTAL)
3014 gtk_paint_vline (style, window, state_type, area, widget, detail,
3015 style->klass->ythickness,
3016 height - style->klass->ythickness - 1, width / 2);
3018 gtk_paint_hline (style, window, state_type, area, widget, detail,
3019 style->klass->xthickness,
3020 width - style->klass->xthickness - 1, height / 2);
3024 gtk_default_draw_handle (GtkStyle *style,
3026 GtkStateType state_type,
3027 GtkShadowType shadow_type,
3035 GtkOrientation orientation)
3038 gint xthick, ythick;
3039 GdkGC *light_gc, *dark_gc;
3042 g_return_if_fail (style != NULL);
3043 g_return_if_fail (window != NULL);
3045 if ((width == -1) && (height == -1))
3046 gdk_window_get_size (window, &width, &height);
3047 else if (width == -1)
3048 gdk_window_get_size (window, &width, NULL);
3049 else if (height == -1)
3050 gdk_window_get_size (window, NULL, &height);
3052 gtk_paint_box (style, window, state_type, shadow_type, area, widget,
3053 detail, x, y, width, height);
3055 light_gc = style->light_gc[state_type];
3056 dark_gc = style->dark_gc[state_type];
3058 xthick = style->klass->xthickness;
3059 ythick = style->klass->ythickness;
3061 dest.x = x + xthick;
3062 dest.y = y + ythick;
3063 dest.width = width - (xthick * 2);
3064 dest.height = height - (ythick * 2);
3066 gdk_gc_set_clip_rectangle (light_gc, &dest);
3067 gdk_gc_set_clip_rectangle (dark_gc, &dest);
3069 for (yy = y + ythick; yy < (y + height - ythick); yy += 3)
3070 for (xx = x + xthick; xx < (x + width - xthick); xx += 6)
3072 gdk_draw_point (window, light_gc, xx, yy);
3073 gdk_draw_point (window, dark_gc, xx + 1, yy + 1);
3075 gdk_draw_point (window, light_gc, xx + 3, yy + 1);
3076 gdk_draw_point (window, dark_gc, xx + 4, yy + 2);
3078 gdk_gc_set_clip_rectangle (light_gc, NULL);
3079 gdk_gc_set_clip_rectangle (dark_gc, NULL);
3083 gtk_style_shade (GdkColor *a,
3091 red = (gdouble) a->red / 65535.0;
3092 green = (gdouble) a->green / 65535.0;
3093 blue = (gdouble) a->blue / 65535.0;
3095 rgb_to_hls (&red, &green, &blue);
3100 else if (green < 0.0)
3106 else if (blue < 0.0)
3109 hls_to_rgb (&red, &green, &blue);
3111 b->red = red * 65535.0;
3112 b->green = green * 65535.0;
3113 b->blue = blue * 65535.0;
3117 rgb_to_hls (gdouble *r,
3158 l = (max + min) / 2;
3165 s = (max - min) / (max + min);
3167 s = (max - min) / (2 - max - min);
3171 h = (green - blue) / delta;
3172 else if (green == max)
3173 h = 2 + (blue - red) / delta;
3174 else if (blue == max)
3175 h = 4 + (red - green) / delta;
3188 hls_to_rgb (gdouble *h,
3201 if (lightness <= 0.5)
3202 m2 = lightness * (1 + saturation);
3204 m2 = lightness + saturation - lightness * saturation;
3205 m1 = 2 * lightness - m2;
3207 if (saturation == 0)
3222 r = m1 + (m2 - m1) * hue / 60;
3226 r = m1 + (m2 - m1) * (240 - hue) / 60;
3237 g = m1 + (m2 - m1) * hue / 60;
3241 g = m1 + (m2 - m1) * (240 - hue) / 60;
3252 b = m1 + (m2 - m1) * hue / 60;
3256 b = m1 + (m2 - m1) * (240 - hue) / 60;
3267 gtk_paint_hline (GtkStyle *style,
3269 GtkStateType state_type,
3277 g_return_if_fail (style != NULL);
3278 g_return_if_fail (style->klass != NULL);
3279 g_return_if_fail (style->klass->draw_hline != NULL);
3281 (*style->klass->draw_hline) (style, window, state_type, area, widget, detail, x1, x2, y);
3285 gtk_paint_vline (GtkStyle *style,
3287 GtkStateType state_type,
3295 g_return_if_fail (style != NULL);
3296 g_return_if_fail (style->klass != NULL);
3297 g_return_if_fail (style->klass->draw_vline != NULL);
3299 (*style->klass->draw_vline) (style, window, state_type, area, widget, detail, y1, y2, x);
3303 gtk_paint_shadow (GtkStyle *style,
3305 GtkStateType state_type,
3306 GtkShadowType shadow_type,
3315 g_return_if_fail (style != NULL);
3316 g_return_if_fail (style->klass != NULL);
3317 g_return_if_fail (style->klass->draw_shadow != NULL);
3319 (*style->klass->draw_shadow) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3323 gtk_paint_polygon (GtkStyle *style,
3325 GtkStateType state_type,
3326 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_shadow != NULL);
3338 (*style->klass->draw_polygon) (style, window, state_type, shadow_type, area, widget, detail, points, npoints, fill);
3342 gtk_paint_arrow (GtkStyle *style,
3344 GtkStateType state_type,
3345 GtkShadowType shadow_type,
3349 GtkArrowType arrow_type,
3356 g_return_if_fail (style != NULL);
3357 g_return_if_fail (style->klass != NULL);
3358 g_return_if_fail (style->klass->draw_arrow != NULL);
3360 (*style->klass->draw_arrow) (style, window, state_type, shadow_type, area, widget, detail, arrow_type, fill, x, y, width, height);
3364 gtk_paint_diamond (GtkStyle *style,
3366 GtkStateType state_type,
3367 GtkShadowType shadow_type,
3376 g_return_if_fail (style != NULL);
3377 g_return_if_fail (style->klass != NULL);
3378 g_return_if_fail (style->klass->draw_diamond != NULL);
3380 (*style->klass->draw_diamond) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3384 gtk_paint_oval (GtkStyle *style,
3386 GtkStateType state_type,
3387 GtkShadowType shadow_type,
3396 g_return_if_fail (style != NULL);
3397 g_return_if_fail (style->klass != NULL);
3398 g_return_if_fail (style->klass->draw_oval != NULL);
3400 (*style->klass->draw_oval) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3404 gtk_paint_string (GtkStyle *style,
3406 GtkStateType state_type,
3412 const gchar *string)
3414 g_return_if_fail (style != NULL);
3415 g_return_if_fail (style->klass != NULL);
3416 g_return_if_fail (style->klass->draw_oval != NULL);
3418 (*style->klass->draw_string) (style, window, state_type, area, widget, detail, x, y, string);
3422 gtk_paint_box (GtkStyle *style,
3424 GtkStateType state_type,
3425 GtkShadowType shadow_type,
3434 g_return_if_fail (style != NULL);
3435 g_return_if_fail (style->klass != NULL);
3436 g_return_if_fail (style->klass->draw_box != NULL);
3438 (*style->klass->draw_box) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3442 gtk_paint_flat_box (GtkStyle *style,
3444 GtkStateType state_type,
3445 GtkShadowType shadow_type,
3454 g_return_if_fail (style != NULL);
3455 g_return_if_fail (style->klass != NULL);
3456 g_return_if_fail (style->klass->draw_flat_box != NULL);
3458 (*style->klass->draw_flat_box) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3462 gtk_paint_check (GtkStyle *style,
3464 GtkStateType state_type,
3465 GtkShadowType shadow_type,
3474 g_return_if_fail (style != NULL);
3475 g_return_if_fail (style->klass != NULL);
3476 g_return_if_fail (style->klass->draw_check != NULL);
3478 (*style->klass->draw_check) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3482 gtk_paint_option (GtkStyle *style,
3484 GtkStateType state_type,
3485 GtkShadowType shadow_type,
3494 g_return_if_fail (style != NULL);
3495 g_return_if_fail (style->klass != NULL);
3496 g_return_if_fail (style->klass->draw_option != NULL);
3498 (*style->klass->draw_option) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3502 gtk_paint_cross (GtkStyle *style,
3504 GtkStateType state_type,
3505 GtkShadowType shadow_type,
3514 g_return_if_fail (style != NULL);
3515 g_return_if_fail (style->klass != NULL);
3516 g_return_if_fail (style->klass->draw_cross != NULL);
3518 (*style->klass->draw_cross) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3522 gtk_paint_ramp (GtkStyle *style,
3524 GtkStateType state_type,
3525 GtkShadowType shadow_type,
3529 GtkArrowType arrow_type,
3535 g_return_if_fail (style != NULL);
3536 g_return_if_fail (style->klass != NULL);
3537 g_return_if_fail (style->klass->draw_ramp != NULL);
3539 (*style->klass->draw_ramp) (style, window, state_type, shadow_type, area, widget, detail, arrow_type, x, y, width, height);
3543 gtk_paint_tab (GtkStyle *style,
3545 GtkStateType state_type,
3546 GtkShadowType shadow_type,
3555 g_return_if_fail (style != NULL);
3556 g_return_if_fail (style->klass != NULL);
3557 g_return_if_fail (style->klass->draw_tab != NULL);
3559 (*style->klass->draw_tab) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3563 gtk_paint_shadow_gap (GtkStyle *style,
3565 GtkStateType state_type,
3566 GtkShadowType shadow_type,
3574 GtkPositionType gap_side,
3578 g_return_if_fail (style != NULL);
3579 g_return_if_fail (style->klass != NULL);
3580 g_return_if_fail (style->klass->draw_shadow_gap != NULL);
3582 (*style->klass->draw_shadow_gap) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
3587 gtk_paint_box_gap (GtkStyle *style,
3589 GtkStateType state_type,
3590 GtkShadowType shadow_type,
3598 GtkPositionType gap_side,
3602 g_return_if_fail (style != NULL);
3603 g_return_if_fail (style->klass != NULL);
3604 g_return_if_fail (style->klass->draw_box_gap != NULL);
3606 (*style->klass->draw_box_gap) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
3610 gtk_paint_extension (GtkStyle *style,
3612 GtkStateType state_type,
3613 GtkShadowType shadow_type,
3621 GtkPositionType gap_side)
3623 g_return_if_fail (style != NULL);
3624 g_return_if_fail (style->klass != NULL);
3625 g_return_if_fail (style->klass->draw_extension != NULL);
3627 (*style->klass->draw_extension) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side);
3631 gtk_paint_focus (GtkStyle *style,
3641 g_return_if_fail (style != NULL);
3642 g_return_if_fail (style->klass != NULL);
3643 g_return_if_fail (style->klass->draw_focus != NULL);
3645 (*style->klass->draw_focus) (style, window, area, widget, detail, x, y, width, height);
3649 gtk_paint_slider (GtkStyle *style,
3651 GtkStateType state_type,
3652 GtkShadowType shadow_type,
3660 GtkOrientation orientation)
3662 g_return_if_fail (style != NULL);
3663 g_return_if_fail (style->klass != NULL);
3664 g_return_if_fail (style->klass->draw_slider != NULL);
3666 (*style->klass->draw_slider) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
3670 gtk_paint_handle (GtkStyle *style,
3672 GtkStateType state_type,
3673 GtkShadowType shadow_type,
3681 GtkOrientation orientation)
3683 g_return_if_fail (style != NULL);
3684 g_return_if_fail (style->klass != NULL);
3685 g_return_if_fail (style->klass->draw_handle != NULL);
3687 (*style->klass->draw_handle) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);