diff options
author | Jonathon Jongsma <jonathon.jongsma@collabora.co.uk> | 2008-09-12 22:25:44 -0500 |
---|---|---|
committer | Jonathon Jongsma <jonathon.jongsma@collabora.co.uk> | 2008-09-12 22:25:44 -0500 |
commit | 977870bf3a7f62af19e348346c2a77b2e99a4c50 (patch) | |
tree | 37165faabf685ac2900ca6bfec21fec2e292b924 | |
parent | e59c2827dcf5c39bcd1b09e676da94627fd1984d (diff) |
Add Win32PrintingSurface
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | cairomm/win32_surface.cc | 17 | ||||
-rw-r--r-- | cairomm/win32_surface.h | 34 |
3 files changed, 51 insertions, 5 deletions
@@ -1,3 +1,8 @@ +2008-09-12 Jonathon Jongsma <jonathon@gnome.org> + + * cairomm/win32_surface.cc: + * cairomm/win32_surface.h: add the Win32PrintingSurface type + 2008-09-10 Jonathon Jongsma <jjongsma@gnome.org> * cairomm/context.cc: diff --git a/cairomm/win32_surface.cc b/cairomm/win32_surface.cc index 32f42ce..2bd8c6d 100644 --- a/cairomm/win32_surface.cc +++ b/cairomm/win32_surface.cc @@ -73,6 +73,23 @@ RefPtr<Win32Surface> Win32Surface::create_with_ddb(HDC hdc, Format format, int w return RefPtr<Win32Surface>(new Win32Surface(cobject, true /* has reference */)); } +Win32PrintingSurface::Win32PrintingSurface(cairo_surface_t* cobject, bool has_reference = false) + : Surface(cobject, has_reference) +{ +} + +Win32PrintingSurface::~Win32PrintingSurface() +{ + // surface is destroyed in base class +} + +static RefPtr<Win32PrintingSurface> Win32PrintingSurface::create(HDC hdc) +{ + cairo_surface_t* cobject = cairo_win32_surface_create(hdc); + check_status_and_throw_exception(cairo_surface_status(cobject)); + return RefPtr<Win32PrintingSurface>(new Win32PrintingSurface(cobject, true /* has reference */)); +} + #endif // CAIRO_HAS_WIN32_SURFACE } //namespace Cairo diff --git a/cairomm/win32_surface.h b/cairomm/win32_surface.h index dc70227..65530c0 100644 --- a/cairomm/win32_surface.h +++ b/cairomm/win32_surface.h @@ -21,10 +21,10 @@ #include <cairomm/surface.h> #include <cairomm/enums.h> +#include <cairo-features.h> #ifdef CAIRO_HAS_WIN32_SURFACE #include <cairo-win32.h> -#endif // This header is not included by cairomm.h because it requires Windows headers that // tend to pollute the namespace with non-prefixed #defines and typedefs. @@ -33,8 +33,6 @@ namespace Cairo { -#ifdef CAIRO_HAS_WIN32_SURFACE - /** A Win32Surface provides a way to render within Microsoft Windows. If you * want to draw to the screen within a Microsoft Windows application, you * should use this Surface type. @@ -117,11 +115,37 @@ public: }; -#endif // CAIRO_HAS_WIN32_SURFACE +/** A multi-page vector surface type for printing on Microsoft Windows + * + * @note For this Surface to be available, cairo must have been compiled with + * Win32 support + * + * @since 1.8 + */ +class Win32PrintingSurface : public Surface +{ +public: + explicit Win32PrintingSurface(cairo_surface_t* cobject, bool has_reference = false); + virtual ~Win32Surface(); + /** Creates a cairo surface that targets the given DC. The DC will be queried + * for its initial clip extents, and this will be used as the size of the + * cairo surface. The DC should be a printing DC; antialiasing will be + * ignored, and GDI will be used as much as possible to draw to the surface. + * + * The returned surface will be wrapped using the paginated surface to provide + * correct complex rendering behaviour; show_page() and associated methods + * must be used for correct output. + * + * @param hdc the DC to create a surface for + * + * @since 1.8 + */ + static RefPtr<Win32PrintingSurface> create(HDC hdc); +}; } // namespace Cairo +#endif // CAIRO_HAS_WIN32_SURFACE #endif //__CAIROMM_WIN32_SURFACE_H - // vim: ts=2 sw=2 et |