|
Packit Service |
e3b512 |
/* Copyright (C) 2007 The cairomm Development Team
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* This library is free software; you can redistribute it and/or
|
|
Packit Service |
e3b512 |
* modify it under the terms of the GNU Library General Public
|
|
Packit Service |
e3b512 |
* License as published by the Free Software Foundation; either
|
|
Packit Service |
e3b512 |
* version 2 of the License, or (at your option) any later version.
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* This library is distributed in the hope that it will be useful,
|
|
Packit Service |
e3b512 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
e3b512 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
e3b512 |
* Library General Public License for more details.
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* You should have received a copy of the GNU Library General Public
|
|
Packit Service |
e3b512 |
* License along with this library; if not, write to the Free Software
|
|
Packit Service |
e3b512 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
Packit Service |
e3b512 |
* 02110-1301, USA.
|
|
Packit Service |
e3b512 |
*/
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
#ifndef __CAIROMM_QUARTZ_SURFACE_H
|
|
Packit Service |
e3b512 |
#define __CAIROMM_QUARTZ_SURFACE_H
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
#include <cairomm/surface.h>
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
#ifdef CAIRO_HAS_QUARTZ_SURFACE
|
|
Packit Service |
e3b512 |
#include <cairo-quartz.h>
|
|
Packit Service |
e3b512 |
#endif
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
namespace Cairo
|
|
Packit Service |
e3b512 |
{
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
#ifdef CAIRO_HAS_QUARTZ_SURFACE
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
/** A QuartzSurface provides a way to render within Apple Mac OS X. If you
|
|
Packit Service |
e3b512 |
* want to draw to the screen within a Mac OS X application, you
|
|
Packit Service |
e3b512 |
* should use this Surface type.
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* @note For this Surface to be available, cairo must have been compiled with
|
|
Packit Service |
e3b512 |
* (native) Quartz support (requires Cairo > 1.4.0)
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* @since 1.4
|
|
Packit Service |
e3b512 |
*/
|
|
Packit Service |
e3b512 |
class QuartzSurface : public Surface
|
|
Packit Service |
e3b512 |
{
|
|
Packit Service |
e3b512 |
public:
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
/** Create a C++ wrapper for the C instance. This C++ instance should then be
|
|
Packit Service |
e3b512 |
* given to a RefPtr.
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* @param cobject The C instance.
|
|
Packit Service |
e3b512 |
* @param has_reference whether we already have a reference. Otherwise, the
|
|
Packit Service |
e3b512 |
* constructor will take an extra reference.
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* @since 1.4
|
|
Packit Service |
e3b512 |
*/
|
|
Packit Service |
e3b512 |
explicit QuartzSurface(cairo_surface_t* cobject, bool has_reference = false);
|
|
Packit Service |
e3b512 |
virtual ~QuartzSurface();
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
/** Returns the CGContextRef associated with this surface, or NULL if none. Also
|
|
Packit Service |
e3b512 |
* returns NULL if the surface is not a Quartz surface.
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* @return CGContextRef or NULL if no CGContextRef available.
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* @since 1.4
|
|
Packit Service |
e3b512 |
*/
|
|
Packit Service |
e3b512 |
CGContextRef get_cg_context() const;
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
/**
|
|
Packit Service |
e3b512 |
* Creates a Quartz surface that wraps the given CGContext. The CGContext is
|
|
Packit Service |
e3b512 |
* assumed to be in the standard Cairo coordinate space (that is, with the
|
|
Packit Service |
e3b512 |
* origin at the upper left and the Y axis increasing downward). If the
|
|
Packit Service |
e3b512 |
* CGContext is in the Quartz coordinate space (with the origin at the bottom
|
|
Packit Service |
e3b512 |
* left), then it should be flipped before this function is called. The flip
|
|
Packit Service |
e3b512 |
* can be accomplished using a translate and a scale; for example:
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* @code
|
|
Packit Service |
e3b512 |
* CGContextTranslateCTM (cgContext, 0.0, height);
|
|
Packit Service |
e3b512 |
* CGContextScaleCTM (cgContext, 1.0, -1.0);
|
|
Packit Service |
e3b512 |
* @endcode
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* All Cairo operations are implemented in terms of Quartz operations,
|
|
Packit Service |
e3b512 |
* as long as Quartz-compatible elements are used (such as Quartz fonts).
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* @param cg_context the CGContext to create a surface for
|
|
Packit Service |
e3b512 |
* @return the newly created surface
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* @since 1.4
|
|
Packit Service |
e3b512 |
*/
|
|
Packit Service |
e3b512 |
static RefPtr<QuartzSurface> create(CGContextRef cg_context, int width, int height);
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
/**
|
|
Packit Service |
e3b512 |
* Creates a Quartz surface backed by a CGBitmap. The surface is created
|
|
Packit Service |
e3b512 |
* using the Device RGB (or Device Gray, for A8) color space. All Cairo
|
|
Packit Service |
e3b512 |
* operations, including those that require software rendering, will succeed
|
|
Packit Service |
e3b512 |
* on this surface.
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* @param format format of pixels in the surface to create
|
|
Packit Service |
e3b512 |
* @param width width of the surface, in pixels
|
|
Packit Service |
e3b512 |
* @param height height of the surface, in pixels
|
|
Packit Service |
e3b512 |
* @return the newly created surface
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* @since 1.4
|
|
Packit Service |
e3b512 |
*/
|
|
Packit Service |
e3b512 |
static RefPtr<QuartzSurface> create(Format format, int width, int height);
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
};
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
#endif // CAIRO_HAS_QUARTZ_SURFACE
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
} // namespace Cairo
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
#endif //__CAIROMM_QUARTZ_SURFACE_H
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
// vim: ts=2 sw=2 et
|