]> Pileus Git - ~andy/gtk/blob - gtk/gtkcssimageprivate.h
ebd977ef1336b197657163d1b4d0b0195ba2b1bd
[~andy/gtk] / gtk / gtkcssimageprivate.h
1 /*
2  * Copyright © 2011 Red Hat Inc.
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.1 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 Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17  *
18  * Authors: Benjamin Otte <otte@gnome.org>
19  */
20
21 #ifndef __GTK_CSS_IMAGE_PRIVATE_H__
22 #define __GTK_CSS_IMAGE_PRIVATE_H__
23
24 #include <cairo.h>
25 #include <glib-object.h>
26
27 #include "gtk/gtkstylecontext.h"
28 #include "gtk/gtkcssparserprivate.h"
29
30 G_BEGIN_DECLS
31
32 #define GTK_TYPE_CSS_IMAGE           (_gtk_css_image_get_type ())
33 #define GTK_CSS_IMAGE(obj)           (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_CSS_IMAGE, GtkCssImage))
34 #define GTK_CSS_IMAGE_CLASS(cls)     (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_CSS_IMAGE, GtkCssImageClass))
35 #define GTK_IS_CSS_IMAGE(obj)        (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_CSS_IMAGE))
36 #define GTK_IS_CSS_IMAGE_CLASS(obj)  (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_CSS_IMAGE))
37 #define GTK_CSS_IMAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CSS_IMAGE, GtkCssImageClass))
38
39 typedef struct _GtkCssImage           GtkCssImage;
40 typedef struct _GtkCssImageClass      GtkCssImageClass;
41
42 struct _GtkCssImage
43 {
44   GObject parent;
45 };
46
47 struct _GtkCssImageClass
48 {
49   GObjectClass parent_class;
50
51   /* width of image or 0 if it has no width (optional) */
52   int          (* get_width)                       (GtkCssImage        *image);
53   /* height of image or 0 if it has no height (optional) */
54   int          (* get_height)                      (GtkCssImage        *image);
55   /* aspect ratio (width / height) of image or 0 if it has no aspect ratio (optional) */
56   double       (* get_aspect_ratio)                (GtkCssImage        *image);
57
58   /* create "computed value" in CSS terms, returns a new reference */
59   GtkCssImage *(* compute)                         (GtkCssImage        *image,
60                                                     GtkStyleContext    *context);
61
62   /* draw to 0,0 with the given width and height */
63   void         (* draw)                            (GtkCssImage        *image,
64                                                     cairo_t            *cr,
65                                                     double              width,
66                                                     double              height);
67   /* parse CSS, return TRUE on success */
68   gboolean     (* parse)                           (GtkCssImage        *image,
69                                                     GtkCssParser       *parser,
70                                                     GFile              *base);
71   /* print to CSS */
72   void         (* print)                           (GtkCssImage        *image,
73                                                     GString            *string);
74 };
75
76 GType          _gtk_css_image_get_type             (void) G_GNUC_CONST;
77
78 gboolean       _gtk_css_image_can_parse            (GtkCssParser       *parser);
79 GtkCssImage *  _gtk_css_image_new_parse            (GtkCssParser       *parser,
80                                                     GFile              *base);
81
82 int            _gtk_css_image_get_width            (GtkCssImage        *image);
83 int            _gtk_css_image_get_height           (GtkCssImage        *image);
84 double         _gtk_css_image_get_aspect_ratio     (GtkCssImage        *image);
85
86 GtkCssImage *  _gtk_css_image_compute              (GtkCssImage        *image,
87                                                     GtkStyleContext    *context);
88
89 void           _gtk_css_image_draw                 (GtkCssImage        *image,
90                                                     cairo_t            *cr,
91                                                     double              width,
92                                                     double              height);
93 void           _gtk_css_image_print                (GtkCssImage        *image,
94                                                     GString            *string);
95
96 void           _gtk_css_image_get_concrete_size    (GtkCssImage        *image,
97                                                     double              specified_width,
98                                                     double              specified_height,
99                                                     double              default_width,
100                                                     double              default_height,
101                                                     double             *concrete_width,
102                                                     double             *concrete_height);
103 cairo_surface_t *
104                _gtk_css_image_get_surface          (GtkCssImage        *image,
105                                                     cairo_surface_t    *target,
106                                                     int                 surface_width,
107                                                     int                 surface_height);
108
109 G_END_DECLS
110
111 #endif /* __GTK_CSS_IMAGE_PRIVATE_H__ */