gtkmm: Gdk::Graphene::Rect Class Reference

gtkmm 4.12.0

Public Member Functions | Protected Attributes | Related Symbols | List of all members
Gdk::Graphene::Rect Class Reference

The location and size of a rectangle region. More...

`#include <gdkmm/graphene_rect.h>`

## Public Member Functions
| Rect ()
| Constructs an invalid object.
| Rect (graphene_rect_t * castitem, bool make_a_copy=false)
| Rect (const Rect & src)
Rect & | operator= (const Rect & src)
| Rect (Rect && other) noexcept
Rect & | operator= (Rect && other) noexcept
| ~Rect () noexcept
void | swap (Rect & other) noexcept
graphene_rect_t * | gobj ()
const graphene_rect_t * | gobj () const
graphene_rect_t * | gobj_copy () const
| Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.
| Rect (float x, float y, float width, float height)
| operator bool () const
| Checks if this instance is valid.
Point | get_origin () const
void | set_origin (const Point & value)
Size | get_size () const
void | set_size (const Size & value)
Point | get_center () const
| Retrieves the coordinates of the center of the given rectangle.
Point | get_top_left () const
| Retrieves the coordinates of the top-left corner of the given rectangle.
Point | get_top_right () const
| Retrieves the coordinates of the top-right corner of the given rectangle.
Point | get_bottom_right () const
| Retrieves the coordinates of the bottom-right corner of the given rectangle.
Point | get_bottom_left () const
| Retrieves the coordinates of the bottom-left corner of the given rectangle.
bool | equal (const Rect & b) const
| Checks whether the two given rectangle are equal.
void | normalize ()
| Normalizes the passed rectangle.
float | get_x () const
| Retrieves the normalized X coordinate of the origin of the given rectangle.
float | get_y () const
| Retrieves the normalized Y coordinate of the origin of the given rectangle.
float | get_width () const
| Retrieves the normalized width of the given rectangle.
float | get_height () const
| Retrieves the normalized height of the given rectangle.
float | get_area () const
| Compute the area of given normalized rectangle.
bool | contains_point (const Point & p) const
| Checks whether a graphene_rect_t contains the given coordinates.
bool | contains_rect (const Rect & b) const
| Checks whether a graphene_rect_t fully contains the given rectangle.

## Protected Attributes
graphene_rect_t * | gobject_

## Related Symbols
(Note that these are not member symbols.)
void | swap (Rect & lhs, Rect & rhs) noexcept
Gdk::Graphene::Rect | wrap (graphene_rect_t * object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

The location and size of a rectangle region.

The width and height of a Gdk::Graphene::Rect can be negative; for instance, a Gdk::Graphene::Rect with an origin of [ 0, 0 ] and a size of [ 10, 10 ] is equivalent to a Gdk::Graphene::Rect with an origin of [ 10, 10 ] and a size of [ -10, -10 ].

Application code can normalize rectangles using normalize(); this function will ensure that the width and height of a rectangle are positive values. All functions taking a Gdk::Graphene::Rect as an argument will internally operate on a normalized copy; all functions returning a Gdk::Graphene::Rect will always return a normalized rectangle.

Since gtkmm 4.12:

## Constructor & Destructor Documentation

## ◆ Rect() [1/5]

Gdk::Graphene::Rect::Rect | ( |  | ) |

Constructs an invalid object.

E.g. for output arguments to methods. There is not much you can do with the object before it has been assigned a valid value.

## ◆ Rect() [2/5]

Gdk::Graphene::Rect::Rect | ( | graphene_rect_t * | castitem,
|  | bool | make_a_copy = `false`
| ) |  |
| explicit

## ◆ Rect() [3/5]

Gdk::Graphene::Rect::Rect | ( | const Rect & | src | ) |

## ◆ Rect() [4/5]

Gdk::Graphene::Rect::Rect | ( | Rect && | other | ) |
| noexcept

## ◆ ~Rect()

Gdk::Graphene::Rect::~Rect | ( |  | ) |
| noexcept

## ◆ Rect() [5/5]

Gdk::Graphene::Rect::Rect | ( | float | x,
|  | float | y,
|  | float | width,
|  | float | height
| ) |  |

## Member Function Documentation

## ◆ contains_point()

bool Gdk::Graphene::Rect::contains_point | ( | const Point & | p | ) | const

Checks whether a graphene_rect_t contains the given coordinates.

Since gtkmm 4.12:

Parameters

  p | A #graphene_point_t.

Returns
  `true` if the rectangle contains the point.

## ◆ contains_rect()

bool Gdk::Graphene::Rect::contains_rect | ( | const Rect & | b | ) | const

Checks whether a graphene_rect_t fully contains the given rectangle.

Since gtkmm 4.12:

Parameters

  b | A graphene_rect_t.

Returns
  `true` if the rectangle a fully contains b.

## ◆ equal()

bool Gdk::Graphene::Rect::equal | ( | const Rect & | b | ) | const

Checks whether the two given rectangle are equal.

Since gtkmm 4.12:

Parameters

  b | A graphene_rect_t.

Returns
  `true` if the rectangles are equal.

## ◆ get_area()

float Gdk::Graphene::Rect::get_area | ( |  | ) | const

Compute the area of given normalized rectangle.

Since gtkmm 4.12:

Returns
  The area of the normalized rectangle.

## ◆ get_bottom_left()

Point Gdk::Graphene::Rect::get_bottom_left | ( |  | ) | const

Retrieves the coordinates of the bottom-left corner of the given rectangle.

## ◆ get_bottom_right()

Point Gdk::Graphene::Rect::get_bottom_right | ( |  | ) | const

Retrieves the coordinates of the bottom-right corner of the given rectangle.

## ◆ get_center()

Point Gdk::Graphene::Rect::get_center | ( |  | ) | const

Retrieves the coordinates of the center of the given rectangle.

## ◆ get_height()

float Gdk::Graphene::Rect::get_height | ( |  | ) | const

Retrieves the normalized height of the given rectangle.

Since gtkmm 4.12:

Returns
  The normalized height of the rectangle.

## ◆ get_origin()

Point Gdk::Graphene::Rect::get_origin | ( |  | ) | const

## ◆ get_size()

Size Gdk::Graphene::Rect::get_size | ( |  | ) | const

## ◆ get_top_left()

Point Gdk::Graphene::Rect::get_top_left | ( |  | ) | const

Retrieves the coordinates of the top-left corner of the given rectangle.

## ◆ get_top_right()

Point Gdk::Graphene::Rect::get_top_right | ( |  | ) | const

Retrieves the coordinates of the top-right corner of the given rectangle.

## ◆ get_width()

float Gdk::Graphene::Rect::get_width | ( |  | ) | const

Retrieves the normalized width of the given rectangle.

Since gtkmm 4.12:

Returns
  The normalized width of the rectangle.

## ◆ get_x()

float Gdk::Graphene::Rect::get_x | ( |  | ) | const

Retrieves the normalized X coordinate of the origin of the given rectangle.

Since gtkmm 4.12:

Returns
  The normalized X coordinate of the rectangle.

## ◆ get_y()

float Gdk::Graphene::Rect::get_y | ( |  | ) | const

Retrieves the normalized Y coordinate of the origin of the given rectangle.

Since gtkmm 4.12:

Returns
  The normalized Y coordinate of the rectangle.

## ◆ gobj() [1/2]

graphene_rect_t * Gdk::Graphene::Rect::gobj | ( |  | ) |
| inline

## ◆ gobj() [2/2]

const graphene_rect_t * Gdk::Graphene::Rect::gobj | ( |  | ) | const
| inline

## ◆ gobj_copy()

graphene_rect_t * Gdk::Graphene::Rect::gobj_copy | ( |  | ) | const

Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.

## ◆ normalize()

void Gdk::Graphene::Rect::normalize | ( |  | ) |

Normalizes the passed rectangle.

This function ensures that the size of the rectangle is made of positive values, and that the origin is the top-left corner of the rectangle.

Since gtkmm 4.12:

## ◆ operator bool()

Gdk::Graphene::Rect::operator bool | ( |  | ) | const
| explicit

Checks if this instance is valid.

It is valid if and only if it contains a value. For instance,

if (rect)
do_something()

## ◆ operator=() [1/2]

Rect & Gdk::Graphene::Rect::operator= | ( | const Rect & | src | ) |

## ◆ operator=() [2/2]

Rect & Gdk::Graphene::Rect::operator= | ( | Rect && | other | ) |
| noexcept

## ◆ set_origin()

void Gdk::Graphene::Rect::set_origin | ( | const Point & | value | ) |

## ◆ set_size()

void Gdk::Graphene::Rect::set_size | ( | const Size & | value | ) |

## ◆ swap()

void Gdk::Graphene::Rect::swap | ( | Rect & | other | ) |
| noexcept

## Friends And Related Symbol Documentation

## ◆ swap()

void swap | ( | Rect & | lhs,
|  | Rect & | rhs
| ) |  |
| related

Parameters

  lhs | The left-hand side
  rhs | The right-hand side

## ◆ wrap()

Gdk::Graphene::Rect wrap | ( | graphene_rect_t * | object,
|  | bool | take_copy = `false`
| ) |  |
| related

A Glib::wrap() method for this object.

Parameters

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns
  A C++ instance that wraps this C instance.

## Member Data Documentation

## ◆ gobject_

graphene_rect_t* Gdk::Graphene::Rect::gobject_
| protected