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_style_set_background (GtkStyle *style,
693 GtkStateType state_type)
696 gint parent_relative;
698 if (style->engine && style->engine->set_background)
700 (*style->engine->set_background) (style, window, state_type);
704 g_return_if_fail (style != NULL);
705 g_return_if_fail (window != NULL);
707 if (style->bg_pixmap[state_type])
709 if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
712 parent_relative = TRUE;
716 pixmap = style->bg_pixmap[state_type];
717 parent_relative = FALSE;
720 gdk_window_set_back_pixmap (window, pixmap, parent_relative);
723 gdk_window_set_background (window, &style->bg[state_type]);
728 gtk_draw_hline (GtkStyle *style,
730 GtkStateType state_type,
735 g_return_if_fail (style != NULL);
736 g_return_if_fail (style->klass != NULL);
737 g_return_if_fail (style->klass->draw_hline != NULL);
739 (*style->klass->draw_hline) (style, window, state_type, NULL, NULL, NULL, x1, x2, y);
744 gtk_draw_vline (GtkStyle *style,
746 GtkStateType state_type,
751 g_return_if_fail (style != NULL);
752 g_return_if_fail (style->klass != NULL);
753 g_return_if_fail (style->klass->draw_vline != NULL);
755 (*style->klass->draw_vline) (style, window, state_type, NULL, NULL, NULL, y1, y2, x);
760 gtk_draw_shadow (GtkStyle *style,
762 GtkStateType state_type,
763 GtkShadowType shadow_type,
769 g_return_if_fail (style != NULL);
770 g_return_if_fail (style->klass != NULL);
771 g_return_if_fail (style->klass->draw_shadow != NULL);
773 (*style->klass->draw_shadow) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
777 gtk_draw_polygon (GtkStyle *style,
779 GtkStateType state_type,
780 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_shadow != NULL);
789 (*style->klass->draw_polygon) (style, window, state_type, shadow_type, NULL, NULL, NULL, points, npoints, fill);
793 gtk_draw_arrow (GtkStyle *style,
795 GtkStateType state_type,
796 GtkShadowType shadow_type,
797 GtkArrowType arrow_type,
804 g_return_if_fail (style != NULL);
805 g_return_if_fail (style->klass != NULL);
806 g_return_if_fail (style->klass->draw_arrow != NULL);
808 (*style->klass->draw_arrow) (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, fill, x, y, width, height);
813 gtk_draw_diamond (GtkStyle *style,
815 GtkStateType state_type,
816 GtkShadowType shadow_type,
822 g_return_if_fail (style != NULL);
823 g_return_if_fail (style->klass != NULL);
824 g_return_if_fail (style->klass->draw_diamond != NULL);
826 (*style->klass->draw_diamond) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
831 gtk_draw_oval (GtkStyle *style,
833 GtkStateType state_type,
834 GtkShadowType shadow_type,
840 g_return_if_fail (style != NULL);
841 g_return_if_fail (style->klass != NULL);
842 g_return_if_fail (style->klass->draw_oval != NULL);
844 (*style->klass->draw_oval) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
848 gtk_draw_string (GtkStyle *style,
850 GtkStateType state_type,
855 g_return_if_fail (style != NULL);
856 g_return_if_fail (style->klass != NULL);
857 g_return_if_fail (style->klass->draw_oval != NULL);
859 (*style->klass->draw_string) (style, window, state_type, NULL, NULL, NULL, x, y, string);
863 gtk_draw_box (GtkStyle *style,
865 GtkStateType state_type,
866 GtkShadowType shadow_type,
872 g_return_if_fail (style != NULL);
873 g_return_if_fail (style->klass != NULL);
874 g_return_if_fail (style->klass->draw_box != NULL);
876 (*style->klass->draw_box) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
880 gtk_draw_flat_box (GtkStyle *style,
882 GtkStateType state_type,
883 GtkShadowType shadow_type,
889 g_return_if_fail (style != NULL);
890 g_return_if_fail (style->klass != NULL);
891 g_return_if_fail (style->klass->draw_flat_box != NULL);
893 (*style->klass->draw_flat_box) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
897 gtk_draw_check (GtkStyle *style,
899 GtkStateType state_type,
900 GtkShadowType shadow_type,
906 g_return_if_fail (style != NULL);
907 g_return_if_fail (style->klass != NULL);
908 g_return_if_fail (style->klass->draw_check != NULL);
910 (*style->klass->draw_check) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
914 gtk_draw_option (GtkStyle *style,
916 GtkStateType state_type,
917 GtkShadowType shadow_type,
923 g_return_if_fail (style != NULL);
924 g_return_if_fail (style->klass != NULL);
925 g_return_if_fail (style->klass->draw_option != NULL);
927 (*style->klass->draw_option) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
931 gtk_draw_cross (GtkStyle *style,
933 GtkStateType state_type,
934 GtkShadowType shadow_type,
940 g_return_if_fail (style != NULL);
941 g_return_if_fail (style->klass != NULL);
942 g_return_if_fail (style->klass->draw_cross != NULL);
944 (*style->klass->draw_cross) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
948 gtk_draw_ramp (GtkStyle *style,
950 GtkStateType state_type,
951 GtkShadowType shadow_type,
952 GtkArrowType arrow_type,
958 g_return_if_fail (style != NULL);
959 g_return_if_fail (style->klass != NULL);
960 g_return_if_fail (style->klass->draw_ramp != NULL);
962 (*style->klass->draw_ramp) (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, x, y, width, height);
966 gtk_draw_tab (GtkStyle *style,
968 GtkStateType state_type,
969 GtkShadowType shadow_type,
975 g_return_if_fail (style != NULL);
976 g_return_if_fail (style->klass != NULL);
977 g_return_if_fail (style->klass->draw_tab != NULL);
979 (*style->klass->draw_tab) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
983 gtk_draw_shadow_gap (GtkStyle *style,
985 GtkStateType state_type,
986 GtkShadowType shadow_type,
991 GtkPositionType gap_side,
995 g_return_if_fail (style != NULL);
996 g_return_if_fail (style->klass != NULL);
997 g_return_if_fail (style->klass->draw_shadow_gap != NULL);
999 (*style->klass->draw_shadow_gap) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width);
1003 gtk_draw_box_gap (GtkStyle *style,
1005 GtkStateType state_type,
1006 GtkShadowType shadow_type,
1011 GtkPositionType gap_side,
1015 g_return_if_fail (style != NULL);
1016 g_return_if_fail (style->klass != NULL);
1017 g_return_if_fail (style->klass->draw_box_gap != NULL);
1019 (*style->klass->draw_box_gap) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width);
1023 gtk_draw_extension (GtkStyle *style,
1025 GtkStateType state_type,
1026 GtkShadowType shadow_type,
1031 GtkPositionType gap_side)
1033 g_return_if_fail (style != NULL);
1034 g_return_if_fail (style->klass != NULL);
1035 g_return_if_fail (style->klass->draw_extension != NULL);
1037 (*style->klass->draw_extension) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side);
1041 gtk_draw_focus (GtkStyle *style,
1048 g_return_if_fail (style != NULL);
1049 g_return_if_fail (style->klass != NULL);
1050 g_return_if_fail (style->klass->draw_focus != NULL);
1052 (*style->klass->draw_focus) (style, window, NULL, NULL, NULL, x, y, width, height);
1056 gtk_draw_slider (GtkStyle *style,
1058 GtkStateType state_type,
1059 GtkShadowType shadow_type,
1064 GtkOrientation orientation)
1066 g_return_if_fail (style != NULL);
1067 g_return_if_fail (style->klass != NULL);
1068 g_return_if_fail (style->klass->draw_slider != NULL);
1070 (*style->klass->draw_slider) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
1074 gtk_draw_handle (GtkStyle *style,
1076 GtkStateType state_type,
1077 GtkShadowType shadow_type,
1082 GtkOrientation orientation)
1084 g_return_if_fail (style != NULL);
1085 g_return_if_fail (style->klass != NULL);
1086 g_return_if_fail (style->klass->draw_handle != NULL);
1088 (*style->klass->draw_handle) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
1091 /* Default functions */
1093 gtk_style_apply_default_pixmap(GtkStyle *style,
1095 GtkStateType state_type,
1102 GdkRectangle new_rect, old_rect;
1105 if ((!style->bg_pixmap[state_type]) ||
1106 (gdk_window_get_type(window) == GDK_WINDOW_PIXMAP))
1108 gc = style->bg_gc[state_type];
1112 old_rect.width = width;
1113 old_rect.height = height;
1117 if (gdk_rectangle_intersect(area, &old_rect, &new_rect))
1118 gdk_draw_rectangle(window, gc, TRUE,
1119 new_rect.x, new_rect.y, new_rect.width, new_rect.height);
1122 gdk_draw_rectangle(window, gc, TRUE,
1123 x, y, width, height);
1127 if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
1128 gdk_window_set_back_pixmap(window, NULL, TRUE);
1130 gdk_window_set_back_pixmap(window, style->bg_pixmap[state_type], FALSE);
1134 old_rect.width = width;
1135 old_rect.height = height;
1137 if ((area) && (gdk_rectangle_intersect(area, &old_rect, &new_rect)))
1138 gdk_window_clear_area(window, new_rect.x, new_rect.y, new_rect.width, new_rect.height);
1140 gdk_window_clear_area(window, x, y, width, height);
1145 gtk_default_draw_hline (GtkStyle *style,
1147 GtkStateType state_type,
1155 gint thickness_light;
1156 gint thickness_dark;
1159 g_return_if_fail (style != NULL);
1160 g_return_if_fail (window != NULL);
1162 thickness_light = style->klass->ythickness / 2;
1163 thickness_dark = style->klass->ythickness - thickness_light;
1167 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1168 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1171 if (detail && !strcmp (detail, "label"))
1173 if (state_type == GTK_STATE_INSENSITIVE)
1174 gdk_draw_line (window, style->white_gc, x1 + 1, y + 1, x2 + 1, y + 1);
1175 gdk_draw_line (window, style->fg_gc[state_type], x1, y, x2, y);
1179 for (i = 0; i < thickness_dark; i++)
1181 gdk_draw_line (window, style->light_gc[state_type], x2 - i - 1, y + i, x2, y + i);
1182 gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x2 - i - 1, y + i);
1185 y += thickness_dark;
1186 for (i = 0; i < thickness_light; i++)
1188 gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x1 + thickness_light - i - 1, y + i);
1189 gdk_draw_line (window, style->light_gc[state_type], x1 + thickness_light - i - 1, y + i, x2, y + i);
1195 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
1196 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
1202 gtk_default_draw_vline (GtkStyle *style,
1204 GtkStateType state_type,
1212 gint thickness_light;
1213 gint thickness_dark;
1216 g_return_if_fail (style != NULL);
1217 g_return_if_fail (window != NULL);
1219 thickness_light = style->klass->xthickness / 2;
1220 thickness_dark = style->klass->xthickness - thickness_light;
1224 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1225 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1227 for (i = 0; i < thickness_dark; i++)
1229 gdk_draw_line (window, style->light_gc[state_type], x + i, y2 - i - 1, x + i, y2);
1230 gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y2 - i - 1);
1233 x += thickness_dark;
1234 for (i = 0; i < thickness_light; i++)
1236 gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y1 + thickness_light - i);
1237 gdk_draw_line (window, style->light_gc[state_type], x + i, y1 + thickness_light - i, x + i, y2);
1241 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
1242 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
1248 gtk_default_draw_shadow (GtkStyle *style,
1250 GtkStateType state_type,
1251 GtkShadowType shadow_type,
1262 gint thickness_light;
1263 gint thickness_dark;
1266 g_return_if_fail (style != NULL);
1267 g_return_if_fail (window != NULL);
1269 if ((width == -1) && (height == -1))
1270 gdk_window_get_size (window, &width, &height);
1271 else if (width == -1)
1272 gdk_window_get_size (window, &width, NULL);
1273 else if (height == -1)
1274 gdk_window_get_size (window, NULL, &height);
1276 switch (shadow_type)
1278 case GTK_SHADOW_NONE:
1281 case GTK_SHADOW_ETCHED_IN:
1282 gc1 = style->light_gc[state_type];
1283 gc2 = style->dark_gc[state_type];
1285 case GTK_SHADOW_OUT:
1286 case GTK_SHADOW_ETCHED_OUT:
1287 gc1 = style->dark_gc[state_type];
1288 gc2 = style->light_gc[state_type];
1294 gdk_gc_set_clip_rectangle (gc1, area);
1295 gdk_gc_set_clip_rectangle (gc2, area);
1296 if ((shadow_type == GTK_SHADOW_IN) ||
1297 (shadow_type == GTK_SHADOW_OUT))
1299 gdk_gc_set_clip_rectangle (style->black_gc, area);
1300 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
1303 switch (shadow_type)
1305 case GTK_SHADOW_NONE:
1309 gdk_draw_line (window, gc1,
1310 x, y + height - 1, x + width - 1, y + height - 1);
1311 gdk_draw_line (window, gc1,
1312 x + width - 1, y, x + width - 1, y + height - 1);
1314 gdk_draw_line (window, style->bg_gc[state_type],
1315 x + 1, y + height - 2, x + width - 2, y + height - 2);
1316 gdk_draw_line (window, style->bg_gc[state_type],
1317 x + width - 2, y + 1, x + width - 2, y + height - 2);
1319 gdk_draw_line (window, style->black_gc,
1320 x + 1, y + 1, x + width - 2, y + 1);
1321 gdk_draw_line (window, style->black_gc,
1322 x + 1, y + 1, x + 1, y + height - 2);
1324 gdk_draw_line (window, gc2,
1325 x, y, x + width - 1, y);
1326 gdk_draw_line (window, gc2,
1327 x, y, x, y + height - 1);
1330 case GTK_SHADOW_OUT:
1331 gdk_draw_line (window, gc1,
1332 x + 1, y + height - 2, x + width - 2, y + height - 2);
1333 gdk_draw_line (window, gc1,
1334 x + width - 2, y + 1, x + width - 2, y + height - 2);
1336 gdk_draw_line (window, gc2,
1337 x, y, x + width - 1, y);
1338 gdk_draw_line (window, gc2,
1339 x, y, x, y + height - 1);
1341 gdk_draw_line (window, style->bg_gc[state_type],
1342 x + 1, y + 1, x + width - 2, y + 1);
1343 gdk_draw_line (window, style->bg_gc[state_type],
1344 x + 1, y + 1, x + 1, y + height - 2);
1346 gdk_draw_line (window, style->black_gc,
1347 x, y + height - 1, x + width - 1, y + height - 1);
1348 gdk_draw_line (window, style->black_gc,
1349 x + width - 1, y, x + width - 1, y + height - 1);
1352 case GTK_SHADOW_ETCHED_IN:
1353 case GTK_SHADOW_ETCHED_OUT:
1354 thickness_light = 1;
1357 for (i = 0; i < thickness_dark; i++)
1359 gdk_draw_line (window, gc1,
1363 y + height - i - 1);
1364 gdk_draw_line (window, gc1,
1368 y + height - i - 1);
1370 gdk_draw_line (window, gc2,
1375 gdk_draw_line (window, gc2,
1379 y + height - i - 2);
1382 for (i = 0; i < thickness_light; i++)
1384 gdk_draw_line (window, gc1,
1385 x + thickness_dark + i,
1386 y + thickness_dark + i,
1387 x + width - thickness_dark - i - 1,
1388 y + thickness_dark + i);
1389 gdk_draw_line (window, gc1,
1390 x + thickness_dark + i,
1391 y + thickness_dark + i,
1392 x + thickness_dark + i,
1393 y + height - thickness_dark - i - 1);
1395 gdk_draw_line (window, gc2,
1396 x + thickness_dark + i,
1397 y + height - thickness_light - i - 1,
1398 x + width - thickness_light - 1,
1399 y + height - thickness_light - i - 1);
1400 gdk_draw_line (window, gc2,
1401 x + width - thickness_light - i - 1,
1402 y + thickness_dark + i,
1403 x + width - thickness_light - i - 1,
1404 y + height - thickness_light - 1);
1410 gdk_gc_set_clip_rectangle (gc1, NULL);
1411 gdk_gc_set_clip_rectangle (gc2, NULL);
1412 if ((shadow_type == GTK_SHADOW_IN) ||
1413 (shadow_type == GTK_SHADOW_OUT))
1415 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
1416 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
1423 gtk_default_draw_polygon (GtkStyle *style,
1425 GtkStateType state_type,
1426 GtkShadowType shadow_type,
1435 #define M_PI 3.14159265358979323846
1438 #define M_PI_4 0.78539816339744830962
1441 static const gdouble pi_over_4 = M_PI_4;
1442 static const gdouble pi_3_over_4 = M_PI_4 * 3;
1453 g_return_if_fail (style != NULL);
1454 g_return_if_fail (window != NULL);
1455 g_return_if_fail (points != NULL);
1457 switch (shadow_type)
1460 gc1 = style->bg_gc[state_type];
1461 gc2 = style->dark_gc[state_type];
1462 gc3 = style->light_gc[state_type];
1463 gc4 = style->black_gc;
1465 case GTK_SHADOW_ETCHED_IN:
1466 gc1 = style->light_gc[state_type];
1467 gc2 = style->dark_gc[state_type];
1468 gc3 = style->dark_gc[state_type];
1469 gc4 = style->light_gc[state_type];
1471 case GTK_SHADOW_OUT:
1472 gc1 = style->dark_gc[state_type];
1473 gc2 = style->light_gc[state_type];
1474 gc3 = style->black_gc;
1475 gc4 = style->bg_gc[state_type];
1477 case GTK_SHADOW_ETCHED_OUT:
1478 gc1 = style->dark_gc[state_type];
1479 gc2 = style->light_gc[state_type];
1480 gc3 = style->light_gc[state_type];
1481 gc4 = style->dark_gc[state_type];
1489 gdk_gc_set_clip_rectangle (gc1, area);
1490 gdk_gc_set_clip_rectangle (gc2, area);
1491 gdk_gc_set_clip_rectangle (gc3, area);
1492 gdk_gc_set_clip_rectangle (gc4, area);
1496 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, npoints);
1500 for (i = 0; i < npoints; i++)
1502 if ((points[i].x == points[i+1].x) &&
1503 (points[i].y == points[i+1].y))
1509 angle = atan2 (points[i+1].y - points[i].y,
1510 points[i+1].x - points[i].x);
1513 if ((angle > -pi_3_over_4) && (angle < pi_over_4))
1515 if (angle > -pi_over_4)
1526 gdk_draw_line (window, gc1,
1527 points[i].x-xadjust, points[i].y-yadjust,
1528 points[i+1].x-xadjust, points[i+1].y-yadjust);
1529 gdk_draw_line (window, gc3,
1530 points[i].x, points[i].y,
1531 points[i+1].x, points[i+1].y);
1535 if ((angle < -pi_3_over_4) || (angle > pi_3_over_4))
1546 gdk_draw_line (window, gc4,
1547 points[i].x+xadjust, points[i].y+yadjust,
1548 points[i+1].x+xadjust, points[i+1].y+yadjust);
1549 gdk_draw_line (window, gc2,
1550 points[i].x, points[i].y,
1551 points[i+1].x, points[i+1].y);
1556 gdk_gc_set_clip_rectangle (gc1, NULL);
1557 gdk_gc_set_clip_rectangle (gc2, NULL);
1558 gdk_gc_set_clip_rectangle (gc3, NULL);
1559 gdk_gc_set_clip_rectangle (gc4, NULL);
1564 gtk_default_draw_arrow (GtkStyle *style,
1566 GtkStateType state_type,
1567 GtkShadowType shadow_type,
1571 GtkArrowType arrow_type,
1586 g_return_if_fail (style != NULL);
1587 g_return_if_fail (window != NULL);
1589 switch (shadow_type)
1592 gc1 = style->bg_gc[state_type];
1593 gc2 = style->dark_gc[state_type];
1594 gc3 = style->light_gc[state_type];
1595 gc4 = style->black_gc;
1597 case GTK_SHADOW_OUT:
1598 gc1 = style->dark_gc[state_type];
1599 gc2 = style->light_gc[state_type];
1600 gc3 = style->black_gc;
1601 gc4 = style->bg_gc[state_type];
1603 case GTK_SHADOW_ETCHED_IN:
1604 gc1 = style->light_gc[state_type];
1605 gc2 = style->dark_gc[state_type];
1609 case GTK_SHADOW_ETCHED_OUT:
1610 gc1 = style->dark_gc[state_type];
1611 gc2 = style->light_gc[state_type];
1619 if ((width == -1) && (height == -1))
1620 gdk_window_get_size (window, &width, &height);
1621 else if (width == -1)
1622 gdk_window_get_size (window, &width, NULL);
1623 else if (height == -1)
1624 gdk_window_get_size (window, NULL, &height);
1626 half_width = width / 2;
1627 half_height = height / 2;
1631 gdk_gc_set_clip_rectangle (gc1, area);
1632 gdk_gc_set_clip_rectangle (gc2, area);
1635 gdk_gc_set_clip_rectangle (gc3, area);
1636 gdk_gc_set_clip_rectangle (gc4, area);
1645 points[0].x = x + half_width;
1648 points[1].y = y + height - 1;
1649 points[2].x = x + width - 1;
1650 points[2].y = y + height - 1;
1652 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1655 switch (shadow_type)
1658 case GTK_SHADOW_OUT:
1660 gdk_draw_line (window, gc1,
1661 x + 1, y + height - 2,
1662 x + width - 2, y + height - 2);
1663 gdk_draw_line (window, gc3,
1664 x + 0, y + height - 1,
1665 x + width - 1, y + height - 1);
1667 gdk_draw_line (window, gc1,
1668 x + width - 2, y + height - 1,
1669 x + half_width, y + 1);
1670 gdk_draw_line (window, gc3,
1671 x + width - 1, y + height - 1,
1674 gdk_draw_line (window, gc4,
1675 x + half_width, y + 1,
1676 x + 1, y + height - 1);
1677 gdk_draw_line (window, gc2,
1682 case GTK_SHADOW_ETCHED_IN:
1683 case GTK_SHADOW_ETCHED_OUT:
1684 gdk_draw_line (window, gc1,
1685 x + half_width, y + 1,
1686 x + 1, y + height - 1);
1687 gdk_draw_line (window, gc1,
1688 x + 1, y + height - 1,
1689 x + width - 1, y + height - 1);
1690 gdk_draw_line (window, gc1,
1691 x + width - 1, y + height - 1,
1692 x + half_width + 1, y + 1);
1694 points[0].x = x + half_width;
1697 points[1].y = y + height - 2;
1698 points[2].x = x + width - 2;
1699 points[2].y = y + height - 2;
1701 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1709 case GTK_ARROW_DOWN:
1712 points[0].x = x + width - 1;
1716 points[2].x = x + half_width;
1717 points[2].y = y + height - 1;
1719 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1721 switch (shadow_type)
1724 case GTK_SHADOW_OUT:
1725 gdk_draw_line (window, gc4,
1727 y + 1, x + 1, y + 1);
1728 gdk_draw_line (window, gc2,
1732 gdk_draw_line (window, gc4,
1734 x + half_width, y + height - 2);
1735 gdk_draw_line (window, gc2,
1737 x + half_width, y + height - 1);
1739 gdk_draw_line (window, gc1,
1740 x + half_width, y + height - 2,
1742 gdk_draw_line (window, gc3,
1743 x + half_width, y + height - 1,
1747 case GTK_SHADOW_ETCHED_IN:
1748 case GTK_SHADOW_ETCHED_OUT:
1749 gdk_draw_line (window, gc1,
1750 x + width - 1, y + 1,
1752 gdk_draw_line (window, gc1,
1754 x + half_width + 1, y + height - 1);
1755 gdk_draw_line (window, gc1,
1756 x + half_width + 1, y + height - 2,
1759 points[0].x = x + width - 2;
1763 points[2].x = x + half_width;
1764 points[2].y = y + height - 2;
1766 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1773 case GTK_ARROW_LEFT:
1777 points[0].y = y + half_height;
1778 points[1].x = x + width - 1;
1779 points[1].y = y + height - 1;
1780 points[2].x = x + width - 1;
1783 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1786 switch (shadow_type)
1789 case GTK_SHADOW_OUT:
1790 gdk_draw_line (window, gc1,
1791 x + 1, y + half_height,
1792 x + width - 1, y + height - 1);
1793 gdk_draw_line (window, gc3,
1795 x + width - 1, y + height - 1);
1797 gdk_draw_line (window, gc1,
1798 x + width - 2, y + height - 1,
1799 x + width - 2, y + 1);
1800 gdk_draw_line (window, gc3,
1801 x + width - 1, y + height - 1,
1804 gdk_draw_line (window, gc4,
1805 x + width - 1, y + 1,
1806 x + 1, y + half_height);
1807 gdk_draw_line (window, gc2,
1809 x, y + half_height);
1812 case GTK_SHADOW_ETCHED_IN:
1813 case GTK_SHADOW_ETCHED_OUT:
1814 gdk_draw_line (window, gc1,
1815 x + width - 1, y + 1,
1816 x + 1, y + half_height);
1817 gdk_draw_line (window, gc1,
1818 x + 1, y + half_height + 1,
1819 x + width - 1, y + height - 1);
1820 gdk_draw_line (window, gc1,
1821 x + width - 1, y + height - 1,
1822 x + width - 1, y + 1);
1824 points[0].x = x + width - 2;
1827 points[1].y = y + half_height;
1828 points[2].x = x + width - 2;
1829 points[2].y = y + height - 2;
1831 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1838 case GTK_ARROW_RIGHT:
1841 points[0].x = x + width - 1;
1842 points[0].y = y + half_height;
1846 points[2].y = y + height - 1;
1848 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1851 switch (shadow_type)
1854 case GTK_SHADOW_OUT:
1855 gdk_draw_line (window, gc4,
1856 x + width - 1, y + half_height,
1858 gdk_draw_line (window, gc2,
1859 x + width - 1, y + half_height,
1861 gdk_draw_line (window, gc4,
1863 x + 1, y + height - 2);
1864 gdk_draw_line (window, gc2,
1868 gdk_draw_line (window, gc1,
1869 x + 1, y + height - 2,
1870 x + width - 1, y + half_height);
1871 gdk_draw_line (window, gc3,
1873 x + width - 1, y + half_height);
1876 case GTK_SHADOW_ETCHED_IN:
1877 case GTK_SHADOW_ETCHED_OUT:
1878 gdk_draw_line (window, gc1,
1879 x + width - 1, y + half_height + 1,
1881 gdk_draw_line (window, gc1,
1883 x + 1, y + height - 1);
1884 gdk_draw_line (window, gc1,
1885 x + 1, y + height - 1,
1886 x + width - 1, y + half_height + 1);
1888 points[0].x = x + width - 2;
1889 points[0].y = y + half_height;
1893 points[2].y = y + height - 1;
1895 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1905 gdk_gc_set_clip_rectangle (gc1, NULL);
1906 gdk_gc_set_clip_rectangle (gc2, NULL);
1909 gdk_gc_set_clip_rectangle (gc3, NULL);
1910 gdk_gc_set_clip_rectangle (gc4, NULL);
1916 gtk_default_draw_diamond (GtkStyle *style,
1918 GtkStateType state_type,
1919 GtkShadowType shadow_type,
1931 g_return_if_fail (style != NULL);
1932 g_return_if_fail (window != NULL);
1934 if ((width == -1) && (height == -1))
1935 gdk_window_get_size (window, &width, &height);
1936 else if (width == -1)
1937 gdk_window_get_size (window, &width, NULL);
1938 else if (height == -1)
1939 gdk_window_get_size (window, NULL, &height);
1941 half_width = width / 2;
1942 half_height = height / 2;
1946 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1947 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
1948 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1949 gdk_gc_set_clip_rectangle (style->black_gc, area);
1951 switch (shadow_type)
1954 gdk_draw_line (window, style->bg_gc[state_type],
1955 x + 2, y + half_height,
1956 x + half_width, y + height - 2);
1957 gdk_draw_line (window, style->bg_gc[state_type],
1958 x + half_width, y + height - 2,
1959 x + width - 2, y + half_height);
1960 gdk_draw_line (window, style->light_gc[state_type],
1961 x + 1, y + half_height,
1962 x + half_width, y + height - 1);
1963 gdk_draw_line (window, style->light_gc[state_type],
1964 x + half_width, y + height - 1,
1965 x + width - 1, y + half_height);
1966 gdk_draw_line (window, style->light_gc[state_type],
1968 x + half_width, y + height);
1969 gdk_draw_line (window, style->light_gc[state_type],
1970 x + half_width, y + height,
1971 x + width, y + half_height);
1973 gdk_draw_line (window, style->black_gc,
1974 x + 2, y + half_height,
1975 x + half_width, y + 2);
1976 gdk_draw_line (window, style->black_gc,
1977 x + half_width, y + 2,
1978 x + width - 2, y + half_height);
1979 gdk_draw_line (window, style->dark_gc[state_type],
1980 x + 1, y + half_height,
1981 x + half_width, y + 1);
1982 gdk_draw_line (window, style->dark_gc[state_type],
1983 x + half_width, y + 1,
1984 x + width - 1, y + half_height);
1985 gdk_draw_line (window, style->dark_gc[state_type],
1988 gdk_draw_line (window, style->dark_gc[state_type],
1990 x + width, y + half_height);
1992 case GTK_SHADOW_OUT:
1993 gdk_draw_line (window, style->dark_gc[state_type],
1994 x + 2, y + half_height,
1995 x + half_width, y + height - 2);
1996 gdk_draw_line (window, style->dark_gc[state_type],
1997 x + half_width, y + height - 2,
1998 x + width - 2, y + half_height);
1999 gdk_draw_line (window, style->dark_gc[state_type],
2000 x + 1, y + half_height,
2001 x + half_width, y + height - 1);
2002 gdk_draw_line (window, style->dark_gc[state_type],
2003 x + half_width, y + height - 1,
2004 x + width - 1, y + half_height);
2005 gdk_draw_line (window, style->black_gc,
2007 x + half_width, y + height);
2008 gdk_draw_line (window, style->black_gc,
2009 x + half_width, y + height,
2010 x + width, y + half_height);
2012 gdk_draw_line (window, style->bg_gc[state_type],
2013 x + 2, y + half_height,
2014 x + half_width, y + 2);
2015 gdk_draw_line (window, style->bg_gc[state_type],
2016 x + half_width, y + 2,
2017 x + width - 2, y + half_height);
2018 gdk_draw_line (window, style->light_gc[state_type],
2019 x + 1, y + half_height,
2020 x + half_width, y + 1);
2021 gdk_draw_line (window, style->light_gc[state_type],
2022 x + half_width, y + 1,
2023 x + width - 1, y + half_height);
2024 gdk_draw_line (window, style->light_gc[state_type],
2027 gdk_draw_line (window, style->light_gc[state_type],
2029 x + width, y + half_height);
2036 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
2037 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2038 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
2039 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2045 gtk_default_draw_oval (GtkStyle *style,
2047 GtkStateType state_type,
2048 GtkShadowType shadow_type,
2057 g_return_if_fail (style != NULL);
2058 g_return_if_fail (window != NULL);
2062 gtk_default_draw_string (GtkStyle *style,
2064 GtkStateType state_type,
2070 const gchar *string)
2072 g_return_if_fail (style != NULL);
2073 g_return_if_fail (window != NULL);
2077 gdk_gc_set_clip_rectangle (style->white_gc, area);
2078 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], area);
2080 if (state_type == GTK_STATE_INSENSITIVE)
2081 gdk_draw_string (window, style->font, style->white_gc, x + 1, y + 1, string);
2082 gdk_draw_string (window, style->font, style->fg_gc[state_type], x, y, string);
2085 gdk_gc_set_clip_rectangle (style->white_gc, NULL);
2086 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], NULL);
2091 gtk_default_draw_box (GtkStyle *style,
2093 GtkStateType state_type,
2094 GtkShadowType shadow_type,
2103 g_return_if_fail (style != NULL);
2104 g_return_if_fail (window != NULL);
2106 if ((width == -1) && (height == -1))
2107 gdk_window_get_size (window, &width, &height);
2108 else if (width == -1)
2109 gdk_window_get_size (window, &width, NULL);
2110 else if (height == -1)
2111 gdk_window_get_size (window, NULL, &height);
2113 if ((!style->bg_pixmap[state_type]) ||
2114 (gdk_window_get_type(window) == GDK_WINDOW_PIXMAP))
2118 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
2120 gdk_draw_rectangle(window, style->bg_gc[state_type], TRUE,
2121 x, y, width, height);
2124 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2128 gtk_style_apply_default_pixmap(style, window, state_type, area, x, y, width, height);
2129 gtk_paint_shadow (style, window, state_type, shadow_type, area, widget, detail,
2130 x, y, width, height);
2134 gtk_default_draw_flat_box (GtkStyle *style,
2136 GtkStateType state_type,
2137 GtkShadowType shadow_type,
2148 g_return_if_fail (style != NULL);
2149 g_return_if_fail (window != NULL);
2151 if ((width == -1) && (height == -1))
2152 gdk_window_get_size (window, &width, &height);
2153 else if (width == -1)
2154 gdk_window_get_size (window, &width, NULL);
2155 else if (height == -1)
2156 gdk_window_get_size (window, NULL, &height);
2158 if ((detail) && (!strcmp("text",detail)) && (state_type == GTK_STATE_SELECTED))
2159 gc1 = style->bg_gc[GTK_STATE_SELECTED];
2160 else if ((detail) && (!strcmp("viewportbin",detail)))
2161 gc1 = style->bg_gc[GTK_STATE_NORMAL];
2162 else if ((detail) && (!strcmp("entry_bg",detail)))
2163 gc1 = style->base_gc[state_type];
2165 gc1 = style->bg_gc[state_type];
2167 if ((!style->bg_pixmap[state_type]) || (gc1 != style->bg_gc[state_type]) ||
2168 (gdk_window_get_type(window) == GDK_WINDOW_PIXMAP))
2172 gdk_gc_set_clip_rectangle (gc1, area);
2174 gdk_draw_rectangle (window, gc1, TRUE,
2175 x, y, width, height);
2176 if ((detail) && (!strcmp("tooltip",detail)))
2177 gdk_draw_rectangle (window, style->black_gc, FALSE,
2178 x, y, width - 1, height - 1);
2181 gdk_gc_set_clip_rectangle (gc1, NULL);
2185 gtk_style_apply_default_pixmap(style, window, state_type, area, x, y, width, height);
2189 gtk_default_draw_check (GtkStyle *style,
2191 GtkStateType state_type,
2192 GtkShadowType shadow_type,
2201 gtk_paint_box (style, window, state_type, shadow_type, area, widget, detail,
2202 x, y, width, height);
2206 gtk_default_draw_option (GtkStyle *style,
2208 GtkStateType state_type,
2209 GtkShadowType shadow_type,
2218 gtk_paint_diamond (style, window, state_type, shadow_type, area, widget,
2219 detail, x, y, width, height);
2223 gtk_default_draw_cross (GtkStyle *style,
2225 GtkStateType state_type,
2226 GtkShadowType shadow_type,
2235 g_return_if_fail (style != NULL);
2236 g_return_if_fail (window != NULL);
2240 gtk_default_draw_ramp (GtkStyle *style,
2242 GtkStateType state_type,
2243 GtkShadowType shadow_type,
2247 GtkArrowType arrow_type,
2253 g_return_if_fail (style != NULL);
2254 g_return_if_fail (window != NULL);
2257 static void gtk_default_draw_tab (GtkStyle *style,
2259 GtkStateType state_type,
2260 GtkShadowType shadow_type,
2269 g_return_if_fail (style != NULL);
2270 g_return_if_fail (window != NULL);
2272 gtk_paint_box (style, window, state_type, shadow_type, area, widget, detail,
2273 x, y, width, height);
2277 gtk_default_draw_shadow_gap (GtkStyle *style,
2279 GtkStateType state_type,
2280 GtkShadowType shadow_type,
2288 GtkPositionType gap_side,
2297 g_return_if_fail (style != NULL);
2298 g_return_if_fail (window != NULL);
2300 if ((width == -1) && (height == -1))
2301 gdk_window_get_size (window, &width, &height);
2302 else if (width == -1)
2303 gdk_window_get_size (window, &width, NULL);
2304 else if (height == -1)
2305 gdk_window_get_size (window, NULL, &height);
2307 switch (shadow_type)
2309 case GTK_SHADOW_NONE:
2312 gc1 = style->dark_gc[state_type];
2313 gc2 = style->black_gc;
2314 gc3 = style->bg_gc[state_type];
2315 gc4 = style->light_gc[state_type];
2317 case GTK_SHADOW_ETCHED_IN:
2318 gc1 = style->dark_gc[state_type];
2319 gc2 = style->light_gc[state_type];
2320 gc3 = style->dark_gc[state_type];
2321 gc4 = style->light_gc[state_type];
2323 case GTK_SHADOW_OUT:
2324 gc1 = style->light_gc[state_type];
2325 gc2 = style->bg_gc[state_type];
2326 gc3 = style->dark_gc[state_type];
2327 gc4 = style->black_gc;
2329 case GTK_SHADOW_ETCHED_OUT:
2330 gc1 = style->light_gc[state_type];
2331 gc2 = style->dark_gc[state_type];
2332 gc3 = style->light_gc[state_type];
2333 gc4 = style->dark_gc[state_type];
2338 gdk_gc_set_clip_rectangle (gc1, area);
2339 gdk_gc_set_clip_rectangle (gc2, area);
2340 gdk_gc_set_clip_rectangle (gc3, area);
2341 gdk_gc_set_clip_rectangle (gc4, area);
2344 switch (shadow_type)
2346 case GTK_SHADOW_NONE:
2348 case GTK_SHADOW_OUT:
2349 case GTK_SHADOW_ETCHED_IN:
2350 case GTK_SHADOW_ETCHED_OUT:
2354 gdk_draw_line (window, gc1,
2355 x, y, x, y + height - 1);
2356 gdk_draw_line (window, gc2,
2357 x + 1, y, x + 1, y + height - 2);
2359 gdk_draw_line (window, gc3,
2360 x + 1, y + height - 2, x + width - 2, y + height - 2);
2361 gdk_draw_line (window, gc3,
2362 x + width - 2, y, x + width - 2, y + height - 2);
2363 gdk_draw_line (window, gc4,
2364 x, y + height - 1, x + width - 1, y + height - 1);
2365 gdk_draw_line (window, gc4,
2366 x + width - 1, y, x + width - 1, y + height - 1);
2369 gdk_draw_line (window, gc1,
2370 x, y, x + gap_x - 1, y);
2371 gdk_draw_line (window, gc2,
2372 x + 1, y + 1, x + gap_x - 1, y + 1);
2373 gdk_draw_line (window, gc2,
2374 x + gap_x, y, x + gap_x, y);
2376 if ((width - (gap_x + gap_width)) > 0)
2378 gdk_draw_line (window, gc1,
2379 x + gap_x + gap_width, y, x + width - 2, y);
2380 gdk_draw_line (window, gc2,
2381 x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
2382 gdk_draw_line (window, gc2,
2383 x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
2386 case GTK_POS_BOTTOM:
2387 gdk_draw_line (window, gc1,
2388 x, y, x + width - 1, y);
2389 gdk_draw_line (window, gc1,
2390 x, y, x, y + height - 1);
2391 gdk_draw_line (window, gc2,
2392 x + 1, y + 1, x + width - 2, y + 1);
2393 gdk_draw_line (window, gc2,
2394 x + 1, y + 1, x + 1, y + height - 1);
2396 gdk_draw_line (window, gc3,
2397 x + width - 2, y + 1, x + width - 2, 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, gc4,
2403 x, y + height - 1, x + gap_x - 1, y + height - 1);
2404 gdk_draw_line (window, gc3,
2405 x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
2406 gdk_draw_line (window, gc3,
2407 x + gap_x, y + height - 1, x + gap_x, y + height - 1);
2409 if ((width - (gap_x + gap_width)) > 0)
2411 gdk_draw_line (window, gc4,
2412 x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
2413 gdk_draw_line (window, gc3,
2414 x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
2415 gdk_draw_line (window, gc3,
2416 x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
2420 gdk_draw_line (window, gc1,
2421 x, y, x + width - 1, y);
2422 gdk_draw_line (window, gc2,
2423 x, y + 1, x + width - 2, y + 1);
2425 gdk_draw_line (window, gc3,
2426 x, y + height - 2, x + width - 2, y + height - 2);
2427 gdk_draw_line (window, gc3,
2428 x + width - 2, y + 1, x + width - 2, y + height - 2);
2429 gdk_draw_line (window, gc4,
2430 x, y + height - 1, x + width - 1, 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, gc1,
2436 x, y, x, y + gap_x - 1);
2437 gdk_draw_line (window, gc2,
2438 x + 1, y + 1, x + 1, y + gap_x - 1);
2439 gdk_draw_line (window, gc2,
2440 x, y + gap_x, x, y + gap_x);
2442 if ((width - (gap_x + gap_width)) > 0)
2444 gdk_draw_line (window, gc1,
2445 x, y + gap_x + gap_width, x, y + height - 2);
2446 gdk_draw_line (window, gc2,
2447 x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
2448 gdk_draw_line (window, gc2,
2449 x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
2453 gdk_draw_line (window, gc1,
2454 x, y, x + width - 1, y);
2455 gdk_draw_line (window, gc1,
2456 x, y, x, y + height - 1);
2457 gdk_draw_line (window, gc2,
2458 x + 1, y + 1, x + width - 1, y + 1);
2459 gdk_draw_line (window, gc2,
2460 x + 1, y + 1, x + 1, y + height - 2);
2462 gdk_draw_line (window, gc3,
2463 x + 1, y + height - 2, x + width - 1, y + height - 2);
2464 gdk_draw_line (window, gc4,
2465 x, y + height - 1, x + width - 1, y + height - 1);
2468 gdk_draw_line (window, gc4,
2469 x + width - 1, y, x + width - 1, y + gap_x - 1);
2470 gdk_draw_line (window, gc3,
2471 x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
2472 gdk_draw_line (window, gc3,
2473 x + width - 1, y + gap_x, x + width - 1, y + gap_x);
2475 if ((width - (gap_x + gap_width)) > 0)
2477 gdk_draw_line (window, gc4,
2478 x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
2479 gdk_draw_line (window, gc3,
2480 x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
2481 gdk_draw_line (window, gc3,
2482 x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
2489 gdk_gc_set_clip_rectangle (gc1, NULL);
2490 gdk_gc_set_clip_rectangle (gc2, NULL);
2491 gdk_gc_set_clip_rectangle (gc3, NULL);
2492 gdk_gc_set_clip_rectangle (gc4, NULL);
2497 gtk_default_draw_box_gap (GtkStyle *style,
2499 GtkStateType state_type,
2500 GtkShadowType shadow_type,
2508 GtkPositionType gap_side,
2517 g_return_if_fail (style != NULL);
2518 g_return_if_fail (window != NULL);
2520 gtk_style_apply_default_pixmap(style, window, state_type, area,
2521 x, y, width, height);
2523 if ((width == -1) && (height == -1))
2524 gdk_window_get_size (window, &width, &height);
2525 else if (width == -1)
2526 gdk_window_get_size (window, &width, NULL);
2527 else if (height == -1)
2528 gdk_window_get_size (window, NULL, &height);
2530 switch (shadow_type)
2532 case GTK_SHADOW_NONE:
2535 gc1 = style->dark_gc[state_type];
2536 gc2 = style->black_gc;
2537 gc3 = style->bg_gc[state_type];
2538 gc4 = style->light_gc[state_type];
2540 case GTK_SHADOW_ETCHED_IN:
2541 gc1 = style->dark_gc[state_type];
2542 gc2 = style->light_gc[state_type];
2543 gc3 = style->dark_gc[state_type];
2544 gc4 = style->light_gc[state_type];
2546 case GTK_SHADOW_OUT:
2547 gc1 = style->light_gc[state_type];
2548 gc2 = style->bg_gc[state_type];
2549 gc3 = style->dark_gc[state_type];
2550 gc4 = style->black_gc;
2552 case GTK_SHADOW_ETCHED_OUT:
2553 gc1 = style->light_gc[state_type];
2554 gc2 = style->dark_gc[state_type];
2555 gc3 = style->light_gc[state_type];
2556 gc4 = style->dark_gc[state_type];
2561 gdk_gc_set_clip_rectangle (gc1, area);
2562 gdk_gc_set_clip_rectangle (gc2, area);
2563 gdk_gc_set_clip_rectangle (gc3, area);
2564 gdk_gc_set_clip_rectangle (gc4, area);
2567 switch (shadow_type)
2569 case GTK_SHADOW_NONE:
2571 case GTK_SHADOW_OUT:
2572 case GTK_SHADOW_ETCHED_IN:
2573 case GTK_SHADOW_ETCHED_OUT:
2577 gdk_draw_line (window, gc1,
2578 x, y, x, y + height - 1);
2579 gdk_draw_line (window, gc2,
2580 x + 1, y, x + 1, y + height - 2);
2582 gdk_draw_line (window, gc3,
2583 x + 1, y + height - 2, x + width - 2, y + height - 2);
2584 gdk_draw_line (window, gc3,
2585 x + width - 2, y, x + width - 2, y + height - 2);
2586 gdk_draw_line (window, gc4,
2587 x, y + height - 1, x + width - 1, y + height - 1);
2588 gdk_draw_line (window, gc4,
2589 x + width - 1, y, x + width - 1, y + height - 1);
2592 gdk_draw_line (window, gc1,
2593 x, y, x + gap_x - 1, y);
2594 gdk_draw_line (window, gc2,
2595 x + 1, y + 1, x + gap_x - 1, y + 1);
2596 gdk_draw_line (window, gc2,
2597 x + gap_x, y, x + gap_x, y);
2599 if ((width - (gap_x + gap_width)) > 0)
2601 gdk_draw_line (window, gc1,
2602 x + gap_x + gap_width, y, x + width - 2, y);
2603 gdk_draw_line (window, gc2,
2604 x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
2605 gdk_draw_line (window, gc2,
2606 x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
2609 case GTK_POS_BOTTOM:
2610 gdk_draw_line (window, gc1,
2611 x, y, x + width - 1, y);
2612 gdk_draw_line (window, gc1,
2613 x, y, x, y + height - 1);
2614 gdk_draw_line (window, gc2,
2615 x + 1, y + 1, x + width - 2, y + 1);
2616 gdk_draw_line (window, gc2,
2617 x + 1, y + 1, x + 1, y + height - 1);
2619 gdk_draw_line (window, gc3,
2620 x + width - 2, y + 1, x + width - 2, y + height - 1);
2621 gdk_draw_line (window, gc4,
2622 x + width - 1, y, x + width - 1, y + height - 1);
2625 gdk_draw_line (window, gc4,
2626 x, y + height - 1, x + gap_x - 1, y + height - 1);
2627 gdk_draw_line (window, gc3,
2628 x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
2629 gdk_draw_line (window, gc3,
2630 x + gap_x, y + height - 1, x + gap_x, y + height - 1);
2632 if ((width - (gap_x + gap_width)) > 0)
2634 gdk_draw_line (window, gc4,
2635 x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
2636 gdk_draw_line (window, gc3,
2637 x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
2638 gdk_draw_line (window, gc3,
2639 x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
2643 gdk_draw_line (window, gc1,
2644 x, y, x + width - 1, y);
2645 gdk_draw_line (window, gc2,
2646 x, y + 1, x + width - 2, y + 1);
2648 gdk_draw_line (window, gc3,
2649 x, y + height - 2, x + width - 2, y + height - 2);
2650 gdk_draw_line (window, gc3,
2651 x + width - 2, y + 1, x + width - 2, y + height - 2);
2652 gdk_draw_line (window, gc4,
2653 x, y + height - 1, x + width - 1, y + height - 1);
2654 gdk_draw_line (window, gc4,
2655 x + width - 1, y, x + width - 1, y + height - 1);
2658 gdk_draw_line (window, gc1,
2659 x, y, x, y + gap_x - 1);
2660 gdk_draw_line (window, gc2,
2661 x + 1, y + 1, x + 1, y + gap_x - 1);
2662 gdk_draw_line (window, gc2,
2663 x, y + gap_x, x, y + gap_x);
2665 if ((width - (gap_x + gap_width)) > 0)
2667 gdk_draw_line (window, gc1,
2668 x, y + gap_x + gap_width, x, y + height - 2);
2669 gdk_draw_line (window, gc2,
2670 x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
2671 gdk_draw_line (window, gc2,
2672 x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
2676 gdk_draw_line (window, gc1,
2677 x, y, x + width - 1, y);
2678 gdk_draw_line (window, gc1,
2679 x, y, x, y + height - 1);
2680 gdk_draw_line (window, gc2,
2681 x + 1, y + 1, x + width - 1, y + 1);
2682 gdk_draw_line (window, gc2,
2683 x + 1, y + 1, x + 1, y + height - 2);
2685 gdk_draw_line (window, gc3,
2686 x + 1, y + height - 2, x + width - 1, y + height - 2);
2687 gdk_draw_line (window, gc4,
2688 x, y + height - 1, x + width - 1, y + height - 1);
2691 gdk_draw_line (window, gc4,
2692 x + width - 1, y, x + width - 1, y + gap_x - 1);
2693 gdk_draw_line (window, gc3,
2694 x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
2695 gdk_draw_line (window, gc3,
2696 x + width - 1, y + gap_x, x + width - 1, y + gap_x);
2698 if ((width - (gap_x + gap_width)) > 0)
2700 gdk_draw_line (window, gc4,
2701 x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
2702 gdk_draw_line (window, gc3,
2703 x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
2704 gdk_draw_line (window, gc3,
2705 x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
2712 gdk_gc_set_clip_rectangle (gc1, NULL);
2713 gdk_gc_set_clip_rectangle (gc2, NULL);
2714 gdk_gc_set_clip_rectangle (gc3, NULL);
2715 gdk_gc_set_clip_rectangle (gc4, NULL);
2720 gtk_default_draw_extension (GtkStyle *style,
2722 GtkStateType state_type,
2723 GtkShadowType shadow_type,
2731 GtkPositionType gap_side)
2738 g_return_if_fail (style != NULL);
2739 g_return_if_fail (window != NULL);
2741 gtk_style_apply_default_pixmap(style, window, GTK_STATE_NORMAL, area,
2742 x, y, width, height);
2744 if ((width == -1) && (height == -1))
2745 gdk_window_get_size (window, &width, &height);
2746 else if (width == -1)
2747 gdk_window_get_size (window, &width, NULL);
2748 else if (height == -1)
2749 gdk_window_get_size (window, NULL, &height);
2751 switch (shadow_type)
2753 case GTK_SHADOW_NONE:
2756 gc1 = style->dark_gc[state_type];
2757 gc2 = style->black_gc;
2758 gc3 = style->bg_gc[state_type];
2759 gc4 = style->light_gc[state_type];
2761 case GTK_SHADOW_ETCHED_IN:
2762 gc1 = style->dark_gc[state_type];
2763 gc2 = style->light_gc[state_type];
2764 gc3 = style->dark_gc[state_type];
2765 gc4 = style->light_gc[state_type];
2767 case GTK_SHADOW_OUT:
2768 gc1 = style->light_gc[state_type];
2769 gc2 = style->bg_gc[state_type];
2770 gc3 = style->dark_gc[state_type];
2771 gc4 = style->black_gc;
2773 case GTK_SHADOW_ETCHED_OUT:
2774 gc1 = style->light_gc[state_type];
2775 gc2 = style->dark_gc[state_type];
2776 gc3 = style->light_gc[state_type];
2777 gc4 = style->dark_gc[state_type];
2782 gdk_gc_set_clip_rectangle (gc1, area);
2783 gdk_gc_set_clip_rectangle (gc2, area);
2784 gdk_gc_set_clip_rectangle (gc3, area);
2785 gdk_gc_set_clip_rectangle (gc4, area);
2787 switch (shadow_type)
2789 case GTK_SHADOW_NONE:
2791 case GTK_SHADOW_OUT:
2792 case GTK_SHADOW_ETCHED_IN:
2793 case GTK_SHADOW_ETCHED_OUT:
2797 gtk_style_apply_default_pixmap(style, window, state_type, area,
2798 x + style->klass->xthickness,
2800 width - (2 * style->klass->xthickness),
2801 height - (style->klass->ythickness));
2802 gdk_draw_line (window, gc1,
2803 x, y, x, y + height - 2);
2804 gdk_draw_line (window, gc2,
2805 x + 1, y, x + 1, y + height - 2);
2807 gdk_draw_line (window, gc3,
2808 x + 2, y + height - 2, x + width - 2, y + height - 2);
2809 gdk_draw_line (window, gc3,
2810 x + width - 2, y, x + width - 2, y + height - 2);
2811 gdk_draw_line (window, gc4,
2812 x + 1, y + height - 1, x + width - 2, y + height - 1);
2813 gdk_draw_line (window, gc4,
2814 x + width - 1, y, x + width - 1, y + height - 2);
2816 case GTK_POS_BOTTOM:
2817 gtk_style_apply_default_pixmap(style, window, state_type, area,
2818 x + style->klass->xthickness,
2819 y + style->klass->ythickness,
2820 width - (2 * style->klass->xthickness),
2821 height - (style->klass->ythickness));
2822 gdk_draw_line (window, gc1,
2823 x + 1, y, x + width - 2, y);
2824 gdk_draw_line (window, gc1,
2825 x, y + 1, x, y + height - 1);
2826 gdk_draw_line (window, gc2,
2827 x + 1, y + 1, x + width - 2, y + 1);
2828 gdk_draw_line (window, gc2,
2829 x + 1, y + 1, x + 1, y + height - 1);
2831 gdk_draw_line (window, gc3,
2832 x + width - 2, y + 2, x + width - 2, y + height - 1);
2833 gdk_draw_line (window, gc4,
2834 x + width - 1, y + 1, x + width - 1, y + height - 1);
2837 gtk_style_apply_default_pixmap(style, window, state_type, area,
2839 y + style->klass->ythickness,
2840 width - (style->klass->xthickness),
2841 height - (2 * style->klass->ythickness));
2842 gdk_draw_line (window, gc1,
2843 x, y, x + width - 2, y);
2844 gdk_draw_line (window, gc2,
2845 x + 1, y + 1, x + width - 2, y + 1);
2847 gdk_draw_line (window, gc3,
2848 x, y + height - 2, x + width - 2, y + height - 2);
2849 gdk_draw_line (window, gc3,
2850 x + width - 2, y + 2, x + width - 2, y + height - 2);
2851 gdk_draw_line (window, gc4,
2852 x, y + height - 1, x + width - 2, y + height - 1);
2853 gdk_draw_line (window, gc4,
2854 x + width - 1, y + 1, x + width - 1, y + height - 2);
2857 gtk_style_apply_default_pixmap(style, window, state_type, area,
2858 x + style->klass->xthickness,
2859 y + style->klass->ythickness,
2860 width - (style->klass->xthickness),
2861 height - (2 * style->klass->ythickness));
2862 gdk_draw_line (window, gc1,
2863 x + 1, y, x + width - 1, y);
2864 gdk_draw_line (window, gc1,
2865 x, y + 1, x, y + height - 2);
2866 gdk_draw_line (window, gc2,
2867 x + 1, y + 1, x + width - 1, y + 1);
2868 gdk_draw_line (window, gc2,
2869 x + 1, y + 1, x + 1, y + height - 2);
2871 gdk_draw_line (window, gc3,
2872 x + 2, y + height - 2, x + width - 1, y + height - 2);
2873 gdk_draw_line (window, gc4,
2874 x + 1, y + height - 1, x + width - 1, y + height - 1);
2880 gdk_gc_set_clip_rectangle (gc1, NULL);
2881 gdk_gc_set_clip_rectangle (gc2, NULL);
2882 gdk_gc_set_clip_rectangle (gc3, NULL);
2883 gdk_gc_set_clip_rectangle (gc4, NULL);
2888 gtk_default_draw_focus (GtkStyle *style,
2898 g_return_if_fail (style != NULL);
2899 g_return_if_fail (window != NULL);
2901 if ((width == -1) && (height == -1))
2903 gdk_window_get_size (window, &width, &height);
2907 else if (width == -1)
2909 gdk_window_get_size (window, &width, NULL);
2912 else if (height == -1)
2914 gdk_window_get_size (window, NULL, &height);
2919 gdk_gc_set_clip_rectangle (style->black_gc, area);
2921 if (detail && !strcmp (detail, "add-mode"))
2923 gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_ON_OFF_DASH, 0, 0);
2924 gdk_gc_set_dashes (style->black_gc, 0, "\4\4", 2);
2926 gdk_draw_rectangle (window,
2927 style->black_gc, FALSE,
2928 x, y, width, height);
2930 gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_SOLID, 0, 0);
2934 gdk_draw_rectangle (window,
2935 style->black_gc, FALSE,
2936 x, y, width, height);
2940 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2945 gtk_default_draw_slider (GtkStyle *style,
2947 GtkStateType state_type,
2948 GtkShadowType shadow_type,
2956 GtkOrientation orientation)
2958 g_return_if_fail (style != NULL);
2959 g_return_if_fail (window != NULL);
2961 if ((width == -1) && (height == -1))
2962 gdk_window_get_size (window, &width, &height);
2963 else if (width == -1)
2964 gdk_window_get_size (window, &width, NULL);
2965 else if (height == -1)
2966 gdk_window_get_size (window, NULL, &height);
2968 gtk_paint_box (style, window, state_type, shadow_type,
2969 area, widget, detail, x, y, width, height);
2970 if (orientation == GTK_ORIENTATION_HORIZONTAL)
2971 gtk_paint_vline (style, window, state_type, area, widget, detail,
2972 style->klass->ythickness,
2973 height - style->klass->ythickness - 1, width / 2);
2975 gtk_paint_hline (style, window, state_type, area, widget, detail,
2976 style->klass->xthickness,
2977 width - style->klass->xthickness - 1, height / 2);
2981 gtk_default_draw_handle (GtkStyle *style,
2983 GtkStateType state_type,
2984 GtkShadowType shadow_type,
2992 GtkOrientation orientation)
2995 gint xthick, ythick;
2996 GdkGC *light_gc, *dark_gc;
2999 g_return_if_fail (style != NULL);
3000 g_return_if_fail (window != NULL);
3002 if ((width == -1) && (height == -1))
3003 gdk_window_get_size (window, &width, &height);
3004 else if (width == -1)
3005 gdk_window_get_size (window, &width, NULL);
3006 else if (height == -1)
3007 gdk_window_get_size (window, NULL, &height);
3009 gtk_paint_box (style, window, state_type, shadow_type, area, widget,
3010 detail, x, y, width, height);
3012 light_gc = style->light_gc[state_type];
3013 dark_gc = style->dark_gc[state_type];
3015 xthick = style->klass->xthickness;
3016 ythick = style->klass->ythickness;
3018 dest.x = x + xthick;
3019 dest.y = y + ythick;
3020 dest.width = width - (xthick * 2);
3021 dest.height = height - (ythick * 2);
3023 gdk_gc_set_clip_rectangle (light_gc, &dest);
3024 gdk_gc_set_clip_rectangle (dark_gc, &dest);
3026 for (yy = y + ythick; yy < (y + height - ythick); yy += 3)
3027 for (xx = x + xthick; xx < (x + width - xthick); xx += 6)
3029 gdk_draw_point (window, light_gc, xx, yy);
3030 gdk_draw_point (window, dark_gc, xx + 1, yy + 1);
3032 gdk_draw_point (window, light_gc, xx + 3, yy + 1);
3033 gdk_draw_point (window, dark_gc, xx + 4, yy + 2);
3035 gdk_gc_set_clip_rectangle (light_gc, NULL);
3036 gdk_gc_set_clip_rectangle (dark_gc, NULL);
3040 gtk_style_shade (GdkColor *a,
3048 red = (gdouble) a->red / 65535.0;
3049 green = (gdouble) a->green / 65535.0;
3050 blue = (gdouble) a->blue / 65535.0;
3052 rgb_to_hls (&red, &green, &blue);
3057 else if (green < 0.0)
3063 else if (blue < 0.0)
3066 hls_to_rgb (&red, &green, &blue);
3068 b->red = red * 65535.0;
3069 b->green = green * 65535.0;
3070 b->blue = blue * 65535.0;
3074 rgb_to_hls (gdouble *r,
3115 l = (max + min) / 2;
3122 s = (max - min) / (max + min);
3124 s = (max - min) / (2 - max - min);
3128 h = (green - blue) / delta;
3129 else if (green == max)
3130 h = 2 + (blue - red) / delta;
3131 else if (blue == max)
3132 h = 4 + (red - green) / delta;
3145 hls_to_rgb (gdouble *h,
3158 if (lightness <= 0.5)
3159 m2 = lightness * (1 + saturation);
3161 m2 = lightness + saturation - lightness * saturation;
3162 m1 = 2 * lightness - m2;
3164 if (saturation == 0)
3179 r = m1 + (m2 - m1) * hue / 60;
3183 r = m1 + (m2 - m1) * (240 - hue) / 60;
3194 g = m1 + (m2 - m1) * hue / 60;
3198 g = m1 + (m2 - m1) * (240 - hue) / 60;
3209 b = m1 + (m2 - m1) * hue / 60;
3213 b = m1 + (m2 - m1) * (240 - hue) / 60;
3224 gtk_paint_hline (GtkStyle *style,
3226 GtkStateType state_type,
3234 g_return_if_fail (style != NULL);
3235 g_return_if_fail (style->klass != NULL);
3236 g_return_if_fail (style->klass->draw_hline != NULL);
3238 (*style->klass->draw_hline) (style, window, state_type, area, widget, detail, x1, x2, y);
3242 gtk_paint_vline (GtkStyle *style,
3244 GtkStateType state_type,
3252 g_return_if_fail (style != NULL);
3253 g_return_if_fail (style->klass != NULL);
3254 g_return_if_fail (style->klass->draw_vline != NULL);
3256 (*style->klass->draw_vline) (style, window, state_type, area, widget, detail, y1, y2, x);
3260 gtk_paint_shadow (GtkStyle *style,
3262 GtkStateType state_type,
3263 GtkShadowType shadow_type,
3272 g_return_if_fail (style != NULL);
3273 g_return_if_fail (style->klass != NULL);
3274 g_return_if_fail (style->klass->draw_shadow != NULL);
3276 (*style->klass->draw_shadow) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3280 gtk_paint_polygon (GtkStyle *style,
3282 GtkStateType state_type,
3283 GtkShadowType shadow_type,
3291 g_return_if_fail (style != NULL);
3292 g_return_if_fail (style->klass != NULL);
3293 g_return_if_fail (style->klass->draw_shadow != NULL);
3295 (*style->klass->draw_polygon) (style, window, state_type, shadow_type, area, widget, detail, points, npoints, fill);
3299 gtk_paint_arrow (GtkStyle *style,
3301 GtkStateType state_type,
3302 GtkShadowType shadow_type,
3306 GtkArrowType arrow_type,
3313 g_return_if_fail (style != NULL);
3314 g_return_if_fail (style->klass != NULL);
3315 g_return_if_fail (style->klass->draw_arrow != NULL);
3317 (*style->klass->draw_arrow) (style, window, state_type, shadow_type, area, widget, detail, arrow_type, fill, x, y, width, height);
3321 gtk_paint_diamond (GtkStyle *style,
3323 GtkStateType state_type,
3324 GtkShadowType shadow_type,
3333 g_return_if_fail (style != NULL);
3334 g_return_if_fail (style->klass != NULL);
3335 g_return_if_fail (style->klass->draw_diamond != NULL);
3337 (*style->klass->draw_diamond) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3341 gtk_paint_oval (GtkStyle *style,
3343 GtkStateType state_type,
3344 GtkShadowType shadow_type,
3353 g_return_if_fail (style != NULL);
3354 g_return_if_fail (style->klass != NULL);
3355 g_return_if_fail (style->klass->draw_oval != NULL);
3357 (*style->klass->draw_oval) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3361 gtk_paint_string (GtkStyle *style,
3363 GtkStateType state_type,
3369 const gchar *string)
3371 g_return_if_fail (style != NULL);
3372 g_return_if_fail (style->klass != NULL);
3373 g_return_if_fail (style->klass->draw_oval != NULL);
3375 (*style->klass->draw_string) (style, window, state_type, area, widget, detail, x, y, string);
3379 gtk_paint_box (GtkStyle *style,
3381 GtkStateType state_type,
3382 GtkShadowType shadow_type,
3391 g_return_if_fail (style != NULL);
3392 g_return_if_fail (style->klass != NULL);
3393 g_return_if_fail (style->klass->draw_box != NULL);
3395 (*style->klass->draw_box) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3399 gtk_paint_flat_box (GtkStyle *style,
3401 GtkStateType state_type,
3402 GtkShadowType shadow_type,
3411 g_return_if_fail (style != NULL);
3412 g_return_if_fail (style->klass != NULL);
3413 g_return_if_fail (style->klass->draw_flat_box != NULL);
3415 (*style->klass->draw_flat_box) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3419 gtk_paint_check (GtkStyle *style,
3421 GtkStateType state_type,
3422 GtkShadowType shadow_type,
3431 g_return_if_fail (style != NULL);
3432 g_return_if_fail (style->klass != NULL);
3433 g_return_if_fail (style->klass->draw_check != NULL);
3435 (*style->klass->draw_check) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3439 gtk_paint_option (GtkStyle *style,
3441 GtkStateType state_type,
3442 GtkShadowType shadow_type,
3451 g_return_if_fail (style != NULL);
3452 g_return_if_fail (style->klass != NULL);
3453 g_return_if_fail (style->klass->draw_option != NULL);
3455 (*style->klass->draw_option) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3459 gtk_paint_cross (GtkStyle *style,
3461 GtkStateType state_type,
3462 GtkShadowType shadow_type,
3471 g_return_if_fail (style != NULL);
3472 g_return_if_fail (style->klass != NULL);
3473 g_return_if_fail (style->klass->draw_cross != NULL);
3475 (*style->klass->draw_cross) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3479 gtk_paint_ramp (GtkStyle *style,
3481 GtkStateType state_type,
3482 GtkShadowType shadow_type,
3486 GtkArrowType arrow_type,
3492 g_return_if_fail (style != NULL);
3493 g_return_if_fail (style->klass != NULL);
3494 g_return_if_fail (style->klass->draw_ramp != NULL);
3496 (*style->klass->draw_ramp) (style, window, state_type, shadow_type, area, widget, detail, arrow_type, x, y, width, height);
3500 gtk_paint_tab (GtkStyle *style,
3502 GtkStateType state_type,
3503 GtkShadowType shadow_type,
3512 g_return_if_fail (style != NULL);
3513 g_return_if_fail (style->klass != NULL);
3514 g_return_if_fail (style->klass->draw_tab != NULL);
3516 (*style->klass->draw_tab) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3520 gtk_paint_shadow_gap (GtkStyle *style,
3522 GtkStateType state_type,
3523 GtkShadowType shadow_type,
3531 GtkPositionType gap_side,
3535 g_return_if_fail (style != NULL);
3536 g_return_if_fail (style->klass != NULL);
3537 g_return_if_fail (style->klass->draw_shadow_gap != NULL);
3539 (*style->klass->draw_shadow_gap) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
3544 gtk_paint_box_gap (GtkStyle *style,
3546 GtkStateType state_type,
3547 GtkShadowType shadow_type,
3555 GtkPositionType gap_side,
3559 g_return_if_fail (style != NULL);
3560 g_return_if_fail (style->klass != NULL);
3561 g_return_if_fail (style->klass->draw_box_gap != NULL);
3563 (*style->klass->draw_box_gap) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
3567 gtk_paint_extension (GtkStyle *style,
3569 GtkStateType state_type,
3570 GtkShadowType shadow_type,
3578 GtkPositionType gap_side)
3580 g_return_if_fail (style != NULL);
3581 g_return_if_fail (style->klass != NULL);
3582 g_return_if_fail (style->klass->draw_extension != NULL);
3584 (*style->klass->draw_extension) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side);
3588 gtk_paint_focus (GtkStyle *style,
3598 g_return_if_fail (style != NULL);
3599 g_return_if_fail (style->klass != NULL);
3600 g_return_if_fail (style->klass->draw_focus != NULL);
3602 (*style->klass->draw_focus) (style, window, area, widget, detail, x, y, width, height);
3606 gtk_paint_slider (GtkStyle *style,
3608 GtkStateType state_type,
3609 GtkShadowType shadow_type,
3617 GtkOrientation orientation)
3619 g_return_if_fail (style != NULL);
3620 g_return_if_fail (style->klass != NULL);
3621 g_return_if_fail (style->klass->draw_slider != NULL);
3623 (*style->klass->draw_slider) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
3627 gtk_paint_handle (GtkStyle *style,
3629 GtkStateType state_type,
3630 GtkShadowType shadow_type,
3638 GtkOrientation orientation)
3640 g_return_if_fail (style != NULL);
3641 g_return_if_fail (style->klass != NULL);
3642 g_return_if_fail (style->klass->draw_handle != NULL);
3644 (*style->klass->draw_handle) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);