]> Pileus Git - ~andy/gtk/blob - gtk/gtkstylecontext.h
GtkStyleContext: Add gtk_style_context_new().
[~andy/gtk] / gtk / gtkstylecontext.h
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, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #ifndef __GTK_STYLE_CONTEXT_H__
21 #define __GTK_STYLE_CONTEXT_H__
22
23 #include <glib-object.h>
24 #include <gtk/gtkstyleprovider.h>
25 #include <gtk/gtkwidgetpath.h>
26
27 G_BEGIN_DECLS
28
29 #define GTK_TYPE_STYLE_CONTEXT         (gtk_style_context_get_type ())
30 #define GTK_STYLE_CONTEXT(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_STYLE_CONTEXT, GtkStyleContext))
31 #define GTK_STYLE_CONTEXT_CLASS(c)     (G_TYPE_CHECK_CLASS_CAST    ((c), GTK_TYPE_STYLE_CONTEXT, GtkStyleContextClass))
32 #define GTK_IS_STYLE_CONTEXT(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_STYLE_CONTEXT))
33 #define GTK_IS_STYLE_CONTEXT_CLASS(c)  (G_TYPE_CHECK_CLASS_TYPE    ((c), GTK_TYPE_STYLE_CONTEXT))
34 #define GTK_STYLE_CONTEXT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS  ((o), GTK_TYPE_STYLE_CONTEXT, GtkStyleContextClass))
35
36 typedef struct GtkStyleContext GtkStyleContext;
37 typedef struct GtkStyleContextClass GtkStyleContextClass;
38
39 struct GtkStyleContext
40 {
41   GObject parent_object;
42   gpointer priv;
43 };
44
45 struct GtkStyleContextClass
46 {
47   GObjectClass parent_class;
48
49   void (* changed) (GtkStyleContext *context);
50 };
51
52 GType gtk_style_context_get_type (void) G_GNUC_CONST;
53
54 GtkStyleContext * gtk_style_context_new (void);
55
56 void gtk_style_context_add_provider_for_screen    (GdkScreen        *screen,
57                                                    GtkStyleProvider *provider,
58                                                    guint             priority);
59 void gtk_style_context_remove_provider_for_screen (GdkScreen        *screen,
60                                                    GtkStyleProvider *provider);
61
62 void gtk_style_context_add_provider    (GtkStyleContext  *context,
63                                         GtkStyleProvider *provider,
64                                         guint             priority);
65
66 void gtk_style_context_remove_provider (GtkStyleContext  *context,
67                                         GtkStyleProvider *provider);
68
69 void gtk_style_context_save    (GtkStyleContext *context);
70 void gtk_style_context_restore (GtkStyleContext *context);
71
72 void gtk_style_context_get_property (GtkStyleContext *context,
73                                      const gchar     *property,
74                                      GtkStateFlags    state,
75                                      GValue          *value);
76 void gtk_style_context_get_valist   (GtkStyleContext *context,
77                                      GtkStateFlags    state,
78                                      va_list          args);
79 void gtk_style_context_get          (GtkStyleContext *context,
80                                      GtkStateFlags    state,
81                                      ...) G_GNUC_NULL_TERMINATED;
82
83 void          gtk_style_context_set_state    (GtkStyleContext *context,
84                                               GtkStateFlags    flags);
85 GtkStateFlags gtk_style_context_get_state    (GtkStyleContext *context);
86
87 gboolean      gtk_style_context_is_state_set (GtkStyleContext *context,
88                                               GtkStateType     state,
89                                               gdouble         *progress);
90
91 void          gtk_style_context_set_path     (GtkStyleContext *context,
92                                               GtkWidgetPath   *path);
93 G_CONST_RETURN GtkWidgetPath * gtk_style_context_get_path (GtkStyleContext *context);
94
95 GList *  gtk_style_context_list_classes (GtkStyleContext *context);
96
97 void     gtk_style_context_set_class   (GtkStyleContext *context,
98                                         const gchar     *class_name);
99 void     gtk_style_context_unset_class (GtkStyleContext *context,
100                                         const gchar     *class_name);
101 gboolean gtk_style_context_has_class   (GtkStyleContext *context,
102                                         const gchar     *class_name);
103
104 GList *  gtk_style_context_list_regions (GtkStyleContext *context);
105
106 void     gtk_style_context_set_region   (GtkStyleContext    *context,
107                                          const gchar        *region_name,
108                                          GtkRegionFlags      flags);
109 void     gtk_style_context_unset_region (GtkStyleContext    *context,
110                                          const gchar        *region_name);
111 gboolean gtk_style_context_has_region   (GtkStyleContext    *context,
112                                          const gchar        *region_name,
113                                          GtkRegionFlags     *flags_return);
114
115 void gtk_style_context_get_style_property (GtkStyleContext *context,
116                                            const gchar     *property_name,
117                                            GValue          *value);
118 void gtk_style_context_get_style_valist   (GtkStyleContext *context,
119                                            va_list          args);
120 void gtk_style_context_get_style          (GtkStyleContext *context,
121                                            ...);
122
123 GtkIconSet * gtk_style_context_lookup_icon_set (GtkStyleContext *context,
124                                                 const gchar     *stock_id);
125
126 void        gtk_style_context_set_screen (GtkStyleContext *context,
127                                           GdkScreen       *screen);
128 GdkScreen * gtk_style_context_get_screen (GtkStyleContext *context);
129
130 void             gtk_style_context_set_direction (GtkStyleContext  *context,
131                                                   GtkTextDirection  direction);
132 GtkTextDirection gtk_style_context_get_direction (GtkStyleContext  *context);
133
134 void             gtk_style_context_set_junction_sides (GtkStyleContext  *context,
135                                                        GtkJunctionSides  sides);
136 GtkJunctionSides gtk_style_context_get_junction_sides (GtkStyleContext  *context);
137
138 gboolean gtk_style_context_lookup_color (GtkStyleContext *context,
139                                          const gchar     *color_name,
140                                          GdkColor        *color);
141
142 void  gtk_style_context_notify_state_change (GtkStyleContext *context,
143                                              GdkWindow       *window,
144                                              gpointer         region_id,
145                                              GtkStateType     state,
146                                              gboolean         state_value);
147 void gtk_style_context_push_animatable_region (GtkStyleContext *context,
148                                                gpointer         region_id);
149 void gtk_style_context_pop_animatable_region  (GtkStyleContext *context);
150
151
152 /* Semi-private API */
153 const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context,
154                                                        GType            widget_type,
155                                                        GParamSpec      *pspec);
156 void           _gtk_style_context_invalidate_animation_areas (GtkStyleContext *context);
157 void           _gtk_style_context_coalesce_animation_areas   (GtkStyleContext *context,
158                                                               gint             rel_x,
159                                                               gint             rel_y);
160
161 /* Animation for state changes */
162 void gtk_style_context_state_transition_start  (GtkStyleContext *context,
163                                                 gpointer         identifier,
164                                                 GtkWidget       *widget,
165                                                 GtkStateType     state,
166                                                 gboolean         value,
167                                                 GdkRectangle    *rect);
168 void gtk_style_context_state_transition_update (GtkStyleContext *context,
169                                                 gpointer         identifier,
170                                                 GdkRectangle    *rect,
171                                                 GtkStateType     state);
172 void gtk_style_context_state_transition_stop   (GtkStyleContext *context,
173                                                 gpointer         identifier);
174
175 void gtk_style_context_invalidate (GtkStyleContext *context);
176 void gtk_style_context_reset_widgets (GdkScreen *screen);
177
178 /* Paint methods */
179 void gtk_render_check (GtkStyleContext *context,
180                        cairo_t         *cr,
181                        gdouble          x,
182                        gdouble          y,
183                        gdouble          width,
184                        gdouble          height);
185 void gtk_render_option (GtkStyleContext *context,
186                         cairo_t         *cr,
187                         gdouble          x,
188                         gdouble          y,
189                         gdouble          width,
190                         gdouble          height);
191 void gtk_render_arrow  (GtkStyleContext *context,
192                         cairo_t         *cr,
193                         gdouble          angle,
194                         gdouble          x,
195                         gdouble          y,
196                         gdouble          size);
197 void gtk_render_background (GtkStyleContext *context,
198                             cairo_t         *cr,
199                             gdouble          x,
200                             gdouble          y,
201                             gdouble          width,
202                             gdouble          height);
203 void gtk_render_frame  (GtkStyleContext *context,
204                         cairo_t         *cr,
205                         gdouble          x,
206                         gdouble          y,
207                         gdouble          width,
208                         gdouble          height);
209 void gtk_render_expander (GtkStyleContext *context,
210                           cairo_t         *cr,
211                           gdouble          x,
212                           gdouble          y,
213                           gdouble          width,
214                           gdouble          height);
215 void gtk_render_focus    (GtkStyleContext *context,
216                           cairo_t         *cr,
217                           gdouble          x,
218                           gdouble          y,
219                           gdouble          width,
220                           gdouble          height);
221 void gtk_render_layout   (GtkStyleContext *context,
222                           cairo_t         *cr,
223                           gdouble          x,
224                           gdouble          y,
225                           PangoLayout     *layout);
226 void gtk_render_line     (GtkStyleContext *context,
227                           cairo_t         *cr,
228                           gdouble          x0,
229                           gdouble          y0,
230                           gdouble          x1,
231                           gdouble          y1);
232 void gtk_render_slider   (GtkStyleContext *context,
233                           cairo_t         *cr,
234                           gdouble          x,
235                           gdouble          y,
236                           gdouble          width,
237                           gdouble          height,
238                           GtkOrientation   orientation);
239 void gtk_render_frame_gap (GtkStyleContext *context,
240                            cairo_t         *cr,
241                            gdouble          x,
242                            gdouble          y,
243                            gdouble          width,
244                            gdouble          height,
245                            GtkPositionType  gap_side,
246                            gdouble          xy0_gap,
247                            gdouble          xy1_gap);
248 void gtk_render_extension (GtkStyleContext *context,
249                            cairo_t         *cr,
250                            gdouble          x,
251                            gdouble          y,
252                            gdouble          width,
253                            gdouble          height,
254                            GtkPositionType  gap_side);
255 void gtk_render_handle    (GtkStyleContext *context,
256                            cairo_t         *cr,
257                            gdouble          x,
258                            gdouble          y,
259                            gdouble          width,
260                            gdouble          height);
261 void gtk_render_progress  (GtkStyleContext *context,
262                            cairo_t         *cr,
263                            gdouble          x,
264                            gdouble          y,
265                            gdouble          width,
266                            gdouble          height);
267
268 G_END_DECLS
269
270 #endif /* __GTK_STYLE_CONTEXT_H__ */