Represents a rectangular area of an image defined as integer X and Y coordinates of its upper left corner and its width and height. This type should be allocated on stack and passed to functions by value or by reference. Never use System::SmartPtr class to manage objects of this type. More...

Public Member Functions

 Rectangle ()
 Constructs a new instance of Rectangle object that represents a rectangle with X and Y coordinates and width and hegiht values set to 0. More...
 
 Rectangle (int x, int y, int width, int height)
 Constructs a new instance of Rectangle object that represents a rectangle with the specified coordinates of its upper left corner and width and height. More...
 
 Rectangle (const Point &location, const Size &size)
 Constructs a new instance of Rectangle object that represents a rectangle with the coordinates of its upper left corner specified as an instance of Point class and its width and height as an instance of Size class. More...
 
 Rectangle (const System::Windows::Forms::Screen::Rectangle_ &rect)
 Constructs a new instance of Rectangle object that represents the rectangle equivalent to the specified one. More...
 
Point get_Location () const
 Returns an instance of the Point class that specifies the location of the upper left corner of the rectangle represented by the current object. More...
 
void set_Location (Point value)
 Sets the location of the upper left corner of the rectangle represented by the current object. More...
 
Size get_Size () const
 Returns an instance of the Size class that specifies the width and height of the rectangle represented by the current object. More...
 
void set_Size (Size value)
 Sets the width and height of the rectangle represented by the current object. More...
 
int get_X () const
 Returns the X coordinate of the upper left corner of the rectangle represented by the current object. More...
 
void set_X (int value)
 Sets the X coordinate of the upper left corner of the rectangle represented by the current object. More...
 
int get_Y () const
 Returns the Y coordinate of the upper left corner of the rectangle represented by the current object. More...
 
void set_Y (int value)
 Sets the Y coordinate of the upper left corner of the rectangle represented by the current object. More...
 
int get_Width () const
 Returns the width of the rectangle represented by the current object. More...
 
void set_Width (int value)
 Sets the width of the rectangle represented by the current object. More...
 
int get_Height () const
 Returns the height of the rectangle represented by the current object. More...
 
void set_Height (int value)
 Sets the height of the rectangle represented by the current object. More...
 
int get_Left () const
 Returns the X coordinate of the left edge of the rectangle represented by the current object. More...
 
int get_Top () const
 Returns the Y coordinate of the top edge of the rectangle represented by the current object. More...
 
int get_Right () const
 Returns the X coordinate of the right edge of the rectangle represented by the current object. More...
 
int get_Bottom () const
 Returns the y coordinate of the bottom edge of the rectangle represented by the current object. More...
 
bool get_IsEmpty () const
 Determines if X and Y coordinates of the upper left corner of the recangle represented by the current object as well as its width and height have values of 0. More...
 
bool Equals (const Rectangle &rect) const
 Determines if the rectangles represented by the current and the specified objects are identical. More...
 
bool Contains (int x, int y) const
 Determines if the specified point is located within the rectangle represented by the current object. More...
 
bool Contains (const Point &point) const
 Determines if the specified point is located within the rectangle represented by the current object. More...
 
bool Contains (const Rectangle &rect) const
 Determines if the specified rectangle is located within the rectangle represented by the current object. More...
 
void Inflate (int width, int height)
 Increases the width and height of the rectangle represented by the current object, maintaining the location of the geometrical center of the rectangle. The width and height are increased in both directions by the specified amounts. More...
 
void Inflate (const Size &size)
 Increases the width and height of the rectangle represented by the current object, maintaining the location of the geometrical center of the rectangle. The width and height are increased in both directions by the amounts specified by width and height values of the specified size object correspondingly. More...
 
void Intersect (const Rectangle &rect)
 Replaces the rectangle represented by the current object with the rectangle that results from the its intersection with the rectangle represented by the specified object. More...
 
bool IntersectsWith (const Rectangle &rect)
 Determines if the rectangles represented by the current and specified objects intesect. More...
 
void Offset (const Point &pos)
 Offsets the position of the rectangle represented by the current object by the specified amounts. More...
 
void Offset (int x, int y)
 Offsets the position of the rectangle represented by the current object by the specified amounts. More...
 
bool operator== (std::nullptr_t) const
 Always returns false. More...
 
bool operator!= (std::nullptr_t) const
 Always returns true. More...
 
String ToString () const
 Returns the string representation of the current object. More...
 
int GetHashCode () const
 Returns a hash code of the current object. More...
 
 operator RectangleF () const
 Returns a RectangleF object that represents a rectangle equivalent to the rectangle represented by the current object. More...
 

Static Public Member Functions

static Rectangle FromLTRB (int left, int top, int right, int bottom)
 Constructs a new Rectangle object that represents a rectangle with the specified edge locations. More...
 
static Rectangle Ceiling (const RectangleF &rect)
 Constructs a Rectangle object from the specified RectangleF object by rounding the RectangleF object's location and size values to the next higher integer values. More...
 
static Rectangle Truncate (const RectangleF &rect)
 Constructs a Rectangle object from the specified RectangleF object by truncating the RectangleF object's location and size values to the next lower integer values. More...
 
static Rectangle Round (const RectangleF &rect)
 Constructs a Rectangle object from the specified RectangleF object by rounding the RectangleF object's location and size values to the nearest integer values. More...
 
static Rectangle Inflate (const Rectangle &rect, int x, int y)
 Increases the width and height of the rectangle represented by the specified object, maintaining the location of the geometrical center of the rectangle. The width and height are increased in both directions by the specified amounts. More...
 
static Rectangle Intersect (const Rectangle &a, const Rectangle &b)
 Returns a rectangle that is a result of intersection of the specified rectangles. More...
 
static Rectangle Union (const Rectangle &a, const Rectangle &b)
 Returns a rectangle that is a result of union of the specified rectangles. More...
 

Static Public Attributes

static const Rectangle Empty
 An empty rectangle i.e. a rectangle whose location and size values have zero values. More...
 

Detailed Description

Represents a rectangular area of an image defined as integer X and Y coordinates of its upper left corner and its width and height. This type should be allocated on stack and passed to functions by value or by reference. Never use System::SmartPtr class to manage objects of this type.

Constructor & Destructor Documentation

◆ Rectangle() [1/4]

System::Drawing::Rectangle::Rectangle ( )

Constructs a new instance of Rectangle object that represents a rectangle with X and Y coordinates and width and hegiht values set to 0.

◆ Rectangle() [2/4]

System::Drawing::Rectangle::Rectangle ( int  x,
int  y,
int  width,
int  height 
)

Constructs a new instance of Rectangle object that represents a rectangle with the specified coordinates of its upper left corner and width and height.

Parameters
xA value of the X coordinate of the upper left corner of the rectangle
yA value of the Y coordinate of the upper left corner of the rectangle
widthThe width of the rectangle
heightThe height of the rectangle

◆ Rectangle() [3/4]

System::Drawing::Rectangle::Rectangle ( const Point location,
const Size size 
)

Constructs a new instance of Rectangle object that represents a rectangle with the coordinates of its upper left corner specified as an instance of Point class and its width and height as an instance of Size class.

Parameters
locationSpecifies the location of the upper left corner of the rectangle
sizeSpecifies the width and hegiht of the rectangle

◆ Rectangle() [4/4]

System::Drawing::Rectangle::Rectangle ( const System::Windows::Forms::Screen::Rectangle_ rect)

Constructs a new instance of Rectangle object that represents the rectangle equivalent to the specified one.

Parameters
rectAn instance of System::Windows::Forms::Screen::Rectangle_ class that specifies the position and size of the rectangle to be represented by the object being constructed

Member Function Documentation

◆ Ceiling()

static Rectangle System::Drawing::Rectangle::Ceiling ( const RectangleF rect)
static

Constructs a Rectangle object from the specified RectangleF object by rounding the RectangleF object's location and size values to the next higher integer values.

Parameters
rectThe RectangleF object to convert
Returns
The Rectangle object constructed from rect

◆ Contains() [1/3]

bool System::Drawing::Rectangle::Contains ( const Point point) const

Determines if the specified point is located within the rectangle represented by the current object.

Parameters
pointA point to check
Returns
True if the specified point is located within the rectangle represented by the current object, otherwise - false

◆ Contains() [2/3]

bool System::Drawing::Rectangle::Contains ( const Rectangle rect) const

Determines if the specified rectangle is located within the rectangle represented by the current object.

Parameters
rectA rectangle to check
Returns
True if the specified rectangle is located within the rectangle represented by the current object, otherwise - false

◆ Contains() [3/3]

bool System::Drawing::Rectangle::Contains ( int  x,
int  y 
) const

Determines if the specified point is located within the rectangle represented by the current object.

Parameters
xThe X coordinate of the point to check
yThe Y coordinate of the point to check
Returns
True if the specified point is located within the rectangle represented by the current object, otherwise - false

◆ Equals()

bool System::Drawing::Rectangle::Equals ( const Rectangle rect) const

Determines if the rectangles represented by the current and the specified objects are identical.

Parameters
rectThe Rectangle object to compare the current object with
Returns
True if the rectangles represented by the current and the specified objects are identical, otherwise - false

◆ FromLTRB()

static Rectangle System::Drawing::Rectangle::FromLTRB ( int  left,
int  top,
int  right,
int  bottom 
)
inlinestatic

Constructs a new Rectangle object that represents a rectangle with the specified edge locations.

Parameters
leftThe X coordinate of the left edge of the rectangle
topThe Y coordinate of the top edge of the rectangle
rightThe X coordinate of the right edge of the rectangle
bottomThe Y coordinate of the bottom edge of the rectangle
Returns
An instance of Rectangle class that represents the speified rectangle

◆ get_Bottom()

int System::Drawing::Rectangle::get_Bottom ( ) const
inline

Returns the y coordinate of the bottom edge of the rectangle represented by the current object.

◆ get_Height()

int System::Drawing::Rectangle::get_Height ( ) const
inline

Returns the height of the rectangle represented by the current object.

◆ get_IsEmpty()

bool System::Drawing::Rectangle::get_IsEmpty ( ) const
inline

Determines if X and Y coordinates of the upper left corner of the recangle represented by the current object as well as its width and height have values of 0.

Returns
True if X and Y coordinates of the upper left corner of the recangle represented by the current object as well as its width and height have values of 0, otherwise - false

◆ get_Left()

int System::Drawing::Rectangle::get_Left ( ) const
inline

Returns the X coordinate of the left edge of the rectangle represented by the current object.

◆ get_Location()

Point System::Drawing::Rectangle::get_Location ( ) const
inline

Returns an instance of the Point class that specifies the location of the upper left corner of the rectangle represented by the current object.

◆ get_Right()

int System::Drawing::Rectangle::get_Right ( ) const
inline

Returns the X coordinate of the right edge of the rectangle represented by the current object.

◆ get_Size()

Size System::Drawing::Rectangle::get_Size ( ) const
inline

Returns an instance of the Size class that specifies the width and height of the rectangle represented by the current object.

◆ get_Top()

int System::Drawing::Rectangle::get_Top ( ) const
inline

Returns the Y coordinate of the top edge of the rectangle represented by the current object.

◆ get_Width()

int System::Drawing::Rectangle::get_Width ( ) const
inline

Returns the width of the rectangle represented by the current object.

◆ get_X()

int System::Drawing::Rectangle::get_X ( ) const
inline

Returns the X coordinate of the upper left corner of the rectangle represented by the current object.

◆ get_Y()

int System::Drawing::Rectangle::get_Y ( ) const
inline

Returns the Y coordinate of the upper left corner of the rectangle represented by the current object.

◆ GetHashCode()

int System::Drawing::Rectangle::GetHashCode ( ) const

Returns a hash code of the current object.

◆ Inflate() [1/3]

static Rectangle System::Drawing::Rectangle::Inflate ( const Rectangle rect,
int  x,
int  y 
)
static

Increases the width and height of the rectangle represented by the specified object, maintaining the location of the geometrical center of the rectangle. The width and height are increased in both directions by the specified amounts.

Parameters
rectA rectangle to inflate
xThe amount by which the width of the rectangle is to be increased in both directions
yThe amount by which the height of the rectangle is to be increased in both directions
Returns
The Rectangle object representing the enlarged rectangle

◆ Inflate() [2/3]

void System::Drawing::Rectangle::Inflate ( const Size size)

Increases the width and height of the rectangle represented by the current object, maintaining the location of the geometrical center of the rectangle. The width and height are increased in both directions by the amounts specified by width and height values of the specified size object correspondingly.

Parameters
sizeThe Size object specifying the amounts to increase the width and height of the rectangle by

◆ Inflate() [3/3]

void System::Drawing::Rectangle::Inflate ( int  width,
int  height 
)

Increases the width and height of the rectangle represented by the current object, maintaining the location of the geometrical center of the rectangle. The width and height are increased in both directions by the specified amounts.

Parameters
widthThe amount by which the width of the rectangle is to be increased in both directions
heightThe amount by which the height of the rectangle is to be increased in both directions

◆ Intersect() [1/2]

static Rectangle System::Drawing::Rectangle::Intersect ( const Rectangle a,
const Rectangle b 
)
static

Returns a rectangle that is a result of intersection of the specified rectangles.

Parameters
aThe first rectangle to intersect
bThe second rectangle to intersect
Returns
The result of intersection of a with b

◆ Intersect() [2/2]

void System::Drawing::Rectangle::Intersect ( const Rectangle rect)

Replaces the rectangle represented by the current object with the rectangle that results from the its intersection with the rectangle represented by the specified object.

Parameters
rectThe Rectangle object that represents the rectangle to intersect the rectangle represented by the current object with

◆ IntersectsWith()

bool System::Drawing::Rectangle::IntersectsWith ( const Rectangle rect)

Determines if the rectangles represented by the current and specified objects intesect.

Parameters
rectThe rectangle to check
Returns
True if the rectangles represented by the current object and rect intersect, otherwise - false

◆ Offset() [1/2]

void System::Drawing::Rectangle::Offset ( const Point pos)

Offsets the position of the rectangle represented by the current object by the specified amounts.

Parameters
posThe Point object that specifies the amount by which the rectangle is offset; the point's X coordinat value specifies the amount to add to the X coordinate of the upper left corner of the rectangle and the point's Y coordinate specifies the amount to add to the Y coordinate of the upper left corner of the rectangle

◆ Offset() [2/2]

void System::Drawing::Rectangle::Offset ( int  x,
int  y 
)

Offsets the position of the rectangle represented by the current object by the specified amounts.

Parameters
xThe value to add to the current X coordinate of the rectangle
yThe value to add to the current Y coordinate of the rectangle

◆ operator RectangleF()

System::Drawing::Rectangle::operator RectangleF ( ) const

Returns a RectangleF object that represents a rectangle equivalent to the rectangle represented by the current object.

◆ operator!=()

bool System::Drawing::Rectangle::operator!= ( std::nullptr_t  ) const
inline

Always returns true.

◆ operator==()

bool System::Drawing::Rectangle::operator== ( std::nullptr_t  ) const
inline

Always returns false.

◆ Round()

static Rectangle System::Drawing::Rectangle::Round ( const RectangleF rect)
static

Constructs a Rectangle object from the specified RectangleF object by rounding the RectangleF object's location and size values to the nearest integer values.

Parameters
rectThe RectangleF object to convert
Returns
The Rectangle object constructed from rect

◆ set_Height()

void System::Drawing::Rectangle::set_Height ( int  value)
inline

Sets the height of the rectangle represented by the current object.

Parameters
valueThe value to set

◆ set_Location()

void System::Drawing::Rectangle::set_Location ( Point  value)
inline

Sets the location of the upper left corner of the rectangle represented by the current object.

Parameters
valueThe value to set

◆ set_Size()

void System::Drawing::Rectangle::set_Size ( Size  value)
inline

Sets the width and height of the rectangle represented by the current object.

Parameters
valueAn instance of Size class specifying the width and height values to set

◆ set_Width()

void System::Drawing::Rectangle::set_Width ( int  value)
inline

Sets the width of the rectangle represented by the current object.

Parameters
valueThe value to set

◆ set_X()

void System::Drawing::Rectangle::set_X ( int  value)
inline

Sets the X coordinate of the upper left corner of the rectangle represented by the current object.

Parameters
valueThe value to set

◆ set_Y()

void System::Drawing::Rectangle::set_Y ( int  value)
inline

Sets the Y coordinate of the upper left corner of the rectangle represented by the current object.

Parameters
valueThe value to set

◆ ToString()

String System::Drawing::Rectangle::ToString ( ) const

Returns the string representation of the current object.

◆ Truncate()

static Rectangle System::Drawing::Rectangle::Truncate ( const RectangleF rect)
static

Constructs a Rectangle object from the specified RectangleF object by truncating the RectangleF object's location and size values to the next lower integer values.

Parameters
rectThe RectangleF object to convert
Returns
The Rectangle object constructed from rect

◆ Union()

static Rectangle System::Drawing::Rectangle::Union ( const Rectangle a,
const Rectangle b 
)
static

Returns a rectangle that is a result of union of the specified rectangles.

Parameters
aThe first rectangle to union
bThe second rectangle to union
Returns
The result of union of a with b

Member Data Documentation

◆ Empty

const Rectangle System::Drawing::Rectangle::Empty
static

An empty rectangle i.e. a rectangle whose location and size values have zero values.