Blame cairomm/win32_surface.h

Packit 908522
/* Copyright (C) 2005 The cairomm Development Team
Packit 908522
 *
Packit 908522
 * This library is free software; you can redistribute it and/or
Packit 908522
 * modify it under the terms of the GNU Library General Public
Packit 908522
 * License as published by the Free Software Foundation; either
Packit 908522
 * version 2 of the License, or (at your option) any later version.
Packit 908522
 *
Packit 908522
 * This library is distributed in the hope that it will be useful,
Packit 908522
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 908522
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 908522
 * Library General Public License for more details.
Packit 908522
 *
Packit 908522
 * You should have received a copy of the GNU Library General Public
Packit 908522
 * License along with this library; if not, write to the Free Software
Packit 908522
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
Packit 908522
 * 02110-1301, USA.
Packit 908522
 */
Packit 908522
Packit 908522
#ifndef __CAIROMM_WIN32_SURFACE_H
Packit 908522
#define __CAIROMM_WIN32_SURFACE_H
Packit 908522
Packit 908522
#include <cairomm/surface.h>
Packit 908522
#include <cairomm/enums.h>
Packit 908522
#include <cairo-features.h>
Packit 908522
Packit 908522
#ifdef CAIRO_HAS_WIN32_SURFACE
Packit 908522
#include <cairo-win32.h>
Packit 908522
Packit 908522
// This header is not included by cairomm.h because it requires Windows headers that 
Packit 908522
// tend to pollute the namespace with non-prefixed #defines and typedefs.
Packit 908522
// You may include it directly if you need to use this API.
Packit 908522
Packit 908522
namespace Cairo
Packit 908522
{
Packit 908522
Packit 908522
/** A Win32Surface provides a way to render within Microsoft Windows.  If you
Packit 908522
 * want to draw to the screen within a Microsoft Windows application, you
Packit 908522
 * should use this Surface type.
Packit 908522
 *
Packit 908522
 * @note For this Surface to be available, cairo must have been compiled with
Packit 908522
 * Win32 support
Packit 908522
 */
Packit 908522
class Win32Surface : public Surface
Packit 908522
{
Packit 908522
public:
Packit 908522
Packit 908522
  /** Create a C++ wrapper for the C instance. This C++ instance should then be
Packit 908522
   * given to a RefPtr.
Packit 908522
   *
Packit 908522
   * @param cobject The C instance.
Packit 908522
   * @param has_reference whether we already have a reference. Otherwise, the
Packit 908522
   * constructor will take an extra reference.
Packit 908522
   */
Packit 908522
  explicit Win32Surface(cairo_surface_t* cobject, bool has_reference = false);
Packit 908522
  virtual ~Win32Surface();
Packit 908522
Packit 908522
  /** Returns the HDC associated with this surface, or NULL if none. Also
Packit 908522
   * returns NULL if the surface is not a win32 surface.
Packit 908522
   *
Packit 908522
   * @return HDC or NULL if no HDC available.
Packit 908522
   */
Packit 908522
  HDC get_dc() const;
Packit 908522
Packit 908522
  //TODO: What does owned mean here? murrayc
Packit 908522
  //TODO: If this is just a get, shouldn't there be a const version too? murrayc
Packit 908522
  /** Returns a ImageSurface that refers to the same bits as the DIB of the
Packit 908522
   * Win32 surface. If the passed-in win32 surface is not a DIB surface, the
Packit 908522
   * returned surface will be NULL
Packit 908522
   *
Packit 908522
   * @return a ImageSurface (owned by the Win32Surface), or an empty RefPtr if the win32
Packit 908522
   * surface is not a DIB.
Packit 908522
   *
Packit 908522
   * @since 1.8
Packit 908522
   */
Packit 908522
  RefPtr<ImageSurface> get_image();
Packit 908522
Packit 908522
  /** Creates a cairo surface that targets the given DC. The DC will be queried
Packit 908522
   * for its initial clip extents, and this will be used as the size of the
Packit 908522
   * cairo surface. Also, if the DC is a raster DC, it will be queried for its
Packit 908522
   * pixel format and the cairo surface format will be set appropriately.
Packit 908522
   *
Packit 908522
   * @param hdc the DC to create a surface for.
Packit 908522
   * @return the newly created surface.
Packit 908522
   */
Packit 908522
  static RefPtr<Win32Surface> create(HDC hdc);
Packit 908522
Packit 908522
  /**
Packit 908522
   * @deprecated use create_with_dib()
Packit 908522
   */
Packit 908522
  static RefPtr<Win32Surface> create(Format format, int width, int height);
Packit 908522
  /** Creates a device-independent-bitmap surface not associated with any
Packit 908522
   * particular existing surface or device context. The created bitmap will be
Packit 908522
   * unititialized.
Packit 908522
   *
Packit 908522
   * @param format format of pixels in the surface to create.
Packit 908522
   * @param width width of the surface, in pixels.
Packit 908522
   * @param height height of the surface, in pixels.
Packit 908522
   * @return the newly created surface.
Packit 908522
   *
Packit 908522
   * @since 1.8
Packit 908522
   */
Packit 908522
  static RefPtr<Win32Surface> create_with_dib(Format format, int width, int height);
Packit 908522
Packit 908522
  /** Creates a device-independent-bitmap surface not associated with any
Packit 908522
   * particular existing surface or device context. The created bitmap will be
Packit 908522
   * uninitialized.
Packit 908522
   *
Packit 908522
   * @param hdc the DC to create a surface for.
Packit 908522
   * @param format format of pixels in the surface to create,
Packit 908522
   * @param width width of the surface, in pixels.
Packit 908522
   * @param height height of the surface, in pixels.
Packit 908522
   * @return the newly created surface.
Packit 908522
   *
Packit 908522
   * @since 1.8
Packit 908522
   */
Packit 908522
  static RefPtr<Win32Surface> create_with_ddb(HDC hdc, Format format, int width, int height);
Packit 908522
Packit 908522
};
Packit 908522
Packit 908522
/** A multi-page vector surface type for printing on Microsoft Windows
Packit 908522
 *
Packit 908522
 * @note For this Surface to be available, cairo must have been compiled with
Packit 908522
 * Win32 support
Packit 908522
 *
Packit 908522
 * @since 1.8
Packit 908522
 */
Packit 908522
class Win32PrintingSurface : public Surface
Packit 908522
{
Packit 908522
public:
Packit 908522
  explicit Win32PrintingSurface(cairo_surface_t* cobject, bool has_reference = false);
Packit 908522
  virtual ~Win32PrintingSurface();
Packit 908522
Packit 908522
  /** Creates a cairo surface that targets the given DC. The DC will be queried
Packit 908522
   * for its initial clip extents, and this will be used as the size of the
Packit 908522
   * cairo surface. The DC should be a printing DC; antialiasing will be
Packit 908522
   * ignored, and GDI will be used as much as possible to draw to the surface.
Packit 908522
   *
Packit 908522
   * The returned surface will be wrapped using the paginated surface to provide
Packit 908522
   * correct complex rendering behaviour; show_page() and associated methods
Packit 908522
   * must be used for correct output.
Packit 908522
   *
Packit 908522
   * @param hdc the DC to create a surface for.
Packit 908522
   *
Packit 908522
   * @since 1.8
Packit 908522
   */
Packit 908522
  static RefPtr<Win32PrintingSurface> create(HDC hdc);
Packit 908522
};
Packit 908522
Packit 908522
} // namespace Cairo
Packit 908522
Packit 908522
#endif // CAIRO_HAS_WIN32_SURFACE
Packit 908522
#endif //__CAIROMM_WIN32_SURFACE_H
Packit 908522
// vim: ts=2 sw=2 et