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 };
412 static gpointer parent_class = NULL;
413 static GdkFont *static_default_font = NULL;
416 /* --- functions --- */
418 gtk_style_get_type (void)
420 static GType style_type = 0;
424 static const GTypeInfo style_info =
426 sizeof (GtkStyleClass),
427 (GBaseInitFunc) NULL,
428 (GBaseFinalizeFunc) NULL,
429 (GClassInitFunc) gtk_style_class_init,
430 NULL, /* class_finalize */
431 NULL, /* class_data */
434 (GInstanceInitFunc) gtk_style_init,
437 style_type = g_type_register_static (G_TYPE_OBJECT,
446 gtk_style_init (GtkStyle *style)
450 style->font_desc = pango_font_description_from_string ("Sans 10");
452 if (!static_default_font)
454 static_default_font = gdk_font_from_description (style->font_desc);
456 if (!static_default_font)
457 static_default_font = gdk_font_load ("fixed");
459 if (!static_default_font)
460 g_error ("Unable to load \"fixed\" font");
463 style->font = static_default_font;
464 gdk_font_ref (style->font);
466 style->attach_count = 0;
467 style->colormap = NULL;
470 style->black.red = 0;
471 style->black.green = 0;
472 style->black.blue = 0;
474 style->white.red = 65535;
475 style->white.green = 65535;
476 style->white.blue = 65535;
478 style->black_gc = NULL;
479 style->white_gc = NULL;
481 style->fg[GTK_STATE_NORMAL] = gtk_default_normal_fg;
482 style->fg[GTK_STATE_ACTIVE] = gtk_default_active_fg;
483 style->fg[GTK_STATE_PRELIGHT] = gtk_default_prelight_fg;
484 style->fg[GTK_STATE_SELECTED] = gtk_default_selected_fg;
485 style->fg[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_fg;
487 style->bg[GTK_STATE_NORMAL] = gtk_default_normal_bg;
488 style->bg[GTK_STATE_ACTIVE] = gtk_default_active_bg;
489 style->bg[GTK_STATE_PRELIGHT] = gtk_default_prelight_bg;
490 style->bg[GTK_STATE_SELECTED] = gtk_default_selected_bg;
491 style->bg[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_bg;
493 for (i = 0; i < 4; i++)
495 style->text[i] = style->fg[i];
496 style->base[i] = style->white;
499 style->base[GTK_STATE_SELECTED] = gtk_default_selected_bg;
500 style->base[GTK_STATE_INSENSITIVE] = gtk_default_prelight_bg;
501 style->text[GTK_STATE_INSENSITIVE] = gtk_default_insensitive_fg;
503 for (i = 0; i < 5; i++)
504 style->bg_pixmap[i] = NULL;
506 style->rc_style = NULL;
508 for (i = 0; i < 5; i++)
510 style->fg_gc[i] = NULL;
511 style->bg_gc[i] = NULL;
512 style->light_gc[i] = NULL;
513 style->dark_gc[i] = NULL;
514 style->mid_gc[i] = NULL;
515 style->text_gc[i] = NULL;
516 style->base_gc[i] = NULL;
517 style->text_aa_gc[i] = NULL;
520 style->xthickness = 2;
521 style->ythickness = 2;
523 style->property_cache = NULL;
527 gtk_style_class_init (GtkStyleClass *klass)
529 GObjectClass *object_class = G_OBJECT_CLASS (klass);
531 parent_class = g_type_class_peek_parent (klass);
533 object_class->finalize = gtk_style_finalize;
535 klass->clone = gtk_style_real_clone;
536 klass->copy = gtk_style_real_copy;
537 klass->init_from_rc = gtk_style_real_init_from_rc;
538 klass->realize = gtk_style_real_realize;
539 klass->unrealize = gtk_style_real_unrealize;
540 klass->set_background = gtk_style_real_set_background;
541 klass->render_icon = gtk_default_render_icon;
543 klass->draw_hline = gtk_default_draw_hline;
544 klass->draw_vline = gtk_default_draw_vline;
545 klass->draw_shadow = gtk_default_draw_shadow;
546 klass->draw_polygon = gtk_default_draw_polygon;
547 klass->draw_arrow = gtk_default_draw_arrow;
548 klass->draw_diamond = gtk_default_draw_diamond;
549 klass->draw_string = gtk_default_draw_string;
550 klass->draw_box = gtk_default_draw_box;
551 klass->draw_flat_box = gtk_default_draw_flat_box;
552 klass->draw_check = gtk_default_draw_check;
553 klass->draw_option = gtk_default_draw_option;
554 klass->draw_tab = gtk_default_draw_tab;
555 klass->draw_shadow_gap = gtk_default_draw_shadow_gap;
556 klass->draw_box_gap = gtk_default_draw_box_gap;
557 klass->draw_extension = gtk_default_draw_extension;
558 klass->draw_focus = gtk_default_draw_focus;
559 klass->draw_slider = gtk_default_draw_slider;
560 klass->draw_handle = gtk_default_draw_handle;
561 klass->draw_expander = gtk_default_draw_expander;
562 klass->draw_layout = gtk_default_draw_layout;
563 klass->draw_resize_grip = gtk_default_draw_resize_grip;
567 clear_property_cache (GtkStyle *style)
569 if (style->property_cache)
573 for (i = 0; i < style->property_cache->len; i++)
575 PropertyValue *node = &g_array_index (style->property_cache, PropertyValue, i);
577 g_param_spec_unref (node->pspec);
578 g_value_unset (&node->value);
580 g_array_free (style->property_cache, TRUE);
581 style->property_cache = NULL;
586 gtk_style_finalize (GObject *object)
588 GtkStyle *style = GTK_STYLE (object);
590 g_return_if_fail (style->attach_count == 0);
592 clear_property_cache (style);
596 if (style->styles->data != style)
597 g_slist_remove (style->styles, style);
600 GSList *tmp_list = style->styles->next;
604 GTK_STYLE (tmp_list->data)->styles = style->styles->next;
605 tmp_list = tmp_list->next;
607 g_slist_free_1 (style->styles);
611 gdk_font_unref (style->font);
612 pango_font_description_free (style->font_desc);
615 gtk_rc_style_unref (style->rc_style);
617 G_OBJECT_CLASS (parent_class)->finalize (object);
622 gtk_style_copy (GtkStyle *style)
626 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
628 new_style = GTK_STYLE_GET_CLASS (style)->clone (style);
629 GTK_STYLE_GET_CLASS (style)->copy (new_style, style);
635 gtk_style_duplicate (GtkStyle *style)
639 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
641 new_style = gtk_style_copy (style);
643 style->styles = g_slist_append (style->styles, new_style);
644 new_style->styles = style->styles;
654 style = g_object_new (GTK_TYPE_STYLE, NULL);
659 /*************************************************************
661 * Attach a style to a window; this process allocates the
662 * colors and creates the GC's for the style - it specializes
663 * it to a particular visual and colormap. The process
664 * may involve the creation of a new style if the style
665 * has already been attached to a window with a different
666 * style and colormap.
671 * Either the style parameter, or a newly created style.
672 * If the style is newly created, the style parameter
673 * will be dereferenced, and the new style will have
674 * a reference count belonging to the caller.
676 * FIXME: The sequence -
677 * create a style => s1
678 * attach s1 to v1, c1 => s1
679 * attach s1 to v2, c2 => s2
680 * detach s1 from v1, c1
681 * attach s1 to v2, c2 => s3
682 * results in two separate, unlinked styles s2 and s3 which
683 * are identical and could be shared. To fix this, we would
684 * want to never remove a style from the list of linked
685 * styles as long as as it has a reference count. However, the
686 * disadvantage of doing it this way means that we would need two
687 * passes through the linked list when attaching (one to check for
688 * matching styles, one to look for empty unattached styles - but
689 * it will almost never be longer than 2 elements.
690 *************************************************************/
693 gtk_style_attach (GtkStyle *style,
697 GtkStyle *new_style = NULL;
698 GdkColormap *colormap;
700 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
701 g_return_val_if_fail (window != NULL, NULL);
703 colormap = gdk_window_get_colormap (window);
706 style->styles = g_slist_append (NULL, style);
708 styles = style->styles;
711 new_style = styles->data;
713 if (new_style->attach_count == 0)
715 gtk_style_realize (new_style, colormap);
718 else if (new_style->colormap == colormap)
722 styles = styles->next;
727 new_style = gtk_style_duplicate (style);
728 gtk_style_realize (new_style, colormap);
731 /* A style gets a refcount from being attached */
732 if (new_style->attach_count == 0)
733 gtk_style_ref (new_style);
735 /* Another refcount belongs to the parent */
736 if (style != new_style)
738 gtk_style_unref (style);
739 gtk_style_ref (new_style);
742 new_style->attach_count++;
748 gtk_style_detach (GtkStyle *style)
750 g_return_if_fail (GTK_IS_STYLE (style));
752 style->attach_count -= 1;
753 if (style->attach_count == 0)
755 GTK_STYLE_GET_CLASS (style)->unrealize (style);
757 gdk_colormap_unref (style->colormap);
758 style->colormap = NULL;
760 gtk_style_unref (style);
765 gtk_style_ref (GtkStyle *style)
767 return (GtkStyle *) g_object_ref (G_OBJECT (style));
771 gtk_style_unref (GtkStyle *style)
773 g_object_unref (G_OBJECT (style));
777 gtk_style_realize (GtkStyle *style,
778 GdkColormap *colormap)
780 g_return_if_fail (GTK_IS_STYLE (style));
781 g_return_if_fail (GDK_IS_COLORMAP (colormap));
783 style->colormap = gdk_colormap_ref (colormap);
784 style->depth = gdk_colormap_get_visual (colormap)->depth;
786 GTK_STYLE_GET_CLASS (style)->realize (style);
790 gtk_style_lookup_icon_set (GtkStyle *style,
791 const char *stock_id)
795 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
796 g_return_val_if_fail (stock_id != NULL, NULL);
798 iter = style->icon_factories;
801 GtkIconSet *icon_set = gtk_icon_factory_lookup (GTK_ICON_FACTORY (iter->data),
806 iter = g_slist_next (iter);
809 return gtk_icon_factory_lookup_default (stock_id);
813 gtk_draw_hline (GtkStyle *style,
815 GtkStateType state_type,
820 g_return_if_fail (GTK_IS_STYLE (style));
821 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_hline != NULL);
823 GTK_STYLE_GET_CLASS (style)->draw_hline (style, window, state_type, NULL, NULL, NULL, x1, x2, y);
828 gtk_draw_vline (GtkStyle *style,
830 GtkStateType state_type,
835 g_return_if_fail (GTK_IS_STYLE (style));
836 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_vline != NULL);
838 GTK_STYLE_GET_CLASS (style)->draw_vline (style, window, state_type, NULL, NULL, NULL, y1, y2, x);
843 gtk_draw_shadow (GtkStyle *style,
845 GtkStateType state_type,
846 GtkShadowType shadow_type,
852 g_return_if_fail (GTK_IS_STYLE (style));
853 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow != NULL);
855 GTK_STYLE_GET_CLASS (style)->draw_shadow (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
859 gtk_draw_polygon (GtkStyle *style,
861 GtkStateType state_type,
862 GtkShadowType shadow_type,
867 g_return_if_fail (GTK_IS_STYLE (style));
868 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_polygon != NULL);
870 GTK_STYLE_GET_CLASS (style)->draw_polygon (style, window, state_type, shadow_type, NULL, NULL, NULL, points, npoints, fill);
874 gtk_draw_arrow (GtkStyle *style,
876 GtkStateType state_type,
877 GtkShadowType shadow_type,
878 GtkArrowType arrow_type,
885 g_return_if_fail (GTK_IS_STYLE (style));
886 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_arrow != NULL);
888 GTK_STYLE_GET_CLASS (style)->draw_arrow (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, fill, x, y, width, height);
893 gtk_draw_diamond (GtkStyle *style,
895 GtkStateType state_type,
896 GtkShadowType shadow_type,
902 g_return_if_fail (GTK_IS_STYLE (style));
903 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_diamond != NULL);
905 GTK_STYLE_GET_CLASS (style)->draw_diamond (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
910 gtk_draw_string (GtkStyle *style,
912 GtkStateType state_type,
917 g_return_if_fail (GTK_IS_STYLE (style));
918 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_string != NULL);
920 GTK_STYLE_GET_CLASS (style)->draw_string (style, window, state_type, NULL, NULL, NULL, x, y, string);
924 gtk_draw_box (GtkStyle *style,
926 GtkStateType state_type,
927 GtkShadowType shadow_type,
933 g_return_if_fail (GTK_IS_STYLE (style));
934 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box != NULL);
936 GTK_STYLE_GET_CLASS (style)->draw_box (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
940 gtk_draw_flat_box (GtkStyle *style,
942 GtkStateType state_type,
943 GtkShadowType shadow_type,
949 g_return_if_fail (GTK_IS_STYLE (style));
950 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_flat_box != NULL);
952 GTK_STYLE_GET_CLASS (style)->draw_flat_box (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
956 gtk_draw_check (GtkStyle *style,
958 GtkStateType state_type,
959 GtkShadowType shadow_type,
965 g_return_if_fail (GTK_IS_STYLE (style));
966 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_check != NULL);
968 GTK_STYLE_GET_CLASS (style)->draw_check (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
972 gtk_draw_option (GtkStyle *style,
974 GtkStateType state_type,
975 GtkShadowType shadow_type,
981 g_return_if_fail (GTK_IS_STYLE (style));
982 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_option != NULL);
984 GTK_STYLE_GET_CLASS (style)->draw_option (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
988 gtk_draw_tab (GtkStyle *style,
990 GtkStateType state_type,
991 GtkShadowType shadow_type,
997 g_return_if_fail (GTK_IS_STYLE (style));
998 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_tab != NULL);
1000 GTK_STYLE_GET_CLASS (style)->draw_tab (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height);
1004 gtk_draw_shadow_gap (GtkStyle *style,
1006 GtkStateType state_type,
1007 GtkShadowType shadow_type,
1012 GtkPositionType gap_side,
1016 g_return_if_fail (GTK_IS_STYLE (style));
1017 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow_gap != NULL);
1019 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);
1023 gtk_draw_box_gap (GtkStyle *style,
1025 GtkStateType state_type,
1026 GtkShadowType shadow_type,
1031 GtkPositionType gap_side,
1035 g_return_if_fail (GTK_IS_STYLE (style));
1036 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box_gap != NULL);
1038 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);
1042 gtk_draw_extension (GtkStyle *style,
1044 GtkStateType state_type,
1045 GtkShadowType shadow_type,
1050 GtkPositionType gap_side)
1052 g_return_if_fail (GTK_IS_STYLE (style));
1053 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_extension != NULL);
1055 GTK_STYLE_GET_CLASS (style)->draw_extension (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side);
1059 gtk_draw_focus (GtkStyle *style,
1066 g_return_if_fail (GTK_IS_STYLE (style));
1067 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_focus != NULL);
1069 GTK_STYLE_GET_CLASS (style)->draw_focus (style, window, NULL, NULL, NULL, x, y, width, height);
1073 gtk_draw_slider (GtkStyle *style,
1075 GtkStateType state_type,
1076 GtkShadowType shadow_type,
1081 GtkOrientation orientation)
1083 g_return_if_fail (GTK_IS_STYLE (style));
1084 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_slider != NULL);
1086 GTK_STYLE_GET_CLASS (style)->draw_slider (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
1090 gtk_draw_handle (GtkStyle *style,
1092 GtkStateType state_type,
1093 GtkShadowType shadow_type,
1098 GtkOrientation orientation)
1100 g_return_if_fail (GTK_IS_STYLE (style));
1101 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_handle != NULL);
1103 GTK_STYLE_GET_CLASS (style)->draw_handle (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation);
1107 gtk_draw_expander (GtkStyle *style,
1109 GtkStateType state_type,
1112 GtkExpanderStyle expander_style)
1114 g_return_if_fail (GTK_IS_STYLE (style));
1115 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_expander != NULL);
1117 GTK_STYLE_GET_CLASS (style)->draw_expander (style, window, state_type,
1119 x, y, expander_style);
1123 gtk_draw_layout (GtkStyle *style,
1125 GtkStateType state_type,
1129 PangoLayout *layout)
1131 g_return_if_fail (GTK_IS_STYLE (style));
1132 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_layout != NULL);
1134 GTK_STYLE_GET_CLASS (style)->draw_layout (style, window, state_type, use_text,
1140 gtk_draw_resize_grip (GtkStyle *style,
1142 GtkStateType state_type,
1149 g_return_if_fail (GTK_IS_STYLE (style));
1150 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_resize_grip != NULL);
1152 GTK_STYLE_GET_CLASS (style)->draw_resize_grip (style, window, state_type,
1155 x, y, width, height);
1160 gtk_style_set_background (GtkStyle *style,
1162 GtkStateType state_type)
1164 g_return_if_fail (GTK_IS_STYLE (style));
1165 g_return_if_fail (window != NULL);
1167 GTK_STYLE_GET_CLASS (style)->set_background (style, window, state_type);
1170 /* Default functions */
1172 gtk_style_real_clone (GtkStyle *style)
1174 return GTK_STYLE (g_object_new (G_OBJECT_TYPE (style), NULL));
1178 gtk_style_real_copy (GtkStyle *style,
1183 for (i = 0; i < 5; i++)
1185 style->fg[i] = src->fg[i];
1186 style->bg[i] = src->bg[i];
1187 style->text[i] = src->text[i];
1188 style->base[i] = src->base[i];
1190 style->bg_pixmap[i] = src->bg_pixmap[i];
1194 gdk_font_unref (style->font);
1195 style->font = src->font;
1197 gdk_font_ref (style->font);
1199 if (style->font_desc)
1200 pango_font_description_free (style->font_desc);
1202 style->font_desc = pango_font_description_copy (src->font_desc);
1204 style->font_desc = NULL;
1206 style->xthickness = src->xthickness;
1207 style->ythickness = src->ythickness;
1209 if (style->rc_style)
1210 gtk_rc_style_unref (style->rc_style);
1211 style->rc_style = src->rc_style;
1213 gtk_rc_style_ref (src->rc_style);
1215 /* don't copy, just clear cache */
1216 clear_property_cache (style);
1220 gtk_style_real_init_from_rc (GtkStyle *style,
1221 GtkRcStyle *rc_style)
1226 /* cache _should_ be still empty */
1227 clear_property_cache (style);
1229 if (rc_style->font_desc)
1231 pango_font_description_free (style->font_desc);
1232 style->font_desc = pango_font_description_copy (rc_style->font_desc);
1234 old_font = style->font;
1235 style->font = gdk_font_from_description (style->font_desc);
1237 gdk_font_unref (old_font);
1239 style->font = old_font;
1242 for (i = 0; i < 5; i++)
1244 if (rc_style->color_flags[i] & GTK_RC_FG)
1245 style->fg[i] = rc_style->fg[i];
1246 if (rc_style->color_flags[i] & GTK_RC_BG)
1247 style->bg[i] = rc_style->bg[i];
1248 if (rc_style->color_flags[i] & GTK_RC_TEXT)
1249 style->text[i] = rc_style->text[i];
1250 if (rc_style->color_flags[i] & GTK_RC_BASE)
1251 style->base[i] = rc_style->base[i];
1254 if (rc_style->xthickness >= 0)
1255 style->xthickness = rc_style->xthickness;
1256 if (rc_style->ythickness >= 0)
1257 style->ythickness = rc_style->ythickness;
1259 if (rc_style->icon_factories)
1263 style->icon_factories = g_slist_copy (rc_style->icon_factories);
1265 iter = style->icon_factories;
1266 while (iter != NULL)
1268 g_object_ref (G_OBJECT (iter->data));
1270 iter = g_slist_next (iter);
1276 style_property_values_cmp (gconstpointer bsearch_node1,
1277 gconstpointer bsearch_node2)
1279 const PropertyValue *val1 = bsearch_node1;
1280 const PropertyValue *val2 = bsearch_node2;
1282 if (val1->widget_type == val2->widget_type)
1283 return val1->pspec < val2->pspec ? -1 : val1->pspec == val2->pspec ? 0 : 1;
1285 return val1->widget_type < val2->widget_type ? -1 : 1;
1289 _gtk_style_peek_property_value (GtkStyle *style,
1292 GtkRcPropertyParser parser)
1294 PropertyValue *pcache, key = { 0, NULL, { 0, } };
1295 const GtkRcProperty *rcprop = NULL;
1298 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
1299 g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), NULL);
1300 g_return_val_if_fail (g_type_is_a (pspec->owner_type, GTK_TYPE_WIDGET), NULL);
1301 g_return_val_if_fail (g_type_is_a (widget_type, pspec->owner_type), NULL);
1303 key.widget_type = widget_type;
1306 /* need value cache array */
1307 if (!style->property_cache)
1308 style->property_cache = g_array_new (FALSE, FALSE, sizeof (PropertyValue));
1311 pcache = bsearch (&key,
1312 style->property_cache->data, style->property_cache->len,
1313 sizeof (PropertyValue), style_property_values_cmp);
1315 return &pcache->value;
1319 while (i < style->property_cache->len &&
1320 style_property_values_cmp (&key, &g_array_index (style->property_cache, PropertyValue, i)) >= 0)
1323 g_array_insert_val (style->property_cache, i, key);
1324 pcache = &g_array_index (style->property_cache, PropertyValue, i);
1326 /* cache miss, initialize value type, then set contents */
1327 g_param_spec_ref (pcache->pspec);
1328 g_value_init (&pcache->value, G_PARAM_SPEC_VALUE_TYPE (pspec));
1330 /* value provided by rc style? */
1331 if (style->rc_style)
1333 GQuark prop_quark = g_quark_from_string (pspec->name);
1337 rcprop = _gtk_rc_style_lookup_rc_property (style->rc_style,
1338 g_type_qname (widget_type),
1342 widget_type = g_type_parent (widget_type);
1344 while (g_type_is_a (widget_type, pspec->owner_type));
1347 /* when supplied by rc style, we need to convert */
1348 if (rcprop && !_gtk_settings_parse_convert (parser, &rcprop->value,
1349 pspec, &pcache->value))
1351 gchar *contents = g_strdup_value_contents (&rcprop->value);
1353 g_message ("%s: failed to retrive property `%s::%s' of type `%s' from rc file value \"%s\" of type `%s'",
1355 g_type_name (pspec->owner_type), pspec->name,
1356 g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
1358 G_VALUE_TYPE_NAME (&rcprop->value));
1360 rcprop = NULL; /* needs default */
1363 /* not supplied by rc style (or conversion failed), revert to default */
1365 g_param_value_set_default (pspec, &pcache->value);
1367 return &pcache->value;
1371 load_bg_image (GdkColormap *colormap,
1373 const gchar *filename)
1375 if (strcmp (filename, "<parent>") == 0)
1376 return (GdkPixmap*) GDK_PARENT_RELATIVE;
1379 return gdk_pixmap_colormap_create_from_xpm (NULL, colormap, NULL,
1386 gtk_style_real_realize (GtkStyle *style)
1388 GdkGCValues gc_values;
1389 GdkGCValuesMask gc_values_mask;
1393 for (i = 0; i < 5; i++)
1395 gtk_style_shade (&style->bg[i], &style->light[i], LIGHTNESS_MULT);
1396 gtk_style_shade (&style->bg[i], &style->dark[i], DARKNESS_MULT);
1398 style->mid[i].red = (style->light[i].red + style->dark[i].red) / 2;
1399 style->mid[i].green = (style->light[i].green + style->dark[i].green) / 2;
1400 style->mid[i].blue = (style->light[i].blue + style->dark[i].blue) / 2;
1402 style->text_aa[i].red = (style->text[i].red + style->base[i].red) / 2;
1403 style->text_aa[i].green = (style->text[i].green + style->base[i].green) / 2;
1404 style->text_aa[i].blue = (style->text[i].blue + style->base[i].blue) / 2;
1407 gdk_color_black (style->colormap, &style->black);
1408 gdk_color_white (style->colormap, &style->white);
1410 gc_values_mask = GDK_GC_FOREGROUND | GDK_GC_FONT;
1411 if (style->font->type == GDK_FONT_FONT)
1413 gc_values.font = style->font;
1415 else if (style->font->type == GDK_FONT_FONTSET)
1417 gc_values.font = static_default_font;
1420 gc_values.foreground = style->black;
1421 style->black_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1423 gc_values.foreground = style->white;
1424 style->white_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1426 for (i = 0; i < 5; i++)
1428 if (style->rc_style && style->rc_style->bg_pixmap_name[i])
1429 style->bg_pixmap[i] = load_bg_image (style->colormap,
1431 style->rc_style->bg_pixmap_name[i]);
1433 if (!gdk_color_alloc (style->colormap, &style->fg[i]))
1434 g_warning ("unable to allocate color: ( %d %d %d )",
1435 style->fg[i].red, style->fg[i].green, style->fg[i].blue);
1436 if (!gdk_color_alloc (style->colormap, &style->bg[i]))
1437 g_warning ("unable to allocate color: ( %d %d %d )",
1438 style->bg[i].red, style->bg[i].green, style->bg[i].blue);
1439 if (!gdk_color_alloc (style->colormap, &style->light[i]))
1440 g_warning ("unable to allocate color: ( %d %d %d )",
1441 style->light[i].red, style->light[i].green, style->light[i].blue);
1442 if (!gdk_color_alloc (style->colormap, &style->dark[i]))
1443 g_warning ("unable to allocate color: ( %d %d %d )",
1444 style->dark[i].red, style->dark[i].green, style->dark[i].blue);
1445 if (!gdk_color_alloc (style->colormap, &style->mid[i]))
1446 g_warning ("unable to allocate color: ( %d %d %d )",
1447 style->mid[i].red, style->mid[i].green, style->mid[i].blue);
1448 if (!gdk_color_alloc (style->colormap, &style->text[i]))
1449 g_warning ("unable to allocate color: ( %d %d %d )",
1450 style->text[i].red, style->text[i].green, style->text[i].blue);
1451 if (!gdk_color_alloc (style->colormap, &style->base[i]))
1452 g_warning ("unable to allocate color: ( %d %d %d )",
1453 style->base[i].red, style->base[i].green, style->base[i].blue);
1454 if (!gdk_color_alloc (style->colormap, &style->text_aa[i]))
1455 g_warning ("unable to allocate color: ( %d %d %d )",
1456 style->text_aa[i].red, style->text_aa[i].green, style->text_aa[i].blue);
1458 gc_values.foreground = style->fg[i];
1459 style->fg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1461 gc_values.foreground = style->bg[i];
1462 style->bg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1464 gc_values.foreground = style->light[i];
1465 style->light_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1467 gc_values.foreground = style->dark[i];
1468 style->dark_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1470 gc_values.foreground = style->mid[i];
1471 style->mid_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1473 gc_values.foreground = style->text[i];
1474 style->text_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1476 gc_values.foreground = style->base[i];
1477 style->base_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1479 gc_values.foreground = style->text_aa[i];
1480 style->text_aa_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1485 gtk_style_real_unrealize (GtkStyle *style)
1489 gtk_gc_release (style->black_gc);
1490 gtk_gc_release (style->white_gc);
1492 for (i = 0; i < 5; i++)
1494 gtk_gc_release (style->fg_gc[i]);
1495 gtk_gc_release (style->bg_gc[i]);
1496 gtk_gc_release (style->light_gc[i]);
1497 gtk_gc_release (style->dark_gc[i]);
1498 gtk_gc_release (style->mid_gc[i]);
1499 gtk_gc_release (style->text_gc[i]);
1500 gtk_gc_release (style->base_gc[i]);
1501 gtk_gc_release (style->text_aa_gc[i]);
1503 if (style->bg_pixmap[i] && style->bg_pixmap[i] != (GdkPixmap*) GDK_PARENT_RELATIVE)
1504 gdk_pixmap_unref (style->bg_pixmap[i]);
1507 gdk_colormap_free_colors (style->colormap, style->fg, 5);
1508 gdk_colormap_free_colors (style->colormap, style->bg, 5);
1509 gdk_colormap_free_colors (style->colormap, style->light, 5);
1510 gdk_colormap_free_colors (style->colormap, style->dark, 5);
1511 gdk_colormap_free_colors (style->colormap, style->mid, 5);
1512 gdk_colormap_free_colors (style->colormap, style->text, 5);
1513 gdk_colormap_free_colors (style->colormap, style->base, 5);
1514 gdk_colormap_free_colors (style->colormap, style->text_aa, 5);
1518 gtk_style_real_set_background (GtkStyle *style,
1520 GtkStateType state_type)
1523 gint parent_relative;
1525 if (style->bg_pixmap[state_type])
1527 if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
1530 parent_relative = TRUE;
1534 pixmap = style->bg_pixmap[state_type];
1535 parent_relative = FALSE;
1538 gdk_window_set_back_pixmap (window, pixmap, parent_relative);
1541 gdk_window_set_background (window, &style->bg[state_type]);
1545 gtk_style_render_icon (GtkStyle *style,
1546 const GtkIconSource *source,
1547 GtkTextDirection direction,
1551 const gchar *detail)
1555 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
1556 g_return_val_if_fail (GTK_STYLE_GET_CLASS (style)->render_icon != NULL, NULL);
1558 pixbuf = GTK_STYLE_GET_CLASS (style)->render_icon (style, source, direction, state,
1559 size, widget, detail);
1561 g_return_val_if_fail (pixbuf != NULL, NULL);
1566 /* Default functions */
1568 gtk_style_apply_default_background (GtkStyle *style,
1571 GtkStateType state_type,
1578 GdkRectangle new_rect, old_rect;
1584 old_rect.width = width;
1585 old_rect.height = height;
1587 if (!gdk_rectangle_intersect (area, &old_rect, &new_rect))
1594 new_rect.width = width;
1595 new_rect.height = height;
1598 if (!style->bg_pixmap[state_type] ||
1599 GDK_IS_PIXMAP (window) ||
1600 (!set_bg && style->bg_pixmap[state_type] != (GdkPixmap*) GDK_PARENT_RELATIVE))
1602 GdkGC *gc = style->bg_gc[state_type];
1604 if (style->bg_pixmap[state_type])
1606 gdk_gc_set_fill (gc, GDK_TILED);
1607 gdk_gc_set_tile (gc, style->bg_pixmap[state_type]);
1610 gdk_draw_rectangle (window, gc, TRUE,
1611 new_rect.x, new_rect.y, new_rect.width, new_rect.height);
1612 if (style->bg_pixmap[state_type])
1613 gdk_gc_set_fill (gc, GDK_SOLID);
1619 if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
1620 gdk_window_set_back_pixmap (window, NULL, TRUE);
1622 gdk_window_set_back_pixmap (window, style->bg_pixmap[state_type], FALSE);
1625 gdk_window_clear_area (window,
1626 new_rect.x, new_rect.y,
1627 new_rect.width, new_rect.height);
1632 scale_or_ref (GdkPixbuf *src,
1636 if (width == gdk_pixbuf_get_width (src) &&
1637 height == gdk_pixbuf_get_height (src))
1639 gdk_pixbuf_ref (src);
1644 return gdk_pixbuf_scale_simple (src,
1646 GDK_INTERP_BILINEAR);
1651 gtk_default_render_icon (GtkStyle *style,
1652 const GtkIconSource *source,
1653 GtkTextDirection direction,
1657 const gchar *detail)
1663 GdkPixbuf *base_pixbuf;
1665 /* Oddly, style can be NULL in this function, because
1666 * GtkIconSet can be used without a style and if so
1667 * it uses this function.
1670 base_pixbuf = gtk_icon_source_get_pixbuf (source);
1672 g_return_val_if_fail (base_pixbuf != NULL, NULL);
1674 if (!gtk_icon_size_lookup (size, &width, &height))
1676 g_warning (G_STRLOC ": invalid icon size `%d'", size);
1680 /* If the size was wildcarded, then scale; otherwise, leave it
1683 if (gtk_icon_source_get_size_wildcarded (source))
1684 scaled = scale_or_ref (base_pixbuf, width, height);
1686 scaled = GDK_PIXBUF (g_object_ref (G_OBJECT (base_pixbuf)));
1688 /* If the state was wildcarded, then generate a state. */
1689 if (gtk_icon_source_get_state_wildcarded (source))
1691 if (state == GTK_STATE_INSENSITIVE)
1693 stated = gdk_pixbuf_copy (scaled);
1695 gdk_pixbuf_saturate_and_pixelate (scaled, stated,
1698 gdk_pixbuf_unref (scaled);
1700 else if (state == GTK_STATE_PRELIGHT)
1702 stated = gdk_pixbuf_copy (scaled);
1704 gdk_pixbuf_saturate_and_pixelate (scaled, stated,
1707 gdk_pixbuf_unref (scaled);
1721 sanitize_size (GdkWindow *window,
1725 gboolean set_bg = FALSE;
1727 if ((*width == -1) && (*height == -1))
1729 set_bg = GDK_IS_WINDOW (window);
1730 gdk_window_get_size (window, width, height);
1732 else if (*width == -1)
1733 gdk_window_get_size (window, width, NULL);
1734 else if (*height == -1)
1735 gdk_window_get_size (window, NULL, height);
1741 draw_part (GdkDrawable *drawable,
1749 gdk_gc_set_clip_rectangle (gc, area);
1751 if (!indicator_parts[part].bmap)
1752 indicator_parts[part].bmap = gdk_bitmap_create_from_data (drawable,
1753 indicator_parts[part].bits,
1754 INDICATOR_PART_SIZE, INDICATOR_PART_SIZE);
1756 gdk_gc_set_ts_origin (gc, x, y);
1757 gdk_gc_set_stipple (gc, indicator_parts[part].bmap);
1758 gdk_gc_set_fill (gc, GDK_STIPPLED);
1760 gdk_draw_rectangle (drawable, gc, TRUE, x, y, INDICATOR_PART_SIZE, INDICATOR_PART_SIZE);
1762 gdk_gc_set_fill (gc, GDK_SOLID);
1765 gdk_gc_set_clip_rectangle (gc, NULL);
1769 gtk_default_draw_hline (GtkStyle *style,
1771 GtkStateType state_type,
1774 const gchar *detail,
1779 gint thickness_light;
1780 gint thickness_dark;
1783 g_return_if_fail (GTK_IS_STYLE (style));
1784 g_return_if_fail (window != NULL);
1786 thickness_light = style->ythickness / 2;
1787 thickness_dark = style->ythickness - thickness_light;
1791 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1792 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1795 if (detail && !strcmp (detail, "label"))
1797 if (state_type == GTK_STATE_INSENSITIVE)
1798 gdk_draw_line (window, style->white_gc, x1 + 1, y + 1, x2 + 1, y + 1);
1799 gdk_draw_line (window, style->fg_gc[state_type], x1, y, x2, y);
1803 for (i = 0; i < thickness_dark; i++)
1805 gdk_draw_line (window, style->light_gc[state_type], x2 - i - 1, y + i, x2, y + i);
1806 gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x2 - i - 1, y + i);
1809 y += thickness_dark;
1810 for (i = 0; i < thickness_light; i++)
1812 gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x1 + thickness_light - i - 1, y + i);
1813 gdk_draw_line (window, style->light_gc[state_type], x1 + thickness_light - i - 1, y + i, x2, y + i);
1819 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
1820 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
1826 gtk_default_draw_vline (GtkStyle *style,
1828 GtkStateType state_type,
1831 const gchar *detail,
1836 gint thickness_light;
1837 gint thickness_dark;
1840 g_return_if_fail (GTK_IS_STYLE (style));
1841 g_return_if_fail (window != NULL);
1843 thickness_light = style->xthickness / 2;
1844 thickness_dark = style->xthickness - thickness_light;
1848 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1849 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1851 for (i = 0; i < thickness_dark; i++)
1853 gdk_draw_line (window, style->light_gc[state_type], x + i, y2 - i - 1, x + i, y2);
1854 gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y2 - i - 1);
1857 x += thickness_dark;
1858 for (i = 0; i < thickness_light; i++)
1860 gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y1 + thickness_light - i);
1861 gdk_draw_line (window, style->light_gc[state_type], x + i, y1 + thickness_light - i, x + i, y2);
1865 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
1866 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
1872 draw_thin_shadow (GtkStyle *style,
1883 sanitize_size (window, &width, &height);
1885 gc1 = style->light_gc[state];
1886 gc2 = style->dark_gc[state];
1890 gdk_gc_set_clip_rectangle (gc1, area);
1891 gdk_gc_set_clip_rectangle (gc2, area);
1894 gdk_draw_line (window, gc1,
1895 x, y + height - 1, x + width - 1, y + height - 1);
1896 gdk_draw_line (window, gc1,
1897 x + width - 1, y, x + width - 1, y + height - 1);
1899 gdk_draw_line (window, gc2,
1900 x, y, x + width - 1, y);
1901 gdk_draw_line (window, gc2,
1902 x, y, x, y + height - 1);
1906 gdk_gc_set_clip_rectangle (gc1, NULL);
1907 gdk_gc_set_clip_rectangle (gc2, NULL);
1912 draw_spin_entry_shadow (GtkStyle *style,
1921 gint window_width, window_height;
1922 gboolean focus_inset;
1924 gdk_window_get_size (window, &window_width, &window_height);
1927 width = window_width;
1929 height = window_height;
1931 focus_inset = (width < window_width && height < window_height);
1935 gdk_gc_set_clip_rectangle (style->light_gc[state], area);
1936 gdk_gc_set_clip_rectangle (style->dark_gc[state], area);
1937 gdk_gc_set_clip_rectangle (style->black_gc, area);
1938 gdk_gc_set_clip_rectangle (style->bg_gc[state], area);
1939 gdk_gc_set_clip_rectangle (style->base_gc[state], area);
1942 gdk_draw_line (window, style->light_gc[state],
1943 x, y + height - 1, x + width - 1, y + height - 1);
1945 gdk_draw_line (window,
1946 style->base_gc[state],
1947 x + width - 1, y + 1, x + width - 1, y + height - 3);
1951 gdk_draw_line (window, style->bg_gc[state],
1952 x + 1, y + height - 2, x + width - 1, y + height - 2);
1953 gdk_draw_line (window,
1954 style->base_gc[state],
1955 x + width - 2, y + 1, x + width - 2, y + height - 3);
1957 gdk_draw_line (window, style->black_gc,
1958 x + 1, y + 1, x + width - 1, y + 1);
1959 gdk_draw_line (window, style->black_gc,
1960 x + 1, y + 1, x + 1, y + height - 2);
1963 gdk_draw_line (window, style->dark_gc[state],
1964 x, y, x + width - 1, y);
1965 gdk_draw_line (window, style->dark_gc[state],
1966 x, y, x, y + height - 1);
1970 gdk_gc_set_clip_rectangle (style->light_gc[state], NULL);
1971 gdk_gc_set_clip_rectangle (style->dark_gc[state], NULL);
1972 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
1973 gdk_gc_set_clip_rectangle (style->bg_gc[state], NULL);
1974 gdk_gc_set_clip_rectangle (style->base_gc[state], NULL);
1979 draw_spinbutton_shadow (GtkStyle *style,
1988 gint y_middle = y + height / 2;
1990 sanitize_size (window, &width, &height);
1994 gdk_gc_set_clip_rectangle (style->black_gc, area);
1995 gdk_gc_set_clip_rectangle (style->bg_gc[state], area);
1996 gdk_gc_set_clip_rectangle (style->dark_gc[state], area);
1997 gdk_gc_set_clip_rectangle (style->light_gc[state], area);
2000 gdk_draw_line (window, style->black_gc,
2001 x, y + 2, x, y + height - 3);
2002 gdk_draw_line (window, style->black_gc,
2003 x, y + 1, x + width - 2, y + 1);
2004 gdk_draw_line (window, style->black_gc,
2005 x + width - 2, y + 2, x + width - 2, y + height - 3);
2007 gdk_draw_line (window, style->bg_gc[state],
2008 x, y + height - 2, x + width - 2, y + height - 2);
2010 gdk_draw_line (window, style->dark_gc[state],
2011 x, y, x + width - 1, y);
2012 gdk_draw_line (window, style->dark_gc[state],
2013 x + 1, y_middle - 1, x + width - 3, y_middle - 1);
2014 gdk_draw_line (window, style->dark_gc[state],
2015 x + 1, y + height - 3, x + width - 3, y + height - 3);
2017 gdk_draw_line (window, style->light_gc[state],
2018 x + 1, y + 2, x + width - 3, y + 2);
2019 gdk_draw_line (window, style->light_gc[state],
2020 x + 1, y_middle, x + width - 3, y_middle);
2021 gdk_draw_line (window, style->light_gc[state],
2022 x + width - 1, y + 1, x + width - 1, y + height - 1);
2023 gdk_draw_line (window, style->light_gc[state],
2024 x, y + height - 1, x + width - 2, y + height - 1);
2028 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2029 gdk_gc_set_clip_rectangle (style->bg_gc[state], NULL);
2030 gdk_gc_set_clip_rectangle (style->dark_gc[state], NULL);
2031 gdk_gc_set_clip_rectangle (style->light_gc[state], NULL);
2036 gtk_default_draw_shadow (GtkStyle *style,
2038 GtkStateType state_type,
2039 GtkShadowType shadow_type,
2042 const gchar *detail,
2050 gint thickness_light;
2051 gint thickness_dark;
2054 g_return_if_fail (GTK_IS_STYLE (style));
2055 g_return_if_fail (window != NULL);
2057 if (shadow_type == GTK_SHADOW_IN)
2059 if (detail && (strcmp (detail, "buttondefault") == 0))
2061 sanitize_size (window, &width, &height);
2063 gdk_draw_rectangle (window, style->black_gc, FALSE,
2064 x, y, width - 1, height - 1);
2068 if (detail && strcmp (detail, "trough") == 0)
2070 draw_thin_shadow (style, window, state_type, area,
2071 x, y, width, height);
2074 else if (widget && GTK_IS_SPIN_BUTTON (widget) &&
2075 detail && strcmp (detail, "entry") == 0)
2077 draw_spin_entry_shadow (style, window, state_type, area,
2078 x, y, width, height);
2081 else if (widget && GTK_IS_SPIN_BUTTON (widget) &&
2082 detail && strcmp (detail, "spinbutton") == 0)
2084 draw_spinbutton_shadow (style, window, state_type,
2085 area, x, y, width, height);
2090 sanitize_size (window, &width, &height);
2092 switch (shadow_type)
2094 case GTK_SHADOW_NONE:
2097 case GTK_SHADOW_ETCHED_IN:
2098 gc1 = style->light_gc[state_type];
2099 gc2 = style->dark_gc[state_type];
2101 case GTK_SHADOW_OUT:
2102 case GTK_SHADOW_ETCHED_OUT:
2103 gc1 = style->dark_gc[state_type];
2104 gc2 = style->light_gc[state_type];
2110 gdk_gc_set_clip_rectangle (gc1, area);
2111 gdk_gc_set_clip_rectangle (gc2, area);
2112 if (shadow_type == GTK_SHADOW_IN ||
2113 shadow_type == GTK_SHADOW_OUT)
2115 gdk_gc_set_clip_rectangle (style->black_gc, area);
2116 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
2120 switch (shadow_type)
2122 case GTK_SHADOW_NONE:
2126 /* Light around right and bottom edge */
2128 if (style->ythickness > 0)
2129 gdk_draw_line (window, gc1,
2130 x, y + height - 1, x + width - 1, y + height - 1);
2131 if (style->xthickness > 0)
2132 gdk_draw_line (window, gc1,
2133 x + width - 1, y, x + width - 1, y + height - 1);
2135 if (style->ythickness > 1)
2136 gdk_draw_line (window, style->bg_gc[state_type],
2137 x + 1, y + height - 2, x + width - 2, y + height - 2);
2138 if (style->xthickness > 1)
2139 gdk_draw_line (window, style->bg_gc[state_type],
2140 x + width - 2, y + 1, x + width - 2, y + height - 2);
2142 /* Dark around left and top */
2144 if (style->ythickness > 1)
2145 gdk_draw_line (window, style->black_gc,
2146 x + 1, y + 1, x + width - 2, y + 1);
2147 if (style->xthickness > 1)
2148 gdk_draw_line (window, style->black_gc,
2149 x + 1, y + 1, x + 1, y + height - 2);
2151 if (style->ythickness > 0)
2152 gdk_draw_line (window, gc2,
2153 x, y, x + width - 1, y);
2154 if (style->xthickness > 0)
2155 gdk_draw_line (window, gc2,
2156 x, y, x, y + height - 1);
2159 case GTK_SHADOW_OUT:
2160 /* Dark around right and bottom edge */
2162 if (style->ythickness > 0)
2164 if (style->ythickness > 1)
2166 gdk_draw_line (window, gc1,
2167 x + 1, y + height - 2, x + width - 2, y + height - 2);
2168 gdk_draw_line (window, style->black_gc,
2169 x, y + height - 1, x + width - 1, y + height - 1);
2173 gdk_draw_line (window, gc1,
2174 x + 1, y + height - 1, x + width - 1, y + height - 1);
2178 if (style->xthickness > 0)
2180 if (style->xthickness > 1)
2182 gdk_draw_line (window, gc1,
2183 x + width - 2, y + 1, x + width - 2, y + height - 2);
2185 gdk_draw_line (window, style->black_gc,
2186 x + width - 1, y, x + width - 1, y + height - 1);
2190 gdk_draw_line (window, gc1,
2191 x + width - 1, y + 1, x + width - 1, y + height - 1);
2195 /* Light around top and left */
2197 if (style->ythickness > 0)
2198 gdk_draw_line (window, gc2,
2199 x, y, x + width - 1, y);
2200 if (style->xthickness > 0)
2201 gdk_draw_line (window, gc2,
2202 x, y, x, y + height - 1);
2204 if (style->ythickness > 1)
2205 gdk_draw_line (window, style->bg_gc[state_type],
2206 x + 1, y + 1, x + width - 2, y + 1);
2207 if (style->xthickness > 1)
2208 gdk_draw_line (window, style->bg_gc[state_type],
2209 x + 1, y + 1, x + 1, y + height - 2);
2212 case GTK_SHADOW_ETCHED_IN:
2213 case GTK_SHADOW_ETCHED_OUT:
2214 if (style->xthickness > 0)
2216 if (style->xthickness > 1)
2218 thickness_light = 1;
2221 for (i = 0; i < thickness_dark; i++)
2223 gdk_draw_line (window, gc1,
2227 y + height - i - 1);
2228 gdk_draw_line (window, gc2,
2232 y + height - i - 2);
2235 for (i = 0; i < thickness_light; i++)
2237 gdk_draw_line (window, gc1,
2238 x + thickness_dark + i,
2239 y + thickness_dark + i,
2240 x + thickness_dark + i,
2241 y + height - thickness_dark - i - 1);
2242 gdk_draw_line (window, gc2,
2243 x + width - thickness_light - i - 1,
2244 y + thickness_dark + i,
2245 x + width - thickness_light - i - 1,
2246 y + height - thickness_light - 1);
2251 gdk_draw_line (window,
2252 style->dark_gc[state_type],
2253 x, y, x, y + height);
2254 gdk_draw_line (window,
2255 style->dark_gc[state_type],
2256 x + width, y, x + width, y + height);
2260 if (style->ythickness > 0)
2262 if (style->ythickness > 1)
2264 thickness_light = 1;
2267 for (i = 0; i < thickness_dark; i++)
2269 gdk_draw_line (window, gc1,
2273 y + height - i - 1);
2275 gdk_draw_line (window, gc2,
2282 for (i = 0; i < thickness_light; i++)
2284 gdk_draw_line (window, gc1,
2285 x + thickness_dark + i,
2286 y + thickness_dark + i,
2287 x + width - thickness_dark - i - 1,
2288 y + thickness_dark + i);
2290 gdk_draw_line (window, gc2,
2291 x + thickness_dark + i,
2292 y + height - thickness_light - i - 1,
2293 x + width - thickness_light - 1,
2294 y + height - thickness_light - i - 1);
2299 gdk_draw_line (window,
2300 style->dark_gc[state_type],
2301 x, y, x + width, y);
2302 gdk_draw_line (window,
2303 style->dark_gc[state_type],
2304 x, y + height, x + width, y + height);
2312 gdk_gc_set_clip_rectangle (gc1, NULL);
2313 gdk_gc_set_clip_rectangle (gc2, NULL);
2314 if (shadow_type == GTK_SHADOW_IN ||
2315 shadow_type == GTK_SHADOW_OUT)
2317 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2318 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2324 gtk_default_draw_polygon (GtkStyle *style,
2326 GtkStateType state_type,
2327 GtkShadowType shadow_type,
2330 const gchar *detail,
2335 static const gdouble pi_over_4 = G_PI_4;
2336 static const gdouble pi_3_over_4 = G_PI_4 * 3;
2346 g_return_if_fail (GTK_IS_STYLE (style));
2347 g_return_if_fail (window != NULL);
2348 g_return_if_fail (points != NULL);
2350 switch (shadow_type)
2353 gc1 = style->bg_gc[state_type];
2354 gc2 = style->dark_gc[state_type];
2355 gc3 = style->light_gc[state_type];
2356 gc4 = style->black_gc;
2358 case GTK_SHADOW_ETCHED_IN:
2359 gc1 = style->light_gc[state_type];
2360 gc2 = style->dark_gc[state_type];
2361 gc3 = style->dark_gc[state_type];
2362 gc4 = style->light_gc[state_type];
2364 case GTK_SHADOW_OUT:
2365 gc1 = style->dark_gc[state_type];
2366 gc2 = style->light_gc[state_type];
2367 gc3 = style->black_gc;
2368 gc4 = style->bg_gc[state_type];
2370 case GTK_SHADOW_ETCHED_OUT:
2371 gc1 = style->dark_gc[state_type];
2372 gc2 = style->light_gc[state_type];
2373 gc3 = style->light_gc[state_type];
2374 gc4 = style->dark_gc[state_type];
2382 gdk_gc_set_clip_rectangle (gc1, area);
2383 gdk_gc_set_clip_rectangle (gc2, area);
2384 gdk_gc_set_clip_rectangle (gc3, area);
2385 gdk_gc_set_clip_rectangle (gc4, area);
2389 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, npoints);
2393 for (i = 0; i < npoints; i++)
2395 if ((points[i].x == points[i+1].x) &&
2396 (points[i].y == points[i+1].y))
2402 angle = atan2 (points[i+1].y - points[i].y,
2403 points[i+1].x - points[i].x);
2406 if ((angle > -pi_3_over_4) && (angle < pi_over_4))
2408 if (angle > -pi_over_4)
2419 gdk_draw_line (window, gc1,
2420 points[i].x-xadjust, points[i].y-yadjust,
2421 points[i+1].x-xadjust, points[i+1].y-yadjust);
2422 gdk_draw_line (window, gc3,
2423 points[i].x, points[i].y,
2424 points[i+1].x, points[i+1].y);
2428 if ((angle < -pi_3_over_4) || (angle > pi_3_over_4))
2439 gdk_draw_line (window, gc4,
2440 points[i].x+xadjust, points[i].y+yadjust,
2441 points[i+1].x+xadjust, points[i+1].y+yadjust);
2442 gdk_draw_line (window, gc2,
2443 points[i].x, points[i].y,
2444 points[i+1].x, points[i+1].y);
2450 gdk_gc_set_clip_rectangle (gc1, NULL);
2451 gdk_gc_set_clip_rectangle (gc2, NULL);
2452 gdk_gc_set_clip_rectangle (gc3, NULL);
2453 gdk_gc_set_clip_rectangle (gc4, NULL);
2458 draw_varrow (GdkWindow *window,
2460 GtkShadowType shadow_type,
2462 GtkArrowType arrow_type,
2469 gint y_start, y_increment;
2473 gdk_gc_set_clip_rectangle (gc, area);
2475 width = width + width % 2 - 1; /* Force odd */
2477 steps = 1 + width / 2;
2479 extra = height - steps;
2481 if (arrow_type == GTK_ARROW_DOWN)
2488 y_start = y + height - 1;
2492 for (i = 0; i < extra; i++)
2494 gdk_draw_line (window, gc,
2495 x, y_start + i * y_increment,
2496 x + width - 1, y_start + i * y_increment);
2498 for (; i < height; i++)
2500 gdk_draw_line (window, gc,
2501 x + (i - extra), y_start + i * y_increment,
2502 x + width - (i - extra) - 1, y_start + i * y_increment);
2507 gdk_gc_set_clip_rectangle (gc, NULL);
2511 draw_harrow (GdkWindow *window,
2513 GtkShadowType shadow_type,
2515 GtkArrowType arrow_type,
2522 gint x_start, x_increment;
2526 gdk_gc_set_clip_rectangle (gc, area);
2528 height = height + height % 2 - 1; /* Force odd */
2530 steps = 1 + height / 2;
2532 extra = width - steps;
2534 if (arrow_type == GTK_ARROW_RIGHT)
2541 x_start = x + width - 1;
2545 for (i = 0; i < extra; i++)
2547 gdk_draw_line (window, gc,
2548 x_start + i * x_increment, y,
2549 x_start + i * x_increment, y + height - 1);
2551 for (; i < width; i++)
2553 gdk_draw_line (window, gc,
2554 x_start + i * x_increment, y + (i - extra),
2555 x_start + i * x_increment, y + height - (i - extra) - 1);
2560 gdk_gc_set_clip_rectangle (gc, NULL);
2564 gtk_default_draw_arrow (GtkStyle *style,
2567 GtkShadowType shadow,
2570 const gchar *detail,
2571 GtkArrowType arrow_type,
2578 sanitize_size (window, &width, &height);
2580 if (detail && strcmp (detail, "spinbutton") == 0)
2582 x += (width - 7) / 2;
2584 if (arrow_type == GTK_ARROW_UP)
2585 y += (height - 4) / 2;
2587 y += (1 + height - 4) / 2;
2589 draw_varrow (window, style->fg_gc[state], shadow, area, arrow_type,
2592 else if (detail && strcmp (detail, "vscrollbar") == 0)
2594 gtk_paint_box (style, window, state, shadow, area,
2595 widget, detail, x, y, width, height);
2597 x += (width - 7) / 2;
2598 y += (height - 5) / 2;
2600 draw_varrow (window, style->fg_gc[state], shadow, area, arrow_type,
2604 else if (detail && strcmp (detail, "hscrollbar") == 0)
2606 gtk_paint_box (style, window, state, shadow, area,
2607 widget, detail, x, y, width, height);
2609 y += (height - 7) / 2;
2610 x += (width - 5) / 2;
2612 draw_harrow (window, style->fg_gc[state], shadow, area, arrow_type,
2617 if (arrow_type == GTK_ARROW_UP || arrow_type == GTK_ARROW_DOWN)
2619 x += (width - 7) / 2;
2620 y += (height - 5) / 2;
2622 draw_varrow (window, style->fg_gc[state], shadow, area, arrow_type,
2627 x += (width - 5) / 2;
2628 y += (height - 7) / 2;
2630 draw_harrow (window, style->fg_gc[state], shadow, area, arrow_type,
2637 gtk_default_draw_diamond (GtkStyle *style,
2639 GtkStateType state_type,
2640 GtkShadowType shadow_type,
2643 const gchar *detail,
2651 GdkGC *outer_nw = NULL;
2652 GdkGC *outer_ne = NULL;
2653 GdkGC *outer_sw = NULL;
2654 GdkGC *outer_se = NULL;
2655 GdkGC *middle_nw = NULL;
2656 GdkGC *middle_ne = NULL;
2657 GdkGC *middle_sw = NULL;
2658 GdkGC *middle_se = NULL;
2659 GdkGC *inner_nw = NULL;
2660 GdkGC *inner_ne = NULL;
2661 GdkGC *inner_sw = NULL;
2662 GdkGC *inner_se = NULL;
2664 g_return_if_fail (GTK_IS_STYLE (style));
2665 g_return_if_fail (window != NULL);
2667 sanitize_size (window, &width, &height);
2669 half_width = width / 2;
2670 half_height = height / 2;
2674 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
2675 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
2676 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
2677 gdk_gc_set_clip_rectangle (style->black_gc, area);
2680 switch (shadow_type)
2683 inner_sw = inner_se = style->bg_gc[state_type];
2684 middle_sw = middle_se = style->light_gc[state_type];
2685 outer_sw = outer_se = style->light_gc[state_type];
2686 inner_nw = inner_ne = style->black_gc;
2687 middle_nw = middle_ne = style->dark_gc[state_type];
2688 outer_nw = outer_ne = style->dark_gc[state_type];
2691 case GTK_SHADOW_OUT:
2692 inner_sw = inner_se = style->dark_gc[state_type];
2693 middle_sw = middle_se = style->dark_gc[state_type];
2694 outer_sw = outer_se = style->black_gc;
2695 inner_nw = inner_ne = style->bg_gc[state_type];
2696 middle_nw = middle_ne = style->light_gc[state_type];
2697 outer_nw = outer_ne = style->light_gc[state_type];
2700 case GTK_SHADOW_ETCHED_IN:
2701 inner_sw = inner_se = style->bg_gc[state_type];
2702 middle_sw = middle_se = style->dark_gc[state_type];
2703 outer_sw = outer_se = style->light_gc[state_type];
2704 inner_nw = inner_ne = style->bg_gc[state_type];
2705 middle_nw = middle_ne = style->light_gc[state_type];
2706 outer_nw = outer_ne = style->dark_gc[state_type];
2709 case GTK_SHADOW_ETCHED_OUT:
2710 inner_sw = inner_se = style->bg_gc[state_type];
2711 middle_sw = middle_se = style->light_gc[state_type];
2712 outer_sw = outer_se = style->dark_gc[state_type];
2713 inner_nw = inner_ne = style->bg_gc[state_type];
2714 middle_nw = middle_ne = style->dark_gc[state_type];
2715 outer_nw = outer_ne = style->light_gc[state_type];
2725 gdk_draw_line (window, inner_sw,
2726 x + 2, y + half_height,
2727 x + half_width, y + height - 2);
2728 gdk_draw_line (window, inner_se,
2729 x + half_width, y + height - 2,
2730 x + width - 2, y + half_height);
2731 gdk_draw_line (window, middle_sw,
2732 x + 1, y + half_height,
2733 x + half_width, y + height - 1);
2734 gdk_draw_line (window, middle_se,
2735 x + half_width, y + height - 1,
2736 x + width - 1, y + half_height);
2737 gdk_draw_line (window, outer_sw,
2739 x + half_width, y + height);
2740 gdk_draw_line (window, outer_se,
2741 x + half_width, y + height,
2742 x + width, y + half_height);
2744 gdk_draw_line (window, inner_nw,
2745 x + 2, y + half_height,
2746 x + half_width, y + 2);
2747 gdk_draw_line (window, inner_ne,
2748 x + half_width, y + 2,
2749 x + width - 2, y + half_height);
2750 gdk_draw_line (window, middle_nw,
2751 x + 1, y + half_height,
2752 x + half_width, y + 1);
2753 gdk_draw_line (window, middle_ne,
2754 x + half_width, y + 1,
2755 x + width - 1, y + half_height);
2756 gdk_draw_line (window, outer_nw,
2759 gdk_draw_line (window, outer_ne,
2761 x + width, y + half_height);
2766 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
2767 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2768 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
2769 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2774 gtk_default_draw_string (GtkStyle *style,
2776 GtkStateType state_type,
2779 const gchar *detail,
2782 const gchar *string)
2784 g_return_if_fail (GTK_IS_STYLE (style));
2785 g_return_if_fail (window != NULL);
2789 gdk_gc_set_clip_rectangle (style->white_gc, area);
2790 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], area);
2793 if (state_type == GTK_STATE_INSENSITIVE)
2794 gdk_draw_string (window, style->font, style->white_gc, x + 1, y + 1, string);
2796 gdk_draw_string (window, style->font, style->fg_gc[state_type], x, y, string);
2800 gdk_gc_set_clip_rectangle (style->white_gc, NULL);
2801 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], NULL);
2806 option_menu_get_props (GtkWidget *widget,
2807 GtkRequisition *indicator_size,
2808 GtkBorder *indicator_spacing)
2810 GtkRequisition *tmp_size = NULL;
2811 GtkBorder *tmp_spacing = NULL;
2814 gtk_widget_style_get (widget,
2815 "indicator_size", &tmp_size,
2816 "indicator_spacing", &tmp_spacing,
2821 *indicator_size = *tmp_size;
2825 *indicator_size = default_option_indicator_size;
2829 *indicator_spacing = *tmp_spacing;
2830 g_free (tmp_spacing);
2833 *indicator_spacing = default_option_indicator_spacing;
2837 gtk_default_draw_box (GtkStyle *style,
2839 GtkStateType state_type,
2840 GtkShadowType shadow_type,
2843 const gchar *detail,
2849 g_return_if_fail (GTK_IS_STYLE (style));
2850 g_return_if_fail (window != NULL);
2852 sanitize_size (window, &width, &height);
2854 if (!style->bg_pixmap[state_type] ||
2855 GDK_IS_PIXMAP (window))
2858 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
2860 gdk_draw_rectangle (window, style->bg_gc[state_type], TRUE,
2861 x, y, width, height);
2863 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2866 gtk_style_apply_default_background (style, window,
2867 widget && !GTK_WIDGET_NO_WINDOW (widget),
2868 state_type, area, x, y, width, height);
2870 gtk_paint_shadow (style, window, state_type, shadow_type, area, widget, detail,
2871 x, y, width, height);
2873 if (detail && strcmp (detail, "optionmenu") == 0)
2875 GtkRequisition indicator_size;
2876 GtkBorder indicator_spacing;
2878 option_menu_get_props (widget, &indicator_size, &indicator_spacing);
2880 sanitize_size (window, &width, &height);
2882 gtk_paint_vline (style, window, state_type, area, widget,
2884 y + style->ythickness + 1,
2885 y + height - style->ythickness - 3,
2886 x + width - (indicator_size.width + indicator_spacing.left + indicator_spacing.right) - style->xthickness);
2891 get_darkened_gc (GdkWindow *window,
2895 GdkColor src = *color;
2899 gc = gdk_gc_new (window);
2901 while (darken_count)
2903 gtk_style_shade (&src, &shaded, 0.93);
2908 gdk_gc_set_rgb_fg_color (gc, &shaded);
2914 gtk_default_draw_flat_box (GtkStyle *style,
2916 GtkStateType state_type,
2917 GtkShadowType shadow_type,
2920 const gchar *detail,
2927 GdkGC *freeme = NULL;
2929 g_return_if_fail (GTK_IS_STYLE (style));
2930 g_return_if_fail (window != NULL);
2932 sanitize_size (window, &width, &height);
2936 if (state_type == GTK_STATE_SELECTED)
2938 if (!strcmp ("text", detail))
2939 gc1 = style->bg_gc[GTK_STATE_SELECTED];
2940 else if (!strncmp ("cell_even", detail, strlen ("cell_even")) ||
2941 !strncmp ("cell_odd", detail, strlen ("cell_odd")))
2943 /* This has to be really broken; alex made me do it. -jrb */
2944 /* Red rum!!! REd RUM!!! */
2945 if (GTK_WIDGET_HAS_FOCUS (widget))
2946 gc1 = style->bg_gc[state_type];
2948 gc1 = style->bg_gc[GTK_STATE_ACTIVE];
2953 gc1 = style->bg_gc[state_type];
2958 if (!strcmp ("viewportbin", detail))
2959 gc1 = style->bg_gc[GTK_STATE_NORMAL];
2960 else if (!strcmp ("entry_bg", detail))
2961 gc1 = style->base_gc[state_type];
2963 /* For trees: even rows are base color, odd rows are a shade of
2964 * the base color, the sort column is a shade of the original color
2968 /* FIXME when we have style properties, clean this up.
2971 else if (!strcmp ("cell_even", detail) ||
2972 !strcmp ("cell_odd", detail) ||
2973 !strcmp ("cell_even_ruled", detail))
2975 gc1 = style->base_gc[state_type];
2977 else if (!strcmp ("cell_even_sorted", detail) ||
2978 !strcmp ("cell_odd_sorted", detail) ||
2979 !strcmp ("cell_odd_ruled", detail) ||
2980 !strcmp ("cell_even_ruled_sorted", detail))
2982 freeme = get_darkened_gc (window, &style->base[state_type], 1);
2985 else if (!strcmp ("cell_odd_ruled_sorted", detail))
2987 freeme = get_darkened_gc (window, &style->base[state_type], 2);
2991 gc1 = style->bg_gc[state_type];
2995 gc1 = style->bg_gc[state_type];
2997 if (!style->bg_pixmap[state_type] || gc1 != style->bg_gc[state_type] ||
2998 GDK_IS_PIXMAP (window))
3001 gdk_gc_set_clip_rectangle (gc1, area);
3003 gdk_draw_rectangle (window, gc1, TRUE,
3004 x, y, width, height);
3006 if (detail && !strcmp ("tooltip", detail))
3007 gdk_draw_rectangle (window, style->black_gc, FALSE,
3008 x, y, width - 1, height - 1);
3011 gdk_gc_set_clip_rectangle (gc1, NULL);
3014 gtk_style_apply_default_background (style, window,
3015 widget && !GTK_WIDGET_NO_WINDOW (widget),
3016 state_type, area, x, y, width, height);
3020 g_object_unref (G_OBJECT (freeme));
3024 gtk_default_draw_check (GtkStyle *style,
3026 GtkStateType state_type,
3027 GtkShadowType shadow_type,
3030 const gchar *detail,
3036 if (detail && strcmp (detail, "cellcheck") == 0)
3038 gdk_draw_rectangle (window,
3039 widget->style->fg_gc[state_type],
3044 if (shadow_type == GTK_SHADOW_IN)
3046 gdk_draw_line (window,
3047 widget->style->fg_gc[state_type],
3051 gdk_draw_line (window,
3052 widget->style->fg_gc[state_type],
3061 x -= (1 + INDICATOR_PART_SIZE - width) / 2;
3062 y -= (1 + INDICATOR_PART_SIZE - height) / 2;
3064 if (strcmp (detail, "check") == 0) /* Menu item */
3066 if (shadow_type == GTK_SHADOW_IN)
3068 draw_part (window, style->black_gc, area, x, y, CHECK_TEXT);
3069 draw_part (window, style->dark_gc[state_type], area, x, y, CHECK_AA);
3074 draw_part (window, style->black_gc, area, x, y, CHECK_BLACK);
3075 draw_part (window, style->dark_gc[state_type], area, x, y, CHECK_DARK);
3076 draw_part (window, style->mid_gc[state_type], area, x, y, CHECK_MID);
3077 draw_part (window, style->light_gc[state_type], area, x, y, CHECK_LIGHT);
3078 draw_part (window, style->base_gc[state_type], area, x, y, CHECK_BASE);
3080 if (shadow_type == GTK_SHADOW_IN)
3082 draw_part (window, style->text_gc[state_type], area, x, y, CHECK_TEXT);
3083 draw_part (window, style->text_aa_gc[state_type], area, x, y, CHECK_AA);
3091 gtk_default_draw_option (GtkStyle *style,
3093 GtkStateType state_type,
3094 GtkShadowType shadow_type,
3097 const gchar *detail,
3103 if (detail && strcmp (detail, "cellradio") == 0)
3105 gdk_draw_arc (window,
3106 widget->style->fg_gc[state_type],
3113 if (shadow_type == GTK_SHADOW_IN)
3115 gdk_draw_arc (window,
3116 widget->style->fg_gc[state_type],
3127 x -= (1 + INDICATOR_PART_SIZE - width) / 2;
3128 y -= (1 + INDICATOR_PART_SIZE - height) / 2;
3130 if (strcmp (detail, "option") == 0) /* Menu item */
3132 if (shadow_type == GTK_SHADOW_IN)
3133 draw_part (window, style->fg_gc[state_type], area, x, y, RADIO_TEXT);
3137 draw_part (window, style->black_gc, area, x, y, RADIO_BLACK);
3138 draw_part (window, style->dark_gc[state_type], area, x, y, RADIO_DARK);
3139 draw_part (window, style->mid_gc[state_type], area, x, y, RADIO_MID);
3140 draw_part (window, style->light_gc[state_type], area, x, y, RADIO_LIGHT);
3141 draw_part (window, style->base_gc[state_type], area, x, y, RADIO_BASE);
3143 if (shadow_type == GTK_SHADOW_IN)
3144 draw_part (window, style->text_gc[state_type], area, x, y, RADIO_TEXT);
3150 gtk_default_draw_tab (GtkStyle *style,
3152 GtkStateType state_type,
3153 GtkShadowType shadow_type,
3156 const gchar *detail,
3162 GtkRequisition indicator_size;
3163 GtkBorder indicator_spacing;
3165 option_menu_get_props (widget, &indicator_size, &indicator_spacing);
3167 x += (width - indicator_size.width) / 2;
3168 y += (height - indicator_size.height) / 2 - 1;
3170 draw_varrow (window, style->black_gc, shadow_type, area, GTK_ARROW_UP,
3171 x, y, indicator_size.width, 5);
3172 draw_varrow (window, style->black_gc, shadow_type, area, GTK_ARROW_DOWN,
3173 x, y + 8, indicator_size.width, 5);
3177 gtk_default_draw_shadow_gap (GtkStyle *style,
3179 GtkStateType state_type,
3180 GtkShadowType shadow_type,
3183 const gchar *detail,
3188 GtkPositionType gap_side,
3197 g_return_if_fail (GTK_IS_STYLE (style));
3198 g_return_if_fail (window != NULL);
3200 sanitize_size (window, &width, &height);
3202 switch (shadow_type)
3204 case GTK_SHADOW_NONE:
3207 gc1 = style->dark_gc[state_type];
3208 gc2 = style->black_gc;
3209 gc3 = style->bg_gc[state_type];
3210 gc4 = style->light_gc[state_type];
3212 case GTK_SHADOW_ETCHED_IN:
3213 gc1 = style->dark_gc[state_type];
3214 gc2 = style->light_gc[state_type];
3215 gc3 = style->dark_gc[state_type];
3216 gc4 = style->light_gc[state_type];
3218 case GTK_SHADOW_OUT:
3219 gc1 = style->light_gc[state_type];
3220 gc2 = style->bg_gc[state_type];
3221 gc3 = style->dark_gc[state_type];
3222 gc4 = style->black_gc;
3224 case GTK_SHADOW_ETCHED_OUT:
3225 gc1 = style->light_gc[state_type];
3226 gc2 = style->dark_gc[state_type];
3227 gc3 = style->light_gc[state_type];
3228 gc4 = style->dark_gc[state_type];
3233 gdk_gc_set_clip_rectangle (gc1, area);
3234 gdk_gc_set_clip_rectangle (gc2, area);
3235 gdk_gc_set_clip_rectangle (gc3, area);
3236 gdk_gc_set_clip_rectangle (gc4, area);
3239 switch (shadow_type)
3241 case GTK_SHADOW_NONE:
3243 case GTK_SHADOW_OUT:
3244 case GTK_SHADOW_ETCHED_IN:
3245 case GTK_SHADOW_ETCHED_OUT:
3249 gdk_draw_line (window, gc1,
3250 x, y, x, y + height - 1);
3251 gdk_draw_line (window, gc2,
3252 x + 1, y, x + 1, y + height - 2);
3254 gdk_draw_line (window, gc3,
3255 x + 1, y + height - 2, x + width - 2, y + height - 2);
3256 gdk_draw_line (window, gc3,
3257 x + width - 2, y, x + width - 2, y + height - 2);
3258 gdk_draw_line (window, gc4,
3259 x, y + height - 1, x + width - 1, y + height - 1);
3260 gdk_draw_line (window, gc4,
3261 x + width - 1, y, x + width - 1, y + height - 1);
3264 gdk_draw_line (window, gc1,
3265 x, y, x + gap_x - 1, y);
3266 gdk_draw_line (window, gc2,
3267 x + 1, y + 1, x + gap_x - 1, y + 1);
3268 gdk_draw_line (window, gc2,
3269 x + gap_x, y, x + gap_x, y);
3271 if ((width - (gap_x + gap_width)) > 0)
3273 gdk_draw_line (window, gc1,
3274 x + gap_x + gap_width, y, x + width - 2, y);
3275 gdk_draw_line (window, gc2,
3276 x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
3277 gdk_draw_line (window, gc2,
3278 x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
3281 case GTK_POS_BOTTOM:
3282 gdk_draw_line (window, gc1,
3283 x, y, x + width - 1, y);
3284 gdk_draw_line (window, gc1,
3285 x, y, x, y + height - 1);
3286 gdk_draw_line (window, gc2,
3287 x + 1, y + 1, x + width - 2, y + 1);
3288 gdk_draw_line (window, gc2,
3289 x + 1, y + 1, x + 1, y + height - 1);
3291 gdk_draw_line (window, gc3,
3292 x + width - 2, y + 1, x + width - 2, y + height - 1);
3293 gdk_draw_line (window, gc4,
3294 x + width - 1, y, x + width - 1, y + height - 1);
3297 gdk_draw_line (window, gc4,
3298 x, y + height - 1, x + gap_x - 1, y + height - 1);
3299 gdk_draw_line (window, gc3,
3300 x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
3301 gdk_draw_line (window, gc3,
3302 x + gap_x, y + height - 1, x + gap_x, y + height - 1);
3304 if ((width - (gap_x + gap_width)) > 0)
3306 gdk_draw_line (window, gc4,
3307 x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
3308 gdk_draw_line (window, gc3,
3309 x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
3310 gdk_draw_line (window, gc3,
3311 x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
3315 gdk_draw_line (window, gc1,
3316 x, y, x + width - 1, y);
3317 gdk_draw_line (window, gc2,
3318 x, y + 1, x + width - 2, y + 1);
3320 gdk_draw_line (window, gc3,
3321 x, y + height - 2, x + width - 2, y + height - 2);
3322 gdk_draw_line (window, gc3,
3323 x + width - 2, y + 1, x + width - 2, y + height - 2);
3324 gdk_draw_line (window, gc4,
3325 x, y + height - 1, x + width - 1, y + height - 1);
3326 gdk_draw_line (window, gc4,
3327 x + width - 1, y, x + width - 1, y + height - 1);
3330 gdk_draw_line (window, gc1,
3331 x, y, x, y + gap_x - 1);
3332 gdk_draw_line (window, gc2,
3333 x + 1, y + 1, x + 1, y + gap_x - 1);
3334 gdk_draw_line (window, gc2,
3335 x, y + gap_x, x, y + gap_x);
3337 if ((width - (gap_x + gap_width)) > 0)
3339 gdk_draw_line (window, gc1,
3340 x, y + gap_x + gap_width, x, y + height - 2);
3341 gdk_draw_line (window, gc2,
3342 x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
3343 gdk_draw_line (window, gc2,
3344 x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
3348 gdk_draw_line (window, gc1,
3349 x, y, x + width - 1, y);
3350 gdk_draw_line (window, gc1,
3351 x, y, x, y + height - 1);
3352 gdk_draw_line (window, gc2,
3353 x + 1, y + 1, x + width - 1, y + 1);
3354 gdk_draw_line (window, gc2,
3355 x + 1, y + 1, x + 1, y + height - 2);
3357 gdk_draw_line (window, gc3,
3358 x + 1, y + height - 2, x + width - 1, y + height - 2);
3359 gdk_draw_line (window, gc4,
3360 x, y + height - 1, x + width - 1, y + height - 1);
3363 gdk_draw_line (window, gc4,
3364 x + width - 1, y, x + width - 1, y + gap_x - 1);
3365 gdk_draw_line (window, gc3,
3366 x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
3367 gdk_draw_line (window, gc3,
3368 x + width - 1, y + gap_x, x + width - 1, y + gap_x);
3370 if ((width - (gap_x + gap_width)) > 0)
3372 gdk_draw_line (window, gc4,
3373 x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
3374 gdk_draw_line (window, gc3,
3375 x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
3376 gdk_draw_line (window, gc3,
3377 x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
3385 gdk_gc_set_clip_rectangle (gc1, NULL);
3386 gdk_gc_set_clip_rectangle (gc2, NULL);
3387 gdk_gc_set_clip_rectangle (gc3, NULL);
3388 gdk_gc_set_clip_rectangle (gc4, NULL);
3393 gtk_default_draw_box_gap (GtkStyle *style,
3395 GtkStateType state_type,
3396 GtkShadowType shadow_type,
3399 const gchar *detail,
3404 GtkPositionType gap_side,
3413 g_return_if_fail (GTK_IS_STYLE (style));
3414 g_return_if_fail (window != NULL);
3416 gtk_style_apply_default_background (style, window,
3417 widget && !GTK_WIDGET_NO_WINDOW (widget),
3418 state_type, area, x, y, width, height);
3420 sanitize_size (window, &width, &height);
3422 switch (shadow_type)
3424 case GTK_SHADOW_NONE:
3427 gc1 = style->dark_gc[state_type];
3428 gc2 = style->black_gc;
3429 gc3 = style->bg_gc[state_type];
3430 gc4 = style->light_gc[state_type];
3432 case GTK_SHADOW_ETCHED_IN:
3433 gc1 = style->dark_gc[state_type];
3434 gc2 = style->light_gc[state_type];
3435 gc3 = style->dark_gc[state_type];
3436 gc4 = style->light_gc[state_type];
3438 case GTK_SHADOW_OUT:
3439 gc1 = style->light_gc[state_type];
3440 gc2 = style->bg_gc[state_type];
3441 gc3 = style->dark_gc[state_type];
3442 gc4 = style->black_gc;
3444 case GTK_SHADOW_ETCHED_OUT:
3445 gc1 = style->light_gc[state_type];
3446 gc2 = style->dark_gc[state_type];
3447 gc3 = style->light_gc[state_type];
3448 gc4 = style->dark_gc[state_type];
3454 gdk_gc_set_clip_rectangle (gc1, area);
3455 gdk_gc_set_clip_rectangle (gc2, area);
3456 gdk_gc_set_clip_rectangle (gc3, area);
3457 gdk_gc_set_clip_rectangle (gc4, area);
3460 switch (shadow_type)
3462 case GTK_SHADOW_NONE:
3464 case GTK_SHADOW_OUT:
3465 case GTK_SHADOW_ETCHED_IN:
3466 case GTK_SHADOW_ETCHED_OUT:
3470 gdk_draw_line (window, gc1,
3471 x, y, x, y + height - 1);
3472 gdk_draw_line (window, gc2,
3473 x + 1, y, x + 1, y + height - 2);
3475 gdk_draw_line (window, gc3,
3476 x + 1, y + height - 2, x + width - 2, y + height - 2);
3477 gdk_draw_line (window, gc3,
3478 x + width - 2, y, x + width - 2, y + height - 2);
3479 gdk_draw_line (window, gc4,
3480 x, y + height - 1, x + width - 1, y + height - 1);
3481 gdk_draw_line (window, gc4,
3482 x + width - 1, y, x + width - 1, y + height - 1);
3485 gdk_draw_line (window, gc1,
3486 x, y, x + gap_x - 1, y);
3487 gdk_draw_line (window, gc2,
3488 x + 1, y + 1, x + gap_x - 1, y + 1);
3489 gdk_draw_line (window, gc2,
3490 x + gap_x, y, x + gap_x, y);
3492 if ((width - (gap_x + gap_width)) > 0)
3494 gdk_draw_line (window, gc1,
3495 x + gap_x + gap_width, y, x + width - 2, y);
3496 gdk_draw_line (window, gc2,
3497 x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
3498 gdk_draw_line (window, gc2,
3499 x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
3502 case GTK_POS_BOTTOM:
3503 gdk_draw_line (window, gc1,
3504 x, y, x + width - 1, y);
3505 gdk_draw_line (window, gc1,
3506 x, y, x, y + height - 1);
3507 gdk_draw_line (window, gc2,
3508 x + 1, y + 1, x + width - 2, y + 1);
3509 gdk_draw_line (window, gc2,
3510 x + 1, y + 1, x + 1, y + height - 1);
3512 gdk_draw_line (window, gc3,
3513 x + width - 2, y + 1, x + width - 2, y + height - 1);
3514 gdk_draw_line (window, gc4,
3515 x + width - 1, y, x + width - 1, y + height - 1);
3518 gdk_draw_line (window, gc4,
3519 x, y + height - 1, x + gap_x - 1, y + height - 1);
3520 gdk_draw_line (window, gc3,
3521 x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
3522 gdk_draw_line (window, gc3,
3523 x + gap_x, y + height - 1, x + gap_x, y + height - 1);
3525 if ((width - (gap_x + gap_width)) > 0)
3527 gdk_draw_line (window, gc4,
3528 x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
3529 gdk_draw_line (window, gc3,
3530 x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
3531 gdk_draw_line (window, gc3,
3532 x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
3536 gdk_draw_line (window, gc1,
3537 x, y, x + width - 1, y);
3538 gdk_draw_line (window, gc2,
3539 x, y + 1, x + width - 2, y + 1);
3541 gdk_draw_line (window, gc3,
3542 x, y + height - 2, x + width - 2, y + height - 2);
3543 gdk_draw_line (window, gc3,
3544 x + width - 2, y + 1, x + width - 2, y + height - 2);
3545 gdk_draw_line (window, gc4,
3546 x, y + height - 1, x + width - 1, y + height - 1);
3547 gdk_draw_line (window, gc4,
3548 x + width - 1, y, x + width - 1, y + height - 1);
3551 gdk_draw_line (window, gc1,
3552 x, y, x, y + gap_x - 1);
3553 gdk_draw_line (window, gc2,
3554 x + 1, y + 1, x + 1, y + gap_x - 1);
3555 gdk_draw_line (window, gc2,
3556 x, y + gap_x, x, y + gap_x);
3558 if ((width - (gap_x + gap_width)) > 0)
3560 gdk_draw_line (window, gc1,
3561 x, y + gap_x + gap_width, x, y + height - 2);
3562 gdk_draw_line (window, gc2,
3563 x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
3564 gdk_draw_line (window, gc2,
3565 x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
3569 gdk_draw_line (window, gc1,
3570 x, y, x + width - 1, y);
3571 gdk_draw_line (window, gc1,
3572 x, y, x, y + height - 1);
3573 gdk_draw_line (window, gc2,
3574 x + 1, y + 1, x + width - 1, y + 1);
3575 gdk_draw_line (window, gc2,
3576 x + 1, y + 1, x + 1, y + height - 2);
3578 gdk_draw_line (window, gc3,
3579 x + 1, y + height - 2, x + width - 1, y + height - 2);
3580 gdk_draw_line (window, gc4,
3581 x, y + height - 1, x + width - 1, y + height - 1);
3584 gdk_draw_line (window, gc4,
3585 x + width - 1, y, x + width - 1, y + gap_x - 1);
3586 gdk_draw_line (window, gc3,
3587 x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
3588 gdk_draw_line (window, gc3,
3589 x + width - 1, y + gap_x, x + width - 1, y + gap_x);
3591 if ((width - (gap_x + gap_width)) > 0)
3593 gdk_draw_line (window, gc4,
3594 x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
3595 gdk_draw_line (window, gc3,
3596 x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
3597 gdk_draw_line (window, gc3,
3598 x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
3606 gdk_gc_set_clip_rectangle (gc1, NULL);
3607 gdk_gc_set_clip_rectangle (gc2, NULL);
3608 gdk_gc_set_clip_rectangle (gc3, NULL);
3609 gdk_gc_set_clip_rectangle (gc4, NULL);
3614 gtk_default_draw_extension (GtkStyle *style,
3616 GtkStateType state_type,
3617 GtkShadowType shadow_type,
3620 const gchar *detail,
3625 GtkPositionType gap_side)
3632 g_return_if_fail (GTK_IS_STYLE (style));
3633 g_return_if_fail (window != NULL);
3635 gtk_style_apply_default_background (style, window,
3636 widget && !GTK_WIDGET_NO_WINDOW (widget),
3637 GTK_STATE_NORMAL, area, x, y, width, height);
3639 sanitize_size (window, &width, &height);
3641 switch (shadow_type)
3643 case GTK_SHADOW_NONE:
3646 gc1 = style->dark_gc[state_type];
3647 gc2 = style->black_gc;
3648 gc3 = style->bg_gc[state_type];
3649 gc4 = style->light_gc[state_type];
3651 case GTK_SHADOW_ETCHED_IN:
3652 gc1 = style->dark_gc[state_type];
3653 gc2 = style->light_gc[state_type];
3654 gc3 = style->dark_gc[state_type];
3655 gc4 = style->light_gc[state_type];
3657 case GTK_SHADOW_OUT:
3658 gc1 = style->light_gc[state_type];
3659 gc2 = style->bg_gc[state_type];
3660 gc3 = style->dark_gc[state_type];
3661 gc4 = style->black_gc;
3663 case GTK_SHADOW_ETCHED_OUT:
3664 gc1 = style->light_gc[state_type];
3665 gc2 = style->dark_gc[state_type];
3666 gc3 = style->light_gc[state_type];
3667 gc4 = style->dark_gc[state_type];
3673 gdk_gc_set_clip_rectangle (gc1, area);
3674 gdk_gc_set_clip_rectangle (gc2, area);
3675 gdk_gc_set_clip_rectangle (gc3, area);
3676 gdk_gc_set_clip_rectangle (gc4, area);
3679 switch (shadow_type)
3681 case GTK_SHADOW_NONE:
3683 case GTK_SHADOW_OUT:
3684 case GTK_SHADOW_ETCHED_IN:
3685 case GTK_SHADOW_ETCHED_OUT:
3689 gtk_style_apply_default_background (style, window,
3690 widget && !GTK_WIDGET_NO_WINDOW (widget),
3692 x + style->xthickness,
3694 width - (2 * style->xthickness),
3695 height - (style->ythickness));
3696 gdk_draw_line (window, gc1,
3697 x, y, x, y + height - 2);
3698 gdk_draw_line (window, gc2,
3699 x + 1, y, x + 1, y + height - 2);
3701 gdk_draw_line (window, gc3,
3702 x + 2, y + height - 2, x + width - 2, y + height - 2);
3703 gdk_draw_line (window, gc3,
3704 x + width - 2, y, x + width - 2, y + height - 2);
3705 gdk_draw_line (window, gc4,
3706 x + 1, y + height - 1, x + width - 2, y + height - 1);
3707 gdk_draw_line (window, gc4,
3708 x + width - 1, y, x + width - 1, y + height - 2);
3710 case GTK_POS_BOTTOM:
3711 gtk_style_apply_default_background (style, window,
3712 widget && !GTK_WIDGET_NO_WINDOW (widget),
3714 x + style->xthickness,
3715 y + style->ythickness,
3716 width - (2 * style->xthickness),
3717 height - (style->ythickness));
3718 gdk_draw_line (window, gc1,
3719 x + 1, y, x + width - 2, y);
3720 gdk_draw_line (window, gc1,
3721 x, y + 1, x, y + height - 1);
3722 gdk_draw_line (window, gc2,
3723 x + 1, y + 1, x + width - 2, y + 1);
3724 gdk_draw_line (window, gc2,
3725 x + 1, y + 1, x + 1, y + height - 1);
3727 gdk_draw_line (window, gc3,
3728 x + width - 2, y + 2, x + width - 2, y + height - 1);
3729 gdk_draw_line (window, gc4,
3730 x + width - 1, y + 1, x + width - 1, y + height - 1);
3733 gtk_style_apply_default_background (style, window,
3734 widget && !GTK_WIDGET_NO_WINDOW (widget),
3737 y + style->ythickness,
3738 width - (style->xthickness),
3739 height - (2 * style->ythickness));
3740 gdk_draw_line (window, gc1,
3741 x, y, x + width - 2, y);
3742 gdk_draw_line (window, gc2,
3743 x + 1, y + 1, x + width - 2, y + 1);
3745 gdk_draw_line (window, gc3,
3746 x, y + height - 2, x + width - 2, y + height - 2);
3747 gdk_draw_line (window, gc3,
3748 x + width - 2, y + 2, x + width - 2, y + height - 2);
3749 gdk_draw_line (window, gc4,
3750 x, y + height - 1, x + width - 2, y + height - 1);
3751 gdk_draw_line (window, gc4,
3752 x + width - 1, y + 1, x + width - 1, y + height - 2);
3755 gtk_style_apply_default_background (style, window,
3756 widget && !GTK_WIDGET_NO_WINDOW (widget),
3758 x + style->xthickness,
3759 y + style->ythickness,
3760 width - (style->xthickness),
3761 height - (2 * style->ythickness));
3762 gdk_draw_line (window, gc1,
3763 x + 1, y, x + width - 1, y);
3764 gdk_draw_line (window, gc1,
3765 x, y + 1, x, y + height - 2);
3766 gdk_draw_line (window, gc2,
3767 x + 1, y + 1, x + width - 1, y + 1);
3768 gdk_draw_line (window, gc2,
3769 x + 1, y + 1, x + 1, y + height - 2);
3771 gdk_draw_line (window, gc3,
3772 x + 2, y + height - 2, x + width - 1, y + height - 2);
3773 gdk_draw_line (window, gc4,
3774 x + 1, y + height - 1, x + width - 1, y + height - 1);
3781 gdk_gc_set_clip_rectangle (gc1, NULL);
3782 gdk_gc_set_clip_rectangle (gc2, NULL);
3783 gdk_gc_set_clip_rectangle (gc3, NULL);
3784 gdk_gc_set_clip_rectangle (gc4, NULL);
3789 gtk_default_draw_focus (GtkStyle *style,
3793 const gchar *detail,
3801 sanitize_size (window, &width, &height);
3804 gdk_gc_set_clip_rectangle (style->black_gc, area);
3806 gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_ON_OFF_DASH, 0, 0);
3808 if (detail && !strcmp (detail, "add-mode"))
3809 gdk_gc_set_dashes (style->black_gc, 0, "\4\4", 2);
3811 gdk_gc_set_dashes (style->black_gc, 0, "\1\1", 2);
3815 points[1].x = x + width;
3817 points[2].x = x + width;
3818 points[2].y = y + height;
3820 points[3].y = y + height;
3821 points[4] = points[0];
3823 gdk_draw_polygon (window, style->black_gc, FALSE, points, 4);
3824 gdk_gc_set_line_attributes (style->black_gc, 0, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
3827 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
3831 gtk_default_draw_slider (GtkStyle *style,
3833 GtkStateType state_type,
3834 GtkShadowType shadow_type,
3837 const gchar *detail,
3842 GtkOrientation orientation)
3844 g_return_if_fail (GTK_IS_STYLE (style));
3845 g_return_if_fail (window != NULL);
3847 sanitize_size (window, &width, &height);
3849 gtk_paint_box (style, window, state_type, shadow_type,
3850 area, widget, detail, x, y, width, height);
3853 (strcmp ("hscale", detail) == 0 ||
3854 strcmp ("vscale", detail) == 0))
3856 if (orientation == GTK_ORIENTATION_HORIZONTAL)
3857 gtk_paint_vline (style, window, state_type, area, widget, detail,
3858 y + style->ythickness,
3859 y + height - style->ythickness - 1, x + width / 2);
3861 gtk_paint_hline (style, window, state_type, area, widget, detail,
3862 x + style->xthickness,
3863 x + width - style->xthickness - 1, y + height / 2);
3868 draw_dot (GdkWindow *window,
3876 size = CLAMP (size, 2, 3);
3880 gdk_draw_point (window, light_gc, x, y);
3881 gdk_draw_point (window, light_gc, x+1, y+1);
3883 else if (size == 3);
3885 gdk_draw_point (window, light_gc, x, y);
3886 gdk_draw_point (window, light_gc, x+1, y);
3887 gdk_draw_point (window, light_gc, x, y+1);
3888 gdk_draw_point (window, dark_gc, x+1, y+2);
3889 gdk_draw_point (window, dark_gc, x+2, y+1);
3890 gdk_draw_point (window, dark_gc, x+2, y+2);
3895 gtk_default_draw_handle (GtkStyle *style,
3897 GtkStateType state_type,
3898 GtkShadowType shadow_type,
3901 const gchar *detail,
3906 GtkOrientation orientation)
3909 gint xthick, ythick;
3910 GdkGC *light_gc, *dark_gc;
3915 g_return_if_fail (GTK_IS_STYLE (style));
3916 g_return_if_fail (window != NULL);
3918 sanitize_size (window, &width, &height);
3920 gtk_paint_box (style, window, state_type, shadow_type, area, widget,
3921 detail, x, y, width, height);
3924 if (!strcmp (detail, "paned"))
3926 /* we want to ignore the shadow border in paned widgets */
3930 light_gc = style->light_gc[state_type];
3931 dark_gc = style->black_gc;
3935 xthick = style->xthickness;
3936 ythick = style->ythickness;
3938 light_gc = style->light_gc[state_type];
3939 dark_gc = style->dark_gc[state_type];
3942 rect.x = x + xthick;
3943 rect.y = y + ythick;
3944 rect.width = width - (xthick * 2);
3945 rect.height = height - (ythick * 2);
3948 intersect = gdk_rectangle_intersect (area, &rect, &dest);
3958 gdk_gc_set_clip_rectangle (light_gc, &dest);
3959 gdk_gc_set_clip_rectangle (dark_gc, &dest);
3961 if (!strcmp (detail, "paned"))
3966 gdk_window_get_size (window, &window_width, &window_height);
3968 if (orientation == GTK_ORIENTATION_HORIZONTAL)
3969 for (xx = window_width/2 - 15; xx <= window_width/2 + 15; xx += 5)
3970 draw_dot (window, light_gc, dark_gc, xx, window_height/2 - 1, 3);
3972 for (yy = window_height/2 - 15; yy <= window_height/2 + 15; yy += 5)
3973 draw_dot (window, light_gc, dark_gc, window_width/2 - 1, yy, 3);
3977 for (yy = y + ythick; yy < (y + height - ythick); yy += 3)
3978 for (xx = x + xthick; xx < (x + width - xthick); xx += 6)
3980 draw_dot (window, light_gc, dark_gc, xx, yy, 2);
3981 draw_dot (window, light_gc, dark_gc, xx + 3, yy + 1, 2);
3985 gdk_gc_set_clip_rectangle (light_gc, NULL);
3986 gdk_gc_set_clip_rectangle (dark_gc, NULL);
3990 create_expander_affine (gdouble affine[6],
4000 width = expander_size / 4.0;
4001 height = expander_size / 2.0;
4003 s = sin (degrees * G_PI / 180.0);
4004 c = cos (degrees * G_PI / 180.0);
4010 affine[4] = -width * c - height * -s + x;
4011 affine[5] = -width * s - height * c + y;
4015 apply_affine_on_point (double affine[6], GdkPoint *point)
4019 x = point->x * affine[0] + point->y * affine[2] + affine[4];
4020 y = point->x * affine[1] + point->y * affine[3] + affine[5];
4027 gtk_default_draw_expander (GtkStyle *style,
4029 GtkStateType state_type,
4032 const gchar *detail,
4035 GtkExpanderStyle expander_style)
4043 gtk_widget_style_get (widget,
4044 "expander_size", &expander_size,
4049 gdk_gc_set_clip_rectangle (style->fg_gc[GTK_STATE_NORMAL], area);
4050 gdk_gc_set_clip_rectangle (style->base_gc[GTK_STATE_NORMAL], area);
4055 points[1].x = expander_size / 2;
4056 points[1].y = expander_size / 2;
4058 points[2].y = expander_size;
4060 switch (expander_style)
4062 case GTK_EXPANDER_COLLAPSED:
4065 case GTK_EXPANDER_SEMI_COLLAPSED:
4068 case GTK_EXPANDER_SEMI_EXPANDED:
4071 case GTK_EXPANDER_EXPANDED:
4075 g_assert_not_reached ();
4078 create_expander_affine (affine, degrees, expander_size, x, y);
4080 for (i = 0; i < 3; i++)
4081 apply_affine_on_point (affine, &points[i]);
4083 if (state_type == GTK_STATE_PRELIGHT)
4085 gdk_draw_polygon (window, style->base_gc[GTK_STATE_NORMAL],
4087 gdk_draw_polygon (window, style->fg_gc[GTK_STATE_NORMAL],
4090 else if (state_type == GTK_STATE_ACTIVE)
4092 gdk_draw_polygon (window, style->light_gc[GTK_STATE_ACTIVE],
4094 gdk_draw_polygon (window, style->fg_gc[GTK_STATE_NORMAL],
4099 gdk_draw_polygon (window, style->fg_gc[GTK_STATE_NORMAL],
4104 gdk_gc_set_clip_rectangle (style->fg_gc[GTK_STATE_NORMAL], NULL);
4105 gdk_gc_set_clip_rectangle (style->base_gc[GTK_STATE_NORMAL], NULL);
4109 typedef struct _ByteRange ByteRange;
4118 range_new (guint start,
4121 ByteRange *br = g_new (ByteRange, 1);
4130 get_insensitive_layout (PangoLayout *layout)
4132 GSList *embossed_ranges = NULL;
4133 GSList *stippled_ranges = NULL;
4134 PangoLayoutIter *iter;
4135 GSList *tmp_list = NULL;
4136 PangoLayout *new_layout;
4137 PangoAttrList *attrs;
4138 GdkBitmap *stipple = NULL;
4140 iter = pango_layout_get_iter (layout);
4144 PangoLayoutRun *run;
4145 PangoAttribute *attr;
4146 gboolean need_stipple = FALSE;
4149 run = pango_layout_iter_get_run (iter);
4153 tmp_list = run->item->analysis.extra_attrs;
4155 while (tmp_list != NULL)
4157 attr = tmp_list->data;
4158 switch (attr->klass->type)
4160 case PANGO_ATTR_FOREGROUND:
4161 case PANGO_ATTR_BACKGROUND:
4162 need_stipple = TRUE;
4172 tmp_list = g_slist_next (tmp_list);
4175 br = range_new (run->item->offset, run->item->offset + run->item->length);
4178 stippled_ranges = g_slist_prepend (stippled_ranges, br);
4180 embossed_ranges = g_slist_prepend (embossed_ranges, br);
4183 while (pango_layout_iter_next_run (iter));
4185 pango_layout_iter_free (iter);
4187 new_layout = pango_layout_copy (layout);
4189 attrs = pango_layout_get_attributes (new_layout);
4193 /* Create attr list if there wasn't one */
4194 attrs = pango_attr_list_new ();
4195 pango_layout_set_attributes (new_layout, attrs);
4196 pango_attr_list_unref (attrs);
4199 tmp_list = embossed_ranges;
4200 while (tmp_list != NULL)
4202 PangoAttribute *attr;
4203 ByteRange *br = tmp_list->data;
4205 attr = gdk_pango_attr_embossed_new (TRUE);
4207 attr->start_index = br->start;
4208 attr->end_index = br->end;
4210 pango_attr_list_change (attrs, attr);
4214 tmp_list = g_slist_next (tmp_list);
4217 g_slist_free (embossed_ranges);
4219 tmp_list = stippled_ranges;
4220 while (tmp_list != NULL)
4222 PangoAttribute *attr;
4223 ByteRange *br = tmp_list->data;
4225 if (stipple == NULL)
4227 #define gray50_width 2
4228 #define gray50_height 2
4229 static char gray50_bits[] = {
4233 stipple = gdk_bitmap_create_from_data (NULL,
4234 gray50_bits, gray50_width,
4238 attr = gdk_pango_attr_stipple_new (stipple);
4240 attr->start_index = br->start;
4241 attr->end_index = br->end;
4243 pango_attr_list_change (attrs, attr);
4247 tmp_list = g_slist_next (tmp_list);
4250 g_slist_free (stippled_ranges);
4253 g_object_unref (G_OBJECT (stipple));
4259 gtk_default_draw_layout (GtkStyle *style,
4261 GtkStateType state_type,
4265 const gchar *detail,
4268 PangoLayout *layout)
4272 g_return_if_fail (GTK_IS_STYLE (style));
4273 g_return_if_fail (window != NULL);
4275 gc = use_text ? style->text_gc[state_type] : style->fg_gc[state_type];
4278 gdk_gc_set_clip_rectangle (gc, area);
4280 if (state_type == GTK_STATE_INSENSITIVE)
4284 ins = get_insensitive_layout (layout);
4286 gdk_draw_layout (window, gc, x, y, ins);
4288 g_object_unref (G_OBJECT (ins));
4292 gdk_draw_layout (window, gc, x, y, layout);
4296 gdk_gc_set_clip_rectangle (gc, NULL);
4300 gtk_default_draw_resize_grip (GtkStyle *style,
4302 GtkStateType state_type,
4305 const gchar *detail,
4312 g_return_if_fail (GTK_IS_STYLE (style));
4313 g_return_if_fail (window != NULL);
4317 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
4318 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
4319 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
4322 /* make it square, aligning to bottom right */
4325 y += (height - width);
4328 else if (height < width)
4330 x += (width - height);
4334 /* Clear background */
4335 gdk_draw_rectangle (window,
4336 style->bg_gc[state_type],
4338 x, y, width, height);
4342 case GDK_WINDOW_EDGE_SOUTH_EAST:
4349 while (xi < (x + width - 3))
4351 gdk_draw_line (window,
4352 style->light_gc[state_type],
4359 gdk_draw_line (window,
4360 style->dark_gc[state_type],
4367 gdk_draw_line (window,
4368 style->dark_gc[state_type],
4378 g_assert_not_reached ();
4384 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
4385 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
4386 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
4391 gtk_style_shade (GdkColor *a,
4399 red = (gdouble) a->red / 65535.0;
4400 green = (gdouble) a->green / 65535.0;
4401 blue = (gdouble) a->blue / 65535.0;
4403 rgb_to_hls (&red, &green, &blue);
4408 else if (green < 0.0)
4414 else if (blue < 0.0)
4417 hls_to_rgb (&red, &green, &blue);
4419 b->red = red * 65535.0;
4420 b->green = green * 65535.0;
4421 b->blue = blue * 65535.0;
4425 rgb_to_hls (gdouble *r,
4466 l = (max + min) / 2;
4473 s = (max - min) / (max + min);
4475 s = (max - min) / (2 - max - min);
4479 h = (green - blue) / delta;
4480 else if (green == max)
4481 h = 2 + (blue - red) / delta;
4482 else if (blue == max)
4483 h = 4 + (red - green) / delta;
4496 hls_to_rgb (gdouble *h,
4509 if (lightness <= 0.5)
4510 m2 = lightness * (1 + saturation);
4512 m2 = lightness + saturation - lightness * saturation;
4513 m1 = 2 * lightness - m2;
4515 if (saturation == 0)
4530 r = m1 + (m2 - m1) * hue / 60;
4534 r = m1 + (m2 - m1) * (240 - hue) / 60;
4545 g = m1 + (m2 - m1) * hue / 60;
4549 g = m1 + (m2 - m1) * (240 - hue) / 60;
4560 b = m1 + (m2 - m1) * hue / 60;
4564 b = m1 + (m2 - m1) * (240 - hue) / 60;
4575 gtk_paint_hline (GtkStyle *style,
4577 GtkStateType state_type,
4580 const gchar *detail,
4585 g_return_if_fail (GTK_IS_STYLE (style));
4586 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_hline != NULL);
4588 GTK_STYLE_GET_CLASS (style)->draw_hline (style, window, state_type, area, widget, detail, x1, x2, y);
4592 gtk_paint_vline (GtkStyle *style,
4594 GtkStateType state_type,
4597 const gchar *detail,
4602 g_return_if_fail (GTK_IS_STYLE (style));
4603 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_vline != NULL);
4605 GTK_STYLE_GET_CLASS (style)->draw_vline (style, window, state_type, area, widget, detail, y1, y2, x);
4609 gtk_paint_shadow (GtkStyle *style,
4611 GtkStateType state_type,
4612 GtkShadowType shadow_type,
4615 const gchar *detail,
4621 g_return_if_fail (GTK_IS_STYLE (style));
4622 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow != NULL);
4624 GTK_STYLE_GET_CLASS (style)->draw_shadow (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4628 gtk_paint_polygon (GtkStyle *style,
4630 GtkStateType state_type,
4631 GtkShadowType shadow_type,
4634 const gchar *detail,
4639 g_return_if_fail (GTK_IS_STYLE (style));
4640 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow != NULL);
4642 GTK_STYLE_GET_CLASS (style)->draw_polygon (style, window, state_type, shadow_type, area, widget, detail, points, npoints, fill);
4646 gtk_paint_arrow (GtkStyle *style,
4648 GtkStateType state_type,
4649 GtkShadowType shadow_type,
4652 const gchar *detail,
4653 GtkArrowType arrow_type,
4660 g_return_if_fail (GTK_IS_STYLE (style));
4661 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_arrow != NULL);
4663 GTK_STYLE_GET_CLASS (style)->draw_arrow (style, window, state_type, shadow_type, area, widget, detail, arrow_type, fill, x, y, width, height);
4667 gtk_paint_diamond (GtkStyle *style,
4669 GtkStateType state_type,
4670 GtkShadowType shadow_type,
4673 const gchar *detail,
4679 g_return_if_fail (GTK_IS_STYLE (style));
4680 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_diamond != NULL);
4682 GTK_STYLE_GET_CLASS (style)->draw_diamond (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4686 gtk_paint_string (GtkStyle *style,
4688 GtkStateType state_type,
4691 const gchar *detail,
4694 const gchar *string)
4696 g_return_if_fail (GTK_IS_STYLE (style));
4697 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_string != NULL);
4699 GTK_STYLE_GET_CLASS (style)->draw_string (style, window, state_type, area, widget, detail, x, y, string);
4703 gtk_paint_box (GtkStyle *style,
4705 GtkStateType state_type,
4706 GtkShadowType shadow_type,
4709 const gchar *detail,
4715 g_return_if_fail (GTK_IS_STYLE (style));
4716 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box != NULL);
4718 GTK_STYLE_GET_CLASS (style)->draw_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4722 gtk_paint_flat_box (GtkStyle *style,
4724 GtkStateType state_type,
4725 GtkShadowType shadow_type,
4728 const gchar *detail,
4734 g_return_if_fail (GTK_IS_STYLE (style));
4735 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_flat_box != NULL);
4737 GTK_STYLE_GET_CLASS (style)->draw_flat_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4741 gtk_paint_check (GtkStyle *style,
4743 GtkStateType state_type,
4744 GtkShadowType shadow_type,
4747 const gchar *detail,
4753 g_return_if_fail (GTK_IS_STYLE (style));
4754 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_check != NULL);
4756 GTK_STYLE_GET_CLASS (style)->draw_check (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4760 gtk_paint_option (GtkStyle *style,
4762 GtkStateType state_type,
4763 GtkShadowType shadow_type,
4766 const gchar *detail,
4772 g_return_if_fail (GTK_IS_STYLE (style));
4773 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_option != NULL);
4775 GTK_STYLE_GET_CLASS (style)->draw_option (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4779 gtk_paint_tab (GtkStyle *style,
4781 GtkStateType state_type,
4782 GtkShadowType shadow_type,
4785 const gchar *detail,
4791 g_return_if_fail (GTK_IS_STYLE (style));
4792 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_tab != NULL);
4794 GTK_STYLE_GET_CLASS (style)->draw_tab (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4798 gtk_paint_shadow_gap (GtkStyle *style,
4800 GtkStateType state_type,
4801 GtkShadowType shadow_type,
4809 GtkPositionType gap_side,
4813 g_return_if_fail (GTK_IS_STYLE (style));
4814 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow_gap != NULL);
4816 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);
4821 gtk_paint_box_gap (GtkStyle *style,
4823 GtkStateType state_type,
4824 GtkShadowType shadow_type,
4832 GtkPositionType gap_side,
4836 g_return_if_fail (GTK_IS_STYLE (style));
4837 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box_gap != NULL);
4839 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);
4843 gtk_paint_extension (GtkStyle *style,
4845 GtkStateType state_type,
4846 GtkShadowType shadow_type,
4854 GtkPositionType gap_side)
4856 g_return_if_fail (GTK_IS_STYLE (style));
4857 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_extension != NULL);
4859 GTK_STYLE_GET_CLASS (style)->draw_extension (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side);
4863 gtk_paint_focus (GtkStyle *style,
4867 const gchar *detail,
4873 g_return_if_fail (GTK_IS_STYLE (style));
4874 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_focus != NULL);
4876 GTK_STYLE_GET_CLASS (style)->draw_focus (style, window, area, widget, detail, x, y, width, height);
4880 gtk_paint_slider (GtkStyle *style,
4882 GtkStateType state_type,
4883 GtkShadowType shadow_type,
4886 const gchar *detail,
4891 GtkOrientation orientation)
4893 g_return_if_fail (GTK_IS_STYLE (style));
4894 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_slider != NULL);
4896 GTK_STYLE_GET_CLASS (style)->draw_slider (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
4900 gtk_paint_handle (GtkStyle *style,
4902 GtkStateType state_type,
4903 GtkShadowType shadow_type,
4906 const gchar *detail,
4911 GtkOrientation orientation)
4913 g_return_if_fail (GTK_IS_STYLE (style));
4914 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_handle != NULL);
4916 GTK_STYLE_GET_CLASS (style)->draw_handle (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
4920 gtk_paint_expander (GtkStyle *style,
4922 GtkStateType state_type,
4925 const gchar *detail,
4928 GtkExpanderStyle expander_style)
4930 g_return_if_fail (GTK_IS_STYLE (style));
4931 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_expander != NULL);
4933 GTK_STYLE_GET_CLASS (style)->draw_expander (style, window, state_type, area,
4934 widget, detail, x, y, expander_style);
4938 gtk_paint_layout (GtkStyle *style,
4940 GtkStateType state_type,
4944 const gchar *detail,
4947 PangoLayout *layout)
4949 g_return_if_fail (GTK_IS_STYLE (style));
4950 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_layout != NULL);
4952 GTK_STYLE_GET_CLASS (style)->draw_layout (style, window, state_type, use_text, area,
4953 widget, detail, x, y, layout);
4957 gtk_paint_resize_grip (GtkStyle *style,
4959 GtkStateType state_type,
4962 const gchar *detail,
4970 g_return_if_fail (GTK_IS_STYLE (style));
4971 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_resize_grip != NULL);
4973 GTK_STYLE_GET_CLASS (style)->draw_resize_grip (style, window, state_type,
4974 area, widget, detail,
4975 edge, x, y, width, height);
4979 gtk_border_copy (const GtkBorder *border)
4981 return (GtkBorder *)g_memdup (border, sizeof (GtkBorder));
4985 gtk_border_free (GtkBorder *border)