Overload gfx::Border class operators to increment/decrement border size.

This commit is contained in:
David Capello 2011-01-30 23:18:52 -03:00
parent f8e940d7a4
commit a7ea661ad0
2 changed files with 76 additions and 0 deletions

View File

@ -24,6 +24,74 @@ Border::Border(int left, int top, int right, int bottom)
m_bottom = bottom;
}
const Border& Border::operator+=(int value)
{
m_left += value;
m_top += value;
m_right += value;
m_bottom += value;
return *this;
}
const Border& Border::operator-=(int value)
{
m_left -= value;
m_top -= value;
m_right -= value;
m_bottom -= value;
return *this;
}
const Border& Border::operator*=(int value)
{
m_left *= value;
m_top *= value;
m_right *= value;
m_bottom *= value;
return *this;
}
const Border& Border::operator/=(int value)
{
m_left /= value;
m_top /= value;
m_right /= value;
m_bottom /= value;
return *this;
}
Border Border::operator+(int value) const
{
return Border(m_left + value,
m_top + value,
m_right + value,
m_bottom + value);
}
Border Border::operator-(int value) const
{
return Border(m_left - value,
m_top - value,
m_right - value,
m_bottom - value);
}
Border Border::operator*(int value) const
{
return Border(m_left * value,
m_top * value,
m_right * value,
m_bottom * value);
}
Border Border::operator/(int value) const
{
return Border(m_left / value,
m_top / value,
m_right / value,
m_bottom / value);
}
Border Border::operator-() const
{
return Border(-m_left, -m_top, -m_right, -m_bottom);

View File

@ -25,6 +25,14 @@ public:
void right(int right) { m_right = right; }
void bottom(int bottom) { m_bottom = bottom; }
const Border& operator+=(int value);
const Border& operator-=(int value);
const Border& operator*=(int value);
const Border& operator/=(int value);
Border operator+(int value) const;
Border operator-(int value) const;
Border operator*(int value) const;
Border operator/(int value) const;
Border operator-() const;
bool operator==(const Border& br) const;