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;
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);
1126 else if (!copy_area || style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
1130 if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
1131 gdk_window_set_back_pixmap (window, NULL, TRUE);
1133 gdk_window_set_back_pixmap (window, style->bg_pixmap[state_type], FALSE);
1138 old_rect.width = width;
1139 old_rect.height = height;
1141 if (area && gdk_rectangle_intersect (area, &old_rect, &new_rect))
1142 gdk_window_clear_area (window, new_rect.x, new_rect.y, new_rect.width, new_rect.height);
1144 gdk_window_clear_area (window, x, y, width, height);
1150 old_rect.width = width;
1151 old_rect.height = height;
1153 if (area && gdk_rectangle_intersect (area, &old_rect, &new_rect))
1154 gdk_window_copy_area (window, style->bg_gc[state_type], new_rect.x, new_rect.y,
1155 style->bg_pixmap[state_type], 0, 0, new_rect.width, new_rect.height);
1158 gdk_window_clear_area (window, x, y, width, height);
1159 gdk_window_copy_area (window, style->bg_gc[state_type], x, y,
1160 style->bg_pixmap[state_type], 0, 0, width, height);
1166 gtk_style_apply_default_pixmap (GtkStyle *style,
1168 GtkStateType state_type,
1175 gtk_style_apply_default_background (style, window, FALSE, state_type,
1176 area, x, y, width, height);
1180 gtk_default_draw_hline (GtkStyle *style,
1182 GtkStateType state_type,
1190 gint thickness_light;
1191 gint thickness_dark;
1194 g_return_if_fail (style != NULL);
1195 g_return_if_fail (window != NULL);
1197 thickness_light = style->klass->ythickness / 2;
1198 thickness_dark = style->klass->ythickness - thickness_light;
1202 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1203 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1206 if (detail && !strcmp (detail, "label"))
1208 if (state_type == GTK_STATE_INSENSITIVE)
1209 gdk_draw_line (window, style->white_gc, x1 + 1, y + 1, x2 + 1, y + 1);
1210 gdk_draw_line (window, style->fg_gc[state_type], x1, y, x2, y);
1214 for (i = 0; i < thickness_dark; i++)
1216 gdk_draw_line (window, style->light_gc[state_type], x2 - i - 1, y + i, x2, y + i);
1217 gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x2 - i - 1, y + i);
1220 y += thickness_dark;
1221 for (i = 0; i < thickness_light; i++)
1223 gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x1 + thickness_light - i - 1, y + i);
1224 gdk_draw_line (window, style->light_gc[state_type], x1 + thickness_light - i - 1, y + i, x2, y + i);
1230 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
1231 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
1237 gtk_default_draw_vline (GtkStyle *style,
1239 GtkStateType state_type,
1247 gint thickness_light;
1248 gint thickness_dark;
1251 g_return_if_fail (style != NULL);
1252 g_return_if_fail (window != NULL);
1254 thickness_light = style->klass->xthickness / 2;
1255 thickness_dark = style->klass->xthickness - thickness_light;
1259 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1260 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1262 for (i = 0; i < thickness_dark; i++)
1264 gdk_draw_line (window, style->light_gc[state_type], x + i, y2 - i - 1, x + i, y2);
1265 gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y2 - i - 1);
1268 x += thickness_dark;
1269 for (i = 0; i < thickness_light; i++)
1271 gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y1 + thickness_light - i);
1272 gdk_draw_line (window, style->light_gc[state_type], x + i, y1 + thickness_light - i, x + i, y2);
1276 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
1277 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
1283 gtk_default_draw_shadow (GtkStyle *style,
1285 GtkStateType state_type,
1286 GtkShadowType shadow_type,
1297 gint thickness_light;
1298 gint thickness_dark;
1301 g_return_if_fail (style != NULL);
1302 g_return_if_fail (window != NULL);
1304 if ((width == -1) && (height == -1))
1305 gdk_window_get_size (window, &width, &height);
1306 else if (width == -1)
1307 gdk_window_get_size (window, &width, NULL);
1308 else if (height == -1)
1309 gdk_window_get_size (window, NULL, &height);
1311 switch (shadow_type)
1313 case GTK_SHADOW_NONE:
1316 case GTK_SHADOW_ETCHED_IN:
1317 gc1 = style->light_gc[state_type];
1318 gc2 = style->dark_gc[state_type];
1320 case GTK_SHADOW_OUT:
1321 case GTK_SHADOW_ETCHED_OUT:
1322 gc1 = style->dark_gc[state_type];
1323 gc2 = style->light_gc[state_type];
1329 gdk_gc_set_clip_rectangle (gc1, area);
1330 gdk_gc_set_clip_rectangle (gc2, area);
1331 if (shadow_type == GTK_SHADOW_IN ||
1332 shadow_type == GTK_SHADOW_OUT)
1334 gdk_gc_set_clip_rectangle (style->black_gc, area);
1335 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
1339 switch (shadow_type)
1341 case GTK_SHADOW_NONE:
1345 gdk_draw_line (window, gc1,
1346 x, y + height - 1, x + width - 1, y + height - 1);
1347 gdk_draw_line (window, gc1,
1348 x + width - 1, y, x + width - 1, y + height - 1);
1350 gdk_draw_line (window, style->bg_gc[state_type],
1351 x + 1, y + height - 2, x + width - 2, y + height - 2);
1352 gdk_draw_line (window, style->bg_gc[state_type],
1353 x + width - 2, y + 1, x + width - 2, y + height - 2);
1355 gdk_draw_line (window, style->black_gc,
1356 x + 1, y + 1, x + width - 2, y + 1);
1357 gdk_draw_line (window, style->black_gc,
1358 x + 1, y + 1, x + 1, y + height - 2);
1360 gdk_draw_line (window, gc2,
1361 x, y, x + width - 1, y);
1362 gdk_draw_line (window, gc2,
1363 x, y, x, y + height - 1);
1366 case GTK_SHADOW_OUT:
1367 gdk_draw_line (window, gc1,
1368 x + 1, y + height - 2, x + width - 2, y + height - 2);
1369 gdk_draw_line (window, gc1,
1370 x + width - 2, y + 1, x + width - 2, y + height - 2);
1372 gdk_draw_line (window, gc2,
1373 x, y, x + width - 1, y);
1374 gdk_draw_line (window, gc2,
1375 x, y, x, y + height - 1);
1377 gdk_draw_line (window, style->bg_gc[state_type],
1378 x + 1, y + 1, x + width - 2, y + 1);
1379 gdk_draw_line (window, style->bg_gc[state_type],
1380 x + 1, y + 1, x + 1, y + height - 2);
1382 gdk_draw_line (window, style->black_gc,
1383 x, y + height - 1, x + width - 1, y + height - 1);
1384 gdk_draw_line (window, style->black_gc,
1385 x + width - 1, y, x + width - 1, y + height - 1);
1388 case GTK_SHADOW_ETCHED_IN:
1389 case GTK_SHADOW_ETCHED_OUT:
1390 thickness_light = 1;
1393 for (i = 0; i < thickness_dark; i++)
1395 gdk_draw_line (window, gc1,
1399 y + height - i - 1);
1400 gdk_draw_line (window, gc1,
1404 y + height - i - 1);
1406 gdk_draw_line (window, gc2,
1411 gdk_draw_line (window, gc2,
1415 y + height - i - 2);
1418 for (i = 0; i < thickness_light; i++)
1420 gdk_draw_line (window, gc1,
1421 x + thickness_dark + i,
1422 y + thickness_dark + i,
1423 x + width - thickness_dark - i - 1,
1424 y + thickness_dark + i);
1425 gdk_draw_line (window, gc1,
1426 x + thickness_dark + i,
1427 y + thickness_dark + i,
1428 x + thickness_dark + i,
1429 y + height - thickness_dark - i - 1);
1431 gdk_draw_line (window, gc2,
1432 x + thickness_dark + i,
1433 y + height - thickness_light - i - 1,
1434 x + width - thickness_light - 1,
1435 y + height - thickness_light - i - 1);
1436 gdk_draw_line (window, gc2,
1437 x + width - thickness_light - i - 1,
1438 y + thickness_dark + i,
1439 x + width - thickness_light - i - 1,
1440 y + height - thickness_light - 1);
1446 gdk_gc_set_clip_rectangle (gc1, NULL);
1447 gdk_gc_set_clip_rectangle (gc2, NULL);
1448 if (shadow_type == GTK_SHADOW_IN ||
1449 shadow_type == GTK_SHADOW_OUT)
1451 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
1452 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
1459 gtk_default_draw_polygon (GtkStyle *style,
1461 GtkStateType state_type,
1462 GtkShadowType shadow_type,
1471 #define M_PI 3.14159265358979323846
1474 #define M_PI_4 0.78539816339744830962
1477 static const gdouble pi_over_4 = M_PI_4;
1478 static const gdouble pi_3_over_4 = M_PI_4 * 3;
1489 g_return_if_fail (style != NULL);
1490 g_return_if_fail (window != NULL);
1491 g_return_if_fail (points != NULL);
1493 switch (shadow_type)
1496 gc1 = style->bg_gc[state_type];
1497 gc2 = style->dark_gc[state_type];
1498 gc3 = style->light_gc[state_type];
1499 gc4 = style->black_gc;
1501 case GTK_SHADOW_ETCHED_IN:
1502 gc1 = style->light_gc[state_type];
1503 gc2 = style->dark_gc[state_type];
1504 gc3 = style->dark_gc[state_type];
1505 gc4 = style->light_gc[state_type];
1507 case GTK_SHADOW_OUT:
1508 gc1 = style->dark_gc[state_type];
1509 gc2 = style->light_gc[state_type];
1510 gc3 = style->black_gc;
1511 gc4 = style->bg_gc[state_type];
1513 case GTK_SHADOW_ETCHED_OUT:
1514 gc1 = style->dark_gc[state_type];
1515 gc2 = style->light_gc[state_type];
1516 gc3 = style->light_gc[state_type];
1517 gc4 = style->dark_gc[state_type];
1525 gdk_gc_set_clip_rectangle (gc1, area);
1526 gdk_gc_set_clip_rectangle (gc2, area);
1527 gdk_gc_set_clip_rectangle (gc3, area);
1528 gdk_gc_set_clip_rectangle (gc4, area);
1532 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, npoints);
1536 for (i = 0; i < npoints; i++)
1538 if ((points[i].x == points[i+1].x) &&
1539 (points[i].y == points[i+1].y))
1545 angle = atan2 (points[i+1].y - points[i].y,
1546 points[i+1].x - points[i].x);
1549 if ((angle > -pi_3_over_4) && (angle < pi_over_4))
1551 if (angle > -pi_over_4)
1562 gdk_draw_line (window, gc1,
1563 points[i].x-xadjust, points[i].y-yadjust,
1564 points[i+1].x-xadjust, points[i+1].y-yadjust);
1565 gdk_draw_line (window, gc3,
1566 points[i].x, points[i].y,
1567 points[i+1].x, points[i+1].y);
1571 if ((angle < -pi_3_over_4) || (angle > pi_3_over_4))
1582 gdk_draw_line (window, gc4,
1583 points[i].x+xadjust, points[i].y+yadjust,
1584 points[i+1].x+xadjust, points[i+1].y+yadjust);
1585 gdk_draw_line (window, gc2,
1586 points[i].x, points[i].y,
1587 points[i+1].x, points[i+1].y);
1592 gdk_gc_set_clip_rectangle (gc1, NULL);
1593 gdk_gc_set_clip_rectangle (gc2, NULL);
1594 gdk_gc_set_clip_rectangle (gc3, NULL);
1595 gdk_gc_set_clip_rectangle (gc4, NULL);
1600 gtk_default_draw_arrow (GtkStyle *style,
1602 GtkStateType state_type,
1603 GtkShadowType shadow_type,
1607 GtkArrowType arrow_type,
1622 g_return_if_fail (style != NULL);
1623 g_return_if_fail (window != NULL);
1625 switch (shadow_type)
1628 gc1 = style->bg_gc[state_type];
1629 gc2 = style->dark_gc[state_type];
1630 gc3 = style->light_gc[state_type];
1631 gc4 = style->black_gc;
1633 case GTK_SHADOW_OUT:
1634 gc1 = style->dark_gc[state_type];
1635 gc2 = style->light_gc[state_type];
1636 gc3 = style->black_gc;
1637 gc4 = style->bg_gc[state_type];
1639 case GTK_SHADOW_ETCHED_IN:
1640 gc1 = style->light_gc[state_type];
1641 gc2 = style->dark_gc[state_type];
1645 case GTK_SHADOW_ETCHED_OUT:
1646 gc1 = style->dark_gc[state_type];
1647 gc2 = style->light_gc[state_type];
1655 if ((width == -1) && (height == -1))
1656 gdk_window_get_size (window, &width, &height);
1657 else if (width == -1)
1658 gdk_window_get_size (window, &width, NULL);
1659 else if (height == -1)
1660 gdk_window_get_size (window, NULL, &height);
1662 half_width = width / 2;
1663 half_height = height / 2;
1667 gdk_gc_set_clip_rectangle (gc1, area);
1668 gdk_gc_set_clip_rectangle (gc2, area);
1671 gdk_gc_set_clip_rectangle (gc3, area);
1672 gdk_gc_set_clip_rectangle (gc4, area);
1681 points[0].x = x + half_width;
1684 points[1].y = y + height - 1;
1685 points[2].x = x + width - 1;
1686 points[2].y = y + height - 1;
1688 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1691 switch (shadow_type)
1694 case GTK_SHADOW_OUT:
1696 gdk_draw_line (window, gc1,
1697 x + 1, y + height - 2,
1698 x + width - 2, y + height - 2);
1699 gdk_draw_line (window, gc3,
1700 x + 0, y + height - 1,
1701 x + width - 1, y + height - 1);
1703 gdk_draw_line (window, gc1,
1704 x + width - 2, y + height - 1,
1705 x + half_width, y + 1);
1706 gdk_draw_line (window, gc3,
1707 x + width - 1, y + height - 1,
1710 gdk_draw_line (window, gc4,
1711 x + half_width, y + 1,
1712 x + 1, y + height - 1);
1713 gdk_draw_line (window, gc2,
1718 case GTK_SHADOW_ETCHED_IN:
1719 case GTK_SHADOW_ETCHED_OUT:
1720 gdk_draw_line (window, gc1,
1721 x + half_width, y + 1,
1722 x + 1, y + height - 1);
1723 gdk_draw_line (window, gc1,
1724 x + 1, y + height - 1,
1725 x + width - 1, y + height - 1);
1726 gdk_draw_line (window, gc1,
1727 x + width - 1, y + height - 1,
1728 x + half_width + 1, y + 1);
1730 points[0].x = x + half_width;
1733 points[1].y = y + height - 2;
1734 points[2].x = x + width - 2;
1735 points[2].y = y + height - 2;
1737 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1745 case GTK_ARROW_DOWN:
1748 points[0].x = x + width - 1;
1752 points[2].x = x + half_width;
1753 points[2].y = y + height - 1;
1755 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1757 switch (shadow_type)
1760 case GTK_SHADOW_OUT:
1761 gdk_draw_line (window, gc4,
1763 y + 1, x + 1, y + 1);
1764 gdk_draw_line (window, gc2,
1768 gdk_draw_line (window, gc4,
1770 x + half_width, y + height - 2);
1771 gdk_draw_line (window, gc2,
1773 x + half_width, y + height - 1);
1775 gdk_draw_line (window, gc1,
1776 x + half_width, y + height - 2,
1778 gdk_draw_line (window, gc3,
1779 x + half_width, y + height - 1,
1783 case GTK_SHADOW_ETCHED_IN:
1784 case GTK_SHADOW_ETCHED_OUT:
1785 gdk_draw_line (window, gc1,
1786 x + width - 1, y + 1,
1788 gdk_draw_line (window, gc1,
1790 x + half_width + 1, y + height - 1);
1791 gdk_draw_line (window, gc1,
1792 x + half_width + 1, y + height - 2,
1795 points[0].x = x + width - 2;
1799 points[2].x = x + half_width;
1800 points[2].y = y + height - 2;
1802 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1809 case GTK_ARROW_LEFT:
1813 points[0].y = y + half_height;
1814 points[1].x = x + width - 1;
1815 points[1].y = y + height - 1;
1816 points[2].x = x + width - 1;
1819 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1822 switch (shadow_type)
1825 case GTK_SHADOW_OUT:
1826 gdk_draw_line (window, gc1,
1827 x + 1, y + half_height,
1828 x + width - 1, y + height - 1);
1829 gdk_draw_line (window, gc3,
1831 x + width - 1, y + height - 1);
1833 gdk_draw_line (window, gc1,
1834 x + width - 2, y + height - 1,
1835 x + width - 2, y + 1);
1836 gdk_draw_line (window, gc3,
1837 x + width - 1, y + height - 1,
1840 gdk_draw_line (window, gc4,
1841 x + width - 1, y + 1,
1842 x + 1, y + half_height);
1843 gdk_draw_line (window, gc2,
1845 x, y + half_height);
1848 case GTK_SHADOW_ETCHED_IN:
1849 case GTK_SHADOW_ETCHED_OUT:
1850 gdk_draw_line (window, gc1,
1851 x + width - 1, y + 1,
1852 x + 1, y + half_height);
1853 gdk_draw_line (window, gc1,
1854 x + 1, y + half_height + 1,
1855 x + width - 1, y + height - 1);
1856 gdk_draw_line (window, gc1,
1857 x + width - 1, y + height - 1,
1858 x + width - 1, y + 1);
1860 points[0].x = x + width - 2;
1863 points[1].y = y + half_height;
1864 points[2].x = x + width - 2;
1865 points[2].y = y + height - 2;
1867 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1874 case GTK_ARROW_RIGHT:
1877 points[0].x = x + width - 1;
1878 points[0].y = y + half_height;
1882 points[2].y = y + height - 1;
1884 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1887 switch (shadow_type)
1890 case GTK_SHADOW_OUT:
1891 gdk_draw_line (window, gc4,
1892 x + width - 1, y + half_height,
1894 gdk_draw_line (window, gc2,
1895 x + width - 1, y + half_height,
1897 gdk_draw_line (window, gc4,
1899 x + 1, y + height - 2);
1900 gdk_draw_line (window, gc2,
1904 gdk_draw_line (window, gc1,
1905 x + 1, y + height - 2,
1906 x + width - 1, y + half_height);
1907 gdk_draw_line (window, gc3,
1909 x + width - 1, y + half_height);
1912 case GTK_SHADOW_ETCHED_IN:
1913 case GTK_SHADOW_ETCHED_OUT:
1914 gdk_draw_line (window, gc1,
1915 x + width - 1, y + half_height + 1,
1917 gdk_draw_line (window, gc1,
1919 x + 1, y + height - 1);
1920 gdk_draw_line (window, gc1,
1921 x + 1, y + height - 1,
1922 x + width - 1, y + half_height + 1);
1924 points[0].x = x + width - 2;
1925 points[0].y = y + half_height;
1929 points[2].y = y + height - 1;
1931 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1941 gdk_gc_set_clip_rectangle (gc1, NULL);
1942 gdk_gc_set_clip_rectangle (gc2, NULL);
1945 gdk_gc_set_clip_rectangle (gc3, NULL);
1946 gdk_gc_set_clip_rectangle (gc4, NULL);
1952 gtk_default_draw_diamond (GtkStyle *style,
1954 GtkStateType state_type,
1955 GtkShadowType shadow_type,
1967 g_return_if_fail (style != NULL);
1968 g_return_if_fail (window != NULL);
1970 if ((width == -1) && (height == -1))
1971 gdk_window_get_size (window, &width, &height);
1972 else if (width == -1)
1973 gdk_window_get_size (window, &width, NULL);
1974 else if (height == -1)
1975 gdk_window_get_size (window, NULL, &height);
1977 half_width = width / 2;
1978 half_height = height / 2;
1982 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1983 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
1984 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1985 gdk_gc_set_clip_rectangle (style->black_gc, area);
1987 switch (shadow_type)
1990 gdk_draw_line (window, style->bg_gc[state_type],
1991 x + 2, y + half_height,
1992 x + half_width, y + height - 2);
1993 gdk_draw_line (window, style->bg_gc[state_type],
1994 x + half_width, y + height - 2,
1995 x + width - 2, y + half_height);
1996 gdk_draw_line (window, style->light_gc[state_type],
1997 x + 1, y + half_height,
1998 x + half_width, y + height - 1);
1999 gdk_draw_line (window, style->light_gc[state_type],
2000 x + half_width, y + height - 1,
2001 x + width - 1, y + half_height);
2002 gdk_draw_line (window, style->light_gc[state_type],
2004 x + half_width, y + height);
2005 gdk_draw_line (window, style->light_gc[state_type],
2006 x + half_width, y + height,
2007 x + width, y + half_height);
2009 gdk_draw_line (window, style->black_gc,
2010 x + 2, y + half_height,
2011 x + half_width, y + 2);
2012 gdk_draw_line (window, style->black_gc,
2013 x + half_width, y + 2,
2014 x + width - 2, y + half_height);
2015 gdk_draw_line (window, style->dark_gc[state_type],
2016 x + 1, y + half_height,
2017 x + half_width, y + 1);
2018 gdk_draw_line (window, style->dark_gc[state_type],
2019 x + half_width, y + 1,
2020 x + width - 1, y + half_height);
2021 gdk_draw_line (window, style->dark_gc[state_type],
2024 gdk_draw_line (window, style->dark_gc[state_type],
2026 x + width, y + half_height);
2028 case GTK_SHADOW_OUT:
2029 gdk_draw_line (window, style->dark_gc[state_type],
2030 x + 2, y + half_height,
2031 x + half_width, y + height - 2);
2032 gdk_draw_line (window, style->dark_gc[state_type],
2033 x + half_width, y + height - 2,
2034 x + width - 2, y + half_height);
2035 gdk_draw_line (window, style->dark_gc[state_type],
2036 x + 1, y + half_height,
2037 x + half_width, y + height - 1);
2038 gdk_draw_line (window, style->dark_gc[state_type],
2039 x + half_width, y + height - 1,
2040 x + width - 1, y + half_height);
2041 gdk_draw_line (window, style->black_gc,
2043 x + half_width, y + height);
2044 gdk_draw_line (window, style->black_gc,
2045 x + half_width, y + height,
2046 x + width, y + half_height);
2048 gdk_draw_line (window, style->bg_gc[state_type],
2049 x + 2, y + half_height,
2050 x + half_width, y + 2);
2051 gdk_draw_line (window, style->bg_gc[state_type],
2052 x + half_width, y + 2,
2053 x + width - 2, y + half_height);
2054 gdk_draw_line (window, style->light_gc[state_type],
2055 x + 1, y + half_height,
2056 x + half_width, y + 1);
2057 gdk_draw_line (window, style->light_gc[state_type],
2058 x + half_width, y + 1,
2059 x + width - 1, y + half_height);
2060 gdk_draw_line (window, style->light_gc[state_type],
2063 gdk_draw_line (window, style->light_gc[state_type],
2065 x + width, y + half_height);
2072 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
2073 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2074 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
2075 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2081 gtk_default_draw_oval (GtkStyle *style,
2083 GtkStateType state_type,
2084 GtkShadowType shadow_type,
2093 g_return_if_fail (style != NULL);
2094 g_return_if_fail (window != NULL);
2098 gtk_default_draw_string (GtkStyle *style,
2100 GtkStateType state_type,
2106 const gchar *string)
2108 g_return_if_fail (style != NULL);
2109 g_return_if_fail (window != NULL);
2113 gdk_gc_set_clip_rectangle (style->white_gc, area);
2114 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], area);
2116 if (state_type == GTK_STATE_INSENSITIVE)
2117 gdk_draw_string (window, style->font, style->white_gc, x + 1, y + 1, string);
2118 gdk_draw_string (window, style->font, style->fg_gc[state_type], x, y, string);
2121 gdk_gc_set_clip_rectangle (style->white_gc, NULL);
2122 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], NULL);
2127 gtk_default_draw_box (GtkStyle *style,
2129 GtkStateType state_type,
2130 GtkShadowType shadow_type,
2139 g_return_if_fail (style != NULL);
2140 g_return_if_fail (window != NULL);
2142 if ((width == -1) && (height == -1))
2143 gdk_window_get_size (window, &width, &height);
2144 else if (width == -1)
2145 gdk_window_get_size (window, &width, NULL);
2146 else if (height == -1)
2147 gdk_window_get_size (window, NULL, &height);
2149 if (!style->bg_pixmap[state_type] ||
2150 gdk_window_get_type (window) == GDK_WINDOW_PIXMAP)
2154 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
2156 gdk_draw_rectangle (window, style->bg_gc[state_type], TRUE,
2157 x, y, width, height);
2160 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2164 gtk_style_apply_default_background (style, window,
2165 widget && GTK_WIDGET_NO_WINDOW (widget),
2166 state_type, area, x, y, width, height);
2168 gtk_paint_shadow (style, window, state_type, shadow_type, area, widget, detail,
2169 x, y, width, height);
2173 gtk_default_draw_flat_box (GtkStyle *style,
2175 GtkStateType state_type,
2176 GtkShadowType shadow_type,
2187 g_return_if_fail (style != NULL);
2188 g_return_if_fail (window != NULL);
2190 if ((width == -1) && (height == -1))
2191 gdk_window_get_size (window, &width, &height);
2192 else if (width == -1)
2193 gdk_window_get_size (window, &width, NULL);
2194 else if (height == -1)
2195 gdk_window_get_size (window, NULL, &height);
2197 if ((detail) && (!strcmp("text",detail)) && (state_type == GTK_STATE_SELECTED))
2198 gc1 = style->bg_gc[GTK_STATE_SELECTED];
2199 else if ((detail) && (!strcmp("viewportbin",detail)))
2200 gc1 = style->bg_gc[GTK_STATE_NORMAL];
2201 else if ((detail) && (!strcmp("entry_bg",detail)))
2202 gc1 = style->base_gc[state_type];
2204 gc1 = style->bg_gc[state_type];
2206 if (!style->bg_pixmap[state_type] || gc1 != style->bg_gc[state_type] ||
2207 gdk_window_get_type (window) == GDK_WINDOW_PIXMAP)
2211 gdk_gc_set_clip_rectangle (gc1, area);
2213 gdk_draw_rectangle (window, gc1, TRUE,
2214 x, y, width, height);
2215 if ((detail) && (!strcmp("tooltip",detail)))
2216 gdk_draw_rectangle (window, style->black_gc, FALSE,
2217 x, y, width - 1, height - 1);
2220 gdk_gc_set_clip_rectangle (gc1, NULL);
2224 gtk_style_apply_default_background (style, window,
2225 widget && GTK_WIDGET_NO_WINDOW (widget),
2226 state_type, area, x, y, width, height);
2230 gtk_default_draw_check (GtkStyle *style,
2232 GtkStateType state_type,
2233 GtkShadowType shadow_type,
2242 gtk_paint_box (style, window, state_type, shadow_type, area, widget, detail,
2243 x, y, width, height);
2247 gtk_default_draw_option (GtkStyle *style,
2249 GtkStateType state_type,
2250 GtkShadowType shadow_type,
2259 gtk_paint_diamond (style, window, state_type, shadow_type, area, widget,
2260 detail, x, y, width, height);
2264 gtk_default_draw_cross (GtkStyle *style,
2266 GtkStateType state_type,
2267 GtkShadowType shadow_type,
2276 g_return_if_fail (style != NULL);
2277 g_return_if_fail (window != NULL);
2281 gtk_default_draw_ramp (GtkStyle *style,
2283 GtkStateType state_type,
2284 GtkShadowType shadow_type,
2288 GtkArrowType arrow_type,
2294 g_return_if_fail (style != NULL);
2295 g_return_if_fail (window != NULL);
2298 static void gtk_default_draw_tab (GtkStyle *style,
2300 GtkStateType state_type,
2301 GtkShadowType shadow_type,
2310 g_return_if_fail (style != NULL);
2311 g_return_if_fail (window != NULL);
2313 gtk_paint_box (style, window, state_type, shadow_type, area, widget, detail,
2314 x, y, width, height);
2318 gtk_default_draw_shadow_gap (GtkStyle *style,
2320 GtkStateType state_type,
2321 GtkShadowType shadow_type,
2329 GtkPositionType gap_side,
2338 g_return_if_fail (style != NULL);
2339 g_return_if_fail (window != NULL);
2341 if ((width == -1) && (height == -1))
2342 gdk_window_get_size (window, &width, &height);
2343 else if (width == -1)
2344 gdk_window_get_size (window, &width, NULL);
2345 else if (height == -1)
2346 gdk_window_get_size (window, NULL, &height);
2348 switch (shadow_type)
2350 case GTK_SHADOW_NONE:
2353 gc1 = style->dark_gc[state_type];
2354 gc2 = style->black_gc;
2355 gc3 = style->bg_gc[state_type];
2356 gc4 = style->light_gc[state_type];
2358 case GTK_SHADOW_ETCHED_IN:
2359 gc1 = style->dark_gc[state_type];
2360 gc2 = style->light_gc[state_type];
2361 gc3 = style->dark_gc[state_type];
2362 gc4 = style->light_gc[state_type];
2364 case GTK_SHADOW_OUT:
2365 gc1 = style->light_gc[state_type];
2366 gc2 = style->bg_gc[state_type];
2367 gc3 = style->dark_gc[state_type];
2368 gc4 = style->black_gc;
2370 case GTK_SHADOW_ETCHED_OUT:
2371 gc1 = style->light_gc[state_type];
2372 gc2 = style->dark_gc[state_type];
2373 gc3 = style->light_gc[state_type];
2374 gc4 = style->dark_gc[state_type];
2379 gdk_gc_set_clip_rectangle (gc1, area);
2380 gdk_gc_set_clip_rectangle (gc2, area);
2381 gdk_gc_set_clip_rectangle (gc3, area);
2382 gdk_gc_set_clip_rectangle (gc4, area);
2385 switch (shadow_type)
2387 case GTK_SHADOW_NONE:
2389 case GTK_SHADOW_OUT:
2390 case GTK_SHADOW_ETCHED_IN:
2391 case GTK_SHADOW_ETCHED_OUT:
2395 gdk_draw_line (window, gc1,
2396 x, y, x, y + height - 1);
2397 gdk_draw_line (window, gc2,
2398 x + 1, y, x + 1, y + height - 2);
2400 gdk_draw_line (window, gc3,
2401 x + 1, y + height - 2, x + width - 2, y + height - 2);
2402 gdk_draw_line (window, gc3,
2403 x + width - 2, y, x + width - 2, y + height - 2);
2404 gdk_draw_line (window, gc4,
2405 x, y + height - 1, x + width - 1, y + height - 1);
2406 gdk_draw_line (window, gc4,
2407 x + width - 1, y, x + width - 1, y + height - 1);
2410 gdk_draw_line (window, gc1,
2411 x, y, x + gap_x - 1, y);
2412 gdk_draw_line (window, gc2,
2413 x + 1, y + 1, x + gap_x - 1, y + 1);
2414 gdk_draw_line (window, gc2,
2415 x + gap_x, y, x + gap_x, y);
2417 if ((width - (gap_x + gap_width)) > 0)
2419 gdk_draw_line (window, gc1,
2420 x + gap_x + gap_width, y, x + width - 2, y);
2421 gdk_draw_line (window, gc2,
2422 x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
2423 gdk_draw_line (window, gc2,
2424 x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
2427 case GTK_POS_BOTTOM:
2428 gdk_draw_line (window, gc1,
2429 x, y, x + width - 1, y);
2430 gdk_draw_line (window, gc1,
2431 x, y, x, y + height - 1);
2432 gdk_draw_line (window, gc2,
2433 x + 1, y + 1, x + width - 2, y + 1);
2434 gdk_draw_line (window, gc2,
2435 x + 1, y + 1, x + 1, y + height - 1);
2437 gdk_draw_line (window, gc3,
2438 x + width - 2, y + 1, x + width - 2, y + height - 1);
2439 gdk_draw_line (window, gc4,
2440 x + width - 1, y, x + width - 1, y + height - 1);
2443 gdk_draw_line (window, gc4,
2444 x, y + height - 1, x + gap_x - 1, y + height - 1);
2445 gdk_draw_line (window, gc3,
2446 x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
2447 gdk_draw_line (window, gc3,
2448 x + gap_x, y + height - 1, x + gap_x, y + height - 1);
2450 if ((width - (gap_x + gap_width)) > 0)
2452 gdk_draw_line (window, gc4,
2453 x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
2454 gdk_draw_line (window, gc3,
2455 x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
2456 gdk_draw_line (window, gc3,
2457 x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
2461 gdk_draw_line (window, gc1,
2462 x, y, x + width - 1, y);
2463 gdk_draw_line (window, gc2,
2464 x, y + 1, x + width - 2, y + 1);
2466 gdk_draw_line (window, gc3,
2467 x, y + height - 2, x + width - 2, y + height - 2);
2468 gdk_draw_line (window, gc3,
2469 x + width - 2, y + 1, x + width - 2, y + height - 2);
2470 gdk_draw_line (window, gc4,
2471 x, y + height - 1, x + width - 1, y + height - 1);
2472 gdk_draw_line (window, gc4,
2473 x + width - 1, y, x + width - 1, y + height - 1);
2476 gdk_draw_line (window, gc1,
2477 x, y, x, y + gap_x - 1);
2478 gdk_draw_line (window, gc2,
2479 x + 1, y + 1, x + 1, y + gap_x - 1);
2480 gdk_draw_line (window, gc2,
2481 x, y + gap_x, x, y + gap_x);
2483 if ((width - (gap_x + gap_width)) > 0)
2485 gdk_draw_line (window, gc1,
2486 x, y + gap_x + gap_width, x, y + height - 2);
2487 gdk_draw_line (window, gc2,
2488 x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
2489 gdk_draw_line (window, gc2,
2490 x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
2494 gdk_draw_line (window, gc1,
2495 x, y, x + width - 1, y);
2496 gdk_draw_line (window, gc1,
2497 x, y, x, y + height - 1);
2498 gdk_draw_line (window, gc2,
2499 x + 1, y + 1, x + width - 1, y + 1);
2500 gdk_draw_line (window, gc2,
2501 x + 1, y + 1, x + 1, y + height - 2);
2503 gdk_draw_line (window, gc3,
2504 x + 1, y + height - 2, x + width - 1, y + height - 2);
2505 gdk_draw_line (window, gc4,
2506 x, y + height - 1, x + width - 1, y + height - 1);
2509 gdk_draw_line (window, gc4,
2510 x + width - 1, y, x + width - 1, y + gap_x - 1);
2511 gdk_draw_line (window, gc3,
2512 x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
2513 gdk_draw_line (window, gc3,
2514 x + width - 1, y + gap_x, x + width - 1, y + gap_x);
2516 if ((width - (gap_x + gap_width)) > 0)
2518 gdk_draw_line (window, gc4,
2519 x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
2520 gdk_draw_line (window, gc3,
2521 x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
2522 gdk_draw_line (window, gc3,
2523 x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
2530 gdk_gc_set_clip_rectangle (gc1, NULL);
2531 gdk_gc_set_clip_rectangle (gc2, NULL);
2532 gdk_gc_set_clip_rectangle (gc3, NULL);
2533 gdk_gc_set_clip_rectangle (gc4, NULL);
2538 gtk_default_draw_box_gap (GtkStyle *style,
2540 GtkStateType state_type,
2541 GtkShadowType shadow_type,
2549 GtkPositionType gap_side,
2558 g_return_if_fail (style != NULL);
2559 g_return_if_fail (window != NULL);
2561 gtk_style_apply_default_background (style, window,
2562 widget && GTK_WIDGET_NO_WINDOW (widget),
2563 state_type, area, x, y, width, height);
2565 if ((width == -1) && (height == -1))
2566 gdk_window_get_size (window, &width, &height);
2567 else if (width == -1)
2568 gdk_window_get_size (window, &width, NULL);
2569 else if (height == -1)
2570 gdk_window_get_size (window, NULL, &height);
2572 switch (shadow_type)
2574 case GTK_SHADOW_NONE:
2577 gc1 = style->dark_gc[state_type];
2578 gc2 = style->black_gc;
2579 gc3 = style->bg_gc[state_type];
2580 gc4 = style->light_gc[state_type];
2582 case GTK_SHADOW_ETCHED_IN:
2583 gc1 = style->dark_gc[state_type];
2584 gc2 = style->light_gc[state_type];
2585 gc3 = style->dark_gc[state_type];
2586 gc4 = style->light_gc[state_type];
2588 case GTK_SHADOW_OUT:
2589 gc1 = style->light_gc[state_type];
2590 gc2 = style->bg_gc[state_type];
2591 gc3 = style->dark_gc[state_type];
2592 gc4 = style->black_gc;
2594 case GTK_SHADOW_ETCHED_OUT:
2595 gc1 = style->light_gc[state_type];
2596 gc2 = style->dark_gc[state_type];
2597 gc3 = style->light_gc[state_type];
2598 gc4 = style->dark_gc[state_type];
2603 gdk_gc_set_clip_rectangle (gc1, area);
2604 gdk_gc_set_clip_rectangle (gc2, area);
2605 gdk_gc_set_clip_rectangle (gc3, area);
2606 gdk_gc_set_clip_rectangle (gc4, area);
2609 switch (shadow_type)
2611 case GTK_SHADOW_NONE:
2613 case GTK_SHADOW_OUT:
2614 case GTK_SHADOW_ETCHED_IN:
2615 case GTK_SHADOW_ETCHED_OUT:
2619 gdk_draw_line (window, gc1,
2620 x, y, x, y + height - 1);
2621 gdk_draw_line (window, gc2,
2622 x + 1, y, x + 1, y + height - 2);
2624 gdk_draw_line (window, gc3,
2625 x + 1, y + height - 2, x + width - 2, y + height - 2);
2626 gdk_draw_line (window, gc3,
2627 x + width - 2, y, x + width - 2, y + height - 2);
2628 gdk_draw_line (window, gc4,
2629 x, y + height - 1, x + width - 1, y + height - 1);
2630 gdk_draw_line (window, gc4,
2631 x + width - 1, y, x + width - 1, y + height - 1);
2634 gdk_draw_line (window, gc1,
2635 x, y, x + gap_x - 1, y);
2636 gdk_draw_line (window, gc2,
2637 x + 1, y + 1, x + gap_x - 1, y + 1);
2638 gdk_draw_line (window, gc2,
2639 x + gap_x, y, x + gap_x, y);
2641 if ((width - (gap_x + gap_width)) > 0)
2643 gdk_draw_line (window, gc1,
2644 x + gap_x + gap_width, y, x + width - 2, y);
2645 gdk_draw_line (window, gc2,
2646 x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
2647 gdk_draw_line (window, gc2,
2648 x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
2651 case GTK_POS_BOTTOM:
2652 gdk_draw_line (window, gc1,
2653 x, y, x + width - 1, y);
2654 gdk_draw_line (window, gc1,
2655 x, y, x, y + height - 1);
2656 gdk_draw_line (window, gc2,
2657 x + 1, y + 1, x + width - 2, y + 1);
2658 gdk_draw_line (window, gc2,
2659 x + 1, y + 1, x + 1, y + height - 1);
2661 gdk_draw_line (window, gc3,
2662 x + width - 2, y + 1, x + width - 2, y + height - 1);
2663 gdk_draw_line (window, gc4,
2664 x + width - 1, y, x + width - 1, y + height - 1);
2667 gdk_draw_line (window, gc4,
2668 x, y + height - 1, x + gap_x - 1, y + height - 1);
2669 gdk_draw_line (window, gc3,
2670 x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
2671 gdk_draw_line (window, gc3,
2672 x + gap_x, y + height - 1, x + gap_x, y + height - 1);
2674 if ((width - (gap_x + gap_width)) > 0)
2676 gdk_draw_line (window, gc4,
2677 x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
2678 gdk_draw_line (window, gc3,
2679 x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
2680 gdk_draw_line (window, gc3,
2681 x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
2685 gdk_draw_line (window, gc1,
2686 x, y, x + width - 1, y);
2687 gdk_draw_line (window, gc2,
2688 x, y + 1, x + width - 2, y + 1);
2690 gdk_draw_line (window, gc3,
2691 x, y + height - 2, x + width - 2, y + height - 2);
2692 gdk_draw_line (window, gc3,
2693 x + width - 2, y + 1, x + width - 2, y + height - 2);
2694 gdk_draw_line (window, gc4,
2695 x, y + height - 1, x + width - 1, y + height - 1);
2696 gdk_draw_line (window, gc4,
2697 x + width - 1, y, x + width - 1, y + height - 1);
2700 gdk_draw_line (window, gc1,
2701 x, y, x, y + gap_x - 1);
2702 gdk_draw_line (window, gc2,
2703 x + 1, y + 1, x + 1, y + gap_x - 1);
2704 gdk_draw_line (window, gc2,
2705 x, y + gap_x, x, y + gap_x);
2707 if ((width - (gap_x + gap_width)) > 0)
2709 gdk_draw_line (window, gc1,
2710 x, y + gap_x + gap_width, x, y + height - 2);
2711 gdk_draw_line (window, gc2,
2712 x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
2713 gdk_draw_line (window, gc2,
2714 x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
2718 gdk_draw_line (window, gc1,
2719 x, y, x + width - 1, y);
2720 gdk_draw_line (window, gc1,
2721 x, y, x, y + height - 1);
2722 gdk_draw_line (window, gc2,
2723 x + 1, y + 1, x + width - 1, y + 1);
2724 gdk_draw_line (window, gc2,
2725 x + 1, y + 1, x + 1, y + height - 2);
2727 gdk_draw_line (window, gc3,
2728 x + 1, y + height - 2, x + width - 1, y + height - 2);
2729 gdk_draw_line (window, gc4,
2730 x, y + height - 1, x + width - 1, y + height - 1);
2733 gdk_draw_line (window, gc4,
2734 x + width - 1, y, x + width - 1, y + gap_x - 1);
2735 gdk_draw_line (window, gc3,
2736 x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
2737 gdk_draw_line (window, gc3,
2738 x + width - 1, y + gap_x, x + width - 1, y + gap_x);
2740 if ((width - (gap_x + gap_width)) > 0)
2742 gdk_draw_line (window, gc4,
2743 x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
2744 gdk_draw_line (window, gc3,
2745 x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
2746 gdk_draw_line (window, gc3,
2747 x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
2754 gdk_gc_set_clip_rectangle (gc1, NULL);
2755 gdk_gc_set_clip_rectangle (gc2, NULL);
2756 gdk_gc_set_clip_rectangle (gc3, NULL);
2757 gdk_gc_set_clip_rectangle (gc4, NULL);
2762 gtk_default_draw_extension (GtkStyle *style,
2764 GtkStateType state_type,
2765 GtkShadowType shadow_type,
2773 GtkPositionType gap_side)
2780 g_return_if_fail (style != NULL);
2781 g_return_if_fail (window != NULL);
2783 gtk_style_apply_default_background (style, window,
2784 widget && GTK_WIDGET_NO_WINDOW (widget),
2785 GTK_STATE_NORMAL, area, x, y, width, height);
2787 if ((width == -1) && (height == -1))
2788 gdk_window_get_size (window, &width, &height);
2789 else if (width == -1)
2790 gdk_window_get_size (window, &width, NULL);
2791 else if (height == -1)
2792 gdk_window_get_size (window, NULL, &height);
2794 switch (shadow_type)
2796 case GTK_SHADOW_NONE:
2799 gc1 = style->dark_gc[state_type];
2800 gc2 = style->black_gc;
2801 gc3 = style->bg_gc[state_type];
2802 gc4 = style->light_gc[state_type];
2804 case GTK_SHADOW_ETCHED_IN:
2805 gc1 = style->dark_gc[state_type];
2806 gc2 = style->light_gc[state_type];
2807 gc3 = style->dark_gc[state_type];
2808 gc4 = style->light_gc[state_type];
2810 case GTK_SHADOW_OUT:
2811 gc1 = style->light_gc[state_type];
2812 gc2 = style->bg_gc[state_type];
2813 gc3 = style->dark_gc[state_type];
2814 gc4 = style->black_gc;
2816 case GTK_SHADOW_ETCHED_OUT:
2817 gc1 = style->light_gc[state_type];
2818 gc2 = style->dark_gc[state_type];
2819 gc3 = style->light_gc[state_type];
2820 gc4 = style->dark_gc[state_type];
2825 gdk_gc_set_clip_rectangle (gc1, area);
2826 gdk_gc_set_clip_rectangle (gc2, area);
2827 gdk_gc_set_clip_rectangle (gc3, area);
2828 gdk_gc_set_clip_rectangle (gc4, area);
2830 switch (shadow_type)
2832 case GTK_SHADOW_NONE:
2834 case GTK_SHADOW_OUT:
2835 case GTK_SHADOW_ETCHED_IN:
2836 case GTK_SHADOW_ETCHED_OUT:
2840 gtk_style_apply_default_background (style, window,
2841 widget && GTK_WIDGET_NO_WINDOW (widget),
2843 x + style->klass->xthickness,
2845 width - (2 * style->klass->xthickness),
2846 height - (style->klass->ythickness));
2847 gdk_draw_line (window, gc1,
2848 x, y, x, y + height - 2);
2849 gdk_draw_line (window, gc2,
2850 x + 1, y, x + 1, y + height - 2);
2852 gdk_draw_line (window, gc3,
2853 x + 2, y + height - 2, x + width - 2, y + height - 2);
2854 gdk_draw_line (window, gc3,
2855 x + width - 2, y, x + width - 2, y + height - 2);
2856 gdk_draw_line (window, gc4,
2857 x + 1, y + height - 1, x + width - 2, y + height - 1);
2858 gdk_draw_line (window, gc4,
2859 x + width - 1, y, x + width - 1, y + height - 2);
2861 case GTK_POS_BOTTOM:
2862 gtk_style_apply_default_background (style, window,
2863 widget && GTK_WIDGET_NO_WINDOW (widget),
2865 x + style->klass->xthickness,
2866 y + style->klass->ythickness,
2867 width - (2 * style->klass->xthickness),
2868 height - (style->klass->ythickness));
2869 gdk_draw_line (window, gc1,
2870 x + 1, y, x + width - 2, y);
2871 gdk_draw_line (window, gc1,
2872 x, y + 1, x, y + height - 1);
2873 gdk_draw_line (window, gc2,
2874 x + 1, y + 1, x + width - 2, y + 1);
2875 gdk_draw_line (window, gc2,
2876 x + 1, y + 1, x + 1, y + height - 1);
2878 gdk_draw_line (window, gc3,
2879 x + width - 2, y + 2, x + width - 2, y + height - 1);
2880 gdk_draw_line (window, gc4,
2881 x + width - 1, y + 1, x + width - 1, y + height - 1);
2884 gtk_style_apply_default_background (style, window,
2885 widget && GTK_WIDGET_NO_WINDOW (widget),
2888 y + style->klass->ythickness,
2889 width - (style->klass->xthickness),
2890 height - (2 * style->klass->ythickness));
2891 gdk_draw_line (window, gc1,
2892 x, y, x + width - 2, y);
2893 gdk_draw_line (window, gc2,
2894 x + 1, y + 1, x + width - 2, y + 1);
2896 gdk_draw_line (window, gc3,
2897 x, y + height - 2, x + width - 2, y + height - 2);
2898 gdk_draw_line (window, gc3,
2899 x + width - 2, y + 2, x + width - 2, y + height - 2);
2900 gdk_draw_line (window, gc4,
2901 x, y + height - 1, x + width - 2, y + height - 1);
2902 gdk_draw_line (window, gc4,
2903 x + width - 1, y + 1, x + width - 1, y + height - 2);
2906 gtk_style_apply_default_background (style, window,
2907 widget && GTK_WIDGET_NO_WINDOW (widget),
2909 x + style->klass->xthickness,
2910 y + style->klass->ythickness,
2911 width - (style->klass->xthickness),
2912 height - (2 * style->klass->ythickness));
2913 gdk_draw_line (window, gc1,
2914 x + 1, y, x + width - 1, y);
2915 gdk_draw_line (window, gc1,
2916 x, y + 1, x, y + height - 2);
2917 gdk_draw_line (window, gc2,
2918 x + 1, y + 1, x + width - 1, y + 1);
2919 gdk_draw_line (window, gc2,
2920 x + 1, y + 1, x + 1, y + height - 2);
2922 gdk_draw_line (window, gc3,
2923 x + 2, y + height - 2, x + width - 1, y + height - 2);
2924 gdk_draw_line (window, gc4,
2925 x + 1, y + height - 1, x + width - 1, y + height - 1);
2931 gdk_gc_set_clip_rectangle (gc1, NULL);
2932 gdk_gc_set_clip_rectangle (gc2, NULL);
2933 gdk_gc_set_clip_rectangle (gc3, NULL);
2934 gdk_gc_set_clip_rectangle (gc4, NULL);
2939 gtk_default_draw_focus (GtkStyle *style,
2949 g_return_if_fail (style != NULL);
2950 g_return_if_fail (window != NULL);
2952 if ((width == -1) && (height == -1))
2954 gdk_window_get_size (window, &width, &height);
2958 else if (width == -1)
2960 gdk_window_get_size (window, &width, NULL);
2963 else if (height == -1)
2965 gdk_window_get_size (window, NULL, &height);
2970 gdk_gc_set_clip_rectangle (style->black_gc, area);
2972 if (detail && !strcmp (detail, "add-mode"))
2974 gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_ON_OFF_DASH, 0, 0);
2975 gdk_gc_set_dashes (style->black_gc, 0, "\4\4", 2);
2977 gdk_draw_rectangle (window,
2978 style->black_gc, FALSE,
2979 x, y, width, height);
2981 gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_SOLID, 0, 0);
2985 gdk_draw_rectangle (window,
2986 style->black_gc, FALSE,
2987 x, y, width, height);
2991 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2996 gtk_default_draw_slider (GtkStyle *style,
2998 GtkStateType state_type,
2999 GtkShadowType shadow_type,
3007 GtkOrientation orientation)
3009 g_return_if_fail (style != NULL);
3010 g_return_if_fail (window != NULL);
3012 if ((width == -1) && (height == -1))
3013 gdk_window_get_size (window, &width, &height);
3014 else if (width == -1)
3015 gdk_window_get_size (window, &width, NULL);
3016 else if (height == -1)
3017 gdk_window_get_size (window, NULL, &height);
3019 gtk_paint_box (style, window, state_type, shadow_type,
3020 area, widget, detail, x, y, width, height);
3021 if (orientation == GTK_ORIENTATION_HORIZONTAL)
3022 gtk_paint_vline (style, window, state_type, area, widget, detail,
3023 style->klass->ythickness,
3024 height - style->klass->ythickness - 1, width / 2);
3026 gtk_paint_hline (style, window, state_type, area, widget, detail,
3027 style->klass->xthickness,
3028 width - style->klass->xthickness - 1, height / 2);
3032 gtk_default_draw_handle (GtkStyle *style,
3034 GtkStateType state_type,
3035 GtkShadowType shadow_type,
3043 GtkOrientation orientation)
3046 gint xthick, ythick;
3047 GdkGC *light_gc, *dark_gc;
3050 g_return_if_fail (style != NULL);
3051 g_return_if_fail (window != NULL);
3053 if ((width == -1) && (height == -1))
3054 gdk_window_get_size (window, &width, &height);
3055 else if (width == -1)
3056 gdk_window_get_size (window, &width, NULL);
3057 else if (height == -1)
3058 gdk_window_get_size (window, NULL, &height);
3060 gtk_paint_box (style, window, state_type, shadow_type, area, widget,
3061 detail, x, y, width, height);
3063 light_gc = style->light_gc[state_type];
3064 dark_gc = style->dark_gc[state_type];
3066 xthick = style->klass->xthickness;
3067 ythick = style->klass->ythickness;
3069 dest.x = x + xthick;
3070 dest.y = y + ythick;
3071 dest.width = width - (xthick * 2);
3072 dest.height = height - (ythick * 2);
3074 gdk_gc_set_clip_rectangle (light_gc, &dest);
3075 gdk_gc_set_clip_rectangle (dark_gc, &dest);
3077 for (yy = y + ythick; yy < (y + height - ythick); yy += 3)
3078 for (xx = x + xthick; xx < (x + width - xthick); xx += 6)
3080 gdk_draw_point (window, light_gc, xx, yy);
3081 gdk_draw_point (window, dark_gc, xx + 1, yy + 1);
3083 gdk_draw_point (window, light_gc, xx + 3, yy + 1);
3084 gdk_draw_point (window, dark_gc, xx + 4, yy + 2);
3086 gdk_gc_set_clip_rectangle (light_gc, NULL);
3087 gdk_gc_set_clip_rectangle (dark_gc, NULL);
3091 gtk_style_shade (GdkColor *a,
3099 red = (gdouble) a->red / 65535.0;
3100 green = (gdouble) a->green / 65535.0;
3101 blue = (gdouble) a->blue / 65535.0;
3103 rgb_to_hls (&red, &green, &blue);
3108 else if (green < 0.0)
3114 else if (blue < 0.0)
3117 hls_to_rgb (&red, &green, &blue);
3119 b->red = red * 65535.0;
3120 b->green = green * 65535.0;
3121 b->blue = blue * 65535.0;
3125 rgb_to_hls (gdouble *r,
3166 l = (max + min) / 2;
3173 s = (max - min) / (max + min);
3175 s = (max - min) / (2 - max - min);
3179 h = (green - blue) / delta;
3180 else if (green == max)
3181 h = 2 + (blue - red) / delta;
3182 else if (blue == max)
3183 h = 4 + (red - green) / delta;
3196 hls_to_rgb (gdouble *h,
3209 if (lightness <= 0.5)
3210 m2 = lightness * (1 + saturation);
3212 m2 = lightness + saturation - lightness * saturation;
3213 m1 = 2 * lightness - m2;
3215 if (saturation == 0)
3230 r = m1 + (m2 - m1) * hue / 60;
3234 r = m1 + (m2 - m1) * (240 - hue) / 60;
3245 g = m1 + (m2 - m1) * hue / 60;
3249 g = m1 + (m2 - m1) * (240 - hue) / 60;
3260 b = m1 + (m2 - m1) * hue / 60;
3264 b = m1 + (m2 - m1) * (240 - hue) / 60;
3275 gtk_paint_hline (GtkStyle *style,
3277 GtkStateType state_type,
3285 g_return_if_fail (style != NULL);
3286 g_return_if_fail (style->klass != NULL);
3287 g_return_if_fail (style->klass->draw_hline != NULL);
3289 (*style->klass->draw_hline) (style, window, state_type, area, widget, detail, x1, x2, y);
3293 gtk_paint_vline (GtkStyle *style,
3295 GtkStateType state_type,
3303 g_return_if_fail (style != NULL);
3304 g_return_if_fail (style->klass != NULL);
3305 g_return_if_fail (style->klass->draw_vline != NULL);
3307 (*style->klass->draw_vline) (style, window, state_type, area, widget, detail, y1, y2, x);
3311 gtk_paint_shadow (GtkStyle *style,
3313 GtkStateType state_type,
3314 GtkShadowType shadow_type,
3323 g_return_if_fail (style != NULL);
3324 g_return_if_fail (style->klass != NULL);
3325 g_return_if_fail (style->klass->draw_shadow != NULL);
3327 (*style->klass->draw_shadow) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3331 gtk_paint_polygon (GtkStyle *style,
3333 GtkStateType state_type,
3334 GtkShadowType shadow_type,
3342 g_return_if_fail (style != NULL);
3343 g_return_if_fail (style->klass != NULL);
3344 g_return_if_fail (style->klass->draw_shadow != NULL);
3346 (*style->klass->draw_polygon) (style, window, state_type, shadow_type, area, widget, detail, points, npoints, fill);
3350 gtk_paint_arrow (GtkStyle *style,
3352 GtkStateType state_type,
3353 GtkShadowType shadow_type,
3357 GtkArrowType arrow_type,
3364 g_return_if_fail (style != NULL);
3365 g_return_if_fail (style->klass != NULL);
3366 g_return_if_fail (style->klass->draw_arrow != NULL);
3368 (*style->klass->draw_arrow) (style, window, state_type, shadow_type, area, widget, detail, arrow_type, fill, x, y, width, height);
3372 gtk_paint_diamond (GtkStyle *style,
3374 GtkStateType state_type,
3375 GtkShadowType shadow_type,
3384 g_return_if_fail (style != NULL);
3385 g_return_if_fail (style->klass != NULL);
3386 g_return_if_fail (style->klass->draw_diamond != NULL);
3388 (*style->klass->draw_diamond) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3392 gtk_paint_oval (GtkStyle *style,
3394 GtkStateType state_type,
3395 GtkShadowType shadow_type,
3404 g_return_if_fail (style != NULL);
3405 g_return_if_fail (style->klass != NULL);
3406 g_return_if_fail (style->klass->draw_oval != NULL);
3408 (*style->klass->draw_oval) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3412 gtk_paint_string (GtkStyle *style,
3414 GtkStateType state_type,
3420 const gchar *string)
3422 g_return_if_fail (style != NULL);
3423 g_return_if_fail (style->klass != NULL);
3424 g_return_if_fail (style->klass->draw_oval != NULL);
3426 (*style->klass->draw_string) (style, window, state_type, area, widget, detail, x, y, string);
3430 gtk_paint_box (GtkStyle *style,
3432 GtkStateType state_type,
3433 GtkShadowType shadow_type,
3442 g_return_if_fail (style != NULL);
3443 g_return_if_fail (style->klass != NULL);
3444 g_return_if_fail (style->klass->draw_box != NULL);
3446 (*style->klass->draw_box) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3450 gtk_paint_flat_box (GtkStyle *style,
3452 GtkStateType state_type,
3453 GtkShadowType shadow_type,
3462 g_return_if_fail (style != NULL);
3463 g_return_if_fail (style->klass != NULL);
3464 g_return_if_fail (style->klass->draw_flat_box != NULL);
3466 (*style->klass->draw_flat_box) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3470 gtk_paint_check (GtkStyle *style,
3472 GtkStateType state_type,
3473 GtkShadowType shadow_type,
3482 g_return_if_fail (style != NULL);
3483 g_return_if_fail (style->klass != NULL);
3484 g_return_if_fail (style->klass->draw_check != NULL);
3486 (*style->klass->draw_check) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3490 gtk_paint_option (GtkStyle *style,
3492 GtkStateType state_type,
3493 GtkShadowType shadow_type,
3502 g_return_if_fail (style != NULL);
3503 g_return_if_fail (style->klass != NULL);
3504 g_return_if_fail (style->klass->draw_option != NULL);
3506 (*style->klass->draw_option) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3510 gtk_paint_cross (GtkStyle *style,
3512 GtkStateType state_type,
3513 GtkShadowType shadow_type,
3522 g_return_if_fail (style != NULL);
3523 g_return_if_fail (style->klass != NULL);
3524 g_return_if_fail (style->klass->draw_cross != NULL);
3526 (*style->klass->draw_cross) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3530 gtk_paint_ramp (GtkStyle *style,
3532 GtkStateType state_type,
3533 GtkShadowType shadow_type,
3537 GtkArrowType arrow_type,
3543 g_return_if_fail (style != NULL);
3544 g_return_if_fail (style->klass != NULL);
3545 g_return_if_fail (style->klass->draw_ramp != NULL);
3547 (*style->klass->draw_ramp) (style, window, state_type, shadow_type, area, widget, detail, arrow_type, x, y, width, height);
3551 gtk_paint_tab (GtkStyle *style,
3553 GtkStateType state_type,
3554 GtkShadowType shadow_type,
3563 g_return_if_fail (style != NULL);
3564 g_return_if_fail (style->klass != NULL);
3565 g_return_if_fail (style->klass->draw_tab != NULL);
3567 (*style->klass->draw_tab) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3571 gtk_paint_shadow_gap (GtkStyle *style,
3573 GtkStateType state_type,
3574 GtkShadowType shadow_type,
3582 GtkPositionType gap_side,
3586 g_return_if_fail (style != NULL);
3587 g_return_if_fail (style->klass != NULL);
3588 g_return_if_fail (style->klass->draw_shadow_gap != NULL);
3590 (*style->klass->draw_shadow_gap) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
3595 gtk_paint_box_gap (GtkStyle *style,
3597 GtkStateType state_type,
3598 GtkShadowType shadow_type,
3606 GtkPositionType gap_side,
3610 g_return_if_fail (style != NULL);
3611 g_return_if_fail (style->klass != NULL);
3612 g_return_if_fail (style->klass->draw_box_gap != NULL);
3614 (*style->klass->draw_box_gap) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
3618 gtk_paint_extension (GtkStyle *style,
3620 GtkStateType state_type,
3621 GtkShadowType shadow_type,
3629 GtkPositionType gap_side)
3631 g_return_if_fail (style != NULL);
3632 g_return_if_fail (style->klass != NULL);
3633 g_return_if_fail (style->klass->draw_extension != NULL);
3635 (*style->klass->draw_extension) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side);
3639 gtk_paint_focus (GtkStyle *style,
3649 g_return_if_fail (style != NULL);
3650 g_return_if_fail (style->klass != NULL);
3651 g_return_if_fail (style->klass->draw_focus != NULL);
3653 (*style->klass->draw_focus) (style, window, area, widget, detail, x, y, width, height);
3657 gtk_paint_slider (GtkStyle *style,
3659 GtkStateType state_type,
3660 GtkShadowType shadow_type,
3668 GtkOrientation orientation)
3670 g_return_if_fail (style != NULL);
3671 g_return_if_fail (style->klass != NULL);
3672 g_return_if_fail (style->klass->draw_slider != NULL);
3674 (*style->klass->draw_slider) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
3678 gtk_paint_handle (GtkStyle *style,
3680 GtkStateType state_type,
3681 GtkShadowType shadow_type,
3689 GtkOrientation orientation)
3691 g_return_if_fail (style != NULL);
3692 g_return_if_fail (style->klass != NULL);
3693 g_return_if_fail (style->klass->draw_handle != NULL);
3695 (*style->klass->draw_handle) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);