summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathon Jongsma <jjongsma@gnome.org>2006-07-04 18:42:18 +0000
committerJonathon Jongsma <jjongsma@gnome.org>2006-07-04 18:42:18 +0000
commit536a84772e314d1b1392f0959f13bff898b821c7 (patch)
treeee486af1d958e68f6957185def4e64e39a74729e
parentd75f0fb15ca4d8588dcc2150c9cd7515ab9251d1 (diff)
2006-07-04 Jonathon Jongsma <jonathon.jongsma@gmail.com>
* cairomm/surface.cc, cairomm/surface.h: added SvgSurface::get_versions() and SvgSurface::version_to_string() API. They're implemented as static members right now.
-rw-r--r--ChangeLog6
-rw-r--r--cairomm/surface.cc22
-rw-r--r--cairomm/surface.h28
3 files changed, 54 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index b490fcc..2dbc7f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-07-04 Jonathon Jongsma <jonathon.jongsma@gmail.com>
+
+ * cairomm/surface.cc, cairomm/surface.h: added SvgSurface::get_versions()
+ and SvgSurface::version_to_string() API. They're implemented as static
+ members right now.
+
2006-06-30 Jonathon Jongsma <jonathon.jongsma@gmail.com>
* configure.in: bumped cairomm version to 0.7.0 and bumped cairo requirement
diff --git a/cairomm/surface.cc b/cairomm/surface.cc
index 111898a..2d0a0ee 100644
--- a/cairomm/surface.cc
+++ b/cairomm/surface.cc
@@ -330,6 +330,28 @@ void SvgSurface::restrict_to_version(SvgVersion version)
check_object_status_and_throw_exception(*this);
}
+const std::vector<SvgVersion> SvgSurface::get_versions()
+{
+ cairo_svg_version_t const *versions;
+ int num_versions;
+ cairo_svg_get_versions(&versions, &num_versions);
+
+ // Just copy the version array out into a std::vector. This is a rarely used
+ // function and the array of versions is going to be very small, so there's no
+ // real performance hit.
+ std::vector<SvgVersion> vec;
+ for (int i = 0; i < num_versions; ++i)
+ {
+ vec.push_back(static_cast<SvgVersion>(versions[i]));
+ }
+ return vec;
+}
+
+std::string SvgSurface::version_to_string(SvgVersion version)
+{
+ return std::string(cairo_svg_version_to_string(static_cast<cairo_svg_version_t>(version)));
+}
+
#endif // CAIRO_HAS_SVG_SURFACE
diff --git a/cairomm/surface.h b/cairomm/surface.h
index 61c1f57..a14e5fa 100644
--- a/cairomm/surface.h
+++ b/cairomm/surface.h
@@ -20,6 +20,7 @@
#define __CAIROMM_SURFACE_H
#include <string>
+#include <vector>
#include <cairomm/enums.h>
#include <cairomm/exception.h>
#include <cairomm/fontoptions.h>
@@ -517,8 +518,7 @@ public:
typedef enum
{
SVG_VERSION_1_1 = CAIRO_SVG_VERSION_1_1,
- SVG_VERSION_1_2 = CAIRO_SVG_VERSION_1_2,
- SVG_VERSION_LAST = CAIRO_SVG_VERSION_LAST
+ SVG_VERSION_1_2 = CAIRO_SVG_VERSION_1_2
} SvgVersion;
/** A SvgSurface provides a way to render Scalable Vector Graphics (SVG) images
@@ -566,8 +566,32 @@ public:
*/
static RefPtr<SvgSurface> create(cairo_write_func_t write_func, void *closure, double width_in_points, double height_in_points);
+ /**
+ * Restricts the generated SVG file to the given version. See get_versions()
+ * for a list of available version values that can be used here.
+ *
+ * This function should only be called before any drawing operations have been
+ * performed on the given surface. The simplest way to do this is to call this
+ * function immediately after creating the surface.
+ *
+ * \since 1.2
+ */
void restrict_to_version(SvgVersion version);
+ /** Retrieves the list of SVG versions supported by cairo. See
+ * restrict_to_version().
+ *
+ * \since 1.2
+ */
+ static const std::vector<SvgVersion> get_versions();
+
+ /** Get the string representation of the given version id. The returned string
+ * will be empty if version isn't valid. See get_versions() for a way to get
+ * the list of valid version ids.
+ *
+ * Since: 1.2
+ */
+ static std::string version_to_string(SvgVersion version);
};
#endif // CAIRO_HAS_SVG_SURFACE