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_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,
406 void (*draw_spinner) (GtkStyle *style,
408 GtkStateType state_type,
418 /* Padding for future expansion */
419 void (*_gtk_reserved1) (void);
420 void (*_gtk_reserved2) (void);
421 void (*_gtk_reserved3) (void);
422 void (*_gtk_reserved4) (void);
423 void (*_gtk_reserved5) (void);
424 void (*_gtk_reserved6) (void);
425 void (*_gtk_reserved7) (void);
426 void (*_gtk_reserved8) (void);
427 void (*_gtk_reserved9) (void);
428 void (*_gtk_reserved10) (void);
429 void (*_gtk_reserved11) (void);
440 GType gtk_style_get_type (void) G_GNUC_CONST;
441 GtkStyle* gtk_style_new (void);
442 GtkStyle* gtk_style_copy (GtkStyle *style);
443 GtkStyle* gtk_style_attach (GtkStyle *style,
444 GdkWindow *window) G_GNUC_WARN_UNUSED_RESULT;
445 void gtk_style_detach (GtkStyle *style);
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 void gtk_paint_hline (GtkStyle *style,
475 GtkStateType state_type,
476 const GdkRectangle *area,
482 void gtk_paint_vline (GtkStyle *style,
484 GtkStateType state_type,
485 const GdkRectangle *area,
491 void gtk_paint_shadow (GtkStyle *style,
493 GtkStateType state_type,
494 GtkShadowType shadow_type,
495 const GdkRectangle *area,
502 void gtk_paint_polygon (GtkStyle *style,
504 GtkStateType state_type,
505 GtkShadowType shadow_type,
506 const GdkRectangle *area,
509 const GdkPoint *points,
512 void gtk_paint_arrow (GtkStyle *style,
514 GtkStateType state_type,
515 GtkShadowType shadow_type,
516 const GdkRectangle *area,
519 GtkArrowType arrow_type,
525 void gtk_paint_diamond (GtkStyle *style,
527 GtkStateType state_type,
528 GtkShadowType shadow_type,
529 const GdkRectangle *area,
536 void gtk_paint_box (GtkStyle *style,
538 GtkStateType state_type,
539 GtkShadowType shadow_type,
540 const GdkRectangle *area,
547 void gtk_paint_flat_box (GtkStyle *style,
549 GtkStateType state_type,
550 GtkShadowType shadow_type,
551 const GdkRectangle *area,
558 void gtk_paint_check (GtkStyle *style,
560 GtkStateType state_type,
561 GtkShadowType shadow_type,
562 const GdkRectangle *area,
569 void gtk_paint_option (GtkStyle *style,
571 GtkStateType state_type,
572 GtkShadowType shadow_type,
573 const GdkRectangle *area,
580 void gtk_paint_tab (GtkStyle *style,
582 GtkStateType state_type,
583 GtkShadowType shadow_type,
584 const GdkRectangle *area,
591 void gtk_paint_shadow_gap (GtkStyle *style,
593 GtkStateType state_type,
594 GtkShadowType shadow_type,
595 const GdkRectangle *area,
602 GtkPositionType gap_side,
605 void gtk_paint_box_gap (GtkStyle *style,
607 GtkStateType state_type,
608 GtkShadowType shadow_type,
609 const GdkRectangle *area,
616 GtkPositionType gap_side,
619 void gtk_paint_extension (GtkStyle *style,
621 GtkStateType state_type,
622 GtkShadowType shadow_type,
623 const GdkRectangle *area,
630 GtkPositionType gap_side);
631 void gtk_paint_focus (GtkStyle *style,
633 GtkStateType state_type,
634 const GdkRectangle *area,
641 void gtk_paint_slider (GtkStyle *style,
643 GtkStateType state_type,
644 GtkShadowType shadow_type,
645 const GdkRectangle *area,
652 GtkOrientation orientation);
653 void gtk_paint_handle (GtkStyle *style,
655 GtkStateType state_type,
656 GtkShadowType shadow_type,
657 const GdkRectangle *area,
664 GtkOrientation orientation);
665 void gtk_paint_expander (GtkStyle *style,
667 GtkStateType state_type,
668 const GdkRectangle *area,
673 GtkExpanderStyle expander_style);
674 void gtk_paint_layout (GtkStyle *style,
676 GtkStateType state_type,
678 const GdkRectangle *area,
683 PangoLayout *layout);
684 void gtk_paint_resize_grip (GtkStyle *style,
686 GtkStateType state_type,
687 const GdkRectangle *area,
695 void gtk_paint_spinner (GtkStyle *style,
697 GtkStateType state_type,
698 const GdkRectangle *area,
707 GType gtk_border_get_type (void) G_GNUC_CONST;
708 GtkBorder *gtk_border_new (void) G_GNUC_MALLOC;
709 GtkBorder *gtk_border_copy (const GtkBorder *border_);
710 void gtk_border_free (GtkBorder *border_);
712 void gtk_style_get_style_property (GtkStyle *style,
714 const gchar *property_name,
716 void gtk_style_get_valist (GtkStyle *style,
718 const gchar *first_property_name,
720 void gtk_style_get (GtkStyle *style,
722 const gchar *first_property_name,
723 ...) G_GNUC_NULL_TERMINATED;
725 /* --- private API --- */
726 const GValue* _gtk_style_peek_property_value (GtkStyle *style,
729 GtkRcPropertyParser parser);
731 void _gtk_style_init_for_settings (GtkStyle *style,
732 GtkSettings *settings);
734 void _gtk_style_shade (const GdkColor *a,
738 void gtk_draw_insertion_cursor (GtkWidget *widget,
739 GdkDrawable *drawable,
740 const GdkRectangle *area,
741 const GdkRectangle *location,
743 GtkTextDirection direction,
744 gboolean draw_arrow);
745 GdkGC *_gtk_widget_get_cursor_gc (GtkWidget *widget);
746 void _gtk_widget_get_cursor_color (GtkWidget *widget,
751 #endif /* __GTK_STYLE_H__ */