Blame cairomm/xlib_surface.h

Packit Service e3b512
/* Copyright (C) 2005 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_XLIB_SURFACE_H
Packit Service e3b512
#define __CAIROMM_XLIB_SURFACE_H
Packit Service e3b512
Packit Service e3b512
#include <cairomm/surface.h>
Packit Service e3b512
Packit Service e3b512
// This header is not included by cairomm.h because it requires X headers that 
Packit Service e3b512
// tend to pollute the namespace with non-prefixed #defines and typedefs.
Packit Service e3b512
// You may include it directly if you need to use this API.
Packit Service e3b512
Packit Service e3b512
#ifdef CAIRO_HAS_XLIB_SURFACE
Packit Service e3b512
#include <cairo-xlib.h> // Needed for the X11 "Display" struct (which pollutes the namespace because it has no prefix.)
Packit Service e3b512
#ifdef CAIRO_HAS_XLIB_XRENDER_SURFACE
Packit Service e3b512
#include <cairo-xlib-xrender.h> // xrender-specific API
Packit Service e3b512
#endif // CAIRO_HAS_XLIB_XRENDER_SURFACE
Packit Service e3b512
#endif // CAIRO_HAS_XLIB_SURFACE
Packit Service e3b512
Packit Service e3b512
Packit Service e3b512
namespace Cairo
Packit Service e3b512
{
Packit Service e3b512
Packit Service e3b512
#ifdef CAIRO_HAS_XLIB_SURFACE
Packit Service e3b512
Packit Service e3b512
/** An XlibSurface provides a way to render to the X Window System using XLib.
Packit Service e3b512
 * If you want to draw to the screen within an application that uses the X
Packit Service e3b512
 * Window system, you should use this Surface type.
Packit Service e3b512
 *
Packit Service e3b512
 * @note For this surface to be availabe, cairo must have been compiled with
Packit Service e3b512
 * support for XLib Surfaces
Packit Service e3b512
 */
Packit Service e3b512
class XlibSurface : 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
  explicit XlibSurface(cairo_surface_t* cobject, bool has_reference = false);
Packit Service e3b512
  virtual ~XlibSurface();
Packit Service e3b512
Packit Service e3b512
  /** Creates an Xlib surface that draws to the given drawable. The way that
Packit Service e3b512
   * colors are represented in the drawable is specified by the provided
Packit Service e3b512
   * visual.
Packit Service e3b512
   *
Packit Service e3b512
   * @note If drawable is a Window, then the function
Packit Service e3b512
   * cairo_xlib_surface_set_size must be called whenever the size of the window
Packit Service e3b512
   * changes.
Packit Service e3b512
   *
Packit Service e3b512
   * @param dpy	an X Display
Packit Service e3b512
   * @param drawable	an X Drawable, (a Pixmap or a Window)
Packit Service e3b512
   * @param visual	the visual to use for drawing to drawable. The depth of the visual must match the depth of the drawable. Currently, only TrueColor visuals are fully supported.
Packit Service e3b512
   * @param width	the current width of drawable.
Packit Service e3b512
   * @param height	the current height of drawable.
Packit Service e3b512
   * @return	A RefPtr to the newly created surface
Packit Service e3b512
   */
Packit Service e3b512
  static RefPtr<XlibSurface> create(Display* dpy, Drawable drawable, Visual* visual, int width, int height);
Packit Service e3b512
Packit Service e3b512
  /** Creates an Xlib surface that draws to the given bitmap. This will be
Packit Service e3b512
   * drawn to as a CAIRO_FORMAT_A1 object.
Packit Service e3b512
   *
Packit Service e3b512
   * @param dpy	an X Display
Packit Service e3b512
   * @param bitmap	an X Drawable, (a depth-1 Pixmap)
Packit Service e3b512
   * @param screen	the X Screen associated with bitmap
Packit Service e3b512
   * @param width	the current width of bitmap.
Packit Service e3b512
   * @param height	the current height of bitmap.
Packit Service e3b512
   * @return	A RefPtr to the newly created surface
Packit Service e3b512
   */
Packit Service e3b512
  static RefPtr<XlibSurface> create(Display *dpy, Pixmap bitmap, Screen *screen, int width, int height);
Packit Service e3b512
Packit Service e3b512
  /** Informs cairo of the new size of the X Drawable underlying the surface.
Packit Service e3b512
   * For a surface created for a Window (rather than a Pixmap), this function
Packit Service e3b512
   * must be called each time the size of the window changes. (For a subwindow,
Packit Service e3b512
   * you are normally resizing the window yourself, but for a toplevel window,
Packit Service e3b512
   * it is necessary to listen for ConfigureNotify events.)
Packit Service e3b512
   *
Packit Service e3b512
   * A Pixmap can never change size, so it is never necessary to call this
Packit Service e3b512
   * function on a surface created for a Pixmap.
Packit Service e3b512
   *
Packit Service e3b512
   * @param width	the new width of the surface
Packit Service e3b512
   * @param height	the new height of the surface
Packit Service e3b512
   */
Packit Service e3b512
  void set_size(int width, int height);
Packit Service e3b512
Packit Service e3b512
  /** Informs cairo of a new X Drawable underlying the surface. The drawable
Packit Service e3b512
   * must match the display, screen and format of the existing drawable or the
Packit Service e3b512
   * application will get X protocol errors and will probably terminate. No
Packit Service e3b512
   * checks are done by this function to ensure this compatibility.
Packit Service e3b512
   *
Packit Service e3b512
   * @param drawable	the new drawable for the surface
Packit Service e3b512
   * @param width	the width of the new drawable
Packit Service e3b512
   * @param height	the height of the new drawable
Packit Service e3b512
   */
Packit Service e3b512
  void set_drawable(Drawable drawable, int width, int height);
Packit Service e3b512
Packit Service e3b512
  /** gets the Drawable object associated with this surface */
Packit Service e3b512
  Drawable get_drawable() const;
Packit Service e3b512
Packit Service e3b512
  /** Get the X Display for the underlying X Drawable. */
Packit Service e3b512
  const Display* get_display() const;
Packit Service e3b512
  /** Get the X Display for the underlying X Drawable. */
Packit Service e3b512
  Display* get_display();
Packit Service e3b512
Packit Service e3b512
  /** Get the X Screen for the underlying X Drawable */
Packit Service e3b512
  Screen* get_screen();
Packit Service e3b512
  /** Get the X Screen for the underlying X Drawable */
Packit Service e3b512
  const Screen* get_screen() const;
Packit Service e3b512
Packit Service e3b512
  /** Get the X Visual for the underlying X Drawable */
Packit Service e3b512
  Visual* get_visual();
Packit Service e3b512
  /** Get the X Visual for the underlying X Drawable */
Packit Service e3b512
  const Visual* get_visual() const;
Packit Service e3b512
Packit Service e3b512
  /** Get the number of bits used to represent each pixel value. */
Packit Service e3b512
  int get_depth() const;
Packit Service e3b512
Packit Service e3b512
  /** Get the height in pixels of the X Drawable underlying the surface */
Packit Service e3b512
  int get_height() const;
Packit Service e3b512
Packit Service e3b512
  /** Get the width in pixels of the X Drawable underlying the surface */
Packit Service e3b512
  int get_width() const;
Packit Service e3b512
Packit Service e3b512
#if CAIRO_HAS_XLIB_XRENDER_SURFACE
Packit Service e3b512
  /**
Packit Service e3b512
   * Creates an Xlib surface that draws to the given drawable.  The way that
Packit Service e3b512
   * colors are represented in the drawable is specified by the provided picture
Packit Service e3b512
   * format.
Packit Service e3b512
   *
Packit Service e3b512
   * Note: If @drawable is a Window, then the function set_size() must be called
Packit Service e3b512
   * whenever the size of the window changes.
Packit Service e3b512
   *
Packit Service e3b512
   * @param dpy an X Display
Packit Service e3b512
   * @param drawable an X Drawable, (a Pixmap or a Window)
Packit Service e3b512
   * @param screen the X Screen associated with @drawable
Packit Service e3b512
   * @param format the picture format to use for drawing to @drawable. The depth
Packit Service e3b512
   *          of @format must match the depth of the drawable.
Packit Service e3b512
   * @param width the current width of @drawable.
Packit Service e3b512
   * @param height the current height of @drawable.
Packit Service e3b512
   *
Packit Service e3b512
   * @return the newly created surface
Packit Service e3b512
   **/
Packit Service e3b512
  static Cairo::RefPtr<Cairo::XlibSurface> 
Packit Service e3b512
  create_with_xrender_format (Display *dpy,
Packit Service e3b512
                              Drawable drawable,
Packit Service e3b512
                              Screen *screen,
Packit Service e3b512
                              XRenderPictFormat *format,
Packit Service e3b512
                              int width,
Packit Service e3b512
                              int height);
Packit Service e3b512
Packit Service e3b512
  /**
Packit Service e3b512
   * Gets the X Render picture format that @surface uses for rendering with the
Packit Service e3b512
   * X Render extension. If the surface was created by
Packit Service e3b512
   * cairo_xlib_surface_create_with_xrender_format() originally, the return
Packit Service e3b512
   * value is the format passed to that constructor.
Packit Service e3b512
   *
Packit Service e3b512
   * Return value: the XRenderPictFormat* associated with @surface,
Packit Service e3b512
   * or %NULL if the surface is not an xlib surface
Packit Service e3b512
   * or if the X Render extension is not available.
Packit Service e3b512
   *
Packit Service e3b512
   * Since: 1.6
Packit Service e3b512
   **/
Packit Service e3b512
  XRenderPictFormat * get_xrender_format() const;
Packit Service e3b512
Packit Service e3b512
#endif // CAIRO_HAS_XLIB_XRENDER_SURFACE
Packit Service e3b512
Packit Service e3b512
};
Packit Service e3b512
Packit Service e3b512
#endif // CAIRO_HAS_XLIB_SURFACE
Packit Service e3b512
Packit Service e3b512
} // namespace Cairo
Packit Service e3b512
Packit Service e3b512
#endif //__CAIROMM_XLIB_SURFACE_H
Packit Service e3b512
Packit Service e3b512
// vim: ts=2 sw=2 et