Blame pango/src/rectangle.hg

Packit 78284e
/* Copyright (C) 2002 The gtkmm Development Team
Packit 78284e
 *
Packit 78284e
 * This library is free software; you can redistribute it and/or
Packit 78284e
 * modify it under the terms of the GNU Lesser General Public
Packit 78284e
 * License as published by the Free Software Foundation; either
Packit 78284e
 * version 2.1 of the License, or (at your option) any later version.
Packit 78284e
 *
Packit 78284e
 * This library is distributed in the hope that it will be useful,
Packit 78284e
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 78284e
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 78284e
 * Lesser General Public License for more details.
Packit 78284e
 *
Packit 78284e
 * You should have received a copy of the GNU Lesser General Public
Packit 78284e
 * License along with this library; if not, write to the Free
Packit 78284e
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Packit 78284e
 */
Packit 78284e
Packit 78284e
#include <pango/pango-types.h>
Packit 78284e
Packit 78284e
_DEFS(pangomm,pango)
Packit 78284e
Packit 78284e
namespace Pango
Packit 78284e
{
Packit 78284e
Packit 78284e
/** A Pango::Rectangle represents a rectangle.
Packit 78284e
 * It is frequently used to represent the logical or ink extents of a single glyph or section of text.
Packit 78284e
 * The coordinate system for each rectangle has its origin at the base line and the horizontal
Packit 78284e
 * origin of the character with increasing coordinates extending to the right and down.
Packit 78284e
 * get_ascent(), get_descent(), get_lbearing(), and get_rbearing() can be used to convert
Packit 78284e
 * from the extents rectangle to more traditional font metrics.
Packit 78284e
 * The units of rectangles usually are in 1/Pango::SCALE of a device unit.
Packit 78284e
 */
Packit 78284e
class Rectangle
Packit 78284e
{
Packit 78284e
  _CLASS_GENERIC(Rectangle, PangoRectangle)
Packit 78284e
Packit 78284e
public:
Packit 78284e
  Rectangle();
Packit 78284e
  Rectangle(int x, int y, int width, int height);
Packit 78284e
  explicit Rectangle(const PangoRectangle* src);
Packit 78284e
Packit 78284e
  /** Sets the X coordinate of the left side of the rectangle.
Packit 78284e
   * @param x The new X coordinate.
Packit 78284e
   */
Packit 78284e
  void set_x(int x)        { gobject_.x = x; }
Packit 78284e
Packit 78284e
  /** Sets the Y coordinate of the top side of the rectangle.
Packit 78284e
   * @param y The new Y coordinate.
Packit 78284e
   */
Packit 78284e
  void set_y(int y)        { gobject_.y = y; }
Packit 78284e
Packit 78284e
  /** Sets the width of the rectangle.
Packit 78284e
   * @param w The new width.
Packit 78284e
   */
Packit 78284e
  void set_width(int w)    { gobject_.width = w; }
Packit 78284e
Packit 78284e
  /** Sets the height of the rectangle.
Packit 78284e
   * @param h The new height.
Packit 78284e
   */
Packit 78284e
  void set_height(int h)   { gobject_.height = h; }
Packit 78284e
Packit 78284e
  /** Gets the X coordinate of the left side of the rectangle.
Packit 78284e
   * @return The X coordinate.
Packit 78284e
   */
Packit 78284e
  int get_x() const        { return gobject_.x; }
Packit 78284e
Packit 78284e
  /** Gets the Y coordinate of the top side of the rectangle.
Packit 78284e
   * @return The Y coordinate.
Packit 78284e
   */
Packit 78284e
  int get_y() const        { return gobject_.y; }
Packit 78284e
Packit 78284e
  /** Gets the width of the rectangle.
Packit 78284e
   * @return The width.
Packit 78284e
   */
Packit 78284e
  int get_width() const    { return gobject_.width; }
Packit 78284e
Packit 78284e
  /** Gets the height of the rectangle.
Packit 78284e
   * @return The height.
Packit 78284e
   */
Packit 78284e
  int get_height() const   { return gobject_.height; }
Packit 78284e
Packit 78284e
  /** Extracts the ascent from a Pango::Rectangle representing glyph extents.
Packit 78284e
   * The ascent is the distance from the baseline to the highest point of the character.
Packit 78284e
   * This is positive if the glyph ascends above the baseline.
Packit 78284e
   * @return The ascent of the character.
Packit 78284e
   */
Packit 78284e
  int get_ascent() const   { return PANGO_ASCENT(*gobj()); }
Packit 78284e
Packit 78284e
  /** Extracts the descent from a Pango::Rectangle representing glyph extents.
Packit 78284e
   * The descent is the distance from the baseline to the lowest point of the character.
Packit 78284e
   * This is positive if the glyph descends below the baseline.
Packit 78284e
   * @return The descent of the character.
Packit 78284e
   */
Packit 78284e
  int get_descent() const  { return PANGO_DESCENT(*gobj()); }
Packit 78284e
Packit 78284e
  /** Extracts the left bearing from a Pango::Rectangle representing glyph extents.
Packit 78284e
   * The left bearing is the distance from the horizontal origin to the farthest left point of the character.
Packit 78284e
   * This is positive for characters drawn completely to the right of the glyph origin.
Packit 78284e
   * @return The left bearing of the character.
Packit 78284e
   */
Packit 78284e
  int get_lbearing() const { return PANGO_LBEARING(*gobj()); }
Packit 78284e
Packit 78284e
  /** Extracts the right bearing from a Pango::Rectangle representing glyph extents.
Packit 78284e
   * The right bearing is the distance from the horizontal origin to the farthest right point of the character.
Packit 78284e
   * This is positive except for characters drawn completely to the left of the horizontal origin.
Packit 78284e
   * @return The right bearing of the character.
Packit 78284e
   */
Packit 78284e
  int get_rbearing() const { return PANGO_RBEARING(*gobj()); }
Packit 78284e
Packit 78284e
  /** Checks for equality of two Pango::Rectangles.
Packit 78284e
   * @param rhs The Pango::Rectangle to compare with.
Packit 78284e
   * @return true if @a rhs is equal with the rectangle.
Packit 78284e
   */
Packit 78284e
  bool equal(const Rectangle& rhs) const;
Packit 78284e
Packit 78284e
  /// Provides access to the underlying C GObject.  
Packit 78284e
  PangoRectangle*       gobj()       { return &gobject_; }
Packit 78284e
  /// Provides access to the underlying C GObject.
Packit 78284e
  const PangoRectangle* gobj() const { return &gobject_; }
Packit 78284e
Packit 78284e
protected:
Packit 78284e
  PangoRectangle gobject_;
Packit 78284e
};
Packit 78284e
Packit 78284e
/** @relates Pango::Rectangle */
Packit 78284e
inline bool operator==(const Rectangle& lhs, const Rectangle& rhs)
Packit 78284e
  { return lhs.equal(rhs); }
Packit 78284e
Packit 78284e
/** @relates Pango::Rectangle */
Packit 78284e
inline bool operator!=(const Rectangle& lhs, const Rectangle& rhs)
Packit 78284e
  { return !lhs.equal(rhs); }
Packit 78284e
Packit 78284e
} /* namespace Pango */
Packit 78284e
Packit 78284e
Packit 78284e
namespace Glib
Packit 78284e
{
Packit 78284e
Packit 78284e
/** @relates Pango::Rectangle */
Packit 78284e
Pango::Rectangle& wrap(PangoRectangle* object);
Packit 78284e
Packit 78284e
/** @relates Pango::Rectangle */
Packit 78284e
const Pango::Rectangle& wrap(const PangoRectangle* object);
Packit 78284e
Packit 78284e
} /* namespace Glib */