rsvg.h 5.51 KB
Newer Older
1
/* vim: set sw=4: -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 3 4 5 6 7
/* 
   rsvg.h: SAX-based renderer for SVG files into a GdkPixbuf.
 
   Copyright (C) 2000 Eazel, Inc.
  
   This program is free software; you can redistribute it and/or
8
   modify it under the terms of the GNU Library General Public License as
9 10 11 12 13 14
   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
15
   Library General Public License for more details.
16
  
17
   You should have received a copy of the GNU Library General Public
18 19 20 21 22 23 24 25 26 27
   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_H
#define RSVG_H

28 29
#include <gdk-pixbuf/gdk-pixbuf.h>

30
G_BEGIN_DECLS
31 32 33 34 35 36
#define RSVG_TYPE_HANDLE                  (rsvg_handle_get_type ())
#define RSVG_HANDLE(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), RSVG_TYPE_HANDLE, RsvgHandle))
#define RSVG_HANDLE_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), RSVG_TYPE_HANDLE, RsvgHandleClass))
#define RSVG_IS_HANDLE(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RSVG_TYPE_HANDLE))
#define RSVG_IS_HANDLE_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), RSVG_TYPE_HANDLE))
#define RSVG_HANDLE_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), RSVG_TYPE_HANDLE, RsvgHandleClass))
37
    GType rsvg_handle_get_type (void);
38

39 40 41
/**
 * An enumeration representing possible error domains
 */
42
typedef enum {
43
    RSVG_ERROR_FAILED
44
} RsvgError;
45

46 47 48
/**
 * 
 */
49
#define RSVG_ERROR (rsvg_error_quark ())
50 51 52
GQuark
rsvg_error_quark (void)
    G_GNUC_CONST;
53

54 55 56
/**
 * The RsvgHandle is an object representing the parsed form of a SVG
 */
57 58 59
typedef struct _RsvgHandle RsvgHandle;
typedef struct RsvgHandlePrivate RsvgHandlePrivate;
typedef struct _RsvgHandleClass RsvgHandleClass;
60
typedef struct _RsvgDimensionData RsvgDimensionData;
61

62
struct _RsvgHandleClass {
63
    GObjectClass parent;
64

65
    gpointer _abi_padding[15];
66 67 68
};

struct _RsvgHandle {
69
    GObject parent;
70

71
    RsvgHandlePrivate *priv;
72

73
    gpointer _abi_padding[15];
74 75
};

76
/* RsvgDimensionData
77
 */
78
struct _RsvgDimensionData {
79
        /**
80 81
	 * SVG's width, in pixels
	 */
82
    int width;
83

84
        /**
85 86
	 * SVG's height, in pixels
	 */
87
    int height;
88

89
        /**
90 91
	 * em
	 */
92
    gdouble em;
93

94
        /**
95 96
	 * ex
	 */
97
    gdouble ex;
98 99
};

100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
void
rsvg_init (void);
void
rsvg_term (void);

void
rsvg_set_default_dpi (double dpi);
void
rsvg_set_default_dpi_x_y (double dpi_x, double dpi_y);

void
rsvg_handle_set_dpi (RsvgHandle * handle, double dpi);
void
rsvg_handle_set_dpi_x_y (RsvgHandle * handle, double dpi_x, double dpi_y);

RsvgHandle *
rsvg_handle_new (void);
gboolean
rsvg_handle_write (RsvgHandle * handle, const guchar * buf, gsize count, GError ** error);
gboolean
rsvg_handle_close (RsvgHandle * handle, GError ** error);
GdkPixbuf *
rsvg_handle_get_pixbuf (RsvgHandle * handle);
GdkPixbuf *
rsvg_handle_get_pixbuf_sub (RsvgHandle * handle, const char *id);
125

Dom Lachowicz's avatar
Dom Lachowicz committed
126
G_CONST_RETURN char *
127 128 129
rsvg_handle_get_base_uri (RsvgHandle * handle);
void
rsvg_handle_set_base_uri (RsvgHandle * handle, const char *base_uri);
Dom Lachowicz's avatar
Dom Lachowicz committed
130

131 132
void
rsvg_handle_get_dimensions (RsvgHandle * handle, RsvgDimensionData * dimension_data);
133 134 135

/* Accessibility API */

136 137 138 139 140 141
G_CONST_RETURN char *
rsvg_handle_get_title (RsvgHandle * handle);
G_CONST_RETURN char *
rsvg_handle_get_desc (RsvgHandle * handle);
G_CONST_RETURN char *
rsvg_handle_get_metadata (RsvgHandle * handle);
Dom Lachowicz's avatar
Dom Lachowicz committed
142

143 144 145 146
RsvgHandle *
rsvg_handle_new_from_data (const guint8 * data, gsize data_len, GError ** error);
RsvgHandle *
rsvg_handle_new_from_file (const gchar * file_name, GError ** error);
147

148 149
#ifndef RSVG_DISABLE_DEPRECATED

150 151
void
rsvg_handle_free (RsvgHandle * handle);
152

153 154 155 156 157 158 159 160 161 162
/**
 * RsvgSizeFunc ():
 * @width: Pointer to where to set/store the width
 * @height: Pointer to where to set/store the height
 * @user_data: User data pointer
 *
 * Function to let a user of the library specify the SVG's dimensions
 * @width: the ouput width the SVG should be
 * @height: the output height the SVG should be
 * @user_data: user data
163
 *
164
 * Deprecated: Set up a cairo matrix and use rsvg_handle_render_cairo() instead.
165
 */
166 167 168 169 170
typedef void (*RsvgSizeFunc) (gint * width, gint * height, gpointer user_data);
void
rsvg_handle_set_size_callback (RsvgHandle * handle,
                               RsvgSizeFunc size_func,
                               gpointer user_data, GDestroyNotify user_data_destroy);
171

172
/* GdkPixbuf convenience API */
173

174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
GdkPixbuf *
rsvg_pixbuf_from_file (const gchar * file_name, GError ** error);
GdkPixbuf *
rsvg_pixbuf_from_file_at_zoom (const gchar * file_name,
                               double x_zoom, double y_zoom, GError ** error);
GdkPixbuf *
rsvg_pixbuf_from_file_at_size (const gchar * file_name, gint width, gint height, GError ** error);
GdkPixbuf *
rsvg_pixbuf_from_file_at_max_size (const gchar * file_name,
                                   gint max_width, gint max_height, GError ** error);
GdkPixbuf *
rsvg_pixbuf_from_file_at_zoom_with_max (const gchar * file_name,
                                        double x_zoom,
                                        double y_zoom,
                                        gint max_width, gint max_height, GError ** error);

#endif                          /* RSVG_DISABLE_DEPRECATED */
191

192
G_END_DECLS
193
#endif                          /* RSVG_H */