rsvg-styles.h 6.41 KB
Newer Older
1 2
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set sw=4 sts=4 expandtab: */
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
/*
   rsvg-styles.h: Handle SVG styles

   Copyright (C) 2000 Eazel, Inc.
   Copyright (C) 2002 Dom Lachowicz <cinamod@hotmail.com>

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public License as
   published by the Free Software Foundation; either version 2 of the
   License, or (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with this program; if not, write to the
   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.

   Author: Raph Levien <raph@artofcode.com>
*/

#ifndef RSVG_STYLES_H
#define RSVG_STYLES_H

30
#include <cairo.h>
31
#include "rsvg.h"
32
#include "rsvg-css.h"
33 34 35 36
#include "rsvg-paint-server.h"

#include <libxml/SAX.h>

37 38 39
G_BEGIN_DECLS 

typedef int TextDecoration;
40 41

enum {
42 43 44 45
    TEXT_NORMAL = 0x00,
    TEXT_OVERLINE = 0x01,
    TEXT_UNDERLINE = 0x02,
    TEXT_STRIKE = 0x04
46 47
};

Dom Lachowicz's avatar
Dom Lachowicz committed
48
typedef enum {
49 50 51
    TEXT_ANCHOR_START,
    TEXT_ANCHOR_MIDDLE,
    TEXT_ANCHOR_END
Dom Lachowicz's avatar
Dom Lachowicz committed
52 53
} TextAnchor;

54
typedef enum {
55 56 57
    UNICODE_BIDI_NORMAL = 0,
    UNICODE_BIDI_EMBED = 1,
    UNICODE_BIDI_OVERRIDE = 2
58 59
} UnicodeBidi;

60 61 62 63 64
typedef enum {
    RSVG_ENABLE_BACKGROUND_ACCUMULATE,
    RSVG_ENABLE_BACKGROUND_NEW
} RsvgEnableBackgroundType;

Dom Lachowicz's avatar
Dom Lachowicz committed
65 66 67
typedef struct _RsvgVpathDash RsvgVpathDash;

struct _RsvgVpathDash {
68 69 70
    RsvgLength offset;
    int n_dash;
    double *dash;
Dom Lachowicz's avatar
Dom Lachowicz committed
71 72
};

73
struct _RsvgState {
74
    RsvgState *parent;
Christian Persch's avatar
Christian Persch committed
75 76
    cairo_matrix_t affine;
    cairo_matrix_t personal_affine;
77

78
    char *filter;
79
    char *mask;
80
    char *clip_path;
81
    guint8 opacity;             /* 0..255 */
82 83
    double baseline_shift;
    gboolean has_baseline_shift;
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105

    RsvgPaintServer *fill;
    gboolean has_fill_server;
    guint8 fill_opacity;        /* 0..255 */
    gboolean has_fill_opacity;
    gint fill_rule;
    gboolean has_fill_rule;
    gint clip_rule;
    gboolean has_clip_rule;

    gboolean overflow;
    gboolean has_overflow;

    RsvgPaintServer *stroke;
    gboolean has_stroke_server;
    guint8 stroke_opacity;      /* 0..255 */
    gboolean has_stroke_opacity;
    RsvgLength stroke_width;
    gboolean has_stroke_width;
    double miter_limit;
    gboolean has_miter_limit;

106
    cairo_line_cap_t cap;
107
    gboolean has_cap;
108
    cairo_line_join_t join;
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
    gboolean has_join;

    RsvgLength font_size;
    gboolean has_font_size;
    char *font_family;
    gboolean has_font_family;
    char *lang;
    gboolean has_lang;
    PangoStyle font_style;
    gboolean has_font_style;
    PangoVariant font_variant;
    gboolean has_font_variant;
    PangoWeight font_weight;
    gboolean has_font_weight;
    PangoStretch font_stretch;
    gboolean has_font_stretch;
    TextDecoration font_decor;
    gboolean has_font_decor;
    PangoDirection text_dir;
    gboolean has_text_dir;
129 130
    PangoGravity text_gravity;
    gboolean has_text_gravity;
131 132 133 134
    UnicodeBidi unicode_bidi;
    gboolean has_unicode_bidi;
    TextAnchor text_anchor;
    gboolean has_text_anchor;
135 136
    RsvgLength letter_spacing;
    gboolean has_letter_spacing;
137 138 139

    guint text_offset;

140
    RsvgCssColorSpec stop_color;
141
    gboolean has_stop_color;
142

143
    RsvgOpacitySpec stop_opacity;
144 145 146 147 148
    gboolean has_stop_opacity;

    gboolean visible;
    gboolean has_visible;

149 150 151
    gboolean space_preserve;
    gboolean has_space_preserve;

152 153 154 155 156
    gboolean has_cond;
    gboolean cond_true;

    RsvgVpathDash dash;
    gboolean has_dash;
157
    gboolean has_dashoffset;
158 159 160 161 162 163 164 165 166 167

    guint32 current_color;
    gboolean has_current_color;

    guint32 flood_color;
    gboolean has_flood_color;

    guchar flood_opacity;
    gboolean has_flood_opacity;

Benjamin Otte's avatar
Benjamin Otte committed
168 169 170
    char *startMarker;
    char *middleMarker;
    char *endMarker;
171 172 173 174
    gboolean has_startMarker;
    gboolean has_middleMarker;
    gboolean has_endMarker;

175
    cairo_operator_t comp_op;
176
    RsvgEnableBackgroundType enable_background;
177

178
    cairo_antialias_t shape_rendering_type;
179
    gboolean has_shape_rendering_type;
180 181

    cairo_antialias_t text_rendering_type;
182
    gboolean has_text_rendering_type;
183 184

    GHashTable *styles;
185
};
186

187
G_GNUC_INTERNAL
Hiroyuki Ikezoe's avatar
Hiroyuki Ikezoe committed
188
RsvgState *rsvg_state_new (void);
189

190
G_GNUC_INTERNAL
191 192
void rsvg_state_free (RsvgState *state);

193
G_GNUC_INTERNAL
194
void rsvg_state_reinit      (RsvgState * state);
195
G_GNUC_INTERNAL
196
void rsvg_state_clone       (RsvgState * dst, const RsvgState * src);
197
G_GNUC_INTERNAL
198
void rsvg_state_inherit     (RsvgState * dst, const RsvgState * src);
199
G_GNUC_INTERNAL
200
void rsvg_state_reinherit   (RsvgState * dst, const RsvgState * src);
201

202
G_GNUC_INTERNAL
203
void rsvg_state_free_all    (RsvgState * state);
204

205
G_GNUC_INTERNAL
206
void rsvg_parse_style_pairs (RsvgState * state, RsvgPropertyBag * atts);
207
G_GNUC_INTERNAL
208
void rsvg_parse_style	    (RsvgHandle * ctx, RsvgState * state, const char *str);
209
G_GNUC_INTERNAL
210
void rsvg_parse_cssbuffer   (RsvgHandle * ctx, const char *buff, size_t buflen);
211
G_GNUC_INTERNAL
212
void rsvg_parse_style_attrs (RsvgHandle *ctx, RsvgNode *node, const char *tag,
213
                             const char *klazz, const char *id, RsvgPropertyBag * atts);
214

215
/* Implemented in rust/src/transform.rs */
216
G_GNUC_INTERNAL
217
gboolean rsvg_parse_transform   (cairo_matrix_t *matrix, const char *src) G_GNUC_WARN_UNUSED_RESULT;
218

219
G_GNUC_INTERNAL
220
RsvgState *rsvg_state_parent    (RsvgState * state);
221

222
G_GNUC_INTERNAL
223
void       rsvg_state_pop       (RsvgDrawingCtx * ctx);
224
G_GNUC_INTERNAL
225
void       rsvg_state_push      (RsvgDrawingCtx * ctx);
226
G_GNUC_INTERNAL
227
RsvgState *rsvg_current_state   (RsvgDrawingCtx * ctx);
228

229
G_GNUC_INTERNAL
230
void rsvg_state_reinherit_top	(RsvgDrawingCtx * ctx, RsvgState * state, int dominate);
231

232
G_GNUC_INTERNAL
233
void rsvg_state_reconstruct	(RsvgState * state, RsvgNode * current);
234

235 236 237
G_GNUC_INTERNAL
gboolean rsvg_state_is_overflow (RsvgState *state);

238 239 240
G_GNUC_INTERNAL
gboolean rsvg_state_has_overflow (RsvgState *state);

241 242 243
G_GNUC_INTERNAL
gboolean rsvg_state_get_cond_true (RsvgState *state);

244 245 246
G_GNUC_INTERNAL
RsvgCssColorSpec *rsvg_state_get_stop_color (RsvgState *state);

247 248 249
G_GNUC_INTERNAL
RsvgOpacitySpec *rsvg_state_get_stop_opacity (RsvgState *state);

250 251 252
G_GNUC_INTERNAL
guint32 rsvg_state_get_current_color (RsvgState *state);

253
G_END_DECLS
254

255
#endif                          /* RSVG_STYLES_H */