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.
21 * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
32 #include "gtkwidget.h"
33 #include "gtkthemes.h"
36 #define LIGHTNESS_MULT 1.3
37 #define DARKNESS_MULT 0.7
39 /* actually glib should do that for us */
41 #define M_PI 3.14159265358979323846
44 #define M_PI_4 0.78539816339744830962
47 static void gtk_style_init (GtkStyle *style,
48 GdkColormap *colormap,
50 static void gtk_style_destroy (GtkStyle *style);
52 static void gtk_default_draw_hline (GtkStyle *style,
54 GtkStateType state_type,
61 static void gtk_default_draw_vline (GtkStyle *style,
63 GtkStateType state_type,
70 static void gtk_default_draw_shadow (GtkStyle *style,
72 GtkStateType state_type,
73 GtkShadowType shadow_type,
81 static void gtk_default_draw_shadow (GtkStyle *style,
83 GtkStateType state_type,
84 GtkShadowType shadow_type,
92 static void gtk_default_draw_polygon (GtkStyle *style,
94 GtkStateType state_type,
95 GtkShadowType shadow_type,
102 static void gtk_default_draw_arrow (GtkStyle *style,
104 GtkStateType state_type,
105 GtkShadowType shadow_type,
109 GtkArrowType arrow_type,
115 static void gtk_default_draw_diamond (GtkStyle *style,
117 GtkStateType state_type,
118 GtkShadowType shadow_type,
126 static void gtk_default_draw_oval (GtkStyle *style,
128 GtkStateType state_type,
129 GtkShadowType shadow_type,
137 static void gtk_default_draw_string (GtkStyle *style,
139 GtkStateType state_type,
145 const gchar *string);
146 static void gtk_default_draw_box (GtkStyle *style,
148 GtkStateType state_type,
149 GtkShadowType shadow_type,
157 static void gtk_default_draw_flat_box (GtkStyle *style,
159 GtkStateType state_type,
160 GtkShadowType shadow_type,
168 static void gtk_default_draw_check (GtkStyle *style,
170 GtkStateType state_type,
171 GtkShadowType shadow_type,
179 static void gtk_default_draw_option (GtkStyle *style,
181 GtkStateType state_type,
182 GtkShadowType shadow_type,
190 static void gtk_default_draw_cross (GtkStyle *style,
192 GtkStateType state_type,
193 GtkShadowType shadow_type,
201 static void gtk_default_draw_ramp (GtkStyle *style,
203 GtkStateType state_type,
204 GtkShadowType shadow_type,
208 GtkArrowType arrow_type,
213 static void gtk_default_draw_tab (GtkStyle *style,
215 GtkStateType state_type,
216 GtkShadowType shadow_type,
224 static void gtk_default_draw_shadow_gap (GtkStyle *style,
226 GtkStateType state_type,
227 GtkShadowType shadow_type,
235 GtkPositionType gap_side,
238 static void gtk_default_draw_box_gap (GtkStyle *style,
240 GtkStateType state_type,
241 GtkShadowType shadow_type,
249 GtkPositionType gap_side,
252 static void gtk_default_draw_extension (GtkStyle *style,
254 GtkStateType state_type,
255 GtkShadowType shadow_type,
263 GtkPositionType gap_side);
264 static void gtk_default_draw_focus (GtkStyle *style,
273 static void gtk_default_draw_slider (GtkStyle *style,
275 GtkStateType state_type,
276 GtkShadowType shadow_type,
284 GtkOrientation orientation);
285 static void gtk_default_draw_handle (GtkStyle *style,
287 GtkStateType state_type,
288 GtkShadowType shadow_type,
296 GtkOrientation orientation);
298 static void gtk_style_shade (GdkColor *a, GdkColor *b, gdouble k);
299 static void rgb_to_hls (gdouble *r, gdouble *g, gdouble *b);
300 static void hls_to_rgb (gdouble *h, gdouble *l, gdouble *s);
303 static const GtkStyleClass default_class =
307 gtk_default_draw_hline,
308 gtk_default_draw_vline,
309 gtk_default_draw_shadow,
310 gtk_default_draw_polygon,
311 gtk_default_draw_arrow,
312 gtk_default_draw_diamond,
313 gtk_default_draw_oval,
314 gtk_default_draw_string,
315 gtk_default_draw_box,
316 gtk_default_draw_flat_box,
317 gtk_default_draw_check,
318 gtk_default_draw_option,
319 gtk_default_draw_cross,
320 gtk_default_draw_ramp,
321 gtk_default_draw_tab,
322 gtk_default_draw_shadow_gap,
323 gtk_default_draw_box_gap,
324 gtk_default_draw_extension,
325 gtk_default_draw_focus,
326 gtk_default_draw_slider,
327 gtk_default_draw_handle
329 GdkFont *default_font = NULL;
331 static GdkColor gtk_default_normal_fg = { 0, 0, 0, 0 };
332 static GdkColor gtk_default_active_fg = { 0, 0, 0, 0 };
333 static GdkColor gtk_default_prelight_fg = { 0, 0, 0, 0 };
334 static GdkColor gtk_default_selected_fg = { 0, 0xffff, 0xffff, 0xffff };
335 static GdkColor gtk_default_insensitive_fg = { 0, 0x7530, 0x7530, 0x7530 };
337 static GdkColor gtk_default_normal_bg = { 0, 0xd6d6, 0xd6d6, 0xd6d6 };
338 static GdkColor gtk_default_active_bg = { 0, 0xc350, 0xc350, 0xc350 };
339 static GdkColor gtk_default_prelight_bg = { 0, 0xea60, 0xea60, 0xea60 };
340 static GdkColor gtk_default_selected_bg = { 0, 0, 0, 0x9c40 };
341 static GdkColor gtk_default_insensitive_bg = { 0, 0xd6d6, 0xd6d6, 0xd6d6 };
344 gtk_style_copy (GtkStyle *style)
349 g_return_val_if_fail (style != NULL, NULL);
351 new_style = gtk_style_new ();
353 for (i = 0; i < 5; i++)
355 new_style->fg[i] = style->fg[i];
356 new_style->bg[i] = style->bg[i];
357 new_style->text[i] = style->text[i];
358 new_style->base[i] = style->base[i];
360 new_style->bg_pixmap[i] = style->bg_pixmap[i];
363 gdk_font_unref (new_style->font);
364 new_style->font = style->font;
365 gdk_font_ref (new_style->font);
369 new_style->rc_style = style->rc_style;
370 gtk_rc_style_ref (style->rc_style);
375 new_style->engine = style->engine;
376 gtk_theme_engine_ref (new_style->engine);
377 new_style->engine->duplicate_style (new_style, style);
384 gtk_style_duplicate (GtkStyle *style)
388 g_return_val_if_fail (style != NULL, NULL);
390 new_style = gtk_style_copy (style);
392 style->styles = g_slist_append (style->styles, new_style);
393 new_style->styles = style->styles;
404 style = g_new0 (GtkStyle, 1);
409 gdk_font_load ("-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-iso8859-1");
411 default_font = gdk_font_load ("fixed");
413 g_error ("Unable to load default font.");
416 style->font = default_font;
417 gdk_font_ref (style->font);
419 style->ref_count = 1;
420 style->attach_count = 0;
421 style->colormap = NULL;
423 style->klass = (GtkStyleClass *)&default_class;
425 style->black.red = 0;
426 style->black.green = 0;
427 style->black.blue = 0;
429 style->white.red = 65535;
430 style->white.green = 65535;
431 style->white.blue = 65535;
433 style->black_gc = NULL;
434 style->white_gc = NULL;
436 style->fg[GTK_STATE_NORMAL] = gtk_default_normal_fg;
437 style->fg[GTK_STATE_ACTIVE] = gtk_default_active_fg;
438 style->fg[GTK_STATE_PRELIGHT] = gtk_default_prelight_fg;
439 style->fg[GTK_STATE_SELECTED] = gtk_default_selected_fg;
440 style->fg[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_fg;
442 style->bg[GTK_STATE_NORMAL] = gtk_default_normal_bg;
443 style->bg[GTK_STATE_ACTIVE] = gtk_default_active_bg;
444 style->bg[GTK_STATE_PRELIGHT] = gtk_default_prelight_bg;
445 style->bg[GTK_STATE_SELECTED] = gtk_default_selected_bg;
446 style->bg[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_bg;
448 for (i = 0; i < 4; i++)
450 style->text[i] = style->fg[i];
451 style->base[i] = style->white;
454 style->base[GTK_STATE_INSENSITIVE] = gtk_default_prelight_bg;
455 style->text[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_fg;
457 for (i = 0; i < 5; i++)
458 style->bg_pixmap[i] = NULL;
460 style->engine = NULL;
461 style->engine_data = NULL;
463 style->rc_style = NULL;
465 for (i = 0; i < 5; i++)
467 style->fg_gc[i] = NULL;
468 style->bg_gc[i] = NULL;
469 style->light_gc[i] = NULL;
470 style->dark_gc[i] = NULL;
471 style->mid_gc[i] = NULL;
472 style->text_gc[i] = NULL;
473 style->base_gc[i] = NULL;
479 /*************************************************************
481 * Attach a style to a window; this process allocates the
482 * colors and creates the GC's for the style - it specializes
483 * it to a particular visual and colormap. The process
484 * may involve the creation of a new style if the style
485 * has already been attached to a window with a different
486 * style and colormap.
491 * Either the style parameter, or a newly created style.
492 * If the style is newly created, the style parameter
493 * will be dereferenced, and the new style will have
494 * a reference count belonging to the caller.
496 * FIXME: The sequence -
497 * create a style => s1
498 * attach s1 to v1, c1 => s1
499 * attach s1 to v2, c2 => s2
500 * detach s1 from v1, c1
501 * attach s1 to v2, c2 => s3
502 * results in two separate, unlinked styles s2 and s3 which
503 * are identical and could be shared. To fix this, we would
504 * want to never remove a style from the list of linked
505 * styles as long as as it has a reference count. However, the
506 * disadvantage of doing it this way means that we would need two
507 * passes through the linked list when attaching (one to check for
508 * matching styles, one to look for empty unattached styles - but
509 * it will almost never be longer than 2 elements.
510 *************************************************************/
513 gtk_style_attach (GtkStyle *style,
517 GtkStyle *new_style = NULL;
518 GdkColormap *colormap;
521 g_return_val_if_fail (style != NULL, NULL);
522 g_return_val_if_fail (window != NULL, NULL);
524 colormap = gdk_window_get_colormap (window);
525 depth = gdk_window_get_visual (window)->depth;
528 style->styles = g_slist_append (NULL, style);
530 styles = style->styles;
533 new_style = styles->data;
535 if (new_style->attach_count == 0)
537 gtk_style_init (new_style, colormap, depth);
540 else if (new_style->colormap == colormap &&
541 new_style->depth == depth)
545 styles = styles->next;
550 new_style = gtk_style_duplicate (style);
551 gtk_style_init (new_style, colormap, depth);
554 /* A style gets a refcount from being attached */
555 if (new_style->attach_count == 0)
556 gtk_style_ref (new_style);
558 /* Another refcount belongs to the parent */
559 if (style != new_style)
561 gtk_style_unref (style);
562 gtk_style_ref (new_style);
565 new_style->attach_count++;
571 gtk_style_detach (GtkStyle *style)
575 g_return_if_fail (style != NULL);
577 style->attach_count -= 1;
578 if (style->attach_count == 0)
581 style->engine->unrealize_style (style);
583 gtk_gc_release (style->black_gc);
584 gtk_gc_release (style->white_gc);
586 for (i = 0; i < 5; i++)
588 gtk_gc_release (style->fg_gc[i]);
589 gtk_gc_release (style->bg_gc[i]);
590 gtk_gc_release (style->light_gc[i]);
591 gtk_gc_release (style->dark_gc[i]);
592 gtk_gc_release (style->mid_gc[i]);
593 gtk_gc_release (style->text_gc[i]);
594 gtk_gc_release (style->base_gc[i]);
597 gtk_style_unref (style);
602 gtk_style_ref (GtkStyle *style)
604 g_return_val_if_fail (style != NULL, NULL);
605 g_return_val_if_fail (style->ref_count > 0, NULL);
607 style->ref_count += 1;
612 gtk_style_unref (GtkStyle *style)
614 g_return_if_fail (style != NULL);
615 g_return_if_fail (style->ref_count > 0);
617 style->ref_count -= 1;
618 if (style->ref_count == 0)
619 gtk_style_destroy (style);
623 gtk_style_init (GtkStyle *style,
624 GdkColormap *colormap,
627 GdkGCValues gc_values;
628 GdkGCValuesMask gc_values_mask;
631 g_return_if_fail (style != NULL);
633 style->colormap = colormap;
634 style->depth = depth;
636 for (i = 0; i < 5; i++)
638 gtk_style_shade (&style->bg[i], &style->light[i], LIGHTNESS_MULT);
639 gtk_style_shade (&style->bg[i], &style->dark[i], DARKNESS_MULT);
641 style->mid[i].red = (style->light[i].red + style->dark[i].red) / 2;
642 style->mid[i].green = (style->light[i].green + style->dark[i].green) / 2;
643 style->mid[i].blue = (style->light[i].blue + style->dark[i].blue) / 2;
646 gdk_color_black (colormap, &style->black);
647 gdk_color_white (colormap, &style->white);
649 gc_values_mask = GDK_GC_FOREGROUND | GDK_GC_FONT;
650 if (style->font->type == GDK_FONT_FONT)
652 gc_values.font = style->font;
654 else if (style->font->type == GDK_FONT_FONTSET)
656 gc_values.font = default_font;
659 gc_values.foreground = style->black;
660 style->black_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
662 gc_values.foreground = style->white;
663 style->white_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
665 for (i = 0; i < 5; i++)
667 if (style->rc_style && style->rc_style->bg_pixmap_name[i])
668 style->bg_pixmap[i] = gtk_rc_load_image (style->colormap,
670 style->rc_style->bg_pixmap_name[i]);
672 if (!gdk_color_alloc (colormap, &style->fg[i]))
673 g_warning ("unable to allocate color: ( %d %d %d )",
674 style->fg[i].red, style->fg[i].green, style->fg[i].blue);
675 if (!gdk_color_alloc (colormap, &style->bg[i]))
676 g_warning ("unable to allocate color: ( %d %d %d )",
677 style->bg[i].red, style->bg[i].green, style->bg[i].blue);
678 if (!gdk_color_alloc (colormap, &style->light[i]))
679 g_warning ("unable to allocate color: ( %d %d %d )",
680 style->light[i].red, style->light[i].green, style->light[i].blue);
681 if (!gdk_color_alloc (colormap, &style->dark[i]))
682 g_warning ("unable to allocate color: ( %d %d %d )",
683 style->dark[i].red, style->dark[i].green, style->dark[i].blue);
684 if (!gdk_color_alloc (colormap, &style->mid[i]))
685 g_warning ("unable to allocate color: ( %d %d %d )",
686 style->mid[i].red, style->mid[i].green, style->mid[i].blue);
687 if (!gdk_color_alloc (colormap, &style->text[i]))
688 g_warning ("unable to allocate color: ( %d %d %d )",
689 style->text[i].red, style->text[i].green, style->text[i].blue);
690 if (!gdk_color_alloc (colormap, &style->base[i]))
691 g_warning ("unable to allocate color: ( %d %d %d )",
692 style->base[i].red, style->base[i].green, style->base[i].blue);
694 gc_values.foreground = style->fg[i];
695 style->fg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
697 gc_values.foreground = style->bg[i];
698 style->bg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
700 gc_values.foreground = style->light[i];
701 style->light_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
703 gc_values.foreground = style->dark[i];
704 style->dark_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
706 gc_values.foreground = style->mid[i];
707 style->mid_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
709 gc_values.foreground = style->text[i];
710 style->text_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
712 gc_values.foreground = style->base[i];
713 style->base_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
717 style->engine->realize_style (style);
721 gtk_style_destroy (GtkStyle *style)
723 g_return_if_fail (style->attach_count == 0);
727 if (style->styles->data != style)
728 g_slist_remove (style->styles, style);
731 GSList *tmp_list = style->styles->next;
735 ((GtkStyle*) tmp_list->data)->styles = style->styles->next;
736 tmp_list = tmp_list->next;
738 g_slist_free_1 (style->styles);
744 style->engine->destroy_style (style);
745 gtk_theme_engine_unref (style->engine);
748 gdk_font_unref (style->font);
750 gtk_rc_style_unref (style->rc_style);
756 gtk_draw_hline (GtkStyle *style,
758 GtkStateType state_type,
763 g_return_if_fail (style != NULL);
764 g_return_if_fail (style->klass != NULL);
765 g_return_if_fail (style->klass->draw_hline != NULL);
767 style->klass->draw_hline (style, window, state_type, NULL, NULL, NULL, x1, x2, y);
772 gtk_draw_vline (GtkStyle *style,
774 GtkStateType state_type,
779 g_return_if_fail (style != NULL);
780 g_return_if_fail (style->klass != NULL);
781 g_return_if_fail (style->klass->draw_vline != NULL);
783 style->klass->draw_vline (style, window, state_type, NULL, NULL, NULL, y1, y2, x);
788 gtk_draw_shadow (GtkStyle *style,
790 GtkStateType state_type,
791 GtkShadowType shadow_type,
797 g_return_if_fail (style != NULL);
798 g_return_if_fail (style->klass != NULL);
799 g_return_if_fail (style->klass->draw_shadow != NULL);
801 style->klass->draw_shadow (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
805 gtk_draw_polygon (GtkStyle *style,
807 GtkStateType state_type,
808 GtkShadowType shadow_type,
813 g_return_if_fail (style != NULL);
814 g_return_if_fail (style->klass != NULL);
815 g_return_if_fail (style->klass->draw_polygon != NULL);
817 style->klass->draw_polygon (style, window, state_type, shadow_type, NULL, NULL, NULL, points, npoints, fill);
821 gtk_draw_arrow (GtkStyle *style,
823 GtkStateType state_type,
824 GtkShadowType shadow_type,
825 GtkArrowType arrow_type,
832 g_return_if_fail (style != NULL);
833 g_return_if_fail (style->klass != NULL);
834 g_return_if_fail (style->klass->draw_arrow != NULL);
836 style->klass->draw_arrow (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, fill, x, y, width, height);
841 gtk_draw_diamond (GtkStyle *style,
843 GtkStateType state_type,
844 GtkShadowType shadow_type,
850 g_return_if_fail (style != NULL);
851 g_return_if_fail (style->klass != NULL);
852 g_return_if_fail (style->klass->draw_diamond != NULL);
854 style->klass->draw_diamond (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
859 gtk_draw_oval (GtkStyle *style,
861 GtkStateType state_type,
862 GtkShadowType shadow_type,
868 g_return_if_fail (style != NULL);
869 g_return_if_fail (style->klass != NULL);
870 g_return_if_fail (style->klass->draw_oval != NULL);
872 style->klass->draw_oval (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
876 gtk_draw_string (GtkStyle *style,
878 GtkStateType state_type,
883 g_return_if_fail (style != NULL);
884 g_return_if_fail (style->klass != NULL);
885 g_return_if_fail (style->klass->draw_string != NULL);
887 style->klass->draw_string (style, window, state_type, NULL, NULL, NULL, x, y, string);
891 gtk_draw_box (GtkStyle *style,
893 GtkStateType state_type,
894 GtkShadowType shadow_type,
900 g_return_if_fail (style != NULL);
901 g_return_if_fail (style->klass != NULL);
902 g_return_if_fail (style->klass->draw_box != NULL);
904 style->klass->draw_box (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
908 gtk_draw_flat_box (GtkStyle *style,
910 GtkStateType state_type,
911 GtkShadowType shadow_type,
917 g_return_if_fail (style != NULL);
918 g_return_if_fail (style->klass != NULL);
919 g_return_if_fail (style->klass->draw_flat_box != NULL);
921 style->klass->draw_flat_box (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
925 gtk_draw_check (GtkStyle *style,
927 GtkStateType state_type,
928 GtkShadowType shadow_type,
934 g_return_if_fail (style != NULL);
935 g_return_if_fail (style->klass != NULL);
936 g_return_if_fail (style->klass->draw_check != NULL);
938 style->klass->draw_check (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
942 gtk_draw_option (GtkStyle *style,
944 GtkStateType state_type,
945 GtkShadowType shadow_type,
951 g_return_if_fail (style != NULL);
952 g_return_if_fail (style->klass != NULL);
953 g_return_if_fail (style->klass->draw_option != NULL);
955 style->klass->draw_option (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
959 gtk_draw_cross (GtkStyle *style,
961 GtkStateType state_type,
962 GtkShadowType shadow_type,
968 g_return_if_fail (style != NULL);
969 g_return_if_fail (style->klass != NULL);
970 g_return_if_fail (style->klass->draw_cross != NULL);
972 style->klass->draw_cross (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
976 gtk_draw_ramp (GtkStyle *style,
978 GtkStateType state_type,
979 GtkShadowType shadow_type,
980 GtkArrowType arrow_type,
986 g_return_if_fail (style != NULL);
987 g_return_if_fail (style->klass != NULL);
988 g_return_if_fail (style->klass->draw_ramp != NULL);
990 style->klass->draw_ramp (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, x, y, width, height);
994 gtk_draw_tab (GtkStyle *style,
996 GtkStateType state_type,
997 GtkShadowType shadow_type,
1003 g_return_if_fail (style != NULL);
1004 g_return_if_fail (style->klass != NULL);
1005 g_return_if_fail (style->klass->draw_tab != NULL);
1007 style->klass->draw_tab (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
1011 gtk_draw_shadow_gap (GtkStyle *style,
1013 GtkStateType state_type,
1014 GtkShadowType shadow_type,
1019 GtkPositionType gap_side,
1023 g_return_if_fail (style != NULL);
1024 g_return_if_fail (style->klass != NULL);
1025 g_return_if_fail (style->klass->draw_shadow_gap != NULL);
1027 style->klass->draw_shadow_gap (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width);
1031 gtk_draw_box_gap (GtkStyle *style,
1033 GtkStateType state_type,
1034 GtkShadowType shadow_type,
1039 GtkPositionType gap_side,
1043 g_return_if_fail (style != NULL);
1044 g_return_if_fail (style->klass != NULL);
1045 g_return_if_fail (style->klass->draw_box_gap != NULL);
1047 style->klass->draw_box_gap (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width);
1051 gtk_draw_extension (GtkStyle *style,
1053 GtkStateType state_type,
1054 GtkShadowType shadow_type,
1059 GtkPositionType gap_side)
1061 g_return_if_fail (style != NULL);
1062 g_return_if_fail (style->klass != NULL);
1063 g_return_if_fail (style->klass->draw_extension != NULL);
1065 style->klass->draw_extension (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side);
1069 gtk_draw_focus (GtkStyle *style,
1076 g_return_if_fail (style != NULL);
1077 g_return_if_fail (style->klass != NULL);
1078 g_return_if_fail (style->klass->draw_focus != NULL);
1080 style->klass->draw_focus (style, window, NULL, NULL, NULL, x, y, width, height);
1084 gtk_draw_slider (GtkStyle *style,
1086 GtkStateType state_type,
1087 GtkShadowType shadow_type,
1092 GtkOrientation orientation)
1094 g_return_if_fail (style != NULL);
1095 g_return_if_fail (style->klass != NULL);
1096 g_return_if_fail (style->klass->draw_slider != NULL);
1098 style->klass->draw_slider (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
1102 gtk_draw_handle (GtkStyle *style,
1104 GtkStateType state_type,
1105 GtkShadowType shadow_type,
1110 GtkOrientation orientation)
1112 g_return_if_fail (style != NULL);
1113 g_return_if_fail (style->klass != NULL);
1114 g_return_if_fail (style->klass->draw_handle != NULL);
1116 style->klass->draw_handle (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
1120 gtk_style_set_background (GtkStyle *style,
1122 GtkStateType state_type)
1125 gint parent_relative;
1127 g_return_if_fail (style != NULL);
1128 g_return_if_fail (window != NULL);
1130 if (style->engine && style->engine->set_background)
1132 style->engine->set_background (style, window, state_type);
1137 if (style->bg_pixmap[state_type])
1139 if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
1142 parent_relative = TRUE;
1146 pixmap = style->bg_pixmap[state_type];
1147 parent_relative = FALSE;
1150 gdk_window_set_back_pixmap (window, pixmap, parent_relative);
1153 gdk_window_set_background (window, &style->bg[state_type]);
1157 /* Default functions */
1159 gtk_style_apply_default_background (GtkStyle *style,
1162 GtkStateType state_type,
1169 GdkRectangle new_rect, old_rect;
1175 old_rect.width = width;
1176 old_rect.height = height;
1178 if (!gdk_rectangle_intersect (area, &old_rect, &new_rect))
1185 new_rect.width = width;
1186 new_rect.height = height;
1189 if (!style->bg_pixmap[state_type] ||
1190 gdk_window_get_type (window) == GDK_WINDOW_PIXMAP ||
1191 (!set_bg && style->bg_pixmap[state_type] != (GdkPixmap*) GDK_PARENT_RELATIVE))
1193 GdkGC *gc = style->bg_gc[state_type];
1195 if (style->bg_pixmap[state_type])
1197 gdk_gc_set_fill (gc, GDK_TILED);
1198 gdk_gc_set_tile (gc, style->bg_pixmap[state_type]);
1201 gdk_draw_rectangle (window, gc, TRUE,
1202 new_rect.x, new_rect.y, new_rect.width, new_rect.height);
1203 if (style->bg_pixmap[state_type])
1204 gdk_gc_set_fill (gc, GDK_SOLID);
1210 if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
1211 gdk_window_set_back_pixmap (window, NULL, TRUE);
1213 gdk_window_set_back_pixmap (window, style->bg_pixmap[state_type], FALSE);
1216 gdk_window_clear_area (window,
1217 new_rect.x, new_rect.y,
1218 new_rect.width, new_rect.height);
1223 gtk_default_draw_hline (GtkStyle *style,
1225 GtkStateType state_type,
1228 const gchar *detail,
1233 gint thickness_light;
1234 gint thickness_dark;
1237 g_return_if_fail (style != NULL);
1238 g_return_if_fail (window != NULL);
1240 thickness_light = style->klass->ythickness / 2;
1241 thickness_dark = style->klass->ythickness - thickness_light;
1245 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1246 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1249 if (detail && !strcmp (detail, "label"))
1251 if (state_type == GTK_STATE_INSENSITIVE)
1252 gdk_draw_line (window, style->white_gc, x1 + 1, y + 1, x2 + 1, y + 1);
1253 gdk_draw_line (window, style->fg_gc[state_type], x1, y, x2, y);
1257 for (i = 0; i < thickness_dark; i++)
1259 gdk_draw_line (window, style->light_gc[state_type], x2 - i - 1, y + i, x2, y + i);
1260 gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x2 - i - 1, y + i);
1263 y += thickness_dark;
1264 for (i = 0; i < thickness_light; i++)
1266 gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x1 + thickness_light - i - 1, y + i);
1267 gdk_draw_line (window, style->light_gc[state_type], x1 + thickness_light - i - 1, y + i, x2, y + i);
1273 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
1274 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
1280 gtk_default_draw_vline (GtkStyle *style,
1282 GtkStateType state_type,
1285 const gchar *detail,
1290 gint thickness_light;
1291 gint thickness_dark;
1294 g_return_if_fail (style != NULL);
1295 g_return_if_fail (window != NULL);
1297 thickness_light = style->klass->xthickness / 2;
1298 thickness_dark = style->klass->xthickness - thickness_light;
1302 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1303 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1305 for (i = 0; i < thickness_dark; i++)
1307 gdk_draw_line (window, style->light_gc[state_type], x + i, y2 - i - 1, x + i, y2);
1308 gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y2 - i - 1);
1311 x += thickness_dark;
1312 for (i = 0; i < thickness_light; i++)
1314 gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y1 + thickness_light - i);
1315 gdk_draw_line (window, style->light_gc[state_type], x + i, y1 + thickness_light - i, x + i, y2);
1319 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
1320 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
1326 gtk_default_draw_shadow (GtkStyle *style,
1328 GtkStateType state_type,
1329 GtkShadowType shadow_type,
1332 const gchar *detail,
1340 gint thickness_light;
1341 gint thickness_dark;
1344 g_return_if_fail (style != NULL);
1345 g_return_if_fail (window != NULL);
1347 if ((width == -1) && (height == -1))
1348 gdk_window_get_size (window, &width, &height);
1349 else if (width == -1)
1350 gdk_window_get_size (window, &width, NULL);
1351 else if (height == -1)
1352 gdk_window_get_size (window, NULL, &height);
1354 switch (shadow_type)
1356 case GTK_SHADOW_NONE:
1359 case GTK_SHADOW_ETCHED_IN:
1360 gc1 = style->light_gc[state_type];
1361 gc2 = style->dark_gc[state_type];
1363 case GTK_SHADOW_OUT:
1364 case GTK_SHADOW_ETCHED_OUT:
1365 gc1 = style->dark_gc[state_type];
1366 gc2 = style->light_gc[state_type];
1372 gdk_gc_set_clip_rectangle (gc1, area);
1373 gdk_gc_set_clip_rectangle (gc2, area);
1374 if (shadow_type == GTK_SHADOW_IN ||
1375 shadow_type == GTK_SHADOW_OUT)
1377 gdk_gc_set_clip_rectangle (style->black_gc, area);
1378 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
1382 switch (shadow_type)
1384 case GTK_SHADOW_NONE:
1388 gdk_draw_line (window, gc1,
1389 x, y + height - 1, x + width - 1, y + height - 1);
1390 gdk_draw_line (window, gc1,
1391 x + width - 1, y, x + width - 1, y + height - 1);
1393 gdk_draw_line (window, style->bg_gc[state_type],
1394 x + 1, y + height - 2, x + width - 2, y + height - 2);
1395 gdk_draw_line (window, style->bg_gc[state_type],
1396 x + width - 2, y + 1, x + width - 2, y + height - 2);
1398 gdk_draw_line (window, style->black_gc,
1399 x + 1, y + 1, x + width - 2, y + 1);
1400 gdk_draw_line (window, style->black_gc,
1401 x + 1, y + 1, x + 1, y + height - 2);
1403 gdk_draw_line (window, gc2,
1404 x, y, x + width - 1, y);
1405 gdk_draw_line (window, gc2,
1406 x, y, x, y + height - 1);
1409 case GTK_SHADOW_OUT:
1410 gdk_draw_line (window, gc1,
1411 x + 1, y + height - 2, x + width - 2, y + height - 2);
1412 gdk_draw_line (window, gc1,
1413 x + width - 2, y + 1, x + width - 2, y + height - 2);
1415 gdk_draw_line (window, gc2,
1416 x, y, x + width - 1, y);
1417 gdk_draw_line (window, gc2,
1418 x, y, x, y + height - 1);
1420 gdk_draw_line (window, style->bg_gc[state_type],
1421 x + 1, y + 1, x + width - 2, y + 1);
1422 gdk_draw_line (window, style->bg_gc[state_type],
1423 x + 1, y + 1, x + 1, y + height - 2);
1425 gdk_draw_line (window, style->black_gc,
1426 x, y + height - 1, x + width - 1, y + height - 1);
1427 gdk_draw_line (window, style->black_gc,
1428 x + width - 1, y, x + width - 1, y + height - 1);
1431 case GTK_SHADOW_ETCHED_IN:
1432 case GTK_SHADOW_ETCHED_OUT:
1433 thickness_light = 1;
1436 for (i = 0; i < thickness_dark; i++)
1438 gdk_draw_line (window, gc1,
1442 y + height - i - 1);
1443 gdk_draw_line (window, gc1,
1447 y + height - i - 1);
1449 gdk_draw_line (window, gc2,
1454 gdk_draw_line (window, gc2,
1458 y + height - i - 2);
1461 for (i = 0; i < thickness_light; i++)
1463 gdk_draw_line (window, gc1,
1464 x + thickness_dark + i,
1465 y + thickness_dark + i,
1466 x + width - thickness_dark - i - 1,
1467 y + thickness_dark + i);
1468 gdk_draw_line (window, gc1,
1469 x + thickness_dark + i,
1470 y + thickness_dark + i,
1471 x + thickness_dark + i,
1472 y + height - thickness_dark - i - 1);
1474 gdk_draw_line (window, gc2,
1475 x + thickness_dark + i,
1476 y + height - thickness_light - i - 1,
1477 x + width - thickness_light - 1,
1478 y + height - thickness_light - i - 1);
1479 gdk_draw_line (window, gc2,
1480 x + width - thickness_light - i - 1,
1481 y + thickness_dark + i,
1482 x + width - thickness_light - i - 1,
1483 y + height - thickness_light - 1);
1489 gdk_gc_set_clip_rectangle (gc1, NULL);
1490 gdk_gc_set_clip_rectangle (gc2, NULL);
1491 if (shadow_type == GTK_SHADOW_IN ||
1492 shadow_type == GTK_SHADOW_OUT)
1494 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
1495 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
1501 gtk_default_draw_polygon (GtkStyle *style,
1503 GtkStateType state_type,
1504 GtkShadowType shadow_type,
1507 const gchar *detail,
1512 static const gdouble pi_over_4 = M_PI_4;
1513 static const gdouble pi_3_over_4 = M_PI_4 * 3;
1523 g_return_if_fail (style != NULL);
1524 g_return_if_fail (window != NULL);
1525 g_return_if_fail (points != NULL);
1527 switch (shadow_type)
1530 gc1 = style->bg_gc[state_type];
1531 gc2 = style->dark_gc[state_type];
1532 gc3 = style->light_gc[state_type];
1533 gc4 = style->black_gc;
1535 case GTK_SHADOW_ETCHED_IN:
1536 gc1 = style->light_gc[state_type];
1537 gc2 = style->dark_gc[state_type];
1538 gc3 = style->dark_gc[state_type];
1539 gc4 = style->light_gc[state_type];
1541 case GTK_SHADOW_OUT:
1542 gc1 = style->dark_gc[state_type];
1543 gc2 = style->light_gc[state_type];
1544 gc3 = style->black_gc;
1545 gc4 = style->bg_gc[state_type];
1547 case GTK_SHADOW_ETCHED_OUT:
1548 gc1 = style->dark_gc[state_type];
1549 gc2 = style->light_gc[state_type];
1550 gc3 = style->light_gc[state_type];
1551 gc4 = style->dark_gc[state_type];
1559 gdk_gc_set_clip_rectangle (gc1, area);
1560 gdk_gc_set_clip_rectangle (gc2, area);
1561 gdk_gc_set_clip_rectangle (gc3, area);
1562 gdk_gc_set_clip_rectangle (gc4, area);
1566 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, npoints);
1570 for (i = 0; i < npoints; i++)
1572 if ((points[i].x == points[i+1].x) &&
1573 (points[i].y == points[i+1].y))
1579 angle = atan2 (points[i+1].y - points[i].y,
1580 points[i+1].x - points[i].x);
1583 if ((angle > -pi_3_over_4) && (angle < pi_over_4))
1585 if (angle > -pi_over_4)
1596 gdk_draw_line (window, gc1,
1597 points[i].x-xadjust, points[i].y-yadjust,
1598 points[i+1].x-xadjust, points[i+1].y-yadjust);
1599 gdk_draw_line (window, gc3,
1600 points[i].x, points[i].y,
1601 points[i+1].x, points[i+1].y);
1605 if ((angle < -pi_3_over_4) || (angle > pi_3_over_4))
1616 gdk_draw_line (window, gc4,
1617 points[i].x+xadjust, points[i].y+yadjust,
1618 points[i+1].x+xadjust, points[i+1].y+yadjust);
1619 gdk_draw_line (window, gc2,
1620 points[i].x, points[i].y,
1621 points[i+1].x, points[i+1].y);
1627 gdk_gc_set_clip_rectangle (gc1, NULL);
1628 gdk_gc_set_clip_rectangle (gc2, NULL);
1629 gdk_gc_set_clip_rectangle (gc3, NULL);
1630 gdk_gc_set_clip_rectangle (gc4, NULL);
1635 gtk_default_draw_arrow (GtkStyle *style,
1637 GtkStateType state_type,
1638 GtkShadowType shadow_type,
1641 const gchar *detail,
1642 GtkArrowType arrow_type,
1657 g_return_if_fail (style != NULL);
1658 g_return_if_fail (window != NULL);
1660 switch (shadow_type)
1663 gc1 = style->bg_gc[state_type];
1664 gc2 = style->dark_gc[state_type];
1665 gc3 = style->light_gc[state_type];
1666 gc4 = style->black_gc;
1668 case GTK_SHADOW_OUT:
1669 gc1 = style->dark_gc[state_type];
1670 gc2 = style->light_gc[state_type];
1671 gc3 = style->black_gc;
1672 gc4 = style->bg_gc[state_type];
1674 case GTK_SHADOW_ETCHED_IN:
1675 gc1 = style->light_gc[state_type];
1676 gc2 = style->dark_gc[state_type];
1680 case GTK_SHADOW_ETCHED_OUT:
1681 gc1 = style->dark_gc[state_type];
1682 gc2 = style->light_gc[state_type];
1690 if ((width == -1) && (height == -1))
1691 gdk_window_get_size (window, &width, &height);
1692 else if (width == -1)
1693 gdk_window_get_size (window, &width, NULL);
1694 else if (height == -1)
1695 gdk_window_get_size (window, NULL, &height);
1697 half_width = width / 2;
1698 half_height = height / 2;
1702 gdk_gc_set_clip_rectangle (gc1, area);
1703 gdk_gc_set_clip_rectangle (gc2, area);
1706 gdk_gc_set_clip_rectangle (gc3, area);
1707 gdk_gc_set_clip_rectangle (gc4, area);
1716 points[0].x = x + half_width;
1719 points[1].y = y + height - 1;
1720 points[2].x = x + width - 1;
1721 points[2].y = y + height - 1;
1723 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1726 switch (shadow_type)
1729 case GTK_SHADOW_OUT:
1731 gdk_draw_line (window, gc1,
1732 x + 1, y + height - 2,
1733 x + width - 2, y + height - 2);
1734 gdk_draw_line (window, gc3,
1735 x + 0, y + height - 1,
1736 x + width - 1, y + height - 1);
1738 gdk_draw_line (window, gc1,
1739 x + width - 2, y + height - 1,
1740 x + half_width, y + 1);
1741 gdk_draw_line (window, gc3,
1742 x + width - 1, y + height - 1,
1745 gdk_draw_line (window, gc4,
1746 x + half_width, y + 1,
1747 x + 1, y + height - 1);
1748 gdk_draw_line (window, gc2,
1753 case GTK_SHADOW_ETCHED_IN:
1754 case GTK_SHADOW_ETCHED_OUT:
1755 gdk_draw_line (window, gc1,
1756 x + half_width, y + 1,
1757 x + 1, y + height - 1);
1758 gdk_draw_line (window, gc1,
1759 x + 1, y + height - 1,
1760 x + width - 1, y + height - 1);
1761 gdk_draw_line (window, gc1,
1762 x + width - 1, y + height - 1,
1763 x + half_width + 1, y + 1);
1765 points[0].x = x + half_width;
1768 points[1].y = y + height - 2;
1769 points[2].x = x + width - 2;
1770 points[2].y = y + height - 2;
1772 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1780 case GTK_ARROW_DOWN:
1783 points[0].x = x + width - 1;
1787 points[2].x = x + half_width;
1788 points[2].y = y + height - 1;
1790 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1792 switch (shadow_type)
1795 case GTK_SHADOW_OUT:
1796 gdk_draw_line (window, gc4,
1798 y + 1, x + 1, y + 1);
1799 gdk_draw_line (window, gc2,
1803 gdk_draw_line (window, gc4,
1805 x + half_width, y + height - 2);
1806 gdk_draw_line (window, gc2,
1808 x + half_width, y + height - 1);
1810 gdk_draw_line (window, gc1,
1811 x + half_width, y + height - 2,
1813 gdk_draw_line (window, gc3,
1814 x + half_width, y + height - 1,
1818 case GTK_SHADOW_ETCHED_IN:
1819 case GTK_SHADOW_ETCHED_OUT:
1820 gdk_draw_line (window, gc1,
1821 x + width - 1, y + 1,
1823 gdk_draw_line (window, gc1,
1825 x + half_width + 1, y + height - 1);
1826 gdk_draw_line (window, gc1,
1827 x + half_width + 1, y + height - 2,
1830 points[0].x = x + width - 2;
1834 points[2].x = x + half_width;
1835 points[2].y = y + height - 2;
1837 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1844 case GTK_ARROW_LEFT:
1848 points[0].y = y + half_height;
1849 points[1].x = x + width - 1;
1850 points[1].y = y + height - 1;
1851 points[2].x = x + width - 1;
1854 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1857 switch (shadow_type)
1860 case GTK_SHADOW_OUT:
1861 gdk_draw_line (window, gc1,
1862 x + 1, y + half_height,
1863 x + width - 1, y + height - 1);
1864 gdk_draw_line (window, gc3,
1866 x + width - 1, y + height - 1);
1868 gdk_draw_line (window, gc1,
1869 x + width - 2, y + height - 1,
1870 x + width - 2, y + 1);
1871 gdk_draw_line (window, gc3,
1872 x + width - 1, y + height - 1,
1875 gdk_draw_line (window, gc4,
1876 x + width - 1, y + 1,
1877 x + 1, y + half_height);
1878 gdk_draw_line (window, gc2,
1880 x, y + half_height);
1883 case GTK_SHADOW_ETCHED_IN:
1884 case GTK_SHADOW_ETCHED_OUT:
1885 gdk_draw_line (window, gc1,
1886 x + width - 1, y + 1,
1887 x + 1, y + half_height);
1888 gdk_draw_line (window, gc1,
1889 x + 1, y + half_height + 1,
1890 x + width - 1, y + height - 1);
1891 gdk_draw_line (window, gc1,
1892 x + width - 1, y + height - 1,
1893 x + width - 1, y + 1);
1895 points[0].x = x + width - 2;
1898 points[1].y = y + half_height;
1899 points[2].x = x + width - 2;
1900 points[2].y = y + height - 2;
1902 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1909 case GTK_ARROW_RIGHT:
1912 points[0].x = x + width - 1;
1913 points[0].y = y + half_height;
1917 points[2].y = y + height - 1;
1919 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1922 switch (shadow_type)
1925 case GTK_SHADOW_OUT:
1926 gdk_draw_line (window, gc4,
1927 x + width - 1, y + half_height,
1929 gdk_draw_line (window, gc2,
1930 x + width - 1, y + half_height,
1932 gdk_draw_line (window, gc4,
1934 x + 1, y + height - 2);
1935 gdk_draw_line (window, gc2,
1939 gdk_draw_line (window, gc1,
1940 x + 1, y + height - 2,
1941 x + width - 1, y + half_height);
1942 gdk_draw_line (window, gc3,
1944 x + width - 1, y + half_height);
1947 case GTK_SHADOW_ETCHED_IN:
1948 case GTK_SHADOW_ETCHED_OUT:
1949 gdk_draw_line (window, gc1,
1950 x + width - 1, y + half_height + 1,
1952 gdk_draw_line (window, gc1,
1954 x + 1, y + height - 1);
1955 gdk_draw_line (window, gc1,
1956 x + 1, y + height - 1,
1957 x + width - 1, y + half_height + 1);
1959 points[0].x = x + width - 2;
1960 points[0].y = y + half_height;
1964 points[2].y = y + height - 1;
1966 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1977 gdk_gc_set_clip_rectangle (gc1, NULL);
1978 gdk_gc_set_clip_rectangle (gc2, NULL);
1981 gdk_gc_set_clip_rectangle (gc3, NULL);
1982 gdk_gc_set_clip_rectangle (gc4, NULL);
1988 gtk_default_draw_diamond (GtkStyle *style,
1990 GtkStateType state_type,
1991 GtkShadowType shadow_type,
1994 const gchar *detail,
2003 g_return_if_fail (style != NULL);
2004 g_return_if_fail (window != NULL);
2006 if ((width == -1) && (height == -1))
2007 gdk_window_get_size (window, &width, &height);
2008 else if (width == -1)
2009 gdk_window_get_size (window, &width, NULL);
2010 else if (height == -1)
2011 gdk_window_get_size (window, NULL, &height);
2013 half_width = width / 2;
2014 half_height = height / 2;
2018 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
2019 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
2020 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
2021 gdk_gc_set_clip_rectangle (style->black_gc, area);
2023 switch (shadow_type)
2026 gdk_draw_line (window, style->bg_gc[state_type],
2027 x + 2, y + half_height,
2028 x + half_width, y + height - 2);
2029 gdk_draw_line (window, style->bg_gc[state_type],
2030 x + half_width, y + height - 2,
2031 x + width - 2, y + half_height);
2032 gdk_draw_line (window, style->light_gc[state_type],
2033 x + 1, y + half_height,
2034 x + half_width, y + height - 1);
2035 gdk_draw_line (window, style->light_gc[state_type],
2036 x + half_width, y + height - 1,
2037 x + width - 1, y + half_height);
2038 gdk_draw_line (window, style->light_gc[state_type],
2040 x + half_width, y + height);
2041 gdk_draw_line (window, style->light_gc[state_type],
2042 x + half_width, y + height,
2043 x + width, y + half_height);
2045 gdk_draw_line (window, style->black_gc,
2046 x + 2, y + half_height,
2047 x + half_width, y + 2);
2048 gdk_draw_line (window, style->black_gc,
2049 x + half_width, y + 2,
2050 x + width - 2, y + half_height);
2051 gdk_draw_line (window, style->dark_gc[state_type],
2052 x + 1, y + half_height,
2053 x + half_width, y + 1);
2054 gdk_draw_line (window, style->dark_gc[state_type],
2055 x + half_width, y + 1,
2056 x + width - 1, y + half_height);
2057 gdk_draw_line (window, style->dark_gc[state_type],
2060 gdk_draw_line (window, style->dark_gc[state_type],
2062 x + width, y + half_height);
2064 case GTK_SHADOW_OUT:
2065 gdk_draw_line (window, style->dark_gc[state_type],
2066 x + 2, y + half_height,
2067 x + half_width, y + height - 2);
2068 gdk_draw_line (window, style->dark_gc[state_type],
2069 x + half_width, y + height - 2,
2070 x + width - 2, y + half_height);
2071 gdk_draw_line (window, style->dark_gc[state_type],
2072 x + 1, y + half_height,
2073 x + half_width, y + height - 1);
2074 gdk_draw_line (window, style->dark_gc[state_type],
2075 x + half_width, y + height - 1,
2076 x + width - 1, y + half_height);
2077 gdk_draw_line (window, style->black_gc,
2079 x + half_width, y + height);
2080 gdk_draw_line (window, style->black_gc,
2081 x + half_width, y + height,
2082 x + width, y + half_height);
2084 gdk_draw_line (window, style->bg_gc[state_type],
2085 x + 2, y + half_height,
2086 x + half_width, y + 2);
2087 gdk_draw_line (window, style->bg_gc[state_type],
2088 x + half_width, y + 2,
2089 x + width - 2, y + half_height);
2090 gdk_draw_line (window, style->light_gc[state_type],
2091 x + 1, y + half_height,
2092 x + half_width, y + 1);
2093 gdk_draw_line (window, style->light_gc[state_type],
2094 x + half_width, y + 1,
2095 x + width - 1, y + half_height);
2096 gdk_draw_line (window, style->light_gc[state_type],
2099 gdk_draw_line (window, style->light_gc[state_type],
2101 x + width, y + half_height);
2108 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
2109 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2110 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
2111 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2116 gtk_default_draw_oval (GtkStyle *style,
2118 GtkStateType state_type,
2119 GtkShadowType shadow_type,
2122 const gchar *detail,
2128 g_return_if_fail (style != NULL);
2129 g_return_if_fail (window != NULL);
2131 g_warning ("gtk_default_draw_oval(): FIXME, this function is currently unimplemented");
2135 gtk_default_draw_string (GtkStyle *style,
2137 GtkStateType state_type,
2140 const gchar *detail,
2143 const gchar *string)
2145 g_return_if_fail (style != NULL);
2146 g_return_if_fail (window != NULL);
2150 gdk_gc_set_clip_rectangle (style->white_gc, area);
2151 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], area);
2154 if (state_type == GTK_STATE_INSENSITIVE)
2155 gdk_draw_string (window, style->font, style->white_gc, x + 1, y + 1, string);
2157 gdk_draw_string (window, style->font, style->fg_gc[state_type], x, y, string);
2161 gdk_gc_set_clip_rectangle (style->white_gc, NULL);
2162 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], NULL);
2167 gtk_default_draw_box (GtkStyle *style,
2169 GtkStateType state_type,
2170 GtkShadowType shadow_type,
2173 const gchar *detail,
2179 g_return_if_fail (style != NULL);
2180 g_return_if_fail (window != NULL);
2182 if (width == -1 && height == -1)
2183 gdk_window_get_size (window, &width, &height);
2184 else if (width == -1)
2185 gdk_window_get_size (window, &width, NULL);
2186 else if (height == -1)
2187 gdk_window_get_size (window, NULL, &height);
2189 if (!style->bg_pixmap[state_type] ||
2190 gdk_window_get_type (window) == GDK_WINDOW_PIXMAP)
2193 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
2195 gdk_draw_rectangle (window, style->bg_gc[state_type], TRUE,
2196 x, y, width, height);
2198 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2201 gtk_style_apply_default_background (style, window,
2202 widget && !GTK_WIDGET_NO_WINDOW (widget),
2203 state_type, area, x, y, width, height);
2205 gtk_paint_shadow (style, window, state_type, shadow_type, area, widget, detail,
2206 x, y, width, height);
2210 gtk_default_draw_flat_box (GtkStyle *style,
2212 GtkStateType state_type,
2213 GtkShadowType shadow_type,
2216 const gchar *detail,
2224 g_return_if_fail (style != NULL);
2225 g_return_if_fail (window != NULL);
2227 if (width == -1 && height == -1)
2228 gdk_window_get_size (window, &width, &height);
2229 else if (width == -1)
2230 gdk_window_get_size (window, &width, NULL);
2231 else if (height == -1)
2232 gdk_window_get_size (window, NULL, &height);
2236 if (!strcmp ("text", detail) && state_type == GTK_STATE_SELECTED)
2237 gc1 = style->bg_gc[GTK_STATE_SELECTED];
2238 else if (!strcmp ("viewportbin", detail))
2239 gc1 = style->bg_gc[GTK_STATE_NORMAL];
2240 else if (!strcmp ("entry_bg", detail))
2241 gc1 = style->base_gc[state_type];
2243 gc1 = style->bg_gc[state_type];
2246 gc1 = style->bg_gc[state_type];
2248 if (!style->bg_pixmap[state_type] || gc1 != style->bg_gc[state_type] ||
2249 gdk_window_get_type (window) == GDK_WINDOW_PIXMAP)
2252 gdk_gc_set_clip_rectangle (gc1, area);
2254 gdk_draw_rectangle (window, gc1, TRUE,
2255 x, y, width, height);
2257 if (detail && !strcmp ("tooltip", detail))
2258 gdk_draw_rectangle (window, style->black_gc, FALSE,
2259 x, y, width - 1, height - 1);
2262 gdk_gc_set_clip_rectangle (gc1, NULL);
2265 gtk_style_apply_default_background (style, window,
2266 widget && !GTK_WIDGET_NO_WINDOW (widget),
2267 state_type, area, x, y, width, height);
2271 gtk_default_draw_check (GtkStyle *style,
2273 GtkStateType state_type,
2274 GtkShadowType shadow_type,
2277 const gchar *detail,
2283 gtk_paint_box (style, window, state_type, shadow_type, area, widget, detail,
2284 x, y, width, height);
2288 gtk_default_draw_option (GtkStyle *style,
2290 GtkStateType state_type,
2291 GtkShadowType shadow_type,
2294 const gchar *detail,
2300 gtk_paint_diamond (style, window, state_type, shadow_type, area, widget,
2301 detail, x, y, width, height);
2305 gtk_default_draw_cross (GtkStyle *style,
2307 GtkStateType state_type,
2308 GtkShadowType shadow_type,
2311 const gchar *detail,
2317 g_return_if_fail (style != NULL);
2318 g_return_if_fail (window != NULL);
2320 g_warning ("gtk_default_draw_cross(): FIXME, this function is currently unimplemented");
2324 gtk_default_draw_ramp (GtkStyle *style,
2326 GtkStateType state_type,
2327 GtkShadowType shadow_type,
2330 const gchar *detail,
2331 GtkArrowType arrow_type,
2337 g_return_if_fail (style != NULL);
2338 g_return_if_fail (window != NULL);
2340 g_warning ("gtk_default_draw_ramp(): FIXME, this function is currently unimplemented");
2344 gtk_default_draw_tab (GtkStyle *style,
2346 GtkStateType state_type,
2347 GtkShadowType shadow_type,
2350 const gchar *detail,
2356 g_return_if_fail (style != NULL);
2357 g_return_if_fail (window != NULL);
2359 gtk_paint_box (style, window, state_type, shadow_type, area, widget, detail,
2360 x, y, width, height);
2364 gtk_default_draw_shadow_gap (GtkStyle *style,
2366 GtkStateType state_type,
2367 GtkShadowType shadow_type,
2370 const gchar *detail,
2375 GtkPositionType gap_side,
2384 g_return_if_fail (style != NULL);
2385 g_return_if_fail (window != NULL);
2387 if (width == -1 && height == -1)
2388 gdk_window_get_size (window, &width, &height);
2389 else if (width == -1)
2390 gdk_window_get_size (window, &width, NULL);
2391 else if (height == -1)
2392 gdk_window_get_size (window, NULL, &height);
2394 switch (shadow_type)
2396 case GTK_SHADOW_NONE:
2399 gc1 = style->dark_gc[state_type];
2400 gc2 = style->black_gc;
2401 gc3 = style->bg_gc[state_type];
2402 gc4 = style->light_gc[state_type];
2404 case GTK_SHADOW_ETCHED_IN:
2405 gc1 = style->dark_gc[state_type];
2406 gc2 = style->light_gc[state_type];
2407 gc3 = style->dark_gc[state_type];
2408 gc4 = style->light_gc[state_type];
2410 case GTK_SHADOW_OUT:
2411 gc1 = style->light_gc[state_type];
2412 gc2 = style->bg_gc[state_type];
2413 gc3 = style->dark_gc[state_type];
2414 gc4 = style->black_gc;
2416 case GTK_SHADOW_ETCHED_OUT:
2417 gc1 = style->light_gc[state_type];
2418 gc2 = style->dark_gc[state_type];
2419 gc3 = style->light_gc[state_type];
2420 gc4 = style->dark_gc[state_type];
2425 gdk_gc_set_clip_rectangle (gc1, area);
2426 gdk_gc_set_clip_rectangle (gc2, area);
2427 gdk_gc_set_clip_rectangle (gc3, area);
2428 gdk_gc_set_clip_rectangle (gc4, area);
2431 switch (shadow_type)
2433 case GTK_SHADOW_NONE:
2435 case GTK_SHADOW_OUT:
2436 case GTK_SHADOW_ETCHED_IN:
2437 case GTK_SHADOW_ETCHED_OUT:
2441 gdk_draw_line (window, gc1,
2442 x, y, x, y + height - 1);
2443 gdk_draw_line (window, gc2,
2444 x + 1, y, x + 1, y + height - 2);
2446 gdk_draw_line (window, gc3,
2447 x + 1, y + height - 2, x + width - 2, y + height - 2);
2448 gdk_draw_line (window, gc3,
2449 x + width - 2, y, x + width - 2, y + height - 2);
2450 gdk_draw_line (window, gc4,
2451 x, y + height - 1, x + width - 1, y + height - 1);
2452 gdk_draw_line (window, gc4,
2453 x + width - 1, y, x + width - 1, y + height - 1);
2456 gdk_draw_line (window, gc1,
2457 x, y, x + gap_x - 1, y);
2458 gdk_draw_line (window, gc2,
2459 x + 1, y + 1, x + gap_x - 1, y + 1);
2460 gdk_draw_line (window, gc2,
2461 x + gap_x, y, x + gap_x, y);
2463 if ((width - (gap_x + gap_width)) > 0)
2465 gdk_draw_line (window, gc1,
2466 x + gap_x + gap_width, y, x + width - 2, y);
2467 gdk_draw_line (window, gc2,
2468 x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
2469 gdk_draw_line (window, gc2,
2470 x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
2473 case GTK_POS_BOTTOM:
2474 gdk_draw_line (window, gc1,
2475 x, y, x + width - 1, y);
2476 gdk_draw_line (window, gc1,
2477 x, y, x, y + height - 1);
2478 gdk_draw_line (window, gc2,
2479 x + 1, y + 1, x + width - 2, y + 1);
2480 gdk_draw_line (window, gc2,
2481 x + 1, y + 1, x + 1, y + height - 1);
2483 gdk_draw_line (window, gc3,
2484 x + width - 2, y + 1, x + width - 2, y + height - 1);
2485 gdk_draw_line (window, gc4,
2486 x + width - 1, y, x + width - 1, y + height - 1);
2489 gdk_draw_line (window, gc4,
2490 x, y + height - 1, x + gap_x - 1, y + height - 1);
2491 gdk_draw_line (window, gc3,
2492 x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
2493 gdk_draw_line (window, gc3,
2494 x + gap_x, y + height - 1, x + gap_x, y + height - 1);
2496 if ((width - (gap_x + gap_width)) > 0)
2498 gdk_draw_line (window, gc4,
2499 x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
2500 gdk_draw_line (window, gc3,
2501 x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
2502 gdk_draw_line (window, gc3,
2503 x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
2507 gdk_draw_line (window, gc1,
2508 x, y, x + width - 1, y);
2509 gdk_draw_line (window, gc2,
2510 x, y + 1, x + width - 2, y + 1);
2512 gdk_draw_line (window, gc3,
2513 x, y + height - 2, x + width - 2, y + height - 2);
2514 gdk_draw_line (window, gc3,
2515 x + width - 2, y + 1, x + width - 2, y + height - 2);
2516 gdk_draw_line (window, gc4,
2517 x, y + height - 1, x + width - 1, y + height - 1);
2518 gdk_draw_line (window, gc4,
2519 x + width - 1, y, x + width - 1, y + height - 1);
2522 gdk_draw_line (window, gc1,
2523 x, y, x, y + gap_x - 1);
2524 gdk_draw_line (window, gc2,
2525 x + 1, y + 1, x + 1, y + gap_x - 1);
2526 gdk_draw_line (window, gc2,
2527 x, y + gap_x, x, y + gap_x);
2529 if ((width - (gap_x + gap_width)) > 0)
2531 gdk_draw_line (window, gc1,
2532 x, y + gap_x + gap_width, x, y + height - 2);
2533 gdk_draw_line (window, gc2,
2534 x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
2535 gdk_draw_line (window, gc2,
2536 x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
2540 gdk_draw_line (window, gc1,
2541 x, y, x + width - 1, y);
2542 gdk_draw_line (window, gc1,
2543 x, y, x, y + height - 1);
2544 gdk_draw_line (window, gc2,
2545 x + 1, y + 1, x + width - 1, y + 1);
2546 gdk_draw_line (window, gc2,
2547 x + 1, y + 1, x + 1, y + height - 2);
2549 gdk_draw_line (window, gc3,
2550 x + 1, y + height - 2, x + width - 1, y + height - 2);
2551 gdk_draw_line (window, gc4,
2552 x, y + height - 1, x + width - 1, y + height - 1);
2555 gdk_draw_line (window, gc4,
2556 x + width - 1, y, x + width - 1, y + gap_x - 1);
2557 gdk_draw_line (window, gc3,
2558 x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
2559 gdk_draw_line (window, gc3,
2560 x + width - 1, y + gap_x, x + width - 1, y + gap_x);
2562 if ((width - (gap_x + gap_width)) > 0)
2564 gdk_draw_line (window, gc4,
2565 x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
2566 gdk_draw_line (window, gc3,
2567 x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
2568 gdk_draw_line (window, gc3,
2569 x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
2577 gdk_gc_set_clip_rectangle (gc1, NULL);
2578 gdk_gc_set_clip_rectangle (gc2, NULL);
2579 gdk_gc_set_clip_rectangle (gc3, NULL);
2580 gdk_gc_set_clip_rectangle (gc4, NULL);
2585 gtk_default_draw_box_gap (GtkStyle *style,
2587 GtkStateType state_type,
2588 GtkShadowType shadow_type,
2591 const gchar *detail,
2596 GtkPositionType gap_side,
2605 g_return_if_fail (style != NULL);
2606 g_return_if_fail (window != NULL);
2608 gtk_style_apply_default_background (style, window,
2609 widget && !GTK_WIDGET_NO_WINDOW (widget),
2610 state_type, area, x, y, width, height);
2612 if (width == -1 && height == -1)
2613 gdk_window_get_size (window, &width, &height);
2614 else if (width == -1)
2615 gdk_window_get_size (window, &width, NULL);
2616 else if (height == -1)
2617 gdk_window_get_size (window, NULL, &height);
2619 switch (shadow_type)
2621 case GTK_SHADOW_NONE:
2624 gc1 = style->dark_gc[state_type];
2625 gc2 = style->black_gc;
2626 gc3 = style->bg_gc[state_type];
2627 gc4 = style->light_gc[state_type];
2629 case GTK_SHADOW_ETCHED_IN:
2630 gc1 = style->dark_gc[state_type];
2631 gc2 = style->light_gc[state_type];
2632 gc3 = style->dark_gc[state_type];
2633 gc4 = style->light_gc[state_type];
2635 case GTK_SHADOW_OUT:
2636 gc1 = style->light_gc[state_type];
2637 gc2 = style->bg_gc[state_type];
2638 gc3 = style->dark_gc[state_type];
2639 gc4 = style->black_gc;
2641 case GTK_SHADOW_ETCHED_OUT:
2642 gc1 = style->light_gc[state_type];
2643 gc2 = style->dark_gc[state_type];
2644 gc3 = style->light_gc[state_type];
2645 gc4 = style->dark_gc[state_type];
2651 gdk_gc_set_clip_rectangle (gc1, area);
2652 gdk_gc_set_clip_rectangle (gc2, area);
2653 gdk_gc_set_clip_rectangle (gc3, area);
2654 gdk_gc_set_clip_rectangle (gc4, area);
2657 switch (shadow_type)
2659 case GTK_SHADOW_NONE:
2661 case GTK_SHADOW_OUT:
2662 case GTK_SHADOW_ETCHED_IN:
2663 case GTK_SHADOW_ETCHED_OUT:
2667 gdk_draw_line (window, gc1,
2668 x, y, x, y + height - 1);
2669 gdk_draw_line (window, gc2,
2670 x + 1, y, x + 1, y + height - 2);
2672 gdk_draw_line (window, gc3,
2673 x + 1, y + height - 2, x + width - 2, y + height - 2);
2674 gdk_draw_line (window, gc3,
2675 x + width - 2, y, x + width - 2, y + height - 2);
2676 gdk_draw_line (window, gc4,
2677 x, y + height - 1, x + width - 1, y + height - 1);
2678 gdk_draw_line (window, gc4,
2679 x + width - 1, y, x + width - 1, y + height - 1);
2682 gdk_draw_line (window, gc1,
2683 x, y, x + gap_x - 1, y);
2684 gdk_draw_line (window, gc2,
2685 x + 1, y + 1, x + gap_x - 1, y + 1);
2686 gdk_draw_line (window, gc2,
2687 x + gap_x, y, x + gap_x, y);
2689 if ((width - (gap_x + gap_width)) > 0)
2691 gdk_draw_line (window, gc1,
2692 x + gap_x + gap_width, y, x + width - 2, y);
2693 gdk_draw_line (window, gc2,
2694 x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
2695 gdk_draw_line (window, gc2,
2696 x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
2699 case GTK_POS_BOTTOM:
2700 gdk_draw_line (window, gc1,
2701 x, y, x + width - 1, y);
2702 gdk_draw_line (window, gc1,
2703 x, y, x, y + height - 1);
2704 gdk_draw_line (window, gc2,
2705 x + 1, y + 1, x + width - 2, y + 1);
2706 gdk_draw_line (window, gc2,
2707 x + 1, y + 1, x + 1, y + height - 1);
2709 gdk_draw_line (window, gc3,
2710 x + width - 2, y + 1, x + width - 2, y + height - 1);
2711 gdk_draw_line (window, gc4,
2712 x + width - 1, y, x + width - 1, y + height - 1);
2715 gdk_draw_line (window, gc4,
2716 x, y + height - 1, x + gap_x - 1, y + height - 1);
2717 gdk_draw_line (window, gc3,
2718 x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
2719 gdk_draw_line (window, gc3,
2720 x + gap_x, y + height - 1, x + gap_x, y + height - 1);
2722 if ((width - (gap_x + gap_width)) > 0)
2724 gdk_draw_line (window, gc4,
2725 x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
2726 gdk_draw_line (window, gc3,
2727 x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
2728 gdk_draw_line (window, gc3,
2729 x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
2733 gdk_draw_line (window, gc1,
2734 x, y, x + width - 1, y);
2735 gdk_draw_line (window, gc2,
2736 x, y + 1, x + width - 2, y + 1);
2738 gdk_draw_line (window, gc3,
2739 x, y + height - 2, x + width - 2, y + height - 2);
2740 gdk_draw_line (window, gc3,
2741 x + width - 2, y + 1, x + width - 2, y + height - 2);
2742 gdk_draw_line (window, gc4,
2743 x, y + height - 1, x + width - 1, y + height - 1);
2744 gdk_draw_line (window, gc4,
2745 x + width - 1, y, x + width - 1, y + height - 1);
2748 gdk_draw_line (window, gc1,
2749 x, y, x, y + gap_x - 1);
2750 gdk_draw_line (window, gc2,
2751 x + 1, y + 1, x + 1, y + gap_x - 1);
2752 gdk_draw_line (window, gc2,
2753 x, y + gap_x, x, y + gap_x);
2755 if ((width - (gap_x + gap_width)) > 0)
2757 gdk_draw_line (window, gc1,
2758 x, y + gap_x + gap_width, x, y + height - 2);
2759 gdk_draw_line (window, gc2,
2760 x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
2761 gdk_draw_line (window, gc2,
2762 x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
2766 gdk_draw_line (window, gc1,
2767 x, y, x + width - 1, y);
2768 gdk_draw_line (window, gc1,
2769 x, y, x, y + height - 1);
2770 gdk_draw_line (window, gc2,
2771 x + 1, y + 1, x + width - 1, y + 1);
2772 gdk_draw_line (window, gc2,
2773 x + 1, y + 1, x + 1, y + height - 2);
2775 gdk_draw_line (window, gc3,
2776 x + 1, y + height - 2, x + width - 1, y + height - 2);
2777 gdk_draw_line (window, gc4,
2778 x, y + height - 1, x + width - 1, y + height - 1);
2781 gdk_draw_line (window, gc4,
2782 x + width - 1, y, x + width - 1, y + gap_x - 1);
2783 gdk_draw_line (window, gc3,
2784 x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
2785 gdk_draw_line (window, gc3,
2786 x + width - 1, y + gap_x, x + width - 1, y + gap_x);
2788 if ((width - (gap_x + gap_width)) > 0)
2790 gdk_draw_line (window, gc4,
2791 x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
2792 gdk_draw_line (window, gc3,
2793 x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
2794 gdk_draw_line (window, gc3,
2795 x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
2803 gdk_gc_set_clip_rectangle (gc1, NULL);
2804 gdk_gc_set_clip_rectangle (gc2, NULL);
2805 gdk_gc_set_clip_rectangle (gc3, NULL);
2806 gdk_gc_set_clip_rectangle (gc4, NULL);
2811 gtk_default_draw_extension (GtkStyle *style,
2813 GtkStateType state_type,
2814 GtkShadowType shadow_type,
2817 const gchar *detail,
2822 GtkPositionType gap_side)
2829 g_return_if_fail (style != NULL);
2830 g_return_if_fail (window != NULL);
2832 gtk_style_apply_default_background (style, window,
2833 widget && !GTK_WIDGET_NO_WINDOW (widget),
2834 GTK_STATE_NORMAL, area, x, y, width, height);
2836 if (width == -1 && height == -1)
2837 gdk_window_get_size (window, &width, &height);
2838 else if (width == -1)
2839 gdk_window_get_size (window, &width, NULL);
2840 else if (height == -1)
2841 gdk_window_get_size (window, NULL, &height);
2843 switch (shadow_type)
2845 case GTK_SHADOW_NONE:
2848 gc1 = style->dark_gc[state_type];
2849 gc2 = style->black_gc;
2850 gc3 = style->bg_gc[state_type];
2851 gc4 = style->light_gc[state_type];
2853 case GTK_SHADOW_ETCHED_IN:
2854 gc1 = style->dark_gc[state_type];
2855 gc2 = style->light_gc[state_type];
2856 gc3 = style->dark_gc[state_type];
2857 gc4 = style->light_gc[state_type];
2859 case GTK_SHADOW_OUT:
2860 gc1 = style->light_gc[state_type];
2861 gc2 = style->bg_gc[state_type];
2862 gc3 = style->dark_gc[state_type];
2863 gc4 = style->black_gc;
2865 case GTK_SHADOW_ETCHED_OUT:
2866 gc1 = style->light_gc[state_type];
2867 gc2 = style->dark_gc[state_type];
2868 gc3 = style->light_gc[state_type];
2869 gc4 = style->dark_gc[state_type];
2875 gdk_gc_set_clip_rectangle (gc1, area);
2876 gdk_gc_set_clip_rectangle (gc2, area);
2877 gdk_gc_set_clip_rectangle (gc3, area);
2878 gdk_gc_set_clip_rectangle (gc4, area);
2881 switch (shadow_type)
2883 case GTK_SHADOW_NONE:
2885 case GTK_SHADOW_OUT:
2886 case GTK_SHADOW_ETCHED_IN:
2887 case GTK_SHADOW_ETCHED_OUT:
2891 gtk_style_apply_default_background (style, window,
2892 widget && !GTK_WIDGET_NO_WINDOW (widget),
2894 x + style->klass->xthickness,
2896 width - (2 * style->klass->xthickness),
2897 height - (style->klass->ythickness));
2898 gdk_draw_line (window, gc1,
2899 x, y, x, y + height - 2);
2900 gdk_draw_line (window, gc2,
2901 x + 1, y, x + 1, y + height - 2);
2903 gdk_draw_line (window, gc3,
2904 x + 2, y + height - 2, x + width - 2, y + height - 2);
2905 gdk_draw_line (window, gc3,
2906 x + width - 2, y, x + width - 2, y + height - 2);
2907 gdk_draw_line (window, gc4,
2908 x + 1, y + height - 1, x + width - 2, y + height - 1);
2909 gdk_draw_line (window, gc4,
2910 x + width - 1, y, x + width - 1, y + height - 2);
2912 case GTK_POS_BOTTOM:
2913 gtk_style_apply_default_background (style, window,
2914 widget && !GTK_WIDGET_NO_WINDOW (widget),
2916 x + style->klass->xthickness,
2917 y + style->klass->ythickness,
2918 width - (2 * style->klass->xthickness),
2919 height - (style->klass->ythickness));
2920 gdk_draw_line (window, gc1,
2921 x + 1, y, x + width - 2, y);
2922 gdk_draw_line (window, gc1,
2923 x, y + 1, x, y + height - 1);
2924 gdk_draw_line (window, gc2,
2925 x + 1, y + 1, x + width - 2, y + 1);
2926 gdk_draw_line (window, gc2,
2927 x + 1, y + 1, x + 1, y + height - 1);
2929 gdk_draw_line (window, gc3,
2930 x + width - 2, y + 2, x + width - 2, y + height - 1);
2931 gdk_draw_line (window, gc4,
2932 x + width - 1, y + 1, x + width - 1, y + height - 1);
2935 gtk_style_apply_default_background (style, window,
2936 widget && !GTK_WIDGET_NO_WINDOW (widget),
2939 y + style->klass->ythickness,
2940 width - (style->klass->xthickness),
2941 height - (2 * style->klass->ythickness));
2942 gdk_draw_line (window, gc1,
2943 x, y, x + width - 2, y);
2944 gdk_draw_line (window, gc2,
2945 x + 1, y + 1, x + width - 2, y + 1);
2947 gdk_draw_line (window, gc3,
2948 x, y + height - 2, x + width - 2, y + height - 2);
2949 gdk_draw_line (window, gc3,
2950 x + width - 2, y + 2, x + width - 2, y + height - 2);
2951 gdk_draw_line (window, gc4,
2952 x, y + height - 1, x + width - 2, y + height - 1);
2953 gdk_draw_line (window, gc4,
2954 x + width - 1, y + 1, x + width - 1, y + height - 2);
2957 gtk_style_apply_default_background (style, window,
2958 widget && !GTK_WIDGET_NO_WINDOW (widget),
2960 x + style->klass->xthickness,
2961 y + style->klass->ythickness,
2962 width - (style->klass->xthickness),
2963 height - (2 * style->klass->ythickness));
2964 gdk_draw_line (window, gc1,
2965 x + 1, y, x + width - 1, y);
2966 gdk_draw_line (window, gc1,
2967 x, y + 1, x, y + height - 2);
2968 gdk_draw_line (window, gc2,
2969 x + 1, y + 1, x + width - 1, y + 1);
2970 gdk_draw_line (window, gc2,
2971 x + 1, y + 1, x + 1, y + height - 2);
2973 gdk_draw_line (window, gc3,
2974 x + 2, y + height - 2, x + width - 1, y + height - 2);
2975 gdk_draw_line (window, gc4,
2976 x + 1, y + height - 1, x + width - 1, y + height - 1);
2983 gdk_gc_set_clip_rectangle (gc1, NULL);
2984 gdk_gc_set_clip_rectangle (gc2, NULL);
2985 gdk_gc_set_clip_rectangle (gc3, NULL);
2986 gdk_gc_set_clip_rectangle (gc4, NULL);
2991 gtk_default_draw_focus (GtkStyle *style,
2995 const gchar *detail,
3001 g_return_if_fail (style != NULL);
3002 g_return_if_fail (window != NULL);
3004 if (width == -1 && height == -1)
3006 gdk_window_get_size (window, &width, &height);
3010 else if (width == -1)
3012 gdk_window_get_size (window, &width, NULL);
3015 else if (height == -1)
3017 gdk_window_get_size (window, NULL, &height);
3022 gdk_gc_set_clip_rectangle (style->black_gc, area);
3024 if (detail && !strcmp (detail, "add-mode"))
3026 gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_ON_OFF_DASH, 0, 0);
3027 gdk_gc_set_dashes (style->black_gc, 0, "\4\4", 2);
3029 gdk_draw_rectangle (window,
3030 style->black_gc, FALSE,
3031 x, y, width, height);
3033 gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_SOLID, 0, 0);
3037 gdk_draw_rectangle (window,
3038 style->black_gc, FALSE,
3039 x, y, width, height);
3043 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
3047 gtk_default_draw_slider (GtkStyle *style,
3049 GtkStateType state_type,
3050 GtkShadowType shadow_type,
3053 const gchar *detail,
3058 GtkOrientation orientation)
3060 g_return_if_fail (style != NULL);
3061 g_return_if_fail (window != NULL);
3063 if (width == -1 && height == -1)
3064 gdk_window_get_size (window, &width, &height);
3065 else if (width == -1)
3066 gdk_window_get_size (window, &width, NULL);
3067 else if (height == -1)
3068 gdk_window_get_size (window, NULL, &height);
3070 gtk_paint_box (style, window, state_type, shadow_type,
3071 area, widget, detail, x, y, width, height);
3073 if (orientation == GTK_ORIENTATION_HORIZONTAL)
3074 gtk_paint_vline (style, window, state_type, area, widget, detail,
3075 style->klass->ythickness,
3076 height - style->klass->ythickness - 1, width / 2);
3078 gtk_paint_hline (style, window, state_type, area, widget, detail,
3079 style->klass->xthickness,
3080 width - style->klass->xthickness - 1, height / 2);
3084 draw_dot (GdkWindow *window,
3092 size = CLAMP (size, 2, 3);
3096 gdk_draw_point (window, light_gc, x, y);
3097 gdk_draw_point (window, light_gc, x+1, y+1);
3099 else if (size == 3);
3101 gdk_draw_point (window, light_gc, x, y);
3102 gdk_draw_point (window, light_gc, x+1, y);
3103 gdk_draw_point (window, light_gc, x, y+1);
3104 gdk_draw_point (window, dark_gc, x+1, y+2);
3105 gdk_draw_point (window, dark_gc, x+2, y+1);
3106 gdk_draw_point (window, dark_gc, x+2, y+2);
3111 gtk_default_draw_handle (GtkStyle *style,
3113 GtkStateType state_type,
3114 GtkShadowType shadow_type,
3117 const gchar *detail,
3122 GtkOrientation orientation)
3125 gint xthick, ythick;
3126 GdkGC *light_gc, *dark_gc;
3131 g_return_if_fail (style != NULL);
3132 g_return_if_fail (window != NULL);
3134 if (width == -1 && height == -1)
3135 gdk_window_get_size (window, &width, &height);
3136 else if (width == -1)
3137 gdk_window_get_size (window, &width, NULL);
3138 else if (height == -1)
3139 gdk_window_get_size (window, NULL, &height);
3141 gtk_paint_box (style, window, state_type, shadow_type, area, widget,
3142 detail, x, y, width, height);
3145 if (!strcmp (detail, "paned"))
3147 /* we want to ignore the shadow border in paned widgets */
3151 light_gc = style->light_gc[state_type];
3152 dark_gc = style->black_gc;
3156 xthick = style->klass->xthickness;
3157 ythick = style->klass->ythickness;
3159 light_gc = style->light_gc[state_type];
3160 dark_gc = style->dark_gc[state_type];
3163 rect.x = x + xthick;
3164 rect.y = y + ythick;
3165 rect.width = width - (xthick * 2);
3166 rect.height = height - (ythick * 2);
3169 intersect = gdk_rectangle_intersect (area, &rect, &dest);
3179 gdk_gc_set_clip_rectangle (light_gc, &dest);
3180 gdk_gc_set_clip_rectangle (dark_gc, &dest);
3182 if (!strcmp (detail, "paned"))
3187 gdk_window_get_size (window, &window_width, &window_height);
3189 if (orientation == GTK_ORIENTATION_HORIZONTAL)
3190 for (xx = window_width/2 - 15; xx <= window_width/2 + 15; xx += 5)
3191 draw_dot (window, light_gc, dark_gc, xx, window_height/2 - 1, 3);
3193 for (yy = window_height/2 - 15; yy <= window_height/2 + 15; yy += 5)
3194 draw_dot (window, light_gc, dark_gc, window_width/2 - 1, yy, 3);
3198 for (yy = y + ythick; yy < (y + height - ythick); yy += 3)
3199 for (xx = x + xthick; xx < (x + width - xthick); xx += 6)
3201 draw_dot (window, light_gc, dark_gc, xx, yy, 2);
3202 draw_dot (window, light_gc, dark_gc, xx + 3, yy + 1, 2);
3206 gdk_gc_set_clip_rectangle (light_gc, NULL);
3207 gdk_gc_set_clip_rectangle (dark_gc, NULL);
3211 gtk_style_shade (GdkColor *a,
3219 red = (gdouble) a->red / 65535.0;
3220 green = (gdouble) a->green / 65535.0;
3221 blue = (gdouble) a->blue / 65535.0;
3223 rgb_to_hls (&red, &green, &blue);
3228 else if (green < 0.0)
3234 else if (blue < 0.0)
3237 hls_to_rgb (&red, &green, &blue);
3239 b->red = red * 65535.0;
3240 b->green = green * 65535.0;
3241 b->blue = blue * 65535.0;
3245 rgb_to_hls (gdouble *r,
3286 l = (max + min) / 2;
3293 s = (max - min) / (max + min);
3295 s = (max - min) / (2 - max - min);
3299 h = (green - blue) / delta;
3300 else if (green == max)
3301 h = 2 + (blue - red) / delta;
3302 else if (blue == max)
3303 h = 4 + (red - green) / delta;
3316 hls_to_rgb (gdouble *h,
3329 if (lightness <= 0.5)
3330 m2 = lightness * (1 + saturation);
3332 m2 = lightness + saturation - lightness * saturation;
3333 m1 = 2 * lightness - m2;
3335 if (saturation == 0)
3350 r = m1 + (m2 - m1) * hue / 60;
3354 r = m1 + (m2 - m1) * (240 - hue) / 60;
3365 g = m1 + (m2 - m1) * hue / 60;
3369 g = m1 + (m2 - m1) * (240 - hue) / 60;
3380 b = m1 + (m2 - m1) * hue / 60;
3384 b = m1 + (m2 - m1) * (240 - hue) / 60;
3395 gtk_paint_hline (GtkStyle *style,
3397 GtkStateType state_type,
3400 const gchar *detail,
3405 g_return_if_fail (style != NULL);
3406 g_return_if_fail (style->klass != NULL);
3407 g_return_if_fail (style->klass->draw_hline != NULL);
3409 style->klass->draw_hline (style, window, state_type, area, widget, detail, x1, x2, y);
3413 gtk_paint_vline (GtkStyle *style,
3415 GtkStateType state_type,
3418 const gchar *detail,
3423 g_return_if_fail (style != NULL);
3424 g_return_if_fail (style->klass != NULL);
3425 g_return_if_fail (style->klass->draw_vline != NULL);
3427 style->klass->draw_vline (style, window, state_type, area, widget, detail, y1, y2, x);
3431 gtk_paint_shadow (GtkStyle *style,
3433 GtkStateType state_type,
3434 GtkShadowType shadow_type,
3437 const gchar *detail,
3443 g_return_if_fail (style != NULL);
3444 g_return_if_fail (style->klass != NULL);
3445 g_return_if_fail (style->klass->draw_shadow != NULL);
3447 style->klass->draw_shadow (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3451 gtk_paint_polygon (GtkStyle *style,
3453 GtkStateType state_type,
3454 GtkShadowType shadow_type,
3457 const gchar *detail,
3462 g_return_if_fail (style != NULL);
3463 g_return_if_fail (style->klass != NULL);
3464 g_return_if_fail (style->klass->draw_shadow != NULL);
3466 style->klass->draw_polygon (style, window, state_type, shadow_type, area, widget, detail, points, npoints, fill);
3470 gtk_paint_arrow (GtkStyle *style,
3472 GtkStateType state_type,
3473 GtkShadowType shadow_type,
3476 const gchar *detail,
3477 GtkArrowType arrow_type,
3484 g_return_if_fail (style != NULL);
3485 g_return_if_fail (style->klass != NULL);
3486 g_return_if_fail (style->klass->draw_arrow != NULL);
3488 style->klass->draw_arrow (style, window, state_type, shadow_type, area, widget, detail, arrow_type, fill, x, y, width, height);
3492 gtk_paint_diamond (GtkStyle *style,
3494 GtkStateType state_type,
3495 GtkShadowType shadow_type,
3498 const gchar *detail,
3504 g_return_if_fail (style != NULL);
3505 g_return_if_fail (style->klass != NULL);
3506 g_return_if_fail (style->klass->draw_diamond != NULL);
3508 style->klass->draw_diamond (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3512 gtk_paint_oval (GtkStyle *style,
3514 GtkStateType state_type,
3515 GtkShadowType shadow_type,
3518 const gchar *detail,
3524 g_return_if_fail (style != NULL);
3525 g_return_if_fail (style->klass != NULL);
3526 g_return_if_fail (style->klass->draw_oval != NULL);
3528 style->klass->draw_oval (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3532 gtk_paint_string (GtkStyle *style,
3534 GtkStateType state_type,
3537 const gchar *detail,
3540 const gchar *string)
3542 g_return_if_fail (style != NULL);
3543 g_return_if_fail (style->klass != NULL);
3544 g_return_if_fail (style->klass->draw_string != NULL);
3546 style->klass->draw_string (style, window, state_type, area, widget, detail, x, y, string);
3550 gtk_paint_box (GtkStyle *style,
3552 GtkStateType state_type,
3553 GtkShadowType shadow_type,
3556 const gchar *detail,
3562 g_return_if_fail (style != NULL);
3563 g_return_if_fail (style->klass != NULL);
3564 g_return_if_fail (style->klass->draw_box != NULL);
3566 style->klass->draw_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3570 gtk_paint_flat_box (GtkStyle *style,
3572 GtkStateType state_type,
3573 GtkShadowType shadow_type,
3576 const gchar *detail,
3582 g_return_if_fail (style != NULL);
3583 g_return_if_fail (style->klass != NULL);
3584 g_return_if_fail (style->klass->draw_flat_box != NULL);
3586 style->klass->draw_flat_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3590 gtk_paint_check (GtkStyle *style,
3592 GtkStateType state_type,
3593 GtkShadowType shadow_type,
3596 const gchar *detail,
3602 g_return_if_fail (style != NULL);
3603 g_return_if_fail (style->klass != NULL);
3604 g_return_if_fail (style->klass->draw_check != NULL);
3606 style->klass->draw_check (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3610 gtk_paint_option (GtkStyle *style,
3612 GtkStateType state_type,
3613 GtkShadowType shadow_type,
3616 const gchar *detail,
3622 g_return_if_fail (style != NULL);
3623 g_return_if_fail (style->klass != NULL);
3624 g_return_if_fail (style->klass->draw_option != NULL);
3626 style->klass->draw_option (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3630 gtk_paint_cross (GtkStyle *style,
3632 GtkStateType state_type,
3633 GtkShadowType shadow_type,
3636 const gchar *detail,
3642 g_return_if_fail (style != NULL);
3643 g_return_if_fail (style->klass != NULL);
3644 g_return_if_fail (style->klass->draw_cross != NULL);
3646 style->klass->draw_cross (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3650 gtk_paint_ramp (GtkStyle *style,
3652 GtkStateType state_type,
3653 GtkShadowType shadow_type,
3656 const gchar *detail,
3657 GtkArrowType arrow_type,
3663 g_return_if_fail (style != NULL);
3664 g_return_if_fail (style->klass != NULL);
3665 g_return_if_fail (style->klass->draw_ramp != NULL);
3667 style->klass->draw_ramp (style, window, state_type, shadow_type, area, widget, detail, arrow_type, x, y, width, height);
3671 gtk_paint_tab (GtkStyle *style,
3673 GtkStateType state_type,
3674 GtkShadowType shadow_type,
3677 const gchar *detail,
3683 g_return_if_fail (style != NULL);
3684 g_return_if_fail (style->klass != NULL);
3685 g_return_if_fail (style->klass->draw_tab != NULL);
3687 style->klass->draw_tab (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3691 gtk_paint_shadow_gap (GtkStyle *style,
3693 GtkStateType state_type,
3694 GtkShadowType shadow_type,
3702 GtkPositionType gap_side,
3706 g_return_if_fail (style != NULL);
3707 g_return_if_fail (style->klass != NULL);
3708 g_return_if_fail (style->klass->draw_shadow_gap != NULL);
3710 style->klass->draw_shadow_gap (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
3715 gtk_paint_box_gap (GtkStyle *style,
3717 GtkStateType state_type,
3718 GtkShadowType shadow_type,
3726 GtkPositionType gap_side,
3730 g_return_if_fail (style != NULL);
3731 g_return_if_fail (style->klass != NULL);
3732 g_return_if_fail (style->klass->draw_box_gap != NULL);
3734 style->klass->draw_box_gap (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
3738 gtk_paint_extension (GtkStyle *style,
3740 GtkStateType state_type,
3741 GtkShadowType shadow_type,
3749 GtkPositionType gap_side)
3751 g_return_if_fail (style != NULL);
3752 g_return_if_fail (style->klass != NULL);
3753 g_return_if_fail (style->klass->draw_extension != NULL);
3755 style->klass->draw_extension (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side);
3759 gtk_paint_focus (GtkStyle *style,
3763 const gchar *detail,
3769 g_return_if_fail (style != NULL);
3770 g_return_if_fail (style->klass != NULL);
3771 g_return_if_fail (style->klass->draw_focus != NULL);
3773 style->klass->draw_focus (style, window, area, widget, detail, x, y, width, height);
3777 gtk_paint_slider (GtkStyle *style,
3779 GtkStateType state_type,
3780 GtkShadowType shadow_type,
3783 const gchar *detail,
3788 GtkOrientation orientation)
3790 g_return_if_fail (style != NULL);
3791 g_return_if_fail (style->klass != NULL);
3792 g_return_if_fail (style->klass->draw_slider != NULL);
3794 style->klass->draw_slider (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
3798 gtk_paint_handle (GtkStyle *style,
3800 GtkStateType state_type,
3801 GtkShadowType shadow_type,
3804 const gchar *detail,
3809 GtkOrientation orientation)
3811 g_return_if_fail (style != NULL);
3812 g_return_if_fail (style->klass != NULL);
3813 g_return_if_fail (style->klass->draw_handle != NULL);
3815 style->klass->draw_handle (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);