]> Pileus Git - ~andy/gtk/blob - gtk/gtkthemingengine.h
d3f6c83cb7489636b7bc574d71ce114ffb97e8d6
[~andy/gtk] / gtk / gtkthemingengine.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 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
21 #error "Only <gtk/gtk.h> can be included directly."
22 #endif
23
24 #ifndef __GTK_THEMING_ENGINE_H__
25 #define __GTK_THEMING_ENGINE_H__
26
27 #include <glib-object.h>
28 #include <cairo.h>
29
30 #include <gtk/gtkstylecontext.h>
31 #include <gtk/gtkwidgetpath.h>
32 #include <gtk/gtkenums.h>
33
34 G_BEGIN_DECLS
35
36 #define GTK_TYPE_THEMING_ENGINE         (gtk_theming_engine_get_type ())
37 #define GTK_THEMING_ENGINE(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_THEMING_ENGINE, GtkThemingEngine))
38 #define GTK_THEMING_ENGINE_CLASS(c)     (G_TYPE_CHECK_CLASS_CAST    ((c), GTK_TYPE_THEMING_ENGINE, GtkThemingEngineClass))
39 #define GTK_IS_THEMING_ENGINE(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_THEMING_ENGINE))
40 #define GTK_IS_THEMING_ENGINE_CLASS(c)  (G_TYPE_CHECK_CLASS_TYPE    ((c), GTK_TYPE_THEMING_ENGINE))
41 #define GTK_THEMING_ENGINE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS  ((o), GTK_TYPE_THEMING_ENGINE, GtkThemingEngineClass))
42
43 typedef struct _GtkThemingEngine GtkThemingEngine;
44 typedef struct GtkThemingEnginePrivate GtkThemingEnginePrivate;
45 typedef struct _GtkThemingEngineClass GtkThemingEngineClass;
46
47 struct _GtkThemingEngine
48 {
49   GObject parent_object;
50   GtkThemingEnginePrivate *priv;
51 };
52
53 /**
54  * GtkThemingEngineClass
55  * @parent_class: The parent class.
56  * @render_line: Renders a line between two points.
57  * @render_background: Renders the background area of a widget region.
58  * @render_frame: Renders the frame around a widget area.
59  * @render_frame_gap: Renders the frame around a widget area with a gap in it.
60  * @render_extension: Renders a extension to a box, usually a notebook tab.
61  * @render_check: Renders a checkmark, as in #GtkCheckButton.
62  * @render_option: Renders an option, as in #GtkRadioButton.
63  * @render_arrow: Renders an arrow pointing to a certain direction.
64  * @render_expander: Renders an element what will expose/expand part of
65  *                   the UI, as in #GtkExpander.
66  * @render_focus: Renders the focus indicator.
67  * @render_layout: Renders a #PangoLayout
68  * @render_slider: Renders a slider control, as in #GtkScale.
69  * @render_handle: Renders a handle to drag UI elements, as in #GtkPaned.
70  * @render_activity: Renders an area displaying activity, such as in #GtkSpinner,
71  *                   or #GtkProgressBar.
72  * @render_icon_pixbuf: Renders an icon as a #GdkPixbuf.
73  * @render_icon: Renders an icon given as a #GdkPixbuf.
74  *
75  * Base class for theming engines.
76  */
77 struct _GtkThemingEngineClass
78 {
79   GObjectClass parent_class;
80
81   void (* render_line) (GtkThemingEngine *engine,
82                         cairo_t          *cr,
83                         gdouble           x0,
84                         gdouble           y0,
85                         gdouble           x1,
86                         gdouble           y1);
87   void (* render_background) (GtkThemingEngine *engine,
88                               cairo_t          *cr,
89                               gdouble           x,
90                               gdouble           y,
91                               gdouble           width,
92                               gdouble           height);
93   void (* render_frame) (GtkThemingEngine *engine,
94                          cairo_t          *cr,
95                          gdouble           x,
96                          gdouble           y,
97                          gdouble           width,
98                          gdouble           height);
99   void (* render_frame_gap) (GtkThemingEngine *engine,
100                              cairo_t          *cr,
101                              gdouble           x,
102                              gdouble           y,
103                              gdouble           width,
104                              gdouble           height,
105                              GtkPositionType   gap_side,
106                              gdouble           xy0_gap,
107                              gdouble           xy1_gap);
108   void (* render_extension) (GtkThemingEngine *engine,
109                              cairo_t          *cr,
110                              gdouble           x,
111                              gdouble           y,
112                              gdouble           width,
113                              gdouble           height,
114                              GtkPositionType   gap_side);
115   void (* render_check) (GtkThemingEngine *engine,
116                          cairo_t          *cr,
117                          gdouble           x,
118                          gdouble           y,
119                          gdouble           width,
120                          gdouble           height);
121   void (* render_option) (GtkThemingEngine *engine,
122                           cairo_t          *cr,
123                           gdouble           x,
124                           gdouble           y,
125                           gdouble           width,
126                           gdouble           height);
127   void (* render_arrow) (GtkThemingEngine *engine,
128                          cairo_t          *cr,
129                          gdouble           angle,
130                          gdouble           x,
131                          gdouble           y,
132                          gdouble           size);
133   void (* render_expander) (GtkThemingEngine *engine,
134                             cairo_t          *cr,
135                             gdouble           x,
136                             gdouble           y,
137                             gdouble           width,
138                             gdouble           height);
139   void (* render_focus) (GtkThemingEngine *engine,
140                          cairo_t          *cr,
141                          gdouble           x,
142                          gdouble           y,
143                          gdouble           width,
144                          gdouble           height);
145   void (* render_layout) (GtkThemingEngine *engine,
146                           cairo_t          *cr,
147                           gdouble           x,
148                           gdouble           y,
149                           PangoLayout      *layout);
150   void (* render_slider) (GtkThemingEngine *engine,
151                           cairo_t          *cr,
152                           gdouble           x,
153                           gdouble           y,
154                           gdouble           width,
155                           gdouble           height,
156                           GtkOrientation    orientation);
157   void (* render_handle)    (GtkThemingEngine *engine,
158                              cairo_t          *cr,
159                              gdouble           x,
160                              gdouble           y,
161                              gdouble           width,
162                              gdouble           height);
163   void (* render_activity) (GtkThemingEngine *engine,
164                             cairo_t          *cr,
165                             gdouble           x,
166                             gdouble           y,
167                             gdouble           width,
168                             gdouble           height);
169
170   GdkPixbuf * (* render_icon_pixbuf) (GtkThemingEngine    *engine,
171                                       const GtkIconSource *source,
172                                       GtkIconSize          size);
173   void (* render_icon) (GtkThemingEngine *engine,
174                         cairo_t          *cr,
175                         GdkPixbuf        *pixbuf,
176                         gdouble           x,
177                         gdouble           y);
178
179   /*< private >*/
180   gpointer padding[15];
181 };
182
183 GType gtk_theming_engine_get_type (void) G_GNUC_CONST;
184
185 void _gtk_theming_engine_set_context (GtkThemingEngine *engine,
186                                       GtkStyleContext  *context);
187
188 /* function implemented in gtkcsscustomproperty.c */
189 void gtk_theming_engine_register_property (const gchar            *name_space,
190                                            GtkStylePropertyParser  parse_func,
191                                            GParamSpec             *pspec);
192
193 void gtk_theming_engine_get_property (GtkThemingEngine *engine,
194                                       const gchar      *property,
195                                       GtkStateFlags     state,
196                                       GValue           *value);
197 void gtk_theming_engine_get_valist   (GtkThemingEngine *engine,
198                                       GtkStateFlags     state,
199                                       va_list           args);
200 void gtk_theming_engine_get          (GtkThemingEngine *engine,
201                                       GtkStateFlags     state,
202                                       ...) G_GNUC_NULL_TERMINATED;
203
204 void gtk_theming_engine_get_style_property (GtkThemingEngine *engine,
205                                             const gchar      *property_name,
206                                             GValue           *value);
207 void gtk_theming_engine_get_style_valist   (GtkThemingEngine *engine,
208                                             va_list           args);
209 void gtk_theming_engine_get_style          (GtkThemingEngine *engine,
210                                             ...);
211
212 gboolean gtk_theming_engine_lookup_color (GtkThemingEngine *engine,
213                                           const gchar      *color_name,
214                                           GdkRGBA          *color);
215
216 const GtkWidgetPath * gtk_theming_engine_get_path (GtkThemingEngine *engine);
217
218 gboolean gtk_theming_engine_has_class  (GtkThemingEngine *engine,
219                                         const gchar      *style_class);
220 gboolean gtk_theming_engine_has_region (GtkThemingEngine *engine,
221                                         const gchar      *style_region,
222                                         GtkRegionFlags   *flags);
223
224 GtkStateFlags gtk_theming_engine_get_state        (GtkThemingEngine *engine);
225 gboolean      gtk_theming_engine_state_is_running (GtkThemingEngine *engine,
226                                                    GtkStateType      state,
227                                                    gdouble          *progress);
228
229 GtkTextDirection gtk_theming_engine_get_direction (GtkThemingEngine *engine);
230
231 GtkJunctionSides gtk_theming_engine_get_junction_sides (GtkThemingEngine *engine);
232
233 /* Helper functions */
234 void gtk_theming_engine_get_color            (GtkThemingEngine *engine,
235                                               GtkStateFlags     state,
236                                               GdkRGBA          *color);
237 void gtk_theming_engine_get_background_color (GtkThemingEngine *engine,
238                                               GtkStateFlags     state,
239                                               GdkRGBA          *color);
240 void gtk_theming_engine_get_border_color     (GtkThemingEngine *engine,
241                                               GtkStateFlags     state,
242                                               GdkRGBA          *color);
243
244 void gtk_theming_engine_get_border  (GtkThemingEngine *engine,
245                                      GtkStateFlags     state,
246                                      GtkBorder        *border);
247 void gtk_theming_engine_get_padding (GtkThemingEngine *engine,
248                                      GtkStateFlags     state,
249                                      GtkBorder        *padding);
250 void gtk_theming_engine_get_margin  (GtkThemingEngine *engine,
251                                      GtkStateFlags     state,
252                                      GtkBorder        *margin);
253
254 const PangoFontDescription * gtk_theming_engine_get_font (GtkThemingEngine *engine,
255                                                           GtkStateFlags     state);
256
257 GtkThemingEngine * gtk_theming_engine_load (const gchar *name);
258
259 GdkScreen * gtk_theming_engine_get_screen (GtkThemingEngine *engine);
260
261 G_END_DECLS
262
263 #endif /* __GTK_THEMING_ENGINE_H__ */