diff options
author | Jonathon Jongsma <jjongsma@gnome.org> | 2007-11-10 21:16:17 -0600 |
---|---|---|
committer | Jonathon Jongsma <jjongsma@gnome.org> | 2007-11-10 21:16:17 -0600 |
commit | 6a01afe2f703c4eb5300e417d8391f538bc25b81 (patch) | |
tree | 1150b7f52aa206cb63c3141cd25a75f01305234e | |
parent | 60f1af39bb971115b86b09ced8f20e96a59c0a6d (diff) |
[PsSurface] Add new API to control PS language level
* cairomm/surface.cc:
* cairomm/surface.h: add new PsSurface API: set_eps(), restrict_to_level(),
get_levels(), level_to_string()
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | cairomm/surface.cc | 33 | ||||
-rw-r--r-- | cairomm/surface.h | 57 |
3 files changed, 96 insertions, 0 deletions
@@ -1,6 +1,12 @@ 2007-11-10 Jonathon Jongsma <jjongsma@gnome.org> * cairomm/surface.cc: + * cairomm/surface.h: add new PsSurface API: set_eps(), restrict_to_level(), + get_levels(), level_to_string() + +2007-11-10 Jonathon Jongsma <jjongsma@gnome.org> + + * cairomm/surface.cc: * cairomm/surface.h: add Surface::copy_page() and Surface::show_page() 2007-11-10 Jonathon Jongsma <jjongsma@gnome.org> diff --git a/cairomm/surface.cc b/cairomm/surface.cc index af672b4..d3dece5 100644 --- a/cairomm/surface.cc +++ b/cairomm/surface.cc @@ -305,6 +305,39 @@ void PsSurface::dsc_begin_page_setup() check_object_status_and_throw_exception(*this); } +void PsSurface::set_eps(bool eps) +{ + cairo_ps_surface_set_eps(m_cobject, eps); + check_object_status_and_throw_exception(*this); +} + +void PsSurface::restrict_to_level(PsLevel level) +{ + cairo_ps_surface_restrict_to_level(m_cobject, static_cast<cairo_ps_level_t>(level)); + check_object_status_and_throw_exception(*this); +} + +const std::vector<PsLevel> PsSurface::get_levels() +{ + cairo_ps_level_t const *levels; + int num_levels; + cairo_ps_get_levels(&levels, &num_levels); + + // Just copy the level array out into a std::vector. This is a rarely used + // function and the array of levels is going to be very small, so there's no + // real performance hit. + std::vector<PsLevel> vec; + for (int i = 0; i < num_levels; ++i) + { + vec.push_back(static_cast<PsLevel>(levels[i])); + } + return vec; +} + +std::string PsSurface::level_to_string(PsLevel level) +{ + return std::string(cairo_ps_level_to_string(static_cast<cairo_ps_level_t>(level))); +} #endif // CAIRO_HAS_PS_SURFACE diff --git a/cairomm/surface.h b/cairomm/surface.h index fd9029b..a6f3404 100644 --- a/cairomm/surface.h +++ b/cairomm/surface.h @@ -433,6 +433,15 @@ public: #ifdef CAIRO_HAS_PS_SURFACE +/** + * describes the language level of the PostScript Language Reference that a + * generated PostScript file will conform to. + */ +typedef enum { + PS_LEVEL_2 = CAIRO_PS_LEVEL_2, + PS_LEVEL_3 = CAIRO_PS_LEVEL_3 +} PsLevel; + /** A PsSurface provides a way to render PostScript documents from cairo. This * surface is not rendered to the screen but instead renders the drawing to a * PostScript file on disk. @@ -514,6 +523,54 @@ public: */ void dsc_begin_page_setup(); +/** + * If eps is true, the PostScript surface will output Encapsulated + * PostScript. + * + * This function should only be called before any drawing operations + * have been performed on the current page. The simplest way to do + * this is to call this function immediately after creating the + * surface. An Encapsulated Postscript file should never contain more + * than one page. + * + * @since 1.6 + **/ + void set_eps(bool eps); + + /** + * Restricts the generated PostSript file to @level. See get_levels() for a + * list of available level 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. + * + * @param level PostScript level + * + * @since 1.6 + **/ + void restrict_to_level(PsLevel level); + + /** + * Used to retrieve the list of supported levels. See + * restrict_to_level(). + * + * @since 1.6 + **/ + static const std::vector<PsLevel> get_levels(); + + /** + * Get the string representation of the given level id. This function will + * return an empty string if level id isn't valid. See get_levels() for a way + * to get the list of valid level ids. + * + * @return the string associated to given level. + * + * @param level a level id + * + * @since 1.6 + **/ + static std::string level_to_string(PsLevel level); }; #endif // CAIRO_HAS_PS_SURFACE |