1 /* Copyright (C) 2007 The cairomm Development Team
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Library General Public
5 * License as published by the Free Software Foundation; either
6 * version 2 of the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Library General Public License for more details.
13 * You should have received a copy of the GNU Library General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 #ifndef __CAIROMM_QUARTZ_SURFACE_H
20 #define __CAIROMM_QUARTZ_SURFACE_H
22 #include <cairomm/surface.h>
24 #ifdef CAIRO_HAS_QUARTZ_SURFACE
25 #include <cairo-quartz.h>
31 #ifdef CAIRO_HAS_QUARTZ_SURFACE
33 /** A QuartzSurface provides a way to render within Apple Mac OS X. If you
34 * want to draw to the screen within a Mac OS X application, you
35 * should use this Surface type.
37 * @note For this Surface to be available, cairo must have been compiled with
38 * (native) Quartz support (requires Cairo > 1.4.0)
40 class QuartzSurface : public Surface
44 /** Create a C++ wrapper for the C instance. This C++ instance should then be
47 * @param cobject The C instance.
48 * @param has_reference whether we already have a reference. Otherwise, the
49 * constructor will take an extra reference.
51 explicit QuartzSurface(cairo_surface_t* cobject, bool has_reference = false);
52 virtual ~QuartzSurface();
54 /** Returns the CGContextRef associated with this surface, or NULL if none. Also
55 * returns NULL if the surface is not a Quartz surface.
57 * @return CGContextRef or NULL if no CGContextRef available.
59 CGContextRef get_cg_context() const;
61 /** Creates a cairo surface that targets the given CGContext.
63 * @param cg_context the CGContext to create a surface for
64 * @return the newly created surface
66 static RefPtr<QuartzSurface> create(CGContextRef cg_context, int width, int height);
68 /** Creates a device-independent-bitmap surface not associated with any
69 * particular existing surface or device context. The created bitmap will be
72 * @param format format of pixels in the surface to create
73 * @param width width of the surface, in pixels
74 * @param height height of the surface, in pixels
75 * @return the newly created surface
77 static RefPtr<QuartzSurface> create(Format format, int width, int height);
81 #endif // CAIRO_HAS_QUARTZ_SURFACE
86 #endif //__CAIROMM_QUARTZ_SURFACE_H