Kaydet (Commit) 6fb6b45c authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

Add expand (contract) to Rectangle as it is often used.

Change-Id: I98e2738a1f79a1157c18b6003f70955e071f1654
üst c7f056ac
......@@ -443,6 +443,15 @@ public:
/// Returns the string representation of the rectangle, format is "x, y, width, height".
rtl::OString toString() const;
/**
* Expands the rectangle in all directions by the input value.
*/
inline void expand(long nExpandBy);
/**
* Contracts the rectangle in all directions by the input value.
*/
inline void contract(long nContractBy);
private:
long nLeft;
long nTop;
......@@ -689,6 +698,22 @@ inline Rectangle operator - ( const Rectangle& rRect, const Point& rPt )
return aRect;
}
inline void Rectangle::expand(long nExpandBy)
{
nLeft -= nExpandBy;
nTop -= nExpandBy;
nRight += nExpandBy;
nBottom += nExpandBy;
}
inline void Rectangle::contract(long nContractBy)
{
nLeft += nContractBy;
nTop += nContractBy;
nRight -= nContractBy;
nBottom -= nContractBy;
}
template< typename charT, typename traits >
inline std::basic_ostream<charT, traits> & operator <<(
std::basic_ostream<charT, traits> & stream, const Rectangle& rectangle )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment