1/* GTK - The GIMP Toolkit
2 * Copyright (C) 2010 Carlos Garnacho <carlosg@gnome.org>
3 *
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.
8 *
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.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef __GTK_STYLE_CONTEXT_H__
19#define __GTK_STYLE_CONTEXT_H__
20
21#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
22#error "Only <gtk/gtk.h> can be included directly."
23#endif
24
25#include <gtk/css/gtkcss.h>
26
27#include <gtk/gtkborder.h>
28#include <gtk/gtkstyleprovider.h>
29#include <gtk/gtktypes.h>
30
31G_BEGIN_DECLS
32
33#define GTK_TYPE_STYLE_CONTEXT (gtk_style_context_get_type ())
34#define GTK_STYLE_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_STYLE_CONTEXT, GtkStyleContext))
35#define GTK_STYLE_CONTEXT_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GTK_TYPE_STYLE_CONTEXT, GtkStyleContextClass))
36#define GTK_IS_STYLE_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_STYLE_CONTEXT))
37#define GTK_IS_STYLE_CONTEXT_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GTK_TYPE_STYLE_CONTEXT))
38#define GTK_STYLE_CONTEXT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_STYLE_CONTEXT, GtkStyleContextClass))
39
40typedef struct _GtkStyleContextClass GtkStyleContextClass;
41
42struct _GtkStyleContext
43{
44 GObject parent_object;
45};
46
47struct _GtkStyleContextClass
48{
49 GObjectClass parent_class;
50
51 void (* changed) (GtkStyleContext *context);
52
53 /* Padding for future expansion */
54 void (*_gtk_reserved1) (void);
55 void (*_gtk_reserved2) (void);
56 void (*_gtk_reserved3) (void);
57 void (*_gtk_reserved4) (void);
58};
59
60
61GDK_AVAILABLE_IN_ALL
62GType gtk_style_context_get_type (void) G_GNUC_CONST;
63
64GDK_AVAILABLE_IN_ALL
65void gtk_style_context_add_provider_for_display (GdkDisplay *display,
66 GtkStyleProvider *provider,
67 guint priority);
68GDK_AVAILABLE_IN_ALL
69void gtk_style_context_remove_provider_for_display (GdkDisplay *display,
70 GtkStyleProvider *provider);
71
72GDK_AVAILABLE_IN_ALL
73void gtk_style_context_add_provider (GtkStyleContext *context,
74 GtkStyleProvider *provider,
75 guint priority);
76
77GDK_AVAILABLE_IN_ALL
78void gtk_style_context_remove_provider (GtkStyleContext *context,
79 GtkStyleProvider *provider);
80
81GDK_AVAILABLE_IN_ALL
82void gtk_style_context_save (GtkStyleContext *context);
83GDK_AVAILABLE_IN_ALL
84void gtk_style_context_restore (GtkStyleContext *context);
85
86GDK_AVAILABLE_IN_ALL
87void gtk_style_context_set_state (GtkStyleContext *context,
88 GtkStateFlags flags);
89GDK_AVAILABLE_IN_ALL
90GtkStateFlags gtk_style_context_get_state (GtkStyleContext *context);
91
92GDK_AVAILABLE_IN_ALL
93void gtk_style_context_set_scale (GtkStyleContext *context,
94 int scale);
95GDK_AVAILABLE_IN_ALL
96int gtk_style_context_get_scale (GtkStyleContext *context);
97
98GDK_AVAILABLE_IN_ALL
99void gtk_style_context_add_class (GtkStyleContext *context,
100 const char *class_name);
101GDK_AVAILABLE_IN_ALL
102void gtk_style_context_remove_class (GtkStyleContext *context,
103 const char *class_name);
104GDK_AVAILABLE_IN_ALL
105gboolean gtk_style_context_has_class (GtkStyleContext *context,
106 const char *class_name);
107
108GDK_AVAILABLE_IN_ALL
109void gtk_style_context_set_display (GtkStyleContext *context,
110 GdkDisplay *display);
111GDK_AVAILABLE_IN_ALL
112GdkDisplay *gtk_style_context_get_display (GtkStyleContext *context);
113
114GDK_AVAILABLE_IN_ALL
115gboolean gtk_style_context_lookup_color (GtkStyleContext *context,
116 const char *color_name,
117 GdkRGBA *color);
118
119/* Some helper functions to retrieve most common properties */
120GDK_AVAILABLE_IN_ALL
121void gtk_style_context_get_color (GtkStyleContext *context,
122 GdkRGBA *color);
123GDK_AVAILABLE_IN_ALL
124void gtk_style_context_get_border (GtkStyleContext *context,
125 GtkBorder *border);
126GDK_AVAILABLE_IN_ALL
127void gtk_style_context_get_padding (GtkStyleContext *context,
128 GtkBorder *padding);
129GDK_AVAILABLE_IN_ALL
130void gtk_style_context_get_margin (GtkStyleContext *context,
131 GtkBorder *margin);
132
133typedef enum {
134 GTK_STYLE_CONTEXT_PRINT_NONE = 0,
135 GTK_STYLE_CONTEXT_PRINT_RECURSE = 1 << 0,
136 GTK_STYLE_CONTEXT_PRINT_SHOW_STYLE = 1 << 1,
137 GTK_STYLE_CONTEXT_PRINT_SHOW_CHANGE = 1 << 2
138} GtkStyleContextPrintFlags;
139
140GDK_AVAILABLE_IN_ALL
141char * gtk_style_context_to_string (GtkStyleContext *context,
142 GtkStyleContextPrintFlags flags);
143
144G_END_DECLS
145
146#endif /* __GTK_STYLE_CONTEXT_H__ */
147

source code of gtk/gtk/gtkstylecontext.h