]> Pileus Git - ~andy/gtk/blob - gtk/gtkstylecontext.h
GtkStyleContext: Add the start of a default set of class names/regions.
[~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 /* Predefined set of CSS classes */
53
54 /**
55  * GTK_STYLE_CLASS_CELL:
56  *
57  * A CSS class to match content rendered in cell views.
58  */
59 #define GTK_STYLE_CLASS_CELL "cell"
60
61 /**
62  * GTK_STYLE_CLASS_ENTRY:
63  *
64  * A CSS class to match text entries.
65  */
66 #define GTK_STYLE_CLASS_ENTRY "entry"
67
68 /**
69  * GTK_STYLE_CLASS_BUTTON:
70  *
71  * A CSS class to match buttons.
72  */
73 #define GTK_STYLE_CLASS_BUTTON "button"
74
75 /**
76  * GTK_STYLE_CLASS_CALENDAR:
77  *
78  * A CSS class to match calendars.
79  */
80 #define GTK_STYLE_CLASS_CALENDAR "calendar"
81
82 /**
83  * GTK_STYLE_CLASS_SLIDER:
84  *
85  * A CSS class to match sliders.
86  */
87 #define GTK_STYLE_CLASS_SLIDER "slider"
88
89 /**
90  * GTK_STYLE_CLASS_BACKGROUND:
91  *
92  * A CSS class to match the window background.
93  */
94 #define GTK_STYLE_CLASS_BACKGROUND "background"
95
96 /**
97  * GTK_STYLE_CLASS_RUBBERBAND:
98  *
99  * A CSS class to match the rubberband selection rectangle.
100  */
101 #define GTK_STYLE_CLASS_RUBBERBAND "rubberband"
102
103 /**
104  * GTK_STYLE_CLASS_TOOLTIP:
105  *
106  * A CSS class to match tooltip windows.
107  */
108 #define GTK_STYLE_CLASS_TOOLTIP "tooltip"
109
110 /**
111  * GTK_STYLE_CLASS_MENU:
112  *
113  * A CSS class to match popup menus.
114  */
115 #define GTK_STYLE_CLASS_MENU "menu"
116
117 /**
118  * GTK_STYLE_CLASS_RADIO:
119  *
120  * A CSS class to match radio buttons.
121  */
122 #define GTK_STYLE_CLASS_RADIO "radio"
123
124 /**
125  * GTK_STYLE_CLASS_CHECK:
126  *
127  * A CSS class to match check boxes.
128  */
129 #define GTK_STYLE_CLASS_CHECK "check"
130
131 /**
132  * GTK_STYLE_CLASS_DEFAULT:
133  *
134  * A CSS class to match the default widget.
135  */
136 #define GTK_STYLE_CLASS_DEFAULT "default"
137
138 /**
139  * GTK_STYLE_CLASS_TROUGH:
140  *
141  * A CSS class to match troughs, as in scrollbars and progressbars.
142  */
143 #define GTK_STYLE_CLASS_TROUGH "trough"
144
145 /**
146  * GTK_STYLE_CLASS_SCROLLBAR:
147  *
148  * A CSS class to match scrollbars.
149  */
150 #define GTK_STYLE_CLASS_SCROLLBAR "scrollbar"
151
152 /**
153  * GTK_STYLE_CLASS_HEADER:
154  *
155  * A CSS class to match a header element.
156  */
157 #define GTK_STYLE_CLASS_HEADER "header"
158
159
160 /* Predefined set of widget regions */
161
162 /**
163  * GTK_STYLE_REGION_ROW:
164  *
165  * A widget region name to define a treeview row.
166  */
167 #define GTK_STYLE_REGION_ROW "row"
168
169 /**
170  * GTK_STYLE_REGION_COLUMN:
171  *
172  * A widget region name to define a treeview column.
173  */
174 #define GTK_STYLE_REGION_COLUMN "column"
175
176 /**
177  * GTK_STYLE_REGION_COLUMN_HEADER:
178  *
179  * A widget region name to define a treeview column header.
180  */
181 #define GTK_STYLE_REGION_COLUMN_HEADER "column-header"
182
183 /**
184  * GTK_STYLE_REGION_TAB:
185  *
186  * A widget region name to define a notebook tab.
187  */
188 #define GTK_STYLE_REGION_TAB "tab"
189
190
191 GType gtk_style_context_get_type (void) G_GNUC_CONST;
192
193 GtkStyleContext * gtk_style_context_new (void);
194
195 void gtk_style_context_add_provider_for_screen    (GdkScreen        *screen,
196                                                    GtkStyleProvider *provider,
197                                                    guint             priority);
198 void gtk_style_context_remove_provider_for_screen (GdkScreen        *screen,
199                                                    GtkStyleProvider *provider);
200
201 void gtk_style_context_add_provider    (GtkStyleContext  *context,
202                                         GtkStyleProvider *provider,
203                                         guint             priority);
204
205 void gtk_style_context_remove_provider (GtkStyleContext  *context,
206                                         GtkStyleProvider *provider);
207
208 void gtk_style_context_save    (GtkStyleContext *context);
209 void gtk_style_context_restore (GtkStyleContext *context);
210
211 void gtk_style_context_get_property (GtkStyleContext *context,
212                                      const gchar     *property,
213                                      GtkStateFlags    state,
214                                      GValue          *value);
215 void gtk_style_context_get_valist   (GtkStyleContext *context,
216                                      GtkStateFlags    state,
217                                      va_list          args);
218 void gtk_style_context_get          (GtkStyleContext *context,
219                                      GtkStateFlags    state,
220                                      ...) G_GNUC_NULL_TERMINATED;
221
222 void          gtk_style_context_set_state    (GtkStyleContext *context,
223                                               GtkStateFlags    flags);
224 GtkStateFlags gtk_style_context_get_state    (GtkStyleContext *context);
225
226 gboolean      gtk_style_context_state_is_running (GtkStyleContext *context,
227                                                   GtkStateType     state,
228                                                   gdouble         *progress);
229
230 void          gtk_style_context_set_path     (GtkStyleContext *context,
231                                               GtkWidgetPath   *path);
232 G_CONST_RETURN GtkWidgetPath * gtk_style_context_get_path (GtkStyleContext *context);
233
234 GList *  gtk_style_context_list_classes (GtkStyleContext *context);
235
236 void     gtk_style_context_add_class    (GtkStyleContext *context,
237                                          const gchar     *class_name);
238 void     gtk_style_context_remove_class (GtkStyleContext *context,
239                                          const gchar     *class_name);
240 gboolean gtk_style_context_has_class    (GtkStyleContext *context,
241                                          const gchar     *class_name);
242
243 GList *  gtk_style_context_list_regions (GtkStyleContext *context);
244
245 void     gtk_style_context_add_region    (GtkStyleContext    *context,
246                                           const gchar        *region_name,
247                                           GtkRegionFlags      flags);
248 void     gtk_style_context_remove_region (GtkStyleContext    *context,
249                                           const gchar        *region_name);
250 gboolean gtk_style_context_has_region    (GtkStyleContext    *context,
251                                           const gchar        *region_name,
252                                           GtkRegionFlags     *flags_return);
253
254 void gtk_style_context_get_style_property (GtkStyleContext *context,
255                                            const gchar     *property_name,
256                                            GValue          *value);
257 void gtk_style_context_get_style_valist   (GtkStyleContext *context,
258                                            va_list          args);
259 void gtk_style_context_get_style          (GtkStyleContext *context,
260                                            ...);
261
262 GtkIconSet * gtk_style_context_lookup_icon_set (GtkStyleContext *context,
263                                                 const gchar     *stock_id);
264
265 void        gtk_style_context_set_screen (GtkStyleContext *context,
266                                           GdkScreen       *screen);
267 GdkScreen * gtk_style_context_get_screen (GtkStyleContext *context);
268
269 void             gtk_style_context_set_direction (GtkStyleContext  *context,
270                                                   GtkTextDirection  direction);
271 GtkTextDirection gtk_style_context_get_direction (GtkStyleContext  *context);
272
273 void             gtk_style_context_set_junction_sides (GtkStyleContext  *context,
274                                                        GtkJunctionSides  sides);
275 GtkJunctionSides gtk_style_context_get_junction_sides (GtkStyleContext  *context);
276
277 gboolean gtk_style_context_lookup_color (GtkStyleContext *context,
278                                          const gchar     *color_name,
279                                          GdkRGBA         *color);
280
281 void  gtk_style_context_notify_state_change (GtkStyleContext *context,
282                                              GdkWindow       *window,
283                                              gpointer         region_id,
284                                              GtkStateType     state,
285                                              gboolean         state_value);
286 void gtk_style_context_push_animatable_region (GtkStyleContext *context,
287                                                gpointer         region_id);
288 void gtk_style_context_pop_animatable_region  (GtkStyleContext *context);
289
290
291 /* Semi-private API */
292 const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context,
293                                                        GType            widget_type,
294                                                        GParamSpec      *pspec);
295 void           _gtk_style_context_invalidate_animation_areas (GtkStyleContext *context);
296 void           _gtk_style_context_coalesce_animation_areas   (GtkStyleContext *context,
297                                                               gint             rel_x,
298                                                               gint             rel_y);
299
300 /* Animation for state changes */
301 void gtk_style_context_state_transition_start  (GtkStyleContext *context,
302                                                 gpointer         identifier,
303                                                 GtkWidget       *widget,
304                                                 GtkStateType     state,
305                                                 gboolean         value,
306                                                 GdkRectangle    *rect);
307 void gtk_style_context_state_transition_update (GtkStyleContext *context,
308                                                 gpointer         identifier,
309                                                 GdkRectangle    *rect,
310                                                 GtkStateType     state);
311 void gtk_style_context_state_transition_stop   (GtkStyleContext *context,
312                                                 gpointer         identifier);
313
314 void gtk_style_context_invalidate (GtkStyleContext *context);
315 void gtk_style_context_reset_widgets (GdkScreen *screen);
316
317 /* Paint methods */
318 void gtk_render_check (GtkStyleContext *context,
319                        cairo_t         *cr,
320                        gdouble          x,
321                        gdouble          y,
322                        gdouble          width,
323                        gdouble          height);
324 void gtk_render_option (GtkStyleContext *context,
325                         cairo_t         *cr,
326                         gdouble          x,
327                         gdouble          y,
328                         gdouble          width,
329                         gdouble          height);
330 void gtk_render_arrow  (GtkStyleContext *context,
331                         cairo_t         *cr,
332                         gdouble          angle,
333                         gdouble          x,
334                         gdouble          y,
335                         gdouble          size);
336 void gtk_render_background (GtkStyleContext *context,
337                             cairo_t         *cr,
338                             gdouble          x,
339                             gdouble          y,
340                             gdouble          width,
341                             gdouble          height);
342 void gtk_render_frame  (GtkStyleContext *context,
343                         cairo_t         *cr,
344                         gdouble          x,
345                         gdouble          y,
346                         gdouble          width,
347                         gdouble          height);
348 void gtk_render_expander (GtkStyleContext *context,
349                           cairo_t         *cr,
350                           gdouble          x,
351                           gdouble          y,
352                           gdouble          width,
353                           gdouble          height);
354 void gtk_render_focus    (GtkStyleContext *context,
355                           cairo_t         *cr,
356                           gdouble          x,
357                           gdouble          y,
358                           gdouble          width,
359                           gdouble          height);
360 void gtk_render_layout   (GtkStyleContext *context,
361                           cairo_t         *cr,
362                           gdouble          x,
363                           gdouble          y,
364                           PangoLayout     *layout);
365 void gtk_render_line     (GtkStyleContext *context,
366                           cairo_t         *cr,
367                           gdouble          x0,
368                           gdouble          y0,
369                           gdouble          x1,
370                           gdouble          y1);
371 void gtk_render_slider   (GtkStyleContext *context,
372                           cairo_t         *cr,
373                           gdouble          x,
374                           gdouble          y,
375                           gdouble          width,
376                           gdouble          height,
377                           GtkOrientation   orientation);
378 void gtk_render_frame_gap (GtkStyleContext *context,
379                            cairo_t         *cr,
380                            gdouble          x,
381                            gdouble          y,
382                            gdouble          width,
383                            gdouble          height,
384                            GtkPositionType  gap_side,
385                            gdouble          xy0_gap,
386                            gdouble          xy1_gap);
387 void gtk_render_extension (GtkStyleContext *context,
388                            cairo_t         *cr,
389                            gdouble          x,
390                            gdouble          y,
391                            gdouble          width,
392                            gdouble          height,
393                            GtkPositionType  gap_side);
394 void gtk_render_handle    (GtkStyleContext *context,
395                            cairo_t         *cr,
396                            gdouble          x,
397                            gdouble          y,
398                            gdouble          width,
399                            gdouble          height);
400 void gtk_render_activity  (GtkStyleContext *context,
401                            cairo_t         *cr,
402                            gdouble          x,
403                            gdouble          y,
404                            gdouble          width,
405                            gdouble          height);
406
407 G_END_DECLS
408
409 #endif /* __GTK_STYLE_CONTEXT_H__ */