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