[cairo-commit] cairomm/cairomm surface.cc, 1.16, 1.17 surface.h,
1.14, 1.15
Jonathon Jongsma
commit at pdx.freedesktop.org
Tue Jul 4 11:42:20 PDT 2006
Committed by: jjongsma
Update of /cvs/cairo/cairomm/cairomm
In directory kemper:/tmp/cvs-serv24898/cairomm
Modified Files:
surface.cc surface.h
Log Message:
2006-07-04 Jonathon Jongsma <jonathon.jongsma at 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.
Index: surface.cc
===================================================================
RCS file: /cvs/cairo/cairomm/cairomm/surface.cc,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- surface.cc 28 Jun 2006 00:26:10 -0000 1.16
+++ surface.cc 4 Jul 2006 18:42:18 -0000 1.17
@@ -330,6 +330,28 @@
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
Index: surface.h
===================================================================
RCS file: /cvs/cairo/cairomm/cairomm/surface.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- surface.h 28 Jun 2006 00:26:10 -0000 1.14
+++ surface.h 4 Jul 2006 18:42:18 -0000 1.15
@@ -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 @@
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 @@
*/
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
More information about the cairo-commit
mailing list