Reference Manual

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# Inti::Gdk::Rectangle Class Reference

A GdkRectangle C++ wrapper class. More...

`#include <inti/gdk/types.h>`

Inheritance diagram for Inti::Gdk::Rectangle:

List of all members.

## Public Member Functions

Constructors

- Rectangle ()
    Construct a null rectangle.
- Rectangle (int x, int y, int width, int height)
    Construct a new rectangle.
- Rectangle (const Point &point, int width, int height)
    Construct a new rectangle.
- Rectangle (const GdkRectangle &rectangle)
    Construct a new rectangle from an existing GdkRectangle.

Accessors

- GdkRectangle * gdk_rectangle () const
    Get a pointer to the GdkRectangle structure.
- operator GdkRectangle * () const
    Conversion operator; safely converts a Rectangle to a GdkRectangle pointer.
- int x () const
    Returns the X coordinate of the top-left corner of the rectangle.
- int y () const
    Returns the Y coordinate of the top-left corner of the rectangle.
- int width () const
    Returns the width of the rectangle.
- int height () const
    Returns the height of the rectangle.
- long area () const
    Returns the area of the rectangle.
- Point center () const
    Returns the point at the center of the rectangle.
- bool contains (int x, int y) const
    Returns true if the rectangle contains the point [x, y].
- bool contains (const Point &point) const
    Returns true if the rectangle contains point.
- bool equal (const Rectangle &other) const
    Returns true if this rectangle compares equal to other.
- bool empty () const
    Returns true if the rectangle is empty.
- bool null () const
    Returns true if the rectangle is null.
- bool intersect (const Rectangle &other) const
    Returns true if this rectangle and other intersect.
- Point & position () const
    Returns a reference to the Point at top-left corner of the rectangle.
- bool operator== (const Rectangle &other) const
    Returns true if this rectangle and other compare equal.
- bool operator!= (const Rectangle &other) const
    Returns true if this rectangle and other compare unequal.

Methods

- void set (int x, int y, int width, int height)
    Sets the position and size of the rectangle.
- void set_empty ()
    Sets the width and height of the rectangle to 0.
- void set_null ()
    Sets the x, y, width and height of the rectangle to 0.
- void set_position (int x, int y)
    Sets the position of the rectangle.
- void set_position (const Point &point)
    Sets the position of the rectangle.
- void set_size (int width, int height)
    Sets the size of the rectangle.
- void capture (Point &point) const
    Keeps point within the boundries of the rectangle.
- Rectangle & inflate (int dx, int dy)
    Resize the rectangle.
- bool intersect_with (const Rectangle &other)
    Calculates the intersection of two rectangles.
- Rectangle & offset (int dx, int dy)
    Move the rectangle.
- void union_with (const Rectangle &other)
    Calculates the union of this rectangle and other.
- Rectangle & operator+= (int increment)
    Inflates the rectangle by increment in all directions.
- Rectangle & operator+= (const Point &point)
    Offsets the rectangle by point.x and point.y.
- Rectangle & operator-= (int increment)
    Shrinks the rectangle by increment in all directions.
- Rectangle & operator-= (const Point &point)
    Offsets the rectangle by -point.x and -point.y.
- Rectangle & operator++ ()
    Inflates the rectangle in all directions by one pixel.
- Rectangle & operator-- ()
    Shrink the rectangle in all directions by one pixel.
- bool operator &= (const Rectangle &other)
    Calculates the intersection of two rectangles (same as intersect_with()).
- void operator|= (const Rectangle &other)
    Calculates the union of this rectangle and other (same as union_with()).

Methods returning a new Rectangle

- Rectangle inflate_by (int dx, int dy) const
    Resize this rectangle and return the result as a new Rectangle.
- Rectangle offset_by (int dx, int dy) const
    Move the rectangle and return the result as a new rectangle.

## Detailed Description

A GdkRectangle C++ wrapper class.

Rectangle is an object that holds the position and size of a rectangle. The intersection of two rectangles can be computed with intersect_with(). To find the union of two rectangles use union_with(). Rectangle uses default copy, assignment and destruction.

## Constructor & Destructor Documentation

Inti::Gdk::Rectangle::Rectangle | ( |  | ) |

| Construct a null rectangle. A null rectangle has its x, y, width and height set to 0;

Inti::Gdk::Rectangle::Rectangle | ( | int | x,
|  | int | y,
|  | int | width,
|  | int | height
| ) |

Construct a new rectangle.

Parameters:

  x | The X coordinate of the rectangle.
  y | The Y coordinate of the rectangle.
  width | The width of the rectangle.
  height | The height of the rectangle.

Inti::Gdk::Rectangle::Rectangle | ( | const Point & | point,
|  | int | width,
|  | int | height
| ) |

Construct a new rectangle.

Parameters:

  point | The x, y coordinates of the top-left corner of the rectangle.
  width | The width of the rectangle.
  height | The height of the rectangle.

Inti::Gdk::Rectangle::Rectangle | ( | const GdkRectangle & | rectangle | ) |

Construct a new rectangle from an existing GdkRectangle.

Parameters:

  rectangle | A GdkRectangle.

## Member Function Documentation

void Inti::Gdk::Rectangle::capture | ( | Point & | point | ) | const

Keeps point within the boundries of the rectangle.

Parameters:

  point | A reference to a Point.

This method is useful if you want to confine the cursor to a rectangle (e.g. a dialog) until the user makes a selection. Just use the captured point to set the cursor position in response to a motion_event signal.

bool Inti::Gdk::Rectangle::empty | ( |  | ) | const

| Returns true if the rectangle is empty. A rectangle is empty if either the width or height is 0;

bool Inti::Gdk::Rectangle::equal | ( | const Rectangle & | other | ) | const

Returns true if this rectangle compares equal to other.

Parameters:

  other | A Gdk::Rectangle.

Rectangle& Inti::Gdk::Rectangle::inflate | ( | int | dx,
|  | int | dy
| ) |

Resize the rectangle.

Parameters:

  dx | The number of pixels to add/subtract the X coordinate of each corner.
  dy | The number of pixels to add/subtract the Y coordinate of each corner.

Returns:
  A reference to the resized rectangle.

Positive values for dx and dy will enlarge the rectangle, and a negative values for dx and dy will shrink the rectangle.

Rectangle Inti::Gdk::Rectangle::inflate_by | ( | int | dx,
|  | int | dy
| ) | const

Resize this rectangle and return the result as a new Rectangle.

Parameters:

  dx | The number of pixels to add/subtract the X coordinate of each corner.
  dy | The number of pixels to add/subtract the Y coordinate of each corner.

Returns:
  A new rectangle (see inflate()).

Positive values for dx and dy will enlarge the rectangle, and a negative values for dx and dy will shrink the rectangle.

bool Inti::Gdk::Rectangle::intersect | ( | const Rectangle & | other | ) | const

Returns true if this rectangle and other intersect.

Parameters:

  other | A Gdk::Rectangle.

bool Inti::Gdk::Rectangle::intersect_with | ( | const Rectangle & | other | ) |

Calculates the intersection of two rectangles.

Parameters:

  other | A Gdk::Rectangle.

Returns:
  true if this rectangle and other intersect.

On returning, this rectangle contains the intersection the original rectangle and other. If the two rectangles don't intersect, the rectangle will be unchanged.

bool Inti::Gdk::Rectangle::null | ( |  | ) | const

| Returns true if the rectangle is null. A null rectangle has its x, y, width and height set to 0;

Rectangle& Inti::Gdk::Rectangle::offset | ( | int | dx,
|  | int | dy
| ) |

Move the rectangle.

Parameters:

  dx | The number of pixels to add/subtract the X coordinate of the top-left corner.
  dy | The number of pixels to add/subtract the Y coordinate of the top-left corner.

Returns:
  A reference to the resized rectangle.

Rectangle Inti::Gdk::Rectangle::offset_by | ( | int | dx,
|  | int | dy
| ) | const

Move the rectangle and return the result as a new rectangle.

Parameters:

  dx | The number of pixels to add/subtract the X coordinate of the top-left corner.
  dy | The number of pixels to add/subtract the Y coordinate of the top-left corner.

Returns:
  A new rectangle (see offset()).

bool Inti::Gdk::Rectangle::operator &= | ( | const Rectangle & | other | ) |

Calculates the intersection of two rectangles (same as intersect_with()).

Parameters:

  other | A Gdk::Rectangle.

Returns:
  true if this rectangle and other intersect.

bool Inti::Gdk::Rectangle::operator!= | ( | const Rectangle & | other | ) | const

Returns true if this rectangle and other compare unequal.

Parameters:

  other | A Gdk::Rectangle.

Rectangle& Inti::Gdk::Rectangle::operator++ | ( |  | ) |

Inflates the rectangle in all directions by one pixel.

Returns:
  A reference to the resized rectangle.

Rectangle& Inti::Gdk::Rectangle::operator+= | ( | const Point & | point | ) |

Offsets the rectangle by point.x and point.y.

Parameters:

  point | A Point specifying the dx and dy values to offset the top-left corner by.

Returns:
  A reference to the moved rectangle.

Rectangle& Inti::Gdk::Rectangle::operator+= | ( | int | increment | ) |

Inflates the rectangle by increment in all directions.

Parameters:

  increment | The number of pixels to inflate the rectangle by.

Returns:
  A reference to the resized rectangle.

Rectangle& Inti::Gdk::Rectangle::operator-- | ( |  | ) |

Shrink the rectangle in all directions by one pixel.

Returns:
  A reference to the resized rectangle.

Rectangle& Inti::Gdk::Rectangle::operator-= | ( | const Point & | point | ) |

Offsets the rectangle by -point.x and -point.y.

Parameters:

  point | A Point specifying the dx and dy values to offset the top-left corner by.

Returns:
  A reference to the moved rectangle.

Rectangle& Inti::Gdk::Rectangle::operator-= | ( | int | increment | ) |

Shrinks the rectangle by increment in all directions.

Parameters:

  increment | The number of pixels to shrink the rectangle by.

Returns:
  A reference to the resized rectangle.

bool Inti::Gdk::Rectangle::operator== | ( | const Rectangle & | other | ) | const

Returns true if this rectangle and other compare equal.

Parameters:

  other | A Gdk::Rectangle.

void Inti::Gdk::Rectangle::operator|= | ( | const Rectangle & | other | ) |

Calculates the union of this rectangle and other (same as union_with()).

Parameters:

  other | A Gdk::Rectangle.

void Inti::Gdk::Rectangle::set | ( | int | x,
|  | int | y,
|  | int | width,
|  | int | height
| ) |

Sets the position and size of the rectangle.

Parameters:

  x | The new X coordinate of the rectangle.
  y | The new Y coordinate of the rectangle.
  width | The new width of the rectangle.
  height | The new height of the rectangle.

void Inti::Gdk::Rectangle::set_position | ( | const Point & | point | ) |

Sets the position of the rectangle.

Parameters:

  point | The new x, y coordinates of the top-left corner of the rectangle.

void Inti::Gdk::Rectangle::set_position | ( | int | x,
|  | int | y
| ) |

Sets the position of the rectangle.

Parameters:

  x | The new X coordinate of the rectangle.
  y | The new Y coordinate of the rectangle.

void Inti::Gdk::Rectangle::set_size | ( | int | width,
|  | int | height
| ) |

Sets the size of the rectangle.

Parameters:

  width | The new width of the rectangle.
  height | The new height of the rectangle.

void Inti::Gdk::Rectangle::union_with | ( | const Rectangle & | other | ) |

Calculates the union of this rectangle and other.

Parameters:

  other | A Gdk::Rectangle.

The union of two rectangles is the smallest rectangle which includes both rectangles within it. On returning, this rectangle contains the union the original rectangle and other.

The documentation for this class was generated from the following file:

- gdk/types.h

Main Page - Footer