Blame cairomm/context.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_CONTEXT_H
Packit 908522
#define __CAIROMM_CONTEXT_H
Packit 908522
Packit 908522
#include <vector>
Packit 908522
#include <utility>
Packit 908522
#include <cairomm/surface.h>
Packit 908522
#include <cairomm/fontface.h>
Packit 908522
#include <cairomm/matrix.h>
Packit 908522
#include <cairomm/pattern.h>
Packit 908522
#include <cairomm/path.h>
Packit 908522
#include <cairomm/scaledfont.h>
Packit 908522
#include <cairomm/types.h>
Packit 908522
#include <valarray>
Packit 908522
#include <vector>
Packit 908522
#include <cairo.h>
Packit 908522
Packit 908522
Packit 908522
namespace Cairo
Packit 908522
{
Packit 908522
Packit 908522
/**
Packit 908522
 * Context is the main class used to draw in cairomm. It contains the current
Packit 908522
 * state of the rendering device, including coordinates of yet to be drawn 
Packit 908522
 * shapes.
Packit 908522
 * 
Packit 908522
 * In the simplest case, create a Context with its target Surface, set its
Packit 908522
 * drawing options (line width, color, etc), create shapes with methods like
Packit 908522
 * move_to() and line_to(), and then draw the shapes to the Surface using
Packit 908522
 * methods such as stroke() or fill().
Packit 908522
 *
Packit 908522
 * Context is a reference-counted object that should be used via Cairo::RefPtr.
Packit 908522
 */
Packit 908522
class Context
Packit 908522
{
Packit 908522
protected:
Packit 908522
  explicit Context(const RefPtr<Surface>& target);
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 Context(cairo_t* cobject, bool has_reference = false);
Packit 908522
Packit 908522
  Context(const Context&) = delete;
Packit 908522
  Context& operator=(const Context&) = delete;
Packit 908522
Packit 908522
  static RefPtr<Context> create(const RefPtr<Surface>& target);
Packit 908522
Packit 908522
  virtual ~Context();
Packit 908522
Packit 908522
  /** Makes a copy of the current state of the Context and saves it on an
Packit 908522
   * internal stack of saved states. When restore() is called, it will be
Packit 908522
   * restored to the saved state. Multiple calls to save() and restore() can be
Packit 908522
   * nested; each call to restore() restores the state from the matching paired
Packit 908522
   * save().
Packit 908522
   *
Packit 908522
   * It isn't necessary to clear all saved states before a cairo_t is freed.
Packit 908522
   * Any saved states will be freed when the Context is destroyed.
Packit 908522
   *
Packit 908522
   * @sa restore()
Packit 908522
   */
Packit 908522
  void save();
Packit 908522
Packit 908522
  /** Restores cr to the state saved by a preceding call to save() and removes
Packit 908522
   * that state from the stack of saved states.
Packit 908522
   *
Packit 908522
   * @sa save()
Packit 908522
   */
Packit 908522
  void restore();
Packit 908522
Packit 908522
  /** Sets the compositing operator to be used for all drawing operations. See
Packit 908522
   * Operator for details on the semantics of each available compositing
Packit 908522
   * operator.
Packit 908522
   *
Packit 908522
   * @param op	a compositing operator, specified as a Operator
Packit 908522
   */
Packit 908522
  void set_operator(Operator op);
Packit 908522
Packit 908522
  /** Sets the source pattern within the Context to source. This Pattern will
Packit 908522
   * then be used for any subsequent drawing operation until a new source
Packit 908522
   * pattern is set.
Packit 908522
   *
Packit 908522
   * Note: The Pattern's transformation matrix will be locked to the user space
Packit 908522
   * in effect at the time of set_source(). This means that further
Packit 908522
   * modifications of the current transformation matrix will not affect the
Packit 908522
   * source pattern.
Packit 908522
   *
Packit 908522
   * @param source	a Pattern to be used as the source for subsequent drawing
Packit 908522
   * operations.
Packit 908522
   *
Packit 908522
   * @sa Pattern::set_matrix()
Packit 908522
   * @sa set_source_rgb()
Packit 908522
   * @sa set_source_rgba()
Packit 908522
   * @sa set_source(const RefPtr<Surface>& surface, double x, double y)
Packit 908522
   */
Packit 908522
  void set_source(const RefPtr<const Pattern>& source);
Packit 908522
Packit 908522
  /** Sets the source pattern within the Context to an opaque color. This
Packit 908522
   * opaque color will then be used for any subsequent drawing operation until
Packit 908522
   * a new source pattern is set.
Packit 908522
   *
Packit 908522
   * The color components are floating point numbers in the range 0 to 1. If
Packit 908522
   * the values passed in are outside that range, they will be clamped.
Packit 908522
   *
Packit 908522
   * @param red	red component of color
Packit 908522
   * @param green	green component of color
Packit 908522
   * @param blue	blue component of color
Packit 908522
   *
Packit 908522
   * @sa set_source_rgba()
Packit 908522
   * @sa set_source()
Packit 908522
   */
Packit 908522
  void set_source_rgb(double red, double green, double blue);
Packit 908522
Packit 908522
  /** Sets the source pattern within the Context to a translucent color. This
Packit 908522
   * color will then be used for any subsequent drawing operation until a new
Packit 908522
   * source pattern is set.
Packit 908522
   *
Packit 908522
   * The color and alpha components are floating point numbers in the range 0
Packit 908522
   * to 1. If the values passed in are outside that range, they will be
Packit 908522
   * clamped.
Packit 908522
   *
Packit 908522
   * @param red	red component of color
Packit 908522
   * @param green	green component of color
Packit 908522
   * @param blue	blue component of color
Packit 908522
   * @param alpha	alpha component of color
Packit 908522
   *
Packit 908522
   * @sa set_source_rgb()
Packit 908522
   * @sa set_source()
Packit 908522
   */
Packit 908522
  void set_source_rgba(double red, double green, double blue, double alpha);
Packit 908522
Packit 908522
  /** This is a convenience function for creating a pattern from a Surface and
Packit 908522
   * setting it as the source
Packit 908522
   *
Packit 908522
   * The x and y parameters give the user-space coordinate at which the Surface
Packit 908522
   * origin should appear. (The Surface origin is its upper-left corner before
Packit 908522
   * any transformation has been applied.) The x and y patterns are negated and
Packit 908522
   * then set as translation values in the pattern matrix.
Packit 908522
   *
Packit 908522
   * Other than the initial translation pattern matrix, as described above, all
Packit 908522
   * other pattern attributes, (such as its extend mode), are set to the
Packit 908522
   * default values as in Context::create(const RefPtr<Surface>& target). The
Packit 908522
   * resulting pattern can be queried with get_source() so that these
Packit 908522
   * attributes can be modified if desired, (eg. to create a repeating pattern
Packit 908522
   * with Pattern::set_extend()).
Packit 908522
   *
Packit 908522
   * @param surface  	a Surface to be used to set the source pattern
Packit 908522
   * @param x  	User-space X coordinate for surface origin
Packit 908522
   * @param y  	User-space Y coordinate for surface origin
Packit 908522
   */
Packit 908522
  void set_source(const RefPtr<Surface>& surface, double x, double y);
Packit 908522
Packit 908522
  /** Sets the tolerance used when converting paths into trapezoids. Curved
Packit 908522
   * segments of the path will be subdivided until the maximum deviation
Packit 908522
   * between the original path and the polygonal approximation is less than
Packit 908522
   * tolerance. The default value is 0.1. A larger value will give better
Packit 908522
   * performance, a smaller value, better appearance. (Reducing the value from
Packit 908522
   * the default value of 0.1 is unlikely to improve appearance significantly.)
Packit 908522
   * The accuracy of paths within Cairo is limited by the precision of its 
Packit 908522
   * internal arithmetic, and the prescribed @tolerance is restricted to the 
Packit 908522
   * smallest representable internal value.
Packit 908522
   * 
Packit 908522
   * @param tolerance	the tolerance, in device units (typically pixels)
Packit 908522
   */
Packit 908522
  void set_tolerance(double tolerance);
Packit 908522
Packit 908522
  /** Set the antialiasing mode of the rasterizer used for drawing shapes. This
Packit 908522
   * value is a hint, and a particular backend may or may not support a
Packit 908522
   * particular value. At the current time, no backend supports
Packit 908522
   * Cairo::ANTIALIAS_SUBPIXEL when drawing shapes.
Packit 908522
   *
Packit 908522
   * Note that this option does not affect text rendering, instead see
Packit 908522
   * FontOptions::set_antialias().
Packit 908522
   *
Packit 908522
   * @param antialias	the new antialiasing mode
Packit 908522
   */
Packit 908522
  void set_antialias(Antialias antialias);
Packit 908522
Packit 908522
  /** Set the current fill rule within the cairo Context. The fill rule is used
Packit 908522
   * to determine which regions are inside or outside a complex (potentially
Packit 908522
   * self-intersecting) path. The current fill rule affects both fill() and
Packit 908522
   * clip(). See FillRule for details on the semantics of each available fill
Packit 908522
   * rule.
Packit 908522
   *
Packit 908522
   * The default fill rule is Cairo::FILL_RULE_WINDING.
Packit 908522
   * 
Packit 908522
   * @param fill_rule	a fill rule, specified as a FillRule
Packit 908522
   */
Packit 908522
  void set_fill_rule(FillRule fill_rule);
Packit 908522
Packit 908522
  /** Sets the current line width within the cairo Context. The line width
Packit 908522
   * specifies the diameter of a pen that is circular in user-space, (though 
Packit 908522
   * device-space pen may be an ellipse in general due to scaling/shear/rotation 
Packit 908522
   * of the CTM).
Packit 908522
   *
Packit 908522
   * Note: When the description above refers to user space and CTM it refers to
Packit 908522
   * the user space and CTM in effect at the time of the stroking operation,
Packit 908522
   * not the user space and CTM in effect at the time of the call to
Packit 908522
   * set_line_width(). The simplest usage makes both of these spaces
Packit 908522
   * identical. That is, if there is no change to the CTM between a call to
Packit 908522
   * set_line_width() and the stroking operation, then one can just pass
Packit 908522
   * user-space values to set_line_width() and ignore this note.
Packit 908522
   *
Packit 908522
   * As with the other stroke parameters, the current line cap style is
Packit 908522
   * examined by stroke(), stroke_extents(), and stroke_to_path(), but does not
Packit 908522
   * have any effect during path construction.
Packit 908522
   * 
Packit 908522
   * The default line width value is 2.0.
Packit 908522
   *
Packit 908522
   * @param width	a line width, as a user-space value
Packit 908522
   */
Packit 908522
  void set_line_width(double width);
Packit 908522
Packit 908522
  /** Sets the current line cap style within the cairo Context. See
Packit 908522
   * LineCap for details about how the available line cap styles are drawn.
Packit 908522
   *
Packit 908522
   * As with the other stroke parameters, the current line cap style is
Packit 908522
   * examined by stroke(), stroke_extents(), and stroke_to_path(), but does not
Packit 908522
   * have any effect during path construction.
Packit 908522
   * 
Packit 908522
   * The default line cap style is Cairo::LINE_CAP_BUTT.
Packit 908522
   *
Packit 908522
   * @param line_cap	a line cap style, as a LineCap
Packit 908522
   */
Packit 908522
  void set_line_cap(LineCap line_cap);
Packit 908522
Packit 908522
  /** Sets the current line join style within the cairo Context. See LineJoin
Packit 908522
   * for details about how the available line join styles are drawn.
Packit 908522
   *
Packit 908522
   * As with the other stroke parameters, the current line join style is
Packit 908522
   * examined by stroke(), stroke_extents(), and stroke_to_path(), but does not
Packit 908522
   * have any effect during path construction.
Packit 908522
   *
Packit 908522
   * The default line join style is Cairo::LINE_JOIN_MITER.
Packit 908522
   *
Packit 908522
   * @param line_join	a line joint style, as a LineJoin
Packit 908522
   */
Packit 908522
  void set_line_join(LineJoin line_join);
Packit 908522
Packit 908522
#ifndef CAIROMM_DISABLE_DEPRECATED
Packit 908522
  /**
Packit 908522
   * Alternate version of set_dash().  You'll probably want to use the one that
Packit 908522
   * takes a std::vector argument instead.
Packit 908522
   *
Packit 908522
   * @deprecated Instead use the version that takes a const dashes parameter.
Packit 908522
   */
Packit 908522
  void set_dash(std::valarray<double>& dashes, double offset);
Packit 908522
Packit 908522
  /** Sets the dash pattern to be used by stroke(). A dash pattern is specified
Packit 908522
   * by dashes, an array of positive values. Each value provides the user-space
Packit 908522
   * length of altenate "on" and "off" portions of the stroke. The offset
Packit 908522
   * specifies an offset into the pattern at which the stroke begins.
Packit 908522
   *
Packit 908522
   * If dashes is empty dashing is disabled.  If the size of dashes is 1, a
Packit 908522
   * symmetric pattern is assumed with alternating on and off portions of the
Packit 908522
   * size specified by the single value in dashes.
Packit 908522
   *
Packit 908522
   * It is invalid for any value in dashes to be negative, or for all values to
Packit 908522
   * be 0.  If this is the case, an exception will be thrown
Packit 908522
   *
Packit 908522
   * @param dashes	an array specifying alternate lengths of on and off portions
Packit 908522
   * @param offset	an offset into the dash pattern at which the stroke should start
Packit 908522
   *
Packit 908522
   * @exception
Packit 908522
   *
Packit 908522
   * @deprecated Instead use the version that takes a const dashes parameter.
Packit 908522
   */
Packit 908522
  void set_dash(std::vector<double>& dashes, double offset);
Packit 908522
#endif //CAIROMM_DISABLE_DEPRECATED
Packit 908522
Packit 908522
  /**
Packit 908522
   * Alternate version of set_dash().  You'll probably want to use the one that
Packit 908522
   * takes a std::vector argument instead.
Packit 908522
   */
Packit 908522
  void set_dash(const std::valarray<double>& dashes, double offset);
Packit 908522
Packit 908522
  /** Sets the dash pattern to be used by stroke(). A dash pattern is specified
Packit 908522
   * by dashes, an array of positive values. Each value provides the user-space
Packit 908522
   * length of altenate "on" and "off" portions of the stroke. The offset
Packit 908522
   * specifies an offset into the pattern at which the stroke begins.
Packit 908522
   *
Packit 908522
   * Each "on" segment will have caps applied as if the segment were a separate
Packit 908522
   * sub-path. In particular, it is valid to use an "on" length of 0.0 with
Packit 908522
   * Cairo::LINE_CAP_ROUND or Cairo::LINE_CAP_SQUARE in order to distributed
Packit 908522
   * dots or squares along a path.
Packit 908522
   *
Packit 908522
   * Note: The length values are in user-space units as evaluated at the time
Packit 908522
   * of stroking. This is not necessarily the same as the user space at the
Packit 908522
   * time of set_dash().
Packit 908522
   *
Packit 908522
   * If dashes is empty dashing is disabled. If the size of dashes is 1, a
Packit 908522
   * symmetric pattern is assumed with alternating on and off portions of the
Packit 908522
   * size specified by the single value in dashes.
Packit 908522
   *
Packit 908522
   * It is invalid for any value in dashes to be negative, or for all values to
Packit 908522
   * be 0.  If this is the case, an exception will be thrown
Packit 908522
   *
Packit 908522
   * @param dashes	an array specifying alternate lengths of on and off portions
Packit 908522
   * @param offset	an offset into the dash pattern at which the stroke should start
Packit 908522
   *
Packit 908522
   * @exception
Packit 908522
   */
Packit 908522
  void set_dash(const std::vector<double>& dashes, double offset);
Packit 908522
Packit 908522
  /** This function disables a dash pattern that was set with set_dash()
Packit 908522
   */
Packit 908522
  void unset_dash();
Packit 908522
  
Packit 908522
  /**
Packit 908522
   * Sets the current miter limit within the cairo context.
Packit 908522
   *
Packit 908522
   * If the current line join style is set to Cairo::LINE_JOIN_MITER (see
Packit 908522
   * set_line_join()), the miter limit is used to determine whether the lines
Packit 908522
   * should be joined with a bevel instead of a miter. Cairo divides the length
Packit 908522
   * of the miter by the line width. If the result is greater than the miter
Packit 908522
   * limit, the style is converted to a bevel.
Packit 908522
   *
Packit 908522
   * As with the other stroke parameters, the current line miter limit is
Packit 908522
   * examined by stroke(), stroke_extents(), and stroke_to_path(), but does not
Packit 908522
   * have any effect during path construction.
Packit 908522
   *
Packit 908522
   * The default miter limit value is 10.0, which will convert joins with
Packit 908522
   * interior angles less than 11 degrees to bevels instead of miters. For
Packit 908522
   * reference, a miter limit of 2.0 makes the miter cutoff at 60 degrees, and
Packit 908522
   * a miter limit of 1.414 makes the cutoff at 90 degrees.
Packit 908522
   *
Packit 908522
   * A miter limit for a desired angle can be computed as: miter_limit =
Packit 908522
   * 1/sin(angle/2)
Packit 908522
   *
Packit 908522
   * @param limit miter limit to set
Packit 908522
   **/
Packit 908522
  void set_miter_limit(double limit);
Packit 908522
Packit 908522
  /** Modifies the current transformation matrix (CTM) by translating the
Packit 908522
   * user-space origin by (tx, ty). This offset is interpreted as a user-space
Packit 908522
   * coordinate according to the CTM in place before the new call to
Packit 908522
   * translate. In other words, the translation of the user-space origin
Packit 908522
   * takes place after any existing transformation.
Packit 908522
   *
Packit 908522
   * @param tx	amount to translate in the X direction
Packit 908522
   * @param ty	amount to translate in the Y direction
Packit 908522
   */
Packit 908522
  void translate(double tx, double ty);
Packit 908522
Packit 908522
  /** Modifies the current transformation matrix (CTM) by scaling the X and Y
Packit 908522
   * user-space axes by sx and sy respectively. The scaling of the axes takes
Packit 908522
   * place after any existing transformation of user space.
Packit 908522
   *
Packit 908522
   * @param sx	scale factor for the X dimension
Packit 908522
   * @param sy	scale factor for the Y dimension
Packit 908522
   */
Packit 908522
  void scale(double sx, double sy);
Packit 908522
Packit 908522
  /** Modifies the current transformation matrix (CTM) by rotating the
Packit 908522
   * user-space axes by angle radians. The rotation of the axes takes places
Packit 908522
   * after any existing transformation of user space. The rotation direction
Packit 908522
   * for positive angles is from the positive X axis toward the positive Y
Packit 908522
   * axis.
Packit 908522
   *
Packit 908522
   * @param angle	angle (in radians) by which the user-space axes will be
Packit 908522
   * rotated
Packit 908522
   */
Packit 908522
  void rotate(double angle_radians);
Packit 908522
Packit 908522
  /** A convenience wrapper around rotate() that accepts angles in degrees
Packit 908522
   *
Packit 908522
   * @param angle_degrees angle (in degrees) by which the user-space axes
Packit 908522
   * should be rotated
Packit 908522
   */
Packit 908522
  void rotate_degrees(double angle_degres);
Packit 908522
Packit 908522
  /** Modifies the current transformation matrix (CTM) by applying matrix as an
Packit 908522
   * additional transformation. The new transformation of user space takes
Packit 908522
   * place after any existing transformation.
Packit 908522
   *
Packit 908522
   * @param matrix	a transformation to be applied to the user-space axes
Packit 908522
   */
Packit 908522
  void transform(const Matrix& matrix);
Packit 908522
Packit 908522
  /* To keep 1.6.x ABI  */
Packit 908522
  void transform(const cairo_matrix_t& matrix);
Packit 908522
Packit 908522
  /** Modifies the current transformation matrix (CTM) by setting it equal to
Packit 908522
   * matrix.
Packit 908522
   *
Packit 908522
   * @param matrix	a transformation matrix from user space to device space
Packit 908522
   */
Packit 908522
  void set_matrix(const Matrix& matrix);
Packit 908522
Packit 908522
  /* To keep 1.6.x ABI  */
Packit 908522
  void set_matrix(const cairo_matrix_t& matrix);
Packit 908522
Packit 908522
  /** Resets the current transformation matrix (CTM) by setting it equal to the
Packit 908522
   * identity matrix. That is, the user-space and device-space axes will be
Packit 908522
   * aligned and one user-space unit will transform to one device-space unit.
Packit 908522
   */
Packit 908522
  void set_identity_matrix();
Packit 908522
Packit 908522
#ifndef CAIROMM_DISABLE_DEPRECATED
Packit 908522
  /** Transform a coordinate from user space to device space by multiplying the
Packit 908522
   * given point by the current transformation matrix (CTM).
Packit 908522
   *
Packit 908522
   * @param x	X value of coordinate (in/out parameter)
Packit 908522
   * @param y	Y value of coordinate (in/out parameter)
Packit 908522
   *
Packit 908522
   * @deprecated Use the const version.
Packit 908522
   */
Packit 908522
  void user_to_device(double& x, double& y);
Packit 908522
Packit 908522
  /** Transform a distance vector from user space to device space. This
Packit 908522
   * function is similar to user_to_device() except that the translation
Packit 908522
   * components of the CTM will be ignored when transforming (dx,dy).
Packit 908522
   *
Packit 908522
   * @param dx	X component of a distance vector (in/out parameter)
Packit 908522
   * @param dy	Y component of a distance vector (in/out parameter)
Packit 908522
   *
Packit 908522
   * @deprecated Use the const version.
Packit 908522
   */
Packit 908522
  void user_to_device_distance(double& dx, double& dy);
Packit 908522
Packit 908522
  /** Transform a coordinate from device space to user space by multiplying the
Packit 908522
   * given point by the inverse of the current transformation matrix (CTM).
Packit 908522
   *
Packit 908522
   * @param x	X value of coordinate (in/out parameter)
Packit 908522
   * @param y	Y value of coordinate (in/out parameter)
Packit 908522
   *
Packit 908522
   * @deprecated Use the const version.
Packit 908522
   */
Packit 908522
  void device_to_user(double& x, double& y);
Packit 908522
Packit 908522
  /** Transform a distance vector from device space to user space. This
Packit 908522
   * function is similar to device_to_user() except that the translation
Packit 908522
   * components of the inverse CTM will be ignored when transforming (dx,dy).
Packit 908522
   *
Packit 908522
   * @param dx	X component of a distance vector (in/out parameter)
Packit 908522
   * @param dy	Y component of a distance vector (in/out parameter)
Packit 908522
   *
Packit 908522
   * @deprecated Use the const version.
Packit 908522
   */
Packit 908522
  void device_to_user_distance(double& dx, double& dy);
Packit 908522
#endif //CAIROMM_DISABLE_DEPRECATED
Packit 908522
Packit 908522
  /** Transform a coordinate from user space to device space by multiplying the
Packit 908522
   * given point by the current transformation matrix (CTM).
Packit 908522
   *
Packit 908522
   * @param x	X value of coordinate (in/out parameter)
Packit 908522
   * @param y	Y value of coordinate (in/out parameter)
Packit 908522
   */
Packit 908522
  void user_to_device(double& x, double& y) const;
Packit 908522
Packit 908522
  /** Transform a distance vector from user space to device space. This
Packit 908522
   * function is similar to user_to_device() except that the translation
Packit 908522
   * components of the CTM will be ignored when transforming (dx,dy).
Packit 908522
   *
Packit 908522
   * @param dx	X component of a distance vector (in/out parameter)
Packit 908522
   * @param dy	Y component of a distance vector (in/out parameter)
Packit 908522
   */
Packit 908522
  void user_to_device_distance(double& dx, double& dy) const;
Packit 908522
Packit 908522
  /** Transform a coordinate from device space to user space by multiplying the
Packit 908522
   * given point by the inverse of the current transformation matrix (CTM).
Packit 908522
   *
Packit 908522
   * @param x	X value of coordinate (in/out parameter)
Packit 908522
   * @param y	Y value of coordinate (in/out parameter)
Packit 908522
   */
Packit 908522
  void device_to_user(double& x, double& y) const;
Packit 908522
Packit 908522
  /** Transform a distance vector from device space to user space. This
Packit 908522
   * function is similar to device_to_user() except that the translation
Packit 908522
   * components of the inverse CTM will be ignored when transforming (dx,dy).
Packit 908522
   *
Packit 908522
   * @param dx	X component of a distance vector (in/out parameter)
Packit 908522
   * @param dy	Y component of a distance vector (in/out parameter)
Packit 908522
   */
Packit 908522
  void device_to_user_distance(double& dx, double& dy) const;
Packit 908522
Packit 908522
  /** Clears the current path. After this call there will be no current point.
Packit 908522
   */
Packit 908522
  void begin_new_path();
Packit 908522
Packit 908522
  /** Begin a new subpath. Note that the existing path is not affected. After
Packit 908522
   * this call there will be no current point.
Packit 908522
   *
Packit 908522
   * In many cases, this call is not needed since new subpaths are frequently
Packit 908522
   * started with move_to().
Packit 908522
   *
Packit 908522
   * A call to begin_new_sub_path() is particularly useful when beginning a new
Packit 908522
   * subpath with one of the arc() calls. This makes things easier as it is no
Packit 908522
   * longer necessary to manually compute the arc's initial coordinates for a
Packit 908522
   * call to move_to().
Packit 908522
   *
Packit 908522
   * @since 1.2
Packit 908522
   */
Packit 908522
  void begin_new_sub_path();
Packit 908522
Packit 908522
  /** If the current subpath is not empty, begin a new subpath. After this call
Packit 908522
   * the current point will be (x, y).
Packit 908522
   *
Packit 908522
   * @param x	the X coordinate of the new position
Packit 908522
   * @param y	the Y coordinate of the new position
Packit 908522
   */
Packit 908522
  void move_to(double x, double y);
Packit 908522
Packit 908522
  /** Adds a line to the path from the current point to position (x, y) in
Packit 908522
   * user-space coordinates. After this call the current point will be (x, y).
Packit 908522
   * 
Packit 908522
   * If there is no current point before the call to line_to()
Packit 908522
   * this function will behave as move_to(x, y).
Packit 908522
   *
Packit 908522
   * @param x	the X coordinate of the end of the new line
Packit 908522
   * @param y	the Y coordinate of the end of the new line
Packit 908522
   */
Packit 908522
  void line_to(double x, double y);
Packit 908522
Packit 908522
  /** Adds a cubic Bezier spline to the path from the current point to position
Packit 908522
   * (x3, y3) in user-space coordinates, using (x1, y1) and (x2, y2) as the
Packit 908522
   * control points. After this call the current point will be (x3, y3).
Packit 908522
   *
Packit 908522
   * If there is no current point before the call to curve_to()
Packit 908522
   * this function will behave as if preceded by a call to
Packit 908522
   * move_to(x1, y1).
Packit 908522
   * 
Packit 908522
   * @param x1	the X coordinate of the first control point
Packit 908522
   * @param y1	the Y coordinate of the first control point
Packit 908522
   * @param x2	the X coordinate of the second control point
Packit 908522
   * @param y2	the Y coordinate of the second control point
Packit 908522
   * @param x3	the X coordinate of the end of the curve
Packit 908522
   * @param y3	the Y coordinate of the end of the curve
Packit 908522
   */
Packit 908522
  void curve_to(double x1, double y1, double x2, double y2, double x3, double y3);
Packit 908522
Packit 908522
  /** Adds a circular arc of the given radius to the current path. The arc is
Packit 908522
   * centered at (@a xc, @a yc), begins at @a angle1 and proceeds in the direction of
Packit 908522
   * increasing angles to end at @a angle2. If @a angle2 is less than @a angle1 it will
Packit 908522
   * be progressively increased by 2*M_PI until it is greater than @a angle1.
Packit 908522
   *
Packit 908522
   * If there is a current point, an initial line segment will be added to the
Packit 908522
   * path to connect the current point to the beginning of the arc. If this
Packit 908522
   * initial line is undesired, it can be avoided by calling
Packit 908522
   * begin_new_sub_path() before calling arc().
Packit 908522
   *
Packit 908522
   * Angles are measured in radians. An angle of 0 is in the direction of the
Packit 908522
   * positive X axis (in user-space). An angle of M_PI/2.0 radians (90 degrees) is
Packit 908522
   * in the direction of the positive Y axis (in user-space). Angles increase
Packit 908522
   * in the direction from the positive X axis toward the positive Y axis. So
Packit 908522
   * with the default transformation matrix, angles increase in a clockwise
Packit 908522
   * direction.
Packit 908522
   *
Packit 908522
   * ( To convert from degrees to radians, use degrees * (M_PI / 180.0). )
Packit 908522
   *
Packit 908522
   * This function gives the arc in the direction of increasing angles; see
Packit 908522
   * arc_negative() to get the arc in the direction of decreasing angles.
Packit 908522
   *
Packit 908522
   * The arc is circular in user-space. To achieve an elliptical arc, you can
Packit 908522
   * scale the current transformation matrix by different amounts in the X and
Packit 908522
   * Y directions. For example, to draw an ellipse in the box given by x, y,
Packit 908522
   * width, height:
Packit 908522
   *
Packit 908522
   * @code
Packit 908522
   * context->save();
Packit 908522
   * context->translate(x, y);
Packit 908522
   * context->scale(width / 2.0, height / 2.0);
Packit 908522
   * context->arc(0.0, 0.0, 1.0, 0.0, 2 * M_PI);
Packit 908522
   * context->restore();
Packit 908522
   * @endcode
Packit 908522
   *
Packit 908522
   * @param xc	X position of the center of the arc
Packit 908522
   * @param yc	Y position of the center of the arc
Packit 908522
   * @param radius	the radius of the arc
Packit 908522
   * @param angle1	the start angle, in radians
Packit 908522
   * @param angle2	the end angle, in radians
Packit 908522
   */
Packit 908522
  void arc(double xc, double yc, double radius, double angle1, double angle2);
Packit 908522
Packit 908522
  /** Adds a circular arc of the given @a radius to the current path. The arc is
Packit 908522
   * centered at (@a xc, @a yc), begins at @a angle1 and proceeds in the direction of
Packit 908522
   * decreasing angles to end at @a angle2. If @a angle2 is greater than @a angle1 it
Packit 908522
   * will be progressively decreased by 2*M_PI until it is greater than @a angle1.
Packit 908522
   *
Packit 908522
   * See arc() for more details. This function differs only in the direction of
Packit 908522
   * the arc between the two angles.
Packit 908522
   *
Packit 908522
   * @param xc	X position of the center of the arc
Packit 908522
   * @param yc	Y position of the center of the arc
Packit 908522
   * @param radius	the radius of the arc
Packit 908522
   * @param angle1	the start angle, in radians
Packit 908522
   * @param angle2	the end angle, in radians
Packit 908522
   */
Packit 908522
  void arc_negative(double xc, double yc, double radius, double angle1, double angle2);
Packit 908522
Packit 908522
  /** If the current subpath is not empty, begin a new subpath. After this call
Packit 908522
   * the current point will offset by (x, y).
Packit 908522
   *
Packit 908522
   * Given a current point of (x, y),
Packit 908522
   * @code
Packit 908522
   * rel_move_to(dx, dy)
Packit 908522
   * @endcode
Packit 908522
   * is logically equivalent to
Packit 908522
   * @code
Packit 908522
   * move_to(x + dx, y + dy)
Packit 908522
   * @endcode
Packit 908522
   *
Packit 908522
   * @param dx	the X offset
Packit 908522
   * @param dy	the Y offset
Packit 908522
   *
Packit 908522
   * It is an error to call this function with no current point. Doing
Packit 908522
   * so will cause this to shutdown with a status of
Packit 908522
   * CAIRO_STATUS_NO_CURRENT_POINT. Cairomm will then throw an exception.
Packit 908522
   */
Packit 908522
  void rel_move_to(double dx, double dy);
Packit 908522
Packit 908522
  /** Relative-coordinate version of line_to(). Adds a line to the path from
Packit 908522
   * the current point to a point that is offset from the current point by (dx,
Packit 908522
   * dy) in user space. After this call the current point will be offset by
Packit 908522
   * (dx, dy).
Packit 908522
   *
Packit 908522
   * Given a current point of (x, y),
Packit 908522
   * @code
Packit 908522
   * rel_line_to(dx, dy)
Packit 908522
   * @endcode
Packit 908522
   * is logically equivalent to
Packit 908522
   * @code
Packit 908522
   * line_to(x + dx, y + dy).
Packit 908522
   * @endcode
Packit 908522
   *
Packit 908522
   * @param dx	the X offset to the end of the new line
Packit 908522
   * @param dy	the Y offset to the end of the new line
Packit 908522
   *
Packit 908522
   * It is an error to call this function with no current point. Doing
Packit 908522
   * so will cause this to shutdown with a status of
Packit 908522
   * CAIRO_STATUS_NO_CURRENT_POINT. Cairomm will then throw an exception.
Packit 908522
   */
Packit 908522
  void rel_line_to(double dx, double dy);
Packit 908522
Packit 908522
  /** Relative-coordinate version of curve_to(). All offsets are relative to
Packit 908522
   * the current point. Adds a cubic Bezier spline to the path from the current
Packit 908522
   * point to a point offset from the current point by (dx3, dy3), using points
Packit 908522
   * offset by (dx1, dy1) and (dx2, dy2) as the control points.  After this
Packit 908522
   * call the current point will be offset by (dx3, dy3).
Packit 908522
   *
Packit 908522
   * Given a current point of (x, y),
Packit 908522
   * @code
Packit 908522
   * rel_curve_to(dx1, dy1, dx2, dy2, dx3, dy3)
Packit 908522
   * @endcode
Packit 908522
   * is logically equivalent to
Packit 908522
   * @code
Packit 908522
   * curve_to(x + dx1, y + dy1, x + dx2, y + dy2, x + dx3, y + dy3).
Packit 908522
   * @endcode
Packit 908522
   *
Packit 908522
   * @param dx1	the X offset to the first control point
Packit 908522
   * @param dy1	the Y offset to the first control point
Packit 908522
   * @param dx2	the X offset to the second control point
Packit 908522
   * @param dy2	the Y offset to the second control point
Packit 908522
   * @param dx3	the X offset to the end of the curve
Packit 908522
   * @param dy3	the Y offset to the end of the curve
Packit 908522
   *
Packit 908522
   * It is an error to call this function with no current point. Doing
Packit 908522
   * so will cause this to shutdown with a status of
Packit 908522
   * CAIRO_STATUS_NO_CURRENT_POINT. Cairomm will then throw an exception.
Packit 908522
   */
Packit 908522
  void rel_curve_to(double dx1, double dy1, double dx2, double dy2, double dx3, double dy3);
Packit 908522
Packit 908522
  /** Adds a closed-subpath rectangle of the given size to the current path at
Packit 908522
   * position (x, y) in user-space coordinates.
Packit 908522
   *
Packit 908522
   * This function is logically equivalent to:
Packit 908522
   *
Packit 908522
   * @code
Packit 908522
   * context->move_to(x, y);
Packit 908522
   * context->rel_line_to(width, 0);
Packit 908522
   * context->rel_line_to(0, height);
Packit 908522
   * context->rel_line_to(-width, 0);
Packit 908522
   * context->close_path();
Packit 908522
   * @endcode
Packit 908522
   *
Packit 908522
   * @param x	the X coordinate of the top left corner of the rectangle
Packit 908522
   * @param y	the Y coordinate to the top left corner of the rectangle
Packit 908522
   * @param width	the width of the rectangle
Packit 908522
   * @param height	the height of the rectangle
Packit 908522
   */
Packit 908522
  void rectangle(double x, double y, double width, double height);
Packit 908522
Packit 908522
  /** Adds a line segment to the path from the current point to the beginning
Packit 908522
   * of the current subpath, (the most recent point passed to move_to()), and
Packit 908522
   * closes this subpath. After this call the current point will be at the 
Packit 908522
   * joined endpoint of the sub-path.
Packit 908522
   *
Packit 908522
   * The behavior of close_path() is distinct from simply calling line_to()
Packit 908522
   * with the equivalent coordinate in the case of stroking.  When a closed
Packit 908522
   * subpath is stroked, there are no caps on the ends of the subpath. Instead,
Packit 908522
   * there is a line join connecting the final and initial segments of the
Packit 908522
   * subpath.
Packit 908522
   * 
Packit 908522
   * If there is no current point before the call to close_path(),
Packit 908522
   * this function will have no effect.
Packit 908522
   *
Packit 908522
   */
Packit 908522
  void close_path();
Packit 908522
Packit 908522
  /** A drawing operator that paints the current source everywhere within the
Packit 908522
   * current clip region.
Packit 908522
   */
Packit 908522
  void paint();
Packit 908522
Packit 908522
  /** A drawing operator that paints the current source everywhere within the
Packit 908522
   * current clip region using a mask of constant alpha value alpha. The effect
Packit 908522
   * is similar to paint(), but the drawing is faded out using the alpha
Packit 908522
   * value.
Packit 908522
   *
Packit 908522
   * @param alpha	an alpha value, between 0 (transparent) and 1 (opaque)
Packit 908522
   */
Packit 908522
  void paint_with_alpha(double alpha);
Packit 908522
Packit 908522
  /** A drawing operator that paints the current source using the alpha channel
Packit 908522
   * of pattern as a mask. (Opaque areas of mask are painted with the source,
Packit 908522
   * transparent areas are not painted.)
Packit 908522
   *
Packit 908522
   * @param pattern a Pattern
Packit 908522
   */
Packit 908522
  void mask(const RefPtr<const Pattern>& pattern);
Packit 908522
Packit 908522
  /** A drawing operator that paints the current source using the alpha channel
Packit 908522
   * of surface as a mask. (Opaque areas of surface are painted with the
Packit 908522
   * source, transparent areas are not painted.)
Packit 908522
   *
Packit 908522
   * @param surface	a Surface
Packit 908522
   * @param surface_x	X coordinate at which to place the origin of surface
Packit 908522
   * @param surface_y	Y coordinate at which to place the origin of surface
Packit 908522
   */
Packit 908522
  void mask(const RefPtr<const Surface>& surface, double surface_x, double surface_y);
Packit 908522
Packit 908522
  /** A drawing operator that strokes the current Path according to the current
Packit 908522
   * line width, line join, line cap, and dash settings. After stroke(),
Packit 908522
   * the current Path will be cleared from the cairo Context.
Packit 908522
   *
Packit 908522
   * @sa set_line_width()
Packit 908522
   * @sa set_line_join()
Packit 908522
   * @sa set_line_cap()
Packit 908522
   * @sa set_dash()
Packit 908522
   * @sa stroke_preserve().
Packit 908522
   * 
Packit 908522
   * Note: Degenerate segments and sub-paths are treated specially and
Packit 908522
   * provide a useful result. These can result in two different
Packit 908522
   * situations:
Packit 908522
   *
Packit 908522
   * 1. Zero-length "on" segments set in set_dash(). If the cap style is
Packit 908522
   * Cairo::LINE_CAP_ROUND or Cairo::LINE_CAP_SQUARE then these segments will
Packit 908522
   * be drawn as circular dots or squares respectively. In the case of
Packit 908522
   * Cairo::LINE_CAP_SQUARE, the orientation of the squares is determined by
Packit 908522
   * the direction of the underlying path.
Packit 908522
   *
Packit 908522
   * 2. A sub-path created by move_to() followed by either a close_path() or
Packit 908522
   * one or more calls to line_to() to the same coordinate as the move_to(). If
Packit 908522
   * the cap style is Cairo::LINE_CAP_ROUND then these sub-paths will be drawn
Packit 908522
   * as circular dots. Note that in the case of Cairo::LINE_CAP_SQUARE a
Packit 908522
   * degenerate sub-path will not be drawn at all, (since the correct
Packit 908522
   * orientation is indeterminate).
Packit 908522
   *
Packit 908522
   * In no case will a cap style of Cairo::LINE_CAP_BUTT cause anything to be
Packit 908522
   * drawn in the case of either degenerate segments or sub-paths.
Packit 908522
   */
Packit 908522
  void stroke();
Packit 908522
Packit 908522
  /** A drawing operator that strokes the current Path according to the current
Packit 908522
   * line width, line join, line cap, and dash settings. Unlike stroke(),
Packit 908522
   * stroke_preserve() preserves the Path within the cairo Context.
Packit 908522
   *
Packit 908522
   * @sa set_line_width()
Packit 908522
   * @sa set_line_join()
Packit 908522
   * @sa set_line_cap()
Packit 908522
   * @sa set_dash()
Packit 908522
   * @sa stroke_preserve().
Packit 908522
   */
Packit 908522
  void stroke_preserve();
Packit 908522
Packit 908522
  /** A drawing operator that fills the current path according to the current
Packit 908522
   * fill rule, (each sub-path is implicitly closed before being filled). After
Packit 908522
   * fill(), the current path will be cleared from the cairo context.
Packit 908522
   *
Packit 908522
   * @sa set_fill_rule()
Packit 908522
   * @sa fill_preserve()
Packit 908522
   */
Packit 908522
  void fill();
Packit 908522
Packit 908522
  /** A drawing operator that fills the current path according to the current
Packit 908522
   * fill rule, (each sub-path is implicitly closed before being filled).
Packit 908522
   * Unlike fill(), fill_preserve() preserves the path within the
Packit 908522
   * cairo Context.
Packit 908522
   *
Packit 908522
   * @sa set_fill_rule()
Packit 908522
   * @sa fill().
Packit 908522
   */
Packit 908522
  void fill_preserve();
Packit 908522
  
Packit 908522
  /**
Packit 908522
   * Emits the current page for backends that support multiple pages, but
Packit 908522
   * doesn't clear it, so, the contents of the current page will be retained
Packit 908522
   * for the next page too.  Use show_page() if you want to get an
Packit 908522
   * empty page after the emission.
Packit 908522
   *
Packit 908522
   * This is a convenience function that simply calls Surface::copy_page() on
Packit 908522
   * @a cr's target.
Packit 908522
   */
Packit 908522
  void copy_page();
Packit 908522
  
Packit 908522
  /**
Packit 908522
   * Emits and clears the current page for backends that support multiple
Packit 908522
   * pages.  Use copy_page() if you don't want to clear the page.
Packit 908522
   *
Packit 908522
   * This is a convenience function that simply calls
Packit 908522
   * Surface::show_page() on @a cr's target.
Packit 908522
   */
Packit 908522
  void show_page();
Packit 908522
  
Packit 908522
  /**
Packit 908522
   * Tests whether the given point is inside the area that would be
Packit 908522
   * affected by a stroke() operation given the current path and
Packit 908522
   * stroking parameters. Surface dimensions and clipping are not taken
Packit 908522
   * into account.
Packit 908522
   *
Packit 908522
   * @param x X coordinate of the point to test
Packit 908522
   * @param y Y coordinate of the point to test
Packit 908522
   * @returns A non-zero value if the point is inside, or zero if outside.
Packit 908522
   *
Packit 908522
   * @sa stroke()
Packit 908522
   * @sa set_line_width()
Packit 908522
   * @sa set_line_join()
Packit 908522
   * @sa set_line_cap()
Packit 908522
   * @sa set_dash()
Packit 908522
   * @sa stroke_preserve().
Packit 908522
   *
Packit 908522
   */
Packit 908522
  bool in_stroke(double x, double y) const;
Packit 908522
Packit 908522
  /**
Packit 908522
   * Tests whether the given point is inside the area that would be
Packit 908522
   * affected by a fill() operation given the current path and
Packit 908522
   * filling parameters. Surface dimensions and clipping are not taken
Packit 908522
   * into account.
Packit 908522
   *
Packit 908522
   * @param x X coordinate of the point to test
Packit 908522
   * @param y Y coordinate of the point to test
Packit 908522
   * @returns A non-zero value if the point is inside, or zero if outside.
Packit 908522
   *
Packit 908522
   * @sa fill()
Packit 908522
   * @sa set_fill_rule()
Packit 908522
   * @sa fill_preserve()
Packit 908522
   */
Packit 908522
  bool in_fill(double x, double y) const;
Packit 908522
Packit 908522
  /**
Packit 908522
   * Tests whether the given point is inside the area that would be visible
Packit 908522
   * through the current clip, i.e. the area that would be filled by a paint()
Packit 908522
   * operation.
Packit 908522
   *
Packit 908522
   * Return value: A non-zero value if the point is inside, or zero if outside.
Packit 908522
   *
Packit 908522
   * @param x X coordinate of the point to test
Packit 908522
   * @param y Y coordinate of the point to test
Packit 908522
   *
Packit 908522
   * @sa clip()
Packit 908522
   * @sa clip_preserve()
Packit 908522
   *
Packit 908522
   * @since 1.10
Packit 908522
   */
Packit 908522
  bool in_clip(double x, double y) const;
Packit 908522
Packit 908522
  /**
Packit 908522
   * Computes a bounding box in user coordinates covering the area that would
Packit 908522
   * be affected, (the "inked" area), by a stroke() operation given the current
Packit 908522
   * path and stroke parameters. If the current path is empty, returns an empty
Packit 908522
   * rectangle ((0,0), (0,0)). Surface dimensions and clipping are not taken
Packit 908522
   * into account.
Packit 908522
   *
Packit 908522
   * Note that if the line width is set to exactly zero, then stroke_extents()
Packit 908522
   * will return an empty rectangle. Contrast with path_extents() which can be
Packit 908522
   * used to compute the non-empty bounds as the line width approaches zero.
Packit 908522
   *
Packit 908522
   * Note that stroke_extents() must necessarily do more work to compute the
Packit 908522
   * precise inked areas in light of the stroke parameters, so path_extents()
Packit 908522
   * may be more desirable for sake of performance if non-inked path extents
Packit 908522
   * are desired.
Packit 908522
   *
Packit 908522
   * @param x1 left of the resulting extents
Packit 908522
   * @param y1 top of the resulting extents
Packit 908522
   * @param x2 right of the resulting extents
Packit 908522
   * @param y2 bottom of the resulting extents
Packit 908522
   *
Packit 908522
   * @sa stroke()
Packit 908522
   * @sa set_line_width()
Packit 908522
   * @sa set_line_join()
Packit 908522
   * @sa set_line_cap()
Packit 908522
   * @sa set_dash()
Packit 908522
   * @sa stroke_preserve()
Packit 908522
   */
Packit 908522
  void get_stroke_extents(double& x1, double& y1, double& x2, double& y2) const;
Packit 908522
Packit 908522
  /**
Packit 908522
   * Computes a bounding box in user coordinates covering the area that would
Packit 908522
   * be affected, (the "inked" area), by a fill() operation given the current
Packit 908522
   * path and fill parameters. If the current path is empty, returns an empty
Packit 908522
   * rectangle ((0,0), (0,0)). Surface dimensions and clipping are not taken
Packit 908522
   * into account.
Packit 908522
   *
Packit 908522
   * Contrast with path_extents(), which is similar, but returns non-zero
Packit 908522
   * extents for some paths with no inked area, (such as a simple line
Packit 908522
   * segment).
Packit 908522
   *
Packit 908522
   * Note that fill_extents() must necessarily do more work to compute the
Packit 908522
   * precise inked areas in light of the fill rule, so path_extents() may be
Packit 908522
   * more desirable for sake of performance if the non-inked path extents are
Packit 908522
   * desired.
Packit 908522
   *
Packit 908522
   * @param x1 left of the resulting extents
Packit 908522
   * @param y1 top of the resulting extents
Packit 908522
   * @param x2 right of the resulting extents
Packit 908522
   * @param y2 bottom of the resulting extents
Packit 908522
   *
Packit 908522
   * @sa fill()
Packit 908522
   * @sa set_fill_rule()
Packit 908522
   * @sa full_preserve()
Packit 908522
   */
Packit 908522
  void get_fill_extents(double& x1, double& y1, double& x2, double& y2) const;
Packit 908522
Packit 908522
  /** Reset the current clip region to its original, unrestricted state. That
Packit 908522
   * is, set the clip region to an infinitely large shape containing the target
Packit 908522
   * surface. Equivalently, if infinity is too hard to grasp, one can imagine
Packit 908522
   * the clip region being reset to the exact bounds of the target surface.
Packit 908522
   *
Packit 908522
   * Note that code meant to be reusable should not call reset_clip() as it
Packit 908522
   * will cause results unexpected by higher-level code which calls clip().
Packit 908522
   * Consider using save() and restore() around clip() as a more robust means
Packit 908522
   * of temporarily restricting the clip region.
Packit 908522
   */
Packit 908522
  void reset_clip();
Packit 908522
Packit 908522
  /** Establishes a new clip region by intersecting the current clip region
Packit 908522
   * with the current Path as it would be filled by fill() and according to the
Packit 908522
   * current fill rule.
Packit 908522
   *
Packit 908522
   * After clip(), the current path will be cleared from the cairo Context.
Packit 908522
   *
Packit 908522
   * The current clip region affects all drawing operations by effectively
Packit 908522
   * masking out any changes to the surface that are outside the current clip
Packit 908522
   * region.
Packit 908522
   *
Packit 908522
   * Calling clip() can only make the clip region smaller, never larger.  But
Packit 908522
   * the current clip is part of the graphics state, so a temporary restriction
Packit 908522
   * of the clip region can be achieved by calling clip() within a
Packit 908522
   * save()/restore() pair. The only other means of increasing the size of the
Packit 908522
   * clip region is reset_clip().
Packit 908522
   *
Packit 908522
   * @sa set_fill_rule()
Packit 908522
   */
Packit 908522
  void clip();
Packit 908522
Packit 908522
  /** Establishes a new clip region by intersecting the current clip region
Packit 908522
   * with the current path as it would be filled by fill() and according to the
Packit 908522
   * current fill rule.
Packit 908522
   *
Packit 908522
   * Unlike clip(), clip_preserve preserves the path within the cairo
Packit 908522
   * Context.
Packit 908522
   *
Packit 908522
   * @sa clip()
Packit 908522
   * @sa set_fill_rule()
Packit 908522
   */
Packit 908522
  void clip_preserve();
Packit 908522
Packit 908522
  /**
Packit 908522
   * Computes a bounding box in user coordinates covering the area inside the
Packit 908522
   * current clip.
Packit 908522
   *
Packit 908522
   * @param x1 left of the resulting extents
Packit 908522
   * @param y1 top of the resulting extents
Packit 908522
   * @param x2 right of the resulting extents
Packit 908522
   * @param y2 bottom of the resulting extents
Packit 908522
   *
Packit 908522
   * @since 1.4
Packit 908522
   **/
Packit 908522
  void get_clip_extents(double& x1, double& y1, double& x2, double& y2) const;
Packit 908522
Packit 908522
  /**
Packit 908522
   * Returns the current clip region as a list of rectangles in user coordinates.
Packit 908522
   *
Packit 908522
   * This function will throw an exception if the clip region cannot be
Packit 908522
   * represented as a list of user-space rectangles.
Packit 908522
   *
Packit 908522
   * @param rectangles a vector to store the rectangles into
Packit 908522
   *
Packit 908522
   * @exception
Packit 908522
   *
Packit 908522
   * @since 1.4
Packit 908522
   */
Packit 908522
  void copy_clip_rectangle_list(std::vector<Rectangle>& rectangles) const;
Packit 908522
Packit 908522
  /**
Packit 908522
   * Selects a family and style of font from a simplified description as a
Packit 908522
   * family name, slant and weight. Cairo provides no operation to list
Packit 908522
   * available family names on the system (this is a "toy", remember), but the
Packit 908522
   * standard CSS2 generic family names, ("serif", "sans-serif", "cursive",
Packit 908522
   * "fantasy", "monospace"), are likely to work as expected.
Packit 908522
   *
Packit 908522
   * Note: The select_font_face() function call is part of what the cairo
Packit 908522
   * designers call the "toy" text API. It is convenient for short demos and
Packit 908522
   * simple programs, but it is not expected to be adequate for serious
Packit 908522
   * text-using applications.
Packit 908522
   *
Packit 908522
   * If @a family starts with the string "@cairo:", or if no native font
Packit 908522
   * backends are compiled in, cairo will use an internal font family. The
Packit 908522
   * internal font family recognizes many modifiers in the @family string, most
Packit 908522
   * notably, it recognizes the string "monospace". That is, the family name
Packit 908522
   * "@cairo:monospace" will use the monospace version of the internal font
Packit 908522
   * family.
Packit 908522
   *
Packit 908522
   * For "real" font selection, see the font-backend-specific
Packit 908522
   * Cairo::FontFace::create functions for the font backend you are using. (For
Packit 908522
   * example, if you are using the freetype-based cairo-ft font backend, see
Packit 908522
   * Cairo::FtFontFace::create().) The resulting font face could then be used
Packit 908522
   * with Cairo::ScaledFont::create() and set_scaled_font().
Packit 908522
   *
Packit 908522
   * Similarly, when using the "real" font support, you can call directly into
Packit 908522
   * the underlying font system, (such as fontconfig or freetype), for
Packit 908522
   * operations such as listing available fonts, etc.
Packit 908522
   *
Packit 908522
   * It is expected that most applications will need to use a more
Packit 908522
   * comprehensive font handling and text layout library, (for example, pango),
Packit 908522
   * in conjunction with cairo.
Packit 908522
   *
Packit 908522
   * If text is drawn without a call to select_font_face(), (nor
Packit 908522
   * set_font_face() nor set_scaled_font()), the default family is
Packit 908522
   * platform-specific, but is essentially "sans-serif". Default slant is
Packit 908522
   * Cairo::FONT_SLANT_NORMAL, and default weight is Cairo::FONT_WEIGHT_NORMAL.
Packit 908522
   *
Packit 908522
   * This function is equivalent to a call to Cairo::ToyFontFace::create()
Packit 908522
   * followed by set_font_face().
Packit 908522
   *
Packit 908522
   * @param family a font family name, encoded in UTF-8
Packit 908522
   * @param slant the slant for the font
Packit 908522
   * @param weight the weight for the font
Packit 908522
   *
Packit 908522
   **/
Packit 908522
  void select_font_face(const std::string& family, FontSlant slant, FontWeight weight);
Packit 908522
Packit 908522
  /**
Packit 908522
   * Sets the current font matrix to a scale by a factor of @a size, replacing
Packit 908522
   * any font matrix previously set with set_font_size() or set_font_matrix().
Packit 908522
   * This results in a font size of @a size user space units. (More precisely,
Packit 908522
   * this matrix will result in the font's em-square being a @size by @a size
Packit 908522
   * square in user space.)
Packit 908522
   *
Packit 908522
   * If text is drawn without a call to set_font_size(), (nor set_font_matrix()
Packit 908522
   * nor set_scaled_font()), the default font size is 10.0.
Packit 908522
   *
Packit 908522
   * @param size the new font size, in user space units)
Packit 908522
   */
Packit 908522
  void set_font_size(double size);
Packit 908522
Packit 908522
  /**
Packit 908522
   * Sets the current font matrix to @matrix. The font matrix gives a
Packit 908522
   * transformation from the design space of the font (in this space, the
Packit 908522
   * em-square is 1 unit by 1 unit) to user space. Normally, a simple scale is
Packit 908522
   * used (see set_font_size()), but a more complex font matrix can be used to
Packit 908522
   * shear the font or stretch it unequally along the two axes
Packit 908522
   *
Packit 908522
   * @param matrix a Cairo::Matrix describing a transform to be applied to the
Packit 908522
   * current font.
Packit 908522
   */
Packit 908522
  void set_font_matrix(const Matrix& matrix);
Packit 908522
Packit 908522
  /**
Packit 908522
   * Returns the current font matrix
Packit 908522
   *
Packit 908522
   * @param matrix a Cairo::Matrix to store the results into (in/out parameter)
Packit 908522
   * @sa set_font_matrix()
Packit 908522
   */
Packit 908522
  void get_font_matrix(Matrix& matrix) const;
Packit 908522
Packit 908522
  /**
Packit 908522
   * Sets a set of custom font rendering options. Rendering options are derived
Packit 908522
   * by merging these options with the options derived from underlying surface;
Packit 908522
   * if the value in @a options has a default value (like
Packit 908522
   * Cairo::ANTIALIAS_DEFAULT), then the value from the surface is used.
Packit 908522
   *
Packit 908522
   * @param options font options to use
Packit 908522
   */
Packit 908522
  void set_font_options(const FontOptions& options);
Packit 908522
Packit 908522
  /* To keep 1.6.x ABI  */
Packit 908522
  void set_font_matrix(const cairo_matrix_t& matrix);
Packit 908522
  void get_font_matrix(cairo_matrix_t& matrix) const;
Packit 908522
Packit 908522
Packit 908522
  /**
Packit 908522
   * Retrieves font rendering options set via set_font_options(). Note that the
Packit 908522
   * returned options do not include any options derived from the underlying
Packit 908522
   * surface; they are literally the options passed to set_font_options().
Packit 908522
   *
Packit 908522
   * @param options a FontOptions object into which to store the retrieved
Packit 908522
   *   options. All existing values are overwritten
Packit 908522
   * @since 1.8
Packit 908522
   */
Packit 908522
  void get_font_options(FontOptions& options) const;
Packit 908522
Packit 908522
  /**
Packit 908522
   * Replaces the current font face, font matrix, and font options in the
Packit 908522
   * context with those of the @a scaled_font. Except for some translation, the
Packit 908522
   * current CTM of the context should be the same as that of the
Packit 908522
   * #cairo_scaled_font_t, which can be accessed using
Packit 908522
   * Cairo::ScaledFont::get_ctm().
Packit 908522
   *
Packit 908522
   * @param scaled_font a scaled font
Packit 908522
   * @since 1.8
Packit 908522
   */
Packit 908522
  void set_scaled_font(const RefPtr<const ScaledFont>& scaled_font);
Packit 908522
Packit 908522
  /** Gets the current scaled font.
Packit 908522
   *
Packit 908522
   * @since 1.8
Packit 908522
   **/
Packit 908522
  RefPtr<ScaledFont> get_scaled_font();
Packit 908522
Packit 908522
  /**
Packit 908522
   * A drawing operator that generates the shape from a string of UTF-8
Packit 908522
   * characters, rendered according to the current font_face, font_size
Packit 908522
   * (font_matrix), and font_options.
Packit 908522
   *
Packit 908522
   * This function first computes a set of glyphs for the string of text. The
Packit 908522
   * first glyph is placed so that its origin is at the current point. The
Packit 908522
   * origin of each subsequent glyph is offset from that of the previous glyph
Packit 908522
   * by the advance values of the previous glyph.
Packit 908522
   *
Packit 908522
   * After this call the current point is moved to the origin of where the
Packit 908522
   * next glyph would be placed in this same progression. That is, the current
Packit 908522
   * point will be at the origin of the final glyph offset by its advance
Packit 908522
   * values. This allows for easy display of a single logical string with
Packit 908522
   * multiple calls to show_text().
Packit 908522
   *
Packit 908522
   * Note: The show_text() function call is part of what the cairo
Packit 908522
   * designers call the "toy" text API. It is convenient for short demos and
Packit 908522
   * simple programs, but it is not expected to be adequate for serious
Packit 908522
   * text-using applications. See show_glyphs() for the "real" text
Packit 908522
   * display API in cairo.
Packit 908522
   *
Packit 908522
   * @param utf8 a string containing text encoded in UTF-8
Packit 908522
   */
Packit 908522
  void show_text(const std::string& utf8);
Packit 908522
Packit 908522
  /**
Packit 908522
   * A drawing operator that generates the shape from an array of glyphs,
Packit 908522
   * rendered according to the current font face, font size (font matrix), and
Packit 908522
   * font options.
Packit 908522
   *
Packit 908522
   * @param glyphs vector of glyphs to show
Packit 908522
   * @param num_glyphs number of glyphs to show
Packit 908522
   **/
Packit 908522
  void show_glyphs(const std::vector<Glyph>& glyphs);
Packit 908522
Packit 908522
  /**
Packit 908522
   * This operation has rendering effects similar to show_glyphs() but, if the
Packit 908522
   * target surface supports it, uses the provided text and cluster mapping to
Packit 908522
   * embed the text for the glyphs shown in the output. If the target does not
Packit 908522
   * support the extended attributes, this function acts like the basic
Packit 908522
   * show_glyphs() as if it had been passed @a glyphs and @a num_glyphs.
Packit 908522
   *
Packit 908522
   * The mapping between @a utf8 and @a glyphs is provided by an array of
Packit 908522
   * <firstterm>clusters</firstterm>. Each cluster covers a number of text
Packit 908522
   * bytes and glyphs, and neighboring clusters cover neighboring areas of @a
Packit 908522
   * utf8 and @a glyphs. The clusters should collectively cover @a utf8 and @a
Packit 908522
   * glyphs in entirety.
Packit 908522
   *
Packit 908522
   * The first cluster always covers bytes from the beginning of @a utf8. If @a
Packit 908522
   * cluster_flags do not have the Cairo::TEXT_CLUSTER_FLAG_BACKWARD set, the
Packit 908522
   * first cluster also covers the beginning of @a glyphs, otherwise it covers
Packit 908522
   * the end of the @a glyphs array and following clusters move backward.
Packit 908522
   *
Packit 908522
   * See Cairo::TextCluster for constraints on valid clusters.
Packit 908522
   *
Packit 908522
   * @param utf8: a string of text encoded in UTF-8
Packit 908522
   * @param glyphs: vector of glyphs to show
Packit 908522
   * @param clusters: vector of cluster mapping information
Packit 908522
   * @param cluster_flags: cluster mapping flags
Packit 908522
   *
Packit 908522
   * @since 1.8
Packit 908522
   **/
Packit 908522
  void show_text_glyphs(const std::string& utf8,
Packit 908522
                        const std::vector<Glyph>& glyphs,
Packit 908522
                        const std::vector<TextCluster>& clusters,
Packit 908522
                        TextClusterFlags cluster_flags);
Packit 908522
  /// @{
Packit 908522
  /** Gets the current font face
Packit 908522
   **/
Packit 908522
  RefPtr<FontFace> get_font_face();
Packit 908522
  RefPtr<const FontFace> get_font_face() const;
Packit 908522
  /// @}
Packit 908522
Packit 908522
  /**
Packit 908522
   * Gets the font extents for the currently selected font.
Packit 908522
   *
Packit 908522
   * @param extents a Cairo::FontExtents object
Packit 908522
   */
Packit 908522
  void get_font_extents(FontExtents& extents) const;
Packit 908522
Packit 908522
  /**
Packit 908522
   * Replaces the current font face in the context with @a font_face
Packit 908522
   * @a font_face. The replaced font face in the context will be destroyed if
Packit 908522
   * there are no other references to it.
Packit 908522
   *
Packit 908522
   * @param font_face a font face
Packit 908522
   */
Packit 908522
  //FIXME: C API acceps NULL to restore the default font. Does C++ API support that?
Packit 908522
  void set_font_face(const RefPtr<const FontFace>& font_face);
Packit 908522
Packit 908522
  /**
Packit 908522
   * Gets the extents for a string of text. The extents describe a user-space
Packit 908522
   * rectangle that encloses the "inked" portion of the text, (as it would be
Packit 908522
   * drawn by show_text()). Additionally, the x_advance and y_advance values
Packit 908522
   * indicate the amount by which the current point would be advanced by
Packit 908522
   * show_text().
Packit 908522
   *
Packit 908522
   * Note that whitespace characters do not directly contribute to the size of
Packit 908522
   * the rectangle (extents.width and extents.height). They do contribute
Packit 908522
   * indirectly by changing the position of non-whitespace characters. In
Packit 908522
   * particular, trailing whitespace characters are likely to not affect the
Packit 908522
   * size of the rectangle, though they will affect the x_advance and y_advance
Packit 908522
   * values.
Packit 908522
   *
Packit 908522
   * @param utf8 a string of text encoded in UTF-8
Packit 908522
   * @param extents a TextExtents object
Packit 908522
   */
Packit 908522
  void get_text_extents(const std::string& utf8, TextExtents& extents) const;
Packit 908522
Packit 908522
  /**
Packit 908522
   * Gets the extents for an array of glyphs. The extents describe a user-space
Packit 908522
   * rectangle that encloses the "inked" portion of the glyphs, (as they would
Packit 908522
   * be drawn by show_glyphs()). Additionally, the x_advance and y_advance
Packit 908522
   * values indicate the amount by which the current point would be advanced by
Packit 908522
   * show_glyphs().
Packit 908522
   *
Packit 908522
   * Note that whitespace glyphs do not contribute to the size of the rectangle
Packit 908522
   * (extents.width and extents.height).
Packit 908522
   *
Packit 908522
   * @param glyphs a vector of glyphs
Packit 908522
   * @param extents a TextExtents object
Packit 908522
   */
Packit 908522
  void get_glyph_extents(const std::vector<Glyph>& glyphs, TextExtents& extents) const;
Packit 908522
Packit 908522
  /**
Packit 908522
   * Adds closed paths for text to the current path. The generated path if
Packit 908522
   * filled, achieves an effect similar to that of show_text().
Packit 908522
   *
Packit 908522
   * Text conversion and positioning is done similar to show_text().
Packit 908522
   *
Packit 908522
   * Like show_text(), After this call the current point is moved to the origin
Packit 908522
   * of where the next glyph would be placed in this same progression. That is,
Packit 908522
   * the current point will be at the origin of the final glyph offset by its
Packit 908522
   * advance values. This allows for chaining multiple calls to to text_path()
Packit 908522
   * without having to set current point in between.
Packit 908522
   *
Packit 908522
   * Note: The text_path() function call is part of what the cairo designers
Packit 908522
   * call the "toy" text API. It is convenient for short demos and simple
Packit 908522
   * programs, but it is not expected to be adequate for serious text-using
Packit 908522
   * applications. See glyph_path() for the "real" text path API in cairo.
Packit 908522
   *
Packit 908522
   * @param utf8 a string of text encoded in UTF-8
Packit 908522
   */
Packit 908522
  void text_path(const std::string& utf8);
Packit 908522
Packit 908522
  /** Adds closed paths for the glyphs to the current path. The generated path
Packit 908522
   * if filled, achieves an effect similar to that of show_glyphs().
Packit 908522
   *
Packit 908522
   * @param glyphs a vector of glyphs
Packit 908522
   */
Packit 908522
  void glyph_path(const std::vector<Glyph>& glyphs);
Packit 908522
Packit 908522
  /** Gets the current compositing operator for a cairo Context
Packit 908522
   */
Packit 908522
  Operator get_operator() const;
Packit 908522
Packit 908522
  /// @{
Packit 908522
  /** Gets the current source pattern for the Context
Packit 908522
   */
Packit 908522
  RefPtr<Pattern> get_source();
Packit 908522
  RefPtr<const Pattern> get_source() const;
Packit 908522
  /// @}
Packit 908522
Packit 908522
  /** Gets the current tolerance value, as set by set_tolerance()
Packit 908522
   */
Packit 908522
  double get_tolerance() const;
Packit 908522
Packit 908522
  /** Gets the current shape antialiasing mode, as set by set_antialias()
Packit 908522
   */
Packit 908522
  Antialias get_antialias() const;
Packit 908522
Packit 908522
  /** Gets the current point of the current path, which is conceptually the
Packit 908522
   * final point reached by the path so far.
Packit 908522
   *
Packit 908522
   * The current point is returned in the user-space coordinate system. If
Packit 908522
   * there is no defined current point then x and y will both be set to 0.0. It
Packit 908522
   * is possible to check this in advance with has_current_point().
Packit 908522
   *
Packit 908522
   * Most path construction functions alter the current point. See the
Packit 908522
   * following for details on how they affect the current point: clear_path(),
Packit 908522
   * move_to(), line_to(), curve_to(), arc(), rel_move_to(), rel_line_to(),
Packit 908522
   * rel_curve_to(), arc(), and text_path()
Packit 908522
   *
Packit 908522
   * Some functions use and alter the current point but do not otherwise change
Packit 908522
   * current path: show_text().
Packit 908522
   *
Packit 908522
   * Some functions unset the current path and as a result, current point:
Packit 908522
   * fill(), stroke().
Packit 908522
   *
Packit 908522
   * @param x	return value for X coordinate of the current point
Packit 908522
   * @param y	return value for Y coordinate of the current point
Packit 908522
   *
Packit 908522
   * @sa has_current_point()
Packit 908522
   */
Packit 908522
  void get_current_point (double& x, double& y) const;
Packit 908522
Packit 908522
  /**
Packit 908522
   * Checks if there is a current point defined. See get_current_point() for
Packit 908522
   * details on the current point.
Packit 908522
   *
Packit 908522
   * @returns @c true if a current point is defined.
Packit 908522
   *
Packit 908522
   * @since 1.6
Packit 908522
   */
Packit 908522
  bool has_current_point() const;
Packit 908522
Packit 908522
  /** Gets the current fill rule, as set by set_fill_rule().
Packit 908522
   */
Packit 908522
  FillRule get_fill_rule() const;
Packit 908522
Packit 908522
  /**
Packit 908522
   * Gets the current line width, as set by set_line_width(). Note that the
Packit 908522
   * value is unchanged even if the CTM has changed between the calls to
Packit 908522
   * set_line_width() and get_line_width().
Packit 908522
   */
Packit 908522
  double get_line_width() const;
Packit 908522
Packit 908522
  /** Gets the current line cap style, as set by set_line_cap()
Packit 908522
   */
Packit 908522
  LineCap get_line_cap() const;
Packit 908522
Packit 908522
  /** Gets the current line join style, as set by set_line_join()
Packit 908522
   */
Packit 908522
  LineJoin get_line_join() const;
Packit 908522
Packit 908522
  /** Gets the current miter limit, as set by set_miter_limit()
Packit 908522
   */
Packit 908522
  double get_miter_limit() const;
Packit 908522
Packit 908522
  /**
Packit 908522
   * Gets the current dash array and offset.
Packit 908522
   *
Packit 908522
   * @param dashes return value for the dash array.
Packit 908522
   * @param offset return value for the current dash offset.
Packit 908522
   *
Packit 908522
   * @since 1.4
Packit 908522
   **/
Packit 908522
  void get_dash(std::vector<double>& dashes, double& offset) const;
Packit 908522
Packit 908522
Packit 908522
  /** Stores the current transformation matrix (CTM) into matrix.
Packit 908522
   *
Packit 908522
   * @param matrix return value for the matrix
Packit 908522
   */
Packit 908522
  void get_matrix(Matrix& matrix);
Packit 908522
Packit 908522
  /* To keep 1.6.x ABI  */
Packit 908522
  void get_matrix(cairo_matrix_t& matrix);
Packit 908522
Packit 908522
  /**
Packit 908522
   * Returns the current transformation matrix (CTM)
Packit 908522
   * @since 1.8
Packit 908522
   */
Packit 908522
  Matrix get_matrix() const;
Packit 908522
Packit 908522
  /// @{
Packit 908522
  /** Gets the target surface associated with this Context.
Packit 908522
   *
Packit 908522
   * @exception
Packit 908522
   */
Packit 908522
  RefPtr<Surface> get_target();
Packit 908522
  RefPtr<const Surface> get_target() const;
Packit 908522
  /// @}
Packit 908522
Packit 908522
  //TODO: Copy or reference-count a Path somethow instead of asking the caller to delete it?
Packit 908522
  /** Creates a copy of the current path and returns it to the user.
Packit 908522
   *
Packit 908522
   * @todo See cairo_path_data_t for hints on how to iterate over the returned
Packit 908522
   * data structure.
Packit 908522
   *
Packit 908522
   * @note The caller owns the Path object returned from this function.  The
Packit 908522
   * Path object must be freed when you are finished with it.
Packit 908522
   */
Packit 908522
  Path* copy_path() const;
Packit 908522
Packit 908522
  /**
Packit 908522
   * Computes a bounding box in user-space coordinates covering the points on
Packit 908522
   * the current path. If the current path is empty, returns an empty rectangle
Packit 908522
   * ((0,0), (0,0)). Stroke parameters, fill rule, surface dimensions and
Packit 908522
   * clipping are not taken into account.
Packit 908522
   *
Packit 908522
   * Contrast with fill_extents() and stroke_extents() which return the extents
Packit 908522
   * of only the area that would be "inked" by the corresponding drawing
Packit 908522
   * operations.
Packit 908522
   *
Packit 908522
   * The result of path_extents() is defined as equivalent to the limit of
Packit 908522
   * stroke_extents() with LINE_CAP_ROUND as the line width approaches 0.0, (but
Packit 908522
   * never reaching the empty-rectangle returned by stroke_extents() for a line
Packit 908522
   * width of 0.0).
Packit 908522
   *
Packit 908522
   * Specifically, this means that zero-area sub-paths such as
Packit 908522
   * move_to();line_to() segments, (even degenerate cases where the coordinates
Packit 908522
   * to both calls are identical), will be considered as contributing to the
Packit 908522
   * extents. However, a lone move_to() will not contribute to the results of
Packit 908522
   * path_extents().
Packit 908522
   *
Packit 908522
   * @param x1 left of the resulting extents
Packit 908522
   * @param y1 top of the resulting extents
Packit 908522
   * @param x2 right of the resulting extents
Packit 908522
   * @param y2 bottom of the resulting extents
Packit 908522
   *
Packit 908522
   * @since 1.6
Packit 908522
   */
Packit 908522
  void get_path_extents(double& x1, double& y1, double& x2, double& y2) const;
Packit 908522
Packit 908522
  /** Gets a flattened copy of the current path and returns it to the user
Packit 908522
   *
Packit 908522
   * @todo See cairo_path_data_t for hints on how to iterate over the returned
Packit 908522
   * data structure.
Packit 908522
   *
Packit 908522
   * This function is like copy_path() except that any curves in the path will
Packit 908522
   * be approximated with piecewise-linear approximations, (accurate to within
Packit 908522
   * the current tolerance value). That is, the result is guaranteed to not have
Packit 908522
   * any elements of type CAIRO_PATH_CURVE_TO which will instead be
Packit 908522
   * replaced by a series of CAIRO_PATH_LINE_TO elements.
Packit 908522
   *
Packit 908522
   * @note The caller owns the Path object returned from this function.  The
Packit 908522
   * Path object must be freed when you are finished with it.
Packit 908522
   */
Packit 908522
  Path* copy_path_flat() const;
Packit 908522
Packit 908522
  /** Append the path onto the current path. The path may be either the return
Packit 908522
   * value from one of copy_path() or copy_path_flat() or it may be constructed
Packit 908522
   * manually.
Packit 908522
   *
Packit 908522
   * @param path	path to be appended
Packit 908522
   */
Packit 908522
  void append_path(const Path& path);
Packit 908522
Packit 908522
  /** Temporarily redirects drawing to an intermediate surface known as a group.
Packit 908522
   * The redirection lasts until the group is completed by a call to pop_group()
Packit 908522
   * or pop_group_to_source(). These calls provide the result of any drawing to
Packit 908522
   * the group as a pattern, (either as an explicit object, or set as the source
Packit 908522
   * pattern).
Packit 908522
   *
Packit 908522
   * This group functionality can be convenient for performing intermediate
Packit 908522
   * compositing. One common use of a group is to render objects as opaque
Packit 908522
   * within the group, (so that they occlude each other), and then blend the
Packit 908522
   * result with translucence onto the destination.
Packit 908522
   *
Packit 908522
   * Groups can be nested arbitrarily deep by making balanced calls to
Packit 908522
   * push_group()/pop_group(). Each call pushes/pops the new target group
Packit 908522
   * onto/from a stack.
Packit 908522
   *
Packit 908522
   * The push_group() function calls save() so that any changes to the graphics
Packit 908522
   * state will not be visible outside the group, (the pop_group functions call
Packit 908522
   * restore()).
Packit 908522
   *
Packit 908522
   * By default the intermediate group will have a content type of
Packit 908522
   * CONTENT_COLOR_ALPHA. Other content types can be chosen for the group by
Packit 908522
   * using push_group_with_content() instead.
Packit 908522
   *
Packit 908522
   * As an example, here is how one might fill and stroke a path with
Packit 908522
   * translucence, but without any portion of the fill being visible under the
Packit 908522
   * stroke:
Packit 908522
   *
Packit 908522
   * @code
Packit 908522
   * cr->push_group();
Packit 908522
   * cr->set_source(fill_pattern);
Packit 908522
   * cr->fill_preserve();
Packit 908522
   * cr->set_source(stroke_pattern);
Packit 908522
   * cr->stroke();
Packit 908522
   * cr->pop_group_to_source();
Packit 908522
   * cr->paint_with_alpha(alpha);
Packit 908522
   * @endcode
Packit 908522
   *
Packit 908522
   * @since 1.2
Packit 908522
   */
Packit 908522
  void push_group();
Packit 908522
Packit 908522
  /**
Packit 908522
   * Temporarily redirects drawing to an intermediate surface known as a
Packit 908522
   * group. The redirection lasts until the group is completed by a call
Packit 908522
   * to pop_group() or pop_group_to_source(). These calls provide the result of
Packit 908522
   * any drawing to the group as a pattern, (either as an explicit object, or set
Packit 908522
   * as the source pattern).
Packit 908522
   *
Packit 908522
   * The group will have a content type of @content. The ability to control this
Packit 908522
   * content type is the only distinction between this function and push_group()
Packit 908522
   * which you should see for a more detailed description of group rendering.
Packit 908522
   *
Packit 908522
   * @param content indicates the type of group that will be created
Packit 908522
   *
Packit 908522
   * @since 1.2
Packit 908522
   */
Packit 908522
  void push_group_with_content(Content content);
Packit 908522
Packit 908522
  /**
Packit 908522
   * Terminates the redirection begun by a call to push_group() or
Packit 908522
   * push_group_with_content() and returns a new pattern containing the results
Packit 908522
   * of all drawing operations performed to the group.
Packit 908522
   *
Packit 908522
   * The pop_group() function calls restore(), (balancing a call to save() by
Packit 908522
   * the push_group function), so that any changes to the graphics state will
Packit 908522
   * not be visible outside the group.
Packit 908522
   *
Packit 908522
   * @return a (surface) pattern containing the results of all drawing
Packit 908522
   * operations performed to the group.
Packit 908522
   *
Packit 908522
   * @since 1.2
Packit 908522
   **/
Packit 908522
  RefPtr<Pattern> pop_group();
Packit 908522
Packit 908522
  /**
Packit 908522
   * Terminates the redirection begun by a call to push_group() or
Packit 908522
   * push_group_with_content() and installs the resulting pattern as the source
Packit 908522
   * pattern in the given cairo Context.
Packit 908522
   *
Packit 908522
   * The behavior of this function is equivalent to the sequence of operations:
Packit 908522
   *
Packit 908522
   * @code
Packit 908522
   * RefPtr<Pattern> group = cr->pop_group();
Packit 908522
   * cr->set_source(group);
Packit 908522
   * @endcode
Packit 908522
   *
Packit 908522
   * but is more convenient as their is no need for a variable to store
Packit 908522
   * the short-lived pointer to the pattern.
Packit 908522
   *
Packit 908522
   * The pop_group() function calls restore(), (balancing a call to save() by
Packit 908522
   * the push_group function), so that any changes to the graphics state will
Packit 908522
   * not be visible outside the group.
Packit 908522
   *
Packit 908522
   * @since 1.2
Packit 908522
   **/
Packit 908522
  void pop_group_to_source();
Packit 908522
Packit 908522
  /**
Packit 908522
   * Gets the target surface for the current group as started by the most recent
Packit 908522
   * call to push_group() or push_group_with_content().
Packit 908522
   *
Packit 908522
   * This function will return NULL if called "outside" of any group rendering
Packit 908522
   * blocks, (that is, after the last balancing call to pop_group() or
Packit 908522
   * pop_group_to_source()).
Packit 908522
   *
Packit 908522
   * @exception
Packit 908522
   *
Packit 908522
   * @since 1.2
Packit 908522
   **/
Packit 908522
  RefPtr<Surface> get_group_target();
Packit 908522
Packit 908522
  /** Same as the non-const version but returns a reference to a const Surface
Packit 908522
   *
Packit 908522
   * @since 1.2
Packit 908522
   */
Packit 908522
  RefPtr<const Surface> get_group_target() const;
Packit 908522
Packit 908522
  /** The base cairo C type that is wrapped by Cairo::Context
Packit 908522
   */
Packit 908522
  typedef cairo_t cobject;
Packit 908522
Packit 908522
  /** Gets a pointer to the base C type that is wrapped by the Context
Packit 908522
   */
Packit 908522
  inline cobject* cobj() { return m_cobject; }
Packit 908522
Packit 908522
  /** Gets a pointer to the base C type that is wrapped by the Context
Packit 908522
   */
Packit 908522
  inline const cobject* cobj() const { return m_cobject; }
Packit 908522
Packit 908522
#ifndef DOXYGEN_IGNORE_THIS
Packit 908522
  ///For use only by the cairomm implementation.
Packit 908522
  inline ErrorStatus get_status() const
Packit 908522
  { return cairo_status(const_cast<cairo_t*>(cobj())); }
Packit 908522
Packit 908522
  void reference() const;
Packit 908522
  void unreference() const;
Packit 908522
#endif //DOXYGEN_IGNORE_THIS
Packit 908522
Packit 908522
protected:
Packit 908522
  cobject* m_cobject;
Packit 908522
};
Packit 908522
Packit 908522
} // namespace Cairo
Packit 908522
Packit 908522
#endif //__CAIROMM_CONTEXT_H
Packit 908522
Packit 908522
// vim: ts=2 sw=2 et