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 Lesser 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 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser 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-2000. 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 "gtkspinbutton.h"
34 #include "gtkwidget.h"
35 #include "gtkthemes.h"
36 #include "gtkiconfactory.h"
37 #include "gtksettings.h" /* _gtk_settings_parse_convert() */
39 #define LIGHTNESS_MULT 1.3
40 #define DARKNESS_MULT 0.7
42 /* --- typedefs & structures --- */
50 /* --- prototypes --- */
51 static void gtk_style_init (GtkStyle *style);
52 static void gtk_style_class_init (GtkStyleClass *klass);
53 static void gtk_style_finalize (GObject *object);
54 static void gtk_style_realize (GtkStyle *style,
55 GdkColormap *colormap);
56 static void gtk_style_real_realize (GtkStyle *style);
57 static void gtk_style_real_unrealize (GtkStyle *style);
58 static void gtk_style_real_copy (GtkStyle *style,
60 static void gtk_style_real_set_background (GtkStyle *style,
62 GtkStateType state_type);
63 static GtkStyle *gtk_style_real_clone (GtkStyle *style);
64 static void gtk_style_real_init_from_rc (GtkStyle *style,
65 GtkRcStyle *rc_style);
66 static GdkPixbuf *gtk_default_render_icon (GtkStyle *style,
67 const GtkIconSource *source,
68 GtkTextDirection direction,
73 static void gtk_default_draw_hline (GtkStyle *style,
75 GtkStateType state_type,
82 static void gtk_default_draw_vline (GtkStyle *style,
84 GtkStateType state_type,
91 static void gtk_default_draw_shadow (GtkStyle *style,
93 GtkStateType state_type,
94 GtkShadowType shadow_type,
102 static void gtk_default_draw_polygon (GtkStyle *style,
104 GtkStateType state_type,
105 GtkShadowType shadow_type,
112 static void gtk_default_draw_arrow (GtkStyle *style,
114 GtkStateType state_type,
115 GtkShadowType shadow_type,
119 GtkArrowType arrow_type,
125 static void gtk_default_draw_diamond (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_tab (GtkStyle *style,
191 GtkStateType state_type,
192 GtkShadowType shadow_type,
200 static void gtk_default_draw_shadow_gap (GtkStyle *style,
202 GtkStateType state_type,
203 GtkShadowType shadow_type,
211 GtkPositionType gap_side,
214 static void gtk_default_draw_box_gap (GtkStyle *style,
216 GtkStateType state_type,
217 GtkShadowType shadow_type,
225 GtkPositionType gap_side,
228 static void gtk_default_draw_extension (GtkStyle *style,
230 GtkStateType state_type,
231 GtkShadowType shadow_type,
239 GtkPositionType gap_side);
240 static void gtk_default_draw_focus (GtkStyle *style,
242 GtkStateType state_type,
250 static void gtk_default_draw_slider (GtkStyle *style,
252 GtkStateType state_type,
253 GtkShadowType shadow_type,
261 GtkOrientation orientation);
262 static void gtk_default_draw_handle (GtkStyle *style,
264 GtkStateType state_type,
265 GtkShadowType shadow_type,
273 GtkOrientation orientation);
274 static void gtk_default_draw_expander (GtkStyle *style,
276 GtkStateType state_type,
282 GtkExpanderStyle expander_style);
283 static void gtk_default_draw_layout (GtkStyle *style,
285 GtkStateType state_type,
292 PangoLayout *layout);
293 static void gtk_default_draw_resize_grip (GtkStyle *style,
295 GtkStateType state_type,
305 static void gtk_style_shade (GdkColor *a,
308 static void rgb_to_hls (gdouble *r,
311 static void hls_to_rgb (gdouble *h,
317 * Data for default check and radio buttons
320 static GtkRequisition default_option_indicator_size = { 7, 13 };
321 static GtkBorder default_option_indicator_spacing = { 7, 5, 2, 2 };
323 #define INDICATOR_PART_SIZE 13
341 static char check_aa_bits[] = {
342 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x58,0x00,0xa0,
343 0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
344 static char check_base_bits[] = {
345 0x00,0x00,0x00,0x00,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,
346 0x07,0xfc,0x07,0xfc,0x07,0xfc,0x07,0x00,0x00,0x00,0x00};
347 static char check_black_bits[] = {
348 0x00,0x00,0xfe,0x0f,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,
349 0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x00,0x00};
350 static char check_dark_bits[] = {
351 0xff,0x1f,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
352 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00};
353 static char check_light_bits[] = {
354 0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,
355 0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0xfe,0x1f};
356 static char check_mid_bits[] = {
357 0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,
358 0x08,0x00,0x08,0x00,0x08,0x00,0x08,0xfc,0x0f,0x00,0x00};
359 static char check_text_bits[] = {
360 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x03,0x80,0x01,0x80,0x00,0xd8,
361 0x00,0x60,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
362 static char radio_base_bits[] = {
363 0x00,0x00,0x00,0x00,0xf0,0x01,0xf8,0x03,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,
364 0x07,0xfc,0x07,0xf8,0x03,0xf0,0x01,0x00,0x00,0x00,0x00};
365 static char radio_black_bits[] = {
366 0x00,0x00,0xf0,0x01,0x08,0x02,0x04,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,
367 0x00,0x02,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
368 static char radio_dark_bits[] = {
369 0xf0,0x01,0x08,0x02,0x04,0x04,0x02,0x04,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
370 0x00,0x01,0x00,0x02,0x00,0x0c,0x00,0x00,0x00,0x00,0x00};
371 static char radio_light_bits[] = {
372 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,0x00,
373 0x10,0x00,0x10,0x00,0x08,0x00,0x04,0x08,0x02,0xf0,0x01};
374 static char radio_mid_bits[] = {
375 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x08,0x00,
376 0x08,0x00,0x08,0x00,0x04,0x00,0x02,0xf0,0x01,0x00,0x00};
377 static char radio_text_bits[] = {
378 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x00,0xf0,0x01,0xf0,0x01,0xf0,
379 0x01,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
384 } indicator_parts[] = {
385 { check_aa_bits, NULL },
386 { check_base_bits, NULL },
387 { check_black_bits, NULL },
388 { check_dark_bits, NULL },
389 { check_light_bits, NULL },
390 { check_mid_bits, NULL },
391 { check_text_bits, NULL },
392 { radio_base_bits, NULL },
393 { radio_black_bits, NULL },
394 { radio_dark_bits, NULL },
395 { radio_light_bits, NULL },
396 { radio_mid_bits, NULL },
397 { radio_text_bits, NULL }
400 /* --- variables --- */
401 static GdkColor gtk_default_normal_fg = { 0, 0, 0, 0 };
402 static GdkColor gtk_default_active_fg = { 0, 0, 0, 0 };
403 static GdkColor gtk_default_prelight_fg = { 0, 0, 0, 0 };
404 static GdkColor gtk_default_selected_fg = { 0, 0xffff, 0xffff, 0xffff };
405 static GdkColor gtk_default_insensitive_fg = { 0, 0x7530, 0x7530, 0x7530 };
407 static GdkColor gtk_default_normal_bg = { 0, 0xd6d6, 0xd6d6, 0xd6d6 };
408 static GdkColor gtk_default_active_bg = { 0, 0xc350, 0xc350, 0xc350 };
409 static GdkColor gtk_default_prelight_bg = { 0, 0xea60, 0xea60, 0xea60 };
410 static GdkColor gtk_default_selected_bg = { 0, 0, 0, 0x9c40 };
411 static GdkColor gtk_default_insensitive_bg = { 0, 0xd6d6, 0xd6d6, 0xd6d6 };
412 static GdkColor gtk_default_selected_base = { 0, 0xa4a4, 0xdfdf, 0xffff };
413 static GdkColor gtk_default_active_base = { 0, 0xbcbc, 0xd2d2, 0xeeee };
415 static gpointer parent_class = NULL;
418 /* --- functions --- */
420 gtk_style_get_type (void)
422 static GType style_type = 0;
426 static const GTypeInfo style_info =
428 sizeof (GtkStyleClass),
429 (GBaseInitFunc) NULL,
430 (GBaseFinalizeFunc) NULL,
431 (GClassInitFunc) gtk_style_class_init,
432 NULL, /* class_finalize */
433 NULL, /* class_data */
436 (GInstanceInitFunc) gtk_style_init,
439 style_type = g_type_register_static (G_TYPE_OBJECT,
448 gtk_style_init (GtkStyle *style)
452 style->font_desc = pango_font_description_from_string ("Sans 10");
454 style->attach_count = 0;
455 style->colormap = NULL;
458 style->black.red = 0;
459 style->black.green = 0;
460 style->black.blue = 0;
462 style->white.red = 65535;
463 style->white.green = 65535;
464 style->white.blue = 65535;
466 style->black_gc = NULL;
467 style->white_gc = NULL;
469 style->fg[GTK_STATE_NORMAL] = gtk_default_normal_fg;
470 style->fg[GTK_STATE_ACTIVE] = gtk_default_active_fg;
471 style->fg[GTK_STATE_PRELIGHT] = gtk_default_prelight_fg;
472 style->fg[GTK_STATE_SELECTED] = gtk_default_selected_fg;
473 style->fg[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_fg;
475 style->bg[GTK_STATE_NORMAL] = gtk_default_normal_bg;
476 style->bg[GTK_STATE_ACTIVE] = gtk_default_active_bg;
477 style->bg[GTK_STATE_PRELIGHT] = gtk_default_prelight_bg;
478 style->bg[GTK_STATE_SELECTED] = gtk_default_selected_bg;
479 style->bg[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_bg;
481 for (i = 0; i < 4; i++)
483 style->text[i] = style->fg[i];
484 style->base[i] = style->white;
487 style->base[GTK_STATE_SELECTED] = gtk_default_selected_base;
488 style->text[GTK_STATE_SELECTED] = style->black;
489 style->base[GTK_STATE_ACTIVE] = gtk_default_active_base;
490 style->text[GTK_STATE_ACTIVE] = style->black;
491 style->base[GTK_STATE_INSENSITIVE] = gtk_default_prelight_bg;
492 style->text[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_fg;
494 for (i = 0; i < 5; i++)
495 style->bg_pixmap[i] = NULL;
497 style->rc_style = NULL;
499 for (i = 0; i < 5; i++)
501 style->fg_gc[i] = NULL;
502 style->bg_gc[i] = NULL;
503 style->light_gc[i] = NULL;
504 style->dark_gc[i] = NULL;
505 style->mid_gc[i] = NULL;
506 style->text_gc[i] = NULL;
507 style->base_gc[i] = NULL;
508 style->text_aa_gc[i] = NULL;
511 style->xthickness = 2;
512 style->ythickness = 2;
514 style->property_cache = NULL;
518 gtk_style_class_init (GtkStyleClass *klass)
520 GObjectClass *object_class = G_OBJECT_CLASS (klass);
522 parent_class = g_type_class_peek_parent (klass);
524 object_class->finalize = gtk_style_finalize;
526 klass->clone = gtk_style_real_clone;
527 klass->copy = gtk_style_real_copy;
528 klass->init_from_rc = gtk_style_real_init_from_rc;
529 klass->realize = gtk_style_real_realize;
530 klass->unrealize = gtk_style_real_unrealize;
531 klass->set_background = gtk_style_real_set_background;
532 klass->render_icon = gtk_default_render_icon;
534 klass->draw_hline = gtk_default_draw_hline;
535 klass->draw_vline = gtk_default_draw_vline;
536 klass->draw_shadow = gtk_default_draw_shadow;
537 klass->draw_polygon = gtk_default_draw_polygon;
538 klass->draw_arrow = gtk_default_draw_arrow;
539 klass->draw_diamond = gtk_default_draw_diamond;
540 klass->draw_string = gtk_default_draw_string;
541 klass->draw_box = gtk_default_draw_box;
542 klass->draw_flat_box = gtk_default_draw_flat_box;
543 klass->draw_check = gtk_default_draw_check;
544 klass->draw_option = gtk_default_draw_option;
545 klass->draw_tab = gtk_default_draw_tab;
546 klass->draw_shadow_gap = gtk_default_draw_shadow_gap;
547 klass->draw_box_gap = gtk_default_draw_box_gap;
548 klass->draw_extension = gtk_default_draw_extension;
549 klass->draw_focus = gtk_default_draw_focus;
550 klass->draw_slider = gtk_default_draw_slider;
551 klass->draw_handle = gtk_default_draw_handle;
552 klass->draw_expander = gtk_default_draw_expander;
553 klass->draw_layout = gtk_default_draw_layout;
554 klass->draw_resize_grip = gtk_default_draw_resize_grip;
558 clear_property_cache (GtkStyle *style)
560 if (style->property_cache)
564 for (i = 0; i < style->property_cache->len; i++)
566 PropertyValue *node = &g_array_index (style->property_cache, PropertyValue, i);
568 g_param_spec_unref (node->pspec);
569 g_value_unset (&node->value);
571 g_array_free (style->property_cache, TRUE);
572 style->property_cache = NULL;
577 gtk_style_finalize (GObject *object)
579 GtkStyle *style = GTK_STYLE (object);
581 g_return_if_fail (style->attach_count == 0);
583 clear_property_cache (style);
587 if (style->styles->data != style)
588 g_slist_remove (style->styles, style);
591 GSList *tmp_list = style->styles->next;
595 GTK_STYLE (tmp_list->data)->styles = style->styles->next;
596 tmp_list = tmp_list->next;
598 g_slist_free_1 (style->styles);
602 pango_font_description_free (style->font_desc);
604 if (style->private_font)
605 gdk_font_unref (style->private_font);
607 if (style->private_font_desc)
608 pango_font_description_free (style->private_font_desc);
611 gtk_rc_style_unref (style->rc_style);
613 G_OBJECT_CLASS (parent_class)->finalize (object);
618 gtk_style_copy (GtkStyle *style)
622 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
624 new_style = GTK_STYLE_GET_CLASS (style)->clone (style);
625 GTK_STYLE_GET_CLASS (style)->copy (new_style, style);
631 gtk_style_duplicate (GtkStyle *style)
635 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
637 new_style = gtk_style_copy (style);
639 style->styles = g_slist_append (style->styles, new_style);
640 new_style->styles = style->styles;
647 * @returns: a new #GtkStyle.
649 * Creates a new #GtkStyle.
656 style = g_object_new (GTK_TYPE_STYLE, NULL);
663 * @style: a #GtkStyle.
664 * @window: a #GtkWindow.
665 * @returns: Either @style, or a newly-created #GtkStyle.
666 * If the style is newly created, the style parameter
667 * will be dereferenced, and the new style will have
668 * a reference count belonging to the caller.
670 * Attaches a style to a window; this process allocates the
671 * colors and creates the GC's for the style - it specializes
672 * it to a particular visual and colormap. The process may
673 * involve the creation of a new style if the style has already
674 * been attached to a window with a different style and colormap.
677 * FIXME: The sequence -
678 * create a style => s1
679 * attach s1 to v1, c1 => s1
680 * attach s1 to v2, c2 => s2
681 * detach s1 from v1, c1
682 * attach s1 to v2, c2 => s3
683 * results in two separate, unlinked styles s2 and s3 which
684 * are identical and could be shared. To fix this, we would
685 * want to never remove a style from the list of linked
686 * styles as long as as it has a reference count. However, the
687 * disadvantage of doing it this way means that we would need two
688 * passes through the linked list when attaching (one to check for
689 * matching styles, one to look for empty unattached styles - but
690 * it will almost never be longer than 2 elements.
693 gtk_style_attach (GtkStyle *style,
697 GtkStyle *new_style = NULL;
698 GdkColormap *colormap;
700 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
701 g_return_val_if_fail (window != NULL, NULL);
703 colormap = gdk_window_get_colormap (window);
706 style->styles = g_slist_append (NULL, style);
708 styles = style->styles;
711 new_style = styles->data;
713 if (new_style->attach_count == 0)
715 gtk_style_realize (new_style, colormap);
718 else if (new_style->colormap == colormap)
722 styles = styles->next;
727 new_style = gtk_style_duplicate (style);
728 gtk_style_realize (new_style, colormap);
731 /* A style gets a refcount from being attached */
732 if (new_style->attach_count == 0)
733 g_object_ref (new_style);
735 /* Another refcount belongs to the parent */
736 if (style != new_style)
738 g_object_unref (style);
739 g_object_ref (new_style);
742 new_style->attach_count++;
748 gtk_style_detach (GtkStyle *style)
750 g_return_if_fail (GTK_IS_STYLE (style));
752 style->attach_count -= 1;
753 if (style->attach_count == 0)
755 GTK_STYLE_GET_CLASS (style)->unrealize (style);
757 gdk_colormap_unref (style->colormap);
758 style->colormap = NULL;
760 g_object_unref (style);
766 * @style: a #GtkStyle.
769 * Deprecated equivalent of g_object_ref().
772 gtk_style_ref (GtkStyle *style)
774 return (GtkStyle *) g_object_ref (G_OBJECT (style));
779 * @style: a #GtkStyle.
781 * Deprecated equivalent of g_object_unref().
784 gtk_style_unref (GtkStyle *style)
786 g_object_unref (G_OBJECT (style));
790 gtk_style_realize (GtkStyle *style,
791 GdkColormap *colormap)
793 g_return_if_fail (GTK_IS_STYLE (style));
794 g_return_if_fail (GDK_IS_COLORMAP (colormap));
796 style->colormap = gdk_colormap_ref (colormap);
797 style->depth = gdk_colormap_get_visual (colormap)->depth;
799 GTK_STYLE_GET_CLASS (style)->realize (style);
803 gtk_style_lookup_icon_set (GtkStyle *style,
804 const char *stock_id)
808 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
809 g_return_val_if_fail (stock_id != NULL, NULL);
811 iter = style->icon_factories;
814 GtkIconSet *icon_set = gtk_icon_factory_lookup (GTK_ICON_FACTORY (iter->data),
819 iter = g_slist_next (iter);
822 return gtk_icon_factory_lookup_default (stock_id);
827 * @style: a #GtkStyle
828 * @window: a #GdkWindow
829 * @state_type: a state
830 * @x1: the starting x coordinate
831 * @x2: the ending x coordinate
832 * @y: the y coordinate
834 * Draws a horizontal line from (@x1, @y) to (@x2, @y) in @window
835 * using the given style and state.
837 * This function is deprecated, use gtk_paint_hline() instead.
840 gtk_draw_hline (GtkStyle *style,
842 GtkStateType state_type,
847 g_return_if_fail (GTK_IS_STYLE (style));
848 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_hline != NULL);
850 GTK_STYLE_GET_CLASS (style)->draw_hline (style, window, state_type, NULL, NULL, NULL, x1, x2, y);
856 * @style: a #GtkStyle
857 * @window: a #GdkWindow
858 * @state_type: a state
859 * @y1: the starting y coordinate
860 * @y2: the ending y coordinate
861 * @x: the x coordinate
863 * Draws a vertical line from (@x, @y1) to (@x, @y2) in @window
864 * using the given style and state.
866 * This function is deprecated, use gtk_paint_vline() instead.
869 gtk_draw_vline (GtkStyle *style,
871 GtkStateType state_type,
876 g_return_if_fail (GTK_IS_STYLE (style));
877 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_vline != NULL);
879 GTK_STYLE_GET_CLASS (style)->draw_vline (style, window, state_type, NULL, NULL, NULL, y1, y2, x);
884 * @style: a #GtkStyle
885 * @window: a #GdkWindow
886 * @state_type: a state
887 * @shadow_type: type of shadow to draw
888 * @x: x origin of the rectangle
889 * @y: y origin of the rectangle
890 * @width: width of the rectangle
891 * @height: width of the rectangle
893 * Draws a shadow around the given rectangle in @window
894 * using the given style and state and shadow type.
896 * This function is deprecated, use gtk_paint_shadow() instead.
899 gtk_draw_shadow (GtkStyle *style,
901 GtkStateType state_type,
902 GtkShadowType shadow_type,
908 g_return_if_fail (GTK_IS_STYLE (style));
909 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow != NULL);
911 GTK_STYLE_GET_CLASS (style)->draw_shadow (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
916 * @style: a #GtkStyle
917 * @window: a #GdkWindow
918 * @state_type: a state
919 * @shadow_type: type of shadow to draw
920 * @points: an array of #GdkPoint<!>s
921 * @npoints: length of @points
922 * @fill: %TRUE if the polygon should be filled
924 * Draws a polygon on @window with the given parameters.
926 * This function is deprecated, use gtk_paint_polygon() instead.
929 gtk_draw_polygon (GtkStyle *style,
931 GtkStateType state_type,
932 GtkShadowType shadow_type,
937 g_return_if_fail (GTK_IS_STYLE (style));
938 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_polygon != NULL);
940 GTK_STYLE_GET_CLASS (style)->draw_polygon (style, window, state_type, shadow_type, NULL, NULL, NULL, points, npoints, fill);
945 * @style: a #GtkStyle
946 * @window: a #GdkWindow
947 * @state_type: a state
948 * @shadow_type: the type of shadow to draw
949 * @arrow_type: the type of arrow to draw
950 * @fill: %TRUE if the arrow tip should be filled
951 * @x: x origin of the rectangle to draw the arrow in
952 * @y: y origin of the rectangle to draw the arrow in
953 * @width: width of the rectangle to draw the arrow in
954 * @height: height of the rectangle to draw the arrow in
956 * Draws an arrow in the given rectangle on @window using the given
957 * parameters. @arrow_type determines the direction of the arrow.
959 * This function is deprecated, use gtk_paint_arrow() instead.
962 gtk_draw_arrow (GtkStyle *style,
964 GtkStateType state_type,
965 GtkShadowType shadow_type,
966 GtkArrowType arrow_type,
973 g_return_if_fail (GTK_IS_STYLE (style));
974 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_arrow != NULL);
976 GTK_STYLE_GET_CLASS (style)->draw_arrow (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, fill, x, y, width, height);
981 * @style: a #GtkStyle
982 * @window: a #GdkWindow
983 * @state_type: a state
984 * @shadow_type: the type of shadow to draw
985 * @x: x origin of the rectangle to draw the diamond in
986 * @y: y origin of the rectangle to draw the diamond in
987 * @width: width of the rectangle to draw the diamond in
988 * @height: height of the rectangle to draw the diamond in
990 * Draws a diamond in the given rectangle on @window using the given parameters.
992 * This function is deprecated, use gtk_paint_diamond() instead.
995 gtk_draw_diamond (GtkStyle *style,
997 GtkStateType state_type,
998 GtkShadowType shadow_type,
1004 g_return_if_fail (GTK_IS_STYLE (style));
1005 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_diamond != NULL);
1007 GTK_STYLE_GET_CLASS (style)->draw_diamond (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
1012 * @style: a #GtkStyle
1013 * @window: a #GdkWindow
1014 * @state_type: a state
1017 * @string: the string to draw
1019 * Draws a text string on @window with the given parameters.
1021 * This function is deprecated, use gtk_paint_layout() instead.
1024 gtk_draw_string (GtkStyle *style,
1026 GtkStateType state_type,
1029 const gchar *string)
1031 g_return_if_fail (GTK_IS_STYLE (style));
1032 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_string != NULL);
1034 GTK_STYLE_GET_CLASS (style)->draw_string (style, window, state_type, NULL, NULL, NULL, x, y, string);
1039 * @style: a #GtkStyle
1040 * @window: a #GdkWindow
1041 * @state_type: a state
1042 * @shadow_type: the type of shadow to draw
1043 * @x: x origin of the box
1044 * @y: y origin of the box
1045 * @width: the width of the box
1046 * @height: the height of the box
1048 * Draws a box on @window with the given parameters.
1050 * This function is deprecated, use gtk_paint_box() instead.
1053 gtk_draw_box (GtkStyle *style,
1055 GtkStateType state_type,
1056 GtkShadowType shadow_type,
1062 g_return_if_fail (GTK_IS_STYLE (style));
1063 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box != NULL);
1065 GTK_STYLE_GET_CLASS (style)->draw_box (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
1069 * gtk_draw_flat_box:
1070 * @style: a #GtkStyle
1071 * @window: a #GdkWindow
1072 * @state_type: a state
1073 * @shadow_type: the type of shadow to draw
1074 * @x: x origin of the box
1075 * @y: y origin of the box
1076 * @width: the width of the box
1077 * @height: the height of the box
1079 * Draws a flat box on @window with the given parameters.
1081 * This function is deprecated, use gtk_paint_flat_box() instead.
1084 gtk_draw_flat_box (GtkStyle *style,
1086 GtkStateType state_type,
1087 GtkShadowType shadow_type,
1093 g_return_if_fail (GTK_IS_STYLE (style));
1094 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_flat_box != NULL);
1096 GTK_STYLE_GET_CLASS (style)->draw_flat_box (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
1101 * @style: a #GtkStyle
1102 * @window: a #GdkWindow
1103 * @state_type: a state
1104 * @shadow_type: the type of shadow to draw
1105 * @x: x origin of the rectangle to draw the check in
1106 * @y: y origin of the rectangle to draw the check in
1107 * @width: the width of the rectangle to draw the check in
1108 * @height: the height of the rectangle to draw the check in
1110 * Draws a check button indicator in the given rectangle on @window with
1111 * the given parameters.
1113 * This function is deprecated, use gtk_paint_check() instead.
1116 gtk_draw_check (GtkStyle *style,
1118 GtkStateType state_type,
1119 GtkShadowType shadow_type,
1125 g_return_if_fail (GTK_IS_STYLE (style));
1126 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_check != NULL);
1128 GTK_STYLE_GET_CLASS (style)->draw_check (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
1133 * @style: a #GtkStyle
1134 * @window: a #GdkWindow
1135 * @state_type: a state
1136 * @shadow_type: the type of shadow to draw
1137 * @x: x origin of the rectangle to draw the option in
1138 * @y: y origin of the rectangle to draw the option in
1139 * @width: the width of the rectangle to draw the option in
1140 * @height: the height of the rectangle to draw the option in
1142 * Draws a radio button indicator in the given rectangle on @window with
1143 * the given parameters.
1145 * This function is deprecated, use gtk_paint_option() instead.
1148 gtk_draw_option (GtkStyle *style,
1150 GtkStateType state_type,
1151 GtkShadowType shadow_type,
1157 g_return_if_fail (GTK_IS_STYLE (style));
1158 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_option != NULL);
1160 GTK_STYLE_GET_CLASS (style)->draw_option (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
1165 * @style: a #GtkStyle
1166 * @window: a #GdkWindow
1167 * @state_type: a state
1168 * @shadow_type: the type of shadow to draw
1169 * @x: x origin of the rectangle to draw the tab in
1170 * @y: y origin of the rectangle to draw the tab in
1171 * @width: the width of the rectangle to draw the tab in
1172 * @height: the height of the rectangle to draw the tab in
1174 * Draws an option menu tab (i.e. the up and down pointing arrows)
1175 * in the given rectangle on @window using the given parameters.
1177 * This function is deprecated, use gtk_paint_tab() instead.
1180 gtk_draw_tab (GtkStyle *style,
1182 GtkStateType state_type,
1183 GtkShadowType shadow_type,
1189 g_return_if_fail (GTK_IS_STYLE (style));
1190 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_tab != NULL);
1192 GTK_STYLE_GET_CLASS (style)->draw_tab (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
1196 gtk_draw_shadow_gap (GtkStyle *style,
1198 GtkStateType state_type,
1199 GtkShadowType shadow_type,
1204 GtkPositionType gap_side,
1208 g_return_if_fail (GTK_IS_STYLE (style));
1209 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow_gap != NULL);
1211 GTK_STYLE_GET_CLASS (style)->draw_shadow_gap (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width);
1215 gtk_draw_box_gap (GtkStyle *style,
1217 GtkStateType state_type,
1218 GtkShadowType shadow_type,
1223 GtkPositionType gap_side,
1227 g_return_if_fail (GTK_IS_STYLE (style));
1228 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box_gap != NULL);
1230 GTK_STYLE_GET_CLASS (style)->draw_box_gap (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width);
1234 gtk_draw_extension (GtkStyle *style,
1236 GtkStateType state_type,
1237 GtkShadowType shadow_type,
1242 GtkPositionType gap_side)
1244 g_return_if_fail (GTK_IS_STYLE (style));
1245 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_extension != NULL);
1247 GTK_STYLE_GET_CLASS (style)->draw_extension (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side);
1252 * @style: a #GtkStyle
1253 * @window: a #GdkWindow
1254 * @x: the x origin of the rectangle around which to draw a focus indicator
1255 * @y: the y origin of the rectangle around which to draw a focus indicator
1256 * @width: the width of the rectangle around which to draw a focus indicator
1257 * @height: the height of the rectangle around which to draw a focus indicator
1259 * Draws a focus indicator around the given rectangle on @window using the
1262 * This function is deprecated, use gtk_paint_focus() instead.
1265 gtk_draw_focus (GtkStyle *style,
1272 g_return_if_fail (GTK_IS_STYLE (style));
1273 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_focus != NULL);
1275 GTK_STYLE_GET_CLASS (style)->draw_focus (style, window, GTK_STATE_NORMAL, NULL, NULL, NULL, x, y, width, height);
1279 gtk_draw_slider (GtkStyle *style,
1281 GtkStateType state_type,
1282 GtkShadowType shadow_type,
1287 GtkOrientation orientation)
1289 g_return_if_fail (GTK_IS_STYLE (style));
1290 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_slider != NULL);
1292 GTK_STYLE_GET_CLASS (style)->draw_slider (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
1296 gtk_draw_handle (GtkStyle *style,
1298 GtkStateType state_type,
1299 GtkShadowType shadow_type,
1304 GtkOrientation orientation)
1306 g_return_if_fail (GTK_IS_STYLE (style));
1307 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_handle != NULL);
1309 GTK_STYLE_GET_CLASS (style)->draw_handle (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
1313 gtk_draw_expander (GtkStyle *style,
1315 GtkStateType state_type,
1318 GtkExpanderStyle expander_style)
1320 g_return_if_fail (GTK_IS_STYLE (style));
1321 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_expander != NULL);
1323 GTK_STYLE_GET_CLASS (style)->draw_expander (style, window, state_type,
1325 x, y, expander_style);
1329 gtk_draw_layout (GtkStyle *style,
1331 GtkStateType state_type,
1335 PangoLayout *layout)
1337 g_return_if_fail (GTK_IS_STYLE (style));
1338 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_layout != NULL);
1340 GTK_STYLE_GET_CLASS (style)->draw_layout (style, window, state_type, use_text,
1346 * gtk_draw_resize_grip:
1347 * @style: a #GtkStyle
1348 * @window: a #GdkWindow
1349 * @state_type: a state
1350 * @edge: the edge in which to draw the resize grip, currently only
1351 * %GTK_WINDOW_EDGE_SOUTH_EAST is implemented
1352 * @x: the x origin of the rectangle in which to draw the resize grip
1353 * @y: the y origin of the rectangle in which to draw the resize grip
1354 * @width: the width of the rectangle in which to draw the resize grip
1355 * @height: the height of the rectangle in which to draw the resize grip
1357 * Draws a resize grip in the given rectangle on @window using the given
1360 * This function is deprecated, use gtk_paint_resize_grip() instead.
1363 gtk_draw_resize_grip (GtkStyle *style,
1365 GtkStateType state_type,
1372 g_return_if_fail (GTK_IS_STYLE (style));
1373 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_resize_grip != NULL);
1375 GTK_STYLE_GET_CLASS (style)->draw_resize_grip (style, window, state_type,
1378 x, y, width, height);
1383 * gtk_style_set_background:
1384 * @style: a #GtkStyle
1385 * @window: a #GdkWindow
1386 * @state_type: a state
1388 * Sets the background of @window to the background color or pixmap
1389 * specified by @style for the given state.
1392 gtk_style_set_background (GtkStyle *style,
1394 GtkStateType state_type)
1396 g_return_if_fail (GTK_IS_STYLE (style));
1397 g_return_if_fail (window != NULL);
1399 GTK_STYLE_GET_CLASS (style)->set_background (style, window, state_type);
1402 /* Default functions */
1404 gtk_style_real_clone (GtkStyle *style)
1406 return GTK_STYLE (g_object_new (G_OBJECT_TYPE (style), NULL));
1410 gtk_style_real_copy (GtkStyle *style,
1415 for (i = 0; i < 5; i++)
1417 style->fg[i] = src->fg[i];
1418 style->bg[i] = src->bg[i];
1419 style->text[i] = src->text[i];
1420 style->base[i] = src->base[i];
1422 style->bg_pixmap[i] = src->bg_pixmap[i];
1425 if (style->private_font)
1426 gdk_font_unref (style->private_font);
1427 style->private_font = src->private_font;
1428 if (style->private_font)
1429 gdk_font_ref (style->private_font);
1431 if (style->font_desc)
1432 pango_font_description_free (style->font_desc);
1434 style->font_desc = pango_font_description_copy (src->font_desc);
1436 style->font_desc = NULL;
1438 style->xthickness = src->xthickness;
1439 style->ythickness = src->ythickness;
1441 if (style->rc_style)
1442 gtk_rc_style_unref (style->rc_style);
1443 style->rc_style = src->rc_style;
1445 gtk_rc_style_ref (src->rc_style);
1447 /* don't copy, just clear cache */
1448 clear_property_cache (style);
1452 gtk_style_real_init_from_rc (GtkStyle *style,
1453 GtkRcStyle *rc_style)
1457 /* cache _should_ be still empty */
1458 clear_property_cache (style);
1460 if (rc_style->font_desc)
1461 pango_font_description_merge (style->font_desc, rc_style->font_desc, TRUE);
1463 for (i = 0; i < 5; i++)
1465 if (rc_style->color_flags[i] & GTK_RC_FG)
1466 style->fg[i] = rc_style->fg[i];
1467 if (rc_style->color_flags[i] & GTK_RC_BG)
1468 style->bg[i] = rc_style->bg[i];
1469 if (rc_style->color_flags[i] & GTK_RC_TEXT)
1470 style->text[i] = rc_style->text[i];
1471 if (rc_style->color_flags[i] & GTK_RC_BASE)
1472 style->base[i] = rc_style->base[i];
1475 if (rc_style->xthickness >= 0)
1476 style->xthickness = rc_style->xthickness;
1477 if (rc_style->ythickness >= 0)
1478 style->ythickness = rc_style->ythickness;
1480 if (rc_style->icon_factories)
1484 style->icon_factories = g_slist_copy (rc_style->icon_factories);
1486 iter = style->icon_factories;
1487 while (iter != NULL)
1489 g_object_ref (G_OBJECT (iter->data));
1491 iter = g_slist_next (iter);
1497 style_property_values_cmp (gconstpointer bsearch_node1,
1498 gconstpointer bsearch_node2)
1500 const PropertyValue *val1 = bsearch_node1;
1501 const PropertyValue *val2 = bsearch_node2;
1503 if (val1->widget_type == val2->widget_type)
1504 return val1->pspec < val2->pspec ? -1 : val1->pspec == val2->pspec ? 0 : 1;
1506 return val1->widget_type < val2->widget_type ? -1 : 1;
1510 _gtk_style_peek_property_value (GtkStyle *style,
1513 GtkRcPropertyParser parser)
1515 PropertyValue *pcache, key = { 0, NULL, { 0, } };
1516 const GtkRcProperty *rcprop = NULL;
1519 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
1520 g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), NULL);
1521 g_return_val_if_fail (g_type_is_a (pspec->owner_type, GTK_TYPE_WIDGET), NULL);
1522 g_return_val_if_fail (g_type_is_a (widget_type, pspec->owner_type), NULL);
1524 key.widget_type = widget_type;
1527 /* need value cache array */
1528 if (!style->property_cache)
1529 style->property_cache = g_array_new (FALSE, FALSE, sizeof (PropertyValue));
1532 pcache = bsearch (&key,
1533 style->property_cache->data, style->property_cache->len,
1534 sizeof (PropertyValue), style_property_values_cmp);
1536 return &pcache->value;
1540 while (i < style->property_cache->len &&
1541 style_property_values_cmp (&key, &g_array_index (style->property_cache, PropertyValue, i)) >= 0)
1544 g_array_insert_val (style->property_cache, i, key);
1545 pcache = &g_array_index (style->property_cache, PropertyValue, i);
1547 /* cache miss, initialize value type, then set contents */
1548 g_param_spec_ref (pcache->pspec);
1549 g_value_init (&pcache->value, G_PARAM_SPEC_VALUE_TYPE (pspec));
1551 /* value provided by rc style? */
1552 if (style->rc_style)
1554 GQuark prop_quark = g_quark_from_string (pspec->name);
1558 rcprop = _gtk_rc_style_lookup_rc_property (style->rc_style,
1559 g_type_qname (widget_type),
1563 widget_type = g_type_parent (widget_type);
1565 while (g_type_is_a (widget_type, pspec->owner_type));
1568 /* when supplied by rc style, we need to convert */
1569 if (rcprop && !_gtk_settings_parse_convert (parser, &rcprop->value,
1570 pspec, &pcache->value))
1572 gchar *contents = g_strdup_value_contents (&rcprop->value);
1574 g_message ("%s: failed to retrieve property `%s::%s' of type `%s' from rc file value \"%s\" of type `%s'",
1576 g_type_name (pspec->owner_type), pspec->name,
1577 g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
1579 G_VALUE_TYPE_NAME (&rcprop->value));
1581 rcprop = NULL; /* needs default */
1584 /* not supplied by rc style (or conversion failed), revert to default */
1586 g_param_value_set_default (pspec, &pcache->value);
1588 return &pcache->value;
1592 load_bg_image (GdkColormap *colormap,
1594 const gchar *filename)
1596 if (strcmp (filename, "<parent>") == 0)
1597 return (GdkPixmap*) GDK_PARENT_RELATIVE;
1600 return gdk_pixmap_colormap_create_from_xpm (NULL, colormap, NULL,
1607 gtk_style_real_realize (GtkStyle *style)
1609 GdkGCValues gc_values;
1610 GdkGCValuesMask gc_values_mask;
1614 for (i = 0; i < 5; i++)
1616 gtk_style_shade (&style->bg[i], &style->light[i], LIGHTNESS_MULT);
1617 gtk_style_shade (&style->bg[i], &style->dark[i], DARKNESS_MULT);
1619 style->mid[i].red = (style->light[i].red + style->dark[i].red) / 2;
1620 style->mid[i].green = (style->light[i].green + style->dark[i].green) / 2;
1621 style->mid[i].blue = (style->light[i].blue + style->dark[i].blue) / 2;
1623 style->text_aa[i].red = (style->text[i].red + style->base[i].red) / 2;
1624 style->text_aa[i].green = (style->text[i].green + style->base[i].green) / 2;
1625 style->text_aa[i].blue = (style->text[i].blue + style->base[i].blue) / 2;
1628 gdk_color_black (style->colormap, &style->black);
1629 gdk_color_white (style->colormap, &style->white);
1631 gc_values_mask = GDK_GC_FOREGROUND;
1633 gc_values.foreground = style->black;
1634 style->black_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1636 gc_values.foreground = style->white;
1637 style->white_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1639 for (i = 0; i < 5; i++)
1641 if (style->rc_style && style->rc_style->bg_pixmap_name[i])
1642 style->bg_pixmap[i] = load_bg_image (style->colormap,
1644 style->rc_style->bg_pixmap_name[i]);
1646 if (!gdk_color_alloc (style->colormap, &style->fg[i]))
1647 g_warning ("unable to allocate color: ( %d %d %d )",
1648 style->fg[i].red, style->fg[i].green, style->fg[i].blue);
1649 if (!gdk_color_alloc (style->colormap, &style->bg[i]))
1650 g_warning ("unable to allocate color: ( %d %d %d )",
1651 style->bg[i].red, style->bg[i].green, style->bg[i].blue);
1652 if (!gdk_color_alloc (style->colormap, &style->light[i]))
1653 g_warning ("unable to allocate color: ( %d %d %d )",
1654 style->light[i].red, style->light[i].green, style->light[i].blue);
1655 if (!gdk_color_alloc (style->colormap, &style->dark[i]))
1656 g_warning ("unable to allocate color: ( %d %d %d )",
1657 style->dark[i].red, style->dark[i].green, style->dark[i].blue);
1658 if (!gdk_color_alloc (style->colormap, &style->mid[i]))
1659 g_warning ("unable to allocate color: ( %d %d %d )",
1660 style->mid[i].red, style->mid[i].green, style->mid[i].blue);
1661 if (!gdk_color_alloc (style->colormap, &style->text[i]))
1662 g_warning ("unable to allocate color: ( %d %d %d )",
1663 style->text[i].red, style->text[i].green, style->text[i].blue);
1664 if (!gdk_color_alloc (style->colormap, &style->base[i]))
1665 g_warning ("unable to allocate color: ( %d %d %d )",
1666 style->base[i].red, style->base[i].green, style->base[i].blue);
1667 if (!gdk_color_alloc (style->colormap, &style->text_aa[i]))
1668 g_warning ("unable to allocate color: ( %d %d %d )",
1669 style->text_aa[i].red, style->text_aa[i].green, style->text_aa[i].blue);
1671 gc_values.foreground = style->fg[i];
1672 style->fg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1674 gc_values.foreground = style->bg[i];
1675 style->bg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1677 gc_values.foreground = style->light[i];
1678 style->light_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1680 gc_values.foreground = style->dark[i];
1681 style->dark_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1683 gc_values.foreground = style->mid[i];
1684 style->mid_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1686 gc_values.foreground = style->text[i];
1687 style->text_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1689 gc_values.foreground = style->base[i];
1690 style->base_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1692 gc_values.foreground = style->text_aa[i];
1693 style->text_aa_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1698 gtk_style_real_unrealize (GtkStyle *style)
1702 gtk_gc_release (style->black_gc);
1703 gtk_gc_release (style->white_gc);
1705 for (i = 0; i < 5; i++)
1707 gtk_gc_release (style->fg_gc[i]);
1708 gtk_gc_release (style->bg_gc[i]);
1709 gtk_gc_release (style->light_gc[i]);
1710 gtk_gc_release (style->dark_gc[i]);
1711 gtk_gc_release (style->mid_gc[i]);
1712 gtk_gc_release (style->text_gc[i]);
1713 gtk_gc_release (style->base_gc[i]);
1714 gtk_gc_release (style->text_aa_gc[i]);
1716 if (style->bg_pixmap[i] && style->bg_pixmap[i] != (GdkPixmap*) GDK_PARENT_RELATIVE)
1717 gdk_pixmap_unref (style->bg_pixmap[i]);
1720 gdk_colormap_free_colors (style->colormap, style->fg, 5);
1721 gdk_colormap_free_colors (style->colormap, style->bg, 5);
1722 gdk_colormap_free_colors (style->colormap, style->light, 5);
1723 gdk_colormap_free_colors (style->colormap, style->dark, 5);
1724 gdk_colormap_free_colors (style->colormap, style->mid, 5);
1725 gdk_colormap_free_colors (style->colormap, style->text, 5);
1726 gdk_colormap_free_colors (style->colormap, style->base, 5);
1727 gdk_colormap_free_colors (style->colormap, style->text_aa, 5);
1731 gtk_style_real_set_background (GtkStyle *style,
1733 GtkStateType state_type)
1736 gint parent_relative;
1738 if (style->bg_pixmap[state_type])
1740 if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
1743 parent_relative = TRUE;
1747 pixmap = style->bg_pixmap[state_type];
1748 parent_relative = FALSE;
1751 gdk_window_set_back_pixmap (window, pixmap, parent_relative);
1754 gdk_window_set_background (window, &style->bg[state_type]);
1758 * gtk_style_render_icon:
1759 * @style: a #GtkStyle
1760 * @source: the #GtkIconSource specifying the icon to render
1761 * @direction: a text direction
1763 * @size: the size to render the icon at
1764 * @widget: the widget
1765 * @detail: a style detail
1766 * @returns: a newly-created #GdkPixbuf containing the rendered icon
1768 * Renders the icon specified by @source at the given @size
1769 * according to the given parameters and returns the result in a
1773 gtk_style_render_icon (GtkStyle *style,
1774 const GtkIconSource *source,
1775 GtkTextDirection direction,
1779 const gchar *detail)
1783 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
1784 g_return_val_if_fail (GTK_STYLE_GET_CLASS (style)->render_icon != NULL, NULL);
1786 pixbuf = GTK_STYLE_GET_CLASS (style)->render_icon (style, source, direction, state,
1787 size, widget, detail);
1789 g_return_val_if_fail (pixbuf != NULL, NULL);
1794 /* Default functions */
1796 gtk_style_apply_default_background (GtkStyle *style,
1799 GtkStateType state_type,
1806 GdkRectangle new_rect, old_rect;
1812 old_rect.width = width;
1813 old_rect.height = height;
1815 if (!gdk_rectangle_intersect (area, &old_rect, &new_rect))
1822 new_rect.width = width;
1823 new_rect.height = height;
1826 if (!style->bg_pixmap[state_type] ||
1827 GDK_IS_PIXMAP (window) ||
1828 (!set_bg && style->bg_pixmap[state_type] != (GdkPixmap*) GDK_PARENT_RELATIVE))
1830 GdkGC *gc = style->bg_gc[state_type];
1832 if (style->bg_pixmap[state_type])
1834 gdk_gc_set_fill (gc, GDK_TILED);
1835 gdk_gc_set_tile (gc, style->bg_pixmap[state_type]);
1838 gdk_draw_rectangle (window, gc, TRUE,
1839 new_rect.x, new_rect.y, new_rect.width, new_rect.height);
1840 if (style->bg_pixmap[state_type])
1841 gdk_gc_set_fill (gc, GDK_SOLID);
1847 if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
1848 gdk_window_set_back_pixmap (window, NULL, TRUE);
1850 gdk_window_set_back_pixmap (window, style->bg_pixmap[state_type], FALSE);
1853 gdk_window_clear_area (window,
1854 new_rect.x, new_rect.y,
1855 new_rect.width, new_rect.height);
1860 scale_or_ref (GdkPixbuf *src,
1864 if (width == gdk_pixbuf_get_width (src) &&
1865 height == gdk_pixbuf_get_height (src))
1867 gdk_pixbuf_ref (src);
1872 return gdk_pixbuf_scale_simple (src,
1874 GDK_INTERP_BILINEAR);
1879 gtk_default_render_icon (GtkStyle *style,
1880 const GtkIconSource *source,
1881 GtkTextDirection direction,
1885 const gchar *detail)
1891 GdkPixbuf *base_pixbuf;
1893 /* Oddly, style can be NULL in this function, because
1894 * GtkIconSet can be used without a style and if so
1895 * it uses this function.
1898 base_pixbuf = gtk_icon_source_get_pixbuf (source);
1900 g_return_val_if_fail (base_pixbuf != NULL, NULL);
1902 if (!gtk_icon_size_lookup (size, &width, &height))
1904 g_warning (G_STRLOC ": invalid icon size `%d'", size);
1908 /* If the size was wildcarded, then scale; otherwise, leave it
1911 if (gtk_icon_source_get_size_wildcarded (source))
1912 scaled = scale_or_ref (base_pixbuf, width, height);
1914 scaled = GDK_PIXBUF (g_object_ref (G_OBJECT (base_pixbuf)));
1916 /* If the state was wildcarded, then generate a state. */
1917 if (gtk_icon_source_get_state_wildcarded (source))
1919 if (state == GTK_STATE_INSENSITIVE)
1921 stated = gdk_pixbuf_copy (scaled);
1923 gdk_pixbuf_saturate_and_pixelate (scaled, stated,
1926 gdk_pixbuf_unref (scaled);
1928 else if (state == GTK_STATE_PRELIGHT)
1930 stated = gdk_pixbuf_copy (scaled);
1932 gdk_pixbuf_saturate_and_pixelate (scaled, stated,
1935 gdk_pixbuf_unref (scaled);
1949 sanitize_size (GdkWindow *window,
1953 gboolean set_bg = FALSE;
1955 if ((*width == -1) && (*height == -1))
1957 set_bg = GDK_IS_WINDOW (window);
1958 gdk_window_get_size (window, width, height);
1960 else if (*width == -1)
1961 gdk_window_get_size (window, width, NULL);
1962 else if (*height == -1)
1963 gdk_window_get_size (window, NULL, height);
1969 draw_part (GdkDrawable *drawable,
1977 gdk_gc_set_clip_rectangle (gc, area);
1979 if (!indicator_parts[part].bmap)
1980 indicator_parts[part].bmap = gdk_bitmap_create_from_data (drawable,
1981 indicator_parts[part].bits,
1982 INDICATOR_PART_SIZE, INDICATOR_PART_SIZE);
1984 gdk_gc_set_ts_origin (gc, x, y);
1985 gdk_gc_set_stipple (gc, indicator_parts[part].bmap);
1986 gdk_gc_set_fill (gc, GDK_STIPPLED);
1988 gdk_draw_rectangle (drawable, gc, TRUE, x, y, INDICATOR_PART_SIZE, INDICATOR_PART_SIZE);
1990 gdk_gc_set_fill (gc, GDK_SOLID);
1993 gdk_gc_set_clip_rectangle (gc, NULL);
1997 gtk_default_draw_hline (GtkStyle *style,
1999 GtkStateType state_type,
2002 const gchar *detail,
2007 gint thickness_light;
2008 gint thickness_dark;
2011 g_return_if_fail (GTK_IS_STYLE (style));
2012 g_return_if_fail (window != NULL);
2014 thickness_light = style->ythickness / 2;
2015 thickness_dark = style->ythickness - thickness_light;
2019 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
2020 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
2023 if (detail && !strcmp (detail, "label"))
2025 if (state_type == GTK_STATE_INSENSITIVE)
2026 gdk_draw_line (window, style->white_gc, x1 + 1, y + 1, x2 + 1, y + 1);
2027 gdk_draw_line (window, style->fg_gc[state_type], x1, y, x2, y);
2031 for (i = 0; i < thickness_dark; i++)
2033 gdk_draw_line (window, style->light_gc[state_type], x2 - i - 1, y + i, x2, y + i);
2034 gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x2 - i - 1, y + i);
2037 y += thickness_dark;
2038 for (i = 0; i < thickness_light; i++)
2040 gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x1 + thickness_light - i - 1, y + i);
2041 gdk_draw_line (window, style->light_gc[state_type], x1 + thickness_light - i - 1, y + i, x2, y + i);
2047 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
2048 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
2054 gtk_default_draw_vline (GtkStyle *style,
2056 GtkStateType state_type,
2059 const gchar *detail,
2064 gint thickness_light;
2065 gint thickness_dark;
2068 g_return_if_fail (GTK_IS_STYLE (style));
2069 g_return_if_fail (window != NULL);
2071 thickness_light = style->xthickness / 2;
2072 thickness_dark = style->xthickness - thickness_light;
2076 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
2077 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
2079 for (i = 0; i < thickness_dark; i++)
2081 gdk_draw_line (window, style->light_gc[state_type], x + i, y2 - i - 1, x + i, y2);
2082 gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y2 - i - 1);
2085 x += thickness_dark;
2086 for (i = 0; i < thickness_light; i++)
2088 gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y1 + thickness_light - i);
2089 gdk_draw_line (window, style->light_gc[state_type], x + i, y1 + thickness_light - i, x + i, y2);
2093 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
2094 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
2100 draw_thin_shadow (GtkStyle *style,
2111 sanitize_size (window, &width, &height);
2113 gc1 = style->light_gc[state];
2114 gc2 = style->dark_gc[state];
2118 gdk_gc_set_clip_rectangle (gc1, area);
2119 gdk_gc_set_clip_rectangle (gc2, area);
2122 gdk_draw_line (window, gc1,
2123 x, y + height - 1, x + width - 1, y + height - 1);
2124 gdk_draw_line (window, gc1,
2125 x + width - 1, y, x + width - 1, y + height - 1);
2127 gdk_draw_line (window, gc2,
2128 x, y, x + width - 1, y);
2129 gdk_draw_line (window, gc2,
2130 x, y, x, y + height - 1);
2134 gdk_gc_set_clip_rectangle (gc1, NULL);
2135 gdk_gc_set_clip_rectangle (gc2, NULL);
2140 draw_spin_entry_shadow (GtkStyle *style,
2149 gint window_width, window_height;
2150 gboolean focus_inset;
2152 gdk_window_get_size (window, &window_width, &window_height);
2155 width = window_width;
2157 height = window_height;
2159 focus_inset = (width < window_width && height < window_height);
2163 gdk_gc_set_clip_rectangle (style->light_gc[state], area);
2164 gdk_gc_set_clip_rectangle (style->dark_gc[state], area);
2165 gdk_gc_set_clip_rectangle (style->black_gc, area);
2166 gdk_gc_set_clip_rectangle (style->bg_gc[state], area);
2167 gdk_gc_set_clip_rectangle (style->base_gc[state], area);
2170 gdk_draw_line (window, style->light_gc[state],
2171 x, y + height - 1, x + width - 1, y + height - 1);
2173 gdk_draw_line (window,
2174 style->base_gc[state],
2175 x + width - 1, y + 1, x + width - 1, y + height - 3);
2179 gdk_draw_line (window, style->bg_gc[state],
2180 x + 1, y + height - 2, x + width - 1, y + height - 2);
2181 gdk_draw_line (window,
2182 style->base_gc[state],
2183 x + width - 2, y + 1, x + width - 2, y + height - 3);
2185 gdk_draw_line (window, style->black_gc,
2186 x + 1, y + 1, x + width - 1, y + 1);
2187 gdk_draw_line (window, style->black_gc,
2188 x + 1, y + 1, x + 1, y + height - 2);
2191 gdk_draw_line (window, style->dark_gc[state],
2192 x, y, x + width - 1, y);
2193 gdk_draw_line (window, style->dark_gc[state],
2194 x, y, x, y + height - 1);
2198 gdk_gc_set_clip_rectangle (style->light_gc[state], NULL);
2199 gdk_gc_set_clip_rectangle (style->dark_gc[state], NULL);
2200 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2201 gdk_gc_set_clip_rectangle (style->bg_gc[state], NULL);
2202 gdk_gc_set_clip_rectangle (style->base_gc[state], NULL);
2207 draw_spinbutton_shadow (GtkStyle *style,
2216 gint y_middle = y + height / 2;
2218 sanitize_size (window, &width, &height);
2222 gdk_gc_set_clip_rectangle (style->black_gc, area);
2223 gdk_gc_set_clip_rectangle (style->bg_gc[state], area);
2224 gdk_gc_set_clip_rectangle (style->dark_gc[state], area);
2225 gdk_gc_set_clip_rectangle (style->light_gc[state], area);
2228 gdk_draw_line (window, style->black_gc,
2229 x, y + 2, x, y + height - 3);
2230 gdk_draw_line (window, style->black_gc,
2231 x, y + 1, x + width - 2, y + 1);
2232 gdk_draw_line (window, style->black_gc,
2233 x + width - 2, y + 2, x + width - 2, y + height - 3);
2235 gdk_draw_line (window, style->bg_gc[state],
2236 x, y + height - 2, x + width - 2, y + height - 2);
2238 gdk_draw_line (window, style->dark_gc[state],
2239 x, y, x + width - 1, y);
2240 gdk_draw_line (window, style->dark_gc[state],
2241 x + 1, y_middle - 1, x + width - 3, y_middle - 1);
2242 gdk_draw_line (window, style->dark_gc[state],
2243 x + 1, y + height - 3, x + width - 3, y + height - 3);
2245 gdk_draw_line (window, style->light_gc[state],
2246 x + 1, y + 2, x + width - 3, y + 2);
2247 gdk_draw_line (window, style->light_gc[state],
2248 x + 1, y_middle, x + width - 3, y_middle);
2249 gdk_draw_line (window, style->light_gc[state],
2250 x + width - 1, y + 1, x + width - 1, y + height - 1);
2251 gdk_draw_line (window, style->light_gc[state],
2252 x, y + height - 1, x + width - 2, y + height - 1);
2256 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2257 gdk_gc_set_clip_rectangle (style->bg_gc[state], NULL);
2258 gdk_gc_set_clip_rectangle (style->dark_gc[state], NULL);
2259 gdk_gc_set_clip_rectangle (style->light_gc[state], NULL);
2264 gtk_default_draw_shadow (GtkStyle *style,
2266 GtkStateType state_type,
2267 GtkShadowType shadow_type,
2270 const gchar *detail,
2278 gint thickness_light;
2279 gint thickness_dark;
2282 g_return_if_fail (GTK_IS_STYLE (style));
2283 g_return_if_fail (window != NULL);
2285 if (shadow_type == GTK_SHADOW_IN)
2287 if (detail && (strcmp (detail, "buttondefault") == 0))
2289 sanitize_size (window, &width, &height);
2291 gdk_draw_rectangle (window, style->black_gc, FALSE,
2292 x, y, width - 1, height - 1);
2296 if (detail && strcmp (detail, "trough") == 0)
2298 draw_thin_shadow (style, window, state_type, area,
2299 x, y, width, height);
2302 else if (widget && GTK_IS_SPIN_BUTTON (widget) &&
2303 detail && strcmp (detail, "entry") == 0)
2305 draw_spin_entry_shadow (style, window, state_type, area,
2306 x, y, width, height);
2309 else if (widget && GTK_IS_SPIN_BUTTON (widget) &&
2310 detail && strcmp (detail, "spinbutton") == 0)
2312 draw_spinbutton_shadow (style, window, state_type,
2313 area, x, y, width, height);
2318 sanitize_size (window, &width, &height);
2320 switch (shadow_type)
2322 case GTK_SHADOW_NONE:
2325 case GTK_SHADOW_ETCHED_IN:
2326 gc1 = style->light_gc[state_type];
2327 gc2 = style->dark_gc[state_type];
2329 case GTK_SHADOW_OUT:
2330 case GTK_SHADOW_ETCHED_OUT:
2331 gc1 = style->dark_gc[state_type];
2332 gc2 = style->light_gc[state_type];
2338 gdk_gc_set_clip_rectangle (gc1, area);
2339 gdk_gc_set_clip_rectangle (gc2, area);
2340 if (shadow_type == GTK_SHADOW_IN ||
2341 shadow_type == GTK_SHADOW_OUT)
2343 gdk_gc_set_clip_rectangle (style->black_gc, area);
2344 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
2348 switch (shadow_type)
2350 case GTK_SHADOW_NONE:
2354 /* Light around right and bottom edge */
2356 if (style->ythickness > 0)
2357 gdk_draw_line (window, gc1,
2358 x, y + height - 1, x + width - 1, y + height - 1);
2359 if (style->xthickness > 0)
2360 gdk_draw_line (window, gc1,
2361 x + width - 1, y, x + width - 1, y + height - 1);
2363 if (style->ythickness > 1)
2364 gdk_draw_line (window, style->bg_gc[state_type],
2365 x + 1, y + height - 2, x + width - 2, y + height - 2);
2366 if (style->xthickness > 1)
2367 gdk_draw_line (window, style->bg_gc[state_type],
2368 x + width - 2, y + 1, x + width - 2, y + height - 2);
2370 /* Dark around left and top */
2372 if (style->ythickness > 1)
2373 gdk_draw_line (window, style->black_gc,
2374 x + 1, y + 1, x + width - 2, y + 1);
2375 if (style->xthickness > 1)
2376 gdk_draw_line (window, style->black_gc,
2377 x + 1, y + 1, x + 1, y + height - 2);
2379 if (style->ythickness > 0)
2380 gdk_draw_line (window, gc2,
2381 x, y, x + width - 1, y);
2382 if (style->xthickness > 0)
2383 gdk_draw_line (window, gc2,
2384 x, y, x, y + height - 1);
2387 case GTK_SHADOW_OUT:
2388 /* Dark around right and bottom edge */
2390 if (style->ythickness > 0)
2392 if (style->ythickness > 1)
2394 gdk_draw_line (window, gc1,
2395 x + 1, y + height - 2, x + width - 2, y + height - 2);
2396 gdk_draw_line (window, style->black_gc,
2397 x, y + height - 1, x + width - 1, y + height - 1);
2401 gdk_draw_line (window, gc1,
2402 x + 1, y + height - 1, x + width - 1, y + height - 1);
2406 if (style->xthickness > 0)
2408 if (style->xthickness > 1)
2410 gdk_draw_line (window, gc1,
2411 x + width - 2, y + 1, x + width - 2, y + height - 2);
2413 gdk_draw_line (window, style->black_gc,
2414 x + width - 1, y, x + width - 1, y + height - 1);
2418 gdk_draw_line (window, gc1,
2419 x + width - 1, y + 1, x + width - 1, y + height - 1);
2423 /* Light around top and left */
2425 if (style->ythickness > 0)
2426 gdk_draw_line (window, gc2,
2427 x, y, x + width - 1, y);
2428 if (style->xthickness > 0)
2429 gdk_draw_line (window, gc2,
2430 x, y, x, y + height - 1);
2432 if (style->ythickness > 1)
2433 gdk_draw_line (window, style->bg_gc[state_type],
2434 x + 1, y + 1, x + width - 2, y + 1);
2435 if (style->xthickness > 1)
2436 gdk_draw_line (window, style->bg_gc[state_type],
2437 x + 1, y + 1, x + 1, y + height - 2);
2440 case GTK_SHADOW_ETCHED_IN:
2441 case GTK_SHADOW_ETCHED_OUT:
2442 if (style->xthickness > 0)
2444 if (style->xthickness > 1)
2446 thickness_light = 1;
2449 for (i = 0; i < thickness_dark; i++)
2451 gdk_draw_line (window, gc1,
2455 y + height - i - 1);
2456 gdk_draw_line (window, gc2,
2460 y + height - i - 2);
2463 for (i = 0; i < thickness_light; i++)
2465 gdk_draw_line (window, gc1,
2466 x + thickness_dark + i,
2467 y + thickness_dark + i,
2468 x + thickness_dark + i,
2469 y + height - thickness_dark - i - 1);
2470 gdk_draw_line (window, gc2,
2471 x + width - thickness_light - i - 1,
2472 y + thickness_dark + i,
2473 x + width - thickness_light - i - 1,
2474 y + height - thickness_light - 1);
2479 gdk_draw_line (window,
2480 style->dark_gc[state_type],
2481 x, y, x, y + height);
2482 gdk_draw_line (window,
2483 style->dark_gc[state_type],
2484 x + width, y, x + width, y + height);
2488 if (style->ythickness > 0)
2490 if (style->ythickness > 1)
2492 thickness_light = 1;
2495 for (i = 0; i < thickness_dark; i++)
2497 gdk_draw_line (window, gc1,
2501 y + height - i - 1);
2503 gdk_draw_line (window, gc2,
2510 for (i = 0; i < thickness_light; i++)
2512 gdk_draw_line (window, gc1,
2513 x + thickness_dark + i,
2514 y + thickness_dark + i,
2515 x + width - thickness_dark - i - 1,
2516 y + thickness_dark + i);
2518 gdk_draw_line (window, gc2,
2519 x + thickness_dark + i,
2520 y + height - thickness_light - i - 1,
2521 x + width - thickness_light - 1,
2522 y + height - thickness_light - i - 1);
2527 gdk_draw_line (window,
2528 style->dark_gc[state_type],
2529 x, y, x + width, y);
2530 gdk_draw_line (window,
2531 style->dark_gc[state_type],
2532 x, y + height, x + width, y + height);
2540 gdk_gc_set_clip_rectangle (gc1, NULL);
2541 gdk_gc_set_clip_rectangle (gc2, NULL);
2542 if (shadow_type == GTK_SHADOW_IN ||
2543 shadow_type == GTK_SHADOW_OUT)
2545 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2546 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2552 gtk_default_draw_polygon (GtkStyle *style,
2554 GtkStateType state_type,
2555 GtkShadowType shadow_type,
2558 const gchar *detail,
2563 static const gdouble pi_over_4 = G_PI_4;
2564 static const gdouble pi_3_over_4 = G_PI_4 * 3;
2574 g_return_if_fail (GTK_IS_STYLE (style));
2575 g_return_if_fail (window != NULL);
2576 g_return_if_fail (points != NULL);
2578 switch (shadow_type)
2581 gc1 = style->bg_gc[state_type];
2582 gc2 = style->dark_gc[state_type];
2583 gc3 = style->light_gc[state_type];
2584 gc4 = style->black_gc;
2586 case GTK_SHADOW_ETCHED_IN:
2587 gc1 = style->light_gc[state_type];
2588 gc2 = style->dark_gc[state_type];
2589 gc3 = style->dark_gc[state_type];
2590 gc4 = style->light_gc[state_type];
2592 case GTK_SHADOW_OUT:
2593 gc1 = style->dark_gc[state_type];
2594 gc2 = style->light_gc[state_type];
2595 gc3 = style->black_gc;
2596 gc4 = style->bg_gc[state_type];
2598 case GTK_SHADOW_ETCHED_OUT:
2599 gc1 = style->dark_gc[state_type];
2600 gc2 = style->light_gc[state_type];
2601 gc3 = style->light_gc[state_type];
2602 gc4 = style->dark_gc[state_type];
2610 gdk_gc_set_clip_rectangle (gc1, area);
2611 gdk_gc_set_clip_rectangle (gc2, area);
2612 gdk_gc_set_clip_rectangle (gc3, area);
2613 gdk_gc_set_clip_rectangle (gc4, area);
2617 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, npoints);
2621 for (i = 0; i < npoints; i++)
2623 if ((points[i].x == points[i+1].x) &&
2624 (points[i].y == points[i+1].y))
2630 angle = atan2 (points[i+1].y - points[i].y,
2631 points[i+1].x - points[i].x);
2634 if ((angle > -pi_3_over_4) && (angle < pi_over_4))
2636 if (angle > -pi_over_4)
2647 gdk_draw_line (window, gc1,
2648 points[i].x-xadjust, points[i].y-yadjust,
2649 points[i+1].x-xadjust, points[i+1].y-yadjust);
2650 gdk_draw_line (window, gc3,
2651 points[i].x, points[i].y,
2652 points[i+1].x, points[i+1].y);
2656 if ((angle < -pi_3_over_4) || (angle > pi_3_over_4))
2667 gdk_draw_line (window, gc4,
2668 points[i].x+xadjust, points[i].y+yadjust,
2669 points[i+1].x+xadjust, points[i+1].y+yadjust);
2670 gdk_draw_line (window, gc2,
2671 points[i].x, points[i].y,
2672 points[i+1].x, points[i+1].y);
2678 gdk_gc_set_clip_rectangle (gc1, NULL);
2679 gdk_gc_set_clip_rectangle (gc2, NULL);
2680 gdk_gc_set_clip_rectangle (gc3, NULL);
2681 gdk_gc_set_clip_rectangle (gc4, NULL);
2686 draw_varrow (GdkWindow *window,
2688 GtkShadowType shadow_type,
2690 GtkArrowType arrow_type,
2697 gint y_start, y_increment;
2701 gdk_gc_set_clip_rectangle (gc, area);
2703 width = width + width % 2 - 1; /* Force odd */
2705 steps = 1 + width / 2;
2707 extra = height - steps;
2709 if (arrow_type == GTK_ARROW_DOWN)
2716 y_start = y + height - 1;
2720 for (i = 0; i < extra; i++)
2722 gdk_draw_line (window, gc,
2723 x, y_start + i * y_increment,
2724 x + width - 1, y_start + i * y_increment);
2726 for (; i < height; i++)
2728 gdk_draw_line (window, gc,
2729 x + (i - extra), y_start + i * y_increment,
2730 x + width - (i - extra) - 1, y_start + i * y_increment);
2735 gdk_gc_set_clip_rectangle (gc, NULL);
2739 draw_harrow (GdkWindow *window,
2741 GtkShadowType shadow_type,
2743 GtkArrowType arrow_type,
2750 gint x_start, x_increment;
2754 gdk_gc_set_clip_rectangle (gc, area);
2756 height = height + height % 2 - 1; /* Force odd */
2758 steps = 1 + height / 2;
2760 extra = width - steps;
2762 if (arrow_type == GTK_ARROW_RIGHT)
2769 x_start = x + width - 1;
2773 for (i = 0; i < extra; i++)
2775 gdk_draw_line (window, gc,
2776 x_start + i * x_increment, y,
2777 x_start + i * x_increment, y + height - 1);
2779 for (; i < width; i++)
2781 gdk_draw_line (window, gc,
2782 x_start + i * x_increment, y + (i - extra),
2783 x_start + i * x_increment, y + height - (i - extra) - 1);
2788 gdk_gc_set_clip_rectangle (gc, NULL);
2792 gtk_default_draw_arrow (GtkStyle *style,
2795 GtkShadowType shadow,
2798 const gchar *detail,
2799 GtkArrowType arrow_type,
2806 sanitize_size (window, &width, &height);
2808 if (detail && strcmp (detail, "spinbutton") == 0)
2811 int my_height = height;
2812 int my_width = width;
2815 if (my_height > my_width)
2817 vpad_add = (my_height - my_width) / 2;
2818 my_height = my_width;
2821 hpad = my_width / 4;
2826 vpad = 2 * hpad - 1;
2833 draw_varrow (window, style->fg_gc[state], shadow, area, arrow_type,
2834 x, y, my_width - hpad, my_height - vpad);
2836 else if (detail && strcmp (detail, "vscrollbar") == 0)
2838 gtk_paint_box (style, window, state, shadow, area,
2839 widget, detail, x, y, width, height);
2841 x += (width - 7) / 2;
2842 y += (height - 5) / 2;
2844 draw_varrow (window, style->fg_gc[state], shadow, area, arrow_type,
2847 else if (detail && strcmp (detail, "hscrollbar") == 0)
2849 gtk_paint_box (style, window, state, shadow, area,
2850 widget, detail, x, y, width, height);
2852 y += (height - 7) / 2;
2853 x += (width - 5) / 2;
2855 draw_harrow (window, style->fg_gc[state], shadow, area, arrow_type,
2860 if (arrow_type == GTK_ARROW_UP || arrow_type == GTK_ARROW_DOWN)
2862 x += (width - 7) / 2;
2863 y += (height - 5) / 2;
2865 draw_varrow (window, style->fg_gc[state], shadow, area, arrow_type,
2870 x += (width - 5) / 2;
2871 y += (height - 7) / 2;
2873 draw_harrow (window, style->fg_gc[state], shadow, area, arrow_type,
2880 gtk_default_draw_diamond (GtkStyle *style,
2882 GtkStateType state_type,
2883 GtkShadowType shadow_type,
2886 const gchar *detail,
2894 GdkGC *outer_nw = NULL;
2895 GdkGC *outer_ne = NULL;
2896 GdkGC *outer_sw = NULL;
2897 GdkGC *outer_se = NULL;
2898 GdkGC *middle_nw = NULL;
2899 GdkGC *middle_ne = NULL;
2900 GdkGC *middle_sw = NULL;
2901 GdkGC *middle_se = NULL;
2902 GdkGC *inner_nw = NULL;
2903 GdkGC *inner_ne = NULL;
2904 GdkGC *inner_sw = NULL;
2905 GdkGC *inner_se = NULL;
2907 g_return_if_fail (GTK_IS_STYLE (style));
2908 g_return_if_fail (window != NULL);
2910 sanitize_size (window, &width, &height);
2912 half_width = width / 2;
2913 half_height = height / 2;
2917 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
2918 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
2919 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
2920 gdk_gc_set_clip_rectangle (style->black_gc, area);
2923 switch (shadow_type)
2926 inner_sw = inner_se = style->bg_gc[state_type];
2927 middle_sw = middle_se = style->light_gc[state_type];
2928 outer_sw = outer_se = style->light_gc[state_type];
2929 inner_nw = inner_ne = style->black_gc;
2930 middle_nw = middle_ne = style->dark_gc[state_type];
2931 outer_nw = outer_ne = style->dark_gc[state_type];
2934 case GTK_SHADOW_OUT:
2935 inner_sw = inner_se = style->dark_gc[state_type];
2936 middle_sw = middle_se = style->dark_gc[state_type];
2937 outer_sw = outer_se = style->black_gc;
2938 inner_nw = inner_ne = style->bg_gc[state_type];
2939 middle_nw = middle_ne = style->light_gc[state_type];
2940 outer_nw = outer_ne = style->light_gc[state_type];
2943 case GTK_SHADOW_ETCHED_IN:
2944 inner_sw = inner_se = style->bg_gc[state_type];
2945 middle_sw = middle_se = style->dark_gc[state_type];
2946 outer_sw = outer_se = style->light_gc[state_type];
2947 inner_nw = inner_ne = style->bg_gc[state_type];
2948 middle_nw = middle_ne = style->light_gc[state_type];
2949 outer_nw = outer_ne = style->dark_gc[state_type];
2952 case GTK_SHADOW_ETCHED_OUT:
2953 inner_sw = inner_se = style->bg_gc[state_type];
2954 middle_sw = middle_se = style->light_gc[state_type];
2955 outer_sw = outer_se = style->dark_gc[state_type];
2956 inner_nw = inner_ne = style->bg_gc[state_type];
2957 middle_nw = middle_ne = style->dark_gc[state_type];
2958 outer_nw = outer_ne = style->light_gc[state_type];
2968 gdk_draw_line (window, inner_sw,
2969 x + 2, y + half_height,
2970 x + half_width, y + height - 2);
2971 gdk_draw_line (window, inner_se,
2972 x + half_width, y + height - 2,
2973 x + width - 2, y + half_height);
2974 gdk_draw_line (window, middle_sw,
2975 x + 1, y + half_height,
2976 x + half_width, y + height - 1);
2977 gdk_draw_line (window, middle_se,
2978 x + half_width, y + height - 1,
2979 x + width - 1, y + half_height);
2980 gdk_draw_line (window, outer_sw,
2982 x + half_width, y + height);
2983 gdk_draw_line (window, outer_se,
2984 x + half_width, y + height,
2985 x + width, y + half_height);
2987 gdk_draw_line (window, inner_nw,
2988 x + 2, y + half_height,
2989 x + half_width, y + 2);
2990 gdk_draw_line (window, inner_ne,
2991 x + half_width, y + 2,
2992 x + width - 2, y + half_height);
2993 gdk_draw_line (window, middle_nw,
2994 x + 1, y + half_height,
2995 x + half_width, y + 1);
2996 gdk_draw_line (window, middle_ne,
2997 x + half_width, y + 1,
2998 x + width - 1, y + half_height);
2999 gdk_draw_line (window, outer_nw,
3002 gdk_draw_line (window, outer_ne,
3004 x + width, y + half_height);
3009 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
3010 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
3011 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
3012 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
3017 gtk_default_draw_string (GtkStyle *style,
3019 GtkStateType state_type,
3022 const gchar *detail,
3025 const gchar *string)
3027 g_return_if_fail (GTK_IS_STYLE (style));
3028 g_return_if_fail (window != NULL);
3032 gdk_gc_set_clip_rectangle (style->white_gc, area);
3033 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], area);
3036 if (state_type == GTK_STATE_INSENSITIVE)
3037 gdk_draw_string (window, gtk_style_get_font (style), style->white_gc, x + 1, y + 1, string);
3039 gdk_draw_string (window, gtk_style_get_font (style), style->fg_gc[state_type], x, y, string);
3043 gdk_gc_set_clip_rectangle (style->white_gc, NULL);
3044 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], NULL);
3049 option_menu_get_props (GtkWidget *widget,
3050 GtkRequisition *indicator_size,
3051 GtkBorder *indicator_spacing)
3053 GtkRequisition *tmp_size = NULL;
3054 GtkBorder *tmp_spacing = NULL;
3057 gtk_widget_style_get (widget,
3058 "indicator_size", &tmp_size,
3059 "indicator_spacing", &tmp_spacing,
3064 *indicator_size = *tmp_size;
3068 *indicator_size = default_option_indicator_size;
3072 *indicator_spacing = *tmp_spacing;
3073 g_free (tmp_spacing);
3076 *indicator_spacing = default_option_indicator_spacing;
3080 gtk_default_draw_box (GtkStyle *style,
3082 GtkStateType state_type,
3083 GtkShadowType shadow_type,
3086 const gchar *detail,
3092 g_return_if_fail (GTK_IS_STYLE (style));
3093 g_return_if_fail (window != NULL);
3095 sanitize_size (window, &width, &height);
3097 if (!style->bg_pixmap[state_type] ||
3098 GDK_IS_PIXMAP (window))
3101 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
3103 gdk_draw_rectangle (window, style->bg_gc[state_type], TRUE,
3104 x, y, width, height);
3106 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
3109 gtk_style_apply_default_background (style, window,
3110 widget && !GTK_WIDGET_NO_WINDOW (widget),
3111 state_type, area, x, y, width, height);
3113 gtk_paint_shadow (style, window, state_type, shadow_type, area, widget, detail,
3114 x, y, width, height);
3116 if (detail && strcmp (detail, "optionmenu") == 0)
3118 GtkRequisition indicator_size;
3119 GtkBorder indicator_spacing;
3121 option_menu_get_props (widget, &indicator_size, &indicator_spacing);
3123 sanitize_size (window, &width, &height);
3125 gtk_paint_vline (style, window, state_type, area, widget,
3127 y + style->ythickness + 1,
3128 y + height - style->ythickness - 3,
3129 x + width - (indicator_size.width + indicator_spacing.left + indicator_spacing.right) - style->xthickness);
3134 get_darkened_gc (GdkWindow *window,
3138 GdkColor src = *color;
3142 gc = gdk_gc_new (window);
3144 while (darken_count)
3146 gtk_style_shade (&src, &shaded, 0.93);
3151 gdk_gc_set_rgb_fg_color (gc, &shaded);
3157 gtk_default_draw_flat_box (GtkStyle *style,
3159 GtkStateType state_type,
3160 GtkShadowType shadow_type,
3163 const gchar *detail,
3170 GdkGC *freeme = NULL;
3172 g_return_if_fail (GTK_IS_STYLE (style));
3173 g_return_if_fail (window != NULL);
3175 sanitize_size (window, &width, &height);
3179 if (state_type == GTK_STATE_SELECTED)
3181 if (!strcmp ("text", detail))
3182 gc1 = style->bg_gc[GTK_STATE_SELECTED];
3183 else if (!strncmp ("cell_even", detail, strlen ("cell_even")) ||
3184 !strncmp ("cell_odd", detail, strlen ("cell_odd")))
3186 /* This has to be really broken; alex made me do it. -jrb */
3187 if (GTK_WIDGET_HAS_FOCUS (widget))
3188 gc1 = style->base_gc[state_type];
3190 gc1 = style->base_gc[GTK_STATE_ACTIVE];
3194 gc1 = style->bg_gc[state_type];
3199 if (!strcmp ("viewportbin", detail))
3200 gc1 = style->bg_gc[GTK_STATE_NORMAL];
3201 else if (!strcmp ("entry_bg", detail))
3202 gc1 = style->base_gc[state_type];
3204 /* For trees: even rows are base color, odd rows are a shade of
3205 * the base color, the sort column is a shade of the original color
3209 /* FIXME when we have style properties, clean this up.
3212 else if (!strcmp ("cell_even", detail) ||
3213 !strcmp ("cell_odd", detail) ||
3214 !strcmp ("cell_even_ruled", detail))
3216 gc1 = style->base_gc[state_type];
3218 else if (!strcmp ("cell_even_sorted", detail) ||
3219 !strcmp ("cell_odd_sorted", detail) ||
3220 !strcmp ("cell_odd_ruled", detail) ||
3221 !strcmp ("cell_even_ruled_sorted", detail))
3223 freeme = get_darkened_gc (window, &style->base[state_type], 1);
3226 else if (!strcmp ("cell_odd_ruled_sorted", detail))
3228 freeme = get_darkened_gc (window, &style->base[state_type], 2);
3232 gc1 = style->bg_gc[state_type];
3236 gc1 = style->bg_gc[state_type];
3238 if (!style->bg_pixmap[state_type] || gc1 != style->bg_gc[state_type] ||
3239 GDK_IS_PIXMAP (window))
3242 gdk_gc_set_clip_rectangle (gc1, area);
3244 gdk_draw_rectangle (window, gc1, TRUE,
3245 x, y, width, height);
3247 if (detail && !strcmp ("tooltip", detail))
3248 gdk_draw_rectangle (window, style->black_gc, FALSE,
3249 x, y, width - 1, height - 1);
3252 gdk_gc_set_clip_rectangle (gc1, NULL);
3255 gtk_style_apply_default_background (style, window,
3256 widget && !GTK_WIDGET_NO_WINDOW (widget),
3257 state_type, area, x, y, width, height);
3261 g_object_unref (G_OBJECT (freeme));
3265 gtk_default_draw_check (GtkStyle *style,
3267 GtkStateType state_type,
3268 GtkShadowType shadow_type,
3271 const gchar *detail,
3277 if (detail && strcmp (detail, "cellcheck") == 0)
3279 gdk_draw_rectangle (window,
3280 widget->style->base_gc[state_type],
3284 gdk_draw_rectangle (window,
3285 widget->style->text_gc[state_type],
3290 x -= (1 + INDICATOR_PART_SIZE - width) / 2;
3291 y -= (((1 + INDICATOR_PART_SIZE - height) / 2) - 1);
3292 if (shadow_type == GTK_SHADOW_IN)
3294 draw_part (window, style->text_gc[state_type], area, x, y, CHECK_TEXT);
3295 draw_part (window, style->text_aa_gc[state_type], area, x, y, CHECK_AA);
3300 x -= (1 + INDICATOR_PART_SIZE - width) / 2;
3301 y -= (1 + INDICATOR_PART_SIZE - height) / 2;
3303 if (strcmp (detail, "check") == 0) /* Menu item */
3305 if (shadow_type == GTK_SHADOW_IN)
3307 draw_part (window, style->black_gc, area, x, y, CHECK_TEXT);
3308 draw_part (window, style->dark_gc[state_type], area, x, y, CHECK_AA);
3313 draw_part (window, style->black_gc, area, x, y, CHECK_BLACK);
3314 draw_part (window, style->dark_gc[state_type], area, x, y, CHECK_DARK);
3315 draw_part (window, style->mid_gc[state_type], area, x, y, CHECK_MID);
3316 draw_part (window, style->light_gc[state_type], area, x, y, CHECK_LIGHT);
3317 draw_part (window, style->base_gc[state_type], area, x, y, CHECK_BASE);
3319 if (shadow_type == GTK_SHADOW_IN)
3321 draw_part (window, style->text_gc[state_type], area, x, y, CHECK_TEXT);
3322 draw_part (window, style->text_aa_gc[state_type], area, x, y, CHECK_AA);
3330 gtk_default_draw_option (GtkStyle *style,
3332 GtkStateType state_type,
3333 GtkShadowType shadow_type,
3336 const gchar *detail,
3342 if (detail && strcmp (detail, "cellradio") == 0)
3344 gdk_draw_arc (window,
3345 widget->style->fg_gc[state_type],
3352 if (shadow_type == GTK_SHADOW_IN)
3354 gdk_draw_arc (window,
3355 widget->style->fg_gc[state_type],
3366 x -= (1 + INDICATOR_PART_SIZE - width) / 2;
3367 y -= (1 + INDICATOR_PART_SIZE - height) / 2;
3369 if (strcmp (detail, "option") == 0) /* Menu item */
3371 if (shadow_type == GTK_SHADOW_IN)
3372 draw_part (window, style->fg_gc[state_type], area, x, y, RADIO_TEXT);
3376 draw_part (window, style->black_gc, area, x, y, RADIO_BLACK);
3377 draw_part (window, style->dark_gc[state_type], area, x, y, RADIO_DARK);
3378 draw_part (window, style->mid_gc[state_type], area, x, y, RADIO_MID);
3379 draw_part (window, style->light_gc[state_type], area, x, y, RADIO_LIGHT);
3380 draw_part (window, style->base_gc[state_type], area, x, y, RADIO_BASE);
3382 if (shadow_type == GTK_SHADOW_IN)
3383 draw_part (window, style->text_gc[state_type], area, x, y, RADIO_TEXT);
3389 gtk_default_draw_tab (GtkStyle *style,
3391 GtkStateType state_type,
3392 GtkShadowType shadow_type,
3395 const gchar *detail,
3401 GtkRequisition indicator_size;
3402 GtkBorder indicator_spacing;
3404 option_menu_get_props (widget, &indicator_size, &indicator_spacing);
3406 x += (width - indicator_size.width) / 2;
3407 y += (height - indicator_size.height) / 2 - 1;
3409 draw_varrow (window, style->black_gc, shadow_type, area, GTK_ARROW_UP,
3410 x, y, indicator_size.width, 5);
3411 draw_varrow (window, style->black_gc, shadow_type, area, GTK_ARROW_DOWN,
3412 x, y + 8, indicator_size.width, 5);
3416 gtk_default_draw_shadow_gap (GtkStyle *style,
3418 GtkStateType state_type,
3419 GtkShadowType shadow_type,
3422 const gchar *detail,
3427 GtkPositionType gap_side,
3436 g_return_if_fail (GTK_IS_STYLE (style));
3437 g_return_if_fail (window != NULL);
3439 sanitize_size (window, &width, &height);
3441 switch (shadow_type)
3443 case GTK_SHADOW_NONE:
3446 gc1 = style->dark_gc[state_type];
3447 gc2 = style->black_gc;
3448 gc3 = style->bg_gc[state_type];
3449 gc4 = style->light_gc[state_type];
3451 case GTK_SHADOW_ETCHED_IN:
3452 gc1 = style->dark_gc[state_type];
3453 gc2 = style->light_gc[state_type];
3454 gc3 = style->dark_gc[state_type];
3455 gc4 = style->light_gc[state_type];
3457 case GTK_SHADOW_OUT:
3458 gc1 = style->light_gc[state_type];
3459 gc2 = style->bg_gc[state_type];
3460 gc3 = style->dark_gc[state_type];
3461 gc4 = style->black_gc;
3463 case GTK_SHADOW_ETCHED_OUT:
3464 gc1 = style->light_gc[state_type];
3465 gc2 = style->dark_gc[state_type];
3466 gc3 = style->light_gc[state_type];
3467 gc4 = style->dark_gc[state_type];
3472 gdk_gc_set_clip_rectangle (gc1, area);
3473 gdk_gc_set_clip_rectangle (gc2, area);
3474 gdk_gc_set_clip_rectangle (gc3, area);
3475 gdk_gc_set_clip_rectangle (gc4, area);
3478 switch (shadow_type)
3480 case GTK_SHADOW_NONE:
3482 case GTK_SHADOW_OUT:
3483 case GTK_SHADOW_ETCHED_IN:
3484 case GTK_SHADOW_ETCHED_OUT:
3488 gdk_draw_line (window, gc1,
3489 x, y, x, y + height - 1);
3490 gdk_draw_line (window, gc2,
3491 x + 1, y, x + 1, y + height - 2);
3493 gdk_draw_line (window, gc3,
3494 x + 1, y + height - 2, x + width - 2, y + height - 2);
3495 gdk_draw_line (window, gc3,
3496 x + width - 2, y, x + width - 2, y + height - 2);
3497 gdk_draw_line (window, gc4,
3498 x, y + height - 1, x + width - 1, y + height - 1);
3499 gdk_draw_line (window, gc4,
3500 x + width - 1, y, x + width - 1, y + height - 1);
3503 gdk_draw_line (window, gc1,
3504 x, y, x + gap_x - 1, y);
3505 gdk_draw_line (window, gc2,
3506 x + 1, y + 1, x + gap_x - 1, y + 1);
3507 gdk_draw_line (window, gc2,
3508 x + gap_x, y, x + gap_x, y);
3510 if ((width - (gap_x + gap_width)) > 0)
3512 gdk_draw_line (window, gc1,
3513 x + gap_x + gap_width, y, x + width - 2, y);
3514 gdk_draw_line (window, gc2,
3515 x + gap_x + gap_width, y + 1, x + width - 3, y + 1);
3516 gdk_draw_line (window, gc2,
3517 x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
3520 case GTK_POS_BOTTOM:
3521 gdk_draw_line (window, gc1,
3522 x, y, x + width - 1, y);
3523 gdk_draw_line (window, gc1,
3524 x, y, x, y + height - 1);
3525 gdk_draw_line (window, gc2,
3526 x + 1, y + 1, x + width - 2, y + 1);
3527 gdk_draw_line (window, gc2,
3528 x + 1, y + 1, x + 1, y + height - 1);
3530 gdk_draw_line (window, gc3,
3531 x + width - 2, y + 1, x + width - 2, y + height - 1);
3532 gdk_draw_line (window, gc4,
3533 x + width - 1, y, x + width - 1, y + height - 1);
3536 gdk_draw_line (window, gc4,
3537 x, y + height - 1, x + gap_x - 1, y + height - 1);
3538 gdk_draw_line (window, gc3,
3539 x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
3540 gdk_draw_line (window, gc3,
3541 x + gap_x, y + height - 1, x + gap_x, y + height - 1);
3543 if ((width - (gap_x + gap_width)) > 0)
3545 gdk_draw_line (window, gc4,
3546 x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
3547 gdk_draw_line (window, gc3,
3548 x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
3549 gdk_draw_line (window, gc3,
3550 x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
3554 gdk_draw_line (window, gc1,
3555 x, y, x + width - 1, y);
3556 gdk_draw_line (window, gc2,
3557 x, y + 1, x + width - 2, y + 1);
3559 gdk_draw_line (window, gc3,
3560 x, y + height - 2, x + width - 2, y + height - 2);
3561 gdk_draw_line (window, gc3,
3562 x + width - 2, y + 1, x + width - 2, y + height - 2);
3563 gdk_draw_line (window, gc4,
3564 x, y + height - 1, x + width - 1, y + height - 1);
3565 gdk_draw_line (window, gc4,
3566 x + width - 1, y, x + width - 1, y + height - 1);
3569 gdk_draw_line (window, gc1,
3570 x, y, x, y + gap_x - 1);
3571 gdk_draw_line (window, gc2,
3572 x + 1, y + 1, x + 1, y + gap_x - 1);
3573 gdk_draw_line (window, gc2,
3574 x, y + gap_x, x, y + gap_x);
3576 if ((width - (gap_x + gap_width)) > 0)
3578 gdk_draw_line (window, gc1,
3579 x, y + gap_x + gap_width, x, y + height - 2);
3580 gdk_draw_line (window, gc2,
3581 x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
3582 gdk_draw_line (window, gc2,
3583 x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
3587 gdk_draw_line (window, gc1,
3588 x, y, x + width - 1, y);
3589 gdk_draw_line (window, gc1,
3590 x, y, x, y + height - 1);
3591 gdk_draw_line (window, gc2,
3592 x + 1, y + 1, x + width - 1, y + 1);
3593 gdk_draw_line (window, gc2,
3594 x + 1, y + 1, x + 1, y + height - 2);
3596 gdk_draw_line (window, gc3,
3597 x + 1, y + height - 2, x + width - 1, y + height - 2);
3598 gdk_draw_line (window, gc4,
3599 x, y + height - 1, x + width - 1, y + height - 1);
3602 gdk_draw_line (window, gc4,
3603 x + width - 1, y, x + width - 1, y + gap_x - 1);
3604 gdk_draw_line (window, gc3,
3605 x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
3606 gdk_draw_line (window, gc3,
3607 x + width - 1, y + gap_x, x + width - 1, y + gap_x);
3609 if ((width - (gap_x + gap_width)) > 0)
3611 gdk_draw_line (window, gc4,
3612 x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
3613 gdk_draw_line (window, gc3,
3614 x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
3615 gdk_draw_line (window, gc3,
3616 x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
3624 gdk_gc_set_clip_rectangle (gc1, NULL);
3625 gdk_gc_set_clip_rectangle (gc2, NULL);
3626 gdk_gc_set_clip_rectangle (gc3, NULL);
3627 gdk_gc_set_clip_rectangle (gc4, NULL);
3632 gtk_default_draw_box_gap (GtkStyle *style,
3634 GtkStateType state_type,
3635 GtkShadowType shadow_type,
3638 const gchar *detail,
3643 GtkPositionType gap_side,
3652 g_return_if_fail (GTK_IS_STYLE (style));
3653 g_return_if_fail (window != NULL);
3655 gtk_style_apply_default_background (style, window,
3656 widget && !GTK_WIDGET_NO_WINDOW (widget),
3657 state_type, area, x, y, width, height);
3659 sanitize_size (window, &width, &height);
3661 switch (shadow_type)
3663 case GTK_SHADOW_NONE:
3666 gc1 = style->dark_gc[state_type];
3667 gc2 = style->black_gc;
3668 gc3 = style->bg_gc[state_type];
3669 gc4 = style->light_gc[state_type];
3671 case GTK_SHADOW_ETCHED_IN:
3672 gc1 = style->dark_gc[state_type];
3673 gc2 = style->light_gc[state_type];
3674 gc3 = style->dark_gc[state_type];
3675 gc4 = style->light_gc[state_type];
3677 case GTK_SHADOW_OUT:
3678 gc1 = style->light_gc[state_type];
3679 gc2 = style->bg_gc[state_type];
3680 gc3 = style->dark_gc[state_type];
3681 gc4 = style->black_gc;
3683 case GTK_SHADOW_ETCHED_OUT:
3684 gc1 = style->light_gc[state_type];
3685 gc2 = style->dark_gc[state_type];
3686 gc3 = style->light_gc[state_type];
3687 gc4 = style->dark_gc[state_type];
3693 gdk_gc_set_clip_rectangle (gc1, area);
3694 gdk_gc_set_clip_rectangle (gc2, area);
3695 gdk_gc_set_clip_rectangle (gc3, area);
3696 gdk_gc_set_clip_rectangle (gc4, area);
3699 switch (shadow_type)
3701 case GTK_SHADOW_NONE:
3703 case GTK_SHADOW_OUT:
3704 case GTK_SHADOW_ETCHED_IN:
3705 case GTK_SHADOW_ETCHED_OUT:
3709 gdk_draw_line (window, gc1,
3710 x, y, x, y + height - 1);
3711 gdk_draw_line (window, gc2,
3712 x + 1, y, x + 1, y + height - 2);
3714 gdk_draw_line (window, gc3,
3715 x + 1, y + height - 2, x + width - 2, y + height - 2);
3716 gdk_draw_line (window, gc3,
3717 x + width - 2, y, x + width - 2, y + height - 2);
3718 gdk_draw_line (window, gc4,
3719 x, y + height - 1, x + width - 1, y + height - 1);
3720 gdk_draw_line (window, gc4,
3721 x + width - 1, y, x + width - 1, y + height - 1);
3724 gdk_draw_line (window, gc1,
3725 x, y, x + gap_x - 1, y);
3726 gdk_draw_line (window, gc2,
3727 x + 1, y + 1, x + gap_x - 1, y + 1);
3728 gdk_draw_line (window, gc2,
3729 x + gap_x, y, x + gap_x, y);
3731 if ((width - (gap_x + gap_width)) > 0)
3733 gdk_draw_line (window, gc1,
3734 x + gap_x + gap_width, y, x + width - 2, y);
3735 gdk_draw_line (window, gc2,
3736 x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
3737 gdk_draw_line (window, gc2,
3738 x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
3741 case GTK_POS_BOTTOM:
3742 gdk_draw_line (window, gc1,
3743 x, y, x + width - 1, y);
3744 gdk_draw_line (window, gc1,
3745 x, y, x, y + height - 1);
3746 gdk_draw_line (window, gc2,
3747 x + 1, y + 1, x + width - 2, y + 1);
3748 gdk_draw_line (window, gc2,
3749 x + 1, y + 1, x + 1, y + height - 1);
3751 gdk_draw_line (window, gc3,
3752 x + width - 2, y + 1, x + width - 2, y + height - 1);
3753 gdk_draw_line (window, gc4,
3754 x + width - 1, y, x + width - 1, y + height - 1);
3757 gdk_draw_line (window, gc4,
3758 x, y + height - 1, x + gap_x - 1, y + height - 1);
3759 gdk_draw_line (window, gc3,
3760 x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
3761 gdk_draw_line (window, gc3,
3762 x + gap_x, y + height - 1, x + gap_x, y + height - 1);
3764 if ((width - (gap_x + gap_width)) > 0)
3766 gdk_draw_line (window, gc4,
3767 x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
3768 gdk_draw_line (window, gc3,
3769 x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
3770 gdk_draw_line (window, gc3,
3771 x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
3775 gdk_draw_line (window, gc1,
3776 x, y, x + width - 1, y);
3777 gdk_draw_line (window, gc2,
3778 x, y + 1, x + width - 2, y + 1);
3780 gdk_draw_line (window, gc3,
3781 x, y + height - 2, x + width - 2, y + height - 2);
3782 gdk_draw_line (window, gc3,
3783 x + width - 2, y + 1, x + width - 2, y + height - 2);
3784 gdk_draw_line (window, gc4,
3785 x, y + height - 1, x + width - 1, y + height - 1);
3786 gdk_draw_line (window, gc4,
3787 x + width - 1, y, x + width - 1, y + height - 1);
3790 gdk_draw_line (window, gc1,
3791 x, y, x, y + gap_x - 1);
3792 gdk_draw_line (window, gc2,
3793 x + 1, y + 1, x + 1, y + gap_x - 1);
3794 gdk_draw_line (window, gc2,
3795 x, y + gap_x, x, y + gap_x);
3797 if ((width - (gap_x + gap_width)) > 0)
3799 gdk_draw_line (window, gc1,
3800 x, y + gap_x + gap_width, x, y + height - 2);
3801 gdk_draw_line (window, gc2,
3802 x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
3803 gdk_draw_line (window, gc2,
3804 x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
3808 gdk_draw_line (window, gc1,
3809 x, y, x + width - 1, y);
3810 gdk_draw_line (window, gc1,
3811 x, y, x, y + height - 1);
3812 gdk_draw_line (window, gc2,
3813 x + 1, y + 1, x + width - 1, y + 1);
3814 gdk_draw_line (window, gc2,
3815 x + 1, y + 1, x + 1, y + height - 2);
3817 gdk_draw_line (window, gc3,
3818 x + 1, y + height - 2, x + width - 1, y + height - 2);
3819 gdk_draw_line (window, gc4,
3820 x, y + height - 1, x + width - 1, y + height - 1);
3823 gdk_draw_line (window, gc4,
3824 x + width - 1, y, x + width - 1, y + gap_x - 1);
3825 gdk_draw_line (window, gc3,
3826 x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
3827 gdk_draw_line (window, gc3,
3828 x + width - 1, y + gap_x, x + width - 1, y + gap_x);
3830 if ((width - (gap_x + gap_width)) > 0)
3832 gdk_draw_line (window, gc4,
3833 x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
3834 gdk_draw_line (window, gc3,
3835 x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
3836 gdk_draw_line (window, gc3,
3837 x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
3845 gdk_gc_set_clip_rectangle (gc1, NULL);
3846 gdk_gc_set_clip_rectangle (gc2, NULL);
3847 gdk_gc_set_clip_rectangle (gc3, NULL);
3848 gdk_gc_set_clip_rectangle (gc4, NULL);
3853 gtk_default_draw_extension (GtkStyle *style,
3855 GtkStateType state_type,
3856 GtkShadowType shadow_type,
3859 const gchar *detail,
3864 GtkPositionType gap_side)
3871 g_return_if_fail (GTK_IS_STYLE (style));
3872 g_return_if_fail (window != NULL);
3874 gtk_style_apply_default_background (style, window,
3875 widget && !GTK_WIDGET_NO_WINDOW (widget),
3876 GTK_STATE_NORMAL, area, x, y, width, height);
3878 sanitize_size (window, &width, &height);
3880 switch (shadow_type)
3882 case GTK_SHADOW_NONE:
3885 gc1 = style->dark_gc[state_type];
3886 gc2 = style->black_gc;
3887 gc3 = style->bg_gc[state_type];
3888 gc4 = style->light_gc[state_type];
3890 case GTK_SHADOW_ETCHED_IN:
3891 gc1 = style->dark_gc[state_type];
3892 gc2 = style->light_gc[state_type];
3893 gc3 = style->dark_gc[state_type];
3894 gc4 = style->light_gc[state_type];
3896 case GTK_SHADOW_OUT:
3897 gc1 = style->light_gc[state_type];
3898 gc2 = style->bg_gc[state_type];
3899 gc3 = style->dark_gc[state_type];
3900 gc4 = style->black_gc;
3902 case GTK_SHADOW_ETCHED_OUT:
3903 gc1 = style->light_gc[state_type];
3904 gc2 = style->dark_gc[state_type];
3905 gc3 = style->light_gc[state_type];
3906 gc4 = style->dark_gc[state_type];
3912 gdk_gc_set_clip_rectangle (gc1, area);
3913 gdk_gc_set_clip_rectangle (gc2, area);
3914 gdk_gc_set_clip_rectangle (gc3, area);
3915 gdk_gc_set_clip_rectangle (gc4, area);
3918 switch (shadow_type)
3920 case GTK_SHADOW_NONE:
3922 case GTK_SHADOW_OUT:
3923 case GTK_SHADOW_ETCHED_IN:
3924 case GTK_SHADOW_ETCHED_OUT:
3928 gtk_style_apply_default_background (style, window,
3929 widget && !GTK_WIDGET_NO_WINDOW (widget),
3931 x + style->xthickness,
3933 width - (2 * style->xthickness),
3934 height - (style->ythickness));
3935 gdk_draw_line (window, gc1,
3936 x, y, x, y + height - 2);
3937 gdk_draw_line (window, gc2,
3938 x + 1, y, x + 1, y + height - 2);
3940 gdk_draw_line (window, gc3,
3941 x + 2, y + height - 2, x + width - 2, y + height - 2);
3942 gdk_draw_line (window, gc3,
3943 x + width - 2, y, x + width - 2, y + height - 2);
3944 gdk_draw_line (window, gc4,
3945 x + 1, y + height - 1, x + width - 2, y + height - 1);
3946 gdk_draw_line (window, gc4,
3947 x + width - 1, y, x + width - 1, y + height - 2);
3949 case GTK_POS_BOTTOM:
3950 gtk_style_apply_default_background (style, window,
3951 widget && !GTK_WIDGET_NO_WINDOW (widget),
3953 x + style->xthickness,
3954 y + style->ythickness,
3955 width - (2 * style->xthickness),
3956 height - (style->ythickness));
3957 gdk_draw_line (window, gc1,
3958 x + 1, y, x + width - 2, y);
3959 gdk_draw_line (window, gc1,
3960 x, y + 1, x, y + height - 1);
3961 gdk_draw_line (window, gc2,
3962 x + 1, y + 1, x + width - 2, y + 1);
3963 gdk_draw_line (window, gc2,
3964 x + 1, y + 1, x + 1, y + height - 1);
3966 gdk_draw_line (window, gc3,
3967 x + width - 2, y + 2, x + width - 2, y + height - 1);
3968 gdk_draw_line (window, gc4,
3969 x + width - 1, y + 1, x + width - 1, y + height - 1);
3972 gtk_style_apply_default_background (style, window,
3973 widget && !GTK_WIDGET_NO_WINDOW (widget),
3976 y + style->ythickness,
3977 width - (style->xthickness),
3978 height - (2 * style->ythickness));
3979 gdk_draw_line (window, gc1,
3980 x, y, x + width - 2, y);
3981 gdk_draw_line (window, gc2,
3982 x + 1, y + 1, x + width - 2, y + 1);
3984 gdk_draw_line (window, gc3,
3985 x, y + height - 2, x + width - 2, y + height - 2);
3986 gdk_draw_line (window, gc3,
3987 x + width - 2, y + 2, x + width - 2, y + height - 2);
3988 gdk_draw_line (window, gc4,
3989 x, y + height - 1, x + width - 2, y + height - 1);
3990 gdk_draw_line (window, gc4,
3991 x + width - 1, y + 1, x + width - 1, y + height - 2);
3994 gtk_style_apply_default_background (style, window,
3995 widget && !GTK_WIDGET_NO_WINDOW (widget),
3997 x + style->xthickness,
3998 y + style->ythickness,
3999 width - (style->xthickness),
4000 height - (2 * style->ythickness));
4001 gdk_draw_line (window, gc1,
4002 x + 1, y, x + width - 1, y);
4003 gdk_draw_line (window, gc1,
4004 x, y + 1, x, y + height - 2);
4005 gdk_draw_line (window, gc2,
4006 x + 1, y + 1, x + width - 1, y + 1);
4007 gdk_draw_line (window, gc2,
4008 x + 1, y + 1, x + 1, y + height - 2);
4010 gdk_draw_line (window, gc3,
4011 x + 2, y + height - 2, x + width - 1, y + height - 2);
4012 gdk_draw_line (window, gc4,
4013 x + 1, y + height - 1, x + width - 1, y + height - 1);
4020 gdk_gc_set_clip_rectangle (gc1, NULL);
4021 gdk_gc_set_clip_rectangle (gc2, NULL);
4022 gdk_gc_set_clip_rectangle (gc3, NULL);
4023 gdk_gc_set_clip_rectangle (gc4, NULL);
4028 gtk_default_draw_focus (GtkStyle *style,
4030 GtkStateType state_type,
4033 const gchar *detail,
4041 gboolean free_dash_list = FALSE;
4042 gint line_width = 1;
4043 gchar *dash_list = "\1\1";
4046 gc = style->fg_gc[state_type];
4050 gtk_widget_style_get (widget,
4051 "focus-line-width", &line_width,
4052 "focus-line-pattern", (gchar *)&dash_list,
4055 free_dash_list = TRUE;
4058 sanitize_size (window, &width, &height);
4061 gdk_gc_set_clip_rectangle (gc, area);
4063 gdk_gc_set_line_attributes (gc, line_width,
4064 dash_list[0] ? GDK_LINE_ON_OFF_DASH : GDK_LINE_SOLID,
4065 GDK_CAP_BUTT, GDK_JOIN_MITER);
4068 if (detail && !strcmp (detail, "add-mode"))
4074 free_dash_list = FALSE;
4077 points[0].x = x + line_width / 2;
4078 points[0].y = y + line_width / 2;
4079 points[1].x = x + width - line_width + line_width / 2;
4080 points[1].y = y + line_width / 2;
4081 points[2].x = x + width - line_width + line_width / 2;
4082 points[2].y = y + height - line_width + line_width / 2;
4083 points[3].x = x + line_width / 2;
4084 points[3].y = y + height - line_width + line_width / 2;
4085 points[4] = points[0];
4089 gdk_draw_lines (window, gc, points, 5);
4093 /* We go through all the pain below because the X rasterization
4094 * rules don't really work right for dashed lines if you
4095 * want continuity in segments that go between top/right
4096 * and left/bottom. For instance, a top left corner
4097 * with a 1-1 dash is drawn as:
4104 * This is because pixels on the top and left boundaries
4105 * of polygons are drawn, but not on the bottom and right.
4106 * So, if you have a line going up that turns the corner
4107 * and goes right, there is a one pixel shift in the pattern.
4109 * So, to fix this, we drawn the top and right in one call,
4110 * then the left and bottom in another call, fixing up
4111 * the dash offset for the second call ourselves to get
4112 * continuity at the upper left.
4114 * It's not perfect since we really should have a join at
4115 * the upper left and lower right instead of two intersecting
4116 * lines but that's only really apparent for no-dashes,
4117 * which (for this reason) are done as one polygon and
4118 * don't to through this code path.
4121 dash_len = strlen (dash_list);
4124 gdk_gc_set_dashes (gc, 0, dash_list, dash_len);
4126 gdk_draw_lines (window, gc, points, 3);
4128 /* We draw this line one farther over than it is "supposed" to
4129 * because of another rasterization problem ... if two 1 pixel
4130 * unjoined lines meet at the lower right, there will be a missing
4137 gint dash_pixels = 0;
4140 /* Adjust the dash offset for the bottom and left so we
4141 * match up at the upper left.
4143 for (i = 0; i < dash_len; i++)
4144 dash_pixels += dash_list[i];
4146 if (dash_len % 2 == 1)
4149 gdk_gc_set_dashes (gc, dash_pixels - (width + height - 2 * line_width) % dash_pixels, dash_list, dash_len);
4152 gdk_draw_lines (window, gc, points + 2, 3);
4155 gdk_gc_set_line_attributes (gc, 0, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
4158 gdk_gc_set_clip_rectangle (gc, NULL);
4165 gtk_default_draw_slider (GtkStyle *style,
4167 GtkStateType state_type,
4168 GtkShadowType shadow_type,
4171 const gchar *detail,
4176 GtkOrientation orientation)
4178 g_return_if_fail (GTK_IS_STYLE (style));
4179 g_return_if_fail (window != NULL);
4181 sanitize_size (window, &width, &height);
4183 gtk_paint_box (style, window, state_type, shadow_type,
4184 area, widget, detail, x, y, width, height);
4187 (strcmp ("hscale", detail) == 0 ||
4188 strcmp ("vscale", detail) == 0))
4190 if (orientation == GTK_ORIENTATION_HORIZONTAL)
4191 gtk_paint_vline (style, window, state_type, area, widget, detail,
4192 y + style->ythickness,
4193 y + height - style->ythickness - 1, x + width / 2);
4195 gtk_paint_hline (style, window, state_type, area, widget, detail,
4196 x + style->xthickness,
4197 x + width - style->xthickness - 1, y + height / 2);
4202 draw_dot (GdkWindow *window,
4210 size = CLAMP (size, 2, 3);
4214 gdk_draw_point (window, light_gc, x, y);
4215 gdk_draw_point (window, light_gc, x+1, y+1);
4217 else if (size == 3);
4219 gdk_draw_point (window, light_gc, x, y);
4220 gdk_draw_point (window, light_gc, x+1, y);
4221 gdk_draw_point (window, light_gc, x, y+1);
4222 gdk_draw_point (window, dark_gc, x+1, y+2);
4223 gdk_draw_point (window, dark_gc, x+2, y+1);
4224 gdk_draw_point (window, dark_gc, x+2, y+2);
4229 gtk_default_draw_handle (GtkStyle *style,
4231 GtkStateType state_type,
4232 GtkShadowType shadow_type,
4235 const gchar *detail,
4240 GtkOrientation orientation)
4243 gint xthick, ythick;
4244 GdkGC *light_gc, *dark_gc;
4249 g_return_if_fail (GTK_IS_STYLE (style));
4250 g_return_if_fail (window != NULL);
4252 sanitize_size (window, &width, &height);
4254 gtk_paint_box (style, window, state_type, shadow_type, area, widget,
4255 detail, x, y, width, height);
4258 if (!strcmp (detail, "paned"))
4260 /* we want to ignore the shadow border in paned widgets */
4264 light_gc = style->light_gc[state_type];
4265 dark_gc = style->black_gc;
4269 xthick = style->xthickness;
4270 ythick = style->ythickness;
4272 light_gc = style->light_gc[state_type];
4273 dark_gc = style->dark_gc[state_type];
4276 rect.x = x + xthick;
4277 rect.y = y + ythick;
4278 rect.width = width - (xthick * 2);
4279 rect.height = height - (ythick * 2);
4282 intersect = gdk_rectangle_intersect (area, &rect, &dest);
4292 gdk_gc_set_clip_rectangle (light_gc, &dest);
4293 gdk_gc_set_clip_rectangle (dark_gc, &dest);
4295 if (!strcmp (detail, "paned"))
4297 if (orientation == GTK_ORIENTATION_HORIZONTAL)
4298 for (xx = x + width/2 - 15; xx <= x + width/2 + 15; xx += 5)
4299 draw_dot (window, light_gc, dark_gc, xx, y + height/2 - 1, 3);
4301 for (yy = y + height/2 - 15; yy <= y + height/2 + 15; yy += 5)
4302 draw_dot (window, light_gc, dark_gc, x + width/2 - 1, yy, 3);
4306 for (yy = y + ythick; yy < (y + height - ythick); yy += 3)
4307 for (xx = x + xthick; xx < (x + width - xthick); xx += 6)
4309 draw_dot (window, light_gc, dark_gc, xx, yy, 2);
4310 draw_dot (window, light_gc, dark_gc, xx + 3, yy + 1, 2);
4314 gdk_gc_set_clip_rectangle (light_gc, NULL);
4315 gdk_gc_set_clip_rectangle (dark_gc, NULL);
4319 create_expander_affine (gdouble affine[6],
4329 width = expander_size / 4.0;
4330 height = expander_size / 2.0;
4332 s = sin (degrees * G_PI / 180.0);
4333 c = cos (degrees * G_PI / 180.0);
4339 affine[4] = -width * c - height * -s + x;
4340 affine[5] = -width * s - height * c + y;
4344 apply_affine_on_point (double affine[6], GdkPoint *point)
4348 x = point->x * affine[0] + point->y * affine[2] + affine[4];
4349 y = point->x * affine[1] + point->y * affine[3] + affine[5];
4356 gtk_default_draw_expander (GtkStyle *style,
4358 GtkStateType state_type,
4361 const gchar *detail,
4364 GtkExpanderStyle expander_style)
4372 gtk_widget_style_get (widget,
4373 "expander_size", &expander_size,
4378 gdk_gc_set_clip_rectangle (style->fg_gc[GTK_STATE_NORMAL], area);
4379 gdk_gc_set_clip_rectangle (style->base_gc[GTK_STATE_NORMAL], area);
4384 points[1].x = expander_size / 2;
4385 points[1].y = expander_size / 2;
4387 points[2].y = expander_size;
4389 switch (expander_style)
4391 case GTK_EXPANDER_COLLAPSED:
4394 case GTK_EXPANDER_SEMI_COLLAPSED:
4397 case GTK_EXPANDER_SEMI_EXPANDED:
4400 case GTK_EXPANDER_EXPANDED:
4404 g_assert_not_reached ();
4407 create_expander_affine (affine, degrees, expander_size, x, y);
4409 for (i = 0; i < 3; i++)
4410 apply_affine_on_point (affine, &points[i]);
4412 if (state_type == GTK_STATE_PRELIGHT)
4414 gdk_draw_polygon (window, style->fg_gc[GTK_STATE_NORMAL],
4417 else if (state_type == GTK_STATE_ACTIVE)
4419 gdk_draw_polygon (window, style->light_gc[GTK_STATE_ACTIVE],
4421 gdk_draw_polygon (window, style->fg_gc[GTK_STATE_NORMAL],
4426 gdk_draw_polygon (window, style->base_gc[GTK_STATE_NORMAL],
4428 gdk_draw_polygon (window, style->fg_gc[GTK_STATE_NORMAL],
4433 gdk_gc_set_clip_rectangle (style->fg_gc[GTK_STATE_NORMAL], NULL);
4434 gdk_gc_set_clip_rectangle (style->base_gc[GTK_STATE_NORMAL], NULL);
4438 typedef struct _ByteRange ByteRange;
4447 range_new (guint start,
4450 ByteRange *br = g_new (ByteRange, 1);
4459 get_insensitive_layout (PangoLayout *layout)
4461 GSList *embossed_ranges = NULL;
4462 GSList *stippled_ranges = NULL;
4463 PangoLayoutIter *iter;
4464 GSList *tmp_list = NULL;
4465 PangoLayout *new_layout;
4466 PangoAttrList *attrs;
4467 GdkBitmap *stipple = NULL;
4469 iter = pango_layout_get_iter (layout);
4473 PangoLayoutRun *run;
4474 PangoAttribute *attr;
4475 gboolean need_stipple = FALSE;
4478 run = pango_layout_iter_get_run (iter);
4482 tmp_list = run->item->analysis.extra_attrs;
4484 while (tmp_list != NULL)
4486 attr = tmp_list->data;
4487 switch (attr->klass->type)
4489 case PANGO_ATTR_FOREGROUND:
4490 case PANGO_ATTR_BACKGROUND:
4491 need_stipple = TRUE;
4501 tmp_list = g_slist_next (tmp_list);
4504 br = range_new (run->item->offset, run->item->offset + run->item->length);
4507 stippled_ranges = g_slist_prepend (stippled_ranges, br);
4509 embossed_ranges = g_slist_prepend (embossed_ranges, br);
4512 while (pango_layout_iter_next_run (iter));
4514 pango_layout_iter_free (iter);
4516 new_layout = pango_layout_copy (layout);
4518 attrs = pango_layout_get_attributes (new_layout);
4522 /* Create attr list if there wasn't one */
4523 attrs = pango_attr_list_new ();
4524 pango_layout_set_attributes (new_layout, attrs);
4525 pango_attr_list_unref (attrs);
4528 tmp_list = embossed_ranges;
4529 while (tmp_list != NULL)
4531 PangoAttribute *attr;
4532 ByteRange *br = tmp_list->data;
4534 attr = gdk_pango_attr_embossed_new (TRUE);
4536 attr->start_index = br->start;
4537 attr->end_index = br->end;
4539 pango_attr_list_change (attrs, attr);
4543 tmp_list = g_slist_next (tmp_list);
4546 g_slist_free (embossed_ranges);
4548 tmp_list = stippled_ranges;
4549 while (tmp_list != NULL)
4551 PangoAttribute *attr;
4552 ByteRange *br = tmp_list->data;
4554 if (stipple == NULL)
4556 #define gray50_width 2
4557 #define gray50_height 2
4558 static char gray50_bits[] = {
4562 stipple = gdk_bitmap_create_from_data (NULL,
4563 gray50_bits, gray50_width,
4567 attr = gdk_pango_attr_stipple_new (stipple);
4569 attr->start_index = br->start;
4570 attr->end_index = br->end;
4572 pango_attr_list_change (attrs, attr);
4576 tmp_list = g_slist_next (tmp_list);
4579 g_slist_free (stippled_ranges);
4582 g_object_unref (G_OBJECT (stipple));
4588 gtk_default_draw_layout (GtkStyle *style,
4590 GtkStateType state_type,
4594 const gchar *detail,
4597 PangoLayout *layout)
4601 g_return_if_fail (GTK_IS_STYLE (style));
4602 g_return_if_fail (window != NULL);
4604 gc = use_text ? style->text_gc[state_type] : style->fg_gc[state_type];
4607 gdk_gc_set_clip_rectangle (gc, area);
4609 if (state_type == GTK_STATE_INSENSITIVE)
4613 ins = get_insensitive_layout (layout);
4615 gdk_draw_layout (window, gc, x, y, ins);
4617 g_object_unref (G_OBJECT (ins));
4621 gdk_draw_layout (window, gc, x, y, layout);
4625 gdk_gc_set_clip_rectangle (gc, NULL);
4629 gtk_default_draw_resize_grip (GtkStyle *style,
4631 GtkStateType state_type,
4634 const gchar *detail,
4641 g_return_if_fail (GTK_IS_STYLE (style));
4642 g_return_if_fail (window != NULL);
4646 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
4647 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
4648 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
4651 /* make it square, aligning to bottom right */
4654 y += (height - width);
4657 else if (height < width)
4659 x += (width - height);
4663 /* Clear background */
4664 gdk_draw_rectangle (window,
4665 style->bg_gc[state_type],
4667 x, y, width, height);
4671 case GDK_WINDOW_EDGE_SOUTH_EAST:
4678 while (xi < (x + width - 3))
4680 gdk_draw_line (window,
4681 style->light_gc[state_type],
4688 gdk_draw_line (window,
4689 style->dark_gc[state_type],
4696 gdk_draw_line (window,
4697 style->dark_gc[state_type],
4707 g_assert_not_reached ();
4713 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
4714 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
4715 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
4720 gtk_style_shade (GdkColor *a,
4728 red = (gdouble) a->red / 65535.0;
4729 green = (gdouble) a->green / 65535.0;
4730 blue = (gdouble) a->blue / 65535.0;
4732 rgb_to_hls (&red, &green, &blue);
4737 else if (green < 0.0)
4743 else if (blue < 0.0)
4746 hls_to_rgb (&red, &green, &blue);
4748 b->red = red * 65535.0;
4749 b->green = green * 65535.0;
4750 b->blue = blue * 65535.0;
4754 rgb_to_hls (gdouble *r,
4795 l = (max + min) / 2;
4802 s = (max - min) / (max + min);
4804 s = (max - min) / (2 - max - min);
4808 h = (green - blue) / delta;
4809 else if (green == max)
4810 h = 2 + (blue - red) / delta;
4811 else if (blue == max)
4812 h = 4 + (red - green) / delta;
4825 hls_to_rgb (gdouble *h,
4838 if (lightness <= 0.5)
4839 m2 = lightness * (1 + saturation);
4841 m2 = lightness + saturation - lightness * saturation;
4842 m1 = 2 * lightness - m2;
4844 if (saturation == 0)
4859 r = m1 + (m2 - m1) * hue / 60;
4863 r = m1 + (m2 - m1) * (240 - hue) / 60;
4874 g = m1 + (m2 - m1) * hue / 60;
4878 g = m1 + (m2 - m1) * (240 - hue) / 60;
4889 b = m1 + (m2 - m1) * hue / 60;
4893 b = m1 + (m2 - m1) * (240 - hue) / 60;
4906 * @style: a #GtkStyle
4907 * @window: a #GdkWindow
4908 * @state_type: a state
4909 * @area: rectangle to which the output is clipped
4912 * @x1: the starting x coordinate
4913 * @x2: the ending x coordinate
4914 * @y: the y coordinate
4916 * Draws a horizontal line from (@x1, @y) to (@x2, @y) in @window
4917 * using the given style and state.
4920 gtk_paint_hline (GtkStyle *style,
4922 GtkStateType state_type,
4925 const gchar *detail,
4930 g_return_if_fail (GTK_IS_STYLE (style));
4931 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_hline != NULL);
4933 GTK_STYLE_GET_CLASS (style)->draw_hline (style, window, state_type, area, widget, detail, x1, x2, y);
4938 * @style: a #GtkStyle
4939 * @window: a #GdkWindow
4940 * @state_type: a state
4941 * @area: rectangle to which the output is clipped
4944 * @y1: the starting y coordinate
4945 * @y2: the ending y coordinate
4946 * @x: the x coordinate
4948 * Draws a vertical line from (@x, @y1) to (@x, @y1) in @window
4949 * using the given style and state.
4952 gtk_paint_vline (GtkStyle *style,
4954 GtkStateType state_type,
4957 const gchar *detail,
4962 g_return_if_fail (GTK_IS_STYLE (style));
4963 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_vline != NULL);
4965 GTK_STYLE_GET_CLASS (style)->draw_vline (style, window, state_type, area, widget, detail, y1, y2, x);
4969 gtk_paint_shadow (GtkStyle *style,
4971 GtkStateType state_type,
4972 GtkShadowType shadow_type,
4975 const gchar *detail,
4981 g_return_if_fail (GTK_IS_STYLE (style));
4982 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow != NULL);
4984 GTK_STYLE_GET_CLASS (style)->draw_shadow (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4988 gtk_paint_polygon (GtkStyle *style,
4990 GtkStateType state_type,
4991 GtkShadowType shadow_type,
4994 const gchar *detail,
4999 g_return_if_fail (GTK_IS_STYLE (style));
5000 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow != NULL);
5002 GTK_STYLE_GET_CLASS (style)->draw_polygon (style, window, state_type, shadow_type, area, widget, detail, points, npoints, fill);
5006 gtk_paint_arrow (GtkStyle *style,
5008 GtkStateType state_type,
5009 GtkShadowType shadow_type,
5012 const gchar *detail,
5013 GtkArrowType arrow_type,
5020 g_return_if_fail (GTK_IS_STYLE (style));
5021 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_arrow != NULL);
5023 GTK_STYLE_GET_CLASS (style)->draw_arrow (style, window, state_type, shadow_type, area, widget, detail, arrow_type, fill, x, y, width, height);
5027 gtk_paint_diamond (GtkStyle *style,
5029 GtkStateType state_type,
5030 GtkShadowType shadow_type,
5033 const gchar *detail,
5039 g_return_if_fail (GTK_IS_STYLE (style));
5040 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_diamond != NULL);
5042 GTK_STYLE_GET_CLASS (style)->draw_diamond (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
5047 * @style: a #GtkStyle
5048 * @window: a #GdkWindow
5049 * @state_type: a state
5050 * @area: clip rectangle
5051 * @widget: the widget
5052 * @detail: a style detail
5055 * @string: the string to draw
5057 * Draws a text string on @window with the given parameters.
5059 * This function is deprecated, use gtk_paint_layout() instead.
5062 gtk_paint_string (GtkStyle *style,
5064 GtkStateType state_type,
5067 const gchar *detail,
5070 const gchar *string)
5072 g_return_if_fail (GTK_IS_STYLE (style));
5073 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_string != NULL);
5075 GTK_STYLE_GET_CLASS (style)->draw_string (style, window, state_type, area, widget, detail, x, y, string);
5079 gtk_paint_box (GtkStyle *style,
5081 GtkStateType state_type,
5082 GtkShadowType shadow_type,
5085 const gchar *detail,
5091 g_return_if_fail (GTK_IS_STYLE (style));
5092 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box != NULL);
5094 GTK_STYLE_GET_CLASS (style)->draw_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
5098 gtk_paint_flat_box (GtkStyle *style,
5100 GtkStateType state_type,
5101 GtkShadowType shadow_type,
5104 const gchar *detail,
5110 g_return_if_fail (GTK_IS_STYLE (style));
5111 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_flat_box != NULL);
5113 GTK_STYLE_GET_CLASS (style)->draw_flat_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
5117 gtk_paint_check (GtkStyle *style,
5119 GtkStateType state_type,
5120 GtkShadowType shadow_type,
5123 const gchar *detail,
5129 g_return_if_fail (GTK_IS_STYLE (style));
5130 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_check != NULL);
5132 GTK_STYLE_GET_CLASS (style)->draw_check (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
5136 gtk_paint_option (GtkStyle *style,
5138 GtkStateType state_type,
5139 GtkShadowType shadow_type,
5142 const gchar *detail,
5148 g_return_if_fail (GTK_IS_STYLE (style));
5149 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_option != NULL);
5151 GTK_STYLE_GET_CLASS (style)->draw_option (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
5155 gtk_paint_tab (GtkStyle *style,
5157 GtkStateType state_type,
5158 GtkShadowType shadow_type,
5161 const gchar *detail,
5167 g_return_if_fail (GTK_IS_STYLE (style));
5168 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_tab != NULL);
5170 GTK_STYLE_GET_CLASS (style)->draw_tab (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
5174 gtk_paint_shadow_gap (GtkStyle *style,
5176 GtkStateType state_type,
5177 GtkShadowType shadow_type,
5185 GtkPositionType gap_side,
5189 g_return_if_fail (GTK_IS_STYLE (style));
5190 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow_gap != NULL);
5192 GTK_STYLE_GET_CLASS (style)->draw_shadow_gap (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
5197 gtk_paint_box_gap (GtkStyle *style,
5199 GtkStateType state_type,
5200 GtkShadowType shadow_type,
5208 GtkPositionType gap_side,
5212 g_return_if_fail (GTK_IS_STYLE (style));
5213 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box_gap != NULL);
5215 GTK_STYLE_GET_CLASS (style)->draw_box_gap (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
5219 gtk_paint_extension (GtkStyle *style,
5221 GtkStateType state_type,
5222 GtkShadowType shadow_type,
5230 GtkPositionType gap_side)
5232 g_return_if_fail (GTK_IS_STYLE (style));
5233 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_extension != NULL);
5235 GTK_STYLE_GET_CLASS (style)->draw_extension (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side);
5239 gtk_paint_focus (GtkStyle *style,
5241 GtkStateType state_type,
5244 const gchar *detail,
5250 g_return_if_fail (GTK_IS_STYLE (style));
5251 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_focus != NULL);
5253 GTK_STYLE_GET_CLASS (style)->draw_focus (style, window, state_type, area, widget, detail, x, y, width, height);
5257 gtk_paint_slider (GtkStyle *style,
5259 GtkStateType state_type,
5260 GtkShadowType shadow_type,
5263 const gchar *detail,
5268 GtkOrientation orientation)
5270 g_return_if_fail (GTK_IS_STYLE (style));
5271 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_slider != NULL);
5273 GTK_STYLE_GET_CLASS (style)->draw_slider (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
5277 gtk_paint_handle (GtkStyle *style,
5279 GtkStateType state_type,
5280 GtkShadowType shadow_type,
5283 const gchar *detail,
5288 GtkOrientation orientation)
5290 g_return_if_fail (GTK_IS_STYLE (style));
5291 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_handle != NULL);
5293 GTK_STYLE_GET_CLASS (style)->draw_handle (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
5297 gtk_paint_expander (GtkStyle *style,
5299 GtkStateType state_type,
5302 const gchar *detail,
5305 GtkExpanderStyle expander_style)
5307 g_return_if_fail (GTK_IS_STYLE (style));
5308 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_expander != NULL);
5310 GTK_STYLE_GET_CLASS (style)->draw_expander (style, window, state_type, area,
5311 widget, detail, x, y, expander_style);
5315 gtk_paint_layout (GtkStyle *style,
5317 GtkStateType state_type,
5321 const gchar *detail,
5324 PangoLayout *layout)
5326 g_return_if_fail (GTK_IS_STYLE (style));
5327 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_layout != NULL);
5329 GTK_STYLE_GET_CLASS (style)->draw_layout (style, window, state_type, use_text, area,
5330 widget, detail, x, y, layout);
5334 gtk_paint_resize_grip (GtkStyle *style,
5336 GtkStateType state_type,
5339 const gchar *detail,
5347 g_return_if_fail (GTK_IS_STYLE (style));
5348 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_resize_grip != NULL);
5350 GTK_STYLE_GET_CLASS (style)->draw_resize_grip (style, window, state_type,
5351 area, widget, detail,
5352 edge, x, y, width, height);
5357 * @border: a #GtkBorder.
5358 * @returns: a copy of @border.
5360 * Copies a #GtkBorder structure.
5363 gtk_border_copy (const GtkBorder *border)
5365 return (GtkBorder *)g_memdup (border, sizeof (GtkBorder));
5370 * @border: a #GtkBorder.
5372 * Frees a #GtkBorder structure.
5375 gtk_border_free (GtkBorder *border)
5381 * gtk_style_get_font:
5382 * @style: a #GtkStyle
5384 * Gets the #GdkFont to use for the given style. This is
5385 * meant only as a replacement for direct access to @style->font
5386 * and should not be used in new code. New code should
5387 * use @style->font_desc instead.
5389 * Return value: the #GdkFont for the style. This font is owned
5390 * by the style; if you want to keep around a copy, you must
5391 * call gdk_font_ref().
5394 gtk_style_get_font (GtkStyle *style)
5396 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
5398 if (style->private_font && style->private_font_desc)
5400 if (!style->font_desc ||
5401 !pango_font_description_equal (style->private_font_desc, style->font_desc))
5403 gdk_font_unref (style->private_font);
5404 style->private_font = NULL;
5406 if (style->private_font_desc)
5408 pango_font_description_free (style->private_font_desc);
5409 style->private_font_desc = NULL;
5414 if (!style->private_font)
5416 if (style->font_desc)
5418 style->private_font = gdk_font_from_description (style->font_desc);
5419 style->private_font_desc = pango_font_description_copy (style->font_desc);
5422 if (!style->private_font)
5423 style->private_font = gdk_font_load ("fixed");
5425 if (!style->private_font)
5426 g_error ("Unable to load \"fixed\" font");
5429 return style->private_font;
5433 * gtk_style_set_font:
5434 * @style: a #GtkStyle.
5435 * @font: a #GdkFont, or %NULL to use the #GdkFont corresponding
5436 * to style->font_desc.
5438 * Sets the #GdkFont to use for a given style. This is
5439 * meant only as a replacement for direct access to style->font
5440 * and should not be used in new code. New code should
5441 * use style->font_desc instead.
5444 gtk_style_set_font (GtkStyle *style,
5449 g_return_if_fail (GTK_IS_STYLE (style));
5451 old_font = style->private_font;
5453 style->private_font = font;
5455 gdk_font_ref (font);
5458 gdk_font_unref (old_font);
5460 if (style->private_font_desc)
5462 pango_font_description_free (style->private_font_desc);
5463 style->private_font_desc = NULL;
5468 * _gtk_draw_insertion_cursor:
5469 * @drawable: a #GdkDrawable
5471 * @location: location where to draw the cursor (@location->width is ignored)
5472 * @dir: text direction for the cursor, used to decide whether to draw a
5473 * directional arrow on the cursor and in what direction. Unless both
5474 * strong and weak cursors are displayed, this should be %GTK_TEXT_DIR_NONE.
5476 * Draws a text caret on @drawable at @location. This is not a style function
5477 * but merely a convenience function for drawing the standard cursor shape.
5480 _gtk_draw_insertion_cursor (GdkDrawable *drawable,
5482 GdkRectangle *location,
5483 GtkTextDirection dir)
5485 gint stem_width = location->height / 30 + 1;
5486 gint arrow_width = stem_width + 1;
5490 for (i = 0; i < stem_width; i++)
5491 gdk_draw_line (drawable, gc,
5492 location->x + i - stem_width / 2, location->y,
5493 location->x + i - stem_width / 2, location->y + location->height);
5495 if (dir == GTK_TEXT_DIR_RTL)
5497 x = location->x - stem_width / 2 - 1;
5498 y = location->y + location->height - arrow_width * 2 - arrow_width + 1;
5500 for (i = 0; i < arrow_width; i++)
5502 gdk_draw_line (drawable, gc,
5504 x, y + 2 * arrow_width - i - 1);
5508 else if (dir == GTK_TEXT_DIR_LTR)
5510 x = location->x + stem_width - stem_width / 2;
5511 y = location->y + location->height - arrow_width * 2 - arrow_width + 1;
5513 for (i = 0; i < arrow_width; i++)
5515 gdk_draw_line (drawable, gc,
5517 x, y + 2 * arrow_width - i - 1);