Defines a rectangular area aligned along pixel dimensions. More...
Public Member Functions  
BRect ()  
Creates an empty BRect object with dimensions (0, 0, 1, 1).  
BRect (BPoint leftTop, BPoint rightBottom)  
Creates a new BRect object with its dimensions defined by the leftTop and rightBottom points.  
BRect (BPoint leftTop, BSize size)  
Creates a new BRect object with its dimensions defined by the leftTop point and size.  
BRect (const BRect &other)  
Creates a new BRect object as a copy of other.  
BRect (float left, float top, float right, float bottom)  
Creates a new BRect object with the given dimensions.  
BRect (float side)  
Creates a new BRect object setting the left and top dimensions to 0 and setting the right and bottom dimensions to side  1.  
bool  Contains (BPoint point) const 
Returns whether or not the BRect contains point.  
bool  Contains (BRect rect) const 
Returns whether or not the BRect wholly contains rect.  
float  Height () const 
Returns the height of the rectangle.  
int32  IntegerHeight () const 
Returns The height of the rectangle rounded using ceil(bottom  top).  
int32  IntegerWidth () const 
Returns The width of the rectangle rounded using ceil(right  left).  
bool  Intersects (BRect rect) const 
Returns whether or not the BRect and rect intersect.  
bool  IsValid () const 
Returns whether or not the BRect is valid.  
BPoint  LeftBottom () const 
Returns the left bottom point of the BRect.  
BPoint  LeftTop () const 
Returns the left top point of the BRect.  
void  PrintToStream () const 
Prints the BRect dimensions to standard output.  
BPoint  RightBottom () const 
Returns the right bottom point of the BRect.  
BPoint  RightTop () const 
Returns the right top point of the BRect.  
void  Set (float left, float top, float right, float bottom) 
Sets the dimensions of a BRect.  
void  SetLeftBottom (const BPoint point) 
Sets the left bottom point of the BRect.  
void  SetLeftTop (const BPoint point) 
Sets the left top point of the BRect.  
void  SetRightBottom (const BPoint point) 
Sets the right bottom point of the BRect.  
void  SetRightTop (const BPoint point) 
Sets the right top point of the BRect.  
BSize  Size () const 
Returns the dimensions of the BRect.  
float  Width () const 
Returns the width of the rectangle.  
Operators  
BRect &  operator= (const BRect &other) 
Creates a new BRect object as a copy of other by overloading the = operator.  
bool  operator== (BRect other) const 
Returns whether or not two rectangles coincide exactly.  
bool  operator!= (BRect other) const 
Returns whether or not two rectangles do NOT coincide exactly.  
BRect  operator& (BRect other) const 
Creates and returns a new BRect that is the intersection of the BRect and other.  
BRect  operator (BRect other) const 
Returns a new BRect that is the union of the BRect and other.  
Transformation  
Positive values make the rectangle smaller, negative values make it larger. The …Self() versions also return the transformed BRect when they are done. The …Copy() versions transform a copy without changing the original.  
void  InsetBy (BPoint inset) 
Inset the BRect by the x and y coordinates of point.  
void  InsetBy (float dx, float dy) 
Inset the BRect by dx units in the horizontal direction and dy units in the vertical direction.  
BRect &  InsetBySelf (BPoint inset) 
Like BRect::InsetBy() but returns the transformed BRect.  
BRect &  InsetBySelf (float dx, float dy) 
Like BRect::InsetBy() but returns the transformed BRect.  
BRect  InsetByCopy (BPoint inset) const 
Like BRect::InsetBy() but returns a copy of the transformed BRect leaving the original unmodified.  
BRect  InsetByCopy (float dx, float dy) const 
Like BRect::InsetBy() but returns a copy of the transformed BRect leaving the original unmodified.  
Translation  
Positive values move the rectangle right and down, negative values move the rectangle left and up. The …Self() versions also return the translated BRect when they are done. The …Copy() versions translate a copy without changing the original.  
void  OffsetBy (BPoint delta) 
Moves the BRect horizontally by the x value of point and vertically by y value of point without changing the size of the rectangle.  
void  OffsetBy (float dx, float dy) 
Moves the BRect horizontally by dx units and vertically by dy units point without changing the size of the rectangle.  
void  OffsetTo (BPoint offset) 
Move the BRect to the location specified by point.  
void  OffsetTo (float x, float y) 
Move the BRect to the point specified by the given x and y coordinates.  
BRect &  OffsetBySelf (BPoint offset) 
Like BRect::OffsetBy() but returns the translated BRect.  
BRect &  OffsetBySelf (float dx, float dy) 
Like BRect::OffsetBy() but returns the translated BRect.  
BRect  OffsetByCopy (BPoint offset) const 
Like BRect::OffsetBy() but returns a copy of the translated BRect leaving the original unmodified.  
BRect  OffsetByCopy (float dx, float dy) const 
Like BRect::OffsetBy() but returns a copy of the translated BRect leaving the original unmodified.  
BRect &  OffsetToSelf (BPoint offset) 
Like BRect::OffsetTo() but returns the translated BRect.  
BRect &  OffsetToSelf (float x, float y) 
Like BRect::OffsetTo() but returns the translated BRect.  
BRect  OffsetToCopy (BPoint offset) const 
Like BRect::OffsetTo() but returns a copy of the translated BRect leaving the original unmodified.  
BRect  OffsetToCopy (float x, float y) const 
Like BRect::OffsetTo() but returns a copy of the translated BRect leaving the original unmodified.  
Public Attributes  
float  bottom 
The value of the rectangle's bottom edge.  
float  left 
The value of the rectangle's left edge.  
float  right 
The value of the rectangle's right edge.  
float  top 
The value of the rectangle's top edge.  
Defines a rectangular area aligned along pixel dimensions.
BRect's are used throughout the Interface Kit to define the frames of windows, views, and bitmaps. BRect's are always oriented with completely vertical and horizontal lines, they cannot be rotated.
A BRect must have a nonnegative width and height to be valid, that is the left value must be greater than or equal to the right value and the bottom edge value be greater than or equal to the top value. You can test whether or not a BRect is valid by calling IsValid(). Nothing prevents you from creating an invalid BRect, but, using one to define an area can produce unpredictable results.
A gotcha of using BRect's is that the starting point is 0, not 1, so in order to create a BRect with a 32x32 pixel area you write:
or if you have the width and height stored in a variable you subtract 1 like this:

inline 
Creates an empty BRect object with dimensions (0, 0, 1, 1).
These dimensions are invalid, use Set() to provide valid dimensions.

inline 

inline 
Creates a new BRect object with the given dimensions.
left  The left dimension. 
top  The top dimension. 
right  The right dimension. 
bottom  The bottom dimension. 
Creates a new BRect object with its dimensions defined by the leftTop and rightBottom points.
leftTop  The position to set the left top corner to. 
rightBottom  The position to set the bottom right corner to. 
Creates a new BRect object with its dimensions defined by the leftTop point and size.
leftTop  The position of the left top corner. 
size  The size of the rect defining its width and height. 

inline 
Creates a new BRect object setting the left and top dimensions to 0 and setting the right and bottom dimensions to side  1.
side  The dimension to set the right and bottom sides. 
bool BRect::Contains  (  BPoint  point  )  const 
bool BRect::Contains  (  BRect  rect  )  const 

inline 
void BRect::InsetBy  (  BPoint  point  ) 
void BRect::InsetBy  (  float  dx, 
float  dy  
) 
Like BRect::InsetBy() but returns a copy of the transformed BRect leaving the original unmodified.
point  The point to use to inset the BRect. 
BRect BRect::InsetByCopy  (  float  dx, 
float  dy  
)  const 
Like BRect::InsetBy() but returns a copy of the transformed BRect leaving the original unmodified.
dx  The horizontal distance to inset the BRect by. 
dy  The vertical distance to inset the BRect by. 
Like BRect::InsetBy() but returns the transformed BRect.
point  The point to use to inset the BRect. 
BRect & BRect::InsetBySelf  (  float  dx, 
float  dy  
) 
Like BRect::InsetBy() but returns the transformed BRect.
dx  The horizontal distance to inset the BRect by. 
dy  The vertical distance to inset the BRect by. 

inline 

inline 
bool BRect::Intersects  (  BRect  rect  )  const 

inline 

inline 

inline 
void BRect::OffsetBy  (  BPoint  point  ) 
Moves the BRect horizontally by the x value of point and vertically by y value of point without changing the size of the rectangle.
point  The point to use to move the rectangle. 
void BRect::OffsetBy  (  float  dx, 
float  dy  
) 
Moves the BRect horizontally by dx units and vertically by dy units point without changing the size of the rectangle.
dx  The number of units the move the rectangle vertically. 
dy  The number of units the move the rectangle horizontally. 
Like BRect::OffsetBy() but returns a copy of the translated BRect leaving the original unmodified.
point  The point to use to move the rectangle. 
BRect BRect::OffsetByCopy  (  float  dx, 
float  dy  
)  const 
Like BRect::OffsetBy() but returns a copy of the translated BRect leaving the original unmodified.
dx  The number of units the move the rectangle vertically. 
dy  The number of units the move the rectangle horizontally. 
Like BRect::OffsetBy() but returns the translated BRect.
point  The point to use to move the rectangle. 
BRect & BRect::OffsetBySelf  (  float  dx, 
float  dy  
) 
Like BRect::OffsetBy() but returns the translated BRect.
dx  The number of units the move the rectangle vertically. 
dy  The number of units the move the rectangle horizontally. 
void BRect::OffsetTo  (  BPoint  point  ) 
void BRect::OffsetTo  (  float  x, 
float  y  
) 
Like BRect::OffsetTo() but returns a copy of the translated BRect leaving the original unmodified.
point  The point to use to move the rectangle. 
BRect BRect::OffsetToCopy  (  float  x, 
float  y  
)  const 
Like BRect::OffsetTo() but returns a copy of the translated BRect leaving the original unmodified.
x  The number of units the move the rectangle vertically. 
y  The number of units the move the rectangle horizontally. 
Like BRect::OffsetTo() but returns the translated BRect.
point  The point to use to move the rectangle. 
BRect & BRect::OffsetToSelf  (  float  x, 
float  y  
) 
Like BRect::OffsetTo() but returns the translated BRect.
x  The vertical coordinate of the point to move the BRect to. 
y  The horizontal coordinate of the point to move the BRect to. 
bool BRect::operator!=  (  BRect  other  )  const 
Returns whether or not two rectangles do NOT coincide exactly.
other  The BRect to compare with. 
true
if the rectangles do NOT coincide, false
otherwise.bool BRect::operator==  (  BRect  other  )  const 
Returns whether or not two rectangles coincide exactly.
other  The BRect to compare with. 
true
if the rectangles coincide, false
otherwise.void BRect::PrintToStream  (  )  const 
Prints the BRect dimensions to standard output.
The format of the output looks like this:
BRect(l:%.1f, t:%.1f, r:%.1f, b:%.1f).

inline 

inline 

inline 
void BRect::SetLeftBottom  (  const BPoint  point  ) 
void BRect::SetLeftTop  (  const BPoint  point  ) 
void BRect::SetRightBottom  (  const BPoint  point  ) 
void BRect::SetRightTop  (  const BPoint  point  ) 

inline 

inline 
BRect::bottom 
The value of the rectangle's bottom edge.
Referenced by Height(), IntegerHeight(), IsValid(), LeftBottom(), operator=(), Set(), and Size().
BRect::left 
The value of the rectangle's left edge.
Referenced by IntegerWidth(), IsValid(), LeftBottom(), LeftTop(), operator=(), Set(), Size(), and Width().
BRect::right 
The value of the rectangle's right edge.
Referenced by IntegerWidth(), IsValid(), operator=(), RightBottom(), RightTop(), Set(), Size(), and Width().
BRect::top 
The value of the rectangle's top edge.
Referenced by Height(), IntegerHeight(), IsValid(), operator=(), RightTop(), Set(), and Size().