gtkmm  4.8.0
Public Member Functions | Static Public Member Functions | Protected Attributes | Related Functions | List of all members
Gdk::Rectangle Class Reference

Gdk::Rectangle is a structure holding the position and size of a rectangle. More...

#include <gdkmm/rectangle.h>

Public Member Functions

 Rectangle (const Rectangle & other) noexcept
 
Rectangleoperator= (const Rectangle & other) noexcept
 
 Rectangle (Rectangle && other) noexcept
 
Rectangleoperator= (Rectangle && other) noexcept
 
 Rectangle ()
 
 Rectangle (const GdkRectangle * gobject)
 
GdkRectangle * gobj ()
 Provides access to the underlying C instance. More...
 
const GdkRectangle * gobj () const
 Provides access to the underlying C instance. More...
 
 Rectangle (int x, int y, int width, int height)
 Creates a new rectangle instance with these dimensions. More...
 
bool operator== (const Rectangle & src) const
 
Rectanglejoin (const Rectangle & src2)
 Calculates the union of two rectangles, changing this rectangle. More...
 
Rectangleintersect (const Rectangle & src2)
 Calculates the intersection of two rectangles, changing this rectangle. More...
 
Rectangleintersect (const Rectangle & src2, bool & rectangles_intersect)
 Calculates the intersection of two rectangles, changing this rectangle. More...
 
bool intersects (const Rectangle & src2) const
 Checks whether two rectangles intersect. More...
 
bool has_zero_area () const
 Checks whether either the width or height is 0. More...
 
bool contains_point (int x, int y) const
 Returns true if rect contains the point described by x and y. More...
 
int get_x () const
 
void set_x (const int & value)
 
int get_y () const
 
void set_y (const int & value)
 
int get_width () const
 
void set_width (const int & value)
 
int get_height () const
 
void set_height (const int & value)
 

Static Public Member Functions

static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system. More...
 

Protected Attributes

GdkRectangle gobject_
 

Related Functions

(Note that these are not member functions.)

Rectangle join (const Rectangle & src1, const Rectangle & src2)
 Calculates the union of two rectangles. More...
 
Rectangle intersect (const Rectangle & src1, const Rectangle & src2)
 Calculates the intersection of two rectangles. More...
 
Rectangle intersect (const Rectangle & src1, const Rectangle & src2, bool & rectangles_intersect)
 Calculates the intersection of two rectangles. More...
 
Gdk::Rectanglewrap (GdkRectangle * object)
 
const Gdk::Rectanglewrap (const GdkRectangle * object)
 

Detailed Description

Gdk::Rectangle is a structure holding the position and size of a rectangle.

The intersection of two rectangles can be computed with intersect(). To find the union of two rectangles use join().

Constructor & Destructor Documentation

◆ Rectangle() [1/5]

Gdk::Rectangle::Rectangle ( const Rectangle other)
noexcept

◆ Rectangle() [2/5]

Gdk::Rectangle::Rectangle ( Rectangle &&  other)
noexcept

◆ Rectangle() [3/5]

Gdk::Rectangle::Rectangle ( )

◆ Rectangle() [4/5]

Gdk::Rectangle::Rectangle ( const GdkRectangle *  gobject)
explicit

◆ Rectangle() [5/5]

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

Creates a new rectangle instance with these dimensions.

Member Function Documentation

◆ contains_point()

bool Gdk::Rectangle::contains_point ( int  x,
int  y 
) const

Returns true if rect contains the point described by x and y.

Parameters
xX coordinate.
yY coordinate.
Returns
true if rect contains the point.

◆ get_height()

int Gdk::Rectangle::get_height ( ) const

◆ get_type()

static GType Gdk::Rectangle::get_type ( )
static

Get the GType for this class, for use with the underlying GObject type system.

◆ get_width()

int Gdk::Rectangle::get_width ( ) const

◆ get_x()

int Gdk::Rectangle::get_x ( ) const

◆ get_y()

int Gdk::Rectangle::get_y ( ) const

◆ gobj() [1/2]

GdkRectangle* Gdk::Rectangle::gobj ( )
inline

Provides access to the underlying C instance.

◆ gobj() [2/2]

const GdkRectangle* Gdk::Rectangle::gobj ( ) const
inline

Provides access to the underlying C instance.

◆ has_zero_area()

bool Gdk::Rectangle::has_zero_area ( ) const

Checks whether either the width or height is 0.

Returns
Whether this rectangle has 0 area.

◆ intersect() [1/2]

Rectangle& Gdk::Rectangle::intersect ( const Rectangle src2)

Calculates the intersection of two rectangles, changing this rectangle.

If the rectangles do not intersect, this rectangle's width and height are set to 0 and its x and y values are undefined.

This method returns a reference to this instance, allowing you to then call another method easily. For instance: rect.intersect(src2).join(src3);

Parameters
src2The rectangle with which to calculate the intersection with this rectangle.
Returns
A reference to this rectangle.

◆ intersect() [2/2]

Rectangle& Gdk::Rectangle::intersect ( const Rectangle src2,
bool &  rectangles_intersect 
)

Calculates the intersection of two rectangles, changing this rectangle.

If the rectangles do not intersect, this rectangle's width and height are set to 0 and its x and y values are undefined.

This method returns a reference to this instance, allowing you to then call another method easily. For instance: rect.intersect(src2, rectangles_intersect).join(src3);

Parameters
src2The rectangle with which to calculate the intersection with this rectangle.
[out]rectangles_intersectThis will be set to true if the rectangles intersect, else false.
Returns
A reference to this rectangle.

◆ intersects()

bool Gdk::Rectangle::intersects ( const Rectangle src2) const

Checks whether two rectangles intersect.

Since gtkmm 3.8:
Parameters
src2The rectangle with which to check intersection with this rectangle.
Returns
Whether this rectangle intersects src2.

◆ join()

Rectangle& Gdk::Rectangle::join ( const Rectangle src2)

Calculates the union of two rectangles, changing this rectangle.

The union of this rectangle and src2 is the smallest rectangle which includes both this rectangle and src2 within it.

This method returns a reference to this instance, allowing you to then call another method easily. For instance: rect.join(src2).intersect(src3);

Parameters
src2The rectangle with which to calculate the union with this rectangle.
Returns
A reference to this rectangle.

◆ operator=() [1/2]

Rectangle& Gdk::Rectangle::operator= ( const Rectangle other)
noexcept

◆ operator=() [2/2]

Rectangle& Gdk::Rectangle::operator= ( Rectangle &&  other)
noexcept

◆ operator==()

bool Gdk::Rectangle::operator== ( const Rectangle src) const

◆ set_height()

void Gdk::Rectangle::set_height ( const int &  value)

◆ set_width()

void Gdk::Rectangle::set_width ( const int &  value)

◆ set_x()

void Gdk::Rectangle::set_x ( const int &  value)

◆ set_y()

void Gdk::Rectangle::set_y ( const int &  value)

Friends And Related Function Documentation

◆ intersect() [1/2]

Rectangle intersect ( const Rectangle src1,
const Rectangle src2 
)
related

Calculates the intersection of two rectangles.

If the rectangles do not intersect, the returned rectangle's width and height are set to 0 and its x and y values are undefined.

Since gtkmm 3.8:
Parameters
src1One of the rectangles.
src2The other rectangle.
Returns
The intersection of src1 and src2.

◆ intersect() [2/2]

Rectangle intersect ( const Rectangle src1,
const Rectangle src2,
bool &  rectangles_intersect 
)
related

Calculates the intersection of two rectangles.

If the rectangles do not intersect, the returned rectangle's width and height are set to 0 and its x and y values are undefined.

Since gtkmm 3.8:
Parameters
src1One of the rectangles.
src2The other rectangle.
[out]rectangles_intersectThis will be set to true if the rectangles intersect, else false.
Returns
The intersection of src1 and src2.

◆ join()

Rectangle join ( const Rectangle src1,
const Rectangle src2 
)
related

Calculates the union of two rectangles.

The union of src1 and src2 is the smallest rectangle which includes both src1 and src2 within it.

Since gtkmm 3.8:
Parameters
src1One of the rectangles.
src2The other rectangle.
Returns
The union of src1 and src2.

◆ wrap() [1/2]

const Gdk::Rectangle & wrap ( const GdkRectangle *  object)
related
Parameters
objectThe C instance
Returns
A C++ instance that wraps this C instance.

◆ wrap() [2/2]

Gdk::Rectangle & wrap ( GdkRectangle *  object)
related
Parameters
objectThe C instance
Returns
A C++ instance that wraps this C instance.

Member Data Documentation

◆ gobject_

GdkRectangle Gdk::Rectangle::gobject_
protected