]> Pileus Git - ~andy/gtk/blob - gtk/gtkcssimageprivate.h
stylecontext: Do invalidation on first resize container
[~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, see <http://www.gnu.org/licenses/>.
16  *
17  * Authors: Benjamin Otte <otte@gnome.org>
18  */
19
20 #ifndef __GTK_CSS_IMAGE_PRIVATE_H__
21 #define __GTK_CSS_IMAGE_PRIVATE_H__
22
23 #include <cairo.h>
24 #include <glib-object.h>
25
26 #include "gtk/gtkcssparserprivate.h"
27 #include "gtk/gtkcsstypesprivate.h"
28
29 G_BEGIN_DECLS
30
31 #define GTK_TYPE_CSS_IMAGE           (_gtk_css_image_get_type ())
32 #define GTK_CSS_IMAGE(obj)           (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_CSS_IMAGE, GtkCssImage))
33 #define GTK_CSS_IMAGE_CLASS(cls)     (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_CSS_IMAGE, GtkCssImageClass))
34 #define GTK_IS_CSS_IMAGE(obj)        (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_CSS_IMAGE))
35 #define GTK_IS_CSS_IMAGE_CLASS(obj)  (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_CSS_IMAGE))
36 #define GTK_CSS_IMAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CSS_IMAGE, GtkCssImageClass))
37
38 typedef struct _GtkCssImage           GtkCssImage;
39 typedef struct _GtkCssImageClass      GtkCssImageClass;
40
41 struct _GtkCssImage
42 {
43   GObject parent;
44 };
45
46 struct _GtkCssImageClass
47 {
48   GObjectClass parent_class;
49
50   /* width of image or 0 if it has no width (optional) */
51   int          (* get_width)                       (GtkCssImage                *image);
52   /* height of image or 0 if it has no height (optional) */
53   int          (* get_height)                      (GtkCssImage                *image);
54   /* aspect ratio (width / height) of image or 0 if it has no aspect ratio (optional) */
55   double       (* get_aspect_ratio)                (GtkCssImage                *image);
56
57   /* create "computed value" in CSS terms, returns a new reference */
58   GtkCssImage *(* compute)                         (GtkCssImage                *image,
59                                                     guint                       property_id,
60                                                     GtkStyleProviderPrivate    *provider,
61                                                     GtkCssComputedValues       *values,
62                                                     GtkCssComputedValues       *parent_values,
63                                                     GtkCssDependencies         *dependencies);
64   /* compare two images for equality */
65   gboolean     (* equal)                           (GtkCssImage                *image1,
66                                                     GtkCssImage                *image2);
67   /* transition between start and end image (end may be NULL), returns new reference */
68   GtkCssImage *(* transition)                      (GtkCssImage                *start,
69                                                     GtkCssImage                *end,
70                                                     guint                       property_id,
71                                                     double                      progress);
72
73   /* draw to 0,0 with the given width and height */
74   void         (* draw)                            (GtkCssImage                *image,
75                                                     cairo_t                    *cr,
76                                                     double                      width,
77                                                     double                      height);
78   /* parse CSS, return TRUE on success */
79   gboolean     (* parse)                           (GtkCssImage                *image,
80                                                     GtkCssParser               *parser);
81   /* print to CSS */
82   void         (* print)                           (GtkCssImage                *image,
83                                                     GString                    *string);
84 };
85
86 GType          _gtk_css_image_get_type             (void) G_GNUC_CONST;
87
88 gboolean       _gtk_css_image_can_parse            (GtkCssParser               *parser);
89 GtkCssImage *  _gtk_css_image_new_parse            (GtkCssParser               *parser);
90
91 int            _gtk_css_image_get_width            (GtkCssImage                *image);
92 int            _gtk_css_image_get_height           (GtkCssImage                *image);
93 double         _gtk_css_image_get_aspect_ratio     (GtkCssImage                *image);
94
95 GtkCssImage *  _gtk_css_image_compute              (GtkCssImage                *image,
96                                                     guint                       property_id,
97                                                     GtkStyleProviderPrivate    *provider,
98                                                     GtkCssComputedValues       *values,
99                                                     GtkCssComputedValues       *parent_values,
100                                                     GtkCssDependencies         *dependencies);
101 gboolean       _gtk_css_image_equal                (GtkCssImage                *image1,
102                                                     GtkCssImage                *image2);
103 GtkCssImage *  _gtk_css_image_transition           (GtkCssImage                *start,
104                                                     GtkCssImage                *end,
105                                                     guint                       property_id,
106                                                     double                      progress);
107
108 void           _gtk_css_image_draw                 (GtkCssImage                *image,
109                                                     cairo_t                    *cr,
110                                                     double                      width,
111                                                     double                      height);
112 void           _gtk_css_image_print                (GtkCssImage                *image,
113                                                     GString                    *string);
114
115 void           _gtk_css_image_get_concrete_size    (GtkCssImage                *image,
116                                                     double                      specified_width,
117                                                     double                      specified_height,
118                                                     double                      default_width,
119                                                     double                      default_height,
120                                                     double                     *concrete_width,
121                                                     double                     *concrete_height);
122 cairo_surface_t *
123                _gtk_css_image_get_surface          (GtkCssImage                *image,
124                                                     cairo_surface_t            *target,
125                                                     int                         surface_width,
126                                                     int                         surface_height);
127
128 G_END_DECLS
129
130 #endif /* __GTK_CSS_IMAGE_PRIVATE_H__ */