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 /* need value cache array */
1304 if (!style->property_cache)
1305 style->property_cache = g_array_new (FALSE, FALSE, sizeof (PropertyValue));
1308 key.widget_type = widget_type;
1310 pcache = bsearch (&key,
1311 style->property_cache->data, style->property_cache->len,
1312 sizeof (PropertyValue), style_property_values_cmp);
1314 return &pcache->value;
1318 while (i < style->property_cache->len &&
1319 style_property_values_cmp (&key, &g_array_index (style->property_cache, PropertyValue, i)) >= 0)
1322 g_array_insert_val (style->property_cache, i, key);
1323 pcache = &g_array_index (style->property_cache, PropertyValue, i);
1325 /* cache miss, initialize value type, then set contents */
1326 g_param_spec_ref (pcache->pspec);
1327 g_value_init (&pcache->value, G_PARAM_SPEC_VALUE_TYPE (pspec));
1329 /* value provided by rc style? */
1330 if (style->rc_style)
1332 GQuark prop_quark = g_quark_from_string (pspec->name);
1336 rcprop = _gtk_rc_style_lookup_rc_property (style->rc_style,
1337 g_type_qname (widget_type),
1341 widget_type = g_type_parent (widget_type);
1343 while (g_type_is_a (widget_type, pspec->owner_type));
1346 /* when supplied by rc style, we need to convert */
1347 if (rcprop && !_gtk_settings_parse_convert (parser, &rcprop->value,
1348 pspec, &pcache->value))
1350 gchar *contents = g_strdup_value_contents (&rcprop->value);
1352 g_message ("%s: failed to retrive property `%s::%s' of type `%s' from rc file value \"%s\" of type `%s'",
1354 g_type_name (pspec->owner_type), pspec->name,
1355 g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
1357 G_VALUE_TYPE_NAME (&rcprop->value));
1359 rcprop = NULL; /* needs default */
1362 /* not supplied by rc style (or conversion failed), revert to default */
1364 g_param_value_set_default (pspec, &pcache->value);
1366 return &pcache->value;
1370 load_bg_image (GdkColormap *colormap,
1372 const gchar *filename)
1374 if (strcmp (filename, "<parent>") == 0)
1375 return (GdkPixmap*) GDK_PARENT_RELATIVE;
1378 return gdk_pixmap_colormap_create_from_xpm (NULL, colormap, NULL,
1385 gtk_style_real_realize (GtkStyle *style)
1387 GdkGCValues gc_values;
1388 GdkGCValuesMask gc_values_mask;
1392 for (i = 0; i < 5; i++)
1394 gtk_style_shade (&style->bg[i], &style->light[i], LIGHTNESS_MULT);
1395 gtk_style_shade (&style->bg[i], &style->dark[i], DARKNESS_MULT);
1397 style->mid[i].red = (style->light[i].red + style->dark[i].red) / 2;
1398 style->mid[i].green = (style->light[i].green + style->dark[i].green) / 2;
1399 style->mid[i].blue = (style->light[i].blue + style->dark[i].blue) / 2;
1401 style->text_aa[i].red = (style->text[i].red + style->base[i].red) / 2;
1402 style->text_aa[i].green = (style->text[i].green + style->base[i].green) / 2;
1403 style->text_aa[i].blue = (style->text[i].blue + style->base[i].blue) / 2;
1406 gdk_color_black (style->colormap, &style->black);
1407 gdk_color_white (style->colormap, &style->white);
1409 gc_values_mask = GDK_GC_FOREGROUND | GDK_GC_FONT;
1410 if (style->font->type == GDK_FONT_FONT)
1412 gc_values.font = style->font;
1414 else if (style->font->type == GDK_FONT_FONTSET)
1416 gc_values.font = static_default_font;
1419 gc_values.foreground = style->black;
1420 style->black_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1422 gc_values.foreground = style->white;
1423 style->white_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1425 for (i = 0; i < 5; i++)
1427 if (style->rc_style && style->rc_style->bg_pixmap_name[i])
1428 style->bg_pixmap[i] = load_bg_image (style->colormap,
1430 style->rc_style->bg_pixmap_name[i]);
1432 if (!gdk_color_alloc (style->colormap, &style->fg[i]))
1433 g_warning ("unable to allocate color: ( %d %d %d )",
1434 style->fg[i].red, style->fg[i].green, style->fg[i].blue);
1435 if (!gdk_color_alloc (style->colormap, &style->bg[i]))
1436 g_warning ("unable to allocate color: ( %d %d %d )",
1437 style->bg[i].red, style->bg[i].green, style->bg[i].blue);
1438 if (!gdk_color_alloc (style->colormap, &style->light[i]))
1439 g_warning ("unable to allocate color: ( %d %d %d )",
1440 style->light[i].red, style->light[i].green, style->light[i].blue);
1441 if (!gdk_color_alloc (style->colormap, &style->dark[i]))
1442 g_warning ("unable to allocate color: ( %d %d %d )",
1443 style->dark[i].red, style->dark[i].green, style->dark[i].blue);
1444 if (!gdk_color_alloc (style->colormap, &style->mid[i]))
1445 g_warning ("unable to allocate color: ( %d %d %d )",
1446 style->mid[i].red, style->mid[i].green, style->mid[i].blue);
1447 if (!gdk_color_alloc (style->colormap, &style->text[i]))
1448 g_warning ("unable to allocate color: ( %d %d %d )",
1449 style->text[i].red, style->text[i].green, style->text[i].blue);
1450 if (!gdk_color_alloc (style->colormap, &style->base[i]))
1451 g_warning ("unable to allocate color: ( %d %d %d )",
1452 style->base[i].red, style->base[i].green, style->base[i].blue);
1453 if (!gdk_color_alloc (style->colormap, &style->text_aa[i]))
1454 g_warning ("unable to allocate color: ( %d %d %d )",
1455 style->text_aa[i].red, style->text_aa[i].green, style->text_aa[i].blue);
1457 gc_values.foreground = style->fg[i];
1458 style->fg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1460 gc_values.foreground = style->bg[i];
1461 style->bg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1463 gc_values.foreground = style->light[i];
1464 style->light_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1466 gc_values.foreground = style->dark[i];
1467 style->dark_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1469 gc_values.foreground = style->mid[i];
1470 style->mid_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1472 gc_values.foreground = style->text[i];
1473 style->text_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1475 gc_values.foreground = style->base[i];
1476 style->base_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1478 gc_values.foreground = style->text_aa[i];
1479 style->text_aa_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask);
1484 gtk_style_real_unrealize (GtkStyle *style)
1488 gtk_gc_release (style->black_gc);
1489 gtk_gc_release (style->white_gc);
1491 for (i = 0; i < 5; i++)
1493 gtk_gc_release (style->fg_gc[i]);
1494 gtk_gc_release (style->bg_gc[i]);
1495 gtk_gc_release (style->light_gc[i]);
1496 gtk_gc_release (style->dark_gc[i]);
1497 gtk_gc_release (style->mid_gc[i]);
1498 gtk_gc_release (style->text_gc[i]);
1499 gtk_gc_release (style->base_gc[i]);
1500 gtk_gc_release (style->text_aa_gc[i]);
1502 if (style->bg_pixmap[i] && style->bg_pixmap[i] != (GdkPixmap*) GDK_PARENT_RELATIVE)
1503 gdk_pixmap_unref (style->bg_pixmap[i]);
1506 gdk_colormap_free_colors (style->colormap, style->fg, 5);
1507 gdk_colormap_free_colors (style->colormap, style->bg, 5);
1508 gdk_colormap_free_colors (style->colormap, style->light, 5);
1509 gdk_colormap_free_colors (style->colormap, style->dark, 5);
1510 gdk_colormap_free_colors (style->colormap, style->mid, 5);
1511 gdk_colormap_free_colors (style->colormap, style->text, 5);
1512 gdk_colormap_free_colors (style->colormap, style->base, 5);
1513 gdk_colormap_free_colors (style->colormap, style->text_aa, 5);
1517 gtk_style_real_set_background (GtkStyle *style,
1519 GtkStateType state_type)
1522 gint parent_relative;
1524 if (style->bg_pixmap[state_type])
1526 if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
1529 parent_relative = TRUE;
1533 pixmap = style->bg_pixmap[state_type];
1534 parent_relative = FALSE;
1537 gdk_window_set_back_pixmap (window, pixmap, parent_relative);
1540 gdk_window_set_background (window, &style->bg[state_type]);
1544 gtk_style_render_icon (GtkStyle *style,
1545 const GtkIconSource *source,
1546 GtkTextDirection direction,
1550 const gchar *detail)
1554 g_return_val_if_fail (GTK_IS_STYLE (style), NULL);
1555 g_return_val_if_fail (GTK_STYLE_GET_CLASS (style)->render_icon != NULL, NULL);
1557 pixbuf = GTK_STYLE_GET_CLASS (style)->render_icon (style, source, direction, state,
1558 size, widget, detail);
1560 g_return_val_if_fail (pixbuf != NULL, NULL);
1565 /* Default functions */
1567 gtk_style_apply_default_background (GtkStyle *style,
1570 GtkStateType state_type,
1577 GdkRectangle new_rect, old_rect;
1583 old_rect.width = width;
1584 old_rect.height = height;
1586 if (!gdk_rectangle_intersect (area, &old_rect, &new_rect))
1593 new_rect.width = width;
1594 new_rect.height = height;
1597 if (!style->bg_pixmap[state_type] ||
1598 GDK_IS_PIXMAP (window) ||
1599 (!set_bg && style->bg_pixmap[state_type] != (GdkPixmap*) GDK_PARENT_RELATIVE))
1601 GdkGC *gc = style->bg_gc[state_type];
1603 if (style->bg_pixmap[state_type])
1605 gdk_gc_set_fill (gc, GDK_TILED);
1606 gdk_gc_set_tile (gc, style->bg_pixmap[state_type]);
1609 gdk_draw_rectangle (window, gc, TRUE,
1610 new_rect.x, new_rect.y, new_rect.width, new_rect.height);
1611 if (style->bg_pixmap[state_type])
1612 gdk_gc_set_fill (gc, GDK_SOLID);
1618 if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE)
1619 gdk_window_set_back_pixmap (window, NULL, TRUE);
1621 gdk_window_set_back_pixmap (window, style->bg_pixmap[state_type], FALSE);
1624 gdk_window_clear_area (window,
1625 new_rect.x, new_rect.y,
1626 new_rect.width, new_rect.height);
1631 scale_or_ref (GdkPixbuf *src,
1635 if (width == gdk_pixbuf_get_width (src) &&
1636 height == gdk_pixbuf_get_height (src))
1638 gdk_pixbuf_ref (src);
1643 return gdk_pixbuf_scale_simple (src,
1645 GDK_INTERP_BILINEAR);
1650 gtk_default_render_icon (GtkStyle *style,
1651 const GtkIconSource *source,
1652 GtkTextDirection direction,
1656 const gchar *detail)
1662 GdkPixbuf *base_pixbuf;
1664 /* Oddly, style can be NULL in this function, because
1665 * GtkIconSet can be used without a style and if so
1666 * it uses this function.
1669 base_pixbuf = gtk_icon_source_get_pixbuf (source);
1671 g_return_val_if_fail (base_pixbuf != NULL, NULL);
1673 if (!gtk_icon_size_lookup (size, &width, &height))
1675 g_warning (G_STRLOC ": invalid icon size `%d'", size);
1679 /* If the size was wildcarded, then scale; otherwise, leave it
1682 if (gtk_icon_source_get_size_wildcarded (source))
1683 scaled = scale_or_ref (base_pixbuf, width, height);
1685 scaled = GDK_PIXBUF (g_object_ref (G_OBJECT (base_pixbuf)));
1687 /* If the state was wildcarded, then generate a state. */
1688 if (gtk_icon_source_get_state_wildcarded (source))
1690 if (state == GTK_STATE_INSENSITIVE)
1692 stated = gdk_pixbuf_copy (scaled);
1694 gdk_pixbuf_saturate_and_pixelate (scaled, stated,
1697 gdk_pixbuf_unref (scaled);
1699 else if (state == GTK_STATE_PRELIGHT)
1701 stated = gdk_pixbuf_copy (scaled);
1703 gdk_pixbuf_saturate_and_pixelate (scaled, stated,
1706 gdk_pixbuf_unref (scaled);
1720 sanitize_size (GdkWindow *window,
1724 gboolean set_bg = FALSE;
1726 if ((*width == -1) && (*height == -1))
1728 set_bg = GDK_IS_WINDOW (window);
1729 gdk_window_get_size (window, width, height);
1731 else if (*width == -1)
1732 gdk_window_get_size (window, width, NULL);
1733 else if (*height == -1)
1734 gdk_window_get_size (window, NULL, height);
1740 draw_part (GdkDrawable *drawable,
1748 gdk_gc_set_clip_rectangle (gc, area);
1750 if (!indicator_parts[part].bmap)
1751 indicator_parts[part].bmap = gdk_bitmap_create_from_data (drawable,
1752 indicator_parts[part].bits,
1753 INDICATOR_PART_SIZE, INDICATOR_PART_SIZE);
1755 gdk_gc_set_ts_origin (gc, x, y);
1756 gdk_gc_set_stipple (gc, indicator_parts[part].bmap);
1757 gdk_gc_set_fill (gc, GDK_STIPPLED);
1759 gdk_draw_rectangle (drawable, gc, TRUE, x, y, INDICATOR_PART_SIZE, INDICATOR_PART_SIZE);
1761 gdk_gc_set_fill (gc, GDK_SOLID);
1764 gdk_gc_set_clip_rectangle (gc, NULL);
1768 gtk_default_draw_hline (GtkStyle *style,
1770 GtkStateType state_type,
1773 const gchar *detail,
1778 gint thickness_light;
1779 gint thickness_dark;
1782 g_return_if_fail (GTK_IS_STYLE (style));
1783 g_return_if_fail (window != NULL);
1785 thickness_light = style->ythickness / 2;
1786 thickness_dark = style->ythickness - thickness_light;
1790 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1791 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1794 if (detail && !strcmp (detail, "label"))
1796 if (state_type == GTK_STATE_INSENSITIVE)
1797 gdk_draw_line (window, style->white_gc, x1 + 1, y + 1, x2 + 1, y + 1);
1798 gdk_draw_line (window, style->fg_gc[state_type], x1, y, x2, y);
1802 for (i = 0; i < thickness_dark; i++)
1804 gdk_draw_line (window, style->light_gc[state_type], x2 - i - 1, y + i, x2, y + i);
1805 gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x2 - i - 1, y + i);
1808 y += thickness_dark;
1809 for (i = 0; i < thickness_light; i++)
1811 gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x1 + thickness_light - i - 1, y + i);
1812 gdk_draw_line (window, style->light_gc[state_type], x1 + thickness_light - i - 1, y + i, x2, y + i);
1818 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
1819 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
1825 gtk_default_draw_vline (GtkStyle *style,
1827 GtkStateType state_type,
1830 const gchar *detail,
1835 gint thickness_light;
1836 gint thickness_dark;
1839 g_return_if_fail (GTK_IS_STYLE (style));
1840 g_return_if_fail (window != NULL);
1842 thickness_light = style->xthickness / 2;
1843 thickness_dark = style->xthickness - thickness_light;
1847 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
1848 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
1850 for (i = 0; i < thickness_dark; i++)
1852 gdk_draw_line (window, style->light_gc[state_type], x + i, y2 - i - 1, x + i, y2);
1853 gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y2 - i - 1);
1856 x += thickness_dark;
1857 for (i = 0; i < thickness_light; i++)
1859 gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y1 + thickness_light - i);
1860 gdk_draw_line (window, style->light_gc[state_type], x + i, y1 + thickness_light - i, x + i, y2);
1864 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
1865 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
1871 draw_thin_shadow (GtkStyle *style,
1882 sanitize_size (window, &width, &height);
1884 gc1 = style->light_gc[state];
1885 gc2 = style->dark_gc[state];
1889 gdk_gc_set_clip_rectangle (gc1, area);
1890 gdk_gc_set_clip_rectangle (gc2, area);
1893 gdk_draw_line (window, gc1,
1894 x, y + height - 1, x + width - 1, y + height - 1);
1895 gdk_draw_line (window, gc1,
1896 x + width - 1, y, x + width - 1, y + height - 1);
1898 gdk_draw_line (window, gc2,
1899 x, y, x + width - 1, y);
1900 gdk_draw_line (window, gc2,
1901 x, y, x, y + height - 1);
1905 gdk_gc_set_clip_rectangle (gc1, NULL);
1906 gdk_gc_set_clip_rectangle (gc2, NULL);
1911 draw_spin_entry_shadow (GtkStyle *style,
1920 gint window_width, window_height;
1921 gboolean focus_inset;
1923 gdk_window_get_size (window, &window_width, &window_height);
1926 width = window_width;
1928 height = window_height;
1930 focus_inset = (width < window_width && height < window_height);
1934 gdk_gc_set_clip_rectangle (style->light_gc[state], area);
1935 gdk_gc_set_clip_rectangle (style->dark_gc[state], area);
1936 gdk_gc_set_clip_rectangle (style->black_gc, area);
1937 gdk_gc_set_clip_rectangle (style->bg_gc[state], area);
1938 gdk_gc_set_clip_rectangle (style->base_gc[state], area);
1941 gdk_draw_line (window, style->light_gc[state],
1942 x, y + height - 1, x + width - 1, y + height - 1);
1944 gdk_draw_line (window,
1945 style->base_gc[state],
1946 x + width - 1, y + 1, x + width - 1, y + height - 3);
1950 gdk_draw_line (window, style->bg_gc[state],
1951 x + 1, y + height - 2, x + width - 1, y + height - 2);
1952 gdk_draw_line (window,
1953 style->base_gc[state],
1954 x + width - 2, y + 1, x + width - 2, y + height - 3);
1956 gdk_draw_line (window, style->black_gc,
1957 x + 1, y + 1, x + width - 1, y + 1);
1958 gdk_draw_line (window, style->black_gc,
1959 x + 1, y + 1, x + 1, y + height - 2);
1962 gdk_draw_line (window, style->dark_gc[state],
1963 x, y, x + width - 1, y);
1964 gdk_draw_line (window, style->dark_gc[state],
1965 x, y, x, y + height - 1);
1969 gdk_gc_set_clip_rectangle (style->light_gc[state], NULL);
1970 gdk_gc_set_clip_rectangle (style->dark_gc[state], NULL);
1971 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
1972 gdk_gc_set_clip_rectangle (style->bg_gc[state], NULL);
1973 gdk_gc_set_clip_rectangle (style->base_gc[state], NULL);
1978 draw_spinbutton_shadow (GtkStyle *style,
1987 gint y_middle = y + height / 2;
1989 sanitize_size (window, &width, &height);
1993 gdk_gc_set_clip_rectangle (style->black_gc, area);
1994 gdk_gc_set_clip_rectangle (style->bg_gc[state], area);
1995 gdk_gc_set_clip_rectangle (style->dark_gc[state], area);
1996 gdk_gc_set_clip_rectangle (style->light_gc[state], area);
1999 gdk_draw_line (window, style->black_gc,
2000 x, y + 2, x, y + height - 3);
2001 gdk_draw_line (window, style->black_gc,
2002 x, y + 1, x + width - 2, y + 1);
2003 gdk_draw_line (window, style->black_gc,
2004 x + width - 2, y + 2, x + width - 2, y + height - 3);
2006 gdk_draw_line (window, style->bg_gc[state],
2007 x, y + height - 2, x + width - 2, y + height - 2);
2009 gdk_draw_line (window, style->dark_gc[state],
2010 x, y, x + width - 1, y);
2011 gdk_draw_line (window, style->dark_gc[state],
2012 x + 1, y_middle - 1, x + width - 3, y_middle - 1);
2013 gdk_draw_line (window, style->dark_gc[state],
2014 x + 1, y + height - 3, x + width - 3, y + height - 3);
2016 gdk_draw_line (window, style->light_gc[state],
2017 x + 1, y + 2, x + width - 3, y + 2);
2018 gdk_draw_line (window, style->light_gc[state],
2019 x + 1, y_middle, x + width - 3, y_middle);
2020 gdk_draw_line (window, style->light_gc[state],
2021 x + width - 1, y + 1, x + width - 1, y + height - 1);
2022 gdk_draw_line (window, style->light_gc[state],
2023 x, y + height - 1, x + width - 2, y + height - 1);
2027 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2028 gdk_gc_set_clip_rectangle (style->bg_gc[state], NULL);
2029 gdk_gc_set_clip_rectangle (style->dark_gc[state], NULL);
2030 gdk_gc_set_clip_rectangle (style->light_gc[state], NULL);
2035 gtk_default_draw_shadow (GtkStyle *style,
2037 GtkStateType state_type,
2038 GtkShadowType shadow_type,
2041 const gchar *detail,
2049 gint thickness_light;
2050 gint thickness_dark;
2053 g_return_if_fail (GTK_IS_STYLE (style));
2054 g_return_if_fail (window != NULL);
2056 if (shadow_type == GTK_SHADOW_IN)
2058 if (detail && (strcmp (detail, "buttondefault") == 0))
2060 sanitize_size (window, &width, &height);
2062 gdk_draw_rectangle (window, style->black_gc, FALSE,
2063 x, y, width - 1, height - 1);
2067 if (detail && strcmp (detail, "trough") == 0)
2069 draw_thin_shadow (style, window, state_type, area,
2070 x, y, width, height);
2073 else if (widget && GTK_IS_SPIN_BUTTON (widget) &&
2074 detail && strcmp (detail, "entry") == 0)
2076 draw_spin_entry_shadow (style, window, state_type, area,
2077 x, y, width, height);
2080 else if (widget && GTK_IS_SPIN_BUTTON (widget) &&
2081 detail && strcmp (detail, "spinbutton") == 0)
2083 draw_spinbutton_shadow (style, window, state_type,
2084 area, x, y, width, height);
2089 sanitize_size (window, &width, &height);
2091 switch (shadow_type)
2093 case GTK_SHADOW_NONE:
2096 case GTK_SHADOW_ETCHED_IN:
2097 gc1 = style->light_gc[state_type];
2098 gc2 = style->dark_gc[state_type];
2100 case GTK_SHADOW_OUT:
2101 case GTK_SHADOW_ETCHED_OUT:
2102 gc1 = style->dark_gc[state_type];
2103 gc2 = style->light_gc[state_type];
2109 gdk_gc_set_clip_rectangle (gc1, area);
2110 gdk_gc_set_clip_rectangle (gc2, area);
2111 if (shadow_type == GTK_SHADOW_IN ||
2112 shadow_type == GTK_SHADOW_OUT)
2114 gdk_gc_set_clip_rectangle (style->black_gc, area);
2115 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
2119 switch (shadow_type)
2121 case GTK_SHADOW_NONE:
2125 /* Light around right and bottom edge */
2127 if (style->ythickness > 0)
2128 gdk_draw_line (window, gc1,
2129 x, y + height - 1, x + width - 1, y + height - 1);
2130 if (style->xthickness > 0)
2131 gdk_draw_line (window, gc1,
2132 x + width - 1, y, x + width - 1, y + height - 1);
2134 if (style->ythickness > 1)
2135 gdk_draw_line (window, style->bg_gc[state_type],
2136 x + 1, y + height - 2, x + width - 2, y + height - 2);
2137 if (style->xthickness > 1)
2138 gdk_draw_line (window, style->bg_gc[state_type],
2139 x + width - 2, y + 1, x + width - 2, y + height - 2);
2141 /* Dark around left and top */
2143 if (style->ythickness > 1)
2144 gdk_draw_line (window, style->black_gc,
2145 x + 1, y + 1, x + width - 2, y + 1);
2146 if (style->xthickness > 1)
2147 gdk_draw_line (window, style->black_gc,
2148 x + 1, y + 1, x + 1, y + height - 2);
2150 if (style->ythickness > 0)
2151 gdk_draw_line (window, gc2,
2152 x, y, x + width - 1, y);
2153 if (style->xthickness > 0)
2154 gdk_draw_line (window, gc2,
2155 x, y, x, y + height - 1);
2158 case GTK_SHADOW_OUT:
2159 /* Dark around right and bottom edge */
2161 if (style->ythickness > 0)
2163 if (style->ythickness > 1)
2165 gdk_draw_line (window, gc1,
2166 x + 1, y + height - 2, x + width - 2, y + height - 2);
2167 gdk_draw_line (window, style->black_gc,
2168 x, y + height - 1, x + width - 1, y + height - 1);
2172 gdk_draw_line (window, gc1,
2173 x + 1, y + height - 1, x + width - 1, y + height - 1);
2177 if (style->xthickness > 0)
2179 if (style->xthickness > 1)
2181 gdk_draw_line (window, gc1,
2182 x + width - 2, y + 1, x + width - 2, y + height - 2);
2184 gdk_draw_line (window, style->black_gc,
2185 x + width - 1, y, x + width - 1, y + height - 1);
2189 gdk_draw_line (window, gc1,
2190 x + width - 1, y + 1, x + width - 1, y + height - 1);
2194 /* Light around top and left */
2196 if (style->ythickness > 0)
2197 gdk_draw_line (window, gc2,
2198 x, y, x + width - 1, y);
2199 if (style->xthickness > 0)
2200 gdk_draw_line (window, gc2,
2201 x, y, x, y + height - 1);
2203 if (style->ythickness > 1)
2204 gdk_draw_line (window, style->bg_gc[state_type],
2205 x + 1, y + 1, x + width - 2, y + 1);
2206 if (style->xthickness > 1)
2207 gdk_draw_line (window, style->bg_gc[state_type],
2208 x + 1, y + 1, x + 1, y + height - 2);
2211 case GTK_SHADOW_ETCHED_IN:
2212 case GTK_SHADOW_ETCHED_OUT:
2213 if (style->xthickness > 0)
2215 if (style->xthickness > 1)
2217 thickness_light = 1;
2220 for (i = 0; i < thickness_dark; i++)
2222 gdk_draw_line (window, gc1,
2226 y + height - i - 1);
2227 gdk_draw_line (window, gc2,
2231 y + height - i - 2);
2234 for (i = 0; i < thickness_light; i++)
2236 gdk_draw_line (window, gc1,
2237 x + thickness_dark + i,
2238 y + thickness_dark + i,
2239 x + thickness_dark + i,
2240 y + height - thickness_dark - i - 1);
2241 gdk_draw_line (window, gc2,
2242 x + width - thickness_light - i - 1,
2243 y + thickness_dark + i,
2244 x + width - thickness_light - i - 1,
2245 y + height - thickness_light - 1);
2250 gdk_draw_line (window,
2251 style->dark_gc[state_type],
2252 x, y, x, y + height);
2253 gdk_draw_line (window,
2254 style->dark_gc[state_type],
2255 x + width, y, x + width, y + height);
2259 if (style->ythickness > 0)
2261 if (style->ythickness > 1)
2263 thickness_light = 1;
2266 for (i = 0; i < thickness_dark; i++)
2268 gdk_draw_line (window, gc1,
2272 y + height - i - 1);
2274 gdk_draw_line (window, gc2,
2281 for (i = 0; i < thickness_light; i++)
2283 gdk_draw_line (window, gc1,
2284 x + thickness_dark + i,
2285 y + thickness_dark + i,
2286 x + width - thickness_dark - i - 1,
2287 y + thickness_dark + i);
2289 gdk_draw_line (window, gc2,
2290 x + thickness_dark + i,
2291 y + height - thickness_light - i - 1,
2292 x + width - thickness_light - 1,
2293 y + height - thickness_light - i - 1);
2298 gdk_draw_line (window,
2299 style->dark_gc[state_type],
2300 x, y, x + width, y);
2301 gdk_draw_line (window,
2302 style->dark_gc[state_type],
2303 x, y + height, x + width, y + height);
2311 gdk_gc_set_clip_rectangle (gc1, NULL);
2312 gdk_gc_set_clip_rectangle (gc2, NULL);
2313 if (shadow_type == GTK_SHADOW_IN ||
2314 shadow_type == GTK_SHADOW_OUT)
2316 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2317 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2323 gtk_default_draw_polygon (GtkStyle *style,
2325 GtkStateType state_type,
2326 GtkShadowType shadow_type,
2329 const gchar *detail,
2334 static const gdouble pi_over_4 = G_PI_4;
2335 static const gdouble pi_3_over_4 = G_PI_4 * 3;
2345 g_return_if_fail (GTK_IS_STYLE (style));
2346 g_return_if_fail (window != NULL);
2347 g_return_if_fail (points != NULL);
2349 switch (shadow_type)
2352 gc1 = style->bg_gc[state_type];
2353 gc2 = style->dark_gc[state_type];
2354 gc3 = style->light_gc[state_type];
2355 gc4 = style->black_gc;
2357 case GTK_SHADOW_ETCHED_IN:
2358 gc1 = style->light_gc[state_type];
2359 gc2 = style->dark_gc[state_type];
2360 gc3 = style->dark_gc[state_type];
2361 gc4 = style->light_gc[state_type];
2363 case GTK_SHADOW_OUT:
2364 gc1 = style->dark_gc[state_type];
2365 gc2 = style->light_gc[state_type];
2366 gc3 = style->black_gc;
2367 gc4 = style->bg_gc[state_type];
2369 case GTK_SHADOW_ETCHED_OUT:
2370 gc1 = style->dark_gc[state_type];
2371 gc2 = style->light_gc[state_type];
2372 gc3 = style->light_gc[state_type];
2373 gc4 = style->dark_gc[state_type];
2381 gdk_gc_set_clip_rectangle (gc1, area);
2382 gdk_gc_set_clip_rectangle (gc2, area);
2383 gdk_gc_set_clip_rectangle (gc3, area);
2384 gdk_gc_set_clip_rectangle (gc4, area);
2388 gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, npoints);
2392 for (i = 0; i < npoints; i++)
2394 if ((points[i].x == points[i+1].x) &&
2395 (points[i].y == points[i+1].y))
2401 angle = atan2 (points[i+1].y - points[i].y,
2402 points[i+1].x - points[i].x);
2405 if ((angle > -pi_3_over_4) && (angle < pi_over_4))
2407 if (angle > -pi_over_4)
2418 gdk_draw_line (window, gc1,
2419 points[i].x-xadjust, points[i].y-yadjust,
2420 points[i+1].x-xadjust, points[i+1].y-yadjust);
2421 gdk_draw_line (window, gc3,
2422 points[i].x, points[i].y,
2423 points[i+1].x, points[i+1].y);
2427 if ((angle < -pi_3_over_4) || (angle > pi_3_over_4))
2438 gdk_draw_line (window, gc4,
2439 points[i].x+xadjust, points[i].y+yadjust,
2440 points[i+1].x+xadjust, points[i+1].y+yadjust);
2441 gdk_draw_line (window, gc2,
2442 points[i].x, points[i].y,
2443 points[i+1].x, points[i+1].y);
2449 gdk_gc_set_clip_rectangle (gc1, NULL);
2450 gdk_gc_set_clip_rectangle (gc2, NULL);
2451 gdk_gc_set_clip_rectangle (gc3, NULL);
2452 gdk_gc_set_clip_rectangle (gc4, NULL);
2457 draw_varrow (GdkWindow *window,
2459 GtkShadowType shadow_type,
2461 GtkArrowType arrow_type,
2468 gint y_start, y_increment;
2472 gdk_gc_set_clip_rectangle (gc, area);
2474 width = width + width % 2 - 1; /* Force odd */
2476 steps = 1 + width / 2;
2478 extra = height - steps;
2480 if (arrow_type == GTK_ARROW_DOWN)
2487 y_start = y + height - 1;
2491 for (i = 0; i < extra; i++)
2493 gdk_draw_line (window, gc,
2494 x, y_start + i * y_increment,
2495 x + width - 1, y_start + i * y_increment);
2497 for (; i < height; i++)
2499 gdk_draw_line (window, gc,
2500 x + (i - extra), y_start + i * y_increment,
2501 x + width - (i - extra) - 1, y_start + i * y_increment);
2506 gdk_gc_set_clip_rectangle (gc, NULL);
2510 draw_harrow (GdkWindow *window,
2512 GtkShadowType shadow_type,
2514 GtkArrowType arrow_type,
2521 gint x_start, x_increment;
2525 gdk_gc_set_clip_rectangle (gc, area);
2527 height = height + height % 2 - 1; /* Force odd */
2529 steps = 1 + height / 2;
2531 extra = width - steps;
2533 if (arrow_type == GTK_ARROW_RIGHT)
2540 x_start = x + width - 1;
2544 for (i = 0; i < extra; i++)
2546 gdk_draw_line (window, gc,
2547 x_start + i * x_increment, y,
2548 x_start + i * x_increment, y + height - 1);
2550 for (; i < width; i++)
2552 gdk_draw_line (window, gc,
2553 x_start + i * x_increment, y + (i - extra),
2554 x_start + i * x_increment, y + height - (i - extra) - 1);
2559 gdk_gc_set_clip_rectangle (gc, NULL);
2563 gtk_default_draw_arrow (GtkStyle *style,
2566 GtkShadowType shadow,
2569 const gchar *detail,
2570 GtkArrowType arrow_type,
2577 sanitize_size (window, &width, &height);
2579 if (detail && strcmp (detail, "spinbutton") == 0)
2581 x += (width - 7) / 2;
2583 if (arrow_type == GTK_ARROW_UP)
2584 y += (height - 4) / 2;
2586 y += (1 + height - 4) / 2;
2588 draw_varrow (window, style->fg_gc[state], shadow, area, arrow_type,
2591 else if (detail && strcmp (detail, "vscrollbar") == 0)
2593 gtk_paint_box (style, window, state, shadow, area,
2594 widget, detail, x, y, width, height);
2596 x += (width - 7) / 2;
2597 y += (height - 5) / 2;
2599 draw_varrow (window, style->fg_gc[state], shadow, area, arrow_type,
2603 else if (detail && strcmp (detail, "hscrollbar") == 0)
2605 gtk_paint_box (style, window, state, shadow, area,
2606 widget, detail, x, y, width, height);
2608 y += (height - 7) / 2;
2609 x += (width - 5) / 2;
2611 draw_harrow (window, style->fg_gc[state], shadow, area, arrow_type,
2616 if (arrow_type == GTK_ARROW_UP || arrow_type == GTK_ARROW_DOWN)
2618 x += (width - 7) / 2;
2619 y += (height - 5) / 2;
2621 draw_varrow (window, style->fg_gc[state], shadow, area, arrow_type,
2626 x += (width - 5) / 2;
2627 y += (height - 7) / 2;
2629 draw_harrow (window, style->fg_gc[state], shadow, area, arrow_type,
2636 gtk_default_draw_diamond (GtkStyle *style,
2638 GtkStateType state_type,
2639 GtkShadowType shadow_type,
2642 const gchar *detail,
2650 GdkGC *outer_nw = NULL;
2651 GdkGC *outer_ne = NULL;
2652 GdkGC *outer_sw = NULL;
2653 GdkGC *outer_se = NULL;
2654 GdkGC *middle_nw = NULL;
2655 GdkGC *middle_ne = NULL;
2656 GdkGC *middle_sw = NULL;
2657 GdkGC *middle_se = NULL;
2658 GdkGC *inner_nw = NULL;
2659 GdkGC *inner_ne = NULL;
2660 GdkGC *inner_sw = NULL;
2661 GdkGC *inner_se = NULL;
2663 g_return_if_fail (GTK_IS_STYLE (style));
2664 g_return_if_fail (window != NULL);
2666 sanitize_size (window, &width, &height);
2668 half_width = width / 2;
2669 half_height = height / 2;
2673 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
2674 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
2675 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
2676 gdk_gc_set_clip_rectangle (style->black_gc, area);
2679 switch (shadow_type)
2682 inner_sw = inner_se = style->bg_gc[state_type];
2683 middle_sw = middle_se = style->light_gc[state_type];
2684 outer_sw = outer_se = style->light_gc[state_type];
2685 inner_nw = inner_ne = style->black_gc;
2686 middle_nw = middle_ne = style->dark_gc[state_type];
2687 outer_nw = outer_ne = style->dark_gc[state_type];
2690 case GTK_SHADOW_OUT:
2691 inner_sw = inner_se = style->dark_gc[state_type];
2692 middle_sw = middle_se = style->dark_gc[state_type];
2693 outer_sw = outer_se = style->black_gc;
2694 inner_nw = inner_ne = style->bg_gc[state_type];
2695 middle_nw = middle_ne = style->light_gc[state_type];
2696 outer_nw = outer_ne = style->light_gc[state_type];
2699 case GTK_SHADOW_ETCHED_IN:
2700 inner_sw = inner_se = style->bg_gc[state_type];
2701 middle_sw = middle_se = style->dark_gc[state_type];
2702 outer_sw = outer_se = style->light_gc[state_type];
2703 inner_nw = inner_ne = style->bg_gc[state_type];
2704 middle_nw = middle_ne = style->light_gc[state_type];
2705 outer_nw = outer_ne = style->dark_gc[state_type];
2708 case GTK_SHADOW_ETCHED_OUT:
2709 inner_sw = inner_se = style->bg_gc[state_type];
2710 middle_sw = middle_se = style->light_gc[state_type];
2711 outer_sw = outer_se = style->dark_gc[state_type];
2712 inner_nw = inner_ne = style->bg_gc[state_type];
2713 middle_nw = middle_ne = style->dark_gc[state_type];
2714 outer_nw = outer_ne = style->light_gc[state_type];
2724 gdk_draw_line (window, inner_sw,
2725 x + 2, y + half_height,
2726 x + half_width, y + height - 2);
2727 gdk_draw_line (window, inner_se,
2728 x + half_width, y + height - 2,
2729 x + width - 2, y + half_height);
2730 gdk_draw_line (window, middle_sw,
2731 x + 1, y + half_height,
2732 x + half_width, y + height - 1);
2733 gdk_draw_line (window, middle_se,
2734 x + half_width, y + height - 1,
2735 x + width - 1, y + half_height);
2736 gdk_draw_line (window, outer_sw,
2738 x + half_width, y + height);
2739 gdk_draw_line (window, outer_se,
2740 x + half_width, y + height,
2741 x + width, y + half_height);
2743 gdk_draw_line (window, inner_nw,
2744 x + 2, y + half_height,
2745 x + half_width, y + 2);
2746 gdk_draw_line (window, inner_ne,
2747 x + half_width, y + 2,
2748 x + width - 2, y + half_height);
2749 gdk_draw_line (window, middle_nw,
2750 x + 1, y + half_height,
2751 x + half_width, y + 1);
2752 gdk_draw_line (window, middle_ne,
2753 x + half_width, y + 1,
2754 x + width - 1, y + half_height);
2755 gdk_draw_line (window, outer_nw,
2758 gdk_draw_line (window, outer_ne,
2760 x + width, y + half_height);
2765 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
2766 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2767 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
2768 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2773 gtk_default_draw_string (GtkStyle *style,
2775 GtkStateType state_type,
2778 const gchar *detail,
2781 const gchar *string)
2783 g_return_if_fail (GTK_IS_STYLE (style));
2784 g_return_if_fail (window != NULL);
2788 gdk_gc_set_clip_rectangle (style->white_gc, area);
2789 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], area);
2792 if (state_type == GTK_STATE_INSENSITIVE)
2793 gdk_draw_string (window, style->font, style->white_gc, x + 1, y + 1, string);
2795 gdk_draw_string (window, style->font, style->fg_gc[state_type], x, y, string);
2799 gdk_gc_set_clip_rectangle (style->white_gc, NULL);
2800 gdk_gc_set_clip_rectangle (style->fg_gc[state_type], NULL);
2805 option_menu_get_props (GtkWidget *widget,
2806 GtkRequisition *indicator_size,
2807 GtkBorder *indicator_spacing)
2809 GtkRequisition *tmp_size = NULL;
2810 GtkBorder *tmp_spacing = NULL;
2813 gtk_widget_style_get (widget,
2814 "indicator_size", &tmp_size,
2815 "indicator_spacing", &tmp_spacing,
2820 *indicator_size = *tmp_size;
2824 *indicator_size = default_option_indicator_size;
2828 *indicator_spacing = *tmp_spacing;
2829 g_free (tmp_spacing);
2832 *indicator_spacing = default_option_indicator_spacing;
2836 gtk_default_draw_box (GtkStyle *style,
2838 GtkStateType state_type,
2839 GtkShadowType shadow_type,
2842 const gchar *detail,
2848 g_return_if_fail (GTK_IS_STYLE (style));
2849 g_return_if_fail (window != NULL);
2851 sanitize_size (window, &width, &height);
2853 if (!style->bg_pixmap[state_type] ||
2854 GDK_IS_PIXMAP (window))
2857 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
2859 gdk_draw_rectangle (window, style->bg_gc[state_type], TRUE,
2860 x, y, width, height);
2862 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
2865 gtk_style_apply_default_background (style, window,
2866 widget && !GTK_WIDGET_NO_WINDOW (widget),
2867 state_type, area, x, y, width, height);
2869 gtk_paint_shadow (style, window, state_type, shadow_type, area, widget, detail,
2870 x, y, width, height);
2872 if (detail && strcmp (detail, "optionmenu") == 0)
2874 GtkRequisition indicator_size;
2875 GtkBorder indicator_spacing;
2877 option_menu_get_props (widget, &indicator_size, &indicator_spacing);
2879 sanitize_size (window, &width, &height);
2881 gtk_paint_vline (style, window, state_type, area, widget,
2883 y + style->ythickness + 1,
2884 y + height - style->ythickness - 3,
2885 x + width - (indicator_size.width + indicator_spacing.left + indicator_spacing.right) - style->xthickness);
2890 get_darkened_gc (GdkWindow *window,
2894 GdkColor src = *color;
2898 gc = gdk_gc_new (window);
2900 while (darken_count)
2902 gtk_style_shade (&src, &shaded, 0.93);
2907 gdk_gc_set_rgb_fg_color (gc, &shaded);
2913 gtk_default_draw_flat_box (GtkStyle *style,
2915 GtkStateType state_type,
2916 GtkShadowType shadow_type,
2919 const gchar *detail,
2926 GdkGC *freeme = NULL;
2928 g_return_if_fail (GTK_IS_STYLE (style));
2929 g_return_if_fail (window != NULL);
2931 sanitize_size (window, &width, &height);
2935 if (state_type == GTK_STATE_SELECTED)
2937 if (!strcmp ("text", detail))
2938 gc1 = style->bg_gc[GTK_STATE_SELECTED];
2939 else if (!strncmp ("cell_even", detail, strlen ("cell_even")) ||
2940 !strncmp ("cell_odd", detail, strlen ("cell_odd")))
2942 /* This has to be really broken; alex made me do it. -jrb */
2943 /* Red rum!!! REd RUM!!! */
2944 if (GTK_WIDGET_HAS_FOCUS (widget))
2945 gc1 = style->bg_gc[state_type];
2947 gc1 = style->bg_gc[GTK_STATE_ACTIVE];
2952 gc1 = style->bg_gc[state_type];
2957 if (!strcmp ("viewportbin", detail))
2958 gc1 = style->bg_gc[GTK_STATE_NORMAL];
2959 else if (!strcmp ("entry_bg", detail))
2960 gc1 = style->base_gc[state_type];
2962 /* For trees: even rows are base color, odd rows are a shade of
2963 * the base color, the sort column is a shade of the original color
2967 /* FIXME when we have style properties, clean this up.
2970 else if (!strcmp ("cell_even", detail) ||
2971 !strcmp ("cell_odd", detail) ||
2972 !strcmp ("cell_even_ruled", detail))
2974 gc1 = style->base_gc[state_type];
2976 else if (!strcmp ("cell_even_sorted", detail) ||
2977 !strcmp ("cell_odd_sorted", detail) ||
2978 !strcmp ("cell_odd_ruled", detail) ||
2979 !strcmp ("cell_even_ruled_sorted", detail))
2981 freeme = get_darkened_gc (window, &style->base[state_type], 1);
2984 else if (!strcmp ("cell_odd_ruled_sorted", detail))
2986 freeme = get_darkened_gc (window, &style->base[state_type], 2);
2990 gc1 = style->bg_gc[state_type];
2994 gc1 = style->bg_gc[state_type];
2996 if (!style->bg_pixmap[state_type] || gc1 != style->bg_gc[state_type] ||
2997 GDK_IS_PIXMAP (window))
3000 gdk_gc_set_clip_rectangle (gc1, area);
3002 gdk_draw_rectangle (window, gc1, TRUE,
3003 x, y, width, height);
3005 if (detail && !strcmp ("tooltip", detail))
3006 gdk_draw_rectangle (window, style->black_gc, FALSE,
3007 x, y, width - 1, height - 1);
3010 gdk_gc_set_clip_rectangle (gc1, NULL);
3013 gtk_style_apply_default_background (style, window,
3014 widget && !GTK_WIDGET_NO_WINDOW (widget),
3015 state_type, area, x, y, width, height);
3019 g_object_unref (G_OBJECT (freeme));
3023 gtk_default_draw_check (GtkStyle *style,
3025 GtkStateType state_type,
3026 GtkShadowType shadow_type,
3029 const gchar *detail,
3035 if (detail && strcmp (detail, "cellcheck") == 0)
3037 gdk_draw_rectangle (window,
3038 widget->style->fg_gc[state_type],
3043 if (shadow_type == GTK_SHADOW_IN)
3045 gdk_draw_line (window,
3046 widget->style->fg_gc[state_type],
3050 gdk_draw_line (window,
3051 widget->style->fg_gc[state_type],
3060 x -= (1 + INDICATOR_PART_SIZE - width) / 2;
3061 y -= (1 + INDICATOR_PART_SIZE - height) / 2;
3063 if (strcmp (detail, "check") == 0) /* Menu item */
3065 if (shadow_type == GTK_SHADOW_IN)
3067 draw_part (window, style->black_gc, area, x, y, CHECK_TEXT);
3068 draw_part (window, style->dark_gc[state_type], area, x, y, CHECK_AA);
3073 draw_part (window, style->black_gc, area, x, y, CHECK_BLACK);
3074 draw_part (window, style->dark_gc[state_type], area, x, y, CHECK_DARK);
3075 draw_part (window, style->mid_gc[state_type], area, x, y, CHECK_MID);
3076 draw_part (window, style->light_gc[state_type], area, x, y, CHECK_LIGHT);
3077 draw_part (window, style->base_gc[state_type], area, x, y, CHECK_BASE);
3079 if (shadow_type == GTK_SHADOW_IN)
3081 draw_part (window, style->text_gc[state_type], area, x, y, CHECK_TEXT);
3082 draw_part (window, style->text_aa_gc[state_type], area, x, y, CHECK_AA);
3090 gtk_default_draw_option (GtkStyle *style,
3092 GtkStateType state_type,
3093 GtkShadowType shadow_type,
3096 const gchar *detail,
3102 if (detail && strcmp (detail, "cellradio") == 0)
3104 gdk_draw_arc (window,
3105 widget->style->fg_gc[state_type],
3112 if (shadow_type == GTK_SHADOW_IN)
3114 gdk_draw_arc (window,
3115 widget->style->fg_gc[state_type],
3126 x -= (1 + INDICATOR_PART_SIZE - width) / 2;
3127 y -= (1 + INDICATOR_PART_SIZE - height) / 2;
3129 if (strcmp (detail, "option") == 0) /* Menu item */
3131 if (shadow_type == GTK_SHADOW_IN)
3132 draw_part (window, style->fg_gc[state_type], area, x, y, RADIO_TEXT);
3136 draw_part (window, style->black_gc, area, x, y, RADIO_BLACK);
3137 draw_part (window, style->dark_gc[state_type], area, x, y, RADIO_DARK);
3138 draw_part (window, style->mid_gc[state_type], area, x, y, RADIO_MID);
3139 draw_part (window, style->light_gc[state_type], area, x, y, RADIO_LIGHT);
3140 draw_part (window, style->base_gc[state_type], area, x, y, RADIO_BASE);
3142 if (shadow_type == GTK_SHADOW_IN)
3143 draw_part (window, style->text_gc[state_type], area, x, y, RADIO_TEXT);
3149 gtk_default_draw_tab (GtkStyle *style,
3151 GtkStateType state_type,
3152 GtkShadowType shadow_type,
3155 const gchar *detail,
3161 GtkRequisition indicator_size;
3162 GtkBorder indicator_spacing;
3164 option_menu_get_props (widget, &indicator_size, &indicator_spacing);
3166 x += (width - indicator_size.width) / 2;
3167 y += (height - indicator_size.height) / 2 - 1;
3169 draw_varrow (window, style->black_gc, shadow_type, area, GTK_ARROW_UP,
3170 x, y, indicator_size.width, 5);
3171 draw_varrow (window, style->black_gc, shadow_type, area, GTK_ARROW_DOWN,
3172 x, y + 8, indicator_size.width, 5);
3176 gtk_default_draw_shadow_gap (GtkStyle *style,
3178 GtkStateType state_type,
3179 GtkShadowType shadow_type,
3182 const gchar *detail,
3187 GtkPositionType gap_side,
3196 g_return_if_fail (GTK_IS_STYLE (style));
3197 g_return_if_fail (window != NULL);
3199 sanitize_size (window, &width, &height);
3201 switch (shadow_type)
3203 case GTK_SHADOW_NONE:
3206 gc1 = style->dark_gc[state_type];
3207 gc2 = style->black_gc;
3208 gc3 = style->bg_gc[state_type];
3209 gc4 = style->light_gc[state_type];
3211 case GTK_SHADOW_ETCHED_IN:
3212 gc1 = style->dark_gc[state_type];
3213 gc2 = style->light_gc[state_type];
3214 gc3 = style->dark_gc[state_type];
3215 gc4 = style->light_gc[state_type];
3217 case GTK_SHADOW_OUT:
3218 gc1 = style->light_gc[state_type];
3219 gc2 = style->bg_gc[state_type];
3220 gc3 = style->dark_gc[state_type];
3221 gc4 = style->black_gc;
3223 case GTK_SHADOW_ETCHED_OUT:
3224 gc1 = style->light_gc[state_type];
3225 gc2 = style->dark_gc[state_type];
3226 gc3 = style->light_gc[state_type];
3227 gc4 = style->dark_gc[state_type];
3232 gdk_gc_set_clip_rectangle (gc1, area);
3233 gdk_gc_set_clip_rectangle (gc2, area);
3234 gdk_gc_set_clip_rectangle (gc3, area);
3235 gdk_gc_set_clip_rectangle (gc4, area);
3238 switch (shadow_type)
3240 case GTK_SHADOW_NONE:
3242 case GTK_SHADOW_OUT:
3243 case GTK_SHADOW_ETCHED_IN:
3244 case GTK_SHADOW_ETCHED_OUT:
3248 gdk_draw_line (window, gc1,
3249 x, y, x, y + height - 1);
3250 gdk_draw_line (window, gc2,
3251 x + 1, y, x + 1, y + height - 2);
3253 gdk_draw_line (window, gc3,
3254 x + 1, y + height - 2, x + width - 2, y + height - 2);
3255 gdk_draw_line (window, gc3,
3256 x + width - 2, y, x + width - 2, y + height - 2);
3257 gdk_draw_line (window, gc4,
3258 x, y + height - 1, x + width - 1, y + height - 1);
3259 gdk_draw_line (window, gc4,
3260 x + width - 1, y, x + width - 1, y + height - 1);
3263 gdk_draw_line (window, gc1,
3264 x, y, x + gap_x - 1, y);
3265 gdk_draw_line (window, gc2,
3266 x + 1, y + 1, x + gap_x - 1, y + 1);
3267 gdk_draw_line (window, gc2,
3268 x + gap_x, y, x + gap_x, y);
3270 if ((width - (gap_x + gap_width)) > 0)
3272 gdk_draw_line (window, gc1,
3273 x + gap_x + gap_width, y, x + width - 2, y);
3274 gdk_draw_line (window, gc2,
3275 x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
3276 gdk_draw_line (window, gc2,
3277 x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
3280 case GTK_POS_BOTTOM:
3281 gdk_draw_line (window, gc1,
3282 x, y, x + width - 1, y);
3283 gdk_draw_line (window, gc1,
3284 x, y, x, y + height - 1);
3285 gdk_draw_line (window, gc2,
3286 x + 1, y + 1, x + width - 2, y + 1);
3287 gdk_draw_line (window, gc2,
3288 x + 1, y + 1, x + 1, y + height - 1);
3290 gdk_draw_line (window, gc3,
3291 x + width - 2, y + 1, x + width - 2, y + height - 1);
3292 gdk_draw_line (window, gc4,
3293 x + width - 1, y, x + width - 1, y + height - 1);
3296 gdk_draw_line (window, gc4,
3297 x, y + height - 1, x + gap_x - 1, y + height - 1);
3298 gdk_draw_line (window, gc3,
3299 x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
3300 gdk_draw_line (window, gc3,
3301 x + gap_x, y + height - 1, x + gap_x, y + height - 1);
3303 if ((width - (gap_x + gap_width)) > 0)
3305 gdk_draw_line (window, gc4,
3306 x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
3307 gdk_draw_line (window, gc3,
3308 x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
3309 gdk_draw_line (window, gc3,
3310 x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
3314 gdk_draw_line (window, gc1,
3315 x, y, x + width - 1, y);
3316 gdk_draw_line (window, gc2,
3317 x, y + 1, x + width - 2, y + 1);
3319 gdk_draw_line (window, gc3,
3320 x, y + height - 2, x + width - 2, y + height - 2);
3321 gdk_draw_line (window, gc3,
3322 x + width - 2, y + 1, x + width - 2, y + height - 2);
3323 gdk_draw_line (window, gc4,
3324 x, y + height - 1, x + width - 1, y + height - 1);
3325 gdk_draw_line (window, gc4,
3326 x + width - 1, y, x + width - 1, y + height - 1);
3329 gdk_draw_line (window, gc1,
3330 x, y, x, y + gap_x - 1);
3331 gdk_draw_line (window, gc2,
3332 x + 1, y + 1, x + 1, y + gap_x - 1);
3333 gdk_draw_line (window, gc2,
3334 x, y + gap_x, x, y + gap_x);
3336 if ((width - (gap_x + gap_width)) > 0)
3338 gdk_draw_line (window, gc1,
3339 x, y + gap_x + gap_width, x, y + height - 2);
3340 gdk_draw_line (window, gc2,
3341 x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
3342 gdk_draw_line (window, gc2,
3343 x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
3347 gdk_draw_line (window, gc1,
3348 x, y, x + width - 1, y);
3349 gdk_draw_line (window, gc1,
3350 x, y, x, y + height - 1);
3351 gdk_draw_line (window, gc2,
3352 x + 1, y + 1, x + width - 1, y + 1);
3353 gdk_draw_line (window, gc2,
3354 x + 1, y + 1, x + 1, y + height - 2);
3356 gdk_draw_line (window, gc3,
3357 x + 1, y + height - 2, x + width - 1, y + height - 2);
3358 gdk_draw_line (window, gc4,
3359 x, y + height - 1, x + width - 1, y + height - 1);
3362 gdk_draw_line (window, gc4,
3363 x + width - 1, y, x + width - 1, y + gap_x - 1);
3364 gdk_draw_line (window, gc3,
3365 x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
3366 gdk_draw_line (window, gc3,
3367 x + width - 1, y + gap_x, x + width - 1, y + gap_x);
3369 if ((width - (gap_x + gap_width)) > 0)
3371 gdk_draw_line (window, gc4,
3372 x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
3373 gdk_draw_line (window, gc3,
3374 x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
3375 gdk_draw_line (window, gc3,
3376 x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
3384 gdk_gc_set_clip_rectangle (gc1, NULL);
3385 gdk_gc_set_clip_rectangle (gc2, NULL);
3386 gdk_gc_set_clip_rectangle (gc3, NULL);
3387 gdk_gc_set_clip_rectangle (gc4, NULL);
3392 gtk_default_draw_box_gap (GtkStyle *style,
3394 GtkStateType state_type,
3395 GtkShadowType shadow_type,
3398 const gchar *detail,
3403 GtkPositionType gap_side,
3412 g_return_if_fail (GTK_IS_STYLE (style));
3413 g_return_if_fail (window != NULL);
3415 gtk_style_apply_default_background (style, window,
3416 widget && !GTK_WIDGET_NO_WINDOW (widget),
3417 state_type, area, x, y, width, height);
3419 sanitize_size (window, &width, &height);
3421 switch (shadow_type)
3423 case GTK_SHADOW_NONE:
3426 gc1 = style->dark_gc[state_type];
3427 gc2 = style->black_gc;
3428 gc3 = style->bg_gc[state_type];
3429 gc4 = style->light_gc[state_type];
3431 case GTK_SHADOW_ETCHED_IN:
3432 gc1 = style->dark_gc[state_type];
3433 gc2 = style->light_gc[state_type];
3434 gc3 = style->dark_gc[state_type];
3435 gc4 = style->light_gc[state_type];
3437 case GTK_SHADOW_OUT:
3438 gc1 = style->light_gc[state_type];
3439 gc2 = style->bg_gc[state_type];
3440 gc3 = style->dark_gc[state_type];
3441 gc4 = style->black_gc;
3443 case GTK_SHADOW_ETCHED_OUT:
3444 gc1 = style->light_gc[state_type];
3445 gc2 = style->dark_gc[state_type];
3446 gc3 = style->light_gc[state_type];
3447 gc4 = style->dark_gc[state_type];
3453 gdk_gc_set_clip_rectangle (gc1, area);
3454 gdk_gc_set_clip_rectangle (gc2, area);
3455 gdk_gc_set_clip_rectangle (gc3, area);
3456 gdk_gc_set_clip_rectangle (gc4, area);
3459 switch (shadow_type)
3461 case GTK_SHADOW_NONE:
3463 case GTK_SHADOW_OUT:
3464 case GTK_SHADOW_ETCHED_IN:
3465 case GTK_SHADOW_ETCHED_OUT:
3469 gdk_draw_line (window, gc1,
3470 x, y, x, y + height - 1);
3471 gdk_draw_line (window, gc2,
3472 x + 1, y, x + 1, y + height - 2);
3474 gdk_draw_line (window, gc3,
3475 x + 1, y + height - 2, x + width - 2, y + height - 2);
3476 gdk_draw_line (window, gc3,
3477 x + width - 2, y, x + width - 2, y + height - 2);
3478 gdk_draw_line (window, gc4,
3479 x, y + height - 1, x + width - 1, y + height - 1);
3480 gdk_draw_line (window, gc4,
3481 x + width - 1, y, x + width - 1, y + height - 1);
3484 gdk_draw_line (window, gc1,
3485 x, y, x + gap_x - 1, y);
3486 gdk_draw_line (window, gc2,
3487 x + 1, y + 1, x + gap_x - 1, y + 1);
3488 gdk_draw_line (window, gc2,
3489 x + gap_x, y, x + gap_x, y);
3491 if ((width - (gap_x + gap_width)) > 0)
3493 gdk_draw_line (window, gc1,
3494 x + gap_x + gap_width, y, x + width - 2, y);
3495 gdk_draw_line (window, gc2,
3496 x + gap_x + gap_width, y + 1, x + width - 2, y + 1);
3497 gdk_draw_line (window, gc2,
3498 x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y);
3501 case GTK_POS_BOTTOM:
3502 gdk_draw_line (window, gc1,
3503 x, y, x + width - 1, y);
3504 gdk_draw_line (window, gc1,
3505 x, y, x, y + height - 1);
3506 gdk_draw_line (window, gc2,
3507 x + 1, y + 1, x + width - 2, y + 1);
3508 gdk_draw_line (window, gc2,
3509 x + 1, y + 1, x + 1, y + height - 1);
3511 gdk_draw_line (window, gc3,
3512 x + width - 2, y + 1, x + width - 2, y + height - 1);
3513 gdk_draw_line (window, gc4,
3514 x + width - 1, y, x + width - 1, y + height - 1);
3517 gdk_draw_line (window, gc4,
3518 x, y + height - 1, x + gap_x - 1, y + height - 1);
3519 gdk_draw_line (window, gc3,
3520 x + 1, y + height - 2, x + gap_x - 1, y + height - 2);
3521 gdk_draw_line (window, gc3,
3522 x + gap_x, y + height - 1, x + gap_x, y + height - 1);
3524 if ((width - (gap_x + gap_width)) > 0)
3526 gdk_draw_line (window, gc4,
3527 x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1);
3528 gdk_draw_line (window, gc3,
3529 x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2);
3530 gdk_draw_line (window, gc3,
3531 x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1);
3535 gdk_draw_line (window, gc1,
3536 x, y, x + width - 1, y);
3537 gdk_draw_line (window, gc2,
3538 x, y + 1, x + width - 2, y + 1);
3540 gdk_draw_line (window, gc3,
3541 x, y + height - 2, x + width - 2, y + height - 2);
3542 gdk_draw_line (window, gc3,
3543 x + width - 2, y + 1, x + width - 2, y + height - 2);
3544 gdk_draw_line (window, gc4,
3545 x, y + height - 1, x + width - 1, y + height - 1);
3546 gdk_draw_line (window, gc4,
3547 x + width - 1, y, x + width - 1, y + height - 1);
3550 gdk_draw_line (window, gc1,
3551 x, y, x, y + gap_x - 1);
3552 gdk_draw_line (window, gc2,
3553 x + 1, y + 1, x + 1, y + gap_x - 1);
3554 gdk_draw_line (window, gc2,
3555 x, y + gap_x, x, y + gap_x);
3557 if ((width - (gap_x + gap_width)) > 0)
3559 gdk_draw_line (window, gc1,
3560 x, y + gap_x + gap_width, x, y + height - 2);
3561 gdk_draw_line (window, gc2,
3562 x + 1, y + gap_x + gap_width, x + 1, y + height - 2);
3563 gdk_draw_line (window, gc2,
3564 x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1);
3568 gdk_draw_line (window, gc1,
3569 x, y, x + width - 1, y);
3570 gdk_draw_line (window, gc1,
3571 x, y, x, y + height - 1);
3572 gdk_draw_line (window, gc2,
3573 x + 1, y + 1, x + width - 1, y + 1);
3574 gdk_draw_line (window, gc2,
3575 x + 1, y + 1, x + 1, y + height - 2);
3577 gdk_draw_line (window, gc3,
3578 x + 1, y + height - 2, x + width - 1, y + height - 2);
3579 gdk_draw_line (window, gc4,
3580 x, y + height - 1, x + width - 1, y + height - 1);
3583 gdk_draw_line (window, gc4,
3584 x + width - 1, y, x + width - 1, y + gap_x - 1);
3585 gdk_draw_line (window, gc3,
3586 x + width - 2, y + 1, x + width - 2, y + gap_x - 1);
3587 gdk_draw_line (window, gc3,
3588 x + width - 1, y + gap_x, x + width - 1, y + gap_x);
3590 if ((width - (gap_x + gap_width)) > 0)
3592 gdk_draw_line (window, gc4,
3593 x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2);
3594 gdk_draw_line (window, gc3,
3595 x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2);
3596 gdk_draw_line (window, gc3,
3597 x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1);
3605 gdk_gc_set_clip_rectangle (gc1, NULL);
3606 gdk_gc_set_clip_rectangle (gc2, NULL);
3607 gdk_gc_set_clip_rectangle (gc3, NULL);
3608 gdk_gc_set_clip_rectangle (gc4, NULL);
3613 gtk_default_draw_extension (GtkStyle *style,
3615 GtkStateType state_type,
3616 GtkShadowType shadow_type,
3619 const gchar *detail,
3624 GtkPositionType gap_side)
3631 g_return_if_fail (GTK_IS_STYLE (style));
3632 g_return_if_fail (window != NULL);
3634 gtk_style_apply_default_background (style, window,
3635 widget && !GTK_WIDGET_NO_WINDOW (widget),
3636 GTK_STATE_NORMAL, area, x, y, width, height);
3638 sanitize_size (window, &width, &height);
3640 switch (shadow_type)
3642 case GTK_SHADOW_NONE:
3645 gc1 = style->dark_gc[state_type];
3646 gc2 = style->black_gc;
3647 gc3 = style->bg_gc[state_type];
3648 gc4 = style->light_gc[state_type];
3650 case GTK_SHADOW_ETCHED_IN:
3651 gc1 = style->dark_gc[state_type];
3652 gc2 = style->light_gc[state_type];
3653 gc3 = style->dark_gc[state_type];
3654 gc4 = style->light_gc[state_type];
3656 case GTK_SHADOW_OUT:
3657 gc1 = style->light_gc[state_type];
3658 gc2 = style->bg_gc[state_type];
3659 gc3 = style->dark_gc[state_type];
3660 gc4 = style->black_gc;
3662 case GTK_SHADOW_ETCHED_OUT:
3663 gc1 = style->light_gc[state_type];
3664 gc2 = style->dark_gc[state_type];
3665 gc3 = style->light_gc[state_type];
3666 gc4 = style->dark_gc[state_type];
3672 gdk_gc_set_clip_rectangle (gc1, area);
3673 gdk_gc_set_clip_rectangle (gc2, area);
3674 gdk_gc_set_clip_rectangle (gc3, area);
3675 gdk_gc_set_clip_rectangle (gc4, area);
3678 switch (shadow_type)
3680 case GTK_SHADOW_NONE:
3682 case GTK_SHADOW_OUT:
3683 case GTK_SHADOW_ETCHED_IN:
3684 case GTK_SHADOW_ETCHED_OUT:
3688 gtk_style_apply_default_background (style, window,
3689 widget && !GTK_WIDGET_NO_WINDOW (widget),
3691 x + style->xthickness,
3693 width - (2 * style->xthickness),
3694 height - (style->ythickness));
3695 gdk_draw_line (window, gc1,
3696 x, y, x, y + height - 2);
3697 gdk_draw_line (window, gc2,
3698 x + 1, y, x + 1, y + height - 2);
3700 gdk_draw_line (window, gc3,
3701 x + 2, y + height - 2, x + width - 2, y + height - 2);
3702 gdk_draw_line (window, gc3,
3703 x + width - 2, y, x + width - 2, y + height - 2);
3704 gdk_draw_line (window, gc4,
3705 x + 1, y + height - 1, x + width - 2, y + height - 1);
3706 gdk_draw_line (window, gc4,
3707 x + width - 1, y, x + width - 1, y + height - 2);
3709 case GTK_POS_BOTTOM:
3710 gtk_style_apply_default_background (style, window,
3711 widget && !GTK_WIDGET_NO_WINDOW (widget),
3713 x + style->xthickness,
3714 y + style->ythickness,
3715 width - (2 * style->xthickness),
3716 height - (style->ythickness));
3717 gdk_draw_line (window, gc1,
3718 x + 1, y, x + width - 2, y);
3719 gdk_draw_line (window, gc1,
3720 x, y + 1, x, y + height - 1);
3721 gdk_draw_line (window, gc2,
3722 x + 1, y + 1, x + width - 2, y + 1);
3723 gdk_draw_line (window, gc2,
3724 x + 1, y + 1, x + 1, y + height - 1);
3726 gdk_draw_line (window, gc3,
3727 x + width - 2, y + 2, x + width - 2, y + height - 1);
3728 gdk_draw_line (window, gc4,
3729 x + width - 1, y + 1, x + width - 1, y + height - 1);
3732 gtk_style_apply_default_background (style, window,
3733 widget && !GTK_WIDGET_NO_WINDOW (widget),
3736 y + style->ythickness,
3737 width - (style->xthickness),
3738 height - (2 * style->ythickness));
3739 gdk_draw_line (window, gc1,
3740 x, y, x + width - 2, y);
3741 gdk_draw_line (window, gc2,
3742 x + 1, y + 1, x + width - 2, y + 1);
3744 gdk_draw_line (window, gc3,
3745 x, y + height - 2, x + width - 2, y + height - 2);
3746 gdk_draw_line (window, gc3,
3747 x + width - 2, y + 2, x + width - 2, y + height - 2);
3748 gdk_draw_line (window, gc4,
3749 x, y + height - 1, x + width - 2, y + height - 1);
3750 gdk_draw_line (window, gc4,
3751 x + width - 1, y + 1, x + width - 1, y + height - 2);
3754 gtk_style_apply_default_background (style, window,
3755 widget && !GTK_WIDGET_NO_WINDOW (widget),
3757 x + style->xthickness,
3758 y + style->ythickness,
3759 width - (style->xthickness),
3760 height - (2 * style->ythickness));
3761 gdk_draw_line (window, gc1,
3762 x + 1, y, x + width - 1, y);
3763 gdk_draw_line (window, gc1,
3764 x, y + 1, x, y + height - 2);
3765 gdk_draw_line (window, gc2,
3766 x + 1, y + 1, x + width - 1, y + 1);
3767 gdk_draw_line (window, gc2,
3768 x + 1, y + 1, x + 1, y + height - 2);
3770 gdk_draw_line (window, gc3,
3771 x + 2, y + height - 2, x + width - 1, y + height - 2);
3772 gdk_draw_line (window, gc4,
3773 x + 1, y + height - 1, x + width - 1, y + height - 1);
3780 gdk_gc_set_clip_rectangle (gc1, NULL);
3781 gdk_gc_set_clip_rectangle (gc2, NULL);
3782 gdk_gc_set_clip_rectangle (gc3, NULL);
3783 gdk_gc_set_clip_rectangle (gc4, NULL);
3788 gtk_default_draw_focus (GtkStyle *style,
3792 const gchar *detail,
3800 sanitize_size (window, &width, &height);
3803 gdk_gc_set_clip_rectangle (style->black_gc, area);
3805 gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_ON_OFF_DASH, 0, 0);
3807 if (detail && !strcmp (detail, "add-mode"))
3808 gdk_gc_set_dashes (style->black_gc, 0, "\4\4", 2);
3810 gdk_gc_set_dashes (style->black_gc, 0, "\1\1", 2);
3814 points[1].x = x + width;
3816 points[2].x = x + width;
3817 points[2].y = y + height;
3819 points[3].y = y + height;
3820 points[4] = points[0];
3822 gdk_draw_polygon (window, style->black_gc, FALSE, points, 4);
3823 gdk_gc_set_line_attributes (style->black_gc, 0, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
3826 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
3830 gtk_default_draw_slider (GtkStyle *style,
3832 GtkStateType state_type,
3833 GtkShadowType shadow_type,
3836 const gchar *detail,
3841 GtkOrientation orientation)
3843 g_return_if_fail (GTK_IS_STYLE (style));
3844 g_return_if_fail (window != NULL);
3846 sanitize_size (window, &width, &height);
3848 gtk_paint_box (style, window, state_type, shadow_type,
3849 area, widget, detail, x, y, width, height);
3852 (strcmp ("hscale", detail) == 0 ||
3853 strcmp ("vscale", detail) == 0))
3855 if (orientation == GTK_ORIENTATION_HORIZONTAL)
3856 gtk_paint_vline (style, window, state_type, area, widget, detail,
3857 y + style->ythickness,
3858 y + height - style->ythickness - 1, x + width / 2);
3860 gtk_paint_hline (style, window, state_type, area, widget, detail,
3861 x + style->xthickness,
3862 x + width - style->xthickness - 1, y + height / 2);
3867 draw_dot (GdkWindow *window,
3875 size = CLAMP (size, 2, 3);
3879 gdk_draw_point (window, light_gc, x, y);
3880 gdk_draw_point (window, light_gc, x+1, y+1);
3882 else if (size == 3);
3884 gdk_draw_point (window, light_gc, x, y);
3885 gdk_draw_point (window, light_gc, x+1, y);
3886 gdk_draw_point (window, light_gc, x, y+1);
3887 gdk_draw_point (window, dark_gc, x+1, y+2);
3888 gdk_draw_point (window, dark_gc, x+2, y+1);
3889 gdk_draw_point (window, dark_gc, x+2, y+2);
3894 gtk_default_draw_handle (GtkStyle *style,
3896 GtkStateType state_type,
3897 GtkShadowType shadow_type,
3900 const gchar *detail,
3905 GtkOrientation orientation)
3908 gint xthick, ythick;
3909 GdkGC *light_gc, *dark_gc;
3914 g_return_if_fail (GTK_IS_STYLE (style));
3915 g_return_if_fail (window != NULL);
3917 sanitize_size (window, &width, &height);
3919 gtk_paint_box (style, window, state_type, shadow_type, area, widget,
3920 detail, x, y, width, height);
3923 if (!strcmp (detail, "paned"))
3925 /* we want to ignore the shadow border in paned widgets */
3929 light_gc = style->light_gc[state_type];
3930 dark_gc = style->black_gc;
3934 xthick = style->xthickness;
3935 ythick = style->ythickness;
3937 light_gc = style->light_gc[state_type];
3938 dark_gc = style->dark_gc[state_type];
3941 rect.x = x + xthick;
3942 rect.y = y + ythick;
3943 rect.width = width - (xthick * 2);
3944 rect.height = height - (ythick * 2);
3947 intersect = gdk_rectangle_intersect (area, &rect, &dest);
3957 gdk_gc_set_clip_rectangle (light_gc, &dest);
3958 gdk_gc_set_clip_rectangle (dark_gc, &dest);
3960 if (!strcmp (detail, "paned"))
3965 gdk_window_get_size (window, &window_width, &window_height);
3967 if (orientation == GTK_ORIENTATION_HORIZONTAL)
3968 for (xx = window_width/2 - 15; xx <= window_width/2 + 15; xx += 5)
3969 draw_dot (window, light_gc, dark_gc, xx, window_height/2 - 1, 3);
3971 for (yy = window_height/2 - 15; yy <= window_height/2 + 15; yy += 5)
3972 draw_dot (window, light_gc, dark_gc, window_width/2 - 1, yy, 3);
3976 for (yy = y + ythick; yy < (y + height - ythick); yy += 3)
3977 for (xx = x + xthick; xx < (x + width - xthick); xx += 6)
3979 draw_dot (window, light_gc, dark_gc, xx, yy, 2);
3980 draw_dot (window, light_gc, dark_gc, xx + 3, yy + 1, 2);
3984 gdk_gc_set_clip_rectangle (light_gc, NULL);
3985 gdk_gc_set_clip_rectangle (dark_gc, NULL);
3989 create_expander_affine (gdouble affine[6],
3999 width = expander_size / 4.0;
4000 height = expander_size / 2.0;
4002 s = sin (degrees * G_PI / 180.0);
4003 c = cos (degrees * G_PI / 180.0);
4009 affine[4] = -width * c - height * -s + x;
4010 affine[5] = -width * s - height * c + y;
4014 apply_affine_on_point (double affine[6], GdkPoint *point)
4018 x = point->x * affine[0] + point->y * affine[2] + affine[4];
4019 y = point->x * affine[1] + point->y * affine[3] + affine[5];
4026 gtk_default_draw_expander (GtkStyle *style,
4028 GtkStateType state_type,
4031 const gchar *detail,
4034 GtkExpanderStyle expander_style)
4042 gtk_widget_style_get (widget,
4043 "expander_size", &expander_size,
4048 gdk_gc_set_clip_rectangle (style->fg_gc[GTK_STATE_NORMAL], area);
4049 gdk_gc_set_clip_rectangle (style->base_gc[GTK_STATE_NORMAL], area);
4054 points[1].x = expander_size / 2;
4055 points[1].y = expander_size / 2;
4057 points[2].y = expander_size;
4059 switch (expander_style)
4061 case GTK_EXPANDER_COLLAPSED:
4064 case GTK_EXPANDER_SEMI_COLLAPSED:
4067 case GTK_EXPANDER_SEMI_EXPANDED:
4070 case GTK_EXPANDER_EXPANDED:
4074 g_assert_not_reached ();
4077 create_expander_affine (affine, degrees, expander_size, x, y);
4079 for (i = 0; i < 3; i++)
4080 apply_affine_on_point (affine, &points[i]);
4082 if (state_type == GTK_STATE_PRELIGHT)
4084 gdk_draw_polygon (window, style->base_gc[GTK_STATE_NORMAL],
4086 gdk_draw_polygon (window, style->fg_gc[GTK_STATE_NORMAL],
4089 else if (state_type == GTK_STATE_ACTIVE)
4091 gdk_draw_polygon (window, style->light_gc[GTK_STATE_ACTIVE],
4093 gdk_draw_polygon (window, style->fg_gc[GTK_STATE_NORMAL],
4098 gdk_draw_polygon (window, style->fg_gc[GTK_STATE_NORMAL],
4103 gdk_gc_set_clip_rectangle (style->fg_gc[GTK_STATE_NORMAL], NULL);
4104 gdk_gc_set_clip_rectangle (style->base_gc[GTK_STATE_NORMAL], NULL);
4108 typedef struct _ByteRange ByteRange;
4117 range_new (guint start,
4120 ByteRange *br = g_new (ByteRange, 1);
4129 get_insensitive_layout (PangoLayout *layout)
4131 GSList *embossed_ranges = NULL;
4132 GSList *stippled_ranges = NULL;
4133 PangoLayoutIter *iter;
4134 GSList *tmp_list = NULL;
4135 PangoLayout *new_layout;
4136 PangoAttrList *attrs;
4137 GdkBitmap *stipple = NULL;
4139 iter = pango_layout_get_iter (layout);
4143 PangoLayoutRun *run;
4144 PangoAttribute *attr;
4145 gboolean need_stipple = FALSE;
4148 run = pango_layout_iter_get_run (iter);
4152 tmp_list = run->item->analysis.extra_attrs;
4154 while (tmp_list != NULL)
4156 attr = tmp_list->data;
4157 switch (attr->klass->type)
4159 case PANGO_ATTR_FOREGROUND:
4160 case PANGO_ATTR_BACKGROUND:
4161 need_stipple = TRUE;
4171 tmp_list = g_slist_next (tmp_list);
4174 br = range_new (run->item->offset, run->item->offset + run->item->length);
4177 stippled_ranges = g_slist_prepend (stippled_ranges, br);
4179 embossed_ranges = g_slist_prepend (embossed_ranges, br);
4182 while (pango_layout_iter_next_run (iter));
4184 pango_layout_iter_free (iter);
4186 new_layout = pango_layout_copy (layout);
4188 attrs = pango_layout_get_attributes (new_layout);
4192 /* Create attr list if there wasn't one */
4193 attrs = pango_attr_list_new ();
4194 pango_layout_set_attributes (new_layout, attrs);
4195 pango_attr_list_unref (attrs);
4198 tmp_list = embossed_ranges;
4199 while (tmp_list != NULL)
4201 PangoAttribute *attr;
4202 ByteRange *br = tmp_list->data;
4204 attr = gdk_pango_attr_embossed_new (TRUE);
4206 attr->start_index = br->start;
4207 attr->end_index = br->end;
4209 pango_attr_list_change (attrs, attr);
4213 tmp_list = g_slist_next (tmp_list);
4216 g_slist_free (embossed_ranges);
4218 tmp_list = stippled_ranges;
4219 while (tmp_list != NULL)
4221 PangoAttribute *attr;
4222 ByteRange *br = tmp_list->data;
4224 if (stipple == NULL)
4226 #define gray50_width 2
4227 #define gray50_height 2
4228 static char gray50_bits[] = {
4232 stipple = gdk_bitmap_create_from_data (NULL,
4233 gray50_bits, gray50_width,
4237 attr = gdk_pango_attr_stipple_new (stipple);
4239 attr->start_index = br->start;
4240 attr->end_index = br->end;
4242 pango_attr_list_change (attrs, attr);
4246 tmp_list = g_slist_next (tmp_list);
4249 g_slist_free (stippled_ranges);
4252 g_object_unref (G_OBJECT (stipple));
4258 gtk_default_draw_layout (GtkStyle *style,
4260 GtkStateType state_type,
4264 const gchar *detail,
4267 PangoLayout *layout)
4271 g_return_if_fail (GTK_IS_STYLE (style));
4272 g_return_if_fail (window != NULL);
4274 gc = use_text ? style->text_gc[state_type] : style->fg_gc[state_type];
4277 gdk_gc_set_clip_rectangle (gc, area);
4279 if (state_type == GTK_STATE_INSENSITIVE)
4283 ins = get_insensitive_layout (layout);
4285 gdk_draw_layout (window, gc, x, y, ins);
4287 g_object_unref (G_OBJECT (ins));
4291 gdk_draw_layout (window, gc, x, y, layout);
4295 gdk_gc_set_clip_rectangle (gc, NULL);
4299 gtk_default_draw_resize_grip (GtkStyle *style,
4301 GtkStateType state_type,
4304 const gchar *detail,
4311 g_return_if_fail (GTK_IS_STYLE (style));
4312 g_return_if_fail (window != NULL);
4316 gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
4317 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
4318 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
4321 /* make it square, aligning to bottom right */
4324 y += (height - width);
4327 else if (height < width)
4329 x += (width - height);
4333 /* Clear background */
4334 gdk_draw_rectangle (window,
4335 style->bg_gc[state_type],
4337 x, y, width, height);
4341 case GDK_WINDOW_EDGE_SOUTH_EAST:
4348 while (xi < (x + width - 3))
4350 gdk_draw_line (window,
4351 style->light_gc[state_type],
4358 gdk_draw_line (window,
4359 style->dark_gc[state_type],
4366 gdk_draw_line (window,
4367 style->dark_gc[state_type],
4377 g_assert_not_reached ();
4383 gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
4384 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
4385 gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
4390 gtk_style_shade (GdkColor *a,
4398 red = (gdouble) a->red / 65535.0;
4399 green = (gdouble) a->green / 65535.0;
4400 blue = (gdouble) a->blue / 65535.0;
4402 rgb_to_hls (&red, &green, &blue);
4407 else if (green < 0.0)
4413 else if (blue < 0.0)
4416 hls_to_rgb (&red, &green, &blue);
4418 b->red = red * 65535.0;
4419 b->green = green * 65535.0;
4420 b->blue = blue * 65535.0;
4424 rgb_to_hls (gdouble *r,
4465 l = (max + min) / 2;
4472 s = (max - min) / (max + min);
4474 s = (max - min) / (2 - max - min);
4478 h = (green - blue) / delta;
4479 else if (green == max)
4480 h = 2 + (blue - red) / delta;
4481 else if (blue == max)
4482 h = 4 + (red - green) / delta;
4495 hls_to_rgb (gdouble *h,
4508 if (lightness <= 0.5)
4509 m2 = lightness * (1 + saturation);
4511 m2 = lightness + saturation - lightness * saturation;
4512 m1 = 2 * lightness - m2;
4514 if (saturation == 0)
4529 r = m1 + (m2 - m1) * hue / 60;
4533 r = m1 + (m2 - m1) * (240 - hue) / 60;
4544 g = m1 + (m2 - m1) * hue / 60;
4548 g = m1 + (m2 - m1) * (240 - hue) / 60;
4559 b = m1 + (m2 - m1) * hue / 60;
4563 b = m1 + (m2 - m1) * (240 - hue) / 60;
4574 gtk_paint_hline (GtkStyle *style,
4576 GtkStateType state_type,
4579 const gchar *detail,
4584 g_return_if_fail (GTK_IS_STYLE (style));
4585 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_hline != NULL);
4587 GTK_STYLE_GET_CLASS (style)->draw_hline (style, window, state_type, area, widget, detail, x1, x2, y);
4591 gtk_paint_vline (GtkStyle *style,
4593 GtkStateType state_type,
4596 const gchar *detail,
4601 g_return_if_fail (GTK_IS_STYLE (style));
4602 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_vline != NULL);
4604 GTK_STYLE_GET_CLASS (style)->draw_vline (style, window, state_type, area, widget, detail, y1, y2, x);
4608 gtk_paint_shadow (GtkStyle *style,
4610 GtkStateType state_type,
4611 GtkShadowType shadow_type,
4614 const gchar *detail,
4620 g_return_if_fail (GTK_IS_STYLE (style));
4621 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow != NULL);
4623 GTK_STYLE_GET_CLASS (style)->draw_shadow (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4627 gtk_paint_polygon (GtkStyle *style,
4629 GtkStateType state_type,
4630 GtkShadowType shadow_type,
4633 const gchar *detail,
4638 g_return_if_fail (GTK_IS_STYLE (style));
4639 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow != NULL);
4641 GTK_STYLE_GET_CLASS (style)->draw_polygon (style, window, state_type, shadow_type, area, widget, detail, points, npoints, fill);
4645 gtk_paint_arrow (GtkStyle *style,
4647 GtkStateType state_type,
4648 GtkShadowType shadow_type,
4651 const gchar *detail,
4652 GtkArrowType arrow_type,
4659 g_return_if_fail (GTK_IS_STYLE (style));
4660 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_arrow != NULL);
4662 GTK_STYLE_GET_CLASS (style)->draw_arrow (style, window, state_type, shadow_type, area, widget, detail, arrow_type, fill, x, y, width, height);
4666 gtk_paint_diamond (GtkStyle *style,
4668 GtkStateType state_type,
4669 GtkShadowType shadow_type,
4672 const gchar *detail,
4678 g_return_if_fail (GTK_IS_STYLE (style));
4679 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_diamond != NULL);
4681 GTK_STYLE_GET_CLASS (style)->draw_diamond (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4685 gtk_paint_string (GtkStyle *style,
4687 GtkStateType state_type,
4690 const gchar *detail,
4693 const gchar *string)
4695 g_return_if_fail (GTK_IS_STYLE (style));
4696 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_string != NULL);
4698 GTK_STYLE_GET_CLASS (style)->draw_string (style, window, state_type, area, widget, detail, x, y, string);
4702 gtk_paint_box (GtkStyle *style,
4704 GtkStateType state_type,
4705 GtkShadowType shadow_type,
4708 const gchar *detail,
4714 g_return_if_fail (GTK_IS_STYLE (style));
4715 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box != NULL);
4717 GTK_STYLE_GET_CLASS (style)->draw_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4721 gtk_paint_flat_box (GtkStyle *style,
4723 GtkStateType state_type,
4724 GtkShadowType shadow_type,
4727 const gchar *detail,
4733 g_return_if_fail (GTK_IS_STYLE (style));
4734 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_flat_box != NULL);
4736 GTK_STYLE_GET_CLASS (style)->draw_flat_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4740 gtk_paint_check (GtkStyle *style,
4742 GtkStateType state_type,
4743 GtkShadowType shadow_type,
4746 const gchar *detail,
4752 g_return_if_fail (GTK_IS_STYLE (style));
4753 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_check != NULL);
4755 GTK_STYLE_GET_CLASS (style)->draw_check (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4759 gtk_paint_option (GtkStyle *style,
4761 GtkStateType state_type,
4762 GtkShadowType shadow_type,
4765 const gchar *detail,
4771 g_return_if_fail (GTK_IS_STYLE (style));
4772 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_option != NULL);
4774 GTK_STYLE_GET_CLASS (style)->draw_option (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4778 gtk_paint_tab (GtkStyle *style,
4780 GtkStateType state_type,
4781 GtkShadowType shadow_type,
4784 const gchar *detail,
4790 g_return_if_fail (GTK_IS_STYLE (style));
4791 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_tab != NULL);
4793 GTK_STYLE_GET_CLASS (style)->draw_tab (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
4797 gtk_paint_shadow_gap (GtkStyle *style,
4799 GtkStateType state_type,
4800 GtkShadowType shadow_type,
4808 GtkPositionType gap_side,
4812 g_return_if_fail (GTK_IS_STYLE (style));
4813 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow_gap != NULL);
4815 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);
4820 gtk_paint_box_gap (GtkStyle *style,
4822 GtkStateType state_type,
4823 GtkShadowType shadow_type,
4831 GtkPositionType gap_side,
4835 g_return_if_fail (GTK_IS_STYLE (style));
4836 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_box_gap != NULL);
4838 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);
4842 gtk_paint_extension (GtkStyle *style,
4844 GtkStateType state_type,
4845 GtkShadowType shadow_type,
4853 GtkPositionType gap_side)
4855 g_return_if_fail (GTK_IS_STYLE (style));
4856 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_extension != NULL);
4858 GTK_STYLE_GET_CLASS (style)->draw_extension (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side);
4862 gtk_paint_focus (GtkStyle *style,
4866 const gchar *detail,
4872 g_return_if_fail (GTK_IS_STYLE (style));
4873 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_focus != NULL);
4875 GTK_STYLE_GET_CLASS (style)->draw_focus (style, window, area, widget, detail, x, y, width, height);
4879 gtk_paint_slider (GtkStyle *style,
4881 GtkStateType state_type,
4882 GtkShadowType shadow_type,
4885 const gchar *detail,
4890 GtkOrientation orientation)
4892 g_return_if_fail (GTK_IS_STYLE (style));
4893 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_slider != NULL);
4895 GTK_STYLE_GET_CLASS (style)->draw_slider (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
4899 gtk_paint_handle (GtkStyle *style,
4901 GtkStateType state_type,
4902 GtkShadowType shadow_type,
4905 const gchar *detail,
4910 GtkOrientation orientation)
4912 g_return_if_fail (GTK_IS_STYLE (style));
4913 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_handle != NULL);
4915 GTK_STYLE_GET_CLASS (style)->draw_handle (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
4919 gtk_paint_expander (GtkStyle *style,
4921 GtkStateType state_type,
4924 const gchar *detail,
4927 GtkExpanderStyle expander_style)
4929 g_return_if_fail (GTK_IS_STYLE (style));
4930 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_expander != NULL);
4932 GTK_STYLE_GET_CLASS (style)->draw_expander (style, window, state_type, area,
4933 widget, detail, x, y, expander_style);
4937 gtk_paint_layout (GtkStyle *style,
4939 GtkStateType state_type,
4943 const gchar *detail,
4946 PangoLayout *layout)
4948 g_return_if_fail (GTK_IS_STYLE (style));
4949 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_layout != NULL);
4951 GTK_STYLE_GET_CLASS (style)->draw_layout (style, window, state_type, use_text, area,
4952 widget, detail, x, y, layout);
4956 gtk_paint_resize_grip (GtkStyle *style,
4958 GtkStateType state_type,
4961 const gchar *detail,
4969 g_return_if_fail (GTK_IS_STYLE (style));
4970 g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_resize_grip != NULL);
4972 GTK_STYLE_GET_CLASS (style)->draw_resize_grip (style, window, state_type,
4973 area, widget, detail,
4974 edge, x, y, width, height);
4978 gtk_border_copy (const GtkBorder *border)
4980 return (GtkBorder *)g_memdup (border, sizeof (GtkBorder));
4984 gtk_border_free (GtkBorder *border)