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/.
31 #include "gtkwidget.h"
32 #include "gtkthemes.h"
35 #define LIGHTNESS_MULT 1.3
36 #define DARKNESS_MULT 0.7
38 /* actually glib should do that for us */
40 #define M_PI 3.14159265358979323846
43 #define M_PI_4 0.78539816339744830962
46 static void gtk_style_init (GtkStyle *style,
47 GdkColormap *colormap,
49 static void gtk_style_destroy (GtkStyle *style);
51 static void gtk_default_draw_hline (GtkStyle *style,
53 GtkStateType state_type,
60 static void gtk_default_draw_vline (GtkStyle *style,
62 GtkStateType state_type,
69 static void gtk_default_draw_shadow (GtkStyle *style,
71 GtkStateType state_type,
72 GtkShadowType shadow_type,
80 static void gtk_default_draw_shadow (GtkStyle *style,
82 GtkStateType state_type,
83 GtkShadowType shadow_type,
91 static void gtk_default_draw_polygon (GtkStyle *style,
93 GtkStateType state_type,
94 GtkShadowType shadow_type,
101 static void gtk_default_draw_arrow (GtkStyle *style,
103 GtkStateType state_type,
104 GtkShadowType shadow_type,
108 GtkArrowType arrow_type,
114 static void gtk_default_draw_diamond (GtkStyle *style,
116 GtkStateType state_type,
117 GtkShadowType shadow_type,
125 static void gtk_default_draw_oval (GtkStyle *style,
127 GtkStateType state_type,
128 GtkShadowType shadow_type,
136 static void gtk_default_draw_string (GtkStyle *style,
138 GtkStateType state_type,
144 const gchar *string);
145 static void gtk_default_draw_box (GtkStyle *style,
147 GtkStateType state_type,
148 GtkShadowType shadow_type,
156 static void gtk_default_draw_flat_box (GtkStyle *style,
158 GtkStateType state_type,
159 GtkShadowType shadow_type,
167 static void gtk_default_draw_check (GtkStyle *style,
169 GtkStateType state_type,
170 GtkShadowType shadow_type,
178 static void gtk_default_draw_option (GtkStyle *style,
180 GtkStateType state_type,
181 GtkShadowType shadow_type,
189 static void gtk_default_draw_cross (GtkStyle *style,
191 GtkStateType state_type,
192 GtkShadowType shadow_type,
200 static void gtk_default_draw_ramp (GtkStyle *style,
202 GtkStateType state_type,
203 GtkShadowType shadow_type,
207 GtkArrowType arrow_type,
212 static void gtk_default_draw_tab (GtkStyle *style,
214 GtkStateType state_type,
215 GtkShadowType shadow_type,
223 static void gtk_default_draw_shadow_gap (GtkStyle *style,
225 GtkStateType state_type,
226 GtkShadowType shadow_type,
234 GtkPositionType gap_side,
237 static void gtk_default_draw_box_gap (GtkStyle *style,
239 GtkStateType state_type,
240 GtkShadowType shadow_type,
248 GtkPositionType gap_side,
251 static void gtk_default_draw_extension (GtkStyle *style,
253 GtkStateType state_type,
254 GtkShadowType shadow_type,
262 GtkPositionType gap_side);
263 static void gtk_default_draw_focus (GtkStyle *style,
272 static void gtk_default_draw_slider (GtkStyle *style,
274 GtkStateType state_type,
275 GtkShadowType shadow_type,
283 GtkOrientation orientation);
284 static void gtk_default_draw_handle (GtkStyle *style,
286 GtkStateType state_type,
287 GtkShadowType shadow_type,
295 GtkOrientation orientation);
297 static void gtk_style_shade (GdkColor *a, GdkColor *b, gdouble k);
298 static void rgb_to_hls (gdouble *r, gdouble *g, gdouble *b);
299 static void hls_to_rgb (gdouble *h, gdouble *l, gdouble *s);
302 static const GtkStyleClass default_class =
306 gtk_default_draw_hline,
307 gtk_default_draw_vline,
308 gtk_default_draw_shadow,
309 gtk_default_draw_polygon,
310 gtk_default_draw_arrow,
311 gtk_default_draw_diamond,
312 gtk_default_draw_oval,
313 gtk_default_draw_string,
314 gtk_default_draw_box,
315 gtk_default_draw_flat_box,
316 gtk_default_draw_check,
317 gtk_default_draw_option,
318 gtk_default_draw_cross,
319 gtk_default_draw_ramp,
320 gtk_default_draw_tab,
321 gtk_default_draw_shadow_gap,
322 gtk_default_draw_box_gap,
323 gtk_default_draw_extension,
324 gtk_default_draw_focus,
325 gtk_default_draw_slider,
326 gtk_default_draw_handle
328 GdkFont *default_font = NULL;
330 static GdkColor gtk_default_normal_fg = { 0, 0, 0, 0 };
331 static GdkColor gtk_default_active_fg = { 0, 0, 0, 0 };
332 static GdkColor gtk_default_prelight_fg = { 0, 0, 0, 0 };
333 static GdkColor gtk_default_selected_fg = { 0, 0xffff, 0xffff, 0xffff };
334 static GdkColor gtk_default_insensitive_fg = { 0, 0x7530, 0x7530, 0x7530 };
336 static GdkColor gtk_default_normal_bg = { 0, 0xd6d6, 0xd6d6, 0xd6d6 };
337 static GdkColor gtk_default_active_bg = { 0, 0xc350, 0xc350, 0xc350 };
338 static GdkColor gtk_default_prelight_bg = { 0, 0xea60, 0xea60, 0xea60 };
339 static GdkColor gtk_default_selected_bg = { 0, 0, 0, 0x9c40 };
340 static GdkColor gtk_default_insensitive_bg = { 0, 0xd6d6, 0xd6d6, 0xd6d6 };
343 gtk_style_copy (GtkStyle *style)
348 g_return_val_if_fail (style != NULL, NULL);
350 new_style = gtk_style_new ();
352 for (i = 0; i < 5; i++)
354 new_style->fg[i] = style->fg[i];
355 new_style->bg[i] = style->bg[i];
356 new_style->text[i] = style->text[i];
357 new_style->base[i] = style->base[i];
359 new_style->bg_pixmap[i] = style->bg_pixmap[i];
362 gdk_font_unref (new_style->font);
363 new_style->font = style->font;
364 gdk_font_ref (new_style->font);
368 new_style->rc_style = style->rc_style;
369 gtk_rc_style_ref (style->rc_style);
374 new_style->engine = style->engine;
375 gtk_theme_engine_ref (new_style->engine);
376 new_style->engine->duplicate_style (new_style, style);
383 gtk_style_duplicate (GtkStyle *style)
387 g_return_val_if_fail (style != NULL, NULL);
389 new_style = gtk_style_copy (style);
391 style->styles = g_slist_append (style->styles, new_style);
392 new_style->styles = style->styles;
403 style = g_new0 (GtkStyle, 1);
408 gdk_font_load ("-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*");
410 default_font = gdk_font_load ("fixed");
412 g_error ("Unable to load default font.");
415 style->font = default_font;
416 gdk_font_ref (style->font);
418 style->ref_count = 1;
419 style->attach_count = 0;
420 style->colormap = NULL;
422 style->klass = (GtkStyleClass *)&default_class;
424 style->black.red = 0;
425 style->black.green = 0;
426 style->black.blue = 0;
428 style->white.red = 65535;
429 style->white.green = 65535;
430 style->white.blue = 65535;
432 style->black_gc = NULL;
433 style->white_gc = NULL;
435 style->fg[GTK_STATE_NORMAL] = gtk_default_normal_fg;
436 style->fg[GTK_STATE_ACTIVE] = gtk_default_active_fg;
437 style->fg[GTK_STATE_PRELIGHT] = gtk_default_prelight_fg;
438 style->fg[GTK_STATE_SELECTED] = gtk_default_selected_fg;
439 style->fg[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_fg;
441 style->bg[GTK_STATE_NORMAL] = gtk_default_normal_bg;
442 style->bg[GTK_STATE_ACTIVE] = gtk_default_active_bg;
443 style->bg[GTK_STATE_PRELIGHT] = gtk_default_prelight_bg;
444 style->bg[GTK_STATE_SELECTED] = gtk_default_selected_bg;
445 style->bg[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_bg;
447 for (i = 0; i < 4; i++)
449 style->text[i] = style->fg[i];
450 style->base[i] = style->white;
453 style->base[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_bg;
454 style->text[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_bg;
456 for (i = 0; i < 5; i++)
457 style->bg_pixmap[i] = NULL;
459 style->engine = NULL;
460 style->engine_data = NULL;
462 style->rc_style = NULL;
464 for (i = 0; i < 5; i++)
466 style->fg_gc[i] = NULL;
467 style->bg_gc[i] = NULL;
468 style->light_gc[i] = NULL;
469 style->dark_gc[i] = NULL;
470 style->mid_gc[i] = NULL;
471 style->text_gc[i] = NULL;
472 style->base_gc[i] = NULL;
478 /*************************************************************
480 * Attach a style to a window; this process allocates the
481 * colors and creates the GC's for the style - it specializes
482 * it to a particular visual and colormap. The process
483 * may involve the creation of a new style if the style
484 * has already been attached to a window with a different
485 * style and colormap.
490 * Either the style parameter, or a newly created style.
491 * If the style is newly created, the style parameter
492 * will be dereferenced, and the new style will have
493 * a reference count belonging to the caller.
495 * FIXME: The sequence -
496 * create a style => s1
497 * attach s1 to v1, c1 => s1
498 * attach s1 to v2, c2 => s2
499 * detach s1 from v1, c1
500 * attach s1 to v2, c2 => s3
501 * results in two separate, unlinked styles s2 and s3 which
502 * are identical and could be shared. To fix this, we would
503 * want to never remove a style from the list of linked
504 * styles as long as as it has a reference count. However, the
505 * disadvantage of doing it this way means that we would need two
506 * passes through the linked list when attaching (one to check for
507 * matching styles, one to look for empty unattached styles - but
508 * it will almost never be longer than 2 elements.
509 *************************************************************/
512 gtk_style_attach (GtkStyle *style,
516 GtkStyle *new_style = NULL;
517 GdkColormap *colormap;
520 g_return_val_if_fail (style != NULL, NULL);
521 g_return_val_if_fail (window != NULL, NULL);
523 colormap = gdk_window_get_colormap (window);
524 depth = gdk_window_get_visual (window)->depth;
527 style->styles = g_slist_append (NULL, style);
529 styles = style->styles;
532 new_style = styles->data;
534 if (new_style->attach_count == 0)
536 gtk_style_init (new_style, colormap, depth);
539 else if (new_style->colormap == colormap &&
540 new_style->depth == depth)
544 styles = styles->next;
549 new_style = gtk_style_duplicate (style);
550 gtk_style_init (new_style, colormap, depth);
553 /* A style gets a refcount from being attached */
554 if (new_style->attach_count == 0)
555 gtk_style_ref (new_style);
557 /* Another refcount belongs to the parent */
558 if (style != new_style)
560 gtk_style_unref (style);
561 gtk_style_ref (new_style);
564 new_style->attach_count++;
570 gtk_style_detach (GtkStyle *style)
574 g_return_if_fail (style != NULL);
576 style->attach_count -= 1;
577 if (style->attach_count == 0)
580 style->engine->unrealize_style (style);
582 gtk_gc_release (style->black_gc);
583 gtk_gc_release (style->white_gc);
585 for (i = 0; i < 5; i++)
587 gtk_gc_release (style->fg_gc[i]);
588 gtk_gc_release (style->bg_gc[i]);
589 gtk_gc_release (style->light_gc[i]);
590 gtk_gc_release (style->dark_gc[i]);
591 gtk_gc_release (style->mid_gc[i]);
592 gtk_gc_release (style->text_gc[i]);
593 gtk_gc_release (style->base_gc[i]);
596 gtk_style_unref (style);
601 gtk_style_ref (GtkStyle *style)
603 g_return_val_if_fail (style != NULL, NULL);
604 g_return_val_if_fail (style->ref_count > 0, NULL);
606 style->ref_count += 1;
611 gtk_style_unref (GtkStyle *style)
613 g_return_if_fail (style != NULL);
614 g_return_if_fail (style->ref_count > 0);
616 style->ref_count -= 1;
617 if (style->ref_count == 0)
618 gtk_style_destroy (style);
622 gtk_style_init (GtkStyle *style,
623 GdkColormap *colormap,
626 GdkGCValues gc_values;
627 GdkGCValuesMask gc_values_mask;
630 g_return_if_fail (style != NULL);
632 style->colormap = colormap;
633 style->depth = depth;
635 for (i = 0; i < 5; i++)
637 gtk_style_shade (&style->bg[i], &style->light[i], LIGHTNESS_MULT);
638 gtk_style_shade (&style->bg[i], &style->dark[i], DARKNESS_MULT);
640 style->mid[i].red = (style->light[i].red + style->dark[i].red) / 2;
641 style->mid[i].green = (style->light[i].green + style->dark[i].green) / 2;
642 style->mid[i].blue = (style->light[i].blue + style->dark[i].blue) / 2;
645 gdk_color_black (colormap, &style->black);
646 gdk_color_white (colormap, &style->white);
648 gc_values_mask = GDK_GC_FOREGROUND | GDK_GC_FONT;
649 if (style->font->type == GDK_FONT_FONT)
651 gc_values.font = style->font;
653 else if (style->font->type == GDK_FONT_FONTSET)
655 gc_values.font = default_font;
658 gc_values.foreground = style->black;
659 style->black_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
661 gc_values.foreground = style->white;
662 style->white_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
664 for (i = 0; i < 5; i++)
666 if (style->rc_style && style->rc_style->bg_pixmap_name[i])
667 style->bg_pixmap[i] = gtk_rc_load_image (style->colormap,
669 style->rc_style->bg_pixmap_name[i]);
671 if (!gdk_color_alloc (colormap, &style->fg[i]))
672 g_warning ("unable to allocate color: ( %d %d %d )",
673 style->fg[i].red, style->fg[i].green, style->fg[i].blue);
674 if (!gdk_color_alloc (colormap, &style->bg[i]))
675 g_warning ("unable to allocate color: ( %d %d %d )",
676 style->bg[i].red, style->bg[i].green, style->bg[i].blue);
677 if (!gdk_color_alloc (colormap, &style->light[i]))
678 g_warning ("unable to allocate color: ( %d %d %d )",
679 style->light[i].red, style->light[i].green, style->light[i].blue);
680 if (!gdk_color_alloc (colormap, &style->dark[i]))
681 g_warning ("unable to allocate color: ( %d %d %d )",
682 style->dark[i].red, style->dark[i].green, style->dark[i].blue);
683 if (!gdk_color_alloc (colormap, &style->mid[i]))
684 g_warning ("unable to allocate color: ( %d %d %d )",
685 style->mid[i].red, style->mid[i].green, style->mid[i].blue);
686 if (!gdk_color_alloc (colormap, &style->text[i]))
687 g_warning ("unable to allocate color: ( %d %d %d )",
688 style->text[i].red, style->text[i].green, style->text[i].blue);
689 if (!gdk_color_alloc (colormap, &style->base[i]))
690 g_warning ("unable to allocate color: ( %d %d %d )",
691 style->base[i].red, style->base[i].green, style->base[i].blue);
693 gc_values.foreground = style->fg[i];
694 style->fg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
696 gc_values.foreground = style->bg[i];
697 style->bg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
699 gc_values.foreground = style->light[i];
700 style->light_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
702 gc_values.foreground = style->dark[i];
703 style->dark_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
705 gc_values.foreground = style->mid[i];
706 style->mid_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
708 gc_values.foreground = style->text[i];
709 style->text_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
711 gc_values.foreground = style->base[i];
712 style->base_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
716 style->engine->realize_style (style);
720 gtk_style_destroy (GtkStyle *style)
722 g_return_if_fail (style->attach_count == 0);
726 if (style->styles->data != style)
727 g_slist_remove (style->styles, style);
730 GSList *tmp_list = style->styles->next;
734 ((GtkStyle*) tmp_list->data)->styles = style->styles->next;
735 tmp_list = tmp_list->next;
737 g_slist_free_1 (style->styles);
743 style->engine->destroy_style (style);
744 gtk_theme_engine_unref (style->engine);
747 gdk_font_unref (style->font);
749 gtk_rc_style_unref (style->rc_style);
755 gtk_draw_hline (GtkStyle *style,
757 GtkStateType state_type,
762 g_return_if_fail (style != NULL);
763 g_return_if_fail (style->klass != NULL);
764 g_return_if_fail (style->klass->draw_hline != NULL);
766 style->klass->draw_hline (style, window, state_type, NULL, NULL, NULL, x1, x2, y);
771 gtk_draw_vline (GtkStyle *style,
773 GtkStateType state_type,
778 g_return_if_fail (style != NULL);
779 g_return_if_fail (style->klass != NULL);
780 g_return_if_fail (style->klass->draw_vline != NULL);
782 style->klass->draw_vline (style, window, state_type, NULL, NULL, NULL, y1, y2, x);
787 gtk_draw_shadow (GtkStyle *style,
789 GtkStateType state_type,
790 GtkShadowType shadow_type,
796 g_return_if_fail (style != NULL);
797 g_return_if_fail (style->klass != NULL);
798 g_return_if_fail (style->klass->draw_shadow != NULL);
800 style->klass->draw_shadow (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
804 gtk_draw_polygon (GtkStyle *style,
806 GtkStateType state_type,
807 GtkShadowType shadow_type,
812 g_return_if_fail (style != NULL);
813 g_return_if_fail (style->klass != NULL);
814 g_return_if_fail (style->klass->draw_polygon != NULL);
816 style->klass->draw_polygon (style, window, state_type, shadow_type, NULL, NULL, NULL, points, npoints, fill);
820 gtk_draw_arrow (GtkStyle *style,
822 GtkStateType state_type,
823 GtkShadowType shadow_type,
824 GtkArrowType arrow_type,
831 g_return_if_fail (style != NULL);
832 g_return_if_fail (style->klass != NULL);
833 g_return_if_fail (style->klass->draw_arrow != NULL);
835 style->klass->draw_arrow (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, fill, x, y, width, height);
840 gtk_draw_diamond (GtkStyle *style,
842 GtkStateType state_type,
843 GtkShadowType shadow_type,
849 g_return_if_fail (style != NULL);
850 g_return_if_fail (style->klass != NULL);
851 g_return_if_fail (style->klass->draw_diamond != NULL);
853 style->klass->draw_diamond (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
858 gtk_draw_oval (GtkStyle *style,
860 GtkStateType state_type,
861 GtkShadowType shadow_type,
867 g_return_if_fail (style != NULL);
868 g_return_if_fail (style->klass != NULL);
869 g_return_if_fail (style->klass->draw_oval != NULL);
871 style->klass->draw_oval (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
875 gtk_draw_string (GtkStyle *style,
877 GtkStateType state_type,
882 g_return_if_fail (style != NULL);
883 g_return_if_fail (style->klass != NULL);
884 g_return_if_fail (style->klass->draw_string != NULL);
886 style->klass->draw_string (style, window, state_type, NULL, NULL, NULL, x, y, string);
890 gtk_draw_box (GtkStyle *style,
892 GtkStateType state_type,
893 GtkShadowType shadow_type,
899 g_return_if_fail (style != NULL);
900 g_return_if_fail (style->klass != NULL);
901 g_return_if_fail (style->klass->draw_box != NULL);
903 style->klass->draw_box (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
907 gtk_draw_flat_box (GtkStyle *style,
909 GtkStateType state_type,
910 GtkShadowType shadow_type,
916 g_return_if_fail (style != NULL);
917 g_return_if_fail (style->klass != NULL);
918 g_return_if_fail (style->klass->draw_flat_box != NULL);
920 style->klass->draw_flat_box (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
924 gtk_draw_check (GtkStyle *style,
926 GtkStateType state_type,
927 GtkShadowType shadow_type,
933 g_return_if_fail (style != NULL);
934 g_return_if_fail (style->klass != NULL);
935 g_return_if_fail (style->klass->draw_check != NULL);
937 style->klass->draw_check (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
941 gtk_draw_option (GtkStyle *style,
943 GtkStateType state_type,
944 GtkShadowType shadow_type,
950 g_return_if_fail (style != NULL);
951 g_return_if_fail (style->klass != NULL);
952 g_return_if_fail (style->klass->draw_option != NULL);
954 style->klass->draw_option (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
958 gtk_draw_cross (GtkStyle *style,
960 GtkStateType state_type,
961 GtkShadowType shadow_type,
967 g_return_if_fail (style != NULL);
968 g_return_if_fail (style->klass != NULL);
969 g_return_if_fail (style->klass->draw_cross != NULL);
971 style->klass->draw_cross (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
975 gtk_draw_ramp (GtkStyle *style,
977 GtkStateType state_type,
978 GtkShadowType shadow_type,
979 GtkArrowType arrow_type,
985 g_return_if_fail (style != NULL);
986 g_return_if_fail (style->klass != NULL);
987 g_return_if_fail (style->klass->draw_ramp != NULL);
989 style->klass->draw_ramp (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, x, y, width, height);
993 gtk_draw_tab (GtkStyle *style,
995 GtkStateType state_type,
996 GtkShadowType shadow_type,
1002 g_return_if_fail (style != NULL);
1003 g_return_if_fail (style->klass != NULL);
1004 g_return_if_fail (style->klass->draw_tab != NULL);
1006 style->klass->draw_tab (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
1010 gtk_draw_shadow_gap (GtkStyle *style,
1012 GtkStateType state_type,
1013 GtkShadowType shadow_type,
1018 GtkPositionType gap_side,
1022 g_return_if_fail (style != NULL);
1023 g_return_if_fail (style->klass != NULL);
1024 g_return_if_fail (style->klass->draw_shadow_gap != NULL);
1026 style->klass->draw_shadow_gap (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width);
1030 gtk_draw_box_gap (GtkStyle *style,
1032 GtkStateType state_type,
1033 GtkShadowType shadow_type,
1038 GtkPositionType gap_side,
1042 g_return_if_fail (style != NULL);
1043 g_return_if_fail (style->klass != NULL);
1044 g_return_if_fail (style->klass->draw_box_gap != NULL);
1046 style->klass->draw_box_gap (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width);
1050 gtk_draw_extension (GtkStyle *style,
1052 GtkStateType state_type,
1053 GtkShadowType shadow_type,
1058 GtkPositionType gap_side)
1060 g_return_if_fail (style != NULL);
1061 g_return_if_fail (style->klass != NULL);
1062 g_return_if_fail (style->klass->draw_extension != NULL);
1064 style->klass->draw_extension (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side);
1068 gtk_draw_focus (GtkStyle *style,
1075 g_return_if_fail (style != NULL);
1076 g_return_if_fail (style->klass != NULL);
1077 g_return_if_fail (style->klass->draw_focus != NULL);
1079 style->klass->draw_focus (style, window, NULL, NULL, NULL, x, y, width, height);
1083 gtk_draw_slider (GtkStyle *style,
1085 GtkStateType state_type,
1086 GtkShadowType shadow_type,
1091 GtkOrientation orientation)
1093 g_return_if_fail (style != NULL);
1094 g_return_if_fail (style->klass != NULL);
1095 g_return_if_fail (style->klass->draw_slider != NULL);
1097 style->klass->draw_slider (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
1101 gtk_draw_handle (GtkStyle *style,
1103 GtkStateType state_type,
1104 GtkShadowType shadow_type,
1109 GtkOrientation orientation)
1111 g_return_if_fail (style != NULL);
1112 g_return_if_fail (style->klass != NULL);
1113 g_return_if_fail (style->klass->draw_handle != NULL);
1115 style->klass->draw_handle (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
1119 gtk_style_set_background (GtkStyle *style,
1121 GtkStateType state_type)
1124 gint parent_relative;
1126 g_return_if_fail (style != NULL);
1127 g_return_if_fail (window != NULL);
1129 if (style->engine && style->engine->set_background)
1131 style->engine->set_background (style, window, state_type);
1136 if (style->bg_pixmap[state_type])
1138 if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
1141 parent_relative = TRUE;
1145 pixmap = style->bg_pixmap[state_type];
1146 parent_relative = FALSE;
1149 gdk_window_set_back_pixmap (window, pixmap, parent_relative);
1152 gdk_window_set_background (window, &style->bg[state_type]);
1156 /* Default functions */
1158 gtk_style_apply_default_background (GtkStyle *style,
1161 GtkStateType state_type,
1168 GdkRectangle new_rect, old_rect;
1174 old_rect.width = width;
1175 old_rect.height = height;
1177 if (!gdk_rectangle_intersect (area, &old_rect, &new_rect))
1184 new_rect.width = width;
1185 new_rect.height = height;
1188 if (!style->bg_pixmap[state_type] ||
1189 gdk_window_get_type (window) == GDK_WINDOW_PIXMAP ||
1190 (!set_bg && style->bg_pixmap[state_type] != (GdkPixmap*) GDK_PARENT_RELATIVE))
1192 GdkGC *gc = style->bg_gc[state_type];
1194 if (style->bg_pixmap[state_type])
1196 gdk_gc_set_fill (gc, GDK_TILED);
1197 gdk_gc_set_tile (gc, style->bg_pixmap[state_type]);
1200 gdk_draw_rectangle (window, gc, TRUE,
1201 new_rect.x, new_rect.y, new_rect.width, new_rect.height);
1202 if (style->bg_pixmap[state_type])
1203 gdk_gc_set_fill (gc, GDK_SOLID);
1209 if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
1210 gdk_window_set_back_pixmap (window, NULL, TRUE);
1212 gdk_window_set_back_pixmap (window, style->bg_pixmap[state_type], FALSE);
1215 gdk_window_clear_area (window,
1216 new_rect.x, new_rect.y,
1217 new_rect.width, new_rect.height);
1222 gtk_default_draw_hline (GtkStyle *style,
1224 GtkStateType state_type,
1227 const gchar *detail,
1232 gint thickness_light;
1233 gint thickness_dark;
1236 g_return_if_fail (style != NULL);
1237 g_return_if_fail (window != NULL);
1239 thickness_light = style->klass->ythickness / 2;
1240 thickness_dark = style->klass->ythickness - thickness_light;
1244 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1245 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1248 if (detail && !strcmp (detail, "label"))
1250 if (state_type == GTK_STATE_INSENSITIVE)
1251 gdk_draw_line (window, style->white_gc, x1 + 1, y + 1, x2 + 1, y + 1);
1252 gdk_draw_line (window, style->fg_gc[state_type], x1, y, x2, y);
1256 for (i = 0; i < thickness_dark; i++)
1258 gdk_draw_line (window, style->light_gc[state_type], x2 - i - 1, y + i, x2, y + i);
1259 gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x2 - i - 1, y + i);
1262 y += thickness_dark;
1263 for (i = 0; i < thickness_light; i++)
1265 gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x1 + thickness_light - i - 1, y + i);
1266 gdk_draw_line (window, style->light_gc[state_type], x1 + thickness_light - i - 1, y + i, x2, y + i);
1272 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
1273 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
1279 gtk_default_draw_vline (GtkStyle *style,
1281 GtkStateType state_type,
1284 const gchar *detail,
1289 gint thickness_light;
1290 gint thickness_dark;
1293 g_return_if_fail (style != NULL);
1294 g_return_if_fail (window != NULL);
1296 thickness_light = style->klass->xthickness / 2;
1297 thickness_dark = style->klass->xthickness - thickness_light;
1301 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1302 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1304 for (i = 0; i < thickness_dark; i++)
1306 gdk_draw_line (window, style->light_gc[state_type], x + i, y2 - i - 1, x + i, y2);
1307 gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y2 - i - 1);
1310 x += thickness_dark;
1311 for (i = 0; i < thickness_light; i++)
1313 gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y1 + thickness_light - i);
1314 gdk_draw_line (window, style->light_gc[state_type], x + i, y1 + thickness_light - i, x + i, y2);
1318 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
1319 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
1325 gtk_default_draw_shadow (GtkStyle *style,
1327 GtkStateType state_type,
1328 GtkShadowType shadow_type,
1331 const gchar *detail,
1339 gint thickness_light;
1340 gint thickness_dark;
1343 g_return_if_fail (style != NULL);
1344 g_return_if_fail (window != NULL);
1346 if ((width == -1) && (height == -1))
1347 gdk_window_get_size (window, &width, &height);
1348 else if (width == -1)
1349 gdk_window_get_size (window, &width, NULL);
1350 else if (height == -1)
1351 gdk_window_get_size (window, NULL, &height);
1353 switch (shadow_type)
1355 case GTK_SHADOW_NONE:
1358 case GTK_SHADOW_ETCHED_IN:
1359 gc1 = style->light_gc[state_type];
1360 gc2 = style->dark_gc[state_type];
1362 case GTK_SHADOW_OUT:
1363 case GTK_SHADOW_ETCHED_OUT:
1364 gc1 = style->dark_gc[state_type];
1365 gc2 = style->light_gc[state_type];
1371 gdk_gc_set_clip_rectangle (gc1, area);
1372 gdk_gc_set_clip_rectangle (gc2, area);
1373 if (shadow_type == GTK_SHADOW_IN ||
1374 shadow_type == GTK_SHADOW_OUT)
1376 gdk_gc_set_clip_rectangle (style->black_gc, area);
1377 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
1381 switch (shadow_type)
1383 case GTK_SHADOW_NONE:
1387 gdk_draw_line (window, gc1,
1388 x, y + height - 1, x + width - 1, y + height - 1);
1389 gdk_draw_line (window, gc1,
1390 x + width - 1, y, x + width - 1, y + height - 1);
1392 gdk_draw_line (window, style->bg_gc[state_type],
1393 x + 1, y + height - 2, x + width - 2, y + height - 2);
1394 gdk_draw_line (window, style->bg_gc[state_type],
1395 x + width - 2, y + 1, x + width - 2, y + height - 2);
1397 gdk_draw_line (window, style->black_gc,
1398 x + 1, y + 1, x + width - 2, y + 1);
1399 gdk_draw_line (window, style->black_gc,
1400 x + 1, y + 1, x + 1, y + height - 2);
1402 gdk_draw_line (window, gc2,
1403 x, y, x + width - 1, y);
1404 gdk_draw_line (window, gc2,
1405 x, y, x, y + height - 1);
1408 case GTK_SHADOW_OUT:
1409 gdk_draw_line (window, gc1,
1410 x + 1, y + height - 2, x + width - 2, y + height - 2);
1411 gdk_draw_line (window, gc1,
1412 x + width - 2, y + 1, x + width - 2, y + height - 2);
1414 gdk_draw_line (window, gc2,
1415 x, y, x + width - 1, y);
1416 gdk_draw_line (window, gc2,
1417 x, y, x, y + height - 1);
1419 gdk_draw_line (window, style->bg_gc[state_type],
1420 x + 1, y + 1, x + width - 2, y + 1);
1421 gdk_draw_line (window, style->bg_gc[state_type],
1422 x + 1, y + 1, x + 1, y + height - 2);
1424 gdk_draw_line (window, style->black_gc,
1425 x, y + height - 1, x + width - 1, y + height - 1);
1426 gdk_draw_line (window, style->black_gc,
1427 x + width - 1, y, x + width - 1, y + height - 1);
1430 case GTK_SHADOW_ETCHED_IN:
1431 case GTK_SHADOW_ETCHED_OUT:
1432 thickness_light = 1;
1435 for (i = 0; i < thickness_dark; i++)
1437 gdk_draw_line (window, gc1,
1441 y + height - i - 1);
1442 gdk_draw_line (window, gc1,
1446 y + height - i - 1);
1448 gdk_draw_line (window, gc2,
1453 gdk_draw_line (window, gc2,
1457 y + height - i - 2);
1460 for (i = 0; i < thickness_light; i++)
1462 gdk_draw_line (window, gc1,
1463 x + thickness_dark + i,
1464 y + thickness_dark + i,
1465 x + width - thickness_dark - i - 1,
1466 y + thickness_dark + i);
1467 gdk_draw_line (window, gc1,
1468 x + thickness_dark + i,
1469 y + thickness_dark + i,
1470 x + thickness_dark + i,
1471 y + height - thickness_dark - i - 1);
1473 gdk_draw_line (window, gc2,
1474 x + thickness_dark + i,
1475 y + height - thickness_light - i - 1,
1476 x + width - thickness_light - 1,
1477 y + height - thickness_light - i - 1);
1478 gdk_draw_line (window, gc2,
1479 x + width - thickness_light - i - 1,
1480 y + thickness_dark + i,
1481 x + width - thickness_light - i - 1,
1482 y + height - thickness_light - 1);
1488 gdk_gc_set_clip_rectangle (gc1, NULL);
1489 gdk_gc_set_clip_rectangle (gc2, NULL);
1490 if (shadow_type == GTK_SHADOW_IN ||
1491 shadow_type == GTK_SHADOW_OUT)
1493 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
1494 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
1500 gtk_default_draw_polygon (GtkStyle *style,
1502 GtkStateType state_type,
1503 GtkShadowType shadow_type,
1506 const gchar *detail,
1511 static const gdouble pi_over_4 = M_PI_4;
1512 static const gdouble pi_3_over_4 = M_PI_4 * 3;
1522 g_return_if_fail (style != NULL);
1523 g_return_if_fail (window != NULL);
1524 g_return_if_fail (points != NULL);
1526 switch (shadow_type)
1529 gc1 = style->bg_gc[state_type];
1530 gc2 = style->dark_gc[state_type];
1531 gc3 = style->light_gc[state_type];
1532 gc4 = style->black_gc;
1534 case GTK_SHADOW_ETCHED_IN:
1535 gc1 = style->light_gc[state_type];
1536 gc2 = style->dark_gc[state_type];
1537 gc3 = style->dark_gc[state_type];
1538 gc4 = style->light_gc[state_type];
1540 case GTK_SHADOW_OUT:
1541 gc1 = style->dark_gc[state_type];
1542 gc2 = style->light_gc[state_type];
1543 gc3 = style->black_gc;
1544 gc4 = style->bg_gc[state_type];
1546 case GTK_SHADOW_ETCHED_OUT:
1547 gc1 = style->dark_gc[state_type];
1548 gc2 = style->light_gc[state_type];
1549 gc3 = style->light_gc[state_type];
1550 gc4 = style->dark_gc[state_type];
1558 gdk_gc_set_clip_rectangle (gc1, area);
1559 gdk_gc_set_clip_rectangle (gc2, area);
1560 gdk_gc_set_clip_rectangle (gc3, area);
1561 gdk_gc_set_clip_rectangle (gc4, area);
1565 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, npoints);
1569 for (i = 0; i < npoints; i++)
1571 if ((points[i].x == points[i+1].x) &&
1572 (points[i].y == points[i+1].y))
1578 angle = atan2 (points[i+1].y - points[i].y,
1579 points[i+1].x - points[i].x);
1582 if ((angle > -pi_3_over_4) && (angle < pi_over_4))
1584 if (angle > -pi_over_4)
1595 gdk_draw_line (window, gc1,
1596 points[i].x-xadjust, points[i].y-yadjust,
1597 points[i+1].x-xadjust, points[i+1].y-yadjust);
1598 gdk_draw_line (window, gc3,
1599 points[i].x, points[i].y,
1600 points[i+1].x, points[i+1].y);
1604 if ((angle < -pi_3_over_4) || (angle > pi_3_over_4))
1615 gdk_draw_line (window, gc4,
1616 points[i].x+xadjust, points[i].y+yadjust,
1617 points[i+1].x+xadjust, points[i+1].y+yadjust);
1618 gdk_draw_line (window, gc2,
1619 points[i].x, points[i].y,
1620 points[i+1].x, points[i+1].y);
1626 gdk_gc_set_clip_rectangle (gc1, NULL);
1627 gdk_gc_set_clip_rectangle (gc2, NULL);
1628 gdk_gc_set_clip_rectangle (gc3, NULL);
1629 gdk_gc_set_clip_rectangle (gc4, NULL);
1634 gtk_default_draw_arrow (GtkStyle *style,
1636 GtkStateType state_type,
1637 GtkShadowType shadow_type,
1640 const gchar *detail,
1641 GtkArrowType arrow_type,
1656 g_return_if_fail (style != NULL);
1657 g_return_if_fail (window != NULL);
1659 switch (shadow_type)
1662 gc1 = style->bg_gc[state_type];
1663 gc2 = style->dark_gc[state_type];
1664 gc3 = style->light_gc[state_type];
1665 gc4 = style->black_gc;
1667 case GTK_SHADOW_OUT:
1668 gc1 = style->dark_gc[state_type];
1669 gc2 = style->light_gc[state_type];
1670 gc3 = style->black_gc;
1671 gc4 = style->bg_gc[state_type];
1673 case GTK_SHADOW_ETCHED_IN:
1674 gc1 = style->light_gc[state_type];
1675 gc2 = style->dark_gc[state_type];
1679 case GTK_SHADOW_ETCHED_OUT:
1680 gc1 = style->dark_gc[state_type];
1681 gc2 = style->light_gc[state_type];
1689 if ((width == -1) && (height == -1))
1690 gdk_window_get_size (window, &width, &height);
1691 else if (width == -1)
1692 gdk_window_get_size (window, &width, NULL);
1693 else if (height == -1)
1694 gdk_window_get_size (window, NULL, &height);
1696 half_width = width / 2;
1697 half_height = height / 2;
1701 gdk_gc_set_clip_rectangle (gc1, area);
1702 gdk_gc_set_clip_rectangle (gc2, area);
1705 gdk_gc_set_clip_rectangle (gc3, area);
1706 gdk_gc_set_clip_rectangle (gc4, area);
1715 points[0].x = x + half_width;
1718 points[1].y = y + height - 1;
1719 points[2].x = x + width - 1;
1720 points[2].y = y + height - 1;
1722 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1725 switch (shadow_type)
1728 case GTK_SHADOW_OUT:
1730 gdk_draw_line (window, gc1,
1731 x + 1, y + height - 2,
1732 x + width - 2, y + height - 2);
1733 gdk_draw_line (window, gc3,
1734 x + 0, y + height - 1,
1735 x + width - 1, y + height - 1);
1737 gdk_draw_line (window, gc1,
1738 x + width - 2, y + height - 1,
1739 x + half_width, y + 1);
1740 gdk_draw_line (window, gc3,
1741 x + width - 1, y + height - 1,
1744 gdk_draw_line (window, gc4,
1745 x + half_width, y + 1,
1746 x + 1, y + height - 1);
1747 gdk_draw_line (window, gc2,
1752 case GTK_SHADOW_ETCHED_IN:
1753 case GTK_SHADOW_ETCHED_OUT:
1754 gdk_draw_line (window, gc1,
1755 x + half_width, y + 1,
1756 x + 1, y + height - 1);
1757 gdk_draw_line (window, gc1,
1758 x + 1, y + height - 1,
1759 x + width - 1, y + height - 1);
1760 gdk_draw_line (window, gc1,
1761 x + width - 1, y + height - 1,
1762 x + half_width + 1, y + 1);
1764 points[0].x = x + half_width;
1767 points[1].y = y + height - 2;
1768 points[2].x = x + width - 2;
1769 points[2].y = y + height - 2;
1771 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1779 case GTK_ARROW_DOWN:
1782 points[0].x = x + width - 1;
1786 points[2].x = x + half_width;
1787 points[2].y = y + height - 1;
1789 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1791 switch (shadow_type)
1794 case GTK_SHADOW_OUT:
1795 gdk_draw_line (window, gc4,
1797 y + 1, x + 1, y + 1);
1798 gdk_draw_line (window, gc2,
1802 gdk_draw_line (window, gc4,
1804 x + half_width, y + height - 2);
1805 gdk_draw_line (window, gc2,
1807 x + half_width, y + height - 1);
1809 gdk_draw_line (window, gc1,
1810 x + half_width, y + height - 2,
1812 gdk_draw_line (window, gc3,
1813 x + half_width, y + height - 1,
1817 case GTK_SHADOW_ETCHED_IN:
1818 case GTK_SHADOW_ETCHED_OUT:
1819 gdk_draw_line (window, gc1,
1820 x + width - 1, y + 1,
1822 gdk_draw_line (window, gc1,
1824 x + half_width + 1, y + height - 1);
1825 gdk_draw_line (window, gc1,
1826 x + half_width + 1, y + height - 2,
1829 points[0].x = x + width - 2;
1833 points[2].x = x + half_width;
1834 points[2].y = y + height - 2;
1836 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1843 case GTK_ARROW_LEFT:
1847 points[0].y = y + half_height;
1848 points[1].x = x + width - 1;
1849 points[1].y = y + height - 1;
1850 points[2].x = x + width - 1;
1853 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1856 switch (shadow_type)
1859 case GTK_SHADOW_OUT:
1860 gdk_draw_line (window, gc1,
1861 x + 1, y + half_height,
1862 x + width - 1, y + height - 1);
1863 gdk_draw_line (window, gc3,
1865 x + width - 1, y + height - 1);
1867 gdk_draw_line (window, gc1,
1868 x + width - 2, y + height - 1,
1869 x + width - 2, y + 1);
1870 gdk_draw_line (window, gc3,
1871 x + width - 1, y + height - 1,
1874 gdk_draw_line (window, gc4,
1875 x + width - 1, y + 1,
1876 x + 1, y + half_height);
1877 gdk_draw_line (window, gc2,
1879 x, y + half_height);
1882 case GTK_SHADOW_ETCHED_IN:
1883 case GTK_SHADOW_ETCHED_OUT:
1884 gdk_draw_line (window, gc1,
1885 x + width - 1, y + 1,
1886 x + 1, y + half_height);
1887 gdk_draw_line (window, gc1,
1888 x + 1, y + half_height + 1,
1889 x + width - 1, y + height - 1);
1890 gdk_draw_line (window, gc1,
1891 x + width - 1, y + height - 1,
1892 x + width - 1, y + 1);
1894 points[0].x = x + width - 2;
1897 points[1].y = y + half_height;
1898 points[2].x = x + width - 2;
1899 points[2].y = y + height - 2;
1901 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1908 case GTK_ARROW_RIGHT:
1911 points[0].x = x + width - 1;
1912 points[0].y = y + half_height;
1916 points[2].y = y + height - 1;
1918 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3);
1921 switch (shadow_type)
1924 case GTK_SHADOW_OUT:
1925 gdk_draw_line (window, gc4,
1926 x + width - 1, y + half_height,
1928 gdk_draw_line (window, gc2,
1929 x + width - 1, y + half_height,
1931 gdk_draw_line (window, gc4,
1933 x + 1, y + height - 2);
1934 gdk_draw_line (window, gc2,
1938 gdk_draw_line (window, gc1,
1939 x + 1, y + height - 2,
1940 x + width - 1, y + half_height);
1941 gdk_draw_line (window, gc3,
1943 x + width - 1, y + half_height);
1946 case GTK_SHADOW_ETCHED_IN:
1947 case GTK_SHADOW_ETCHED_OUT:
1948 gdk_draw_line (window, gc1,
1949 x + width - 1, y + half_height + 1,
1951 gdk_draw_line (window, gc1,
1953 x + 1, y + height - 1);
1954 gdk_draw_line (window, gc1,
1955 x + 1, y + height - 1,
1956 x + width - 1, y + half_height + 1);
1958 points[0].x = x + width - 2;
1959 points[0].y = y + half_height;
1963 points[2].y = y + height - 1;
1965 gdk_draw_polygon (window, gc2, FALSE, points, 3);
1976 gdk_gc_set_clip_rectangle (gc1, NULL);
1977 gdk_gc_set_clip_rectangle (gc2, NULL);
1980 gdk_gc_set_clip_rectangle (gc3, NULL);
1981 gdk_gc_set_clip_rectangle (gc4, NULL);
1987 gtk_default_draw_diamond (GtkStyle *style,
1989 GtkStateType state_type,
1990 GtkShadowType shadow_type,
1993 const gchar *detail,
2002 g_return_if_fail (style != NULL);
2003 g_return_if_fail (window != NULL);
2005 if ((width == -1) && (height == -1))
2006 gdk_window_get_size (window, &width, &height);
2007 else if (width == -1)
2008 gdk_window_get_size (window, &width, NULL);
2009 else if (height == -1)
2010 gdk_window_get_size (window, NULL, &height);
2012 half_width = width / 2;
2013 half_height = height / 2;
2017 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
2018 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
2019 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
2020 gdk_gc_set_clip_rectangle (style->black_gc, area);
2022 switch (shadow_type)
2025 gdk_draw_line (window, style->bg_gc[state_type],
2026 x + 2, y + half_height,
2027 x + half_width, y + height - 2);
2028 gdk_draw_line (window, style->bg_gc[state_type],
2029 x + half_width, y + height - 2,
2030 x + width - 2, y + half_height);
2031 gdk_draw_line (window, style->light_gc[state_type],
2032 x + 1, y + half_height,
2033 x + half_width, y + height - 1);
2034 gdk_draw_line (window, style->light_gc[state_type],
2035 x + half_width, y + height - 1,
2036 x + width - 1, y + half_height);
2037 gdk_draw_line (window, style->light_gc[state_type],
2039 x + half_width, y + height);
2040 gdk_draw_line (window, style->light_gc[state_type],
2041 x + half_width, y + height,
2042 x + width, y + half_height);
2044 gdk_draw_line (window, style->black_gc,
2045 x + 2, y + half_height,
2046 x + half_width, y + 2);
2047 gdk_draw_line (window, style->black_gc,
2048 x + half_width, y + 2,
2049 x + width - 2, y + half_height);
2050 gdk_draw_line (window, style->dark_gc[state_type],
2051 x + 1, y + half_height,
2052 x + half_width, y + 1);
2053 gdk_draw_line (window, style->dark_gc[state_type],
2054 x + half_width, y + 1,
2055 x + width - 1, y + half_height);
2056 gdk_draw_line (window, style->dark_gc[state_type],
2059 gdk_draw_line (window, style->dark_gc[state_type],
2061 x + width, y + half_height);
2063 case GTK_SHADOW_OUT:
2064 gdk_draw_line (window, style->dark_gc[state_type],
2065 x + 2, y + half_height,
2066 x + half_width, y + height - 2);
2067 gdk_draw_line (window, style->dark_gc[state_type],
2068 x + half_width, y + height - 2,
2069 x + width - 2, y + half_height);
2070 gdk_draw_line (window, style->dark_gc[state_type],
2071 x + 1, y + half_height,
2072 x + half_width, y + height - 1);
2073 gdk_draw_line (window, style->dark_gc[state_type],
2074 x + half_width, y + height - 1,
2075 x + width - 1, y + half_height);
2076 gdk_draw_line (window, style->black_gc,
2078 x + half_width, y + height);
2079 gdk_draw_line (window, style->black_gc,
2080 x + half_width, y + height,
2081 x + width, y + half_height);
2083 gdk_draw_line (window, style->bg_gc[state_type],
2084 x + 2, y + half_height,
2085 x + half_width, y + 2);
2086 gdk_draw_line (window, style->bg_gc[state_type],
2087 x + half_width, y + 2,
2088 x + width - 2, y + half_height);
2089 gdk_draw_line (window, style->light_gc[state_type],
2090 x + 1, y + half_height,
2091 x + half_width, y + 1);
2092 gdk_draw_line (window, style->light_gc[state_type],
2093 x + half_width, y + 1,
2094 x + width - 1, y + half_height);
2095 gdk_draw_line (window, style->light_gc[state_type],
2098 gdk_draw_line (window, style->light_gc[state_type],
2100 x + width, y + half_height);
2107 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
2108 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2109 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
2110 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2115 gtk_default_draw_oval (GtkStyle *style,
2117 GtkStateType state_type,
2118 GtkShadowType shadow_type,
2121 const gchar *detail,
2127 g_return_if_fail (style != NULL);
2128 g_return_if_fail (window != NULL);
2130 g_warning ("gtk_default_draw_oval(): FIXME, this function is currently unimplemented");
2134 gtk_default_draw_string (GtkStyle *style,
2136 GtkStateType state_type,
2139 const gchar *detail,
2142 const gchar *string)
2144 g_return_if_fail (style != NULL);
2145 g_return_if_fail (window != NULL);
2149 gdk_gc_set_clip_rectangle (style->white_gc, area);
2150 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], area);
2153 if (state_type == GTK_STATE_INSENSITIVE)
2154 gdk_draw_string (window, style->font, style->white_gc, x + 1, y + 1, string);
2156 gdk_draw_string (window, style->font, style->fg_gc[state_type], x, y, string);
2160 gdk_gc_set_clip_rectangle (style->white_gc, NULL);
2161 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], NULL);
2166 gtk_default_draw_box (GtkStyle *style,
2168 GtkStateType state_type,
2169 GtkShadowType shadow_type,
2172 const gchar *detail,
2178 g_return_if_fail (style != NULL);
2179 g_return_if_fail (window != NULL);
2181 if (width == -1 && height == -1)
2182 gdk_window_get_size (window, &width, &height);
2183 else if (width == -1)
2184 gdk_window_get_size (window, &width, NULL);
2185 else if (height == -1)
2186 gdk_window_get_size (window, NULL, &height);
2188 if (!style->bg_pixmap[state_type] ||
2189 gdk_window_get_type (window) == GDK_WINDOW_PIXMAP)
2192 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
2194 gdk_draw_rectangle (window, style->bg_gc[state_type], TRUE,
2195 x, y, width, height);
2197 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2200 gtk_style_apply_default_background (style, window,
2201 widget && !GTK_WIDGET_NO_WINDOW (widget),
2202 state_type, area, x, y, width, height);
2204 gtk_paint_shadow (style, window, state_type, shadow_type, area, widget, detail,
2205 x, y, width, height);
2209 gtk_default_draw_flat_box (GtkStyle *style,
2211 GtkStateType state_type,
2212 GtkShadowType shadow_type,
2215 const gchar *detail,
2223 g_return_if_fail (style != NULL);
2224 g_return_if_fail (window != NULL);
2226 if (width == -1 && height == -1)
2227 gdk_window_get_size (window, &width, &height);
2228 else if (width == -1)
2229 gdk_window_get_size (window, &width, NULL);
2230 else if (height == -1)
2231 gdk_window_get_size (window, NULL, &height);
2235 if (!strcmp ("text", detail) && state_type == GTK_STATE_SELECTED)
2236 gc1 = style->bg_gc[GTK_STATE_SELECTED];
2237 else if (!strcmp ("viewportbin", detail))
2238 gc1 = style->bg_gc[GTK_STATE_NORMAL];
2239 else if (!strcmp ("entry_bg", detail))
2240 gc1 = style->base_gc[state_type];
2242 gc1 = style->bg_gc[state_type];
2245 gc1 = style->bg_gc[state_type];
2247 if (!style->bg_pixmap[state_type] || gc1 != style->bg_gc[state_type] ||
2248 gdk_window_get_type (window) == GDK_WINDOW_PIXMAP)
2251 gdk_gc_set_clip_rectangle (gc1, area);
2253 gdk_draw_rectangle (window, gc1, TRUE,
2254 x, y, width, height);
2256 if (detail && !strcmp ("tooltip", detail))
2257 gdk_draw_rectangle (window, style->black_gc, FALSE,
2258 x, y, width - 1, height - 1);
2261 gdk_gc_set_clip_rectangle (gc1, NULL);
2264 gtk_style_apply_default_background (style, window,
2265 widget && !GTK_WIDGET_NO_WINDOW (widget),
2266 state_type, area, x, y, width, height);
2270 gtk_default_draw_check (GtkStyle *style,
2272 GtkStateType state_type,
2273 GtkShadowType shadow_type,
2276 const gchar *detail,
2282 gtk_paint_box (style, window, state_type, shadow_type, area, widget, detail,
2283 x, y, width, height);
2287 gtk_default_draw_option (GtkStyle *style,
2289 GtkStateType state_type,
2290 GtkShadowType shadow_type,
2293 const gchar *detail,
2299 gtk_paint_diamond (style, window, state_type, shadow_type, area, widget,
2300 detail, x, y, width, height);
2304 gtk_default_draw_cross (GtkStyle *style,
2306 GtkStateType state_type,
2307 GtkShadowType shadow_type,
2310 const gchar *detail,
2316 g_return_if_fail (style != NULL);
2317 g_return_if_fail (window != NULL);
2319 g_warning ("gtk_default_draw_cross(): FIXME, this function is currently unimplemented");
2323 gtk_default_draw_ramp (GtkStyle *style,
2325 GtkStateType state_type,
2326 GtkShadowType shadow_type,
2329 const gchar *detail,
2330 GtkArrowType arrow_type,
2336 g_return_if_fail (style != NULL);
2337 g_return_if_fail (window != NULL);
2339 g_warning ("gtk_default_draw_ramp(): FIXME, this function is currently unimplemented");
2343 gtk_default_draw_tab (GtkStyle *style,
2345 GtkStateType state_type,
2346 GtkShadowType shadow_type,
2349 const gchar *detail,
2355 g_return_if_fail (style != NULL);
2356 g_return_if_fail (window != NULL);
2358 gtk_paint_box (style, window, state_type, shadow_type, area, widget, detail,
2359 x, y, width, height);
2363 gtk_default_draw_shadow_gap (GtkStyle *style,
2365 GtkStateType state_type,
2366 GtkShadowType shadow_type,
2369 const gchar *detail,
2374 GtkPositionType gap_side,
2383 g_return_if_fail (style != NULL);
2384 g_return_if_fail (window != NULL);
2386 if (width == -1 && height == -1)
2387 gdk_window_get_size (window, &width, &height);
2388 else if (width == -1)
2389 gdk_window_get_size (window, &width, NULL);
2390 else if (height == -1)
2391 gdk_window_get_size (window, NULL, &height);
2393 switch (shadow_type)
2395 case GTK_SHADOW_NONE:
2398 gc1 = style->dark_gc[state_type];
2399 gc2 = style->black_gc;
2400 gc3 = style->bg_gc[state_type];
2401 gc4 = style->light_gc[state_type];
2403 case GTK_SHADOW_ETCHED_IN:
2404 gc1 = style->dark_gc[state_type];
2405 gc2 = style->light_gc[state_type];
2406 gc3 = style->dark_gc[state_type];
2407 gc4 = style->light_gc[state_type];
2409 case GTK_SHADOW_OUT:
2410 gc1 = style->light_gc[state_type];
2411 gc2 = style->bg_gc[state_type];
2412 gc3 = style->dark_gc[state_type];
2413 gc4 = style->black_gc;
2415 case GTK_SHADOW_ETCHED_OUT:
2416 gc1 = style->light_gc[state_type];
2417 gc2 = style->dark_gc[state_type];
2418 gc3 = style->light_gc[state_type];
2419 gc4 = style->dark_gc[state_type];
2424 gdk_gc_set_clip_rectangle (gc1, area);
2425 gdk_gc_set_clip_rectangle (gc2, area);
2426 gdk_gc_set_clip_rectangle (gc3, area);
2427 gdk_gc_set_clip_rectangle (gc4, area);
2430 switch (shadow_type)
2432 case GTK_SHADOW_NONE:
2434 case GTK_SHADOW_OUT:
2435 case GTK_SHADOW_ETCHED_IN:
2436 case GTK_SHADOW_ETCHED_OUT:
2440 gdk_draw_line (window, gc1,
2441 x, y, x, y + height - 1);
2442 gdk_draw_line (window, gc2,
2443 x + 1, y, x + 1, y + height - 2);
2445 gdk_draw_line (window, gc3,
2446 x + 1, y + height - 2, x + width - 2, y + height - 2);
2447 gdk_draw_line (window, gc3,
2448 x + width - 2, y, x + width - 2, y + height - 2);
2449 gdk_draw_line (window, gc4,
2450 x, y + height - 1, x + width - 1, y + height - 1);
2451 gdk_draw_line (window, gc4,
2452 x + width - 1, y, x + width - 1, y + height - 1);
2455 gdk_draw_line (window, gc1,
2456 x, y, x + gap_x - 1, y);
2457 gdk_draw_line (window, gc2,
2458 x + 1, y + 1, x + gap_x - 1, y + 1);
2459 gdk_draw_line (window, gc2,
2460 x + gap_x, y, x + gap_x, y);
2462 if ((width - (gap_x + gap_width)) > 0)
2464 gdk_draw_line (window, gc1,
2465 x + gap_x + gap_width, y, x + width - 2, y);
2466 gdk_draw_line (window, gc2,
2467 x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
2468 gdk_draw_line (window, gc2,
2469 x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
2472 case GTK_POS_BOTTOM:
2473 gdk_draw_line (window, gc1,
2474 x, y, x + width - 1, y);
2475 gdk_draw_line (window, gc1,
2476 x, y, x, y + height - 1);
2477 gdk_draw_line (window, gc2,
2478 x + 1, y + 1, x + width - 2, y + 1);
2479 gdk_draw_line (window, gc2,
2480 x + 1, y + 1, x + 1, y + height - 1);
2482 gdk_draw_line (window, gc3,
2483 x + width - 2, y + 1, x + width - 2, y + height - 1);
2484 gdk_draw_line (window, gc4,
2485 x + width - 1, y, x + width - 1, y + height - 1);
2488 gdk_draw_line (window, gc4,
2489 x, y + height - 1, x + gap_x - 1, y + height - 1);
2490 gdk_draw_line (window, gc3,
2491 x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
2492 gdk_draw_line (window, gc3,
2493 x + gap_x, y + height - 1, x + gap_x, y + height - 1);
2495 if ((width - (gap_x + gap_width)) > 0)
2497 gdk_draw_line (window, gc4,
2498 x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
2499 gdk_draw_line (window, gc3,
2500 x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
2501 gdk_draw_line (window, gc3,
2502 x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
2506 gdk_draw_line (window, gc1,
2507 x, y, x + width - 1, y);
2508 gdk_draw_line (window, gc2,
2509 x, y + 1, x + width - 2, y + 1);
2511 gdk_draw_line (window, gc3,
2512 x, y + height - 2, x + width - 2, y + height - 2);
2513 gdk_draw_line (window, gc3,
2514 x + width - 2, y + 1, x + width - 2, y + height - 2);
2515 gdk_draw_line (window, gc4,
2516 x, y + height - 1, x + width - 1, y + height - 1);
2517 gdk_draw_line (window, gc4,
2518 x + width - 1, y, x + width - 1, y + height - 1);
2521 gdk_draw_line (window, gc1,
2522 x, y, x, y + gap_x - 1);
2523 gdk_draw_line (window, gc2,
2524 x + 1, y + 1, x + 1, y + gap_x - 1);
2525 gdk_draw_line (window, gc2,
2526 x, y + gap_x, x, y + gap_x);
2528 if ((width - (gap_x + gap_width)) > 0)
2530 gdk_draw_line (window, gc1,
2531 x, y + gap_x + gap_width, x, y + height - 2);
2532 gdk_draw_line (window, gc2,
2533 x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
2534 gdk_draw_line (window, gc2,
2535 x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
2539 gdk_draw_line (window, gc1,
2540 x, y, x + width - 1, y);
2541 gdk_draw_line (window, gc1,
2542 x, y, x, y + height - 1);
2543 gdk_draw_line (window, gc2,
2544 x + 1, y + 1, x + width - 1, y + 1);
2545 gdk_draw_line (window, gc2,
2546 x + 1, y + 1, x + 1, y + height - 2);
2548 gdk_draw_line (window, gc3,
2549 x + 1, y + height - 2, x + width - 1, y + height - 2);
2550 gdk_draw_line (window, gc4,
2551 x, y + height - 1, x + width - 1, y + height - 1);
2554 gdk_draw_line (window, gc4,
2555 x + width - 1, y, x + width - 1, y + gap_x - 1);
2556 gdk_draw_line (window, gc3,
2557 x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
2558 gdk_draw_line (window, gc3,
2559 x + width - 1, y + gap_x, x + width - 1, y + gap_x);
2561 if ((width - (gap_x + gap_width)) > 0)
2563 gdk_draw_line (window, gc4,
2564 x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
2565 gdk_draw_line (window, gc3,
2566 x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
2567 gdk_draw_line (window, gc3,
2568 x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
2576 gdk_gc_set_clip_rectangle (gc1, NULL);
2577 gdk_gc_set_clip_rectangle (gc2, NULL);
2578 gdk_gc_set_clip_rectangle (gc3, NULL);
2579 gdk_gc_set_clip_rectangle (gc4, NULL);
2584 gtk_default_draw_box_gap (GtkStyle *style,
2586 GtkStateType state_type,
2587 GtkShadowType shadow_type,
2590 const gchar *detail,
2595 GtkPositionType gap_side,
2604 g_return_if_fail (style != NULL);
2605 g_return_if_fail (window != NULL);
2607 gtk_style_apply_default_background (style, window,
2608 widget && !GTK_WIDGET_NO_WINDOW (widget),
2609 state_type, area, x, y, width, height);
2611 if (width == -1 && height == -1)
2612 gdk_window_get_size (window, &width, &height);
2613 else if (width == -1)
2614 gdk_window_get_size (window, &width, NULL);
2615 else if (height == -1)
2616 gdk_window_get_size (window, NULL, &height);
2618 switch (shadow_type)
2620 case GTK_SHADOW_NONE:
2623 gc1 = style->dark_gc[state_type];
2624 gc2 = style->black_gc;
2625 gc3 = style->bg_gc[state_type];
2626 gc4 = style->light_gc[state_type];
2628 case GTK_SHADOW_ETCHED_IN:
2629 gc1 = style->dark_gc[state_type];
2630 gc2 = style->light_gc[state_type];
2631 gc3 = style->dark_gc[state_type];
2632 gc4 = style->light_gc[state_type];
2634 case GTK_SHADOW_OUT:
2635 gc1 = style->light_gc[state_type];
2636 gc2 = style->bg_gc[state_type];
2637 gc3 = style->dark_gc[state_type];
2638 gc4 = style->black_gc;
2640 case GTK_SHADOW_ETCHED_OUT:
2641 gc1 = style->light_gc[state_type];
2642 gc2 = style->dark_gc[state_type];
2643 gc3 = style->light_gc[state_type];
2644 gc4 = style->dark_gc[state_type];
2650 gdk_gc_set_clip_rectangle (gc1, area);
2651 gdk_gc_set_clip_rectangle (gc2, area);
2652 gdk_gc_set_clip_rectangle (gc3, area);
2653 gdk_gc_set_clip_rectangle (gc4, area);
2656 switch (shadow_type)
2658 case GTK_SHADOW_NONE:
2660 case GTK_SHADOW_OUT:
2661 case GTK_SHADOW_ETCHED_IN:
2662 case GTK_SHADOW_ETCHED_OUT:
2666 gdk_draw_line (window, gc1,
2667 x, y, x, y + height - 1);
2668 gdk_draw_line (window, gc2,
2669 x + 1, y, x + 1, y + height - 2);
2671 gdk_draw_line (window, gc3,
2672 x + 1, y + height - 2, x + width - 2, y + height - 2);
2673 gdk_draw_line (window, gc3,
2674 x + width - 2, y, x + width - 2, y + height - 2);
2675 gdk_draw_line (window, gc4,
2676 x, y + height - 1, x + width - 1, y + height - 1);
2677 gdk_draw_line (window, gc4,
2678 x + width - 1, y, x + width - 1, y + height - 1);
2681 gdk_draw_line (window, gc1,
2682 x, y, x + gap_x - 1, y);
2683 gdk_draw_line (window, gc2,
2684 x + 1, y + 1, x + gap_x - 1, y + 1);
2685 gdk_draw_line (window, gc2,
2686 x + gap_x, y, x + gap_x, y);
2688 if ((width - (gap_x + gap_width)) > 0)
2690 gdk_draw_line (window, gc1,
2691 x + gap_x + gap_width, y, x + width - 2, y);
2692 gdk_draw_line (window, gc2,
2693 x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
2694 gdk_draw_line (window, gc2,
2695 x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
2698 case GTK_POS_BOTTOM:
2699 gdk_draw_line (window, gc1,
2700 x, y, x + width - 1, y);
2701 gdk_draw_line (window, gc1,
2702 x, y, x, y + height - 1);
2703 gdk_draw_line (window, gc2,
2704 x + 1, y + 1, x + width - 2, y + 1);
2705 gdk_draw_line (window, gc2,
2706 x + 1, y + 1, x + 1, y + height - 1);
2708 gdk_draw_line (window, gc3,
2709 x + width - 2, y + 1, x + width - 2, y + height - 1);
2710 gdk_draw_line (window, gc4,
2711 x + width - 1, y, x + width - 1, y + height - 1);
2714 gdk_draw_line (window, gc4,
2715 x, y + height - 1, x + gap_x - 1, y + height - 1);
2716 gdk_draw_line (window, gc3,
2717 x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
2718 gdk_draw_line (window, gc3,
2719 x + gap_x, y + height - 1, x + gap_x, y + height - 1);
2721 if ((width - (gap_x + gap_width)) > 0)
2723 gdk_draw_line (window, gc4,
2724 x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
2725 gdk_draw_line (window, gc3,
2726 x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
2727 gdk_draw_line (window, gc3,
2728 x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
2732 gdk_draw_line (window, gc1,
2733 x, y, x + width - 1, y);
2734 gdk_draw_line (window, gc2,
2735 x, y + 1, x + width - 2, y + 1);
2737 gdk_draw_line (window, gc3,
2738 x, y + height - 2, x + width - 2, y + height - 2);
2739 gdk_draw_line (window, gc3,
2740 x + width - 2, y + 1, x + width - 2, y + height - 2);
2741 gdk_draw_line (window, gc4,
2742 x, y + height - 1, x + width - 1, y + height - 1);
2743 gdk_draw_line (window, gc4,
2744 x + width - 1, y, x + width - 1, y + height - 1);
2747 gdk_draw_line (window, gc1,
2748 x, y, x, y + gap_x - 1);
2749 gdk_draw_line (window, gc2,
2750 x + 1, y + 1, x + 1, y + gap_x - 1);
2751 gdk_draw_line (window, gc2,
2752 x, y + gap_x, x, y + gap_x);
2754 if ((width - (gap_x + gap_width)) > 0)
2756 gdk_draw_line (window, gc1,
2757 x, y + gap_x + gap_width, x, y + height - 2);
2758 gdk_draw_line (window, gc2,
2759 x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
2760 gdk_draw_line (window, gc2,
2761 x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
2765 gdk_draw_line (window, gc1,
2766 x, y, x + width - 1, y);
2767 gdk_draw_line (window, gc1,
2768 x, y, x, y + height - 1);
2769 gdk_draw_line (window, gc2,
2770 x + 1, y + 1, x + width - 1, y + 1);
2771 gdk_draw_line (window, gc2,
2772 x + 1, y + 1, x + 1, y + height - 2);
2774 gdk_draw_line (window, gc3,
2775 x + 1, y + height - 2, x + width - 1, y + height - 2);
2776 gdk_draw_line (window, gc4,
2777 x, y + height - 1, x + width - 1, y + height - 1);
2780 gdk_draw_line (window, gc4,
2781 x + width - 1, y, x + width - 1, y + gap_x - 1);
2782 gdk_draw_line (window, gc3,
2783 x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
2784 gdk_draw_line (window, gc3,
2785 x + width - 1, y + gap_x, x + width - 1, y + gap_x);
2787 if ((width - (gap_x + gap_width)) > 0)
2789 gdk_draw_line (window, gc4,
2790 x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
2791 gdk_draw_line (window, gc3,
2792 x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
2793 gdk_draw_line (window, gc3,
2794 x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
2802 gdk_gc_set_clip_rectangle (gc1, NULL);
2803 gdk_gc_set_clip_rectangle (gc2, NULL);
2804 gdk_gc_set_clip_rectangle (gc3, NULL);
2805 gdk_gc_set_clip_rectangle (gc4, NULL);
2810 gtk_default_draw_extension (GtkStyle *style,
2812 GtkStateType state_type,
2813 GtkShadowType shadow_type,
2816 const gchar *detail,
2821 GtkPositionType gap_side)
2828 g_return_if_fail (style != NULL);
2829 g_return_if_fail (window != NULL);
2831 gtk_style_apply_default_background (style, window,
2832 widget && !GTK_WIDGET_NO_WINDOW (widget),
2833 GTK_STATE_NORMAL, area, x, y, width, height);
2835 if (width == -1 && height == -1)
2836 gdk_window_get_size (window, &width, &height);
2837 else if (width == -1)
2838 gdk_window_get_size (window, &width, NULL);
2839 else if (height == -1)
2840 gdk_window_get_size (window, NULL, &height);
2842 switch (shadow_type)
2844 case GTK_SHADOW_NONE:
2847 gc1 = style->dark_gc[state_type];
2848 gc2 = style->black_gc;
2849 gc3 = style->bg_gc[state_type];
2850 gc4 = style->light_gc[state_type];
2852 case GTK_SHADOW_ETCHED_IN:
2853 gc1 = style->dark_gc[state_type];
2854 gc2 = style->light_gc[state_type];
2855 gc3 = style->dark_gc[state_type];
2856 gc4 = style->light_gc[state_type];
2858 case GTK_SHADOW_OUT:
2859 gc1 = style->light_gc[state_type];
2860 gc2 = style->bg_gc[state_type];
2861 gc3 = style->dark_gc[state_type];
2862 gc4 = style->black_gc;
2864 case GTK_SHADOW_ETCHED_OUT:
2865 gc1 = style->light_gc[state_type];
2866 gc2 = style->dark_gc[state_type];
2867 gc3 = style->light_gc[state_type];
2868 gc4 = style->dark_gc[state_type];
2874 gdk_gc_set_clip_rectangle (gc1, area);
2875 gdk_gc_set_clip_rectangle (gc2, area);
2876 gdk_gc_set_clip_rectangle (gc3, area);
2877 gdk_gc_set_clip_rectangle (gc4, area);
2880 switch (shadow_type)
2882 case GTK_SHADOW_NONE:
2884 case GTK_SHADOW_OUT:
2885 case GTK_SHADOW_ETCHED_IN:
2886 case GTK_SHADOW_ETCHED_OUT:
2890 gtk_style_apply_default_background (style, window,
2891 widget && !GTK_WIDGET_NO_WINDOW (widget),
2893 x + style->klass->xthickness,
2895 width - (2 * style->klass->xthickness),
2896 height - (style->klass->ythickness));
2897 gdk_draw_line (window, gc1,
2898 x, y, x, y + height - 2);
2899 gdk_draw_line (window, gc2,
2900 x + 1, y, x + 1, y + height - 2);
2902 gdk_draw_line (window, gc3,
2903 x + 2, y + height - 2, x + width - 2, y + height - 2);
2904 gdk_draw_line (window, gc3,
2905 x + width - 2, y, x + width - 2, y + height - 2);
2906 gdk_draw_line (window, gc4,
2907 x + 1, y + height - 1, x + width - 2, y + height - 1);
2908 gdk_draw_line (window, gc4,
2909 x + width - 1, y, x + width - 1, y + height - 2);
2911 case GTK_POS_BOTTOM:
2912 gtk_style_apply_default_background (style, window,
2913 widget && !GTK_WIDGET_NO_WINDOW (widget),
2915 x + style->klass->xthickness,
2916 y + style->klass->ythickness,
2917 width - (2 * style->klass->xthickness),
2918 height - (style->klass->ythickness));
2919 gdk_draw_line (window, gc1,
2920 x + 1, y, x + width - 2, y);
2921 gdk_draw_line (window, gc1,
2922 x, y + 1, x, y + height - 1);
2923 gdk_draw_line (window, gc2,
2924 x + 1, y + 1, x + width - 2, y + 1);
2925 gdk_draw_line (window, gc2,
2926 x + 1, y + 1, x + 1, y + height - 1);
2928 gdk_draw_line (window, gc3,
2929 x + width - 2, y + 2, x + width - 2, y + height - 1);
2930 gdk_draw_line (window, gc4,
2931 x + width - 1, y + 1, x + width - 1, y + height - 1);
2934 gtk_style_apply_default_background (style, window,
2935 widget && !GTK_WIDGET_NO_WINDOW (widget),
2938 y + style->klass->ythickness,
2939 width - (style->klass->xthickness),
2940 height - (2 * style->klass->ythickness));
2941 gdk_draw_line (window, gc1,
2942 x, y, x + width - 2, y);
2943 gdk_draw_line (window, gc2,
2944 x + 1, y + 1, x + width - 2, y + 1);
2946 gdk_draw_line (window, gc3,
2947 x, y + height - 2, x + width - 2, y + height - 2);
2948 gdk_draw_line (window, gc3,
2949 x + width - 2, y + 2, x + width - 2, y + height - 2);
2950 gdk_draw_line (window, gc4,
2951 x, y + height - 1, x + width - 2, y + height - 1);
2952 gdk_draw_line (window, gc4,
2953 x + width - 1, y + 1, x + width - 1, y + height - 2);
2956 gtk_style_apply_default_background (style, window,
2957 widget && !GTK_WIDGET_NO_WINDOW (widget),
2959 x + style->klass->xthickness,
2960 y + style->klass->ythickness,
2961 width - (style->klass->xthickness),
2962 height - (2 * style->klass->ythickness));
2963 gdk_draw_line (window, gc1,
2964 x + 1, y, x + width - 1, y);
2965 gdk_draw_line (window, gc1,
2966 x, y + 1, x, y + height - 2);
2967 gdk_draw_line (window, gc2,
2968 x + 1, y + 1, x + width - 1, y + 1);
2969 gdk_draw_line (window, gc2,
2970 x + 1, y + 1, x + 1, y + height - 2);
2972 gdk_draw_line (window, gc3,
2973 x + 2, y + height - 2, x + width - 1, y + height - 2);
2974 gdk_draw_line (window, gc4,
2975 x + 1, y + height - 1, x + width - 1, y + height - 1);
2982 gdk_gc_set_clip_rectangle (gc1, NULL);
2983 gdk_gc_set_clip_rectangle (gc2, NULL);
2984 gdk_gc_set_clip_rectangle (gc3, NULL);
2985 gdk_gc_set_clip_rectangle (gc4, NULL);
2990 gtk_default_draw_focus (GtkStyle *style,
2994 const gchar *detail,
3000 g_return_if_fail (style != NULL);
3001 g_return_if_fail (window != NULL);
3003 if (width == -1 && height == -1)
3005 gdk_window_get_size (window, &width, &height);
3009 else if (width == -1)
3011 gdk_window_get_size (window, &width, NULL);
3014 else if (height == -1)
3016 gdk_window_get_size (window, NULL, &height);
3021 gdk_gc_set_clip_rectangle (style->black_gc, area);
3023 if (detail && !strcmp (detail, "add-mode"))
3025 gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_ON_OFF_DASH, 0, 0);
3026 gdk_gc_set_dashes (style->black_gc, 0, "\4\4", 2);
3028 gdk_draw_rectangle (window,
3029 style->black_gc, FALSE,
3030 x, y, width, height);
3032 gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_SOLID, 0, 0);
3036 gdk_draw_rectangle (window,
3037 style->black_gc, FALSE,
3038 x, y, width, height);
3042 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
3046 gtk_default_draw_slider (GtkStyle *style,
3048 GtkStateType state_type,
3049 GtkShadowType shadow_type,
3052 const gchar *detail,
3057 GtkOrientation orientation)
3059 g_return_if_fail (style != NULL);
3060 g_return_if_fail (window != NULL);
3062 if (width == -1 && height == -1)
3063 gdk_window_get_size (window, &width, &height);
3064 else if (width == -1)
3065 gdk_window_get_size (window, &width, NULL);
3066 else if (height == -1)
3067 gdk_window_get_size (window, NULL, &height);
3069 gtk_paint_box (style, window, state_type, shadow_type,
3070 area, widget, detail, x, y, width, height);
3072 if (orientation == GTK_ORIENTATION_HORIZONTAL)
3073 gtk_paint_vline (style, window, state_type, area, widget, detail,
3074 style->klass->ythickness,
3075 height - style->klass->ythickness - 1, width / 2);
3077 gtk_paint_hline (style, window, state_type, area, widget, detail,
3078 style->klass->xthickness,
3079 width - style->klass->xthickness - 1, height / 2);
3083 draw_dot (GdkWindow *window,
3091 size = CLAMP (size, 2, 3);
3095 gdk_draw_point (window, light_gc, x, y);
3096 gdk_draw_point (window, light_gc, x+1, y+1);
3098 else if (size == 3);
3100 gdk_draw_point (window, light_gc, x, y);
3101 gdk_draw_point (window, light_gc, x+1, y);
3102 gdk_draw_point (window, light_gc, x, y+1);
3103 gdk_draw_point (window, dark_gc, x+1, y+2);
3104 gdk_draw_point (window, dark_gc, x+2, y+1);
3105 gdk_draw_point (window, dark_gc, x+2, y+2);
3110 gtk_default_draw_handle (GtkStyle *style,
3112 GtkStateType state_type,
3113 GtkShadowType shadow_type,
3116 const gchar *detail,
3121 GtkOrientation orientation)
3124 gint xthick, ythick;
3125 GdkGC *light_gc, *dark_gc;
3130 g_return_if_fail (style != NULL);
3131 g_return_if_fail (window != NULL);
3133 if (width == -1 && height == -1)
3134 gdk_window_get_size (window, &width, &height);
3135 else if (width == -1)
3136 gdk_window_get_size (window, &width, NULL);
3137 else if (height == -1)
3138 gdk_window_get_size (window, NULL, &height);
3140 gtk_paint_box (style, window, state_type, shadow_type, area, widget,
3141 detail, x, y, width, height);
3144 if (!strcmp (detail, "paned"))
3146 /* we want to ignore the shadow border in paned widgets */
3150 light_gc = style->light_gc[state_type];
3151 dark_gc = style->black_gc;
3155 xthick = style->klass->xthickness;
3156 ythick = style->klass->ythickness;
3158 light_gc = style->light_gc[state_type];
3159 dark_gc = style->dark_gc[state_type];
3162 rect.x = x + xthick;
3163 rect.y = y + ythick;
3164 rect.width = width - (xthick * 2);
3165 rect.height = height - (ythick * 2);
3168 intersect = gdk_rectangle_intersect (area, &rect, &dest);
3178 gdk_gc_set_clip_rectangle (light_gc, &dest);
3179 gdk_gc_set_clip_rectangle (dark_gc, &dest);
3181 if (!strcmp (detail, "paned"))
3186 gdk_window_get_size (window, &window_width, &window_height);
3188 if (orientation == GTK_ORIENTATION_HORIZONTAL)
3189 for (xx = window_width/2 - 15; xx <= window_width/2 + 15; xx += 5)
3190 draw_dot (window, light_gc, dark_gc, xx, window_height/2 - 1, 3);
3192 for (yy = window_height/2 - 15; yy <= window_height/2 + 15; yy += 5)
3193 draw_dot (window, light_gc, dark_gc, window_width/2 - 1, yy, 3);
3197 for (yy = y + ythick; yy < (y + height - ythick); yy += 3)
3198 for (xx = x + xthick; xx < (x + width - xthick); xx += 6)
3200 draw_dot (window, light_gc, dark_gc, xx, yy, 2);
3201 draw_dot (window, light_gc, dark_gc, xx + 3, yy + 1, 2);
3205 gdk_gc_set_clip_rectangle (light_gc, NULL);
3206 gdk_gc_set_clip_rectangle (dark_gc, NULL);
3210 gtk_style_shade (GdkColor *a,
3218 red = (gdouble) a->red / 65535.0;
3219 green = (gdouble) a->green / 65535.0;
3220 blue = (gdouble) a->blue / 65535.0;
3222 rgb_to_hls (&red, &green, &blue);
3227 else if (green < 0.0)
3233 else if (blue < 0.0)
3236 hls_to_rgb (&red, &green, &blue);
3238 b->red = red * 65535.0;
3239 b->green = green * 65535.0;
3240 b->blue = blue * 65535.0;
3244 rgb_to_hls (gdouble *r,
3285 l = (max + min) / 2;
3292 s = (max - min) / (max + min);
3294 s = (max - min) / (2 - max - min);
3298 h = (green - blue) / delta;
3299 else if (green == max)
3300 h = 2 + (blue - red) / delta;
3301 else if (blue == max)
3302 h = 4 + (red - green) / delta;
3315 hls_to_rgb (gdouble *h,
3328 if (lightness <= 0.5)
3329 m2 = lightness * (1 + saturation);
3331 m2 = lightness + saturation - lightness * saturation;
3332 m1 = 2 * lightness - m2;
3334 if (saturation == 0)
3349 r = m1 + (m2 - m1) * hue / 60;
3353 r = m1 + (m2 - m1) * (240 - hue) / 60;
3364 g = m1 + (m2 - m1) * hue / 60;
3368 g = m1 + (m2 - m1) * (240 - hue) / 60;
3379 b = m1 + (m2 - m1) * hue / 60;
3383 b = m1 + (m2 - m1) * (240 - hue) / 60;
3394 gtk_paint_hline (GtkStyle *style,
3396 GtkStateType state_type,
3399 const gchar *detail,
3404 g_return_if_fail (style != NULL);
3405 g_return_if_fail (style->klass != NULL);
3406 g_return_if_fail (style->klass->draw_hline != NULL);
3408 style->klass->draw_hline (style, window, state_type, area, widget, detail, x1, x2, y);
3412 gtk_paint_vline (GtkStyle *style,
3414 GtkStateType state_type,
3417 const gchar *detail,
3422 g_return_if_fail (style != NULL);
3423 g_return_if_fail (style->klass != NULL);
3424 g_return_if_fail (style->klass->draw_vline != NULL);
3426 style->klass->draw_vline (style, window, state_type, area, widget, detail, y1, y2, x);
3430 gtk_paint_shadow (GtkStyle *style,
3432 GtkStateType state_type,
3433 GtkShadowType shadow_type,
3436 const gchar *detail,
3442 g_return_if_fail (style != NULL);
3443 g_return_if_fail (style->klass != NULL);
3444 g_return_if_fail (style->klass->draw_shadow != NULL);
3446 style->klass->draw_shadow (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3450 gtk_paint_polygon (GtkStyle *style,
3452 GtkStateType state_type,
3453 GtkShadowType shadow_type,
3456 const gchar *detail,
3461 g_return_if_fail (style != NULL);
3462 g_return_if_fail (style->klass != NULL);
3463 g_return_if_fail (style->klass->draw_shadow != NULL);
3465 style->klass->draw_polygon (style, window, state_type, shadow_type, area, widget, detail, points, npoints, fill);
3469 gtk_paint_arrow (GtkStyle *style,
3471 GtkStateType state_type,
3472 GtkShadowType shadow_type,
3475 const gchar *detail,
3476 GtkArrowType arrow_type,
3483 g_return_if_fail (style != NULL);
3484 g_return_if_fail (style->klass != NULL);
3485 g_return_if_fail (style->klass->draw_arrow != NULL);
3487 style->klass->draw_arrow (style, window, state_type, shadow_type, area, widget, detail, arrow_type, fill, x, y, width, height);
3491 gtk_paint_diamond (GtkStyle *style,
3493 GtkStateType state_type,
3494 GtkShadowType shadow_type,
3497 const gchar *detail,
3503 g_return_if_fail (style != NULL);
3504 g_return_if_fail (style->klass != NULL);
3505 g_return_if_fail (style->klass->draw_diamond != NULL);
3507 style->klass->draw_diamond (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3511 gtk_paint_oval (GtkStyle *style,
3513 GtkStateType state_type,
3514 GtkShadowType shadow_type,
3517 const gchar *detail,
3523 g_return_if_fail (style != NULL);
3524 g_return_if_fail (style->klass != NULL);
3525 g_return_if_fail (style->klass->draw_oval != NULL);
3527 style->klass->draw_oval (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3531 gtk_paint_string (GtkStyle *style,
3533 GtkStateType state_type,
3536 const gchar *detail,
3539 const gchar *string)
3541 g_return_if_fail (style != NULL);
3542 g_return_if_fail (style->klass != NULL);
3543 g_return_if_fail (style->klass->draw_string != NULL);
3545 style->klass->draw_string (style, window, state_type, area, widget, detail, x, y, string);
3549 gtk_paint_box (GtkStyle *style,
3551 GtkStateType state_type,
3552 GtkShadowType shadow_type,
3555 const gchar *detail,
3561 g_return_if_fail (style != NULL);
3562 g_return_if_fail (style->klass != NULL);
3563 g_return_if_fail (style->klass->draw_box != NULL);
3565 style->klass->draw_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3569 gtk_paint_flat_box (GtkStyle *style,
3571 GtkStateType state_type,
3572 GtkShadowType shadow_type,
3575 const gchar *detail,
3581 g_return_if_fail (style != NULL);
3582 g_return_if_fail (style->klass != NULL);
3583 g_return_if_fail (style->klass->draw_flat_box != NULL);
3585 style->klass->draw_flat_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3589 gtk_paint_check (GtkStyle *style,
3591 GtkStateType state_type,
3592 GtkShadowType shadow_type,
3595 const gchar *detail,
3601 g_return_if_fail (style != NULL);
3602 g_return_if_fail (style->klass != NULL);
3603 g_return_if_fail (style->klass->draw_check != NULL);
3605 style->klass->draw_check (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3609 gtk_paint_option (GtkStyle *style,
3611 GtkStateType state_type,
3612 GtkShadowType shadow_type,
3615 const gchar *detail,
3621 g_return_if_fail (style != NULL);
3622 g_return_if_fail (style->klass != NULL);
3623 g_return_if_fail (style->klass->draw_option != NULL);
3625 style->klass->draw_option (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3629 gtk_paint_cross (GtkStyle *style,
3631 GtkStateType state_type,
3632 GtkShadowType shadow_type,
3635 const gchar *detail,
3641 g_return_if_fail (style != NULL);
3642 g_return_if_fail (style->klass != NULL);
3643 g_return_if_fail (style->klass->draw_cross != NULL);
3645 style->klass->draw_cross (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3649 gtk_paint_ramp (GtkStyle *style,
3651 GtkStateType state_type,
3652 GtkShadowType shadow_type,
3655 const gchar *detail,
3656 GtkArrowType arrow_type,
3662 g_return_if_fail (style != NULL);
3663 g_return_if_fail (style->klass != NULL);
3664 g_return_if_fail (style->klass->draw_ramp != NULL);
3666 style->klass->draw_ramp (style, window, state_type, shadow_type, area, widget, detail, arrow_type, x, y, width, height);
3670 gtk_paint_tab (GtkStyle *style,
3672 GtkStateType state_type,
3673 GtkShadowType shadow_type,
3676 const gchar *detail,
3682 g_return_if_fail (style != NULL);
3683 g_return_if_fail (style->klass != NULL);
3684 g_return_if_fail (style->klass->draw_tab != NULL);
3686 style->klass->draw_tab (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
3690 gtk_paint_shadow_gap (GtkStyle *style,
3692 GtkStateType state_type,
3693 GtkShadowType shadow_type,
3701 GtkPositionType gap_side,
3705 g_return_if_fail (style != NULL);
3706 g_return_if_fail (style->klass != NULL);
3707 g_return_if_fail (style->klass->draw_shadow_gap != NULL);
3709 style->klass->draw_shadow_gap (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
3714 gtk_paint_box_gap (GtkStyle *style,
3716 GtkStateType state_type,
3717 GtkShadowType shadow_type,
3725 GtkPositionType gap_side,
3729 g_return_if_fail (style != NULL);
3730 g_return_if_fail (style->klass != NULL);
3731 g_return_if_fail (style->klass->draw_box_gap != NULL);
3733 style->klass->draw_box_gap (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
3737 gtk_paint_extension (GtkStyle *style,
3739 GtkStateType state_type,
3740 GtkShadowType shadow_type,
3748 GtkPositionType gap_side)
3750 g_return_if_fail (style != NULL);
3751 g_return_if_fail (style->klass != NULL);
3752 g_return_if_fail (style->klass->draw_extension != NULL);
3754 style->klass->draw_extension (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side);
3758 gtk_paint_focus (GtkStyle *style,
3762 const gchar *detail,
3768 g_return_if_fail (style != NULL);
3769 g_return_if_fail (style->klass != NULL);
3770 g_return_if_fail (style->klass->draw_focus != NULL);
3772 style->klass->draw_focus (style, window, area, widget, detail, x, y, width, height);
3776 gtk_paint_slider (GtkStyle *style,
3778 GtkStateType state_type,
3779 GtkShadowType shadow_type,
3782 const gchar *detail,
3787 GtkOrientation orientation)
3789 g_return_if_fail (style != NULL);
3790 g_return_if_fail (style->klass != NULL);
3791 g_return_if_fail (style->klass->draw_slider != NULL);
3793 style->klass->draw_slider (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
3797 gtk_paint_handle (GtkStyle *style,
3799 GtkStateType state_type,
3800 GtkShadowType shadow_type,
3803 const gchar *detail,
3808 GtkOrientation orientation)
3810 g_return_if_fail (style != NULL);
3811 g_return_if_fail (style->klass != NULL);
3812 g_return_if_fail (style->klass->draw_handle != NULL);
3814 style->klass->draw_handle (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);