]> Pileus Git - ~andy/gtk/blob - gtk/gtkstylecontext.h
c6150e24073b4d1f2fbf05c3e54d2d72946a4571
[~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_MENUBAR:
119  *
120  * A CSS class to menubars.
121  */
122 #define GTK_STYLE_CLASS_MENUBAR "menubar"
123
124 /**
125  * GTK_STYLE_CLASS_MENUITEM:
126  *
127  * A CSS class to match menu items.
128  */
129 #define GTK_STYLE_CLASS_MENUITEM "menuitem"
130
131 /**
132  * GTK_STYLE_CLASS_RADIO:
133  *
134  * A CSS class to match radio buttons.
135  */
136 #define GTK_STYLE_CLASS_RADIO "radio"
137
138 /**
139  * GTK_STYLE_CLASS_CHECK:
140  *
141  * A CSS class to match check boxes.
142  */
143 #define GTK_STYLE_CLASS_CHECK "check"
144
145 /**
146  * GTK_STYLE_CLASS_DEFAULT:
147  *
148  * A CSS class to match the default widget.
149  */
150 #define GTK_STYLE_CLASS_DEFAULT "default"
151
152 /**
153  * GTK_STYLE_CLASS_TROUGH:
154  *
155  * A CSS class to match troughs, as in scrollbars and progressbars.
156  */
157 #define GTK_STYLE_CLASS_TROUGH "trough"
158
159 /**
160  * GTK_STYLE_CLASS_SCROLLBAR:
161  *
162  * A CSS class to match scrollbars.
163  */
164 #define GTK_STYLE_CLASS_SCROLLBAR "scrollbar"
165
166 /**
167  * GTK_STYLE_CLASS_HEADER:
168  *
169  * A CSS class to match a header element.
170  */
171 #define GTK_STYLE_CLASS_HEADER "header"
172
173 /**
174  * GTK_STYLE_CLASS_ACCELERATOR:
175  *
176  * A CSS class to match an accelerator.
177  */
178 #define GTK_STYLE_CLASS_ACCELERATOR "accelerator"
179
180 /**
181  * GTK_STYLE_CLASS_GRIP:
182  *
183  * A widget class defining a resize grip
184  */
185 #define GTK_STYLE_CLASS_GRIP "grip"
186
187 /**
188  * GTK_STYLE_CLASS_PROGRESSBAR:
189  *
190  * A widget class defining a resize grip
191  */
192 #define GTK_STYLE_CLASS_PROGRESSBAR "progressbar"
193
194 /* Predefined set of widget regions */
195
196 /**
197  * GTK_STYLE_REGION_ROW:
198  *
199  * A widget region name to define a treeview row.
200  */
201 #define GTK_STYLE_REGION_ROW "row"
202
203 /**
204  * GTK_STYLE_REGION_COLUMN:
205  *
206  * A widget region name to define a treeview column.
207  */
208 #define GTK_STYLE_REGION_COLUMN "column"
209
210 /**
211  * GTK_STYLE_REGION_COLUMN_HEADER:
212  *
213  * A widget region name to define a treeview column header.
214  */
215 #define GTK_STYLE_REGION_COLUMN_HEADER "column-header"
216
217 /**
218  * GTK_STYLE_REGION_TAB:
219  *
220  * A widget region name to define a notebook tab.
221  */
222 #define GTK_STYLE_REGION_TAB "tab"
223
224
225 GType gtk_style_context_get_type (void) G_GNUC_CONST;
226
227 GtkStyleContext * gtk_style_context_new (void);
228
229 void gtk_style_context_add_provider_for_screen    (GdkScreen        *screen,
230                                                    GtkStyleProvider *provider,
231                                                    guint             priority);
232 void gtk_style_context_remove_provider_for_screen (GdkScreen        *screen,
233                                                    GtkStyleProvider *provider);
234
235 void gtk_style_context_add_provider    (GtkStyleContext  *context,
236                                         GtkStyleProvider *provider,
237                                         guint             priority);
238
239 void gtk_style_context_remove_provider (GtkStyleContext  *context,
240                                         GtkStyleProvider *provider);
241
242 void gtk_style_context_save    (GtkStyleContext *context);
243 void gtk_style_context_restore (GtkStyleContext *context);
244
245 void gtk_style_context_get_property (GtkStyleContext *context,
246                                      const gchar     *property,
247                                      GtkStateFlags    state,
248                                      GValue          *value);
249 void gtk_style_context_get_valist   (GtkStyleContext *context,
250                                      GtkStateFlags    state,
251                                      va_list          args);
252 void gtk_style_context_get          (GtkStyleContext *context,
253                                      GtkStateFlags    state,
254                                      ...) G_GNUC_NULL_TERMINATED;
255
256 void          gtk_style_context_set_state    (GtkStyleContext *context,
257                                               GtkStateFlags    flags);
258 GtkStateFlags gtk_style_context_get_state    (GtkStyleContext *context);
259
260 gboolean      gtk_style_context_state_is_running (GtkStyleContext *context,
261                                                   GtkStateType     state,
262                                                   gdouble         *progress);
263
264 void          gtk_style_context_set_path     (GtkStyleContext *context,
265                                               GtkWidgetPath   *path);
266 G_CONST_RETURN GtkWidgetPath * gtk_style_context_get_path (GtkStyleContext *context);
267
268 GList *  gtk_style_context_list_classes (GtkStyleContext *context);
269
270 void     gtk_style_context_add_class    (GtkStyleContext *context,
271                                          const gchar     *class_name);
272 void     gtk_style_context_remove_class (GtkStyleContext *context,
273                                          const gchar     *class_name);
274 gboolean gtk_style_context_has_class    (GtkStyleContext *context,
275                                          const gchar     *class_name);
276
277 GList *  gtk_style_context_list_regions (GtkStyleContext *context);
278
279 void     gtk_style_context_add_region    (GtkStyleContext    *context,
280                                           const gchar        *region_name,
281                                           GtkRegionFlags      flags);
282 void     gtk_style_context_remove_region (GtkStyleContext    *context,
283                                           const gchar        *region_name);
284 gboolean gtk_style_context_has_region    (GtkStyleContext    *context,
285                                           const gchar        *region_name,
286                                           GtkRegionFlags     *flags_return);
287
288 void gtk_style_context_get_style_property (GtkStyleContext *context,
289                                            const gchar     *property_name,
290                                            GValue          *value);
291 void gtk_style_context_get_style_valist   (GtkStyleContext *context,
292                                            va_list          args);
293 void gtk_style_context_get_style          (GtkStyleContext *context,
294                                            ...);
295
296 GtkIconSet * gtk_style_context_lookup_icon_set (GtkStyleContext *context,
297                                                 const gchar     *stock_id);
298
299 void        gtk_style_context_set_screen (GtkStyleContext *context,
300                                           GdkScreen       *screen);
301 GdkScreen * gtk_style_context_get_screen (GtkStyleContext *context);
302
303 void             gtk_style_context_set_direction (GtkStyleContext  *context,
304                                                   GtkTextDirection  direction);
305 GtkTextDirection gtk_style_context_get_direction (GtkStyleContext  *context);
306
307 void             gtk_style_context_set_junction_sides (GtkStyleContext  *context,
308                                                        GtkJunctionSides  sides);
309 GtkJunctionSides gtk_style_context_get_junction_sides (GtkStyleContext  *context);
310
311 gboolean gtk_style_context_lookup_color (GtkStyleContext *context,
312                                          const gchar     *color_name,
313                                          GdkRGBA         *color);
314
315 void  gtk_style_context_notify_state_change (GtkStyleContext *context,
316                                              GdkWindow       *window,
317                                              gpointer         region_id,
318                                              GtkStateType     state,
319                                              gboolean         state_value);
320 void gtk_style_context_push_animatable_region (GtkStyleContext *context,
321                                                gpointer         region_id);
322 void gtk_style_context_pop_animatable_region  (GtkStyleContext *context);
323
324
325 /* Semi-private API */
326 const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context,
327                                                        GType            widget_type,
328                                                        GParamSpec      *pspec);
329 void           _gtk_style_context_invalidate_animation_areas (GtkStyleContext *context);
330 void           _gtk_style_context_coalesce_animation_areas   (GtkStyleContext *context,
331                                                               gint             rel_x,
332                                                               gint             rel_y);
333
334 /* Animation for state changes */
335 void gtk_style_context_state_transition_start  (GtkStyleContext *context,
336                                                 gpointer         identifier,
337                                                 GtkWidget       *widget,
338                                                 GtkStateType     state,
339                                                 gboolean         value,
340                                                 GdkRectangle    *rect);
341 void gtk_style_context_state_transition_update (GtkStyleContext *context,
342                                                 gpointer         identifier,
343                                                 GdkRectangle    *rect,
344                                                 GtkStateType     state);
345 void gtk_style_context_state_transition_stop   (GtkStyleContext *context,
346                                                 gpointer         identifier);
347
348 void gtk_style_context_invalidate (GtkStyleContext *context);
349 void gtk_style_context_reset_widgets (GdkScreen *screen);
350
351 /* Paint methods */
352 void gtk_render_check (GtkStyleContext *context,
353                        cairo_t         *cr,
354                        gdouble          x,
355                        gdouble          y,
356                        gdouble          width,
357                        gdouble          height);
358 void gtk_render_option (GtkStyleContext *context,
359                         cairo_t         *cr,
360                         gdouble          x,
361                         gdouble          y,
362                         gdouble          width,
363                         gdouble          height);
364 void gtk_render_arrow  (GtkStyleContext *context,
365                         cairo_t         *cr,
366                         gdouble          angle,
367                         gdouble          x,
368                         gdouble          y,
369                         gdouble          size);
370 void gtk_render_background (GtkStyleContext *context,
371                             cairo_t         *cr,
372                             gdouble          x,
373                             gdouble          y,
374                             gdouble          width,
375                             gdouble          height);
376 void gtk_render_frame  (GtkStyleContext *context,
377                         cairo_t         *cr,
378                         gdouble          x,
379                         gdouble          y,
380                         gdouble          width,
381                         gdouble          height);
382 void gtk_render_expander (GtkStyleContext *context,
383                           cairo_t         *cr,
384                           gdouble          x,
385                           gdouble          y,
386                           gdouble          width,
387                           gdouble          height);
388 void gtk_render_focus    (GtkStyleContext *context,
389                           cairo_t         *cr,
390                           gdouble          x,
391                           gdouble          y,
392                           gdouble          width,
393                           gdouble          height);
394 void gtk_render_layout   (GtkStyleContext *context,
395                           cairo_t         *cr,
396                           gdouble          x,
397                           gdouble          y,
398                           PangoLayout     *layout);
399 void gtk_render_line     (GtkStyleContext *context,
400                           cairo_t         *cr,
401                           gdouble          x0,
402                           gdouble          y0,
403                           gdouble          x1,
404                           gdouble          y1);
405 void gtk_render_slider   (GtkStyleContext *context,
406                           cairo_t         *cr,
407                           gdouble          x,
408                           gdouble          y,
409                           gdouble          width,
410                           gdouble          height,
411                           GtkOrientation   orientation);
412 void gtk_render_frame_gap (GtkStyleContext *context,
413                            cairo_t         *cr,
414                            gdouble          x,
415                            gdouble          y,
416                            gdouble          width,
417                            gdouble          height,
418                            GtkPositionType  gap_side,
419                            gdouble          xy0_gap,
420                            gdouble          xy1_gap);
421 void gtk_render_extension (GtkStyleContext *context,
422                            cairo_t         *cr,
423                            gdouble          x,
424                            gdouble          y,
425                            gdouble          width,
426                            gdouble          height,
427                            GtkPositionType  gap_side);
428 void gtk_render_handle    (GtkStyleContext *context,
429                            cairo_t         *cr,
430                            gdouble          x,
431                            gdouble          y,
432                            gdouble          width,
433                            gdouble          height);
434 void gtk_render_activity  (GtkStyleContext *context,
435                            cairo_t         *cr,
436                            gdouble          x,
437                            gdouble          y,
438                            gdouble          width,
439                            gdouble          height);
440
441 GdkPixbuf * gtk_render_icon_pixbuf (GtkStyleContext     *context,
442                                     const GtkIconSource *source,
443                                     GtkIconSize          size);
444
445 G_END_DECLS
446
447 #endif /* __GTK_STYLE_CONTEXT_H__ */