1 | /* vim: set sw=4: -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ |
---|
2 | /* |
---|
3 | rsvg-private.h: Internals of RSVG |
---|
4 | |
---|
5 | Copyright (C) 2000 Eazel, Inc. |
---|
6 | Copyright (C) 2002 Dom Lachowicz <cinamod@hotmail.com> |
---|
7 | |
---|
8 | This program is free software; you can redistribute it and/or |
---|
9 | modify it under the terms of the GNU Library General Public License as |
---|
10 | published by the Free Software Foundation; either version 2 of the |
---|
11 | License, or (at your option) any later version. |
---|
12 | |
---|
13 | This program is distributed in the hope that it will be useful, |
---|
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
16 | Library General Public License for more details. |
---|
17 | |
---|
18 | You should have received a copy of the GNU Library General Public |
---|
19 | License along with this program; if not, write to the |
---|
20 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
---|
21 | Boston, MA 02111-1307, USA. |
---|
22 | |
---|
23 | Author: Raph Levien <raph@artofcode.com> |
---|
24 | */ |
---|
25 | |
---|
26 | #ifndef RSVG_PRIVATE_H |
---|
27 | #define RSVG_PRIVATE_H |
---|
28 | |
---|
29 | #include "rsvg.h" |
---|
30 | |
---|
31 | #include <libxml/SAX.h> |
---|
32 | #include <libxml/xmlmemory.h> |
---|
33 | #include <pango/pango.h> |
---|
34 | #include <libart_lgpl/art_rect.h> |
---|
35 | #include <glib/gslist.h> |
---|
36 | |
---|
37 | G_BEGIN_DECLS |
---|
38 | |
---|
39 | typedef struct RsvgSaxHandler RsvgSaxHandler; |
---|
40 | typedef struct _RsvgPropertyBag RsvgPropertyBag; |
---|
41 | typedef struct _RsvgState RsvgState; |
---|
42 | typedef struct _RsvgDefs RsvgDefs; |
---|
43 | typedef struct _RsvgDefVal RsvgDefVal; |
---|
44 | typedef struct _RsvgFilter RsvgFilter; |
---|
45 | |
---|
46 | /* prepare for gettext */ |
---|
47 | #ifndef _ |
---|
48 | #define _(X) X |
---|
49 | #endif |
---|
50 | |
---|
51 | struct RsvgSaxHandler { |
---|
52 | void (*free) (RsvgSaxHandler *self); |
---|
53 | void (*start_element) (RsvgSaxHandler *self, const xmlChar *name, RsvgPropertyBag *atts); |
---|
54 | void (*end_element) (RsvgSaxHandler *self, const xmlChar *name); |
---|
55 | void (*characters) (RsvgSaxHandler *self, const xmlChar *ch, int len); |
---|
56 | }; |
---|
57 | |
---|
58 | struct RsvgHandle { |
---|
59 | RsvgSizeFunc size_func; |
---|
60 | gpointer user_data; |
---|
61 | GDestroyNotify user_data_destroy; |
---|
62 | GdkPixbuf *pixbuf; |
---|
63 | ArtIRect bbox; |
---|
64 | |
---|
65 | /* stack; there is a state for each element */ |
---|
66 | |
---|
67 | GSList * state; |
---|
68 | |
---|
69 | RsvgDefs *defs; |
---|
70 | guint in_defs; |
---|
71 | guint nest_level; |
---|
72 | void *current_defs_group; |
---|
73 | |
---|
74 | guint in_switch; |
---|
75 | |
---|
76 | GHashTable *css_props; |
---|
77 | |
---|
78 | /* not a handler stack. each nested handler keeps |
---|
79 | * track of its parent |
---|
80 | */ |
---|
81 | RsvgSaxHandler *handler; |
---|
82 | int handler_nest; |
---|
83 | |
---|
84 | GHashTable *entities; /* g_malloc'd string -> xmlEntityPtr */ |
---|
85 | |
---|
86 | PangoContext *pango_context; |
---|
87 | xmlParserCtxtPtr ctxt; |
---|
88 | GError **error; |
---|
89 | |
---|
90 | int width; |
---|
91 | int height; |
---|
92 | double dpi_x; |
---|
93 | double dpi_y; |
---|
94 | |
---|
95 | GString * title; |
---|
96 | GString * desc; |
---|
97 | |
---|
98 | gchar * base_uri; |
---|
99 | |
---|
100 | void * currentfilter; |
---|
101 | void * currentsubfilter; |
---|
102 | |
---|
103 | GMemChunk * state_allocator; |
---|
104 | |
---|
105 | /* virtual fns */ |
---|
106 | gboolean (* write) (RsvgHandle *handle, |
---|
107 | const guchar *buf, |
---|
108 | gsize count, |
---|
109 | GError **error); |
---|
110 | |
---|
111 | gboolean (* close) (RsvgHandle *handle, |
---|
112 | GError **error); |
---|
113 | |
---|
114 | void (* free) (RsvgHandle * handle); |
---|
115 | }; |
---|
116 | |
---|
117 | void rsvg_linear_gradient_free (RsvgDefVal *self); |
---|
118 | void rsvg_radial_gradient_free (RsvgDefVal *self); |
---|
119 | void rsvg_pattern_free (RsvgDefVal *self); |
---|
120 | |
---|
121 | /* "super"/parent calls */ |
---|
122 | void rsvg_handle_init (RsvgHandle * handle); |
---|
123 | gboolean rsvg_handle_write_impl (RsvgHandle *handle, |
---|
124 | const guchar *buf, |
---|
125 | gsize count, |
---|
126 | GError **error); |
---|
127 | gboolean rsvg_handle_close_impl (RsvgHandle *handle, |
---|
128 | GError **error); |
---|
129 | void rsvg_handle_free_impl (RsvgHandle *handle); |
---|
130 | |
---|
131 | typedef enum { |
---|
132 | RSVG_SIZE_ZOOM, |
---|
133 | RSVG_SIZE_WH, |
---|
134 | RSVG_SIZE_WH_MAX, |
---|
135 | RSVG_SIZE_ZOOM_MAX |
---|
136 | } RsvgSizeType; |
---|
137 | |
---|
138 | typedef enum { |
---|
139 | objectBoundingBox, userSpaceOnUse |
---|
140 | } RsvgCoordUnits; |
---|
141 | |
---|
142 | struct RsvgSizeCallbackData |
---|
143 | { |
---|
144 | RsvgSizeType type; |
---|
145 | double x_zoom; |
---|
146 | double y_zoom; |
---|
147 | gint width; |
---|
148 | gint height; |
---|
149 | |
---|
150 | gboolean keep_aspect_ratio; |
---|
151 | }; |
---|
152 | |
---|
153 | struct _RsvgPropertyBag |
---|
154 | { |
---|
155 | GHashTable * props; |
---|
156 | }; |
---|
157 | |
---|
158 | RsvgPropertyBag * |
---|
159 | rsvg_property_bag_new (const xmlChar **atts); |
---|
160 | |
---|
161 | void |
---|
162 | rsvg_property_bag_free (RsvgPropertyBag *bag); |
---|
163 | |
---|
164 | G_CONST_RETURN char * |
---|
165 | rsvg_property_bag_lookup (RsvgPropertyBag *bag, const char * key); |
---|
166 | |
---|
167 | guint |
---|
168 | rsvg_property_bag_size (RsvgPropertyBag *bag); |
---|
169 | |
---|
170 | GdkPixbuf * |
---|
171 | rsvg_pixbuf_from_data_with_size_data (const guchar * buff, |
---|
172 | size_t len, |
---|
173 | struct RsvgSizeCallbackData * data, |
---|
174 | const char * base_uri, |
---|
175 | GError ** error); |
---|
176 | |
---|
177 | G_CONST_RETURN char * |
---|
178 | rsvg_handle_get_base_uri (RsvgHandle *handle); |
---|
179 | |
---|
180 | void rsvg_handle_set_base_uri (RsvgHandle *handle, |
---|
181 | const char *base_uri); |
---|
182 | |
---|
183 | gboolean |
---|
184 | rsvg_eval_switch_attributes (RsvgPropertyBag *atts, gboolean * p_has_cond); |
---|
185 | |
---|
186 | GdkPixbuf * |
---|
187 | _rsvg_pixbuf_new_cleared (GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample, |
---|
188 | int width, int height); |
---|
189 | |
---|
190 | G_END_DECLS |
---|
191 | |
---|
192 | #endif |
---|