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;
73 * @style: a #GtkStyle.
75 * Returns whether the style is attached to a window.
77 #define GTK_STYLE_ATTACHED(style) (GTK_STYLE (style)->attach_count > 0)
81 GObject parent_instance;
92 GdkColor text_aa[5]; /* Halfway between text/base */
96 PangoFontDescription *font_desc;
101 cairo_pattern_t *background[5];
108 PangoFontDescription *private_font_desc; /* Font description for style->private_font or %NULL */
110 /* the RcStyle from which this style was created */
111 GtkRcStyle *rc_style;
113 GSList *styles; /* of type GtkStyle* */
114 GArray *property_cache;
115 GSList *icon_factories; /* of type GtkIconFactory* */
118 struct _GtkStyleClass
120 GObjectClass parent_class;
122 /* Initialize for a particular visual. style->visual
123 * will have been set at this point. Will typically chain
126 void (*realize) (GtkStyle *style);
128 /* Clean up for a particular visual. Will typically chain
131 void (*unrealize) (GtkStyle *style);
133 /* Make style an exact duplicate of src.
135 void (*copy) (GtkStyle *style,
138 /* Create an empty style of the same type as this style.
139 * The default implementation, which does
140 * g_object_new (G_OBJECT_TYPE (style), NULL);
141 * should work in most cases.
143 GtkStyle *(*clone) (GtkStyle *style);
145 /* Initialize the GtkStyle with the values in the GtkRcStyle.
146 * should chain to the parent implementation.
148 void (*init_from_rc) (GtkStyle *style,
149 GtkRcStyle *rc_style);
151 void (*set_background) (GtkStyle *style,
153 GtkStateType state_type);
156 GdkPixbuf * (* render_icon) (GtkStyle *style,
157 const GtkIconSource *source,
158 GtkTextDirection direction,
162 const gchar *detail);
167 void (*draw_hline) (GtkStyle *style,
169 GtkStateType state_type,
175 void (*draw_vline) (GtkStyle *style,
177 GtkStateType state_type,
183 void (*draw_shadow) (GtkStyle *style,
185 GtkStateType state_type,
186 GtkShadowType shadow_type,
193 void (*draw_arrow) (GtkStyle *style,
195 GtkStateType state_type,
196 GtkShadowType shadow_type,
199 GtkArrowType arrow_type,
205 void (*draw_diamond) (GtkStyle *style,
207 GtkStateType state_type,
208 GtkShadowType shadow_type,
215 void (*draw_box) (GtkStyle *style,
217 GtkStateType state_type,
218 GtkShadowType shadow_type,
225 void (*draw_flat_box) (GtkStyle *style,
227 GtkStateType state_type,
228 GtkShadowType shadow_type,
235 void (*draw_check) (GtkStyle *style,
237 GtkStateType state_type,
238 GtkShadowType shadow_type,
245 void (*draw_option) (GtkStyle *style,
247 GtkStateType state_type,
248 GtkShadowType shadow_type,
255 void (*draw_tab) (GtkStyle *style,
257 GtkStateType state_type,
258 GtkShadowType shadow_type,
265 void (*draw_shadow_gap) (GtkStyle *style,
267 GtkStateType state_type,
268 GtkShadowType shadow_type,
275 GtkPositionType gap_side,
278 void (*draw_box_gap) (GtkStyle *style,
280 GtkStateType state_type,
281 GtkShadowType shadow_type,
288 GtkPositionType gap_side,
291 void (*draw_extension) (GtkStyle *style,
293 GtkStateType state_type,
294 GtkShadowType shadow_type,
301 GtkPositionType gap_side);
302 void (*draw_focus) (GtkStyle *style,
304 GtkStateType state_type,
311 void (*draw_slider) (GtkStyle *style,
313 GtkStateType state_type,
314 GtkShadowType shadow_type,
321 GtkOrientation orientation);
322 void (*draw_handle) (GtkStyle *style,
324 GtkStateType state_type,
325 GtkShadowType shadow_type,
332 GtkOrientation orientation);
334 void (*draw_expander) (GtkStyle *style,
336 GtkStateType state_type,
341 GtkExpanderStyle expander_style);
342 void (*draw_layout) (GtkStyle *style,
344 GtkStateType state_type,
350 PangoLayout *layout);
351 void (*draw_resize_grip) (GtkStyle *style,
353 GtkStateType state_type,
361 void (*draw_spinner) (GtkStyle *style,
363 GtkStateType state_type,
372 /* Padding for future expansion */
373 void (*_gtk_reserved1) (void);
374 void (*_gtk_reserved2) (void);
375 void (*_gtk_reserved3) (void);
376 void (*_gtk_reserved4) (void);
377 void (*_gtk_reserved5) (void);
378 void (*_gtk_reserved6) (void);
379 void (*_gtk_reserved7) (void);
380 void (*_gtk_reserved8) (void);
381 void (*_gtk_reserved9) (void);
382 void (*_gtk_reserved10) (void);
383 void (*_gtk_reserved11) (void);
388 * @left: The width of the left border.
389 * @right: The width of the right border.
390 * @top: The width of the top border.
391 * @bottom: The width of the bottom border.
393 * A struct that specifies a border around a rectangular area that can
394 * be of different width on each side.
404 GType gtk_style_get_type (void) G_GNUC_CONST;
405 GtkStyle* gtk_style_new (void);
406 GtkStyle* gtk_style_copy (GtkStyle *style);
407 GtkStyle* gtk_style_attach (GtkStyle *style,
408 GdkWindow *window) G_GNUC_WARN_UNUSED_RESULT;
409 void gtk_style_detach (GtkStyle *style);
410 void gtk_style_set_background (GtkStyle *style,
412 GtkStateType state_type);
413 void gtk_style_apply_default_background (GtkStyle *style,
416 GtkStateType state_type,
422 GtkIconSet* gtk_style_lookup_icon_set (GtkStyle *style,
423 const gchar *stock_id);
424 gboolean gtk_style_lookup_color (GtkStyle *style,
425 const gchar *color_name,
428 GdkPixbuf* gtk_style_render_icon (GtkStyle *style,
429 const GtkIconSource *source,
430 GtkTextDirection direction,
434 const gchar *detail);
436 void gtk_paint_hline (GtkStyle *style,
438 GtkStateType state_type,
444 void gtk_paint_vline (GtkStyle *style,
446 GtkStateType state_type,
452 void gtk_paint_shadow (GtkStyle *style,
454 GtkStateType state_type,
455 GtkShadowType shadow_type,
462 void gtk_paint_arrow (GtkStyle *style,
464 GtkStateType state_type,
465 GtkShadowType shadow_type,
468 GtkArrowType arrow_type,
474 void gtk_paint_diamond (GtkStyle *style,
476 GtkStateType state_type,
477 GtkShadowType shadow_type,
484 void gtk_paint_box (GtkStyle *style,
486 GtkStateType state_type,
487 GtkShadowType shadow_type,
494 void gtk_paint_flat_box (GtkStyle *style,
496 GtkStateType state_type,
497 GtkShadowType shadow_type,
504 void gtk_paint_check (GtkStyle *style,
506 GtkStateType state_type,
507 GtkShadowType shadow_type,
514 void gtk_paint_option (GtkStyle *style,
516 GtkStateType state_type,
517 GtkShadowType shadow_type,
524 void gtk_paint_tab (GtkStyle *style,
526 GtkStateType state_type,
527 GtkShadowType shadow_type,
534 void gtk_paint_shadow_gap (GtkStyle *style,
536 GtkStateType state_type,
537 GtkShadowType shadow_type,
544 GtkPositionType gap_side,
547 void gtk_paint_box_gap (GtkStyle *style,
549 GtkStateType state_type,
550 GtkShadowType shadow_type,
557 GtkPositionType gap_side,
560 void gtk_paint_extension (GtkStyle *style,
562 GtkStateType state_type,
563 GtkShadowType shadow_type,
570 GtkPositionType gap_side);
571 void gtk_paint_focus (GtkStyle *style,
573 GtkStateType state_type,
580 void gtk_paint_slider (GtkStyle *style,
582 GtkStateType state_type,
583 GtkShadowType shadow_type,
590 GtkOrientation orientation);
591 void gtk_paint_handle (GtkStyle *style,
593 GtkStateType state_type,
594 GtkShadowType shadow_type,
601 GtkOrientation orientation);
602 void gtk_paint_expander (GtkStyle *style,
604 GtkStateType state_type,
609 GtkExpanderStyle expander_style);
610 void gtk_paint_layout (GtkStyle *style,
612 GtkStateType state_type,
618 PangoLayout *layout);
619 void gtk_paint_resize_grip (GtkStyle *style,
621 GtkStateType state_type,
629 void gtk_paint_spinner (GtkStyle *style,
631 GtkStateType state_type,
641 GType gtk_border_get_type (void) G_GNUC_CONST;
642 GtkBorder *gtk_border_new (void) G_GNUC_MALLOC;
643 GtkBorder *gtk_border_copy (const GtkBorder *border_);
644 void gtk_border_free (GtkBorder *border_);
646 void gtk_style_get_style_property (GtkStyle *style,
648 const gchar *property_name,
650 void gtk_style_get_valist (GtkStyle *style,
652 const gchar *first_property_name,
654 void gtk_style_get (GtkStyle *style,
656 const gchar *first_property_name,
657 ...) G_GNUC_NULL_TERMINATED;
659 /* --- private API --- */
660 const GValue* _gtk_style_peek_property_value (GtkStyle *style,
663 GtkRcPropertyParser parser);
665 void _gtk_style_init_for_settings (GtkStyle *style,
666 GtkSettings *settings);
668 void _gtk_style_shade (const GdkColor *a,
672 void gtk_draw_insertion_cursor (GtkWidget *widget,
674 const GdkRectangle *location,
676 GtkTextDirection direction,
677 gboolean draw_arrow);
678 void _gtk_widget_get_cursor_color (GtkWidget *widget,
683 #endif /* __GTK_STYLE_H__ */