1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
32 #include "gtkspinbutton.h"
34 #include "gtkwidget.h"
35 #include "gtkthemes.h"
36 #include "gtkiconfactory.h"
37 #include "gtksettings.h" /* _gtk_settings_parse_convert() */
39 #define LIGHTNESS_MULT 1.3
40 #define DARKNESS_MULT 0.7
42 /* --- typedefs & structures --- */
50 /* --- prototypes --- */
51 static void gtk_style_init (GtkStyle *style);
52 static void gtk_style_class_init (GtkStyleClass *klass);
53 static void gtk_style_finalize (GObject *object);
54 static void gtk_style_realize (GtkStyle *style,
55 GdkColormap *colormap);
56 static void gtk_style_real_realize (GtkStyle *style);
57 static void gtk_style_real_unrealize (GtkStyle *style);
58 static void gtk_style_real_copy (GtkStyle *style,
60 static void gtk_style_real_set_background (GtkStyle *style,
62 GtkStateType state_type);
63 static GtkStyle *gtk_style_real_clone (GtkStyle *style);
64 static void gtk_style_real_init_from_rc (GtkStyle *style,
65 GtkRcStyle *rc_style);
66 static GdkPixbuf *gtk_default_render_icon (GtkStyle *style,
67 const GtkIconSource *source,
68 GtkTextDirection direction,
73 static void gtk_default_draw_hline (GtkStyle *style,
75 GtkStateType state_type,
82 static void gtk_default_draw_vline (GtkStyle *style,
84 GtkStateType state_type,
91 static void gtk_default_draw_shadow (GtkStyle *style,
93 GtkStateType state_type,
94 GtkShadowType shadow_type,
102 static void gtk_default_draw_polygon (GtkStyle *style,
104 GtkStateType state_type,
105 GtkShadowType shadow_type,
112 static void gtk_default_draw_arrow (GtkStyle *style,
114 GtkStateType state_type,
115 GtkShadowType shadow_type,
119 GtkArrowType arrow_type,
125 static void gtk_default_draw_diamond (GtkStyle *style,
127 GtkStateType state_type,
128 GtkShadowType shadow_type,
136 static void gtk_default_draw_string (GtkStyle *style,
138 GtkStateType state_type,
144 const gchar *string);
145 static void gtk_default_draw_box (GtkStyle *style,
147 GtkStateType state_type,
148 GtkShadowType shadow_type,
156 static void gtk_default_draw_flat_box (GtkStyle *style,
158 GtkStateType state_type,
159 GtkShadowType shadow_type,
167 static void gtk_default_draw_check (GtkStyle *style,
169 GtkStateType state_type,
170 GtkShadowType shadow_type,
178 static void gtk_default_draw_option (GtkStyle *style,
180 GtkStateType state_type,
181 GtkShadowType shadow_type,
189 static void gtk_default_draw_tab (GtkStyle *style,
191 GtkStateType state_type,
192 GtkShadowType shadow_type,
200 static void gtk_default_draw_shadow_gap (GtkStyle *style,
202 GtkStateType state_type,
203 GtkShadowType shadow_type,
211 GtkPositionType gap_side,
214 static void gtk_default_draw_box_gap (GtkStyle *style,
216 GtkStateType state_type,
217 GtkShadowType shadow_type,
225 GtkPositionType gap_side,
228 static void gtk_default_draw_extension (GtkStyle *style,
230 GtkStateType state_type,
231 GtkShadowType shadow_type,
239 GtkPositionType gap_side);
240 static void gtk_default_draw_focus (GtkStyle *style,
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,
281 GtkExpanderStyle expander_style);
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 };
411 static GdkColor gtk_default_selected_base = { 0, 0xa4a4, 0xdfdf, 0xffff };
412 static GdkColor gtk_default_active_base = { 0, 0xbcbc, 0xd2d2, 0xeeee };
414 static gpointer parent_class = NULL;
415 static GdkFont *static_default_font = NULL;
418 /* --- functions --- */
420 gtk_style_get_type (void)
422 static GType style_type = 0;
426 static const GTypeInfo style_info =
428 sizeof (GtkStyleClass),
429 (GBaseInitFunc) NULL,
430 (GBaseFinalizeFunc) NULL,
431 (GClassInitFunc) gtk_style_class_init,
432 NULL, /* class_finalize */
433 NULL, /* class_data */
436 (GInstanceInitFunc) gtk_style_init,
439 style_type = g_type_register_static (G_TYPE_OBJECT,
448 gtk_style_init (GtkStyle *style)
452 style->font_desc = pango_font_description_from_string ("Sans 10");
454 if (!static_default_font)
456 static_default_font = gdk_font_from_description (style->font_desc);
458 if (!static_default_font)
459 static_default_font = gdk_font_load ("fixed");
461 if (!static_default_font)
462 g_error ("Unable to load \"fixed\" font");
465 style->font = static_default_font;
466 gdk_font_ref (style->font);
468 style->attach_count = 0;
469 style->colormap = NULL;
472 style->black.red = 0;
473 style->black.green = 0;
474 style->black.blue = 0;
476 style->white.red = 65535;
477 style->white.green = 65535;
478 style->white.blue = 65535;
480 style->black_gc = NULL;
481 style->white_gc = NULL;
483 style->fg[GTK_STATE_NORMAL] = gtk_default_normal_fg;
484 style->fg[GTK_STATE_ACTIVE] = gtk_default_active_fg;
485 style->fg[GTK_STATE_PRELIGHT] = gtk_default_prelight_fg;
486 style->fg[GTK_STATE_SELECTED] = gtk_default_selected_fg;
487 style->fg[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_fg;
489 style->bg[GTK_STATE_NORMAL] = gtk_default_normal_bg;
490 style->bg[GTK_STATE_ACTIVE] = gtk_default_active_bg;
491 style->bg[GTK_STATE_PRELIGHT] = gtk_default_prelight_bg;
492 style->bg[GTK_STATE_SELECTED] = gtk_default_selected_bg;
493 style->bg[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_bg;
495 for (i = 0; i < 4; i++)
497 style->text[i] = style->fg[i];
498 style->base[i] = style->white;
501 style->base[GTK_STATE_SELECTED] = gtk_default_selected_base;
502 style->text[GTK_STATE_SELECTED] = style->black;
503 style->base[GTK_STATE_ACTIVE] = gtk_default_active_base;
504 style->text[GTK_STATE_ACTIVE] = style->black;
505 style->base[GTK_STATE_INSENSITIVE] = gtk_default_prelight_bg;
506 style->text[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_fg;
508 for (i = 0; i < 5; i++)
509 style->bg_pixmap[i] = NULL;
511 style->rc_style = NULL;
513 for (i = 0; i < 5; i++)
515 style->fg_gc[i] = NULL;
516 style->bg_gc[i] = NULL;
517 style->light_gc[i] = NULL;
518 style->dark_gc[i] = NULL;
519 style->mid_gc[i] = NULL;
520 style->text_gc[i] = NULL;
521 style->base_gc[i] = NULL;
522 style->text_aa_gc[i] = NULL;
525 style->xthickness = 2;
526 style->ythickness = 2;
528 style->property_cache = NULL;
532 gtk_style_class_init (GtkStyleClass *klass)
534 GObjectClass *object_class = G_OBJECT_CLASS (klass);
536 parent_class = g_type_class_peek_parent (klass);
538 object_class->finalize = gtk_style_finalize;
540 klass->clone = gtk_style_real_clone;
541 klass->copy = gtk_style_real_copy;
542 klass->init_from_rc = gtk_style_real_init_from_rc;
543 klass->realize = gtk_style_real_realize;
544 klass->unrealize = gtk_style_real_unrealize;
545 klass->set_background = gtk_style_real_set_background;
546 klass->render_icon = gtk_default_render_icon;
548 klass->draw_hline = gtk_default_draw_hline;
549 klass->draw_vline = gtk_default_draw_vline;
550 klass->draw_shadow = gtk_default_draw_shadow;
551 klass->draw_polygon = gtk_default_draw_polygon;
552 klass->draw_arrow = gtk_default_draw_arrow;
553 klass->draw_diamond = gtk_default_draw_diamond;
554 klass->draw_string = gtk_default_draw_string;
555 klass->draw_box = gtk_default_draw_box;
556 klass->draw_flat_box = gtk_default_draw_flat_box;
557 klass->draw_check = gtk_default_draw_check;
558 klass->draw_option = gtk_default_draw_option;
559 klass->draw_tab = gtk_default_draw_tab;
560 klass->draw_shadow_gap = gtk_default_draw_shadow_gap;
561 klass->draw_box_gap = gtk_default_draw_box_gap;
562 klass->draw_extension = gtk_default_draw_extension;
563 klass->draw_focus = gtk_default_draw_focus;
564 klass->draw_slider = gtk_default_draw_slider;
565 klass->draw_handle = gtk_default_draw_handle;
566 klass->draw_expander = gtk_default_draw_expander;
567 klass->draw_layout = gtk_default_draw_layout;
568 klass->draw_resize_grip = gtk_default_draw_resize_grip;
572 clear_property_cache (GtkStyle *style)
574 if (style->property_cache)
578 for (i = 0; i < style->property_cache->len; i++)
580 PropertyValue *node = &g_array_index (style->property_cache, PropertyValue, i);
582 g_param_spec_unref (node->pspec);
583 g_value_unset (&node->value);
585 g_array_free (style->property_cache, TRUE);
586 style->property_cache = NULL;
591 gtk_style_finalize (GObject *object)
593 GtkStyle *style = GTK_STYLE (object);
595 g_return_if_fail (style->attach_count == 0);
597 clear_property_cache (style);
601 if (style->styles->data != style)
602 g_slist_remove (style->styles, style);
605 GSList *tmp_list = style->styles->next;
609 GTK_STYLE (tmp_list->data)->styles = style->styles->next;
610 tmp_list = tmp_list->next;
612 g_slist_free_1 (style->styles);
616 gdk_font_unref (style->font);
617 pango_font_description_free (style->font_desc);
620 gtk_rc_style_unref (style->rc_style);
622 G_OBJECT_CLASS (parent_class)->finalize (object);
627 gtk_style_copy (GtkStyle *style)
631 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
633 new_style = GTK_STYLE_GET_CLASS (style)->clone (style);
634 GTK_STYLE_GET_CLASS (style)->copy (new_style, style);
640 gtk_style_duplicate (GtkStyle *style)
644 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
646 new_style = gtk_style_copy (style);
648 style->styles = g_slist_append (style->styles, new_style);
649 new_style->styles = style->styles;
659 style = g_object_new (GTK_TYPE_STYLE, NULL);
664 /*************************************************************
666 * Attach a style to a window; this process allocates the
667 * colors and creates the GC's for the style - it specializes
668 * it to a particular visual and colormap. The process
669 * may involve the creation of a new style if the style
670 * has already been attached to a window with a different
671 * style and colormap.
676 * Either the style parameter, or a newly created style.
677 * If the style is newly created, the style parameter
678 * will be dereferenced, and the new style will have
679 * a reference count belonging to the caller.
681 * FIXME: The sequence -
682 * create a style => s1
683 * attach s1 to v1, c1 => s1
684 * attach s1 to v2, c2 => s2
685 * detach s1 from v1, c1
686 * attach s1 to v2, c2 => s3
687 * results in two separate, unlinked styles s2 and s3 which
688 * are identical and could be shared. To fix this, we would
689 * want to never remove a style from the list of linked
690 * styles as long as as it has a reference count. However, the
691 * disadvantage of doing it this way means that we would need two
692 * passes through the linked list when attaching (one to check for
693 * matching styles, one to look for empty unattached styles - but
694 * it will almost never be longer than 2 elements.
695 *************************************************************/
698 gtk_style_attach (GtkStyle *style,
702 GtkStyle *new_style = NULL;
703 GdkColormap *colormap;
705 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
706 g_return_val_if_fail (window != NULL, NULL);
708 colormap = gdk_window_get_colormap (window);
711 style->styles = g_slist_append (NULL, style);
713 styles = style->styles;
716 new_style = styles->data;
718 if (new_style->attach_count == 0)
720 gtk_style_realize (new_style, colormap);
723 else if (new_style->colormap == colormap)
727 styles = styles->next;
732 new_style = gtk_style_duplicate (style);
733 gtk_style_realize (new_style, colormap);
736 /* A style gets a refcount from being attached */
737 if (new_style->attach_count == 0)
738 gtk_style_ref (new_style);
740 /* Another refcount belongs to the parent */
741 if (style != new_style)
743 gtk_style_unref (style);
744 gtk_style_ref (new_style);
747 new_style->attach_count++;
753 gtk_style_detach (GtkStyle *style)
755 g_return_if_fail (GTK_IS_STYLE (style));
757 style->attach_count -= 1;
758 if (style->attach_count == 0)
760 GTK_STYLE_GET_CLASS (style)->unrealize (style);
762 gdk_colormap_unref (style->colormap);
763 style->colormap = NULL;
765 gtk_style_unref (style);
770 gtk_style_ref (GtkStyle *style)
772 return (GtkStyle *) g_object_ref (G_OBJECT (style));
776 gtk_style_unref (GtkStyle *style)
778 g_object_unref (G_OBJECT (style));
782 gtk_style_realize (GtkStyle *style,
783 GdkColormap *colormap)
785 g_return_if_fail (GTK_IS_STYLE (style));
786 g_return_if_fail (GDK_IS_COLORMAP (colormap));
788 style->colormap = gdk_colormap_ref (colormap);
789 style->depth = gdk_colormap_get_visual (colormap)->depth;
791 GTK_STYLE_GET_CLASS (style)->realize (style);
795 gtk_style_lookup_icon_set (GtkStyle *style,
796 const char *stock_id)
800 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
801 g_return_val_if_fail (stock_id != NULL, NULL);
803 iter = style->icon_factories;
806 GtkIconSet *icon_set = gtk_icon_factory_lookup (GTK_ICON_FACTORY (iter->data),
811 iter = g_slist_next (iter);
814 return gtk_icon_factory_lookup_default (stock_id);
818 gtk_draw_hline (GtkStyle *style,
820 GtkStateType state_type,
825 g_return_if_fail (GTK_IS_STYLE (style));
826 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_hline != NULL);
828 GTK_STYLE_GET_CLASS (style)->draw_hline (style, window, state_type, NULL, NULL, NULL, x1, x2, y);
833 gtk_draw_vline (GtkStyle *style,
835 GtkStateType state_type,
840 g_return_if_fail (GTK_IS_STYLE (style));
841 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_vline != NULL);
843 GTK_STYLE_GET_CLASS (style)->draw_vline (style, window, state_type, NULL, NULL, NULL, y1, y2, x);
848 gtk_draw_shadow (GtkStyle *style,
850 GtkStateType state_type,
851 GtkShadowType shadow_type,
857 g_return_if_fail (GTK_IS_STYLE (style));
858 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow != NULL);
860 GTK_STYLE_GET_CLASS (style)->draw_shadow (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
864 gtk_draw_polygon (GtkStyle *style,
866 GtkStateType state_type,
867 GtkShadowType shadow_type,
872 g_return_if_fail (GTK_IS_STYLE (style));
873 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_polygon != NULL);
875 GTK_STYLE_GET_CLASS (style)->draw_polygon (style, window, state_type, shadow_type, NULL, NULL, NULL, points, npoints, fill);
879 gtk_draw_arrow (GtkStyle *style,
881 GtkStateType state_type,
882 GtkShadowType shadow_type,
883 GtkArrowType arrow_type,
890 g_return_if_fail (GTK_IS_STYLE (style));
891 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_arrow != NULL);
893 GTK_STYLE_GET_CLASS (style)->draw_arrow (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, fill, x, y, width, height);
898 gtk_draw_diamond (GtkStyle *style,
900 GtkStateType state_type,
901 GtkShadowType shadow_type,
907 g_return_if_fail (GTK_IS_STYLE (style));
908 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_diamond != NULL);
910 GTK_STYLE_GET_CLASS (style)->draw_diamond (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
915 gtk_draw_string (GtkStyle *style,
917 GtkStateType state_type,
922 g_return_if_fail (GTK_IS_STYLE (style));
923 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_string != NULL);
925 GTK_STYLE_GET_CLASS (style)->draw_string (style, window, state_type, NULL, NULL, NULL, x, y, string);
929 gtk_draw_box (GtkStyle *style,
931 GtkStateType state_type,
932 GtkShadowType shadow_type,
938 g_return_if_fail (GTK_IS_STYLE (style));
939 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box != NULL);
941 GTK_STYLE_GET_CLASS (style)->draw_box (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
945 gtk_draw_flat_box (GtkStyle *style,
947 GtkStateType state_type,
948 GtkShadowType shadow_type,
954 g_return_if_fail (GTK_IS_STYLE (style));
955 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_flat_box != NULL);
957 GTK_STYLE_GET_CLASS (style)->draw_flat_box (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
961 gtk_draw_check (GtkStyle *style,
963 GtkStateType state_type,
964 GtkShadowType shadow_type,
970 g_return_if_fail (GTK_IS_STYLE (style));
971 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_check != NULL);
973 GTK_STYLE_GET_CLASS (style)->draw_check (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
977 gtk_draw_option (GtkStyle *style,
979 GtkStateType state_type,
980 GtkShadowType shadow_type,
986 g_return_if_fail (GTK_IS_STYLE (style));
987 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_option != NULL);
989 GTK_STYLE_GET_CLASS (style)->draw_option (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
993 gtk_draw_tab (GtkStyle *style,
995 GtkStateType state_type,
996 GtkShadowType shadow_type,
1002 g_return_if_fail (GTK_IS_STYLE (style));
1003 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_tab != NULL);
1005 GTK_STYLE_GET_CLASS (style)->draw_tab (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
1009 gtk_draw_shadow_gap (GtkStyle *style,
1011 GtkStateType state_type,
1012 GtkShadowType shadow_type,
1017 GtkPositionType gap_side,
1021 g_return_if_fail (GTK_IS_STYLE (style));
1022 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow_gap != NULL);
1024 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);
1028 gtk_draw_box_gap (GtkStyle *style,
1030 GtkStateType state_type,
1031 GtkShadowType shadow_type,
1036 GtkPositionType gap_side,
1040 g_return_if_fail (GTK_IS_STYLE (style));
1041 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box_gap != NULL);
1043 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);
1047 gtk_draw_extension (GtkStyle *style,
1049 GtkStateType state_type,
1050 GtkShadowType shadow_type,
1055 GtkPositionType gap_side)
1057 g_return_if_fail (GTK_IS_STYLE (style));
1058 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_extension != NULL);
1060 GTK_STYLE_GET_CLASS (style)->draw_extension (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side);
1064 gtk_draw_focus (GtkStyle *style,
1071 g_return_if_fail (GTK_IS_STYLE (style));
1072 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_focus != NULL);
1074 GTK_STYLE_GET_CLASS (style)->draw_focus (style, window, NULL, NULL, NULL, x, y, width, height);
1078 gtk_draw_slider (GtkStyle *style,
1080 GtkStateType state_type,
1081 GtkShadowType shadow_type,
1086 GtkOrientation orientation)
1088 g_return_if_fail (GTK_IS_STYLE (style));
1089 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_slider != NULL);
1091 GTK_STYLE_GET_CLASS (style)->draw_slider (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
1095 gtk_draw_handle (GtkStyle *style,
1097 GtkStateType state_type,
1098 GtkShadowType shadow_type,
1103 GtkOrientation orientation)
1105 g_return_if_fail (GTK_IS_STYLE (style));
1106 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_handle != NULL);
1108 GTK_STYLE_GET_CLASS (style)->draw_handle (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
1112 gtk_draw_expander (GtkStyle *style,
1114 GtkStateType state_type,
1117 GtkExpanderStyle expander_style)
1119 g_return_if_fail (GTK_IS_STYLE (style));
1120 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_expander != NULL);
1122 GTK_STYLE_GET_CLASS (style)->draw_expander (style, window, state_type,
1124 x, y, expander_style);
1128 gtk_draw_layout (GtkStyle *style,
1130 GtkStateType state_type,
1134 PangoLayout *layout)
1136 g_return_if_fail (GTK_IS_STYLE (style));
1137 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_layout != NULL);
1139 GTK_STYLE_GET_CLASS (style)->draw_layout (style, window, state_type, use_text,
1145 gtk_draw_resize_grip (GtkStyle *style,
1147 GtkStateType state_type,
1154 g_return_if_fail (GTK_IS_STYLE (style));
1155 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_resize_grip != NULL);
1157 GTK_STYLE_GET_CLASS (style)->draw_resize_grip (style, window, state_type,
1160 x, y, width, height);
1165 gtk_style_set_background (GtkStyle *style,
1167 GtkStateType state_type)
1169 g_return_if_fail (GTK_IS_STYLE (style));
1170 g_return_if_fail (window != NULL);
1172 GTK_STYLE_GET_CLASS (style)->set_background (style, window, state_type);
1175 /* Default functions */
1177 gtk_style_real_clone (GtkStyle *style)
1179 return GTK_STYLE (g_object_new (G_OBJECT_TYPE (style), NULL));
1183 gtk_style_real_copy (GtkStyle *style,
1188 for (i = 0; i < 5; i++)
1190 style->fg[i] = src->fg[i];
1191 style->bg[i] = src->bg[i];
1192 style->text[i] = src->text[i];
1193 style->base[i] = src->base[i];
1195 style->bg_pixmap[i] = src->bg_pixmap[i];
1199 gdk_font_unref (style->font);
1200 style->font = src->font;
1202 gdk_font_ref (style->font);
1204 if (style->font_desc)
1205 pango_font_description_free (style->font_desc);
1207 style->font_desc = pango_font_description_copy (src->font_desc);
1209 style->font_desc = NULL;
1211 style->xthickness = src->xthickness;
1212 style->ythickness = src->ythickness;
1214 if (style->rc_style)
1215 gtk_rc_style_unref (style->rc_style);
1216 style->rc_style = src->rc_style;
1218 gtk_rc_style_ref (src->rc_style);
1220 /* don't copy, just clear cache */
1221 clear_property_cache (style);
1225 gtk_style_real_init_from_rc (GtkStyle *style,
1226 GtkRcStyle *rc_style)
1231 /* cache _should_ be still empty */
1232 clear_property_cache (style);
1234 if (rc_style->font_desc)
1236 pango_font_description_free (style->font_desc);
1237 style->font_desc = pango_font_description_copy (rc_style->font_desc);
1239 old_font = style->font;
1240 style->font = gdk_font_from_description (style->font_desc);
1242 gdk_font_unref (old_font);
1244 style->font = old_font;
1247 for (i = 0; i < 5; i++)
1249 if (rc_style->color_flags[i] & GTK_RC_FG)
1250 style->fg[i] = rc_style->fg[i];
1251 if (rc_style->color_flags[i] & GTK_RC_BG)
1252 style->bg[i] = rc_style->bg[i];
1253 if (rc_style->color_flags[i] & GTK_RC_TEXT)
1254 style->text[i] = rc_style->text[i];
1255 if (rc_style->color_flags[i] & GTK_RC_BASE)
1256 style->base[i] = rc_style->base[i];
1259 if (rc_style->xthickness >= 0)
1260 style->xthickness = rc_style->xthickness;
1261 if (rc_style->ythickness >= 0)
1262 style->ythickness = rc_style->ythickness;
1264 if (rc_style->icon_factories)
1268 style->icon_factories = g_slist_copy (rc_style->icon_factories);
1270 iter = style->icon_factories;
1271 while (iter != NULL)
1273 g_object_ref (G_OBJECT (iter->data));
1275 iter = g_slist_next (iter);
1281 style_property_values_cmp (gconstpointer bsearch_node1,
1282 gconstpointer bsearch_node2)
1284 const PropertyValue *val1 = bsearch_node1;
1285 const PropertyValue *val2 = bsearch_node2;
1287 if (val1->widget_type == val2->widget_type)
1288 return val1->pspec < val2->pspec ? -1 : val1->pspec == val2->pspec ? 0 : 1;
1290 return val1->widget_type < val2->widget_type ? -1 : 1;
1294 _gtk_style_peek_property_value (GtkStyle *style,
1297 GtkRcPropertyParser parser)
1299 PropertyValue *pcache, key = { 0, NULL, { 0, } };
1300 const GtkRcProperty *rcprop = NULL;
1303 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
1304 g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), NULL);
1305 g_return_val_if_fail (g_type_is_a (pspec->owner_type, GTK_TYPE_WIDGET), NULL);
1306 g_return_val_if_fail (g_type_is_a (widget_type, pspec->owner_type), NULL);
1308 key.widget_type = widget_type;
1311 /* need value cache array */
1312 if (!style->property_cache)
1313 style->property_cache = g_array_new (FALSE, FALSE, sizeof (PropertyValue));
1316 pcache = bsearch (&key,
1317 style->property_cache->data, style->property_cache->len,
1318 sizeof (PropertyValue), style_property_values_cmp);
1320 return &pcache->value;
1324 while (i < style->property_cache->len &&
1325 style_property_values_cmp (&key, &g_array_index (style->property_cache, PropertyValue, i)) >= 0)
1328 g_array_insert_val (style->property_cache, i, key);
1329 pcache = &g_array_index (style->property_cache, PropertyValue, i);
1331 /* cache miss, initialize value type, then set contents */
1332 g_param_spec_ref (pcache->pspec);
1333 g_value_init (&pcache->value, G_PARAM_SPEC_VALUE_TYPE (pspec));
1335 /* value provided by rc style? */
1336 if (style->rc_style)
1338 GQuark prop_quark = g_quark_from_string (pspec->name);
1342 rcprop = _gtk_rc_style_lookup_rc_property (style->rc_style,
1343 g_type_qname (widget_type),
1347 widget_type = g_type_parent (widget_type);
1349 while (g_type_is_a (widget_type, pspec->owner_type));
1352 /* when supplied by rc style, we need to convert */
1353 if (rcprop && !_gtk_settings_parse_convert (parser, &rcprop->value,
1354 pspec, &pcache->value))
1356 gchar *contents = g_strdup_value_contents (&rcprop->value);
1358 g_message ("%s: failed to retrive property `%s::%s' of type `%s' from rc file value \"%s\" of type `%s'",
1360 g_type_name (pspec->owner_type), pspec->name,
1361 g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
1363 G_VALUE_TYPE_NAME (&rcprop->value));
1365 rcprop = NULL; /* needs default */
1368 /* not supplied by rc style (or conversion failed), revert to default */
1370 g_param_value_set_default (pspec, &pcache->value);
1372 return &pcache->value;
1376 load_bg_image (GdkColormap *colormap,
1378 const gchar *filename)
1380 if (strcmp (filename, "<parent>") == 0)
1381 return (GdkPixmap*) GDK_PARENT_RELATIVE;
1384 return gdk_pixmap_colormap_create_from_xpm (NULL, colormap, NULL,
1391 gtk_style_real_realize (GtkStyle *style)
1393 GdkGCValues gc_values;
1394 GdkGCValuesMask gc_values_mask;
1398 for (i = 0; i < 5; i++)
1400 gtk_style_shade (&style->bg[i], &style->light[i], LIGHTNESS_MULT);
1401 gtk_style_shade (&style->bg[i], &style->dark[i], DARKNESS_MULT);
1403 style->mid[i].red = (style->light[i].red + style->dark[i].red) / 2;
1404 style->mid[i].green = (style->light[i].green + style->dark[i].green) / 2;
1405 style->mid[i].blue = (style->light[i].blue + style->dark[i].blue) / 2;
1407 style->text_aa[i].red = (style->text[i].red + style->base[i].red) / 2;
1408 style->text_aa[i].green = (style->text[i].green + style->base[i].green) / 2;
1409 style->text_aa[i].blue = (style->text[i].blue + style->base[i].blue) / 2;
1412 gdk_color_black (style->colormap, &style->black);
1413 gdk_color_white (style->colormap, &style->white);
1415 gc_values_mask = GDK_GC_FOREGROUND | GDK_GC_FONT;
1416 if (style->font->type == GDK_FONT_FONT)
1418 gc_values.font = style->font;
1420 else if (style->font->type == GDK_FONT_FONTSET)
1422 gc_values.font = static_default_font;
1425 gc_values.foreground = style->black;
1426 style->black_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1428 gc_values.foreground = style->white;
1429 style->white_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1431 for (i = 0; i < 5; i++)
1433 if (style->rc_style && style->rc_style->bg_pixmap_name[i])
1434 style->bg_pixmap[i] = load_bg_image (style->colormap,
1436 style->rc_style->bg_pixmap_name[i]);
1438 if (!gdk_color_alloc (style->colormap, &style->fg[i]))
1439 g_warning ("unable to allocate color: ( %d %d %d )",
1440 style->fg[i].red, style->fg[i].green, style->fg[i].blue);
1441 if (!gdk_color_alloc (style->colormap, &style->bg[i]))
1442 g_warning ("unable to allocate color: ( %d %d %d )",
1443 style->bg[i].red, style->bg[i].green, style->bg[i].blue);
1444 if (!gdk_color_alloc (style->colormap, &style->light[i]))
1445 g_warning ("unable to allocate color: ( %d %d %d )",
1446 style->light[i].red, style->light[i].green, style->light[i].blue);
1447 if (!gdk_color_alloc (style->colormap, &style->dark[i]))
1448 g_warning ("unable to allocate color: ( %d %d %d )",
1449 style->dark[i].red, style->dark[i].green, style->dark[i].blue);
1450 if (!gdk_color_alloc (style->colormap, &style->mid[i]))
1451 g_warning ("unable to allocate color: ( %d %d %d )",
1452 style->mid[i].red, style->mid[i].green, style->mid[i].blue);
1453 if (!gdk_color_alloc (style->colormap, &style->text[i]))
1454 g_warning ("unable to allocate color: ( %d %d %d )",
1455 style->text[i].red, style->text[i].green, style->text[i].blue);
1456 if (!gdk_color_alloc (style->colormap, &style->base[i]))
1457 g_warning ("unable to allocate color: ( %d %d %d )",
1458 style->base[i].red, style->base[i].green, style->base[i].blue);
1459 if (!gdk_color_alloc (style->colormap, &style->text_aa[i]))
1460 g_warning ("unable to allocate color: ( %d %d %d )",
1461 style->text_aa[i].red, style->text_aa[i].green, style->text_aa[i].blue);
1463 gc_values.foreground = style->fg[i];
1464 style->fg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1466 gc_values.foreground = style->bg[i];
1467 style->bg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1469 gc_values.foreground = style->light[i];
1470 style->light_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1472 gc_values.foreground = style->dark[i];
1473 style->dark_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1475 gc_values.foreground = style->mid[i];
1476 style->mid_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1478 gc_values.foreground = style->text[i];
1479 style->text_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1481 gc_values.foreground = style->base[i];
1482 style->base_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1484 gc_values.foreground = style->text_aa[i];
1485 style->text_aa_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1490 gtk_style_real_unrealize (GtkStyle *style)
1494 gtk_gc_release (style->black_gc);
1495 gtk_gc_release (style->white_gc);
1497 for (i = 0; i < 5; i++)
1499 gtk_gc_release (style->fg_gc[i]);
1500 gtk_gc_release (style->bg_gc[i]);
1501 gtk_gc_release (style->light_gc[i]);
1502 gtk_gc_release (style->dark_gc[i]);
1503 gtk_gc_release (style->mid_gc[i]);
1504 gtk_gc_release (style->text_gc[i]);
1505 gtk_gc_release (style->base_gc[i]);
1506 gtk_gc_release (style->text_aa_gc[i]);
1508 if (style->bg_pixmap[i] && style->bg_pixmap[i] != (GdkPixmap*) GDK_PARENT_RELATIVE)
1509 gdk_pixmap_unref (style->bg_pixmap[i]);
1512 gdk_colormap_free_colors (style->colormap, style->fg, 5);
1513 gdk_colormap_free_colors (style->colormap, style->bg, 5);
1514 gdk_colormap_free_colors (style->colormap, style->light, 5);
1515 gdk_colormap_free_colors (style->colormap, style->dark, 5);
1516 gdk_colormap_free_colors (style->colormap, style->mid, 5);
1517 gdk_colormap_free_colors (style->colormap, style->text, 5);
1518 gdk_colormap_free_colors (style->colormap, style->base, 5);
1519 gdk_colormap_free_colors (style->colormap, style->text_aa, 5);
1523 gtk_style_real_set_background (GtkStyle *style,
1525 GtkStateType state_type)
1528 gint parent_relative;
1530 if (style->bg_pixmap[state_type])
1532 if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
1535 parent_relative = TRUE;
1539 pixmap = style->bg_pixmap[state_type];
1540 parent_relative = FALSE;
1543 gdk_window_set_back_pixmap (window, pixmap, parent_relative);
1546 gdk_window_set_background (window, &style->bg[state_type]);
1550 gtk_style_render_icon (GtkStyle *style,
1551 const GtkIconSource *source,
1552 GtkTextDirection direction,
1556 const gchar *detail)
1560 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
1561 g_return_val_if_fail (GTK_STYLE_GET_CLASS (style)->render_icon != NULL, NULL);
1563 pixbuf = GTK_STYLE_GET_CLASS (style)->render_icon (style, source, direction, state,
1564 size, widget, detail);
1566 g_return_val_if_fail (pixbuf != NULL, NULL);
1571 /* Default functions */
1573 gtk_style_apply_default_background (GtkStyle *style,
1576 GtkStateType state_type,
1583 GdkRectangle new_rect, old_rect;
1589 old_rect.width = width;
1590 old_rect.height = height;
1592 if (!gdk_rectangle_intersect (area, &old_rect, &new_rect))
1599 new_rect.width = width;
1600 new_rect.height = height;
1603 if (!style->bg_pixmap[state_type] ||
1604 GDK_IS_PIXMAP (window) ||
1605 (!set_bg && style->bg_pixmap[state_type] != (GdkPixmap*) GDK_PARENT_RELATIVE))
1607 GdkGC *gc = style->bg_gc[state_type];
1609 if (style->bg_pixmap[state_type])
1611 gdk_gc_set_fill (gc, GDK_TILED);
1612 gdk_gc_set_tile (gc, style->bg_pixmap[state_type]);
1615 gdk_draw_rectangle (window, gc, TRUE,
1616 new_rect.x, new_rect.y, new_rect.width, new_rect.height);
1617 if (style->bg_pixmap[state_type])
1618 gdk_gc_set_fill (gc, GDK_SOLID);
1624 if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
1625 gdk_window_set_back_pixmap (window, NULL, TRUE);
1627 gdk_window_set_back_pixmap (window, style->bg_pixmap[state_type], FALSE);
1630 gdk_window_clear_area (window,
1631 new_rect.x, new_rect.y,
1632 new_rect.width, new_rect.height);
1637 scale_or_ref (GdkPixbuf *src,
1641 if (width == gdk_pixbuf_get_width (src) &&
1642 height == gdk_pixbuf_get_height (src))
1644 gdk_pixbuf_ref (src);
1649 return gdk_pixbuf_scale_simple (src,
1651 GDK_INTERP_BILINEAR);
1656 gtk_default_render_icon (GtkStyle *style,
1657 const GtkIconSource *source,
1658 GtkTextDirection direction,
1662 const gchar *detail)
1668 GdkPixbuf *base_pixbuf;
1670 /* Oddly, style can be NULL in this function, because
1671 * GtkIconSet can be used without a style and if so
1672 * it uses this function.
1675 base_pixbuf = gtk_icon_source_get_pixbuf (source);
1677 g_return_val_if_fail (base_pixbuf != NULL, NULL);
1679 if (!gtk_icon_size_lookup (size, &width, &height))
1681 g_warning (G_STRLOC ": invalid icon size `%d'", size);
1685 /* If the size was wildcarded, then scale; otherwise, leave it
1688 if (gtk_icon_source_get_size_wildcarded (source))
1689 scaled = scale_or_ref (base_pixbuf, width, height);
1691 scaled = GDK_PIXBUF (g_object_ref (G_OBJECT (base_pixbuf)));
1693 /* If the state was wildcarded, then generate a state. */
1694 if (gtk_icon_source_get_state_wildcarded (source))
1696 if (state == GTK_STATE_INSENSITIVE)
1698 stated = gdk_pixbuf_copy (scaled);
1700 gdk_pixbuf_saturate_and_pixelate (scaled, stated,
1703 gdk_pixbuf_unref (scaled);
1705 else if (state == GTK_STATE_PRELIGHT)
1707 stated = gdk_pixbuf_copy (scaled);
1709 gdk_pixbuf_saturate_and_pixelate (scaled, stated,
1712 gdk_pixbuf_unref (scaled);
1726 sanitize_size (GdkWindow *window,
1730 gboolean set_bg = FALSE;
1732 if ((*width == -1) && (*height == -1))
1734 set_bg = GDK_IS_WINDOW (window);
1735 gdk_window_get_size (window, width, height);
1737 else if (*width == -1)
1738 gdk_window_get_size (window, width, NULL);
1739 else if (*height == -1)
1740 gdk_window_get_size (window, NULL, height);
1746 draw_part (GdkDrawable *drawable,
1754 gdk_gc_set_clip_rectangle (gc, area);
1756 if (!indicator_parts[part].bmap)
1757 indicator_parts[part].bmap = gdk_bitmap_create_from_data (drawable,
1758 indicator_parts[part].bits,
1759 INDICATOR_PART_SIZE, INDICATOR_PART_SIZE);
1761 gdk_gc_set_ts_origin (gc, x, y);
1762 gdk_gc_set_stipple (gc, indicator_parts[part].bmap);
1763 gdk_gc_set_fill (gc, GDK_STIPPLED);
1765 gdk_draw_rectangle (drawable, gc, TRUE, x, y, INDICATOR_PART_SIZE, INDICATOR_PART_SIZE);
1767 gdk_gc_set_fill (gc, GDK_SOLID);
1770 gdk_gc_set_clip_rectangle (gc, NULL);
1774 gtk_default_draw_hline (GtkStyle *style,
1776 GtkStateType state_type,
1779 const gchar *detail,
1784 gint thickness_light;
1785 gint thickness_dark;
1788 g_return_if_fail (GTK_IS_STYLE (style));
1789 g_return_if_fail (window != NULL);
1791 thickness_light = style->ythickness / 2;
1792 thickness_dark = style->ythickness - thickness_light;
1796 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1797 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1800 if (detail && !strcmp (detail, "label"))
1802 if (state_type == GTK_STATE_INSENSITIVE)
1803 gdk_draw_line (window, style->white_gc, x1 + 1, y + 1, x2 + 1, y + 1);
1804 gdk_draw_line (window, style->fg_gc[state_type], x1, y, x2, y);
1808 for (i = 0; i < thickness_dark; i++)
1810 gdk_draw_line (window, style->light_gc[state_type], x2 - i - 1, y + i, x2, y + i);
1811 gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x2 - i - 1, y + i);
1814 y += thickness_dark;
1815 for (i = 0; i < thickness_light; i++)
1817 gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x1 + thickness_light - i - 1, y + i);
1818 gdk_draw_line (window, style->light_gc[state_type], x1 + thickness_light - i - 1, y + i, x2, y + i);
1824 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
1825 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
1831 gtk_default_draw_vline (GtkStyle *style,
1833 GtkStateType state_type,
1836 const gchar *detail,
1841 gint thickness_light;
1842 gint thickness_dark;
1845 g_return_if_fail (GTK_IS_STYLE (style));
1846 g_return_if_fail (window != NULL);
1848 thickness_light = style->xthickness / 2;
1849 thickness_dark = style->xthickness - thickness_light;
1853 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1854 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1856 for (i = 0; i < thickness_dark; i++)
1858 gdk_draw_line (window, style->light_gc[state_type], x + i, y2 - i - 1, x + i, y2);
1859 gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y2 - i - 1);
1862 x += thickness_dark;
1863 for (i = 0; i < thickness_light; i++)
1865 gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y1 + thickness_light - i);
1866 gdk_draw_line (window, style->light_gc[state_type], x + i, y1 + thickness_light - i, x + i, y2);
1870 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
1871 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
1877 draw_thin_shadow (GtkStyle *style,
1888 sanitize_size (window, &width, &height);
1890 gc1 = style->light_gc[state];
1891 gc2 = style->dark_gc[state];
1895 gdk_gc_set_clip_rectangle (gc1, area);
1896 gdk_gc_set_clip_rectangle (gc2, area);
1899 gdk_draw_line (window, gc1,
1900 x, y + height - 1, x + width - 1, y + height - 1);
1901 gdk_draw_line (window, gc1,
1902 x + width - 1, y, x + width - 1, y + height - 1);
1904 gdk_draw_line (window, gc2,
1905 x, y, x + width - 1, y);
1906 gdk_draw_line (window, gc2,
1907 x, y, x, y + height - 1);
1911 gdk_gc_set_clip_rectangle (gc1, NULL);
1912 gdk_gc_set_clip_rectangle (gc2, NULL);
1917 draw_spin_entry_shadow (GtkStyle *style,
1926 gint window_width, window_height;
1927 gboolean focus_inset;
1929 gdk_window_get_size (window, &window_width, &window_height);
1932 width = window_width;
1934 height = window_height;
1936 focus_inset = (width < window_width && height < window_height);
1940 gdk_gc_set_clip_rectangle (style->light_gc[state], area);
1941 gdk_gc_set_clip_rectangle (style->dark_gc[state], area);
1942 gdk_gc_set_clip_rectangle (style->black_gc, area);
1943 gdk_gc_set_clip_rectangle (style->bg_gc[state], area);
1944 gdk_gc_set_clip_rectangle (style->base_gc[state], area);
1947 gdk_draw_line (window, style->light_gc[state],
1948 x, y + height - 1, x + width - 1, y + height - 1);
1950 gdk_draw_line (window,
1951 style->base_gc[state],
1952 x + width - 1, y + 1, x + width - 1, y + height - 3);
1956 gdk_draw_line (window, style->bg_gc[state],
1957 x + 1, y + height - 2, x + width - 1, y + height - 2);
1958 gdk_draw_line (window,
1959 style->base_gc[state],
1960 x + width - 2, y + 1, x + width - 2, y + height - 3);
1962 gdk_draw_line (window, style->black_gc,
1963 x + 1, y + 1, x + width - 1, y + 1);
1964 gdk_draw_line (window, style->black_gc,
1965 x + 1, y + 1, x + 1, y + height - 2);
1968 gdk_draw_line (window, style->dark_gc[state],
1969 x, y, x + width - 1, y);
1970 gdk_draw_line (window, style->dark_gc[state],
1971 x, y, x, y + height - 1);
1975 gdk_gc_set_clip_rectangle (style->light_gc[state], NULL);
1976 gdk_gc_set_clip_rectangle (style->dark_gc[state], NULL);
1977 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
1978 gdk_gc_set_clip_rectangle (style->bg_gc[state], NULL);
1979 gdk_gc_set_clip_rectangle (style->base_gc[state], NULL);
1984 draw_spinbutton_shadow (GtkStyle *style,
1993 gint y_middle = y + height / 2;
1995 sanitize_size (window, &width, &height);
1999 gdk_gc_set_clip_rectangle (style->black_gc, area);
2000 gdk_gc_set_clip_rectangle (style->bg_gc[state], area);
2001 gdk_gc_set_clip_rectangle (style->dark_gc[state], area);
2002 gdk_gc_set_clip_rectangle (style->light_gc[state], area);
2005 gdk_draw_line (window, style->black_gc,
2006 x, y + 2, x, y + height - 3);
2007 gdk_draw_line (window, style->black_gc,
2008 x, y + 1, x + width - 2, y + 1);
2009 gdk_draw_line (window, style->black_gc,
2010 x + width - 2, y + 2, x + width - 2, y + height - 3);
2012 gdk_draw_line (window, style->bg_gc[state],
2013 x, y + height - 2, x + width - 2, y + height - 2);
2015 gdk_draw_line (window, style->dark_gc[state],
2016 x, y, x + width - 1, y);
2017 gdk_draw_line (window, style->dark_gc[state],
2018 x + 1, y_middle - 1, x + width - 3, y_middle - 1);
2019 gdk_draw_line (window, style->dark_gc[state],
2020 x + 1, y + height - 3, x + width - 3, y + height - 3);
2022 gdk_draw_line (window, style->light_gc[state],
2023 x + 1, y + 2, x + width - 3, y + 2);
2024 gdk_draw_line (window, style->light_gc[state],
2025 x + 1, y_middle, x + width - 3, y_middle);
2026 gdk_draw_line (window, style->light_gc[state],
2027 x + width - 1, y + 1, x + width - 1, y + height - 1);
2028 gdk_draw_line (window, style->light_gc[state],
2029 x, y + height - 1, x + width - 2, y + height - 1);
2033 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2034 gdk_gc_set_clip_rectangle (style->bg_gc[state], NULL);
2035 gdk_gc_set_clip_rectangle (style->dark_gc[state], NULL);
2036 gdk_gc_set_clip_rectangle (style->light_gc[state], NULL);
2041 gtk_default_draw_shadow (GtkStyle *style,
2043 GtkStateType state_type,
2044 GtkShadowType shadow_type,
2047 const gchar *detail,
2055 gint thickness_light;
2056 gint thickness_dark;
2059 g_return_if_fail (GTK_IS_STYLE (style));
2060 g_return_if_fail (window != NULL);
2062 if (shadow_type == GTK_SHADOW_IN)
2064 if (detail && (strcmp (detail, "buttondefault") == 0))
2066 sanitize_size (window, &width, &height);
2068 gdk_draw_rectangle (window, style->black_gc, FALSE,
2069 x, y, width - 1, height - 1);
2073 if (detail && strcmp (detail, "trough") == 0)
2075 draw_thin_shadow (style, window, state_type, area,
2076 x, y, width, height);
2079 else if (widget && GTK_IS_SPIN_BUTTON (widget) &&
2080 detail && strcmp (detail, "entry") == 0)
2082 draw_spin_entry_shadow (style, window, state_type, area,
2083 x, y, width, height);
2086 else if (widget && GTK_IS_SPIN_BUTTON (widget) &&
2087 detail && strcmp (detail, "spinbutton") == 0)
2089 draw_spinbutton_shadow (style, window, state_type,
2090 area, x, y, width, height);
2095 sanitize_size (window, &width, &height);
2097 switch (shadow_type)
2099 case GTK_SHADOW_NONE:
2102 case GTK_SHADOW_ETCHED_IN:
2103 gc1 = style->light_gc[state_type];
2104 gc2 = style->dark_gc[state_type];
2106 case GTK_SHADOW_OUT:
2107 case GTK_SHADOW_ETCHED_OUT:
2108 gc1 = style->dark_gc[state_type];
2109 gc2 = style->light_gc[state_type];
2115 gdk_gc_set_clip_rectangle (gc1, area);
2116 gdk_gc_set_clip_rectangle (gc2, area);
2117 if (shadow_type == GTK_SHADOW_IN ||
2118 shadow_type == GTK_SHADOW_OUT)
2120 gdk_gc_set_clip_rectangle (style->black_gc, area);
2121 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
2125 switch (shadow_type)
2127 case GTK_SHADOW_NONE:
2131 /* Light around right and bottom edge */
2133 if (style->ythickness > 0)
2134 gdk_draw_line (window, gc1,
2135 x, y + height - 1, x + width - 1, y + height - 1);
2136 if (style->xthickness > 0)
2137 gdk_draw_line (window, gc1,
2138 x + width - 1, y, x + width - 1, y + height - 1);
2140 if (style->ythickness > 1)
2141 gdk_draw_line (window, style->bg_gc[state_type],
2142 x + 1, y + height - 2, x + width - 2, y + height - 2);
2143 if (style->xthickness > 1)
2144 gdk_draw_line (window, style->bg_gc[state_type],
2145 x + width - 2, y + 1, x + width - 2, y + height - 2);
2147 /* Dark around left and top */
2149 if (style->ythickness > 1)
2150 gdk_draw_line (window, style->black_gc,
2151 x + 1, y + 1, x + width - 2, y + 1);
2152 if (style->xthickness > 1)
2153 gdk_draw_line (window, style->black_gc,
2154 x + 1, y + 1, x + 1, y + height - 2);
2156 if (style->ythickness > 0)
2157 gdk_draw_line (window, gc2,
2158 x, y, x + width - 1, y);
2159 if (style->xthickness > 0)
2160 gdk_draw_line (window, gc2,
2161 x, y, x, y + height - 1);
2164 case GTK_SHADOW_OUT:
2165 /* Dark around right and bottom edge */
2167 if (style->ythickness > 0)
2169 if (style->ythickness > 1)
2171 gdk_draw_line (window, gc1,
2172 x + 1, y + height - 2, x + width - 2, y + height - 2);
2173 gdk_draw_line (window, style->black_gc,
2174 x, y + height - 1, x + width - 1, y + height - 1);
2178 gdk_draw_line (window, gc1,
2179 x + 1, y + height - 1, x + width - 1, y + height - 1);
2183 if (style->xthickness > 0)
2185 if (style->xthickness > 1)
2187 gdk_draw_line (window, gc1,
2188 x + width - 2, y + 1, x + width - 2, y + height - 2);
2190 gdk_draw_line (window, style->black_gc,
2191 x + width - 1, y, x + width - 1, y + height - 1);
2195 gdk_draw_line (window, gc1,
2196 x + width - 1, y + 1, x + width - 1, y + height - 1);
2200 /* Light around top and left */
2202 if (style->ythickness > 0)
2203 gdk_draw_line (window, gc2,
2204 x, y, x + width - 1, y);
2205 if (style->xthickness > 0)
2206 gdk_draw_line (window, gc2,
2207 x, y, x, y + height - 1);
2209 if (style->ythickness > 1)
2210 gdk_draw_line (window, style->bg_gc[state_type],
2211 x + 1, y + 1, x + width - 2, y + 1);
2212 if (style->xthickness > 1)
2213 gdk_draw_line (window, style->bg_gc[state_type],
2214 x + 1, y + 1, x + 1, y + height - 2);
2217 case GTK_SHADOW_ETCHED_IN:
2218 case GTK_SHADOW_ETCHED_OUT:
2219 if (style->xthickness > 0)
2221 if (style->xthickness > 1)
2223 thickness_light = 1;
2226 for (i = 0; i < thickness_dark; i++)
2228 gdk_draw_line (window, gc1,
2232 y + height - i - 1);
2233 gdk_draw_line (window, gc2,
2237 y + height - i - 2);
2240 for (i = 0; i < thickness_light; i++)
2242 gdk_draw_line (window, gc1,
2243 x + thickness_dark + i,
2244 y + thickness_dark + i,
2245 x + thickness_dark + i,
2246 y + height - thickness_dark - i - 1);
2247 gdk_draw_line (window, gc2,
2248 x + width - thickness_light - i - 1,
2249 y + thickness_dark + i,
2250 x + width - thickness_light - i - 1,
2251 y + height - thickness_light - 1);
2256 gdk_draw_line (window,
2257 style->dark_gc[state_type],
2258 x, y, x, y + height);
2259 gdk_draw_line (window,
2260 style->dark_gc[state_type],
2261 x + width, y, x + width, y + height);
2265 if (style->ythickness > 0)
2267 if (style->ythickness > 1)
2269 thickness_light = 1;
2272 for (i = 0; i < thickness_dark; i++)
2274 gdk_draw_line (window, gc1,
2278 y + height - i - 1);
2280 gdk_draw_line (window, gc2,
2287 for (i = 0; i < thickness_light; i++)
2289 gdk_draw_line (window, gc1,
2290 x + thickness_dark + i,
2291 y + thickness_dark + i,
2292 x + width - thickness_dark - i - 1,
2293 y + thickness_dark + i);
2295 gdk_draw_line (window, gc2,
2296 x + thickness_dark + i,
2297 y + height - thickness_light - i - 1,
2298 x + width - thickness_light - 1,
2299 y + height - thickness_light - i - 1);
2304 gdk_draw_line (window,
2305 style->dark_gc[state_type],
2306 x, y, x + width, y);
2307 gdk_draw_line (window,
2308 style->dark_gc[state_type],
2309 x, y + height, x + width, y + height);
2317 gdk_gc_set_clip_rectangle (gc1, NULL);
2318 gdk_gc_set_clip_rectangle (gc2, NULL);
2319 if (shadow_type == GTK_SHADOW_IN ||
2320 shadow_type == GTK_SHADOW_OUT)
2322 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2323 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2329 gtk_default_draw_polygon (GtkStyle *style,
2331 GtkStateType state_type,
2332 GtkShadowType shadow_type,
2335 const gchar *detail,
2340 static const gdouble pi_over_4 = G_PI_4;
2341 static const gdouble pi_3_over_4 = G_PI_4 * 3;
2351 g_return_if_fail (GTK_IS_STYLE (style));
2352 g_return_if_fail (window != NULL);
2353 g_return_if_fail (points != NULL);
2355 switch (shadow_type)
2358 gc1 = style->bg_gc[state_type];
2359 gc2 = style->dark_gc[state_type];
2360 gc3 = style->light_gc[state_type];
2361 gc4 = style->black_gc;
2363 case GTK_SHADOW_ETCHED_IN:
2364 gc1 = style->light_gc[state_type];
2365 gc2 = style->dark_gc[state_type];
2366 gc3 = style->dark_gc[state_type];
2367 gc4 = style->light_gc[state_type];
2369 case GTK_SHADOW_OUT:
2370 gc1 = style->dark_gc[state_type];
2371 gc2 = style->light_gc[state_type];
2372 gc3 = style->black_gc;
2373 gc4 = style->bg_gc[state_type];
2375 case GTK_SHADOW_ETCHED_OUT:
2376 gc1 = style->dark_gc[state_type];
2377 gc2 = style->light_gc[state_type];
2378 gc3 = style->light_gc[state_type];
2379 gc4 = style->dark_gc[state_type];
2387 gdk_gc_set_clip_rectangle (gc1, area);
2388 gdk_gc_set_clip_rectangle (gc2, area);
2389 gdk_gc_set_clip_rectangle (gc3, area);
2390 gdk_gc_set_clip_rectangle (gc4, area);
2394 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, npoints);
2398 for (i = 0; i < npoints; i++)
2400 if ((points[i].x == points[i+1].x) &&
2401 (points[i].y == points[i+1].y))
2407 angle = atan2 (points[i+1].y - points[i].y,
2408 points[i+1].x - points[i].x);
2411 if ((angle > -pi_3_over_4) && (angle < pi_over_4))
2413 if (angle > -pi_over_4)
2424 gdk_draw_line (window, gc1,
2425 points[i].x-xadjust, points[i].y-yadjust,
2426 points[i+1].x-xadjust, points[i+1].y-yadjust);
2427 gdk_draw_line (window, gc3,
2428 points[i].x, points[i].y,
2429 points[i+1].x, points[i+1].y);
2433 if ((angle < -pi_3_over_4) || (angle > pi_3_over_4))
2444 gdk_draw_line (window, gc4,
2445 points[i].x+xadjust, points[i].y+yadjust,
2446 points[i+1].x+xadjust, points[i+1].y+yadjust);
2447 gdk_draw_line (window, gc2,
2448 points[i].x, points[i].y,
2449 points[i+1].x, points[i+1].y);
2455 gdk_gc_set_clip_rectangle (gc1, NULL);
2456 gdk_gc_set_clip_rectangle (gc2, NULL);
2457 gdk_gc_set_clip_rectangle (gc3, NULL);
2458 gdk_gc_set_clip_rectangle (gc4, NULL);
2463 draw_varrow (GdkWindow *window,
2465 GtkShadowType shadow_type,
2467 GtkArrowType arrow_type,
2474 gint y_start, y_increment;
2478 gdk_gc_set_clip_rectangle (gc, area);
2480 width = width + width % 2 - 1; /* Force odd */
2482 steps = 1 + width / 2;
2484 extra = height - steps;
2486 if (arrow_type == GTK_ARROW_DOWN)
2493 y_start = y + height - 1;
2497 for (i = 0; i < extra; i++)
2499 gdk_draw_line (window, gc,
2500 x, y_start + i * y_increment,
2501 x + width - 1, y_start + i * y_increment);
2503 for (; i < height; i++)
2505 gdk_draw_line (window, gc,
2506 x + (i - extra), y_start + i * y_increment,
2507 x + width - (i - extra) - 1, y_start + i * y_increment);
2512 gdk_gc_set_clip_rectangle (gc, NULL);
2516 draw_harrow (GdkWindow *window,
2518 GtkShadowType shadow_type,
2520 GtkArrowType arrow_type,
2527 gint x_start, x_increment;
2531 gdk_gc_set_clip_rectangle (gc, area);
2533 height = height + height % 2 - 1; /* Force odd */
2535 steps = 1 + height / 2;
2537 extra = width - steps;
2539 if (arrow_type == GTK_ARROW_RIGHT)
2546 x_start = x + width - 1;
2550 for (i = 0; i < extra; i++)
2552 gdk_draw_line (window, gc,
2553 x_start + i * x_increment, y,
2554 x_start + i * x_increment, y + height - 1);
2556 for (; i < width; i++)
2558 gdk_draw_line (window, gc,
2559 x_start + i * x_increment, y + (i - extra),
2560 x_start + i * x_increment, y + height - (i - extra) - 1);
2565 gdk_gc_set_clip_rectangle (gc, NULL);
2569 gtk_default_draw_arrow (GtkStyle *style,
2572 GtkShadowType shadow,
2575 const gchar *detail,
2576 GtkArrowType arrow_type,
2583 sanitize_size (window, &width, &height);
2585 if (detail && strcmp (detail, "spinbutton") == 0)
2587 x += (width - 7) / 2;
2589 if (arrow_type == GTK_ARROW_UP)
2590 y += (height - 4) / 2;
2592 y += (1 + height - 4) / 2;
2594 draw_varrow (window, style->fg_gc[state], shadow, area, arrow_type,
2597 else if (detail && strcmp (detail, "vscrollbar") == 0)
2599 gtk_paint_box (style, window, state, shadow, area,
2600 widget, detail, x, y, width, height);
2602 x += (width - 7) / 2;
2603 y += (height - 5) / 2;
2605 draw_varrow (window, style->fg_gc[state], shadow, area, arrow_type,
2609 else if (detail && strcmp (detail, "hscrollbar") == 0)
2611 gtk_paint_box (style, window, state, shadow, area,
2612 widget, detail, x, y, width, height);
2614 y += (height - 7) / 2;
2615 x += (width - 5) / 2;
2617 draw_harrow (window, style->fg_gc[state], shadow, area, arrow_type,
2622 if (arrow_type == GTK_ARROW_UP || arrow_type == GTK_ARROW_DOWN)
2624 x += (width - 7) / 2;
2625 y += (height - 5) / 2;
2627 draw_varrow (window, style->fg_gc[state], shadow, area, arrow_type,
2632 x += (width - 5) / 2;
2633 y += (height - 7) / 2;
2635 draw_harrow (window, style->fg_gc[state], shadow, area, arrow_type,
2642 gtk_default_draw_diamond (GtkStyle *style,
2644 GtkStateType state_type,
2645 GtkShadowType shadow_type,
2648 const gchar *detail,
2656 GdkGC *outer_nw = NULL;
2657 GdkGC *outer_ne = NULL;
2658 GdkGC *outer_sw = NULL;
2659 GdkGC *outer_se = NULL;
2660 GdkGC *middle_nw = NULL;
2661 GdkGC *middle_ne = NULL;
2662 GdkGC *middle_sw = NULL;
2663 GdkGC *middle_se = NULL;
2664 GdkGC *inner_nw = NULL;
2665 GdkGC *inner_ne = NULL;
2666 GdkGC *inner_sw = NULL;
2667 GdkGC *inner_se = NULL;
2669 g_return_if_fail (GTK_IS_STYLE (style));
2670 g_return_if_fail (window != NULL);
2672 sanitize_size (window, &width, &height);
2674 half_width = width / 2;
2675 half_height = height / 2;
2679 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
2680 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
2681 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
2682 gdk_gc_set_clip_rectangle (style->black_gc, area);
2685 switch (shadow_type)
2688 inner_sw = inner_se = style->bg_gc[state_type];
2689 middle_sw = middle_se = style->light_gc[state_type];
2690 outer_sw = outer_se = style->light_gc[state_type];
2691 inner_nw = inner_ne = style->black_gc;
2692 middle_nw = middle_ne = style->dark_gc[state_type];
2693 outer_nw = outer_ne = style->dark_gc[state_type];
2696 case GTK_SHADOW_OUT:
2697 inner_sw = inner_se = style->dark_gc[state_type];
2698 middle_sw = middle_se = style->dark_gc[state_type];
2699 outer_sw = outer_se = style->black_gc;
2700 inner_nw = inner_ne = style->bg_gc[state_type];
2701 middle_nw = middle_ne = style->light_gc[state_type];
2702 outer_nw = outer_ne = style->light_gc[state_type];
2705 case GTK_SHADOW_ETCHED_IN:
2706 inner_sw = inner_se = style->bg_gc[state_type];
2707 middle_sw = middle_se = style->dark_gc[state_type];
2708 outer_sw = outer_se = style->light_gc[state_type];
2709 inner_nw = inner_ne = style->bg_gc[state_type];
2710 middle_nw = middle_ne = style->light_gc[state_type];
2711 outer_nw = outer_ne = style->dark_gc[state_type];
2714 case GTK_SHADOW_ETCHED_OUT:
2715 inner_sw = inner_se = style->bg_gc[state_type];
2716 middle_sw = middle_se = style->light_gc[state_type];
2717 outer_sw = outer_se = style->dark_gc[state_type];
2718 inner_nw = inner_ne = style->bg_gc[state_type];
2719 middle_nw = middle_ne = style->dark_gc[state_type];
2720 outer_nw = outer_ne = style->light_gc[state_type];
2730 gdk_draw_line (window, inner_sw,
2731 x + 2, y + half_height,
2732 x + half_width, y + height - 2);
2733 gdk_draw_line (window, inner_se,
2734 x + half_width, y + height - 2,
2735 x + width - 2, y + half_height);
2736 gdk_draw_line (window, middle_sw,
2737 x + 1, y + half_height,
2738 x + half_width, y + height - 1);
2739 gdk_draw_line (window, middle_se,
2740 x + half_width, y + height - 1,
2741 x + width - 1, y + half_height);
2742 gdk_draw_line (window, outer_sw,
2744 x + half_width, y + height);
2745 gdk_draw_line (window, outer_se,
2746 x + half_width, y + height,
2747 x + width, y + half_height);
2749 gdk_draw_line (window, inner_nw,
2750 x + 2, y + half_height,
2751 x + half_width, y + 2);
2752 gdk_draw_line (window, inner_ne,
2753 x + half_width, y + 2,
2754 x + width - 2, y + half_height);
2755 gdk_draw_line (window, middle_nw,
2756 x + 1, y + half_height,
2757 x + half_width, y + 1);
2758 gdk_draw_line (window, middle_ne,
2759 x + half_width, y + 1,
2760 x + width - 1, y + half_height);
2761 gdk_draw_line (window, outer_nw,
2764 gdk_draw_line (window, outer_ne,
2766 x + width, y + half_height);
2771 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
2772 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2773 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
2774 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2779 gtk_default_draw_string (GtkStyle *style,
2781 GtkStateType state_type,
2784 const gchar *detail,
2787 const gchar *string)
2789 g_return_if_fail (GTK_IS_STYLE (style));
2790 g_return_if_fail (window != NULL);
2794 gdk_gc_set_clip_rectangle (style->white_gc, area);
2795 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], area);
2798 if (state_type == GTK_STATE_INSENSITIVE)
2799 gdk_draw_string (window, style->font, style->white_gc, x + 1, y + 1, string);
2801 gdk_draw_string (window, style->font, style->fg_gc[state_type], x, y, string);
2805 gdk_gc_set_clip_rectangle (style->white_gc, NULL);
2806 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], NULL);
2811 option_menu_get_props (GtkWidget *widget,
2812 GtkRequisition *indicator_size,
2813 GtkBorder *indicator_spacing)
2815 GtkRequisition *tmp_size = NULL;
2816 GtkBorder *tmp_spacing = NULL;
2819 gtk_widget_style_get (widget,
2820 "indicator_size", &tmp_size,
2821 "indicator_spacing", &tmp_spacing,
2826 *indicator_size = *tmp_size;
2830 *indicator_size = default_option_indicator_size;
2834 *indicator_spacing = *tmp_spacing;
2835 g_free (tmp_spacing);
2838 *indicator_spacing = default_option_indicator_spacing;
2842 gtk_default_draw_box (GtkStyle *style,
2844 GtkStateType state_type,
2845 GtkShadowType shadow_type,
2848 const gchar *detail,
2854 g_return_if_fail (GTK_IS_STYLE (style));
2855 g_return_if_fail (window != NULL);
2857 sanitize_size (window, &width, &height);
2859 if (!style->bg_pixmap[state_type] ||
2860 GDK_IS_PIXMAP (window))
2863 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
2865 gdk_draw_rectangle (window, style->bg_gc[state_type], TRUE,
2866 x, y, width, height);
2868 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2871 gtk_style_apply_default_background (style, window,
2872 widget && !GTK_WIDGET_NO_WINDOW (widget),
2873 state_type, area, x, y, width, height);
2875 gtk_paint_shadow (style, window, state_type, shadow_type, area, widget, detail,
2876 x, y, width, height);
2878 if (detail && strcmp (detail, "optionmenu") == 0)
2880 GtkRequisition indicator_size;
2881 GtkBorder indicator_spacing;
2883 option_menu_get_props (widget, &indicator_size, &indicator_spacing);
2885 sanitize_size (window, &width, &height);
2887 gtk_paint_vline (style, window, state_type, area, widget,
2889 y + style->ythickness + 1,
2890 y + height - style->ythickness - 3,
2891 x + width - (indicator_size.width + indicator_spacing.left + indicator_spacing.right) - style->xthickness);
2896 get_darkened_gc (GdkWindow *window,
2900 GdkColor src = *color;
2904 gc = gdk_gc_new (window);
2906 while (darken_count)
2908 gtk_style_shade (&src, &shaded, 0.93);
2913 gdk_gc_set_rgb_fg_color (gc, &shaded);
2919 gtk_default_draw_flat_box (GtkStyle *style,
2921 GtkStateType state_type,
2922 GtkShadowType shadow_type,
2925 const gchar *detail,
2932 GdkGC *freeme = NULL;
2934 g_return_if_fail (GTK_IS_STYLE (style));
2935 g_return_if_fail (window != NULL);
2937 sanitize_size (window, &width, &height);
2941 if (state_type == GTK_STATE_SELECTED)
2943 if (!strcmp ("text", detail))
2944 gc1 = style->bg_gc[GTK_STATE_SELECTED];
2945 else if (!strncmp ("cell_even", detail, strlen ("cell_even")) ||
2946 !strncmp ("cell_odd", detail, strlen ("cell_odd")))
2948 /* This has to be really broken; alex made me do it. -jrb */
2949 if (GTK_WIDGET_HAS_FOCUS (widget))
2950 gc1 = style->base_gc[state_type];
2952 gc1 = style->base_gc[GTK_STATE_ACTIVE];
2956 gc1 = style->bg_gc[state_type];
2961 if (!strcmp ("viewportbin", detail))
2962 gc1 = style->bg_gc[GTK_STATE_NORMAL];
2963 else if (!strcmp ("entry_bg", detail))
2964 gc1 = style->base_gc[state_type];
2966 /* For trees: even rows are base color, odd rows are a shade of
2967 * the base color, the sort column is a shade of the original color
2971 /* FIXME when we have style properties, clean this up.
2974 else if (!strcmp ("cell_even", detail) ||
2975 !strcmp ("cell_odd", detail) ||
2976 !strcmp ("cell_even_ruled", detail))
2978 gc1 = style->base_gc[state_type];
2980 else if (!strcmp ("cell_even_sorted", detail) ||
2981 !strcmp ("cell_odd_sorted", detail) ||
2982 !strcmp ("cell_odd_ruled", detail) ||
2983 !strcmp ("cell_even_ruled_sorted", detail))
2985 freeme = get_darkened_gc (window, &style->base[state_type], 1);
2988 else if (!strcmp ("cell_odd_ruled_sorted", detail))
2990 freeme = get_darkened_gc (window, &style->base[state_type], 2);
2994 gc1 = style->bg_gc[state_type];
2998 gc1 = style->bg_gc[state_type];
3000 if (!style->bg_pixmap[state_type] || gc1 != style->bg_gc[state_type] ||
3001 GDK_IS_PIXMAP (window))
3004 gdk_gc_set_clip_rectangle (gc1, area);
3006 gdk_draw_rectangle (window, gc1, TRUE,
3007 x, y, width, height);
3009 if (detail && !strcmp ("tooltip", detail))
3010 gdk_draw_rectangle (window, style->black_gc, FALSE,
3011 x, y, width - 1, height - 1);
3014 gdk_gc_set_clip_rectangle (gc1, NULL);
3017 gtk_style_apply_default_background (style, window,
3018 widget && !GTK_WIDGET_NO_WINDOW (widget),
3019 state_type, area, x, y, width, height);
3023 g_object_unref (G_OBJECT (freeme));
3027 gtk_default_draw_check (GtkStyle *style,
3029 GtkStateType state_type,
3030 GtkShadowType shadow_type,
3033 const gchar *detail,
3039 if (detail && strcmp (detail, "cellcheck") == 0)
3041 gdk_draw_rectangle (window,
3042 widget->style->fg_gc[state_type],
3047 if (shadow_type == GTK_SHADOW_IN)
3049 gdk_draw_line (window,
3050 widget->style->fg_gc[state_type],
3054 gdk_draw_line (window,
3055 widget->style->fg_gc[state_type],
3064 x -= (1 + INDICATOR_PART_SIZE - width) / 2;
3065 y -= (1 + INDICATOR_PART_SIZE - height) / 2;
3067 if (strcmp (detail, "check") == 0) /* Menu item */
3069 if (shadow_type == GTK_SHADOW_IN)
3071 draw_part (window, style->black_gc, area, x, y, CHECK_TEXT);
3072 draw_part (window, style->dark_gc[state_type], area, x, y, CHECK_AA);
3077 draw_part (window, style->black_gc, area, x, y, CHECK_BLACK);
3078 draw_part (window, style->dark_gc[state_type], area, x, y, CHECK_DARK);
3079 draw_part (window, style->mid_gc[state_type], area, x, y, CHECK_MID);
3080 draw_part (window, style->light_gc[state_type], area, x, y, CHECK_LIGHT);
3081 draw_part (window, style->base_gc[state_type], area, x, y, CHECK_BASE);
3083 if (shadow_type == GTK_SHADOW_IN)
3085 draw_part (window, style->text_gc[state_type], area, x, y, CHECK_TEXT);
3086 draw_part (window, style->text_aa_gc[state_type], area, x, y, CHECK_AA);
3094 gtk_default_draw_option (GtkStyle *style,
3096 GtkStateType state_type,
3097 GtkShadowType shadow_type,
3100 const gchar *detail,
3106 if (detail && strcmp (detail, "cellradio") == 0)
3108 gdk_draw_arc (window,
3109 widget->style->fg_gc[state_type],
3116 if (shadow_type == GTK_SHADOW_IN)
3118 gdk_draw_arc (window,
3119 widget->style->fg_gc[state_type],
3130 x -= (1 + INDICATOR_PART_SIZE - width) / 2;
3131 y -= (1 + INDICATOR_PART_SIZE - height) / 2;
3133 if (strcmp (detail, "option") == 0) /* Menu item */
3135 if (shadow_type == GTK_SHADOW_IN)
3136 draw_part (window, style->fg_gc[state_type], area, x, y, RADIO_TEXT);
3140 draw_part (window, style->black_gc, area, x, y, RADIO_BLACK);
3141 draw_part (window, style->dark_gc[state_type], area, x, y, RADIO_DARK);
3142 draw_part (window, style->mid_gc[state_type], area, x, y, RADIO_MID);
3143 draw_part (window, style->light_gc[state_type], area, x, y, RADIO_LIGHT);
3144 draw_part (window, style->base_gc[state_type], area, x, y, RADIO_BASE);
3146 if (shadow_type == GTK_SHADOW_IN)
3147 draw_part (window, style->text_gc[state_type], area, x, y, RADIO_TEXT);
3153 gtk_default_draw_tab (GtkStyle *style,
3155 GtkStateType state_type,
3156 GtkShadowType shadow_type,
3159 const gchar *detail,
3165 GtkRequisition indicator_size;
3166 GtkBorder indicator_spacing;
3168 option_menu_get_props (widget, &indicator_size, &indicator_spacing);
3170 x += (width - indicator_size.width) / 2;
3171 y += (height - indicator_size.height) / 2 - 1;
3173 draw_varrow (window, style->black_gc, shadow_type, area, GTK_ARROW_UP,
3174 x, y, indicator_size.width, 5);
3175 draw_varrow (window, style->black_gc, shadow_type, area, GTK_ARROW_DOWN,
3176 x, y + 8, indicator_size.width, 5);
3180 gtk_default_draw_shadow_gap (GtkStyle *style,
3182 GtkStateType state_type,
3183 GtkShadowType shadow_type,
3186 const gchar *detail,
3191 GtkPositionType gap_side,
3200 g_return_if_fail (GTK_IS_STYLE (style));
3201 g_return_if_fail (window != NULL);
3203 sanitize_size (window, &width, &height);
3205 switch (shadow_type)
3207 case GTK_SHADOW_NONE:
3210 gc1 = style->dark_gc[state_type];
3211 gc2 = style->black_gc;
3212 gc3 = style->bg_gc[state_type];
3213 gc4 = style->light_gc[state_type];
3215 case GTK_SHADOW_ETCHED_IN:
3216 gc1 = style->dark_gc[state_type];
3217 gc2 = style->light_gc[state_type];
3218 gc3 = style->dark_gc[state_type];
3219 gc4 = style->light_gc[state_type];
3221 case GTK_SHADOW_OUT:
3222 gc1 = style->light_gc[state_type];
3223 gc2 = style->bg_gc[state_type];
3224 gc3 = style->dark_gc[state_type];
3225 gc4 = style->black_gc;
3227 case GTK_SHADOW_ETCHED_OUT:
3228 gc1 = style->light_gc[state_type];
3229 gc2 = style->dark_gc[state_type];
3230 gc3 = style->light_gc[state_type];
3231 gc4 = style->dark_gc[state_type];
3236 gdk_gc_set_clip_rectangle (gc1, area);
3237 gdk_gc_set_clip_rectangle (gc2, area);
3238 gdk_gc_set_clip_rectangle (gc3, area);
3239 gdk_gc_set_clip_rectangle (gc4, area);
3242 switch (shadow_type)
3244 case GTK_SHADOW_NONE:
3246 case GTK_SHADOW_OUT:
3247 case GTK_SHADOW_ETCHED_IN:
3248 case GTK_SHADOW_ETCHED_OUT:
3252 gdk_draw_line (window, gc1,
3253 x, y, x, y + height - 1);
3254 gdk_draw_line (window, gc2,
3255 x + 1, y, x + 1, y + height - 2);
3257 gdk_draw_line (window, gc3,
3258 x + 1, y + height - 2, x + width - 2, y + height - 2);
3259 gdk_draw_line (window, gc3,
3260 x + width - 2, y, x + width - 2, y + height - 2);
3261 gdk_draw_line (window, gc4,
3262 x, y + height - 1, x + width - 1, y + height - 1);
3263 gdk_draw_line (window, gc4,
3264 x + width - 1, y, x + width - 1, y + height - 1);
3267 gdk_draw_line (window, gc1,
3268 x, y, x + gap_x - 1, y);
3269 gdk_draw_line (window, gc2,
3270 x + 1, y + 1, x + gap_x - 1, y + 1);
3271 gdk_draw_line (window, gc2,
3272 x + gap_x, y, x + gap_x, y);
3274 if ((width - (gap_x + gap_width)) > 0)
3276 gdk_draw_line (window, gc1,
3277 x + gap_x + gap_width, y, x + width - 2, y);
3278 gdk_draw_line (window, gc2,
3279 x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
3280 gdk_draw_line (window, gc2,
3281 x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
3284 case GTK_POS_BOTTOM:
3285 gdk_draw_line (window, gc1,
3286 x, y, x + width - 1, y);
3287 gdk_draw_line (window, gc1,
3288 x, y, x, y + height - 1);
3289 gdk_draw_line (window, gc2,
3290 x + 1, y + 1, x + width - 2, y + 1);
3291 gdk_draw_line (window, gc2,
3292 x + 1, y + 1, x + 1, y + height - 1);
3294 gdk_draw_line (window, gc3,
3295 x + width - 2, y + 1, x + width - 2, y + height - 1);
3296 gdk_draw_line (window, gc4,
3297 x + width - 1, y, x + width - 1, y + height - 1);
3300 gdk_draw_line (window, gc4,
3301 x, y + height - 1, x + gap_x - 1, y + height - 1);
3302 gdk_draw_line (window, gc3,
3303 x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
3304 gdk_draw_line (window, gc3,
3305 x + gap_x, y + height - 1, x + gap_x, y + height - 1);
3307 if ((width - (gap_x + gap_width)) > 0)
3309 gdk_draw_line (window, gc4,
3310 x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
3311 gdk_draw_line (window, gc3,
3312 x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
3313 gdk_draw_line (window, gc3,
3314 x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
3318 gdk_draw_line (window, gc1,
3319 x, y, x + width - 1, y);
3320 gdk_draw_line (window, gc2,
3321 x, y + 1, x + width - 2, y + 1);
3323 gdk_draw_line (window, gc3,
3324 x, y + height - 2, x + width - 2, y + height - 2);
3325 gdk_draw_line (window, gc3,
3326 x + width - 2, y + 1, x + width - 2, y + height - 2);
3327 gdk_draw_line (window, gc4,
3328 x, y + height - 1, x + width - 1, y + height - 1);
3329 gdk_draw_line (window, gc4,
3330 x + width - 1, y, x + width - 1, y + height - 1);
3333 gdk_draw_line (window, gc1,
3334 x, y, x, y + gap_x - 1);
3335 gdk_draw_line (window, gc2,
3336 x + 1, y + 1, x + 1, y + gap_x - 1);
3337 gdk_draw_line (window, gc2,
3338 x, y + gap_x, x, y + gap_x);
3340 if ((width - (gap_x + gap_width)) > 0)
3342 gdk_draw_line (window, gc1,
3343 x, y + gap_x + gap_width, x, y + height - 2);
3344 gdk_draw_line (window, gc2,
3345 x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
3346 gdk_draw_line (window, gc2,
3347 x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
3351 gdk_draw_line (window, gc1,
3352 x, y, x + width - 1, y);
3353 gdk_draw_line (window, gc1,
3354 x, y, x, y + height - 1);
3355 gdk_draw_line (window, gc2,
3356 x + 1, y + 1, x + width - 1, y + 1);
3357 gdk_draw_line (window, gc2,
3358 x + 1, y + 1, x + 1, y + height - 2);
3360 gdk_draw_line (window, gc3,
3361 x + 1, y + height - 2, x + width - 1, y + height - 2);
3362 gdk_draw_line (window, gc4,
3363 x, y + height - 1, x + width - 1, y + height - 1);
3366 gdk_draw_line (window, gc4,
3367 x + width - 1, y, x + width - 1, y + gap_x - 1);
3368 gdk_draw_line (window, gc3,
3369 x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
3370 gdk_draw_line (window, gc3,
3371 x + width - 1, y + gap_x, x + width - 1, y + gap_x);
3373 if ((width - (gap_x + gap_width)) > 0)
3375 gdk_draw_line (window, gc4,
3376 x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
3377 gdk_draw_line (window, gc3,
3378 x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
3379 gdk_draw_line (window, gc3,
3380 x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
3388 gdk_gc_set_clip_rectangle (gc1, NULL);
3389 gdk_gc_set_clip_rectangle (gc2, NULL);
3390 gdk_gc_set_clip_rectangle (gc3, NULL);
3391 gdk_gc_set_clip_rectangle (gc4, NULL);
3396 gtk_default_draw_box_gap (GtkStyle *style,
3398 GtkStateType state_type,
3399 GtkShadowType shadow_type,
3402 const gchar *detail,
3407 GtkPositionType gap_side,
3416 g_return_if_fail (GTK_IS_STYLE (style));
3417 g_return_if_fail (window != NULL);
3419 gtk_style_apply_default_background (style, window,
3420 widget && !GTK_WIDGET_NO_WINDOW (widget),
3421 state_type, area, x, y, width, height);
3423 sanitize_size (window, &width, &height);
3425 switch (shadow_type)
3427 case GTK_SHADOW_NONE:
3430 gc1 = style->dark_gc[state_type];
3431 gc2 = style->black_gc;
3432 gc3 = style->bg_gc[state_type];
3433 gc4 = style->light_gc[state_type];
3435 case GTK_SHADOW_ETCHED_IN:
3436 gc1 = style->dark_gc[state_type];
3437 gc2 = style->light_gc[state_type];
3438 gc3 = style->dark_gc[state_type];
3439 gc4 = style->light_gc[state_type];
3441 case GTK_SHADOW_OUT:
3442 gc1 = style->light_gc[state_type];
3443 gc2 = style->bg_gc[state_type];
3444 gc3 = style->dark_gc[state_type];
3445 gc4 = style->black_gc;
3447 case GTK_SHADOW_ETCHED_OUT:
3448 gc1 = style->light_gc[state_type];
3449 gc2 = style->dark_gc[state_type];
3450 gc3 = style->light_gc[state_type];
3451 gc4 = style->dark_gc[state_type];
3457 gdk_gc_set_clip_rectangle (gc1, area);
3458 gdk_gc_set_clip_rectangle (gc2, area);
3459 gdk_gc_set_clip_rectangle (gc3, area);
3460 gdk_gc_set_clip_rectangle (gc4, area);
3463 switch (shadow_type)
3465 case GTK_SHADOW_NONE:
3467 case GTK_SHADOW_OUT:
3468 case GTK_SHADOW_ETCHED_IN:
3469 case GTK_SHADOW_ETCHED_OUT:
3473 gdk_draw_line (window, gc1,
3474 x, y, x, y + height - 1);
3475 gdk_draw_line (window, gc2,
3476 x + 1, y, x + 1, y + height - 2);
3478 gdk_draw_line (window, gc3,
3479 x + 1, y + height - 2, x + width - 2, y + height - 2);
3480 gdk_draw_line (window, gc3,
3481 x + width - 2, y, x + width - 2, y + height - 2);
3482 gdk_draw_line (window, gc4,
3483 x, y + height - 1, x + width - 1, y + height - 1);
3484 gdk_draw_line (window, gc4,
3485 x + width - 1, y, x + width - 1, y + height - 1);
3488 gdk_draw_line (window, gc1,
3489 x, y, x + gap_x - 1, y);
3490 gdk_draw_line (window, gc2,
3491 x + 1, y + 1, x + gap_x - 1, y + 1);
3492 gdk_draw_line (window, gc2,
3493 x + gap_x, y, x + gap_x, y);
3495 if ((width - (gap_x + gap_width)) > 0)
3497 gdk_draw_line (window, gc1,
3498 x + gap_x + gap_width, y, x + width - 2, y);
3499 gdk_draw_line (window, gc2,
3500 x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
3501 gdk_draw_line (window, gc2,
3502 x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
3505 case GTK_POS_BOTTOM:
3506 gdk_draw_line (window, gc1,
3507 x, y, x + width - 1, y);
3508 gdk_draw_line (window, gc1,
3509 x, y, x, y + height - 1);
3510 gdk_draw_line (window, gc2,
3511 x + 1, y + 1, x + width - 2, y + 1);
3512 gdk_draw_line (window, gc2,
3513 x + 1, y + 1, x + 1, y + height - 1);
3515 gdk_draw_line (window, gc3,
3516 x + width - 2, y + 1, x + width - 2, y + height - 1);
3517 gdk_draw_line (window, gc4,
3518 x + width - 1, y, x + width - 1, y + height - 1);
3521 gdk_draw_line (window, gc4,
3522 x, y + height - 1, x + gap_x - 1, y + height - 1);
3523 gdk_draw_line (window, gc3,
3524 x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
3525 gdk_draw_line (window, gc3,
3526 x + gap_x, y + height - 1, x + gap_x, y + height - 1);
3528 if ((width - (gap_x + gap_width)) > 0)
3530 gdk_draw_line (window, gc4,
3531 x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
3532 gdk_draw_line (window, gc3,
3533 x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
3534 gdk_draw_line (window, gc3,
3535 x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
3539 gdk_draw_line (window, gc1,
3540 x, y, x + width - 1, y);
3541 gdk_draw_line (window, gc2,
3542 x, y + 1, x + width - 2, y + 1);
3544 gdk_draw_line (window, gc3,
3545 x, y + height - 2, x + width - 2, y + height - 2);
3546 gdk_draw_line (window, gc3,
3547 x + width - 2, y + 1, x + width - 2, y + height - 2);
3548 gdk_draw_line (window, gc4,
3549 x, y + height - 1, x + width - 1, y + height - 1);
3550 gdk_draw_line (window, gc4,
3551 x + width - 1, y, x + width - 1, y + height - 1);
3554 gdk_draw_line (window, gc1,
3555 x, y, x, y + gap_x - 1);
3556 gdk_draw_line (window, gc2,
3557 x + 1, y + 1, x + 1, y + gap_x - 1);
3558 gdk_draw_line (window, gc2,
3559 x, y + gap_x, x, y + gap_x);
3561 if ((width - (gap_x + gap_width)) > 0)
3563 gdk_draw_line (window, gc1,
3564 x, y + gap_x + gap_width, x, y + height - 2);
3565 gdk_draw_line (window, gc2,
3566 x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
3567 gdk_draw_line (window, gc2,
3568 x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
3572 gdk_draw_line (window, gc1,
3573 x, y, x + width - 1, y);
3574 gdk_draw_line (window, gc1,
3575 x, y, x, y + height - 1);
3576 gdk_draw_line (window, gc2,
3577 x + 1, y + 1, x + width - 1, y + 1);
3578 gdk_draw_line (window, gc2,
3579 x + 1, y + 1, x + 1, y + height - 2);
3581 gdk_draw_line (window, gc3,
3582 x + 1, y + height - 2, x + width - 1, y + height - 2);
3583 gdk_draw_line (window, gc4,
3584 x, y + height - 1, x + width - 1, y + height - 1);
3587 gdk_draw_line (window, gc4,
3588 x + width - 1, y, x + width - 1, y + gap_x - 1);
3589 gdk_draw_line (window, gc3,
3590 x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
3591 gdk_draw_line (window, gc3,
3592 x + width - 1, y + gap_x, x + width - 1, y + gap_x);
3594 if ((width - (gap_x + gap_width)) > 0)
3596 gdk_draw_line (window, gc4,
3597 x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
3598 gdk_draw_line (window, gc3,
3599 x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
3600 gdk_draw_line (window, gc3,
3601 x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
3609 gdk_gc_set_clip_rectangle (gc1, NULL);
3610 gdk_gc_set_clip_rectangle (gc2, NULL);
3611 gdk_gc_set_clip_rectangle (gc3, NULL);
3612 gdk_gc_set_clip_rectangle (gc4, NULL);
3617 gtk_default_draw_extension (GtkStyle *style,
3619 GtkStateType state_type,
3620 GtkShadowType shadow_type,
3623 const gchar *detail,
3628 GtkPositionType gap_side)
3635 g_return_if_fail (GTK_IS_STYLE (style));
3636 g_return_if_fail (window != NULL);
3638 gtk_style_apply_default_background (style, window,
3639 widget && !GTK_WIDGET_NO_WINDOW (widget),
3640 GTK_STATE_NORMAL, area, x, y, width, height);
3642 sanitize_size (window, &width, &height);
3644 switch (shadow_type)
3646 case GTK_SHADOW_NONE:
3649 gc1 = style->dark_gc[state_type];
3650 gc2 = style->black_gc;
3651 gc3 = style->bg_gc[state_type];
3652 gc4 = style->light_gc[state_type];
3654 case GTK_SHADOW_ETCHED_IN:
3655 gc1 = style->dark_gc[state_type];
3656 gc2 = style->light_gc[state_type];
3657 gc3 = style->dark_gc[state_type];
3658 gc4 = style->light_gc[state_type];
3660 case GTK_SHADOW_OUT:
3661 gc1 = style->light_gc[state_type];
3662 gc2 = style->bg_gc[state_type];
3663 gc3 = style->dark_gc[state_type];
3664 gc4 = style->black_gc;
3666 case GTK_SHADOW_ETCHED_OUT:
3667 gc1 = style->light_gc[state_type];
3668 gc2 = style->dark_gc[state_type];
3669 gc3 = style->light_gc[state_type];
3670 gc4 = style->dark_gc[state_type];
3676 gdk_gc_set_clip_rectangle (gc1, area);
3677 gdk_gc_set_clip_rectangle (gc2, area);
3678 gdk_gc_set_clip_rectangle (gc3, area);
3679 gdk_gc_set_clip_rectangle (gc4, area);
3682 switch (shadow_type)
3684 case GTK_SHADOW_NONE:
3686 case GTK_SHADOW_OUT:
3687 case GTK_SHADOW_ETCHED_IN:
3688 case GTK_SHADOW_ETCHED_OUT:
3692 gtk_style_apply_default_background (style, window,
3693 widget && !GTK_WIDGET_NO_WINDOW (widget),
3695 x + style->xthickness,
3697 width - (2 * style->xthickness),
3698 height - (style->ythickness));
3699 gdk_draw_line (window, gc1,
3700 x, y, x, y + height - 2);
3701 gdk_draw_line (window, gc2,
3702 x + 1, y, x + 1, y + height - 2);
3704 gdk_draw_line (window, gc3,
3705 x + 2, y + height - 2, x + width - 2, y + height - 2);
3706 gdk_draw_line (window, gc3,
3707 x + width - 2, y, x + width - 2, y + height - 2);
3708 gdk_draw_line (window, gc4,
3709 x + 1, y + height - 1, x + width - 2, y + height - 1);
3710 gdk_draw_line (window, gc4,
3711 x + width - 1, y, x + width - 1, y + height - 2);
3713 case GTK_POS_BOTTOM:
3714 gtk_style_apply_default_background (style, window,
3715 widget && !GTK_WIDGET_NO_WINDOW (widget),
3717 x + style->xthickness,
3718 y + style->ythickness,
3719 width - (2 * style->xthickness),
3720 height - (style->ythickness));
3721 gdk_draw_line (window, gc1,
3722 x + 1, y, x + width - 2, y);
3723 gdk_draw_line (window, gc1,
3724 x, y + 1, x, y + height - 1);
3725 gdk_draw_line (window, gc2,
3726 x + 1, y + 1, x + width - 2, y + 1);
3727 gdk_draw_line (window, gc2,
3728 x + 1, y + 1, x + 1, y + height - 1);
3730 gdk_draw_line (window, gc3,
3731 x + width - 2, y + 2, x + width - 2, y + height - 1);
3732 gdk_draw_line (window, gc4,
3733 x + width - 1, y + 1, x + width - 1, y + height - 1);
3736 gtk_style_apply_default_background (style, window,
3737 widget && !GTK_WIDGET_NO_WINDOW (widget),
3740 y + style->ythickness,
3741 width - (style->xthickness),
3742 height - (2 * style->ythickness));
3743 gdk_draw_line (window, gc1,
3744 x, y, x + width - 2, y);
3745 gdk_draw_line (window, gc2,
3746 x + 1, y + 1, x + width - 2, y + 1);
3748 gdk_draw_line (window, gc3,
3749 x, y + height - 2, x + width - 2, y + height - 2);
3750 gdk_draw_line (window, gc3,
3751 x + width - 2, y + 2, x + width - 2, y + height - 2);
3752 gdk_draw_line (window, gc4,
3753 x, y + height - 1, x + width - 2, y + height - 1);
3754 gdk_draw_line (window, gc4,
3755 x + width - 1, y + 1, x + width - 1, y + height - 2);
3758 gtk_style_apply_default_background (style, window,
3759 widget && !GTK_WIDGET_NO_WINDOW (widget),
3761 x + style->xthickness,
3762 y + style->ythickness,
3763 width - (style->xthickness),
3764 height - (2 * style->ythickness));
3765 gdk_draw_line (window, gc1,
3766 x + 1, y, x + width - 1, y);
3767 gdk_draw_line (window, gc1,
3768 x, y + 1, x, y + height - 2);
3769 gdk_draw_line (window, gc2,
3770 x + 1, y + 1, x + width - 1, y + 1);
3771 gdk_draw_line (window, gc2,
3772 x + 1, y + 1, x + 1, y + height - 2);
3774 gdk_draw_line (window, gc3,
3775 x + 2, y + height - 2, x + width - 1, y + height - 2);
3776 gdk_draw_line (window, gc4,
3777 x + 1, y + height - 1, x + width - 1, y + height - 1);
3784 gdk_gc_set_clip_rectangle (gc1, NULL);
3785 gdk_gc_set_clip_rectangle (gc2, NULL);
3786 gdk_gc_set_clip_rectangle (gc3, NULL);
3787 gdk_gc_set_clip_rectangle (gc4, NULL);
3792 gtk_default_draw_focus (GtkStyle *style,
3796 const gchar *detail,
3804 sanitize_size (window, &width, &height);
3807 gdk_gc_set_clip_rectangle (style->black_gc, area);
3809 gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_ON_OFF_DASH, 0, 0);
3811 if (detail && !strcmp (detail, "add-mode"))
3812 gdk_gc_set_dashes (style->black_gc, 0, "\4\4", 2);
3814 gdk_gc_set_dashes (style->black_gc, 0, "\1\1", 2);
3818 points[1].x = x + width;
3820 points[2].x = x + width;
3821 points[2].y = y + height;
3823 points[3].y = y + height;
3824 points[4] = points[0];
3826 gdk_draw_polygon (window, style->black_gc, FALSE, points, 4);
3827 gdk_gc_set_line_attributes (style->black_gc, 0, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
3830 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
3834 gtk_default_draw_slider (GtkStyle *style,
3836 GtkStateType state_type,
3837 GtkShadowType shadow_type,
3840 const gchar *detail,
3845 GtkOrientation orientation)
3847 g_return_if_fail (GTK_IS_STYLE (style));
3848 g_return_if_fail (window != NULL);
3850 sanitize_size (window, &width, &height);
3852 gtk_paint_box (style, window, state_type, shadow_type,
3853 area, widget, detail, x, y, width, height);
3856 (strcmp ("hscale", detail) == 0 ||
3857 strcmp ("vscale", detail) == 0))
3859 if (orientation == GTK_ORIENTATION_HORIZONTAL)
3860 gtk_paint_vline (style, window, state_type, area, widget, detail,
3861 y + style->ythickness,
3862 y + height - style->ythickness - 1, x + width / 2);
3864 gtk_paint_hline (style, window, state_type, area, widget, detail,
3865 x + style->xthickness,
3866 x + width - style->xthickness - 1, y + height / 2);
3871 draw_dot (GdkWindow *window,
3879 size = CLAMP (size, 2, 3);
3883 gdk_draw_point (window, light_gc, x, y);
3884 gdk_draw_point (window, light_gc, x+1, y+1);
3886 else if (size == 3);
3888 gdk_draw_point (window, light_gc, x, y);
3889 gdk_draw_point (window, light_gc, x+1, y);
3890 gdk_draw_point (window, light_gc, x, y+1);
3891 gdk_draw_point (window, dark_gc, x+1, y+2);
3892 gdk_draw_point (window, dark_gc, x+2, y+1);
3893 gdk_draw_point (window, dark_gc, x+2, y+2);
3898 gtk_default_draw_handle (GtkStyle *style,
3900 GtkStateType state_type,
3901 GtkShadowType shadow_type,
3904 const gchar *detail,
3909 GtkOrientation orientation)
3912 gint xthick, ythick;
3913 GdkGC *light_gc, *dark_gc;
3918 g_return_if_fail (GTK_IS_STYLE (style));
3919 g_return_if_fail (window != NULL);
3921 sanitize_size (window, &width, &height);
3923 gtk_paint_box (style, window, state_type, shadow_type, area, widget,
3924 detail, x, y, width, height);
3927 if (!strcmp (detail, "paned"))
3929 /* we want to ignore the shadow border in paned widgets */
3933 light_gc = style->light_gc[state_type];
3934 dark_gc = style->black_gc;
3938 xthick = style->xthickness;
3939 ythick = style->ythickness;
3941 light_gc = style->light_gc[state_type];
3942 dark_gc = style->dark_gc[state_type];
3945 rect.x = x + xthick;
3946 rect.y = y + ythick;
3947 rect.width = width - (xthick * 2);
3948 rect.height = height - (ythick * 2);
3951 intersect = gdk_rectangle_intersect (area, &rect, &dest);
3961 gdk_gc_set_clip_rectangle (light_gc, &dest);
3962 gdk_gc_set_clip_rectangle (dark_gc, &dest);
3964 if (!strcmp (detail, "paned"))
3969 gdk_window_get_size (window, &window_width, &window_height);
3971 if (orientation == GTK_ORIENTATION_HORIZONTAL)
3972 for (xx = window_width/2 - 15; xx <= window_width/2 + 15; xx += 5)
3973 draw_dot (window, light_gc, dark_gc, xx, window_height/2 - 1, 3);
3975 for (yy = window_height/2 - 15; yy <= window_height/2 + 15; yy += 5)
3976 draw_dot (window, light_gc, dark_gc, window_width/2 - 1, yy, 3);
3980 for (yy = y + ythick; yy < (y + height - ythick); yy += 3)
3981 for (xx = x + xthick; xx < (x + width - xthick); xx += 6)
3983 draw_dot (window, light_gc, dark_gc, xx, yy, 2);
3984 draw_dot (window, light_gc, dark_gc, xx + 3, yy + 1, 2);
3988 gdk_gc_set_clip_rectangle (light_gc, NULL);
3989 gdk_gc_set_clip_rectangle (dark_gc, NULL);
3993 create_expander_affine (gdouble affine[6],
4003 width = expander_size / 4.0;
4004 height = expander_size / 2.0;
4006 s = sin (degrees * G_PI / 180.0);
4007 c = cos (degrees * G_PI / 180.0);
4013 affine[4] = -width * c - height * -s + x;
4014 affine[5] = -width * s - height * c + y;
4018 apply_affine_on_point (double affine[6], GdkPoint *point)
4022 x = point->x * affine[0] + point->y * affine[2] + affine[4];
4023 y = point->x * affine[1] + point->y * affine[3] + affine[5];
4030 gtk_default_draw_expander (GtkStyle *style,
4032 GtkStateType state_type,
4035 const gchar *detail,
4038 GtkExpanderStyle expander_style)
4046 gtk_widget_style_get (widget,
4047 "expander_size", &expander_size,
4052 gdk_gc_set_clip_rectangle (style->fg_gc[GTK_STATE_NORMAL], area);
4053 gdk_gc_set_clip_rectangle (style->base_gc[GTK_STATE_NORMAL], area);
4058 points[1].x = expander_size / 2;
4059 points[1].y = expander_size / 2;
4061 points[2].y = expander_size;
4063 switch (expander_style)
4065 case GTK_EXPANDER_COLLAPSED:
4068 case GTK_EXPANDER_SEMI_COLLAPSED:
4071 case GTK_EXPANDER_SEMI_EXPANDED:
4074 case GTK_EXPANDER_EXPANDED:
4078 g_assert_not_reached ();
4081 create_expander_affine (affine, degrees, expander_size, x, y);
4083 for (i = 0; i < 3; i++)
4084 apply_affine_on_point (affine, &points[i]);
4086 if (state_type == GTK_STATE_PRELIGHT)
4088 gdk_draw_polygon (window, style->base_gc[GTK_STATE_NORMAL],
4090 gdk_draw_polygon (window, style->fg_gc[GTK_STATE_NORMAL],
4093 else if (state_type == GTK_STATE_ACTIVE)
4095 gdk_draw_polygon (window, style->light_gc[GTK_STATE_ACTIVE],
4097 gdk_draw_polygon (window, style->fg_gc[GTK_STATE_NORMAL],
4102 gdk_draw_polygon (window, style->fg_gc[GTK_STATE_NORMAL],
4107 gdk_gc_set_clip_rectangle (style->fg_gc[GTK_STATE_NORMAL], NULL);
4108 gdk_gc_set_clip_rectangle (style->base_gc[GTK_STATE_NORMAL], NULL);
4112 typedef struct _ByteRange ByteRange;
4121 range_new (guint start,
4124 ByteRange *br = g_new (ByteRange, 1);
4133 get_insensitive_layout (PangoLayout *layout)
4135 GSList *embossed_ranges = NULL;
4136 GSList *stippled_ranges = NULL;
4137 PangoLayoutIter *iter;
4138 GSList *tmp_list = NULL;
4139 PangoLayout *new_layout;
4140 PangoAttrList *attrs;
4141 GdkBitmap *stipple = NULL;
4143 iter = pango_layout_get_iter (layout);
4147 PangoLayoutRun *run;
4148 PangoAttribute *attr;
4149 gboolean need_stipple = FALSE;
4152 run = pango_layout_iter_get_run (iter);
4156 tmp_list = run->item->analysis.extra_attrs;
4158 while (tmp_list != NULL)
4160 attr = tmp_list->data;
4161 switch (attr->klass->type)
4163 case PANGO_ATTR_FOREGROUND:
4164 case PANGO_ATTR_BACKGROUND:
4165 need_stipple = TRUE;
4175 tmp_list = g_slist_next (tmp_list);
4178 br = range_new (run->item->offset, run->item->offset + run->item->length);
4181 stippled_ranges = g_slist_prepend (stippled_ranges, br);
4183 embossed_ranges = g_slist_prepend (embossed_ranges, br);
4186 while (pango_layout_iter_next_run (iter));
4188 pango_layout_iter_free (iter);
4190 new_layout = pango_layout_copy (layout);
4192 attrs = pango_layout_get_attributes (new_layout);
4196 /* Create attr list if there wasn't one */
4197 attrs = pango_attr_list_new ();
4198 pango_layout_set_attributes (new_layout, attrs);
4199 pango_attr_list_unref (attrs);
4202 tmp_list = embossed_ranges;
4203 while (tmp_list != NULL)
4205 PangoAttribute *attr;
4206 ByteRange *br = tmp_list->data;
4208 attr = gdk_pango_attr_embossed_new (TRUE);
4210 attr->start_index = br->start;
4211 attr->end_index = br->end;
4213 pango_attr_list_change (attrs, attr);
4217 tmp_list = g_slist_next (tmp_list);
4220 g_slist_free (embossed_ranges);
4222 tmp_list = stippled_ranges;
4223 while (tmp_list != NULL)
4225 PangoAttribute *attr;
4226 ByteRange *br = tmp_list->data;
4228 if (stipple == NULL)
4230 #define gray50_width 2
4231 #define gray50_height 2
4232 static char gray50_bits[] = {
4236 stipple = gdk_bitmap_create_from_data (NULL,
4237 gray50_bits, gray50_width,
4241 attr = gdk_pango_attr_stipple_new (stipple);
4243 attr->start_index = br->start;
4244 attr->end_index = br->end;
4246 pango_attr_list_change (attrs, attr);
4250 tmp_list = g_slist_next (tmp_list);
4253 g_slist_free (stippled_ranges);
4256 g_object_unref (G_OBJECT (stipple));
4262 gtk_default_draw_layout (GtkStyle *style,
4264 GtkStateType state_type,
4268 const gchar *detail,
4271 PangoLayout *layout)
4275 g_return_if_fail (GTK_IS_STYLE (style));
4276 g_return_if_fail (window != NULL);
4278 gc = use_text ? style->text_gc[state_type] : style->fg_gc[state_type];
4281 gdk_gc_set_clip_rectangle (gc, area);
4283 if (state_type == GTK_STATE_INSENSITIVE)
4287 ins = get_insensitive_layout (layout);
4289 gdk_draw_layout (window, gc, x, y, ins);
4291 g_object_unref (G_OBJECT (ins));
4295 gdk_draw_layout (window, gc, x, y, layout);
4299 gdk_gc_set_clip_rectangle (gc, NULL);
4303 gtk_default_draw_resize_grip (GtkStyle *style,
4305 GtkStateType state_type,
4308 const gchar *detail,
4315 g_return_if_fail (GTK_IS_STYLE (style));
4316 g_return_if_fail (window != NULL);
4320 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
4321 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
4322 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
4325 /* make it square, aligning to bottom right */
4328 y += (height - width);
4331 else if (height < width)
4333 x += (width - height);
4337 /* Clear background */
4338 gdk_draw_rectangle (window,
4339 style->bg_gc[state_type],
4341 x, y, width, height);
4345 case GDK_WINDOW_EDGE_SOUTH_EAST:
4352 while (xi < (x + width - 3))
4354 gdk_draw_line (window,
4355 style->light_gc[state_type],
4362 gdk_draw_line (window,
4363 style->dark_gc[state_type],
4370 gdk_draw_line (window,
4371 style->dark_gc[state_type],
4381 g_assert_not_reached ();
4387 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
4388 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
4389 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
4394 gtk_style_shade (GdkColor *a,
4402 red = (gdouble) a->red / 65535.0;
4403 green = (gdouble) a->green / 65535.0;
4404 blue = (gdouble) a->blue / 65535.0;
4406 rgb_to_hls (&red, &green, &blue);
4411 else if (green < 0.0)
4417 else if (blue < 0.0)
4420 hls_to_rgb (&red, &green, &blue);
4422 b->red = red * 65535.0;
4423 b->green = green * 65535.0;
4424 b->blue = blue * 65535.0;
4428 rgb_to_hls (gdouble *r,
4469 l = (max + min) / 2;
4476 s = (max - min) / (max + min);
4478 s = (max - min) / (2 - max - min);
4482 h = (green - blue) / delta;
4483 else if (green == max)
4484 h = 2 + (blue - red) / delta;
4485 else if (blue == max)
4486 h = 4 + (red - green) / delta;
4499 hls_to_rgb (gdouble *h,
4512 if (lightness <= 0.5)
4513 m2 = lightness * (1 + saturation);
4515 m2 = lightness + saturation - lightness * saturation;
4516 m1 = 2 * lightness - m2;
4518 if (saturation == 0)
4533 r = m1 + (m2 - m1) * hue / 60;
4537 r = m1 + (m2 - m1) * (240 - hue) / 60;
4548 g = m1 + (m2 - m1) * hue / 60;
4552 g = m1 + (m2 - m1) * (240 - hue) / 60;
4563 b = m1 + (m2 - m1) * hue / 60;
4567 b = m1 + (m2 - m1) * (240 - hue) / 60;
4578 gtk_paint_hline (GtkStyle *style,
4580 GtkStateType state_type,
4583 const gchar *detail,
4588 g_return_if_fail (GTK_IS_STYLE (style));
4589 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_hline != NULL);
4591 GTK_STYLE_GET_CLASS (style)->draw_hline (style, window, state_type, area, widget, detail, x1, x2, y);
4595 gtk_paint_vline (GtkStyle *style,
4597 GtkStateType state_type,
4600 const gchar *detail,
4605 g_return_if_fail (GTK_IS_STYLE (style));
4606 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_vline != NULL);
4608 GTK_STYLE_GET_CLASS (style)->draw_vline (style, window, state_type, area, widget, detail, y1, y2, x);
4612 gtk_paint_shadow (GtkStyle *style,
4614 GtkStateType state_type,
4615 GtkShadowType shadow_type,
4618 const gchar *detail,
4624 g_return_if_fail (GTK_IS_STYLE (style));
4625 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow != NULL);
4627 GTK_STYLE_GET_CLASS (style)->draw_shadow (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4631 gtk_paint_polygon (GtkStyle *style,
4633 GtkStateType state_type,
4634 GtkShadowType shadow_type,
4637 const gchar *detail,
4642 g_return_if_fail (GTK_IS_STYLE (style));
4643 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow != NULL);
4645 GTK_STYLE_GET_CLASS (style)->draw_polygon (style, window, state_type, shadow_type, area, widget, detail, points, npoints, fill);
4649 gtk_paint_arrow (GtkStyle *style,
4651 GtkStateType state_type,
4652 GtkShadowType shadow_type,
4655 const gchar *detail,
4656 GtkArrowType arrow_type,
4663 g_return_if_fail (GTK_IS_STYLE (style));
4664 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_arrow != NULL);
4666 GTK_STYLE_GET_CLASS (style)->draw_arrow (style, window, state_type, shadow_type, area, widget, detail, arrow_type, fill, x, y, width, height);
4670 gtk_paint_diamond (GtkStyle *style,
4672 GtkStateType state_type,
4673 GtkShadowType shadow_type,
4676 const gchar *detail,
4682 g_return_if_fail (GTK_IS_STYLE (style));
4683 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_diamond != NULL);
4685 GTK_STYLE_GET_CLASS (style)->draw_diamond (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4689 gtk_paint_string (GtkStyle *style,
4691 GtkStateType state_type,
4694 const gchar *detail,
4697 const gchar *string)
4699 g_return_if_fail (GTK_IS_STYLE (style));
4700 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_string != NULL);
4702 GTK_STYLE_GET_CLASS (style)->draw_string (style, window, state_type, area, widget, detail, x, y, string);
4706 gtk_paint_box (GtkStyle *style,
4708 GtkStateType state_type,
4709 GtkShadowType shadow_type,
4712 const gchar *detail,
4718 g_return_if_fail (GTK_IS_STYLE (style));
4719 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box != NULL);
4721 GTK_STYLE_GET_CLASS (style)->draw_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4725 gtk_paint_flat_box (GtkStyle *style,
4727 GtkStateType state_type,
4728 GtkShadowType shadow_type,
4731 const gchar *detail,
4737 g_return_if_fail (GTK_IS_STYLE (style));
4738 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_flat_box != NULL);
4740 GTK_STYLE_GET_CLASS (style)->draw_flat_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4744 gtk_paint_check (GtkStyle *style,
4746 GtkStateType state_type,
4747 GtkShadowType shadow_type,
4750 const gchar *detail,
4756 g_return_if_fail (GTK_IS_STYLE (style));
4757 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_check != NULL);
4759 GTK_STYLE_GET_CLASS (style)->draw_check (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4763 gtk_paint_option (GtkStyle *style,
4765 GtkStateType state_type,
4766 GtkShadowType shadow_type,
4769 const gchar *detail,
4775 g_return_if_fail (GTK_IS_STYLE (style));
4776 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_option != NULL);
4778 GTK_STYLE_GET_CLASS (style)->draw_option (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4782 gtk_paint_tab (GtkStyle *style,
4784 GtkStateType state_type,
4785 GtkShadowType shadow_type,
4788 const gchar *detail,
4794 g_return_if_fail (GTK_IS_STYLE (style));
4795 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_tab != NULL);
4797 GTK_STYLE_GET_CLASS (style)->draw_tab (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4801 gtk_paint_shadow_gap (GtkStyle *style,
4803 GtkStateType state_type,
4804 GtkShadowType shadow_type,
4812 GtkPositionType gap_side,
4816 g_return_if_fail (GTK_IS_STYLE (style));
4817 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow_gap != NULL);
4819 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);
4824 gtk_paint_box_gap (GtkStyle *style,
4826 GtkStateType state_type,
4827 GtkShadowType shadow_type,
4835 GtkPositionType gap_side,
4839 g_return_if_fail (GTK_IS_STYLE (style));
4840 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box_gap != NULL);
4842 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);
4846 gtk_paint_extension (GtkStyle *style,
4848 GtkStateType state_type,
4849 GtkShadowType shadow_type,
4857 GtkPositionType gap_side)
4859 g_return_if_fail (GTK_IS_STYLE (style));
4860 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_extension != NULL);
4862 GTK_STYLE_GET_CLASS (style)->draw_extension (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side);
4866 gtk_paint_focus (GtkStyle *style,
4870 const gchar *detail,
4876 g_return_if_fail (GTK_IS_STYLE (style));
4877 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_focus != NULL);
4879 GTK_STYLE_GET_CLASS (style)->draw_focus (style, window, area, widget, detail, x, y, width, height);
4883 gtk_paint_slider (GtkStyle *style,
4885 GtkStateType state_type,
4886 GtkShadowType shadow_type,
4889 const gchar *detail,
4894 GtkOrientation orientation)
4896 g_return_if_fail (GTK_IS_STYLE (style));
4897 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_slider != NULL);
4899 GTK_STYLE_GET_CLASS (style)->draw_slider (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
4903 gtk_paint_handle (GtkStyle *style,
4905 GtkStateType state_type,
4906 GtkShadowType shadow_type,
4909 const gchar *detail,
4914 GtkOrientation orientation)
4916 g_return_if_fail (GTK_IS_STYLE (style));
4917 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_handle != NULL);
4919 GTK_STYLE_GET_CLASS (style)->draw_handle (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
4923 gtk_paint_expander (GtkStyle *style,
4925 GtkStateType state_type,
4928 const gchar *detail,
4931 GtkExpanderStyle expander_style)
4933 g_return_if_fail (GTK_IS_STYLE (style));
4934 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_expander != NULL);
4936 GTK_STYLE_GET_CLASS (style)->draw_expander (style, window, state_type, area,
4937 widget, detail, x, y, expander_style);
4941 gtk_paint_layout (GtkStyle *style,
4943 GtkStateType state_type,
4947 const gchar *detail,
4950 PangoLayout *layout)
4952 g_return_if_fail (GTK_IS_STYLE (style));
4953 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_layout != NULL);
4955 GTK_STYLE_GET_CLASS (style)->draw_layout (style, window, state_type, use_text, area,
4956 widget, detail, x, y, layout);
4960 gtk_paint_resize_grip (GtkStyle *style,
4962 GtkStateType state_type,
4965 const gchar *detail,
4973 g_return_if_fail (GTK_IS_STYLE (style));
4974 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_resize_grip != NULL);
4976 GTK_STYLE_GET_CLASS (style)->draw_resize_grip (style, window, state_type,
4977 area, widget, detail,
4978 edge, x, y, width, height);
4982 gtk_border_copy (const GtkBorder *border)
4984 return (GtkBorder *)g_memdup (border, sizeof (GtkBorder));
4988 gtk_border_free (GtkBorder *border)