]> git.saurik.com Git - wxWidgets.git/commitdiff
implement * and / operators for wxPoint, not only wxSize.
authorFrancesco Montorsi <f18m_cpp217828@yahoo.it>
Sun, 30 May 2010 23:28:14 +0000 (23:28 +0000)
committerFrancesco Montorsi <f18m_cpp217828@yahoo.it>
Sun, 30 May 2010 23:28:14 +0000 (23:28 +0000)
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

include/wx/gdicmn.h
interface/wx/gdicmn.h

index 2d8685e25f2294b5e385850d43fdcb52ccff30aa..898dce7642766f72abede06cc29e4e38d80afe45 100644 (file)
@@ -493,6 +493,76 @@ inline wxPoint operator-(const wxPoint& p)
     return wxPoint(-p.x, -p.y);
 }
 
     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);
 
 // ---------------------------------------------------------------------------
 WX_DECLARE_LIST_WITH_DECL(wxPoint, wxPointList, class WXDLLIMPEXP_CORE);
 
 // ---------------------------------------------------------------------------
index 2c5d6a799455e4cc1a2c804cfd31a1a01f6464ae..192a6b6bd2d6cb3b8f99d47be9d9bb4c955da3b7 100644 (file)
@@ -500,6 +500,13 @@ public:
 
     /**
         @name Miscellaneous operators
 
     /**
         @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);
     */
     //@{
     wxPoint& operator=(const wxPoint& pt);
@@ -520,6 +527,12 @@ public:
 
     wxPoint& operator +=(const wxSize& sz);
     wxPoint& operator -=(const wxSize& sz);
 
     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
     
     /**
         @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);
     */
     //@{
     wxSize& operator=(const wxSize& sz);