implement * and / operators for wxPoint, not only wxSize.

Add to their documentation a note about the fact that the real operators are not class members but rather global functions.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64444 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Francesco Montorsi
2010-05-30 23:28:14 +00:00
parent f68e16c5fc
commit ed0dd9c1f0
2 changed files with 90 additions and 0 deletions

View File

@@ -493,6 +493,76 @@ inline wxPoint operator-(const wxPoint& p)
return wxPoint(-p.x, -p.y);
}
inline wxPoint operator/(const wxPoint& s, int i)
{
return wxPoint(s.x / i, s.y / i);
}
inline wxPoint operator*(const wxPoint& s, int i)
{
return wxPoint(s.x * i, s.y * i);
}
inline wxPoint operator*(int i, const wxPoint& s)
{
return wxPoint(s.x * i, s.y * i);
}
inline wxPoint operator/(const wxPoint& s, unsigned int i)
{
return wxPoint(s.x / i, s.y / i);
}
inline wxPoint operator*(const wxPoint& s, unsigned int i)
{
return wxPoint(s.x * i, s.y * i);
}
inline wxPoint operator*(unsigned int i, const wxPoint& s)
{
return wxPoint(s.x * i, s.y * i);
}
inline wxPoint operator/(const wxPoint& s, long i)
{
return wxPoint(s.x / i, s.y / i);
}
inline wxPoint operator*(const wxPoint& s, long i)
{
return wxPoint(s.x * i, s.y * i);
}
inline wxPoint operator*(long i, const wxPoint& s)
{
return wxPoint(s.x * i, s.y * i);
}
inline wxPoint operator/(const wxPoint& s, unsigned long i)
{
return wxPoint(s.x / i, s.y / i);
}
inline wxPoint operator*(const wxPoint& s, unsigned long i)
{
return wxPoint(s.x * i, s.y * i);
}
inline wxPoint operator*(unsigned long i, const wxPoint& s)
{
return wxPoint(s.x * i, s.y * i);
}
inline wxPoint operator*(const wxPoint& s, double i)
{
return wxPoint(int(s.x * i), int(s.y * i));
}
inline wxPoint operator*(double i, const wxPoint& s)
{
return wxPoint(int(s.x * i), int(s.y * i));
}
WX_DECLARE_LIST_WITH_DECL(wxPoint, wxPointList, class WXDLLIMPEXP_CORE);
// ---------------------------------------------------------------------------

View File

@@ -500,6 +500,13 @@ public:
/**
@name Miscellaneous operators
Note that these operators are documented as class members
(to make them easier to find) but, as their prototype shows,
they are implemented as global operators; note that this is
transparent to the user but it helps to understand why the
following functions are documented to take the wxPoint they
operate on as an explicit argument.
*/
//@{
wxPoint& operator=(const wxPoint& pt);
@@ -520,6 +527,12 @@ public:
wxPoint& operator +=(const wxSize& sz);
wxPoint& operator -=(const wxSize& sz);
wxSize operator /(const wxPoint& sz, int factor);
wxSize operator *(const wxPoint& sz, int factor);
wxSize operator *(int factor, const wxSize& sz);
wxSize& operator /=(int factor);
wxSize& operator *=(int factor);
//@}
/**
@@ -806,6 +819,13 @@ public:
/**
@name Miscellaneous operators
Note that these operators are documented as class members
(to make them easier to find) but, as their prototype shows,
they are implemented as global operators; note that this is
transparent to the user but it helps to understand why the
following functions are documented to take the wxSize they
operate on as an explicit argument.
*/
//@{
wxSize& operator=(const wxSize& sz);