Add some operators+(Border) to Border class and Border::getSize() member function.

This commit is contained in:
David Capello 2011-02-19 23:44:48 -03:00
parent e2848f1f55
commit 88112b7ffe
2 changed files with 86 additions and 0 deletions

View File

@ -5,6 +5,7 @@
// read LICENSE.txt for more information.
#include "gfx/border.h"
#include "gfx/size.h"
using namespace gfx;
@ -24,6 +25,47 @@ Border::Border(int left, int top, int right, int bottom)
m_bottom = bottom;
}
Size Border::getSize() const
{
return Size(m_left + m_right, m_top + m_bottom);
}
const Border& Border::operator+=(const Border& br)
{
m_left += br.m_left;
m_top += br.m_top;
m_right += br.m_right;
m_bottom += br.m_bottom;
return *this;
}
const Border& Border::operator-=(const Border& br)
{
m_left -= br.m_left;
m_top -= br.m_top;
m_right -= br.m_right;
m_bottom -= br.m_bottom;
return *this;
}
const Border& Border::operator*=(const Border& br)
{
m_left *= br.m_left;
m_top *= br.m_top;
m_right *= br.m_right;
m_bottom *= br.m_bottom;
return *this;
}
const Border& Border::operator/=(const Border& br)
{
m_left /= br.m_left;
m_top /= br.m_top;
m_right /= br.m_right;
m_bottom /= br.m_bottom;
return *this;
}
const Border& Border::operator+=(int value)
{
m_left += value;
@ -60,6 +102,38 @@ const Border& Border::operator/=(int value)
return *this;
}
Border Border::operator+(const Border& br) const
{
return Border(m_left + br.left(),
m_top + br.top(),
m_right + br.right(),
m_bottom + br.bottom());
}
Border Border::operator-(const Border& br) const
{
return Border(m_left - br.left(),
m_top - br.top(),
m_right - br.right(),
m_bottom - br.bottom());
}
Border Border::operator*(const Border& br) const
{
return Border(m_left * br.left(),
m_top * br.top(),
m_right * br.right(),
m_bottom * br.bottom());
}
Border Border::operator/(const Border& br) const
{
return Border(m_left / br.left(),
m_top / br.top(),
m_right / br.right(),
m_bottom / br.bottom());
}
Border Border::operator+(int value) const
{
return Border(m_left + value,

View File

@ -9,6 +9,8 @@
namespace gfx {
class Size;
class Border
{
public:
@ -25,10 +27,20 @@ public:
void right(int right) { m_right = right; }
void bottom(int bottom) { m_bottom = bottom; }
Size getSize() const;
const Border& operator+=(const Border& br);
const Border& operator-=(const Border& br);
const Border& operator*=(const Border& br);
const Border& operator/=(const Border& br);
const Border& operator+=(int value);
const Border& operator-=(int value);
const Border& operator*=(int value);
const Border& operator/=(int value);
Border operator+(const Border& br) const;
Border operator-(const Border& br) const;
Border operator*(const Border& br) const;
Border operator/(const Border& br) const;
Border operator+(int value) const;
Border operator-(int value) const;
Border operator*(int value) const;