]> Pileus Git - ~andy/gtk/blob - gtk/gtkstylecontext.h
GtkStyleContext: Fix animation framework to work with the new draw() semantics.
[~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 void gtk_style_context_add_provider_for_screen    (GdkScreen        *screen,
55                                                    GtkStyleProvider *provider,
56                                                    guint             priority);
57 void gtk_style_context_remove_provider_for_screen (GdkScreen        *screen,
58                                                    GtkStyleProvider *provider);
59
60 void gtk_style_context_add_provider    (GtkStyleContext  *context,
61                                         GtkStyleProvider *provider,
62                                         guint             priority);
63
64 void gtk_style_context_remove_provider (GtkStyleContext  *context,
65                                         GtkStyleProvider *provider);
66
67 void gtk_style_context_save    (GtkStyleContext *context);
68 void gtk_style_context_restore (GtkStyleContext *context);
69
70 void gtk_style_context_get_property (GtkStyleContext *context,
71                                      const gchar     *property,
72                                      GtkStateFlags    state,
73                                      GValue          *value);
74 void gtk_style_context_get_valist   (GtkStyleContext *context,
75                                      GtkStateFlags    state,
76                                      va_list          args);
77 void gtk_style_context_get          (GtkStyleContext *context,
78                                      GtkStateFlags    state,
79                                      ...) G_GNUC_NULL_TERMINATED;
80
81 void          gtk_style_context_set_state    (GtkStyleContext *context,
82                                               GtkStateFlags    flags);
83 GtkStateFlags gtk_style_context_get_state    (GtkStyleContext *context);
84
85 gboolean      gtk_style_context_is_state_set (GtkStyleContext *context,
86                                               GtkStateType     state,
87                                               gdouble         *progress);
88
89 void          gtk_style_context_set_path     (GtkStyleContext *context,
90                                               GtkWidgetPath   *path);
91 G_CONST_RETURN GtkWidgetPath * gtk_style_context_get_path (GtkStyleContext *context);
92
93 GList *  gtk_style_context_list_classes (GtkStyleContext *context);
94
95 void     gtk_style_context_set_class   (GtkStyleContext *context,
96                                         const gchar     *class_name);
97 void     gtk_style_context_unset_class (GtkStyleContext *context,
98                                         const gchar     *class_name);
99 gboolean gtk_style_context_has_class   (GtkStyleContext *context,
100                                         const gchar     *class_name);
101
102 GList *  gtk_style_context_list_regions (GtkStyleContext *context);
103
104 void     gtk_style_context_set_region   (GtkStyleContext    *context,
105                                          const gchar        *region_name,
106                                          GtkRegionFlags      flags);
107 void     gtk_style_context_unset_region (GtkStyleContext    *context,
108                                          const gchar        *region_name);
109 gboolean gtk_style_context_has_region   (GtkStyleContext    *context,
110                                          const gchar        *region_name,
111                                          GtkRegionFlags     *flags_return);
112
113 void gtk_style_context_get_style_property (GtkStyleContext *context,
114                                            const gchar     *property_name,
115                                            GValue          *value);
116 void gtk_style_context_get_style_valist   (GtkStyleContext *context,
117                                            va_list          args);
118 void gtk_style_context_get_style          (GtkStyleContext *context,
119                                            ...);
120
121 GtkIconSet * gtk_style_context_lookup_icon_set (GtkStyleContext *context,
122                                                 const gchar     *stock_id);
123
124 void        gtk_style_context_set_screen (GtkStyleContext *context,
125                                           GdkScreen       *screen);
126 GdkScreen * gtk_style_context_get_screen (GtkStyleContext *context);
127
128 void             gtk_style_context_set_direction (GtkStyleContext  *context,
129                                                   GtkTextDirection  direction);
130 GtkTextDirection gtk_style_context_get_direction (GtkStyleContext  *context);
131
132 void             gtk_style_context_set_junction_sides (GtkStyleContext  *context,
133                                                        GtkJunctionSides  sides);
134 GtkJunctionSides gtk_style_context_get_junction_sides (GtkStyleContext  *context);
135
136 gboolean gtk_style_context_lookup_color (GtkStyleContext *context,
137                                          const gchar     *color_name,
138                                          GdkColor        *color);
139
140 void  gtk_style_context_notify_state_change (GtkStyleContext *context,
141                                              GdkWindow       *window,
142                                              gpointer         region_id,
143                                              GtkStateType     state,
144                                              gboolean         state_value);
145 void gtk_style_context_push_animatable_region (GtkStyleContext *context,
146                                                gpointer         region_id);
147 void gtk_style_context_pop_animatable_region  (GtkStyleContext *context);
148
149
150 /* Semi-private API */
151 const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context,
152                                                        GType            widget_type,
153                                                        GParamSpec      *pspec);
154 void           _gtk_style_context_invalidate_animation_areas (GtkStyleContext *context);
155 void           _gtk_style_context_coalesce_animation_areas   (GtkStyleContext *context,
156                                                               gint             rel_x,
157                                                               gint             rel_y);
158
159 /* Animation for state changes */
160 void gtk_style_context_state_transition_start  (GtkStyleContext *context,
161                                                 gpointer         identifier,
162                                                 GtkWidget       *widget,
163                                                 GtkStateType     state,
164                                                 gboolean         value,
165                                                 GdkRectangle    *rect);
166 void gtk_style_context_state_transition_update (GtkStyleContext *context,
167                                                 gpointer         identifier,
168                                                 GdkRectangle    *rect,
169                                                 GtkStateType     state);
170 void gtk_style_context_state_transition_stop   (GtkStyleContext *context,
171                                                 gpointer         identifier);
172
173 void gtk_style_context_invalidate (GtkStyleContext *context);
174 void gtk_style_context_reset_widgets (GdkScreen *screen);
175
176 /* Paint methods */
177 void gtk_render_check (GtkStyleContext *context,
178                        cairo_t         *cr,
179                        gdouble          x,
180                        gdouble          y,
181                        gdouble          width,
182                        gdouble          height);
183 void gtk_render_option (GtkStyleContext *context,
184                         cairo_t         *cr,
185                         gdouble          x,
186                         gdouble          y,
187                         gdouble          width,
188                         gdouble          height);
189 void gtk_render_arrow  (GtkStyleContext *context,
190                         cairo_t         *cr,
191                         gdouble          angle,
192                         gdouble          x,
193                         gdouble          y,
194                         gdouble          size);
195 void gtk_render_background (GtkStyleContext *context,
196                             cairo_t         *cr,
197                             gdouble          x,
198                             gdouble          y,
199                             gdouble          width,
200                             gdouble          height);
201 void gtk_render_frame  (GtkStyleContext *context,
202                         cairo_t         *cr,
203                         gdouble          x,
204                         gdouble          y,
205                         gdouble          width,
206                         gdouble          height);
207 void gtk_render_expander (GtkStyleContext *context,
208                           cairo_t         *cr,
209                           gdouble          x,
210                           gdouble          y,
211                           gdouble          width,
212                           gdouble          height);
213 void gtk_render_focus    (GtkStyleContext *context,
214                           cairo_t         *cr,
215                           gdouble          x,
216                           gdouble          y,
217                           gdouble          width,
218                           gdouble          height);
219 void gtk_render_layout   (GtkStyleContext *context,
220                           cairo_t         *cr,
221                           gdouble          x,
222                           gdouble          y,
223                           PangoLayout     *layout);
224 void gtk_render_line     (GtkStyleContext *context,
225                           cairo_t         *cr,
226                           gdouble          x0,
227                           gdouble          y0,
228                           gdouble          x1,
229                           gdouble          y1);
230 void gtk_render_slider   (GtkStyleContext *context,
231                           cairo_t         *cr,
232                           gdouble          x,
233                           gdouble          y,
234                           gdouble          width,
235                           gdouble          height,
236                           GtkOrientation   orientation);
237 void gtk_render_frame_gap (GtkStyleContext *context,
238                            cairo_t         *cr,
239                            gdouble          x,
240                            gdouble          y,
241                            gdouble          width,
242                            gdouble          height,
243                            GtkPositionType  gap_side,
244                            gdouble          xy0_gap,
245                            gdouble          xy1_gap);
246 void gtk_render_extension (GtkStyleContext *context,
247                            cairo_t         *cr,
248                            gdouble          x,
249                            gdouble          y,
250                            gdouble          width,
251                            gdouble          height,
252                            GtkPositionType  gap_side);
253 void gtk_render_handle    (GtkStyleContext *context,
254                            cairo_t         *cr,
255                            gdouble          x,
256                            gdouble          y,
257                            gdouble          width,
258                            gdouble          height,
259                            GtkOrientation   orientation);
260
261 G_END_DECLS
262
263 #endif /* __GTK_STYLE_CONTEXT_H__ */