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/.
31 #include "gtkspinbutton.h"
33 #include "gtkwidget.h"
34 #include "gtkthemes.h"
35 #include "gtkiconfactory.h"
36 #include "gtksettings.h" /* _gtk_settings_parse_convert() */
38 #define LIGHTNESS_MULT 1.3
39 #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,
249 static void gtk_default_draw_slider (GtkStyle *style,
251 GtkStateType state_type,
252 GtkShadowType shadow_type,
260 GtkOrientation orientation);
261 static void gtk_default_draw_handle (GtkStyle *style,
263 GtkStateType state_type,
264 GtkShadowType shadow_type,
272 GtkOrientation orientation);
273 static void gtk_default_draw_expander (GtkStyle *style,
275 GtkStateType state_type,
282 static void gtk_default_draw_layout (GtkStyle *style,
284 GtkStateType state_type,
291 PangoLayout *layout);
292 static void gtk_default_draw_resize_grip (GtkStyle *style,
294 GtkStateType state_type,
304 static void gtk_style_shade (GdkColor *a,
307 static void rgb_to_hls (gdouble *r,
310 static void hls_to_rgb (gdouble *h,
316 * Data for default check and radio buttons
319 static GtkRequisition default_option_indicator_size = { 7, 13 };
320 static GtkBorder default_option_indicator_spacing = { 7, 5, 2, 2 };
322 #define INDICATOR_PART_SIZE 13
340 static char check_aa_bits[] = {
341 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x58,0x00,0xa0,
342 0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
343 static char check_base_bits[] = {
344 0x00,0x00,0x00,0x00,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,
345 0x07,0xfc,0x07,0xfc,0x07,0xfc,0x07,0x00,0x00,0x00,0x00};
346 static char check_black_bits[] = {
347 0x00,0x00,0xfe,0x0f,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,
348 0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x00,0x00};
349 static char check_dark_bits[] = {
350 0xff,0x1f,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
351 0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00};
352 static char check_light_bits[] = {
353 0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,
354 0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0xfe,0x1f};
355 static char check_mid_bits[] = {
356 0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,
357 0x08,0x00,0x08,0x00,0x08,0x00,0x08,0xfc,0x0f,0x00,0x00};
358 static char check_text_bits[] = {
359 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x03,0x80,0x01,0x80,0x00,0xd8,
360 0x00,0x60,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
361 static char radio_base_bits[] = {
362 0x00,0x00,0x00,0x00,0xf0,0x01,0xf8,0x03,0xfc,0x07,0xfc,0x07,0xfc,0x07,0xfc,
363 0x07,0xfc,0x07,0xf8,0x03,0xf0,0x01,0x00,0x00,0x00,0x00};
364 static char radio_black_bits[] = {
365 0x00,0x00,0xf0,0x01,0x08,0x02,0x04,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,
366 0x00,0x02,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
367 static char radio_dark_bits[] = {
368 0xf0,0x01,0x08,0x02,0x04,0x04,0x02,0x04,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
369 0x00,0x01,0x00,0x02,0x00,0x0c,0x00,0x00,0x00,0x00,0x00};
370 static char radio_light_bits[] = {
371 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x10,0x00,
372 0x10,0x00,0x10,0x00,0x08,0x00,0x04,0x08,0x02,0xf0,0x01};
373 static char radio_mid_bits[] = {
374 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x08,0x00,
375 0x08,0x00,0x08,0x00,0x04,0x00,0x02,0xf0,0x01,0x00,0x00};
376 static char radio_text_bits[] = {
377 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x00,0xf0,0x01,0xf0,0x01,0xf0,
378 0x01,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
383 } indicator_parts[] = {
384 { check_aa_bits, NULL },
385 { check_base_bits, NULL },
386 { check_black_bits, NULL },
387 { check_dark_bits, NULL },
388 { check_light_bits, NULL },
389 { check_mid_bits, NULL },
390 { check_text_bits, NULL },
391 { radio_base_bits, NULL },
392 { radio_black_bits, NULL },
393 { radio_dark_bits, NULL },
394 { radio_light_bits, NULL },
395 { radio_mid_bits, NULL },
396 { radio_text_bits, NULL }
399 /* --- variables --- */
400 static GdkColor gtk_default_normal_fg = { 0, 0, 0, 0 };
401 static GdkColor gtk_default_active_fg = { 0, 0, 0, 0 };
402 static GdkColor gtk_default_prelight_fg = { 0, 0, 0, 0 };
403 static GdkColor gtk_default_selected_fg = { 0, 0xffff, 0xffff, 0xffff };
404 static GdkColor gtk_default_insensitive_fg = { 0, 0x7530, 0x7530, 0x7530 };
406 static GdkColor gtk_default_normal_bg = { 0, 0xd6d6, 0xd6d6, 0xd6d6 };
407 static GdkColor gtk_default_active_bg = { 0, 0xc350, 0xc350, 0xc350 };
408 static GdkColor gtk_default_prelight_bg = { 0, 0xea60, 0xea60, 0xea60 };
409 static GdkColor gtk_default_selected_bg = { 0, 0, 0, 0x9c40 };
410 static GdkColor gtk_default_insensitive_bg = { 0, 0xd6d6, 0xd6d6, 0xd6d6 };
412 static gpointer parent_class = NULL;
413 static GdkFont *static_default_font = NULL;
416 /* --- functions --- */
418 gtk_style_get_type (void)
420 static GType style_type = 0;
424 static const GTypeInfo style_info =
426 sizeof (GtkStyleClass),
427 (GBaseInitFunc) NULL,
428 (GBaseFinalizeFunc) NULL,
429 (GClassInitFunc) gtk_style_class_init,
430 NULL, /* class_finalize */
431 NULL, /* class_data */
434 (GInstanceInitFunc) gtk_style_init,
437 style_type = g_type_register_static (G_TYPE_OBJECT,
446 gtk_style_init (GtkStyle *style)
450 style->font_desc = pango_font_description_from_string ("Sans 10");
452 if (!static_default_font)
454 static_default_font = gdk_font_from_description (style->font_desc);
456 if (!static_default_font)
457 static_default_font = gdk_font_load ("fixed");
459 if (!static_default_font)
460 g_error ("Unable to load \"fixed\" font");
463 style->font = static_default_font;
464 gdk_font_ref (style->font);
466 style->attach_count = 0;
467 style->colormap = NULL;
470 style->black.red = 0;
471 style->black.green = 0;
472 style->black.blue = 0;
474 style->white.red = 65535;
475 style->white.green = 65535;
476 style->white.blue = 65535;
478 style->black_gc = NULL;
479 style->white_gc = NULL;
481 style->fg[GTK_STATE_NORMAL] = gtk_default_normal_fg;
482 style->fg[GTK_STATE_ACTIVE] = gtk_default_active_fg;
483 style->fg[GTK_STATE_PRELIGHT] = gtk_default_prelight_fg;
484 style->fg[GTK_STATE_SELECTED] = gtk_default_selected_fg;
485 style->fg[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_fg;
487 style->bg[GTK_STATE_NORMAL] = gtk_default_normal_bg;
488 style->bg[GTK_STATE_ACTIVE] = gtk_default_active_bg;
489 style->bg[GTK_STATE_PRELIGHT] = gtk_default_prelight_bg;
490 style->bg[GTK_STATE_SELECTED] = gtk_default_selected_bg;
491 style->bg[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_bg;
493 for (i = 0; i < 4; i++)
495 style->text[i] = style->fg[i];
496 style->base[i] = style->white;
499 style->base[GTK_STATE_SELECTED] = gtk_default_selected_bg;
500 style->base[GTK_STATE_INSENSITIVE] = gtk_default_prelight_bg;
501 style->text[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_fg;
503 for (i = 0; i < 5; i++)
504 style->bg_pixmap[i] = NULL;
506 style->rc_style = NULL;
508 for (i = 0; i < 5; i++)
510 style->fg_gc[i] = NULL;
511 style->bg_gc[i] = NULL;
512 style->light_gc[i] = NULL;
513 style->dark_gc[i] = NULL;
514 style->mid_gc[i] = NULL;
515 style->text_gc[i] = NULL;
516 style->base_gc[i] = NULL;
517 style->text_aa_gc[i] = NULL;
520 style->xthickness = 2;
521 style->ythickness = 2;
523 style->property_cache = NULL;
527 gtk_style_class_init (GtkStyleClass *klass)
529 GObjectClass *object_class = G_OBJECT_CLASS (klass);
531 parent_class = g_type_class_peek_parent (klass);
533 object_class->finalize = gtk_style_finalize;
535 klass->clone = gtk_style_real_clone;
536 klass->copy = gtk_style_real_copy;
537 klass->init_from_rc = gtk_style_real_init_from_rc;
538 klass->realize = gtk_style_real_realize;
539 klass->unrealize = gtk_style_real_unrealize;
540 klass->set_background = gtk_style_real_set_background;
541 klass->render_icon = gtk_default_render_icon;
543 klass->draw_hline = gtk_default_draw_hline;
544 klass->draw_vline = gtk_default_draw_vline;
545 klass->draw_shadow = gtk_default_draw_shadow;
546 klass->draw_polygon = gtk_default_draw_polygon;
547 klass->draw_arrow = gtk_default_draw_arrow;
548 klass->draw_diamond = gtk_default_draw_diamond;
549 klass->draw_string = gtk_default_draw_string;
550 klass->draw_box = gtk_default_draw_box;
551 klass->draw_flat_box = gtk_default_draw_flat_box;
552 klass->draw_check = gtk_default_draw_check;
553 klass->draw_option = gtk_default_draw_option;
554 klass->draw_tab = gtk_default_draw_tab;
555 klass->draw_shadow_gap = gtk_default_draw_shadow_gap;
556 klass->draw_box_gap = gtk_default_draw_box_gap;
557 klass->draw_extension = gtk_default_draw_extension;
558 klass->draw_focus = gtk_default_draw_focus;
559 klass->draw_slider = gtk_default_draw_slider;
560 klass->draw_handle = gtk_default_draw_handle;
561 klass->draw_expander = gtk_default_draw_expander;
562 klass->draw_layout = gtk_default_draw_layout;
563 klass->draw_resize_grip = gtk_default_draw_resize_grip;
567 gtk_style_finalize (GObject *object)
569 GtkStyle *style = GTK_STYLE (object);
571 g_return_if_fail (style->attach_count == 0);
573 if (style->property_cache)
577 for (i = 0; i < style->property_cache->n_nodes; i++)
579 PropertyValue *node = g_bsearch_array_get_nth (style->property_cache, i);
581 g_param_spec_unref (node->pspec);
582 g_value_unset (&node->value);
584 g_bsearch_array_destroy (style->property_cache);
585 style->property_cache = NULL;
590 if (style->styles->data != style)
591 g_slist_remove (style->styles, style);
594 GSList *tmp_list = style->styles->next;
598 GTK_STYLE (tmp_list->data)->styles = style->styles->next;
599 tmp_list = tmp_list->next;
601 g_slist_free_1 (style->styles);
605 gdk_font_unref (style->font);
606 pango_font_description_free (style->font_desc);
609 gtk_rc_style_unref (style->rc_style);
611 G_OBJECT_CLASS (parent_class)->finalize (object);
616 gtk_style_copy (GtkStyle *style)
620 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
622 new_style = GTK_STYLE_GET_CLASS (style)->clone (style);
623 GTK_STYLE_GET_CLASS (style)->copy (new_style, style);
629 gtk_style_duplicate (GtkStyle *style)
633 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
635 new_style = gtk_style_copy (style);
637 style->styles = g_slist_append (style->styles, new_style);
638 new_style->styles = style->styles;
648 style = g_object_new (GTK_TYPE_STYLE, NULL);
653 /*************************************************************
655 * Attach a style to a window; this process allocates the
656 * colors and creates the GC's for the style - it specializes
657 * it to a particular visual and colormap. The process
658 * may involve the creation of a new style if the style
659 * has already been attached to a window with a different
660 * style and colormap.
665 * Either the style parameter, or a newly created style.
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 * FIXME: The sequence -
671 * create a style => s1
672 * attach s1 to v1, c1 => s1
673 * attach s1 to v2, c2 => s2
674 * detach s1 from v1, c1
675 * attach s1 to v2, c2 => s3
676 * results in two separate, unlinked styles s2 and s3 which
677 * are identical and could be shared. To fix this, we would
678 * want to never remove a style from the list of linked
679 * styles as long as as it has a reference count. However, the
680 * disadvantage of doing it this way means that we would need two
681 * passes through the linked list when attaching (one to check for
682 * matching styles, one to look for empty unattached styles - but
683 * it will almost never be longer than 2 elements.
684 *************************************************************/
687 gtk_style_attach (GtkStyle *style,
691 GtkStyle *new_style = NULL;
692 GdkColormap *colormap;
694 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
695 g_return_val_if_fail (window != NULL, NULL);
697 colormap = gdk_window_get_colormap (window);
700 style->styles = g_slist_append (NULL, style);
702 styles = style->styles;
705 new_style = styles->data;
707 if (new_style->attach_count == 0)
709 gtk_style_realize (new_style, colormap);
712 else if (new_style->colormap == colormap)
716 styles = styles->next;
721 new_style = gtk_style_duplicate (style);
722 gtk_style_realize (new_style, colormap);
725 /* A style gets a refcount from being attached */
726 if (new_style->attach_count == 0)
727 gtk_style_ref (new_style);
729 /* Another refcount belongs to the parent */
730 if (style != new_style)
732 gtk_style_unref (style);
733 gtk_style_ref (new_style);
736 new_style->attach_count++;
742 gtk_style_detach (GtkStyle *style)
744 g_return_if_fail (GTK_IS_STYLE (style));
746 style->attach_count -= 1;
747 if (style->attach_count == 0)
749 GTK_STYLE_GET_CLASS (style)->unrealize (style);
751 gdk_colormap_unref (style->colormap);
752 style->colormap = NULL;
754 gtk_style_unref (style);
759 gtk_style_ref (GtkStyle *style)
761 return (GtkStyle *) g_object_ref (G_OBJECT (style));
765 gtk_style_unref (GtkStyle *style)
767 g_object_unref (G_OBJECT (style));
771 gtk_style_realize (GtkStyle *style,
772 GdkColormap *colormap)
774 g_return_if_fail (GTK_IS_STYLE (style));
775 g_return_if_fail (GDK_IS_COLORMAP (colormap));
777 style->colormap = gdk_colormap_ref (colormap);
778 style->depth = gdk_colormap_get_visual (colormap)->depth;
780 GTK_STYLE_GET_CLASS (style)->realize (style);
784 gtk_style_lookup_icon_set (GtkStyle *style,
785 const char *stock_id)
789 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
790 g_return_val_if_fail (stock_id != NULL, NULL);
792 iter = style->icon_factories;
795 GtkIconSet *icon_set = gtk_icon_factory_lookup (GTK_ICON_FACTORY (iter->data),
800 iter = g_slist_next (iter);
803 return gtk_icon_factory_lookup_default (stock_id);
807 gtk_draw_hline (GtkStyle *style,
809 GtkStateType state_type,
814 g_return_if_fail (GTK_IS_STYLE (style));
815 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_hline != NULL);
817 GTK_STYLE_GET_CLASS (style)->draw_hline (style, window, state_type, NULL, NULL, NULL, x1, x2, y);
822 gtk_draw_vline (GtkStyle *style,
824 GtkStateType state_type,
829 g_return_if_fail (GTK_IS_STYLE (style));
830 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_vline != NULL);
832 GTK_STYLE_GET_CLASS (style)->draw_vline (style, window, state_type, NULL, NULL, NULL, y1, y2, x);
837 gtk_draw_shadow (GtkStyle *style,
839 GtkStateType state_type,
840 GtkShadowType shadow_type,
846 g_return_if_fail (GTK_IS_STYLE (style));
847 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow != NULL);
849 GTK_STYLE_GET_CLASS (style)->draw_shadow (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
853 gtk_draw_polygon (GtkStyle *style,
855 GtkStateType state_type,
856 GtkShadowType shadow_type,
861 g_return_if_fail (GTK_IS_STYLE (style));
862 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_polygon != NULL);
864 GTK_STYLE_GET_CLASS (style)->draw_polygon (style, window, state_type, shadow_type, NULL, NULL, NULL, points, npoints, fill);
868 gtk_draw_arrow (GtkStyle *style,
870 GtkStateType state_type,
871 GtkShadowType shadow_type,
872 GtkArrowType arrow_type,
879 g_return_if_fail (GTK_IS_STYLE (style));
880 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_arrow != NULL);
882 GTK_STYLE_GET_CLASS (style)->draw_arrow (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, fill, x, y, width, height);
887 gtk_draw_diamond (GtkStyle *style,
889 GtkStateType state_type,
890 GtkShadowType shadow_type,
896 g_return_if_fail (GTK_IS_STYLE (style));
897 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_diamond != NULL);
899 GTK_STYLE_GET_CLASS (style)->draw_diamond (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
904 gtk_draw_string (GtkStyle *style,
906 GtkStateType state_type,
911 g_return_if_fail (GTK_IS_STYLE (style));
912 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_string != NULL);
914 GTK_STYLE_GET_CLASS (style)->draw_string (style, window, state_type, NULL, NULL, NULL, x, y, string);
918 gtk_draw_box (GtkStyle *style,
920 GtkStateType state_type,
921 GtkShadowType shadow_type,
927 g_return_if_fail (GTK_IS_STYLE (style));
928 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box != NULL);
930 GTK_STYLE_GET_CLASS (style)->draw_box (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
934 gtk_draw_flat_box (GtkStyle *style,
936 GtkStateType state_type,
937 GtkShadowType shadow_type,
943 g_return_if_fail (GTK_IS_STYLE (style));
944 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_flat_box != NULL);
946 GTK_STYLE_GET_CLASS (style)->draw_flat_box (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
950 gtk_draw_check (GtkStyle *style,
952 GtkStateType state_type,
953 GtkShadowType shadow_type,
959 g_return_if_fail (GTK_IS_STYLE (style));
960 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_check != NULL);
962 GTK_STYLE_GET_CLASS (style)->draw_check (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
966 gtk_draw_option (GtkStyle *style,
968 GtkStateType state_type,
969 GtkShadowType shadow_type,
975 g_return_if_fail (GTK_IS_STYLE (style));
976 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_option != NULL);
978 GTK_STYLE_GET_CLASS (style)->draw_option (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
982 gtk_draw_tab (GtkStyle *style,
984 GtkStateType state_type,
985 GtkShadowType shadow_type,
991 g_return_if_fail (GTK_IS_STYLE (style));
992 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_tab != NULL);
994 GTK_STYLE_GET_CLASS (style)->draw_tab (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
998 gtk_draw_shadow_gap (GtkStyle *style,
1000 GtkStateType state_type,
1001 GtkShadowType shadow_type,
1006 GtkPositionType gap_side,
1010 g_return_if_fail (GTK_IS_STYLE (style));
1011 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow_gap != NULL);
1013 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);
1017 gtk_draw_box_gap (GtkStyle *style,
1019 GtkStateType state_type,
1020 GtkShadowType shadow_type,
1025 GtkPositionType gap_side,
1029 g_return_if_fail (GTK_IS_STYLE (style));
1030 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box_gap != NULL);
1032 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);
1036 gtk_draw_extension (GtkStyle *style,
1038 GtkStateType state_type,
1039 GtkShadowType shadow_type,
1044 GtkPositionType gap_side)
1046 g_return_if_fail (GTK_IS_STYLE (style));
1047 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_extension != NULL);
1049 GTK_STYLE_GET_CLASS (style)->draw_extension (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side);
1053 gtk_draw_focus (GtkStyle *style,
1060 g_return_if_fail (GTK_IS_STYLE (style));
1061 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_focus != NULL);
1063 GTK_STYLE_GET_CLASS (style)->draw_focus (style, window, NULL, NULL, NULL, x, y, width, height);
1067 gtk_draw_slider (GtkStyle *style,
1069 GtkStateType state_type,
1070 GtkShadowType shadow_type,
1075 GtkOrientation orientation)
1077 g_return_if_fail (GTK_IS_STYLE (style));
1078 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_slider != NULL);
1080 GTK_STYLE_GET_CLASS (style)->draw_slider (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
1084 gtk_draw_handle (GtkStyle *style,
1086 GtkStateType state_type,
1087 GtkShadowType shadow_type,
1092 GtkOrientation orientation)
1094 g_return_if_fail (GTK_IS_STYLE (style));
1095 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_handle != NULL);
1097 GTK_STYLE_GET_CLASS (style)->draw_handle (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
1101 gtk_draw_expander (GtkStyle *style,
1103 GtkStateType state_type,
1108 g_return_if_fail (GTK_IS_STYLE (style));
1109 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_expander != NULL);
1111 GTK_STYLE_GET_CLASS (style)->draw_expander (style, window, state_type,
1117 gtk_draw_layout (GtkStyle *style,
1119 GtkStateType state_type,
1123 PangoLayout *layout)
1125 g_return_if_fail (GTK_IS_STYLE (style));
1126 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_layout != NULL);
1128 GTK_STYLE_GET_CLASS (style)->draw_layout (style, window, state_type, use_text,
1134 gtk_draw_resize_grip (GtkStyle *style,
1136 GtkStateType state_type,
1143 g_return_if_fail (GTK_IS_STYLE (style));
1144 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_resize_grip != NULL);
1146 GTK_STYLE_GET_CLASS (style)->draw_resize_grip (style, window, state_type,
1149 x, y, width, height);
1154 gtk_style_set_background (GtkStyle *style,
1156 GtkStateType state_type)
1158 g_return_if_fail (GTK_IS_STYLE (style));
1159 g_return_if_fail (window != NULL);
1161 GTK_STYLE_GET_CLASS (style)->set_background (style, window, state_type);
1164 /* Default functions */
1166 gtk_style_real_clone (GtkStyle *style)
1168 return GTK_STYLE (g_object_new (G_OBJECT_TYPE (style), NULL));
1172 gtk_style_real_copy (GtkStyle *style,
1177 for (i = 0; i < 5; i++)
1179 style->fg[i] = src->fg[i];
1180 style->bg[i] = src->bg[i];
1181 style->text[i] = src->text[i];
1182 style->base[i] = src->base[i];
1184 style->bg_pixmap[i] = src->bg_pixmap[i];
1188 gdk_font_unref (style->font);
1189 style->font = src->font;
1191 gdk_font_ref (style->font);
1193 if (style->font_desc)
1194 pango_font_description_free (style->font_desc);
1196 style->font_desc = pango_font_description_copy (src->font_desc);
1198 style->font_desc = NULL;
1200 style->xthickness = src->xthickness;
1201 style->ythickness = src->ythickness;
1203 if (style->rc_style)
1204 gtk_rc_style_unref (style->rc_style);
1205 style->rc_style = src->rc_style;
1207 gtk_rc_style_ref (src->rc_style);
1209 /* don't copy, just clear cache */
1210 if (style->property_cache)
1214 for (i = 0; i < style->property_cache->n_nodes; i++)
1216 PropertyValue *node = g_bsearch_array_get_nth (style->property_cache, i);
1218 g_param_spec_unref (node->pspec);
1219 g_value_unset (&node->value);
1221 g_bsearch_array_destroy (style->property_cache);
1222 style->property_cache = NULL;
1227 gtk_style_real_init_from_rc (GtkStyle *style,
1228 GtkRcStyle *rc_style)
1233 /* cache _should_ be still empty */
1234 if (style->property_cache)
1238 for (i = 0; i < style->property_cache->n_nodes; i++)
1240 PropertyValue *node = g_bsearch_array_get_nth (style->property_cache, i);
1242 g_param_spec_unref (node->pspec);
1243 g_value_unset (&node->value);
1245 g_bsearch_array_destroy (style->property_cache);
1246 style->property_cache = NULL;
1249 if (rc_style->font_desc)
1251 pango_font_description_free (style->font_desc);
1252 style->font_desc = pango_font_description_copy (rc_style->font_desc);
1254 old_font = style->font;
1255 style->font = gdk_font_from_description (style->font_desc);
1257 gdk_font_unref (old_font);
1259 style->font = old_font;
1262 for (i = 0; i < 5; i++)
1264 if (rc_style->color_flags[i] & GTK_RC_FG)
1265 style->fg[i] = rc_style->fg[i];
1266 if (rc_style->color_flags[i] & GTK_RC_BG)
1267 style->bg[i] = rc_style->bg[i];
1268 if (rc_style->color_flags[i] & GTK_RC_TEXT)
1269 style->text[i] = rc_style->text[i];
1270 if (rc_style->color_flags[i] & GTK_RC_BASE)
1271 style->base[i] = rc_style->base[i];
1274 if (rc_style->xthickness >= 0)
1275 style->xthickness = rc_style->xthickness;
1276 if (rc_style->ythickness >= 0)
1277 style->ythickness = rc_style->ythickness;
1279 if (rc_style->icon_factories)
1283 style->icon_factories = g_slist_copy (rc_style->icon_factories);
1285 iter = style->icon_factories;
1286 while (iter != NULL)
1288 g_object_ref (G_OBJECT (iter->data));
1290 iter = g_slist_next (iter);
1296 style_property_values_cmp (gconstpointer bsearch_node1,
1297 gconstpointer bsearch_node2)
1299 const PropertyValue *val1 = bsearch_node1;
1300 const PropertyValue *val2 = bsearch_node2;
1303 cmp = G_BSEARCH_ARRAY_CMP (val1->widget_type, val2->widget_type);
1305 cmp = G_BSEARCH_ARRAY_CMP (val1->pspec, val2->pspec);
1311 _gtk_style_peek_property_value (GtkStyle *style,
1314 GtkRcPropertyParser parser)
1316 PropertyValue *pcache, key = { 0, NULL, { 0, } };
1317 const GtkRcProperty *rcprop = NULL;
1319 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
1320 g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), NULL);
1321 g_return_val_if_fail (g_type_is_a (pspec->owner_type, GTK_TYPE_WIDGET), NULL);
1322 g_return_val_if_fail (g_type_is_a (widget_type, pspec->owner_type), NULL);
1324 /* need value cache array */
1325 if (!style->property_cache)
1326 style->property_cache = g_bsearch_array_new (sizeof (PropertyValue),
1327 style_property_values_cmp,
1329 /* lookup, or insert value if not yet present */
1330 key.widget_type = widget_type;
1332 pcache = g_bsearch_array_insert (style->property_cache, &key, FALSE);
1333 if (G_VALUE_TYPE (&pcache->value))
1334 return &pcache->value;
1336 /* cache miss, initialize value type, then set contents */
1337 g_param_spec_ref (pcache->pspec);
1338 g_value_init (&pcache->value, G_PARAM_SPEC_VALUE_TYPE (pspec));
1340 /* value provided by rc style? */
1341 if (style->rc_style)
1343 GQuark prop_quark = g_quark_from_string (pspec->name);
1347 rcprop = _gtk_rc_style_lookup_rc_property (style->rc_style,
1348 g_type_qname (widget_type),
1352 widget_type = g_type_parent (widget_type);
1354 while (g_type_is_a (widget_type, pspec->owner_type));
1357 /* when supplied by rc style, we need to convert */
1358 if (rcprop && !_gtk_settings_parse_convert (parser, &rcprop->value,
1359 pspec, &pcache->value))
1361 gchar *contents = g_strdup_value_contents (&rcprop->value);
1363 g_message ("%s: failed to retrive property `%s::%s' of type `%s' from rc file value \"%s\" of type `%s'",
1365 g_type_name (pspec->owner_type), pspec->name,
1366 g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
1368 G_VALUE_TYPE_NAME (&rcprop->value));
1370 rcprop = NULL; /* needs default */
1373 /* not supplied by rc style (or conversion failed), revert to default */
1375 g_param_value_set_default (pspec, &pcache->value);
1377 return &pcache->value;
1381 load_bg_image (GdkColormap *colormap,
1383 const gchar *filename)
1385 if (strcmp (filename, "<parent>") == 0)
1386 return (GdkPixmap*) GDK_PARENT_RELATIVE;
1389 return gdk_pixmap_colormap_create_from_xpm (NULL, colormap, NULL,
1396 gtk_style_real_realize (GtkStyle *style)
1398 GdkGCValues gc_values;
1399 GdkGCValuesMask gc_values_mask;
1403 for (i = 0; i < 5; i++)
1405 gtk_style_shade (&style->bg[i], &style->light[i], LIGHTNESS_MULT);
1406 gtk_style_shade (&style->bg[i], &style->dark[i], DARKNESS_MULT);
1408 style->mid[i].red = (style->light[i].red + style->dark[i].red) / 2;
1409 style->mid[i].green = (style->light[i].green + style->dark[i].green) / 2;
1410 style->mid[i].blue = (style->light[i].blue + style->dark[i].blue) / 2;
1412 style->text_aa[i].red = (style->text[i].red + style->base[i].red) / 2;
1413 style->text_aa[i].green = (style->text[i].green + style->base[i].green) / 2;
1414 style->text_aa[i].blue = (style->text[i].blue + style->base[i].blue) / 2;
1417 gdk_color_black (style->colormap, &style->black);
1418 gdk_color_white (style->colormap, &style->white);
1420 gc_values_mask = GDK_GC_FOREGROUND | GDK_GC_FONT;
1421 if (style->font->type == GDK_FONT_FONT)
1423 gc_values.font = style->font;
1425 else if (style->font->type == GDK_FONT_FONTSET)
1427 gc_values.font = static_default_font;
1430 gc_values.foreground = style->black;
1431 style->black_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1433 gc_values.foreground = style->white;
1434 style->white_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1436 for (i = 0; i < 5; i++)
1438 if (style->rc_style && style->rc_style->bg_pixmap_name[i])
1439 style->bg_pixmap[i] = load_bg_image (style->colormap,
1441 style->rc_style->bg_pixmap_name[i]);
1443 if (!gdk_color_alloc (style->colormap, &style->fg[i]))
1444 g_warning ("unable to allocate color: ( %d %d %d )",
1445 style->fg[i].red, style->fg[i].green, style->fg[i].blue);
1446 if (!gdk_color_alloc (style->colormap, &style->bg[i]))
1447 g_warning ("unable to allocate color: ( %d %d %d )",
1448 style->bg[i].red, style->bg[i].green, style->bg[i].blue);
1449 if (!gdk_color_alloc (style->colormap, &style->light[i]))
1450 g_warning ("unable to allocate color: ( %d %d %d )",
1451 style->light[i].red, style->light[i].green, style->light[i].blue);
1452 if (!gdk_color_alloc (style->colormap, &style->dark[i]))
1453 g_warning ("unable to allocate color: ( %d %d %d )",
1454 style->dark[i].red, style->dark[i].green, style->dark[i].blue);
1455 if (!gdk_color_alloc (style->colormap, &style->mid[i]))
1456 g_warning ("unable to allocate color: ( %d %d %d )",
1457 style->mid[i].red, style->mid[i].green, style->mid[i].blue);
1458 if (!gdk_color_alloc (style->colormap, &style->text[i]))
1459 g_warning ("unable to allocate color: ( %d %d %d )",
1460 style->text[i].red, style->text[i].green, style->text[i].blue);
1461 if (!gdk_color_alloc (style->colormap, &style->base[i]))
1462 g_warning ("unable to allocate color: ( %d %d %d )",
1463 style->base[i].red, style->base[i].green, style->base[i].blue);
1464 if (!gdk_color_alloc (style->colormap, &style->text_aa[i]))
1465 g_warning ("unable to allocate color: ( %d %d %d )",
1466 style->text_aa[i].red, style->text_aa[i].green, style->text_aa[i].blue);
1468 gc_values.foreground = style->fg[i];
1469 style->fg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1471 gc_values.foreground = style->bg[i];
1472 style->bg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1474 gc_values.foreground = style->light[i];
1475 style->light_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1477 gc_values.foreground = style->dark[i];
1478 style->dark_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1480 gc_values.foreground = style->mid[i];
1481 style->mid_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1483 gc_values.foreground = style->text[i];
1484 style->text_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1486 gc_values.foreground = style->base[i];
1487 style->base_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1489 gc_values.foreground = style->text_aa[i];
1490 style->text_aa_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1495 gtk_style_real_unrealize (GtkStyle *style)
1499 gtk_gc_release (style->black_gc);
1500 gtk_gc_release (style->white_gc);
1502 for (i = 0; i < 5; i++)
1504 gtk_gc_release (style->fg_gc[i]);
1505 gtk_gc_release (style->bg_gc[i]);
1506 gtk_gc_release (style->light_gc[i]);
1507 gtk_gc_release (style->dark_gc[i]);
1508 gtk_gc_release (style->mid_gc[i]);
1509 gtk_gc_release (style->text_gc[i]);
1510 gtk_gc_release (style->base_gc[i]);
1512 if (style->bg_pixmap[i] && style->bg_pixmap[i] != (GdkPixmap*) GDK_PARENT_RELATIVE)
1513 gdk_pixmap_unref (style->bg_pixmap[i]);
1516 gdk_colormap_free_colors (style->colormap, style->fg, 5);
1517 gdk_colormap_free_colors (style->colormap, style->bg, 5);
1518 gdk_colormap_free_colors (style->colormap, style->light, 5);
1519 gdk_colormap_free_colors (style->colormap, style->dark, 5);
1520 gdk_colormap_free_colors (style->colormap, style->mid, 5);
1521 gdk_colormap_free_colors (style->colormap, style->text, 5);
1522 gdk_colormap_free_colors (style->colormap, style->base, 5);
1526 gtk_style_real_set_background (GtkStyle *style,
1528 GtkStateType state_type)
1531 gint parent_relative;
1533 if (style->bg_pixmap[state_type])
1535 if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
1538 parent_relative = TRUE;
1542 pixmap = style->bg_pixmap[state_type];
1543 parent_relative = FALSE;
1546 gdk_window_set_back_pixmap (window, pixmap, parent_relative);
1549 gdk_window_set_background (window, &style->bg[state_type]);
1553 gtk_style_render_icon (GtkStyle *style,
1554 const GtkIconSource *source,
1555 GtkTextDirection direction,
1559 const gchar *detail)
1563 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
1564 g_return_val_if_fail (GTK_STYLE_GET_CLASS (style)->render_icon != NULL, NULL);
1566 pixbuf = GTK_STYLE_GET_CLASS (style)->render_icon (style, source, direction, state,
1567 size, widget, detail);
1569 g_return_val_if_fail (pixbuf != NULL, NULL);
1574 /* Default functions */
1576 gtk_style_apply_default_background (GtkStyle *style,
1579 GtkStateType state_type,
1586 GdkRectangle new_rect, old_rect;
1592 old_rect.width = width;
1593 old_rect.height = height;
1595 if (!gdk_rectangle_intersect (area, &old_rect, &new_rect))
1602 new_rect.width = width;
1603 new_rect.height = height;
1606 if (!style->bg_pixmap[state_type] ||
1607 GDK_IS_PIXMAP (window) ||
1608 (!set_bg && style->bg_pixmap[state_type] != (GdkPixmap*) GDK_PARENT_RELATIVE))
1610 GdkGC *gc = style->bg_gc[state_type];
1612 if (style->bg_pixmap[state_type])
1614 gdk_gc_set_fill (gc, GDK_TILED);
1615 gdk_gc_set_tile (gc, style->bg_pixmap[state_type]);
1618 gdk_draw_rectangle (window, gc, TRUE,
1619 new_rect.x, new_rect.y, new_rect.width, new_rect.height);
1620 if (style->bg_pixmap[state_type])
1621 gdk_gc_set_fill (gc, GDK_SOLID);
1627 if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
1628 gdk_window_set_back_pixmap (window, NULL, TRUE);
1630 gdk_window_set_back_pixmap (window, style->bg_pixmap[state_type], FALSE);
1633 gdk_window_clear_area (window,
1634 new_rect.x, new_rect.y,
1635 new_rect.width, new_rect.height);
1640 scale_or_ref (GdkPixbuf *src,
1644 if (width == gdk_pixbuf_get_width (src) &&
1645 height == gdk_pixbuf_get_height (src))
1647 gdk_pixbuf_ref (src);
1652 return gdk_pixbuf_scale_simple (src,
1654 GDK_INTERP_BILINEAR);
1659 gtk_default_render_icon (GtkStyle *style,
1660 const GtkIconSource *source,
1661 GtkTextDirection direction,
1665 const gchar *detail)
1671 GdkPixbuf *base_pixbuf;
1673 /* Oddly, style can be NULL in this function, because
1674 * GtkIconSet can be used without a style and if so
1675 * it uses this function.
1678 base_pixbuf = gtk_icon_source_get_pixbuf (source);
1680 g_return_val_if_fail (base_pixbuf != NULL, NULL);
1682 if (!gtk_icon_size_lookup (size, &width, &height))
1684 g_warning (G_STRLOC ": invalid icon size `%d'", size);
1688 /* If the size was wildcarded, then scale; otherwise, leave it
1691 if (gtk_icon_source_get_size_wildcarded (source))
1692 scaled = scale_or_ref (base_pixbuf, width, height);
1694 scaled = GDK_PIXBUF (g_object_ref (G_OBJECT (base_pixbuf)));
1696 /* If the state was wildcarded, then generate a state. */
1697 if (gtk_icon_source_get_state_wildcarded (source))
1699 if (state == GTK_STATE_INSENSITIVE)
1701 stated = gdk_pixbuf_copy (scaled);
1703 gdk_pixbuf_saturate_and_pixelate (scaled, stated,
1706 gdk_pixbuf_unref (scaled);
1708 else if (state == GTK_STATE_PRELIGHT)
1710 stated = gdk_pixbuf_copy (scaled);
1712 gdk_pixbuf_saturate_and_pixelate (scaled, stated,
1715 gdk_pixbuf_unref (scaled);
1729 sanitize_size (GdkWindow *window,
1733 gboolean set_bg = FALSE;
1735 if ((*width == -1) && (*height == -1))
1737 set_bg = GDK_IS_WINDOW (window);
1738 gdk_window_get_size (window, width, height);
1740 else if (*width == -1)
1741 gdk_window_get_size (window, width, NULL);
1742 else if (*height == -1)
1743 gdk_window_get_size (window, NULL, height);
1749 draw_part (GdkDrawable *drawable,
1757 gdk_gc_set_clip_rectangle (gc, area);
1759 if (!indicator_parts[part].bmap)
1760 indicator_parts[part].bmap = gdk_bitmap_create_from_data (drawable,
1761 indicator_parts[part].bits,
1762 INDICATOR_PART_SIZE, INDICATOR_PART_SIZE);
1764 gdk_gc_set_ts_origin (gc, x, y);
1765 gdk_gc_set_stipple (gc, indicator_parts[part].bmap);
1766 gdk_gc_set_fill (gc, GDK_STIPPLED);
1768 gdk_draw_rectangle (drawable, gc, TRUE, x, y, INDICATOR_PART_SIZE, INDICATOR_PART_SIZE);
1770 gdk_gc_set_fill (gc, GDK_SOLID);
1773 gdk_gc_set_clip_rectangle (gc, NULL);
1777 gtk_default_draw_hline (GtkStyle *style,
1779 GtkStateType state_type,
1782 const gchar *detail,
1787 gint thickness_light;
1788 gint thickness_dark;
1791 g_return_if_fail (GTK_IS_STYLE (style));
1792 g_return_if_fail (window != NULL);
1794 thickness_light = style->ythickness / 2;
1795 thickness_dark = style->ythickness - thickness_light;
1799 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1800 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1803 if (detail && !strcmp (detail, "label"))
1805 if (state_type == GTK_STATE_INSENSITIVE)
1806 gdk_draw_line (window, style->white_gc, x1 + 1, y + 1, x2 + 1, y + 1);
1807 gdk_draw_line (window, style->fg_gc[state_type], x1, y, x2, y);
1811 for (i = 0; i < thickness_dark; i++)
1813 gdk_draw_line (window, style->light_gc[state_type], x2 - i - 1, y + i, x2, y + i);
1814 gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x2 - i - 1, y + i);
1817 y += thickness_dark;
1818 for (i = 0; i < thickness_light; i++)
1820 gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x1 + thickness_light - i - 1, y + i);
1821 gdk_draw_line (window, style->light_gc[state_type], x1 + thickness_light - i - 1, y + i, x2, y + i);
1827 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
1828 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
1834 gtk_default_draw_vline (GtkStyle *style,
1836 GtkStateType state_type,
1839 const gchar *detail,
1844 gint thickness_light;
1845 gint thickness_dark;
1848 g_return_if_fail (GTK_IS_STYLE (style));
1849 g_return_if_fail (window != NULL);
1851 thickness_light = style->xthickness / 2;
1852 thickness_dark = style->xthickness - thickness_light;
1856 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1857 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1859 for (i = 0; i < thickness_dark; i++)
1861 gdk_draw_line (window, style->light_gc[state_type], x + i, y2 - i - 1, x + i, y2);
1862 gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y2 - i - 1);
1865 x += thickness_dark;
1866 for (i = 0; i < thickness_light; i++)
1868 gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y1 + thickness_light - i);
1869 gdk_draw_line (window, style->light_gc[state_type], x + i, y1 + thickness_light - i, x + i, y2);
1873 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
1874 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
1880 draw_thin_shadow (GtkStyle *style,
1891 sanitize_size (window, &width, &height);
1893 gc1 = style->light_gc[state];
1894 gc2 = style->dark_gc[state];
1898 gdk_gc_set_clip_rectangle (gc1, area);
1899 gdk_gc_set_clip_rectangle (gc2, area);
1902 gdk_draw_line (window, gc1,
1903 x, y + height - 1, x + width - 1, y + height - 1);
1904 gdk_draw_line (window, gc1,
1905 x + width - 1, y, x + width - 1, y + height - 1);
1907 gdk_draw_line (window, gc2,
1908 x, y, x + width - 1, y);
1909 gdk_draw_line (window, gc2,
1910 x, y, x, y + height - 1);
1914 gdk_gc_set_clip_rectangle (gc1, NULL);
1915 gdk_gc_set_clip_rectangle (gc2, NULL);
1920 draw_spin_entry_shadow (GtkStyle *style,
1929 gint window_width, window_height;
1930 gboolean focus_inset;
1932 gdk_window_get_size (window, &window_width, &window_height);
1935 width = window_width;
1937 height = window_height;
1939 focus_inset = (width < window_width && height < window_height);
1943 gdk_gc_set_clip_rectangle (style->light_gc[state], area);
1944 gdk_gc_set_clip_rectangle (style->dark_gc[state], area);
1945 gdk_gc_set_clip_rectangle (style->black_gc, area);
1946 gdk_gc_set_clip_rectangle (style->bg_gc[state], area);
1947 gdk_gc_set_clip_rectangle (style->base_gc[state], area);
1950 gdk_draw_line (window, style->light_gc[state],
1951 x, y + height - 1, x + width - 1, y + height - 1);
1953 gdk_draw_line (window,
1954 style->base_gc[state],
1955 x + width - 1, y + 1, x + width - 1, y + height - 3);
1959 gdk_draw_line (window, style->bg_gc[state],
1960 x + 1, y + height - 2, x + width - 1, y + height - 2);
1961 gdk_draw_line (window,
1962 style->base_gc[state],
1963 x + width - 2, y + 1, x + width - 2, y + height - 3);
1965 gdk_draw_line (window, style->black_gc,
1966 x + 1, y + 1, x + width - 1, y + 1);
1967 gdk_draw_line (window, style->black_gc,
1968 x + 1, y + 1, x + 1, y + height - 2);
1971 gdk_draw_line (window, style->dark_gc[state],
1972 x, y, x + width - 1, y);
1973 gdk_draw_line (window, style->dark_gc[state],
1974 x, y, x, y + height - 1);
1978 gdk_gc_set_clip_rectangle (style->light_gc[state], NULL);
1979 gdk_gc_set_clip_rectangle (style->dark_gc[state], NULL);
1980 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
1981 gdk_gc_set_clip_rectangle (style->bg_gc[state], NULL);
1982 gdk_gc_set_clip_rectangle (style->base_gc[state], NULL);
1987 draw_spinbutton_shadow (GtkStyle *style,
1996 gint y_middle = y + height / 2;
1998 sanitize_size (window, &width, &height);
2002 gdk_gc_set_clip_rectangle (style->black_gc, area);
2003 gdk_gc_set_clip_rectangle (style->bg_gc[state], area);
2004 gdk_gc_set_clip_rectangle (style->dark_gc[state], area);
2005 gdk_gc_set_clip_rectangle (style->light_gc[state], area);
2008 gdk_draw_line (window, style->black_gc,
2009 x, y + 2, x, y + height - 3);
2010 gdk_draw_line (window, style->black_gc,
2011 x, y + 1, x + width - 2, y + 1);
2012 gdk_draw_line (window, style->black_gc,
2013 x + width - 2, y + 2, x + width - 2, y + height - 3);
2015 gdk_draw_line (window, style->bg_gc[state],
2016 x, y + height - 2, x + width - 2, y + height - 2);
2018 gdk_draw_line (window, style->dark_gc[state],
2019 x, y, x + width - 1, y);
2020 gdk_draw_line (window, style->dark_gc[state],
2021 x + 1, y_middle - 1, x + width - 3, y_middle - 1);
2022 gdk_draw_line (window, style->dark_gc[state],
2023 x + 1, y + height - 3, x + width - 3, y + height - 3);
2025 gdk_draw_line (window, style->light_gc[state],
2026 x + 1, y + 2, x + width - 3, y + 2);
2027 gdk_draw_line (window, style->light_gc[state],
2028 x + 1, y_middle, x + width - 3, y_middle);
2029 gdk_draw_line (window, style->light_gc[state],
2030 x + width - 1, y + 1, x + width - 1, y + height - 1);
2031 gdk_draw_line (window, style->light_gc[state],
2032 x, y + height - 1, x + width - 2, y + height - 1);
2036 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2037 gdk_gc_set_clip_rectangle (style->bg_gc[state], NULL);
2038 gdk_gc_set_clip_rectangle (style->dark_gc[state], NULL);
2039 gdk_gc_set_clip_rectangle (style->light_gc[state], NULL);
2044 gtk_default_draw_shadow (GtkStyle *style,
2046 GtkStateType state_type,
2047 GtkShadowType shadow_type,
2050 const gchar *detail,
2058 gint thickness_light;
2059 gint thickness_dark;
2062 g_return_if_fail (GTK_IS_STYLE (style));
2063 g_return_if_fail (window != NULL);
2065 if (shadow_type == GTK_SHADOW_IN)
2067 if (detail && (strcmp (detail, "buttondefault") == 0))
2069 sanitize_size (window, &width, &height);
2071 gdk_draw_rectangle (window, style->black_gc, FALSE,
2072 x, y, width - 1, height - 1);
2076 if (detail && strcmp (detail, "trough") == 0)
2078 draw_thin_shadow (style, window, state_type, area,
2079 x, y, width, height);
2082 else if (widget && GTK_IS_SPIN_BUTTON (widget) &&
2083 detail && strcmp (detail, "entry") == 0)
2085 draw_spin_entry_shadow (style, window, state_type, area,
2086 x, y, width, height);
2089 else if (widget && GTK_IS_SPIN_BUTTON (widget) &&
2090 detail && strcmp (detail, "spinbutton") == 0)
2092 draw_spinbutton_shadow (style, window, state_type,
2093 area, x, y, width, height);
2098 sanitize_size (window, &width, &height);
2100 switch (shadow_type)
2102 case GTK_SHADOW_NONE:
2105 case GTK_SHADOW_ETCHED_IN:
2106 gc1 = style->light_gc[state_type];
2107 gc2 = style->dark_gc[state_type];
2109 case GTK_SHADOW_OUT:
2110 case GTK_SHADOW_ETCHED_OUT:
2111 gc1 = style->dark_gc[state_type];
2112 gc2 = style->light_gc[state_type];
2118 gdk_gc_set_clip_rectangle (gc1, area);
2119 gdk_gc_set_clip_rectangle (gc2, area);
2120 if (shadow_type == GTK_SHADOW_IN ||
2121 shadow_type == GTK_SHADOW_OUT)
2123 gdk_gc_set_clip_rectangle (style->black_gc, area);
2124 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
2128 switch (shadow_type)
2130 case GTK_SHADOW_NONE:
2134 /* Light around right and bottom edge */
2136 if (style->ythickness > 0)
2137 gdk_draw_line (window, gc1,
2138 x, y + height - 1, x + width - 1, y + height - 1);
2139 if (style->xthickness > 0)
2140 gdk_draw_line (window, gc1,
2141 x + width - 1, y, x + width - 1, y + height - 1);
2143 if (style->ythickness > 1)
2144 gdk_draw_line (window, style->bg_gc[state_type],
2145 x + 1, y + height - 2, x + width - 2, y + height - 2);
2146 if (style->xthickness > 1)
2147 gdk_draw_line (window, style->bg_gc[state_type],
2148 x + width - 2, y + 1, x + width - 2, y + height - 2);
2150 /* Dark around left and top */
2152 if (style->ythickness > 1)
2153 gdk_draw_line (window, style->black_gc,
2154 x + 1, y + 1, x + width - 2, y + 1);
2155 if (style->xthickness > 1)
2156 gdk_draw_line (window, style->black_gc,
2157 x + 1, y + 1, x + 1, y + height - 2);
2159 if (style->ythickness > 0)
2160 gdk_draw_line (window, gc2,
2161 x, y, x + width - 1, y);
2162 if (style->xthickness > 0)
2163 gdk_draw_line (window, gc2,
2164 x, y, x, y + height - 1);
2167 case GTK_SHADOW_OUT:
2168 /* Dark around right and bottom edge */
2170 if (style->ythickness > 0)
2172 if (style->ythickness > 1)
2174 gdk_draw_line (window, gc1,
2175 x + 1, y + height - 2, x + width - 2, y + height - 2);
2176 gdk_draw_line (window, style->black_gc,
2177 x, y + height - 1, x + width - 1, y + height - 1);
2181 gdk_draw_line (window, gc1,
2182 x + 1, y + height - 1, x + width - 1, y + height - 1);
2186 if (style->xthickness > 0)
2188 if (style->xthickness > 1)
2190 gdk_draw_line (window, gc1,
2191 x + width - 2, y + 1, x + width - 2, y + height - 2);
2193 gdk_draw_line (window, style->black_gc,
2194 x + width - 1, y, x + width - 1, y + height - 1);
2198 gdk_draw_line (window, gc1,
2199 x + width - 1, y + 1, x + width - 1, y + height - 1);
2203 /* Light around top and left */
2205 if (style->ythickness > 0)
2206 gdk_draw_line (window, gc2,
2207 x, y, x + width - 1, y);
2208 if (style->xthickness > 0)
2209 gdk_draw_line (window, gc2,
2210 x, y, x, y + height - 1);
2212 if (style->ythickness > 1)
2213 gdk_draw_line (window, style->bg_gc[state_type],
2214 x + 1, y + 1, x + width - 2, y + 1);
2215 if (style->xthickness > 1)
2216 gdk_draw_line (window, style->bg_gc[state_type],
2217 x + 1, y + 1, x + 1, y + height - 2);
2220 case GTK_SHADOW_ETCHED_IN:
2221 case GTK_SHADOW_ETCHED_OUT:
2222 if (style->xthickness > 0)
2224 if (style->xthickness > 1)
2226 thickness_light = 1;
2229 for (i = 0; i < thickness_dark; i++)
2231 gdk_draw_line (window, gc1,
2235 y + height - i - 1);
2236 gdk_draw_line (window, gc2,
2240 y + height - i - 2);
2243 for (i = 0; i < thickness_light; i++)
2245 gdk_draw_line (window, gc1,
2246 x + thickness_dark + i,
2247 y + thickness_dark + i,
2248 x + thickness_dark + i,
2249 y + height - thickness_dark - i - 1);
2250 gdk_draw_line (window, gc2,
2251 x + width - thickness_light - i - 1,
2252 y + thickness_dark + i,
2253 x + width - thickness_light - i - 1,
2254 y + height - thickness_light - 1);
2259 gdk_draw_line (window,
2260 style->dark_gc[state_type],
2261 x, y, x, y + height);
2262 gdk_draw_line (window,
2263 style->dark_gc[state_type],
2264 x + width, y, x + width, y + height);
2268 if (style->ythickness > 0)
2270 if (style->ythickness > 1)
2272 thickness_light = 1;
2275 for (i = 0; i < thickness_dark; i++)
2277 gdk_draw_line (window, gc1,
2281 y + height - i - 1);
2283 gdk_draw_line (window, gc2,
2290 for (i = 0; i < thickness_light; i++)
2292 gdk_draw_line (window, gc1,
2293 x + thickness_dark + i,
2294 y + thickness_dark + i,
2295 x + width - thickness_dark - i - 1,
2296 y + thickness_dark + i);
2298 gdk_draw_line (window, gc2,
2299 x + thickness_dark + i,
2300 y + height - thickness_light - i - 1,
2301 x + width - thickness_light - 1,
2302 y + height - thickness_light - i - 1);
2307 gdk_draw_line (window,
2308 style->dark_gc[state_type],
2309 x, y, x + width, y);
2310 gdk_draw_line (window,
2311 style->dark_gc[state_type],
2312 x, y + height, x + width, y + height);
2320 gdk_gc_set_clip_rectangle (gc1, NULL);
2321 gdk_gc_set_clip_rectangle (gc2, NULL);
2322 if (shadow_type == GTK_SHADOW_IN ||
2323 shadow_type == GTK_SHADOW_OUT)
2325 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2326 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2332 gtk_default_draw_polygon (GtkStyle *style,
2334 GtkStateType state_type,
2335 GtkShadowType shadow_type,
2338 const gchar *detail,
2343 static const gdouble pi_over_4 = G_PI_4;
2344 static const gdouble pi_3_over_4 = G_PI_4 * 3;
2354 g_return_if_fail (GTK_IS_STYLE (style));
2355 g_return_if_fail (window != NULL);
2356 g_return_if_fail (points != NULL);
2358 switch (shadow_type)
2361 gc1 = style->bg_gc[state_type];
2362 gc2 = style->dark_gc[state_type];
2363 gc3 = style->light_gc[state_type];
2364 gc4 = style->black_gc;
2366 case GTK_SHADOW_ETCHED_IN:
2367 gc1 = style->light_gc[state_type];
2368 gc2 = style->dark_gc[state_type];
2369 gc3 = style->dark_gc[state_type];
2370 gc4 = style->light_gc[state_type];
2372 case GTK_SHADOW_OUT:
2373 gc1 = style->dark_gc[state_type];
2374 gc2 = style->light_gc[state_type];
2375 gc3 = style->black_gc;
2376 gc4 = style->bg_gc[state_type];
2378 case GTK_SHADOW_ETCHED_OUT:
2379 gc1 = style->dark_gc[state_type];
2380 gc2 = style->light_gc[state_type];
2381 gc3 = style->light_gc[state_type];
2382 gc4 = style->dark_gc[state_type];
2390 gdk_gc_set_clip_rectangle (gc1, area);
2391 gdk_gc_set_clip_rectangle (gc2, area);
2392 gdk_gc_set_clip_rectangle (gc3, area);
2393 gdk_gc_set_clip_rectangle (gc4, area);
2397 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, npoints);
2401 for (i = 0; i < npoints; i++)
2403 if ((points[i].x == points[i+1].x) &&
2404 (points[i].y == points[i+1].y))
2410 angle = atan2 (points[i+1].y - points[i].y,
2411 points[i+1].x - points[i].x);
2414 if ((angle > -pi_3_over_4) && (angle < pi_over_4))
2416 if (angle > -pi_over_4)
2427 gdk_draw_line (window, gc1,
2428 points[i].x-xadjust, points[i].y-yadjust,
2429 points[i+1].x-xadjust, points[i+1].y-yadjust);
2430 gdk_draw_line (window, gc3,
2431 points[i].x, points[i].y,
2432 points[i+1].x, points[i+1].y);
2436 if ((angle < -pi_3_over_4) || (angle > pi_3_over_4))
2447 gdk_draw_line (window, gc4,
2448 points[i].x+xadjust, points[i].y+yadjust,
2449 points[i+1].x+xadjust, points[i+1].y+yadjust);
2450 gdk_draw_line (window, gc2,
2451 points[i].x, points[i].y,
2452 points[i+1].x, points[i+1].y);
2458 gdk_gc_set_clip_rectangle (gc1, NULL);
2459 gdk_gc_set_clip_rectangle (gc2, NULL);
2460 gdk_gc_set_clip_rectangle (gc3, NULL);
2461 gdk_gc_set_clip_rectangle (gc4, NULL);
2466 draw_varrow (GdkWindow *window,
2468 GtkShadowType shadow_type,
2470 GtkArrowType arrow_type,
2477 gint y_start, y_increment;
2481 gdk_gc_set_clip_rectangle (gc, area);
2483 width = width + width % 2 - 1; /* Force odd */
2485 steps = 1 + width / 2;
2487 extra = height - steps;
2489 if (arrow_type == GTK_ARROW_DOWN)
2496 y_start = y + height - 1;
2500 for (i = 0; i < extra; i++)
2502 gdk_draw_line (window, gc,
2503 x, y_start + i * y_increment,
2504 x + width - 1, y_start + i * y_increment);
2506 for (; i < height; i++)
2508 gdk_draw_line (window, gc,
2509 x + (i - extra), y_start + i * y_increment,
2510 x + width - (i - extra) - 1, y_start + i * y_increment);
2515 gdk_gc_set_clip_rectangle (gc, NULL);
2519 draw_harrow (GdkWindow *window,
2521 GtkShadowType shadow_type,
2523 GtkArrowType arrow_type,
2530 gint x_start, x_increment;
2534 gdk_gc_set_clip_rectangle (gc, area);
2536 height = height + height % 2 - 1; /* Force odd */
2538 steps = 1 + height / 2;
2540 extra = width - steps;
2542 if (arrow_type == GTK_ARROW_RIGHT)
2549 x_start = x + width - 1;
2553 for (i = 0; i < extra; i++)
2555 gdk_draw_line (window, gc,
2556 x_start + i * x_increment, y,
2557 x_start + i * x_increment, y + height - 1);
2559 for (; i < width; i++)
2561 gdk_draw_line (window, gc,
2562 x_start + i * x_increment, y + (i - extra),
2563 x_start + i * x_increment, y + height - (i - extra) - 1);
2568 gdk_gc_set_clip_rectangle (gc, NULL);
2572 gtk_default_draw_arrow (GtkStyle *style,
2575 GtkShadowType shadow,
2578 const gchar *detail,
2579 GtkArrowType arrow_type,
2586 sanitize_size (window, &width, &height);
2588 if (detail && strcmp (detail, "spinbutton") == 0)
2590 x += (width - 7) / 2;
2592 if (arrow_type == GTK_ARROW_UP)
2593 y += (height - 4) / 2;
2595 y += (1 + height - 4) / 2;
2597 draw_varrow (window, style->fg_gc[state], shadow, area, arrow_type,
2600 else if (detail && strcmp (detail, "vscrollbar") == 0)
2602 gtk_paint_box (style, window, state, shadow, area,
2603 widget, detail, x, y, width, height);
2605 x += (width - 7) / 2;
2606 y += (height - 5) / 2;
2608 draw_varrow (window, style->fg_gc[state], shadow, area, arrow_type,
2612 else if (detail && strcmp (detail, "hscrollbar") == 0)
2614 gtk_paint_box (style, window, state, shadow, area,
2615 widget, detail, x, y, width, height);
2617 y += (height - 7) / 2;
2618 x += (width - 5) / 2;
2620 draw_harrow (window, style->fg_gc[state], shadow, area, arrow_type,
2625 if (arrow_type == GTK_ARROW_UP || arrow_type == GTK_ARROW_DOWN)
2627 x += (width - 7) / 2;
2628 y += (height - 5) / 2;
2630 draw_varrow (window, style->fg_gc[state], shadow, area, arrow_type,
2635 x += (width - 5) / 2;
2636 y += (height - 7) / 2;
2638 draw_harrow (window, style->fg_gc[state], shadow, area, arrow_type,
2645 gtk_default_draw_diamond (GtkStyle *style,
2647 GtkStateType state_type,
2648 GtkShadowType shadow_type,
2651 const gchar *detail,
2659 GdkGC *outer_nw = NULL;
2660 GdkGC *outer_ne = NULL;
2661 GdkGC *outer_sw = NULL;
2662 GdkGC *outer_se = NULL;
2663 GdkGC *middle_nw = NULL;
2664 GdkGC *middle_ne = NULL;
2665 GdkGC *middle_sw = NULL;
2666 GdkGC *middle_se = NULL;
2667 GdkGC *inner_nw = NULL;
2668 GdkGC *inner_ne = NULL;
2669 GdkGC *inner_sw = NULL;
2670 GdkGC *inner_se = NULL;
2672 g_return_if_fail (GTK_IS_STYLE (style));
2673 g_return_if_fail (window != NULL);
2675 sanitize_size (window, &width, &height);
2677 half_width = width / 2;
2678 half_height = height / 2;
2682 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
2683 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
2684 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
2685 gdk_gc_set_clip_rectangle (style->black_gc, area);
2688 switch (shadow_type)
2691 inner_sw = inner_se = style->bg_gc[state_type];
2692 middle_sw = middle_se = style->light_gc[state_type];
2693 outer_sw = outer_se = style->light_gc[state_type];
2694 inner_nw = inner_ne = style->black_gc;
2695 middle_nw = middle_ne = style->dark_gc[state_type];
2696 outer_nw = outer_ne = style->dark_gc[state_type];
2699 case GTK_SHADOW_OUT:
2700 inner_sw = inner_se = style->dark_gc[state_type];
2701 middle_sw = middle_se = style->dark_gc[state_type];
2702 outer_sw = outer_se = style->black_gc;
2703 inner_nw = inner_ne = style->bg_gc[state_type];
2704 middle_nw = middle_ne = style->light_gc[state_type];
2705 outer_nw = outer_ne = style->light_gc[state_type];
2708 case GTK_SHADOW_ETCHED_IN:
2709 inner_sw = inner_se = style->bg_gc[state_type];
2710 middle_sw = middle_se = style->dark_gc[state_type];
2711 outer_sw = outer_se = style->light_gc[state_type];
2712 inner_nw = inner_ne = style->bg_gc[state_type];
2713 middle_nw = middle_ne = style->light_gc[state_type];
2714 outer_nw = outer_ne = style->dark_gc[state_type];
2717 case GTK_SHADOW_ETCHED_OUT:
2718 inner_sw = inner_se = style->bg_gc[state_type];
2719 middle_sw = middle_se = style->light_gc[state_type];
2720 outer_sw = outer_se = style->dark_gc[state_type];
2721 inner_nw = inner_ne = style->bg_gc[state_type];
2722 middle_nw = middle_ne = style->dark_gc[state_type];
2723 outer_nw = outer_ne = style->light_gc[state_type];
2733 gdk_draw_line (window, inner_sw,
2734 x + 2, y + half_height,
2735 x + half_width, y + height - 2);
2736 gdk_draw_line (window, inner_se,
2737 x + half_width, y + height - 2,
2738 x + width - 2, y + half_height);
2739 gdk_draw_line (window, middle_sw,
2740 x + 1, y + half_height,
2741 x + half_width, y + height - 1);
2742 gdk_draw_line (window, middle_se,
2743 x + half_width, y + height - 1,
2744 x + width - 1, y + half_height);
2745 gdk_draw_line (window, outer_sw,
2747 x + half_width, y + height);
2748 gdk_draw_line (window, outer_se,
2749 x + half_width, y + height,
2750 x + width, y + half_height);
2752 gdk_draw_line (window, inner_nw,
2753 x + 2, y + half_height,
2754 x + half_width, y + 2);
2755 gdk_draw_line (window, inner_ne,
2756 x + half_width, y + 2,
2757 x + width - 2, y + half_height);
2758 gdk_draw_line (window, middle_nw,
2759 x + 1, y + half_height,
2760 x + half_width, y + 1);
2761 gdk_draw_line (window, middle_ne,
2762 x + half_width, y + 1,
2763 x + width - 1, y + half_height);
2764 gdk_draw_line (window, outer_nw,
2767 gdk_draw_line (window, outer_ne,
2769 x + width, y + half_height);
2774 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
2775 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2776 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
2777 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2782 gtk_default_draw_string (GtkStyle *style,
2784 GtkStateType state_type,
2787 const gchar *detail,
2790 const gchar *string)
2792 g_return_if_fail (GTK_IS_STYLE (style));
2793 g_return_if_fail (window != NULL);
2797 gdk_gc_set_clip_rectangle (style->white_gc, area);
2798 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], area);
2801 if (state_type == GTK_STATE_INSENSITIVE)
2802 gdk_draw_string (window, style->font, style->white_gc, x + 1, y + 1, string);
2804 gdk_draw_string (window, style->font, style->fg_gc[state_type], x, y, string);
2808 gdk_gc_set_clip_rectangle (style->white_gc, NULL);
2809 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], NULL);
2814 option_menu_get_props (GtkWidget *widget,
2815 GtkRequisition *indicator_size,
2816 GtkBorder *indicator_spacing)
2818 GtkRequisition *tmp_size = NULL;
2819 GtkBorder *tmp_spacing = NULL;
2822 gtk_widget_style_get (widget,
2823 "indicator_size", &tmp_size,
2824 "indicator_spacing", &tmp_spacing,
2829 *indicator_size = *tmp_size;
2833 *indicator_size = default_option_indicator_size;
2837 *indicator_spacing = *tmp_spacing;
2838 g_free (tmp_spacing);
2841 *indicator_spacing = default_option_indicator_spacing;
2845 gtk_default_draw_box (GtkStyle *style,
2847 GtkStateType state_type,
2848 GtkShadowType shadow_type,
2851 const gchar *detail,
2857 g_return_if_fail (GTK_IS_STYLE (style));
2858 g_return_if_fail (window != NULL);
2860 sanitize_size (window, &width, &height);
2862 if (!style->bg_pixmap[state_type] ||
2863 GDK_IS_PIXMAP (window))
2866 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
2868 gdk_draw_rectangle (window, style->bg_gc[state_type], TRUE,
2869 x, y, width, height);
2871 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2874 gtk_style_apply_default_background (style, window,
2875 widget && !GTK_WIDGET_NO_WINDOW (widget),
2876 state_type, area, x, y, width, height);
2878 gtk_paint_shadow (style, window, state_type, shadow_type, area, widget, detail,
2879 x, y, width, height);
2881 if (detail && strcmp (detail, "optionmenu") == 0)
2883 GtkRequisition indicator_size;
2884 GtkBorder indicator_spacing;
2886 option_menu_get_props (widget, &indicator_size, &indicator_spacing);
2888 sanitize_size (window, &width, &height);
2890 gtk_paint_vline (style, window, state_type, area, widget,
2892 y + style->ythickness + 1,
2893 y + height - style->ythickness - 3,
2894 x + width - (indicator_size.width + indicator_spacing.left + indicator_spacing.right) - style->xthickness);
2899 get_darkened_gc (GdkWindow *window,
2903 GdkColor src = *color;
2907 gc = gdk_gc_new (window);
2909 while (darken_count)
2911 gtk_style_shade (&src, &shaded, 0.93);
2916 gdk_gc_set_rgb_fg_color (gc, &shaded);
2922 gtk_default_draw_flat_box (GtkStyle *style,
2924 GtkStateType state_type,
2925 GtkShadowType shadow_type,
2928 const gchar *detail,
2935 GdkGC *freeme = NULL;
2937 g_return_if_fail (GTK_IS_STYLE (style));
2938 g_return_if_fail (window != NULL);
2940 sanitize_size (window, &width, &height);
2944 if (state_type == GTK_STATE_SELECTED)
2946 if (!strcmp ("text", detail))
2947 gc1 = style->bg_gc[GTK_STATE_SELECTED];
2948 else if (!strcmp ("cell_even_sorted", detail) ||
2949 !strcmp ("cell_odd_sorted", detail) ||
2950 !strcmp ("cell_even_ruled_sorted", detail) ||
2951 !strcmp ("cell_odd_ruled_sorted", detail))
2953 freeme = get_darkened_gc (window, &style->bg[state_type], 1);
2958 gc1 = style->bg_gc[state_type];
2963 if (!strcmp ("viewportbin", detail))
2964 gc1 = style->bg_gc[GTK_STATE_NORMAL];
2965 else if (!strcmp ("entry_bg", detail))
2966 gc1 = style->base_gc[state_type];
2968 /* For trees: even rows are base color, odd rows are a shade of
2969 * the base color, the sort column is a shade of the original color
2973 /* FIXME when we have style properties, clean this up.
2976 else if (!strcmp ("cell_even", detail) ||
2977 !strcmp ("cell_odd", detail) ||
2978 !strcmp ("cell_even_ruled", detail))
2980 gc1 = style->base_gc[state_type];
2982 else if (!strcmp ("cell_even_sorted", detail) ||
2983 !strcmp ("cell_odd_sorted", detail) ||
2984 !strcmp ("cell_odd_ruled", detail) ||
2985 !strcmp ("cell_even_ruled_sorted", detail))
2987 freeme = get_darkened_gc (window, &style->base[state_type], 1);
2990 else if (!strcmp ("cell_odd_ruled_sorted", detail))
2992 freeme = get_darkened_gc (window, &style->base[state_type], 2);
2996 gc1 = style->bg_gc[state_type];
3000 gc1 = style->bg_gc[state_type];
3002 if (!style->bg_pixmap[state_type] || gc1 != style->bg_gc[state_type] ||
3003 GDK_IS_PIXMAP (window))
3006 gdk_gc_set_clip_rectangle (gc1, area);
3008 gdk_draw_rectangle (window, gc1, TRUE,
3009 x, y, width, height);
3011 if (detail && !strcmp ("tooltip", detail))
3012 gdk_draw_rectangle (window, style->black_gc, FALSE,
3013 x, y, width - 1, height - 1);
3016 gdk_gc_set_clip_rectangle (gc1, NULL);
3019 gtk_style_apply_default_background (style, window,
3020 widget && !GTK_WIDGET_NO_WINDOW (widget),
3021 state_type, area, x, y, width, height);
3025 g_object_unref (G_OBJECT (freeme));
3029 gtk_default_draw_check (GtkStyle *style,
3031 GtkStateType state_type,
3032 GtkShadowType shadow_type,
3035 const gchar *detail,
3041 if (detail && strcmp (detail, "cellcheck") == 0)
3043 gdk_draw_rectangle (window,
3044 widget->style->fg_gc[state_type],
3049 if (shadow_type == GTK_SHADOW_IN)
3051 gdk_draw_line (window,
3052 widget->style->fg_gc[state_type],
3056 gdk_draw_line (window,
3057 widget->style->fg_gc[state_type],
3066 x -= (1 + INDICATOR_PART_SIZE - width) / 2;
3067 y -= (1 + INDICATOR_PART_SIZE - height) / 2;
3069 if (strcmp (detail, "check") == 0) /* Menu item */
3071 if (shadow_type == GTK_SHADOW_IN)
3073 draw_part (window, style->black_gc, area, x, y, CHECK_TEXT);
3074 draw_part (window, style->dark_gc[state_type], area, x, y, CHECK_AA);
3079 draw_part (window, style->black_gc, area, x, y, CHECK_BLACK);
3080 draw_part (window, style->dark_gc[state_type], area, x, y, CHECK_DARK);
3081 draw_part (window, style->mid_gc[state_type], area, x, y, CHECK_MID);
3082 draw_part (window, style->light_gc[state_type], area, x, y, CHECK_LIGHT);
3083 draw_part (window, style->base_gc[state_type], area, x, y, CHECK_BASE);
3085 if (shadow_type == GTK_SHADOW_IN)
3087 draw_part (window, style->text_gc[state_type], area, x, y, CHECK_TEXT);
3088 draw_part (window, style->text_aa_gc[state_type], area, x, y, CHECK_AA);
3096 gtk_default_draw_option (GtkStyle *style,
3098 GtkStateType state_type,
3099 GtkShadowType shadow_type,
3102 const gchar *detail,
3108 if (detail && strcmp (detail, "cellradio") == 0)
3110 gdk_draw_arc (window,
3111 widget->style->fg_gc[state_type],
3118 if (shadow_type == GTK_SHADOW_IN)
3120 gdk_draw_arc (window,
3121 widget->style->fg_gc[state_type],
3132 x -= (1 + INDICATOR_PART_SIZE - width) / 2;
3133 y -= (1 + INDICATOR_PART_SIZE - height) / 2;
3135 if (strcmp (detail, "option") == 0) /* Menu item */
3137 if (shadow_type == GTK_SHADOW_IN)
3138 draw_part (window, style->fg_gc[state_type], area, x, y, RADIO_TEXT);
3142 draw_part (window, style->black_gc, area, x, y, RADIO_BLACK);
3143 draw_part (window, style->dark_gc[state_type], area, x, y, RADIO_DARK);
3144 draw_part (window, style->mid_gc[state_type], area, x, y, RADIO_MID);
3145 draw_part (window, style->light_gc[state_type], area, x, y, RADIO_LIGHT);
3146 draw_part (window, style->base_gc[state_type], area, x, y, RADIO_BASE);
3148 if (shadow_type == GTK_SHADOW_IN)
3149 draw_part (window, style->text_gc[state_type], area, x, y, RADIO_TEXT);
3155 gtk_default_draw_tab (GtkStyle *style,
3157 GtkStateType state_type,
3158 GtkShadowType shadow_type,
3161 const gchar *detail,
3167 GtkRequisition indicator_size;
3168 GtkBorder indicator_spacing;
3170 option_menu_get_props (widget, &indicator_size, &indicator_spacing);
3172 x += (width - indicator_size.width) / 2;
3173 y += (height - indicator_size.height) / 2 - 1;
3175 draw_varrow (window, style->black_gc, shadow_type, area, GTK_ARROW_UP,
3176 x, y, indicator_size.width, 5);
3177 draw_varrow (window, style->black_gc, shadow_type, area, GTK_ARROW_DOWN,
3178 x, y + 8, indicator_size.width, 5);
3182 gtk_default_draw_shadow_gap (GtkStyle *style,
3184 GtkStateType state_type,
3185 GtkShadowType shadow_type,
3188 const gchar *detail,
3193 GtkPositionType gap_side,
3202 g_return_if_fail (GTK_IS_STYLE (style));
3203 g_return_if_fail (window != NULL);
3205 sanitize_size (window, &width, &height);
3207 switch (shadow_type)
3209 case GTK_SHADOW_NONE:
3212 gc1 = style->dark_gc[state_type];
3213 gc2 = style->black_gc;
3214 gc3 = style->bg_gc[state_type];
3215 gc4 = style->light_gc[state_type];
3217 case GTK_SHADOW_ETCHED_IN:
3218 gc1 = style->dark_gc[state_type];
3219 gc2 = style->light_gc[state_type];
3220 gc3 = style->dark_gc[state_type];
3221 gc4 = style->light_gc[state_type];
3223 case GTK_SHADOW_OUT:
3224 gc1 = style->light_gc[state_type];
3225 gc2 = style->bg_gc[state_type];
3226 gc3 = style->dark_gc[state_type];
3227 gc4 = style->black_gc;
3229 case GTK_SHADOW_ETCHED_OUT:
3230 gc1 = style->light_gc[state_type];
3231 gc2 = style->dark_gc[state_type];
3232 gc3 = style->light_gc[state_type];
3233 gc4 = style->dark_gc[state_type];
3238 gdk_gc_set_clip_rectangle (gc1, area);
3239 gdk_gc_set_clip_rectangle (gc2, area);
3240 gdk_gc_set_clip_rectangle (gc3, area);
3241 gdk_gc_set_clip_rectangle (gc4, area);
3244 switch (shadow_type)
3246 case GTK_SHADOW_NONE:
3248 case GTK_SHADOW_OUT:
3249 case GTK_SHADOW_ETCHED_IN:
3250 case GTK_SHADOW_ETCHED_OUT:
3254 gdk_draw_line (window, gc1,
3255 x, y, x, y + height - 1);
3256 gdk_draw_line (window, gc2,
3257 x + 1, y, x + 1, y + height - 2);
3259 gdk_draw_line (window, gc3,
3260 x + 1, y + height - 2, x + width - 2, y + height - 2);
3261 gdk_draw_line (window, gc3,
3262 x + width - 2, y, x + width - 2, y + height - 2);
3263 gdk_draw_line (window, gc4,
3264 x, y + height - 1, x + width - 1, y + height - 1);
3265 gdk_draw_line (window, gc4,
3266 x + width - 1, y, x + width - 1, y + height - 1);
3269 gdk_draw_line (window, gc1,
3270 x, y, x + gap_x - 1, y);
3271 gdk_draw_line (window, gc2,
3272 x + 1, y + 1, x + gap_x - 1, y + 1);
3273 gdk_draw_line (window, gc2,
3274 x + gap_x, y, x + gap_x, y);
3276 if ((width - (gap_x + gap_width)) > 0)
3278 gdk_draw_line (window, gc1,
3279 x + gap_x + gap_width, y, x + width - 2, y);
3280 gdk_draw_line (window, gc2,
3281 x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
3282 gdk_draw_line (window, gc2,
3283 x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
3286 case GTK_POS_BOTTOM:
3287 gdk_draw_line (window, gc1,
3288 x, y, x + width - 1, y);
3289 gdk_draw_line (window, gc1,
3290 x, y, x, y + height - 1);
3291 gdk_draw_line (window, gc2,
3292 x + 1, y + 1, x + width - 2, y + 1);
3293 gdk_draw_line (window, gc2,
3294 x + 1, y + 1, x + 1, y + height - 1);
3296 gdk_draw_line (window, gc3,
3297 x + width - 2, y + 1, x + width - 2, y + height - 1);
3298 gdk_draw_line (window, gc4,
3299 x + width - 1, y, x + width - 1, y + height - 1);
3302 gdk_draw_line (window, gc4,
3303 x, y + height - 1, x + gap_x - 1, y + height - 1);
3304 gdk_draw_line (window, gc3,
3305 x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
3306 gdk_draw_line (window, gc3,
3307 x + gap_x, y + height - 1, x + gap_x, y + height - 1);
3309 if ((width - (gap_x + gap_width)) > 0)
3311 gdk_draw_line (window, gc4,
3312 x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
3313 gdk_draw_line (window, gc3,
3314 x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
3315 gdk_draw_line (window, gc3,
3316 x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
3320 gdk_draw_line (window, gc1,
3321 x, y, x + width - 1, y);
3322 gdk_draw_line (window, gc2,
3323 x, y + 1, x + width - 2, y + 1);
3325 gdk_draw_line (window, gc3,
3326 x, y + height - 2, x + width - 2, y + height - 2);
3327 gdk_draw_line (window, gc3,
3328 x + width - 2, y + 1, x + width - 2, y + height - 2);
3329 gdk_draw_line (window, gc4,
3330 x, y + height - 1, x + width - 1, y + height - 1);
3331 gdk_draw_line (window, gc4,
3332 x + width - 1, y, x + width - 1, y + height - 1);
3335 gdk_draw_line (window, gc1,
3336 x, y, x, y + gap_x - 1);
3337 gdk_draw_line (window, gc2,
3338 x + 1, y + 1, x + 1, y + gap_x - 1);
3339 gdk_draw_line (window, gc2,
3340 x, y + gap_x, x, y + gap_x);
3342 if ((width - (gap_x + gap_width)) > 0)
3344 gdk_draw_line (window, gc1,
3345 x, y + gap_x + gap_width, x, y + height - 2);
3346 gdk_draw_line (window, gc2,
3347 x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
3348 gdk_draw_line (window, gc2,
3349 x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
3353 gdk_draw_line (window, gc1,
3354 x, y, x + width - 1, y);
3355 gdk_draw_line (window, gc1,
3356 x, y, x, y + height - 1);
3357 gdk_draw_line (window, gc2,
3358 x + 1, y + 1, x + width - 1, y + 1);
3359 gdk_draw_line (window, gc2,
3360 x + 1, y + 1, x + 1, y + height - 2);
3362 gdk_draw_line (window, gc3,
3363 x + 1, y + height - 2, x + width - 1, y + height - 2);
3364 gdk_draw_line (window, gc4,
3365 x, y + height - 1, x + width - 1, y + height - 1);
3368 gdk_draw_line (window, gc4,
3369 x + width - 1, y, x + width - 1, y + gap_x - 1);
3370 gdk_draw_line (window, gc3,
3371 x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
3372 gdk_draw_line (window, gc3,
3373 x + width - 1, y + gap_x, x + width - 1, y + gap_x);
3375 if ((width - (gap_x + gap_width)) > 0)
3377 gdk_draw_line (window, gc4,
3378 x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
3379 gdk_draw_line (window, gc3,
3380 x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
3381 gdk_draw_line (window, gc3,
3382 x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
3390 gdk_gc_set_clip_rectangle (gc1, NULL);
3391 gdk_gc_set_clip_rectangle (gc2, NULL);
3392 gdk_gc_set_clip_rectangle (gc3, NULL);
3393 gdk_gc_set_clip_rectangle (gc4, NULL);
3398 gtk_default_draw_box_gap (GtkStyle *style,
3400 GtkStateType state_type,
3401 GtkShadowType shadow_type,
3404 const gchar *detail,
3409 GtkPositionType gap_side,
3418 g_return_if_fail (GTK_IS_STYLE (style));
3419 g_return_if_fail (window != NULL);
3421 gtk_style_apply_default_background (style, window,
3422 widget && !GTK_WIDGET_NO_WINDOW (widget),
3423 state_type, area, x, y, width, height);
3425 sanitize_size (window, &width, &height);
3427 switch (shadow_type)
3429 case GTK_SHADOW_NONE:
3432 gc1 = style->dark_gc[state_type];
3433 gc2 = style->black_gc;
3434 gc3 = style->bg_gc[state_type];
3435 gc4 = style->light_gc[state_type];
3437 case GTK_SHADOW_ETCHED_IN:
3438 gc1 = style->dark_gc[state_type];
3439 gc2 = style->light_gc[state_type];
3440 gc3 = style->dark_gc[state_type];
3441 gc4 = style->light_gc[state_type];
3443 case GTK_SHADOW_OUT:
3444 gc1 = style->light_gc[state_type];
3445 gc2 = style->bg_gc[state_type];
3446 gc3 = style->dark_gc[state_type];
3447 gc4 = style->black_gc;
3449 case GTK_SHADOW_ETCHED_OUT:
3450 gc1 = style->light_gc[state_type];
3451 gc2 = style->dark_gc[state_type];
3452 gc3 = style->light_gc[state_type];
3453 gc4 = style->dark_gc[state_type];
3459 gdk_gc_set_clip_rectangle (gc1, area);
3460 gdk_gc_set_clip_rectangle (gc2, area);
3461 gdk_gc_set_clip_rectangle (gc3, area);
3462 gdk_gc_set_clip_rectangle (gc4, area);
3465 switch (shadow_type)
3467 case GTK_SHADOW_NONE:
3469 case GTK_SHADOW_OUT:
3470 case GTK_SHADOW_ETCHED_IN:
3471 case GTK_SHADOW_ETCHED_OUT:
3475 gdk_draw_line (window, gc1,
3476 x, y, x, y + height - 1);
3477 gdk_draw_line (window, gc2,
3478 x + 1, y, x + 1, y + height - 2);
3480 gdk_draw_line (window, gc3,
3481 x + 1, y + height - 2, x + width - 2, y + height - 2);
3482 gdk_draw_line (window, gc3,
3483 x + width - 2, y, x + width - 2, y + height - 2);
3484 gdk_draw_line (window, gc4,
3485 x, y + height - 1, x + width - 1, y + height - 1);
3486 gdk_draw_line (window, gc4,
3487 x + width - 1, y, x + width - 1, y + height - 1);
3490 gdk_draw_line (window, gc1,
3491 x, y, x + gap_x - 1, y);
3492 gdk_draw_line (window, gc2,
3493 x + 1, y + 1, x + gap_x - 1, y + 1);
3494 gdk_draw_line (window, gc2,
3495 x + gap_x, y, x + gap_x, y);
3497 if ((width - (gap_x + gap_width)) > 0)
3499 gdk_draw_line (window, gc1,
3500 x + gap_x + gap_width, y, x + width - 2, y);
3501 gdk_draw_line (window, gc2,
3502 x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
3503 gdk_draw_line (window, gc2,
3504 x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
3507 case GTK_POS_BOTTOM:
3508 gdk_draw_line (window, gc1,
3509 x, y, x + width - 1, y);
3510 gdk_draw_line (window, gc1,
3511 x, y, x, y + height - 1);
3512 gdk_draw_line (window, gc2,
3513 x + 1, y + 1, x + width - 2, y + 1);
3514 gdk_draw_line (window, gc2,
3515 x + 1, y + 1, x + 1, y + height - 1);
3517 gdk_draw_line (window, gc3,
3518 x + width - 2, y + 1, x + width - 2, y + height - 1);
3519 gdk_draw_line (window, gc4,
3520 x + width - 1, y, x + width - 1, y + height - 1);
3523 gdk_draw_line (window, gc4,
3524 x, y + height - 1, x + gap_x - 1, y + height - 1);
3525 gdk_draw_line (window, gc3,
3526 x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
3527 gdk_draw_line (window, gc3,
3528 x + gap_x, y + height - 1, x + gap_x, y + height - 1);
3530 if ((width - (gap_x + gap_width)) > 0)
3532 gdk_draw_line (window, gc4,
3533 x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
3534 gdk_draw_line (window, gc3,
3535 x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
3536 gdk_draw_line (window, gc3,
3537 x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
3541 gdk_draw_line (window, gc1,
3542 x, y, x + width - 1, y);
3543 gdk_draw_line (window, gc2,
3544 x, y + 1, x + width - 2, y + 1);
3546 gdk_draw_line (window, gc3,
3547 x, y + height - 2, x + width - 2, y + height - 2);
3548 gdk_draw_line (window, gc3,
3549 x + width - 2, y + 1, x + width - 2, y + height - 2);
3550 gdk_draw_line (window, gc4,
3551 x, y + height - 1, x + width - 1, y + height - 1);
3552 gdk_draw_line (window, gc4,
3553 x + width - 1, y, x + width - 1, y + height - 1);
3556 gdk_draw_line (window, gc1,
3557 x, y, x, y + gap_x - 1);
3558 gdk_draw_line (window, gc2,
3559 x + 1, y + 1, x + 1, y + gap_x - 1);
3560 gdk_draw_line (window, gc2,
3561 x, y + gap_x, x, y + gap_x);
3563 if ((width - (gap_x + gap_width)) > 0)
3565 gdk_draw_line (window, gc1,
3566 x, y + gap_x + gap_width, x, y + height - 2);
3567 gdk_draw_line (window, gc2,
3568 x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
3569 gdk_draw_line (window, gc2,
3570 x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
3574 gdk_draw_line (window, gc1,
3575 x, y, x + width - 1, y);
3576 gdk_draw_line (window, gc1,
3577 x, y, x, y + height - 1);
3578 gdk_draw_line (window, gc2,
3579 x + 1, y + 1, x + width - 1, y + 1);
3580 gdk_draw_line (window, gc2,
3581 x + 1, y + 1, x + 1, y + height - 2);
3583 gdk_draw_line (window, gc3,
3584 x + 1, y + height - 2, x + width - 1, y + height - 2);
3585 gdk_draw_line (window, gc4,
3586 x, y + height - 1, x + width - 1, y + height - 1);
3589 gdk_draw_line (window, gc4,
3590 x + width - 1, y, x + width - 1, y + gap_x - 1);
3591 gdk_draw_line (window, gc3,
3592 x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
3593 gdk_draw_line (window, gc3,
3594 x + width - 1, y + gap_x, x + width - 1, y + gap_x);
3596 if ((width - (gap_x + gap_width)) > 0)
3598 gdk_draw_line (window, gc4,
3599 x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
3600 gdk_draw_line (window, gc3,
3601 x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
3602 gdk_draw_line (window, gc3,
3603 x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
3611 gdk_gc_set_clip_rectangle (gc1, NULL);
3612 gdk_gc_set_clip_rectangle (gc2, NULL);
3613 gdk_gc_set_clip_rectangle (gc3, NULL);
3614 gdk_gc_set_clip_rectangle (gc4, NULL);
3619 gtk_default_draw_extension (GtkStyle *style,
3621 GtkStateType state_type,
3622 GtkShadowType shadow_type,
3625 const gchar *detail,
3630 GtkPositionType gap_side)
3637 g_return_if_fail (GTK_IS_STYLE (style));
3638 g_return_if_fail (window != NULL);
3640 gtk_style_apply_default_background (style, window,
3641 widget && !GTK_WIDGET_NO_WINDOW (widget),
3642 GTK_STATE_NORMAL, area, x, y, width, height);
3644 sanitize_size (window, &width, &height);
3646 switch (shadow_type)
3648 case GTK_SHADOW_NONE:
3651 gc1 = style->dark_gc[state_type];
3652 gc2 = style->black_gc;
3653 gc3 = style->bg_gc[state_type];
3654 gc4 = style->light_gc[state_type];
3656 case GTK_SHADOW_ETCHED_IN:
3657 gc1 = style->dark_gc[state_type];
3658 gc2 = style->light_gc[state_type];
3659 gc3 = style->dark_gc[state_type];
3660 gc4 = style->light_gc[state_type];
3662 case GTK_SHADOW_OUT:
3663 gc1 = style->light_gc[state_type];
3664 gc2 = style->bg_gc[state_type];
3665 gc3 = style->dark_gc[state_type];
3666 gc4 = style->black_gc;
3668 case GTK_SHADOW_ETCHED_OUT:
3669 gc1 = style->light_gc[state_type];
3670 gc2 = style->dark_gc[state_type];
3671 gc3 = style->light_gc[state_type];
3672 gc4 = style->dark_gc[state_type];
3678 gdk_gc_set_clip_rectangle (gc1, area);
3679 gdk_gc_set_clip_rectangle (gc2, area);
3680 gdk_gc_set_clip_rectangle (gc3, area);
3681 gdk_gc_set_clip_rectangle (gc4, area);
3684 switch (shadow_type)
3686 case GTK_SHADOW_NONE:
3688 case GTK_SHADOW_OUT:
3689 case GTK_SHADOW_ETCHED_IN:
3690 case GTK_SHADOW_ETCHED_OUT:
3694 gtk_style_apply_default_background (style, window,
3695 widget && !GTK_WIDGET_NO_WINDOW (widget),
3697 x + style->xthickness,
3699 width - (2 * style->xthickness),
3700 height - (style->ythickness));
3701 gdk_draw_line (window, gc1,
3702 x, y, x, y + height - 2);
3703 gdk_draw_line (window, gc2,
3704 x + 1, y, x + 1, y + height - 2);
3706 gdk_draw_line (window, gc3,
3707 x + 2, y + height - 2, x + width - 2, y + height - 2);
3708 gdk_draw_line (window, gc3,
3709 x + width - 2, y, x + width - 2, y + height - 2);
3710 gdk_draw_line (window, gc4,
3711 x + 1, y + height - 1, x + width - 2, y + height - 1);
3712 gdk_draw_line (window, gc4,
3713 x + width - 1, y, x + width - 1, y + height - 2);
3715 case GTK_POS_BOTTOM:
3716 gtk_style_apply_default_background (style, window,
3717 widget && !GTK_WIDGET_NO_WINDOW (widget),
3719 x + style->xthickness,
3720 y + style->ythickness,
3721 width - (2 * style->xthickness),
3722 height - (style->ythickness));
3723 gdk_draw_line (window, gc1,
3724 x + 1, y, x + width - 2, y);
3725 gdk_draw_line (window, gc1,
3726 x, y + 1, x, y + height - 1);
3727 gdk_draw_line (window, gc2,
3728 x + 1, y + 1, x + width - 2, y + 1);
3729 gdk_draw_line (window, gc2,
3730 x + 1, y + 1, x + 1, y + height - 1);
3732 gdk_draw_line (window, gc3,
3733 x + width - 2, y + 2, x + width - 2, y + height - 1);
3734 gdk_draw_line (window, gc4,
3735 x + width - 1, y + 1, x + width - 1, y + height - 1);
3738 gtk_style_apply_default_background (style, window,
3739 widget && !GTK_WIDGET_NO_WINDOW (widget),
3742 y + style->ythickness,
3743 width - (style->xthickness),
3744 height - (2 * style->ythickness));
3745 gdk_draw_line (window, gc1,
3746 x, y, x + width - 2, y);
3747 gdk_draw_line (window, gc2,
3748 x + 1, y + 1, x + width - 2, y + 1);
3750 gdk_draw_line (window, gc3,
3751 x, y + height - 2, x + width - 2, y + height - 2);
3752 gdk_draw_line (window, gc3,
3753 x + width - 2, y + 2, x + width - 2, y + height - 2);
3754 gdk_draw_line (window, gc4,
3755 x, y + height - 1, x + width - 2, y + height - 1);
3756 gdk_draw_line (window, gc4,
3757 x + width - 1, y + 1, x + width - 1, y + height - 2);
3760 gtk_style_apply_default_background (style, window,
3761 widget && !GTK_WIDGET_NO_WINDOW (widget),
3763 x + style->xthickness,
3764 y + style->ythickness,
3765 width - (style->xthickness),
3766 height - (2 * style->ythickness));
3767 gdk_draw_line (window, gc1,
3768 x + 1, y, x + width - 1, y);
3769 gdk_draw_line (window, gc1,
3770 x, y + 1, x, y + height - 2);
3771 gdk_draw_line (window, gc2,
3772 x + 1, y + 1, x + width - 1, y + 1);
3773 gdk_draw_line (window, gc2,
3774 x + 1, y + 1, x + 1, y + height - 2);
3776 gdk_draw_line (window, gc3,
3777 x + 2, y + height - 2, x + width - 1, y + height - 2);
3778 gdk_draw_line (window, gc4,
3779 x + 1, y + height - 1, x + width - 1, y + height - 1);
3786 gdk_gc_set_clip_rectangle (gc1, NULL);
3787 gdk_gc_set_clip_rectangle (gc2, NULL);
3788 gdk_gc_set_clip_rectangle (gc3, NULL);
3789 gdk_gc_set_clip_rectangle (gc4, NULL);
3794 gtk_default_draw_focus (GtkStyle *style,
3798 const gchar *detail,
3806 sanitize_size (window, &width, &height);
3809 gdk_gc_set_clip_rectangle (style->black_gc, area);
3811 gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_ON_OFF_DASH, 0, 0);
3813 if (detail && !strcmp (detail, "add-mode"))
3814 gdk_gc_set_dashes (style->black_gc, 0, "\4\4", 2);
3816 gdk_gc_set_dashes (style->black_gc, 0, "\1\1", 2);
3820 points[1].x = x + width;
3822 points[2].x = x + width;
3823 points[2].y = y + height;
3825 points[3].y = y + height;
3826 points[4] = points[0];
3828 gdk_draw_polygon (window, style->black_gc, FALSE, points, 4);
3829 gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_SOLID, 0, 0);
3832 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
3836 gtk_default_draw_slider (GtkStyle *style,
3838 GtkStateType state_type,
3839 GtkShadowType shadow_type,
3842 const gchar *detail,
3847 GtkOrientation orientation)
3849 g_return_if_fail (GTK_IS_STYLE (style));
3850 g_return_if_fail (window != NULL);
3852 sanitize_size (window, &width, &height);
3854 gtk_paint_box (style, window, state_type, shadow_type,
3855 area, widget, detail, x, y, width, height);
3858 (strcmp ("hscale", detail) == 0 ||
3859 strcmp ("vscale", detail) == 0))
3861 if (orientation == GTK_ORIENTATION_HORIZONTAL)
3862 gtk_paint_vline (style, window, state_type, area, widget, detail,
3863 y + style->ythickness,
3864 y + height - style->ythickness - 1, x + width / 2);
3866 gtk_paint_hline (style, window, state_type, area, widget, detail,
3867 x + style->xthickness,
3868 x + width - style->xthickness - 1, y + height / 2);
3873 draw_dot (GdkWindow *window,
3881 size = CLAMP (size, 2, 3);
3885 gdk_draw_point (window, light_gc, x, y);
3886 gdk_draw_point (window, light_gc, x+1, y+1);
3888 else if (size == 3);
3890 gdk_draw_point (window, light_gc, x, y);
3891 gdk_draw_point (window, light_gc, x+1, y);
3892 gdk_draw_point (window, light_gc, x, y+1);
3893 gdk_draw_point (window, dark_gc, x+1, y+2);
3894 gdk_draw_point (window, dark_gc, x+2, y+1);
3895 gdk_draw_point (window, dark_gc, x+2, y+2);
3900 gtk_default_draw_handle (GtkStyle *style,
3902 GtkStateType state_type,
3903 GtkShadowType shadow_type,
3906 const gchar *detail,
3911 GtkOrientation orientation)
3914 gint xthick, ythick;
3915 GdkGC *light_gc, *dark_gc;
3920 g_return_if_fail (GTK_IS_STYLE (style));
3921 g_return_if_fail (window != NULL);
3923 sanitize_size (window, &width, &height);
3925 gtk_paint_box (style, window, state_type, shadow_type, area, widget,
3926 detail, x, y, width, height);
3929 if (!strcmp (detail, "paned"))
3931 /* we want to ignore the shadow border in paned widgets */
3935 light_gc = style->light_gc[state_type];
3936 dark_gc = style->black_gc;
3940 xthick = style->xthickness;
3941 ythick = style->ythickness;
3943 light_gc = style->light_gc[state_type];
3944 dark_gc = style->dark_gc[state_type];
3947 rect.x = x + xthick;
3948 rect.y = y + ythick;
3949 rect.width = width - (xthick * 2);
3950 rect.height = height - (ythick * 2);
3953 intersect = gdk_rectangle_intersect (area, &rect, &dest);
3963 gdk_gc_set_clip_rectangle (light_gc, &dest);
3964 gdk_gc_set_clip_rectangle (dark_gc, &dest);
3966 if (!strcmp (detail, "paned"))
3971 gdk_window_get_size (window, &window_width, &window_height);
3973 if (orientation == GTK_ORIENTATION_HORIZONTAL)
3974 for (xx = window_width/2 - 15; xx <= window_width/2 + 15; xx += 5)
3975 draw_dot (window, light_gc, dark_gc, xx, window_height/2 - 1, 3);
3977 for (yy = window_height/2 - 15; yy <= window_height/2 + 15; yy += 5)
3978 draw_dot (window, light_gc, dark_gc, window_width/2 - 1, yy, 3);
3982 for (yy = y + ythick; yy < (y + height - ythick); yy += 3)
3983 for (xx = x + xthick; xx < (x + width - xthick); xx += 6)
3985 draw_dot (window, light_gc, dark_gc, xx, yy, 2);
3986 draw_dot (window, light_gc, dark_gc, xx + 3, yy + 1, 2);
3990 gdk_gc_set_clip_rectangle (light_gc, NULL);
3991 gdk_gc_set_clip_rectangle (dark_gc, NULL);
3995 gtk_default_draw_expander (GtkStyle *style,
3997 GtkStateType state_type,
4000 const gchar *detail,
4005 /* FIXME replace macro with a style property */
4012 gdk_gc_set_clip_rectangle (style->fg_gc[GTK_STATE_NORMAL], area);
4013 gdk_gc_set_clip_rectangle (style->base_gc[GTK_STATE_NORMAL], area);
4019 points[0].y = y + (PM_SIZE + 2) / 6;
4020 points[1].x = points[0].x + 1 * (PM_SIZE + 2);
4021 points[1].y = points[0].y;
4022 points[2].x = (points[0].x + 1 * (PM_SIZE + 2) / 2);
4023 points[2].y = y + 2 * (PM_SIZE + 2) / 3;
4027 points[0].x = x + 1 * ((PM_SIZE + 2) / 6 + 2);
4028 points[0].y = y - 1;
4029 points[1].x = points[0].x;
4030 points[1].y = points[0].y + (PM_SIZE + 2);
4031 points[2].x = (points[0].x + 1 * (2 * (PM_SIZE + 2) / 3 - 1));
4032 points[2].y = points[0].y + (PM_SIZE + 2) / 2;
4035 gdk_draw_polygon (window, style->base_gc[GTK_STATE_NORMAL],
4037 gdk_draw_polygon (window, style->fg_gc[GTK_STATE_NORMAL],
4043 gdk_gc_set_clip_rectangle (style->fg_gc[GTK_STATE_NORMAL], NULL);
4044 gdk_gc_set_clip_rectangle (style->base_gc[GTK_STATE_NORMAL], NULL);
4050 typedef struct _ByteRange ByteRange;
4059 range_new (guint start,
4062 ByteRange *br = g_new (ByteRange, 1);
4071 get_insensitive_layout (PangoLayout *layout)
4073 GSList *embossed_ranges = NULL;
4074 GSList *stippled_ranges = NULL;
4075 PangoLayoutIter *iter;
4076 GSList *tmp_list = NULL;
4077 PangoLayout *new_layout;
4078 PangoAttrList *attrs;
4079 GdkBitmap *stipple = NULL;
4081 iter = pango_layout_get_iter (layout);
4085 PangoLayoutRun *run;
4086 PangoAttribute *attr;
4087 gboolean need_stipple = FALSE;
4090 run = pango_layout_iter_get_run (iter);
4094 tmp_list = run->item->analysis.extra_attrs;
4096 while (tmp_list != NULL)
4098 attr = tmp_list->data;
4099 switch (attr->klass->type)
4101 case PANGO_ATTR_FOREGROUND:
4102 case PANGO_ATTR_BACKGROUND:
4103 need_stipple = TRUE;
4113 tmp_list = g_slist_next (tmp_list);
4116 br = range_new (run->item->offset, run->item->offset + run->item->length);
4119 stippled_ranges = g_slist_prepend (stippled_ranges, br);
4121 embossed_ranges = g_slist_prepend (embossed_ranges, br);
4124 while (pango_layout_iter_next_run (iter));
4126 pango_layout_iter_free (iter);
4128 new_layout = pango_layout_copy (layout);
4130 attrs = pango_layout_get_attributes (new_layout);
4134 /* Create attr list if there wasn't one */
4135 attrs = pango_attr_list_new ();
4136 pango_layout_set_attributes (new_layout, attrs);
4137 pango_attr_list_unref (attrs);
4140 tmp_list = embossed_ranges;
4141 while (tmp_list != NULL)
4143 PangoAttribute *attr;
4144 ByteRange *br = tmp_list->data;
4146 attr = gdk_pango_attr_embossed_new (TRUE);
4148 attr->start_index = br->start;
4149 attr->end_index = br->end;
4151 pango_attr_list_change (attrs, attr);
4155 tmp_list = g_slist_next (tmp_list);
4158 g_slist_free (embossed_ranges);
4160 tmp_list = stippled_ranges;
4161 while (tmp_list != NULL)
4163 PangoAttribute *attr;
4164 ByteRange *br = tmp_list->data;
4166 if (stipple == NULL)
4168 #define gray50_width 2
4169 #define gray50_height 2
4170 static char gray50_bits[] = {
4174 stipple = gdk_bitmap_create_from_data (NULL,
4175 gray50_bits, gray50_width,
4179 attr = gdk_pango_attr_stipple_new (stipple);
4181 attr->start_index = br->start;
4182 attr->end_index = br->end;
4184 pango_attr_list_change (attrs, attr);
4188 tmp_list = g_slist_next (tmp_list);
4191 g_slist_free (stippled_ranges);
4194 g_object_unref (G_OBJECT (stipple));
4200 gtk_default_draw_layout (GtkStyle *style,
4202 GtkStateType state_type,
4206 const gchar *detail,
4209 PangoLayout *layout)
4213 g_return_if_fail (GTK_IS_STYLE (style));
4214 g_return_if_fail (window != NULL);
4216 gc = use_text ? style->text_gc[state_type] : style->fg_gc[state_type];
4219 gdk_gc_set_clip_rectangle (gc, area);
4221 if (state_type == GTK_STATE_INSENSITIVE)
4225 ins = get_insensitive_layout (layout);
4227 gdk_draw_layout (window, gc, x, y, ins);
4229 g_object_unref (G_OBJECT (ins));
4233 gdk_draw_layout (window, gc, x, y, layout);
4237 gdk_gc_set_clip_rectangle (gc, NULL);
4241 gtk_default_draw_resize_grip (GtkStyle *style,
4243 GtkStateType state_type,
4246 const gchar *detail,
4253 g_return_if_fail (GTK_IS_STYLE (style));
4254 g_return_if_fail (window != NULL);
4258 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
4259 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
4260 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
4263 /* make it square, aligning to bottom right */
4266 y += (height - width);
4269 else if (height < width)
4271 x += (width - height);
4275 /* Clear background */
4276 gdk_draw_rectangle (window,
4277 style->bg_gc[state_type],
4279 x, y, width, height);
4283 case GDK_WINDOW_EDGE_SOUTH_EAST:
4290 while (xi < (x + width - 3))
4292 gdk_draw_line (window,
4293 style->light_gc[state_type],
4300 gdk_draw_line (window,
4301 style->dark_gc[state_type],
4308 gdk_draw_line (window,
4309 style->dark_gc[state_type],
4319 g_assert_not_reached ();
4325 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
4326 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
4327 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
4332 gtk_style_shade (GdkColor *a,
4340 red = (gdouble) a->red / 65535.0;
4341 green = (gdouble) a->green / 65535.0;
4342 blue = (gdouble) a->blue / 65535.0;
4344 rgb_to_hls (&red, &green, &blue);
4349 else if (green < 0.0)
4355 else if (blue < 0.0)
4358 hls_to_rgb (&red, &green, &blue);
4360 b->red = red * 65535.0;
4361 b->green = green * 65535.0;
4362 b->blue = blue * 65535.0;
4366 rgb_to_hls (gdouble *r,
4407 l = (max + min) / 2;
4414 s = (max - min) / (max + min);
4416 s = (max - min) / (2 - max - min);
4420 h = (green - blue) / delta;
4421 else if (green == max)
4422 h = 2 + (blue - red) / delta;
4423 else if (blue == max)
4424 h = 4 + (red - green) / delta;
4437 hls_to_rgb (gdouble *h,
4450 if (lightness <= 0.5)
4451 m2 = lightness * (1 + saturation);
4453 m2 = lightness + saturation - lightness * saturation;
4454 m1 = 2 * lightness - m2;
4456 if (saturation == 0)
4471 r = m1 + (m2 - m1) * hue / 60;
4475 r = m1 + (m2 - m1) * (240 - hue) / 60;
4486 g = m1 + (m2 - m1) * hue / 60;
4490 g = m1 + (m2 - m1) * (240 - hue) / 60;
4501 b = m1 + (m2 - m1) * hue / 60;
4505 b = m1 + (m2 - m1) * (240 - hue) / 60;
4516 gtk_paint_hline (GtkStyle *style,
4518 GtkStateType state_type,
4521 const gchar *detail,
4526 g_return_if_fail (GTK_IS_STYLE (style));
4527 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_hline != NULL);
4529 GTK_STYLE_GET_CLASS (style)->draw_hline (style, window, state_type, area, widget, detail, x1, x2, y);
4533 gtk_paint_vline (GtkStyle *style,
4535 GtkStateType state_type,
4538 const gchar *detail,
4543 g_return_if_fail (GTK_IS_STYLE (style));
4544 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_vline != NULL);
4546 GTK_STYLE_GET_CLASS (style)->draw_vline (style, window, state_type, area, widget, detail, y1, y2, x);
4550 gtk_paint_shadow (GtkStyle *style,
4552 GtkStateType state_type,
4553 GtkShadowType shadow_type,
4556 const gchar *detail,
4562 g_return_if_fail (GTK_IS_STYLE (style));
4563 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow != NULL);
4565 GTK_STYLE_GET_CLASS (style)->draw_shadow (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4569 gtk_paint_polygon (GtkStyle *style,
4571 GtkStateType state_type,
4572 GtkShadowType shadow_type,
4575 const gchar *detail,
4580 g_return_if_fail (GTK_IS_STYLE (style));
4581 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow != NULL);
4583 GTK_STYLE_GET_CLASS (style)->draw_polygon (style, window, state_type, shadow_type, area, widget, detail, points, npoints, fill);
4587 gtk_paint_arrow (GtkStyle *style,
4589 GtkStateType state_type,
4590 GtkShadowType shadow_type,
4593 const gchar *detail,
4594 GtkArrowType arrow_type,
4601 g_return_if_fail (GTK_IS_STYLE (style));
4602 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_arrow != NULL);
4604 GTK_STYLE_GET_CLASS (style)->draw_arrow (style, window, state_type, shadow_type, area, widget, detail, arrow_type, fill, x, y, width, height);
4608 gtk_paint_diamond (GtkStyle *style,
4610 GtkStateType state_type,
4611 GtkShadowType shadow_type,
4614 const gchar *detail,
4620 g_return_if_fail (GTK_IS_STYLE (style));
4621 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_diamond != NULL);
4623 GTK_STYLE_GET_CLASS (style)->draw_diamond (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4627 gtk_paint_string (GtkStyle *style,
4629 GtkStateType state_type,
4632 const gchar *detail,
4635 const gchar *string)
4637 g_return_if_fail (GTK_IS_STYLE (style));
4638 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_string != NULL);
4640 GTK_STYLE_GET_CLASS (style)->draw_string (style, window, state_type, area, widget, detail, x, y, string);
4644 gtk_paint_box (GtkStyle *style,
4646 GtkStateType state_type,
4647 GtkShadowType shadow_type,
4650 const gchar *detail,
4656 g_return_if_fail (GTK_IS_STYLE (style));
4657 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box != NULL);
4659 GTK_STYLE_GET_CLASS (style)->draw_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4663 gtk_paint_flat_box (GtkStyle *style,
4665 GtkStateType state_type,
4666 GtkShadowType shadow_type,
4669 const gchar *detail,
4675 g_return_if_fail (GTK_IS_STYLE (style));
4676 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_flat_box != NULL);
4678 GTK_STYLE_GET_CLASS (style)->draw_flat_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4682 gtk_paint_check (GtkStyle *style,
4684 GtkStateType state_type,
4685 GtkShadowType shadow_type,
4688 const gchar *detail,
4694 g_return_if_fail (GTK_IS_STYLE (style));
4695 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_check != NULL);
4697 GTK_STYLE_GET_CLASS (style)->draw_check (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4701 gtk_paint_option (GtkStyle *style,
4703 GtkStateType state_type,
4704 GtkShadowType shadow_type,
4707 const gchar *detail,
4713 g_return_if_fail (GTK_IS_STYLE (style));
4714 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_option != NULL);
4716 GTK_STYLE_GET_CLASS (style)->draw_option (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4720 gtk_paint_tab (GtkStyle *style,
4722 GtkStateType state_type,
4723 GtkShadowType shadow_type,
4726 const gchar *detail,
4732 g_return_if_fail (GTK_IS_STYLE (style));
4733 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_tab != NULL);
4735 GTK_STYLE_GET_CLASS (style)->draw_tab (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4739 gtk_paint_shadow_gap (GtkStyle *style,
4741 GtkStateType state_type,
4742 GtkShadowType shadow_type,
4750 GtkPositionType gap_side,
4754 g_return_if_fail (GTK_IS_STYLE (style));
4755 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow_gap != NULL);
4757 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);
4762 gtk_paint_box_gap (GtkStyle *style,
4764 GtkStateType state_type,
4765 GtkShadowType shadow_type,
4773 GtkPositionType gap_side,
4777 g_return_if_fail (GTK_IS_STYLE (style));
4778 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box_gap != NULL);
4780 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);
4784 gtk_paint_extension (GtkStyle *style,
4786 GtkStateType state_type,
4787 GtkShadowType shadow_type,
4795 GtkPositionType gap_side)
4797 g_return_if_fail (GTK_IS_STYLE (style));
4798 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_extension != NULL);
4800 GTK_STYLE_GET_CLASS (style)->draw_extension (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side);
4804 gtk_paint_focus (GtkStyle *style,
4808 const gchar *detail,
4814 g_return_if_fail (GTK_IS_STYLE (style));
4815 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_focus != NULL);
4817 GTK_STYLE_GET_CLASS (style)->draw_focus (style, window, area, widget, detail, x, y, width, height);
4821 gtk_paint_slider (GtkStyle *style,
4823 GtkStateType state_type,
4824 GtkShadowType shadow_type,
4827 const gchar *detail,
4832 GtkOrientation orientation)
4834 g_return_if_fail (GTK_IS_STYLE (style));
4835 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_slider != NULL);
4837 GTK_STYLE_GET_CLASS (style)->draw_slider (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
4841 gtk_paint_handle (GtkStyle *style,
4843 GtkStateType state_type,
4844 GtkShadowType shadow_type,
4847 const gchar *detail,
4852 GtkOrientation orientation)
4854 g_return_if_fail (GTK_IS_STYLE (style));
4855 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_handle != NULL);
4857 GTK_STYLE_GET_CLASS (style)->draw_handle (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
4861 gtk_paint_expander (GtkStyle *style,
4863 GtkStateType state_type,
4866 const gchar *detail,
4871 g_return_if_fail (GTK_IS_STYLE (style));
4872 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_expander != NULL);
4874 GTK_STYLE_GET_CLASS (style)->draw_expander (style, window, state_type, area,
4875 widget, detail, x, y, is_open);
4879 gtk_paint_layout (GtkStyle *style,
4881 GtkStateType state_type,
4885 const gchar *detail,
4888 PangoLayout *layout)
4890 g_return_if_fail (GTK_IS_STYLE (style));
4891 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_layout != NULL);
4893 GTK_STYLE_GET_CLASS (style)->draw_layout (style, window, state_type, use_text, area,
4894 widget, detail, x, y, layout);
4898 gtk_paint_resize_grip (GtkStyle *style,
4900 GtkStateType state_type,
4903 const gchar *detail,
4911 g_return_if_fail (GTK_IS_STYLE (style));
4912 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_resize_grip != NULL);
4914 GTK_STYLE_GET_CLASS (style)->draw_resize_grip (style, window, state_type,
4915 area, widget, detail,
4916 edge, x, y, width, height);
4920 gtk_border_copy (const GtkBorder *border)
4922 return (GtkBorder *)g_memdup (border, sizeof (GtkBorder));
4926 gtk_border_free (GtkBorder *border)