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/.
27 #if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
28 #error "Only <gtk/gtk.h> can be included directly."
31 #ifndef __GTK_STYLE_H__
32 #define __GTK_STYLE_H__
36 #include <gtk/gtkenums.h>
41 #define GTK_TYPE_STYLE (gtk_style_get_type ())
42 #define GTK_STYLE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GTK_TYPE_STYLE, GtkStyle))
43 #define GTK_STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_STYLE, GtkStyleClass))
44 #define GTK_IS_STYLE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GTK_TYPE_STYLE))
45 #define GTK_IS_STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_STYLE))
46 #define GTK_STYLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_STYLE, GtkStyleClass))
48 #define GTK_TYPE_BORDER (gtk_border_get_type ())
50 /* Some forward declarations needed to rationalize the header
53 typedef struct _GtkBorder GtkBorder;
54 typedef struct _GtkStyle GtkStyle;
55 typedef struct _GtkStyleClass GtkStyleClass;
56 typedef struct _GtkThemeEngine GtkThemeEngine;
57 typedef struct _GtkRcStyle GtkRcStyle;
58 typedef struct _GtkIconSet GtkIconSet;
59 typedef struct _GtkIconSource GtkIconSource;
60 typedef struct _GtkRcProperty GtkRcProperty;
61 typedef struct _GtkSettings GtkSettings;
62 typedef gboolean (*GtkRcPropertyParser) (const GParamSpec *pspec,
63 const GString *rc_string,
64 GValue *property_value);
66 /* We make this forward declaration here, since we pass
67 * GtkWidget's to the draw functions.
69 typedef struct _GtkWidget GtkWidget;
71 #define GTK_STYLE_ATTACHED(style) (GTK_STYLE (style)->attach_count > 0)
75 GObject parent_instance;
86 GdkColor text_aa[5]; /* Halfway between text/base */
90 PangoFontDescription *font_desc;
102 GdkGC *text_aa_gc[5];
106 GdkPixmap *bg_pixmap[5];
113 GdkColormap *colormap;
114 GdkFont *private_font;
115 PangoFontDescription *private_font_desc; /* Font description for style->private_font or %NULL */
117 /* the RcStyle from which this style was created */
118 GtkRcStyle *rc_style;
120 GSList *styles; /* of type GtkStyle* */
121 GArray *property_cache;
122 GSList *icon_factories; /* of type GtkIconFactory* */
125 struct _GtkStyleClass
127 GObjectClass parent_class;
129 /* Initialize for a particular colormap/depth
130 * combination. style->colormap/style->depth will have
131 * been set at this point. Will typically chain to parent.
133 void (*realize) (GtkStyle *style);
135 /* Clean up for a particular colormap/depth combination. Will
136 * typically chain to parent.
138 void (*unrealize) (GtkStyle *style);
140 /* Make style an exact duplicate of src.
142 void (*copy) (GtkStyle *style,
145 /* Create an empty style of the same type as this style.
146 * The default implementation, which does
147 * g_object_new (G_OBJECT_TYPE (style), NULL);
148 * should work in most cases.
150 GtkStyle *(*clone) (GtkStyle *style);
152 /* Initialize the GtkStyle with the values in the GtkRcStyle.
153 * should chain to the parent implementation.
155 void (*init_from_rc) (GtkStyle *style,
156 GtkRcStyle *rc_style);
158 void (*set_background) (GtkStyle *style,
160 GtkStateType state_type);
163 GdkPixbuf * (* render_icon) (GtkStyle *style,
164 const GtkIconSource *source,
165 GtkTextDirection direction,
169 const gchar *detail);
174 void (*draw_hline) (GtkStyle *style,
176 GtkStateType state_type,
183 void (*draw_vline) (GtkStyle *style,
185 GtkStateType state_type,
192 void (*draw_shadow) (GtkStyle *style,
194 GtkStateType state_type,
195 GtkShadowType shadow_type,
203 void (*draw_polygon) (GtkStyle *style,
205 GtkStateType state_type,
206 GtkShadowType shadow_type,
213 void (*draw_arrow) (GtkStyle *style,
215 GtkStateType state_type,
216 GtkShadowType shadow_type,
220 GtkArrowType arrow_type,
226 void (*draw_diamond) (GtkStyle *style,
228 GtkStateType state_type,
229 GtkShadowType shadow_type,
237 void (*draw_string) (GtkStyle *style,
239 GtkStateType state_type,
245 const gchar *string);
246 void (*draw_box) (GtkStyle *style,
248 GtkStateType state_type,
249 GtkShadowType shadow_type,
257 void (*draw_flat_box) (GtkStyle *style,
259 GtkStateType state_type,
260 GtkShadowType shadow_type,
268 void (*draw_check) (GtkStyle *style,
270 GtkStateType state_type,
271 GtkShadowType shadow_type,
279 void (*draw_option) (GtkStyle *style,
281 GtkStateType state_type,
282 GtkShadowType shadow_type,
290 void (*draw_tab) (GtkStyle *style,
292 GtkStateType state_type,
293 GtkShadowType shadow_type,
301 void (*draw_shadow_gap) (GtkStyle *style,
303 GtkStateType state_type,
304 GtkShadowType shadow_type,
312 GtkPositionType gap_side,
315 void (*draw_box_gap) (GtkStyle *style,
317 GtkStateType state_type,
318 GtkShadowType shadow_type,
326 GtkPositionType gap_side,
329 void (*draw_extension) (GtkStyle *style,
331 GtkStateType state_type,
332 GtkShadowType shadow_type,
340 GtkPositionType gap_side);
341 void (*draw_focus) (GtkStyle *style,
343 GtkStateType state_type,
351 void (*draw_slider) (GtkStyle *style,
353 GtkStateType state_type,
354 GtkShadowType shadow_type,
362 GtkOrientation orientation);
363 void (*draw_handle) (GtkStyle *style,
365 GtkStateType state_type,
366 GtkShadowType shadow_type,
374 GtkOrientation orientation);
376 void (*draw_expander) (GtkStyle *style,
378 GtkStateType state_type,
384 GtkExpanderStyle expander_style);
385 void (*draw_layout) (GtkStyle *style,
387 GtkStateType state_type,
394 PangoLayout *layout);
395 void (*draw_resize_grip) (GtkStyle *style,
397 GtkStateType state_type,
407 /* Padding for future expansion */
408 void (*_gtk_reserved1) (void);
409 void (*_gtk_reserved2) (void);
410 void (*_gtk_reserved3) (void);
411 void (*_gtk_reserved4) (void);
412 void (*_gtk_reserved5) (void);
413 void (*_gtk_reserved6) (void);
414 void (*_gtk_reserved7) (void);
415 void (*_gtk_reserved8) (void);
416 void (*_gtk_reserved9) (void);
417 void (*_gtk_reserved10) (void);
418 void (*_gtk_reserved11) (void);
419 void (*_gtk_reserved12) (void);
430 GType gtk_style_get_type (void) G_GNUC_CONST;
431 GtkStyle* gtk_style_new (void);
432 GtkStyle* gtk_style_copy (GtkStyle *style);
433 GtkStyle* gtk_style_attach (GtkStyle *style,
434 GdkWindow *window) G_GNUC_WARN_UNUSED_RESULT;
435 void gtk_style_detach (GtkStyle *style);
437 #ifndef GTK_DISABLE_DEPRECATED
438 GtkStyle* gtk_style_ref (GtkStyle *style);
439 void gtk_style_unref (GtkStyle *style);
441 GdkFont * gtk_style_get_font (GtkStyle *style);
442 void gtk_style_set_font (GtkStyle *style,
444 #endif /* GTK_DISABLE_DEPRECATED */
446 void gtk_style_set_background (GtkStyle *style,
448 GtkStateType state_type);
449 void gtk_style_apply_default_background (GtkStyle *style,
452 GtkStateType state_type,
453 const GdkRectangle *area,
459 GtkIconSet* gtk_style_lookup_icon_set (GtkStyle *style,
460 const gchar *stock_id);
461 gboolean gtk_style_lookup_color (GtkStyle *style,
462 const gchar *color_name,
465 GdkPixbuf* gtk_style_render_icon (GtkStyle *style,
466 const GtkIconSource *source,
467 GtkTextDirection direction,
471 const gchar *detail);
473 #ifndef GTK_DISABLE_DEPRECATED
474 void gtk_draw_hline (GtkStyle *style,
476 GtkStateType state_type,
480 void gtk_draw_vline (GtkStyle *style,
482 GtkStateType state_type,
486 void gtk_draw_shadow (GtkStyle *style,
488 GtkStateType state_type,
489 GtkShadowType shadow_type,
494 void gtk_draw_polygon (GtkStyle *style,
496 GtkStateType state_type,
497 GtkShadowType shadow_type,
501 void gtk_draw_arrow (GtkStyle *style,
503 GtkStateType state_type,
504 GtkShadowType shadow_type,
505 GtkArrowType arrow_type,
511 void gtk_draw_diamond (GtkStyle *style,
513 GtkStateType state_type,
514 GtkShadowType shadow_type,
519 void gtk_draw_box (GtkStyle *style,
521 GtkStateType state_type,
522 GtkShadowType shadow_type,
527 void gtk_draw_flat_box (GtkStyle *style,
529 GtkStateType state_type,
530 GtkShadowType shadow_type,
535 void gtk_draw_check (GtkStyle *style,
537 GtkStateType state_type,
538 GtkShadowType shadow_type,
543 void gtk_draw_option (GtkStyle *style,
545 GtkStateType state_type,
546 GtkShadowType shadow_type,
551 void gtk_draw_tab (GtkStyle *style,
553 GtkStateType state_type,
554 GtkShadowType shadow_type,
559 void gtk_draw_shadow_gap (GtkStyle *style,
561 GtkStateType state_type,
562 GtkShadowType shadow_type,
567 GtkPositionType gap_side,
570 void gtk_draw_box_gap (GtkStyle *style,
572 GtkStateType state_type,
573 GtkShadowType shadow_type,
578 GtkPositionType gap_side,
581 void gtk_draw_extension (GtkStyle *style,
583 GtkStateType state_type,
584 GtkShadowType shadow_type,
589 GtkPositionType gap_side);
590 void gtk_draw_focus (GtkStyle *style,
596 void gtk_draw_slider (GtkStyle *style,
598 GtkStateType state_type,
599 GtkShadowType shadow_type,
604 GtkOrientation orientation);
605 void gtk_draw_handle (GtkStyle *style,
607 GtkStateType state_type,
608 GtkShadowType shadow_type,
613 GtkOrientation orientation);
614 void gtk_draw_expander (GtkStyle *style,
616 GtkStateType state_type,
619 GtkExpanderStyle expander_style);
620 void gtk_draw_layout (GtkStyle *style,
622 GtkStateType state_type,
626 PangoLayout *layout);
627 void gtk_draw_resize_grip (GtkStyle *style,
629 GtkStateType state_type,
635 #endif /* GTK_DISABLE_DEPRECATED */
637 void gtk_paint_hline (GtkStyle *style,
639 GtkStateType state_type,
640 const GdkRectangle *area,
646 void gtk_paint_vline (GtkStyle *style,
648 GtkStateType state_type,
649 const GdkRectangle *area,
655 void gtk_paint_shadow (GtkStyle *style,
657 GtkStateType state_type,
658 GtkShadowType shadow_type,
659 const GdkRectangle *area,
666 void gtk_paint_polygon (GtkStyle *style,
668 GtkStateType state_type,
669 GtkShadowType shadow_type,
670 const GdkRectangle *area,
673 const GdkPoint *points,
676 void gtk_paint_arrow (GtkStyle *style,
678 GtkStateType state_type,
679 GtkShadowType shadow_type,
680 const GdkRectangle *area,
683 GtkArrowType arrow_type,
689 void gtk_paint_diamond (GtkStyle *style,
691 GtkStateType state_type,
692 GtkShadowType shadow_type,
693 const GdkRectangle *area,
700 void gtk_paint_box (GtkStyle *style,
702 GtkStateType state_type,
703 GtkShadowType shadow_type,
704 const GdkRectangle *area,
711 void gtk_paint_flat_box (GtkStyle *style,
713 GtkStateType state_type,
714 GtkShadowType shadow_type,
715 const GdkRectangle *area,
722 void gtk_paint_check (GtkStyle *style,
724 GtkStateType state_type,
725 GtkShadowType shadow_type,
726 const GdkRectangle *area,
733 void gtk_paint_option (GtkStyle *style,
735 GtkStateType state_type,
736 GtkShadowType shadow_type,
737 const GdkRectangle *area,
744 void gtk_paint_tab (GtkStyle *style,
746 GtkStateType state_type,
747 GtkShadowType shadow_type,
748 const GdkRectangle *area,
755 void gtk_paint_shadow_gap (GtkStyle *style,
757 GtkStateType state_type,
758 GtkShadowType shadow_type,
759 const GdkRectangle *area,
766 GtkPositionType gap_side,
769 void gtk_paint_box_gap (GtkStyle *style,
771 GtkStateType state_type,
772 GtkShadowType shadow_type,
773 const GdkRectangle *area,
780 GtkPositionType gap_side,
783 void gtk_paint_extension (GtkStyle *style,
785 GtkStateType state_type,
786 GtkShadowType shadow_type,
787 const GdkRectangle *area,
794 GtkPositionType gap_side);
795 void gtk_paint_focus (GtkStyle *style,
797 GtkStateType state_type,
798 const GdkRectangle *area,
805 void gtk_paint_slider (GtkStyle *style,
807 GtkStateType state_type,
808 GtkShadowType shadow_type,
809 const GdkRectangle *area,
816 GtkOrientation orientation);
817 void gtk_paint_handle (GtkStyle *style,
819 GtkStateType state_type,
820 GtkShadowType shadow_type,
821 const GdkRectangle *area,
828 GtkOrientation orientation);
829 void gtk_paint_expander (GtkStyle *style,
831 GtkStateType state_type,
832 const GdkRectangle *area,
837 GtkExpanderStyle expander_style);
838 void gtk_paint_layout (GtkStyle *style,
840 GtkStateType state_type,
842 const GdkRectangle *area,
847 PangoLayout *layout);
848 void gtk_paint_resize_grip (GtkStyle *style,
850 GtkStateType state_type,
851 const GdkRectangle *area,
861 GType gtk_border_get_type (void) G_GNUC_CONST;
862 GtkBorder *gtk_border_new (void) G_GNUC_MALLOC;
863 GtkBorder *gtk_border_copy (const GtkBorder *border_);
864 void gtk_border_free (GtkBorder *border_);
866 void gtk_style_get_style_property (GtkStyle *style,
868 const gchar *property_name,
870 void gtk_style_get_valist (GtkStyle *style,
872 const gchar *first_property_name,
874 void gtk_style_get (GtkStyle *style,
876 const gchar *first_property_name,
877 ...) G_GNUC_NULL_TERMINATED;
879 /* --- private API --- */
880 const GValue* _gtk_style_peek_property_value (GtkStyle *style,
883 GtkRcPropertyParser parser);
885 void _gtk_style_init_for_settings (GtkStyle *style,
886 GtkSettings *settings);
888 void _gtk_style_shade (const GdkColor *a,
893 #ifndef GTK_DISABLE_DEPRECATED
894 #define gtk_style_apply_default_pixmap(s,gw,st,a,x,y,w,h) gtk_style_apply_default_background (s,gw,1,st,a,x,y,w,h)
895 void gtk_draw_string (GtkStyle *style,
897 GtkStateType state_type,
900 const gchar *string);
901 void gtk_paint_string (GtkStyle *style,
903 GtkStateType state_type,
904 const GdkRectangle *area,
909 const gchar *string);
910 #endif /* GTK_DISABLE_DEPRECATED */
912 void gtk_draw_insertion_cursor (GtkWidget *widget,
913 GdkDrawable *drawable,
914 const GdkRectangle *area,
915 const GdkRectangle *location,
917 GtkTextDirection direction,
918 gboolean draw_arrow);
919 GdkGC *_gtk_widget_get_cursor_gc (GtkWidget *widget);
920 void _gtk_widget_get_cursor_color (GtkWidget *widget,
925 #endif /* __GTK_STYLE_H__ */