From 9a5d2ffade725241564de22a849ca726a4689950 Mon Sep 17 00:00:00 2001 From: David Miguel Susano Pinto Date: Thu, 4 Jan 2024 00:19:35 +0000 Subject: [PATCH 1/8] Correct names of variables in wxPoint and wxRealPoint arithmetic operators. The arithmetic operators for wxPoint and wxRealPoint are quite repetitive and were made by copy-paste from the wxSize operators. Because of that, some of the names are a bit misleading which this commit changes. The changes are: 1. replace s/sz with p/pt for point variables (likely 's' comes from copied code used for wxSize variables) 2. replace 'i' with 'f' for floating point types (likely 'i' comes from copied code used for integer types) 3. replace 'factor' with 'divisor' for division operations (factors are the multiplication operands, not division) --- include/wx/gdicmn.h | 112 +++++++++++++++++++++--------------------- interface/wx/gdicmn.h | 14 +++--- 2 files changed, 63 insertions(+), 63 deletions(-) diff --git a/include/wx/gdicmn.h b/include/wx/gdicmn.h index ae0287ac8d..5467575e2c 100644 --- a/include/wx/gdicmn.h +++ b/include/wx/gdicmn.h @@ -494,74 +494,74 @@ inline wxRealPoint operator-(const wxRealPoint& p1, const wxRealPoint& p2) } -inline wxRealPoint operator/(const wxRealPoint& s, int i) +inline wxRealPoint operator/(const wxRealPoint& p, int i) { - return wxRealPoint(s.x / i, s.y / i); + return wxRealPoint(p.x / i, p.y / i); } -inline wxRealPoint operator*(const wxRealPoint& s, int i) +inline wxRealPoint operator*(const wxRealPoint& p, int i) { - return wxRealPoint(s.x * i, s.y * i); + return wxRealPoint(p.x * i, p.y * i); } -inline wxRealPoint operator*(int i, const wxRealPoint& s) +inline wxRealPoint operator*(int i, const wxRealPoint& p) { - return wxRealPoint(s.x * i, s.y * i); + return wxRealPoint(p.x * i, p.y * i); } -inline wxRealPoint operator/(const wxRealPoint& s, unsigned int i) +inline wxRealPoint operator/(const wxRealPoint& p, unsigned int i) { - return wxRealPoint(s.x / i, s.y / i); + return wxRealPoint(p.x / i, p.y / i); } -inline wxRealPoint operator*(const wxRealPoint& s, unsigned int i) +inline wxRealPoint operator*(const wxRealPoint& p, unsigned int i) { - return wxRealPoint(s.x * i, s.y * i); + return wxRealPoint(p.x * i, p.y * i); } -inline wxRealPoint operator*(unsigned int i, const wxRealPoint& s) +inline wxRealPoint operator*(unsigned int i, const wxRealPoint& p) { - return wxRealPoint(s.x * i, s.y * i); + return wxRealPoint(p.x * i, p.y * i); } -inline wxRealPoint operator/(const wxRealPoint& s, long i) +inline wxRealPoint operator/(const wxRealPoint& p, long i) { - return wxRealPoint(s.x / i, s.y / i); + return wxRealPoint(p.x / i, p.y / i); } -inline wxRealPoint operator*(const wxRealPoint& s, long i) +inline wxRealPoint operator*(const wxRealPoint& p, long i) { - return wxRealPoint(s.x * i, s.y * i); + return wxRealPoint(p.x * i, p.y * i); } -inline wxRealPoint operator*(long i, const wxRealPoint& s) +inline wxRealPoint operator*(long i, const wxRealPoint& p) { - return wxRealPoint(s.x * i, s.y * i); + return wxRealPoint(p.x * i, p.y * i); } -inline wxRealPoint operator/(const wxRealPoint& s, unsigned long i) +inline wxRealPoint operator/(const wxRealPoint& p, unsigned long i) { - return wxRealPoint(s.x / i, s.y / i); + return wxRealPoint(p.x / i, p.y / i); } -inline wxRealPoint operator*(const wxRealPoint& s, unsigned long i) +inline wxRealPoint operator*(const wxRealPoint& p, unsigned long i) { - return wxRealPoint(s.x * i, s.y * i); + return wxRealPoint(p.x * i, p.y * i); } -inline wxRealPoint operator*(unsigned long i, const wxRealPoint& s) +inline wxRealPoint operator*(unsigned long i, const wxRealPoint& p) { - return wxRealPoint(s.x * i, s.y * i); + return wxRealPoint(p.x * i, p.y * i); } -inline wxRealPoint operator*(const wxRealPoint& s, double i) +inline wxRealPoint operator*(const wxRealPoint& p, double f) { - return wxRealPoint(s.x * i, s.y * i); + return wxRealPoint(p.x * f, p.y * f); } -inline wxRealPoint operator*(double i, const wxRealPoint& s) +inline wxRealPoint operator*(double f, const wxRealPoint& p) { - return wxRealPoint(s.x * i, s.y * i); + return wxRealPoint(p.x * f, p.y * f); } inline wxRealPoint operator/(const wxRealPoint& p, double f) @@ -654,74 +654,74 @@ inline wxPoint operator-(const wxPoint& p) return wxPoint(-p.x, -p.y); } -inline wxPoint operator/(const wxPoint& s, int i) +inline wxPoint operator/(const wxPoint& p, int i) { - return wxPoint(s.x / i, s.y / i); + return wxPoint(p.x / i, p.y / i); } -inline wxPoint operator*(const wxPoint& s, int i) +inline wxPoint operator*(const wxPoint& p, int i) { - return wxPoint(s.x * i, s.y * i); + return wxPoint(p.x * i, p.y * i); } -inline wxPoint operator*(int i, const wxPoint& s) +inline wxPoint operator*(int i, const wxPoint& p) { - return wxPoint(s.x * i, s.y * i); + return wxPoint(p.x * i, p.y * i); } -inline wxPoint operator/(const wxPoint& s, unsigned int i) +inline wxPoint operator/(const wxPoint& p, unsigned int i) { - return wxPoint(s.x / i, s.y / i); + return wxPoint(p.x / i, p.y / i); } -inline wxPoint operator*(const wxPoint& s, unsigned int i) +inline wxPoint operator*(const wxPoint& p, unsigned int i) { - return wxPoint(s.x * i, s.y * i); + return wxPoint(p.x * i, p.y * i); } -inline wxPoint operator*(unsigned int i, const wxPoint& s) +inline wxPoint operator*(unsigned int i, const wxPoint& p) { - return wxPoint(s.x * i, s.y * i); + return wxPoint(p.x * i, p.y * i); } -inline wxPoint operator/(const wxPoint& s, long i) +inline wxPoint operator/(const wxPoint& p, long i) { - return wxPoint(s.x / i, s.y / i); + return wxPoint(p.x / i, p.y / i); } -inline wxPoint operator*(const wxPoint& s, long i) +inline wxPoint operator*(const wxPoint& p, long i) { - return wxPoint(int(s.x * i), int(s.y * i)); + return wxPoint(int(p.x * i), int(p.y * i)); } -inline wxPoint operator*(long i, const wxPoint& s) +inline wxPoint operator*(long i, const wxPoint& p) { - return wxPoint(int(s.x * i), int(s.y * i)); + return wxPoint(int(p.x * i), int(p.y * i)); } -inline wxPoint operator/(const wxPoint& s, unsigned long i) +inline wxPoint operator/(const wxPoint& p, unsigned long i) { - return wxPoint(s.x / i, s.y / i); + return wxPoint(p.x / i, p.y / i); } -inline wxPoint operator*(const wxPoint& s, unsigned long i) +inline wxPoint operator*(const wxPoint& p, unsigned long i) { - return wxPoint(int(s.x * i), int(s.y * i)); + return wxPoint(int(p.x * i), int(p.y * i)); } -inline wxPoint operator*(unsigned long i, const wxPoint& s) +inline wxPoint operator*(unsigned long i, const wxPoint& p) { - return wxPoint(int(s.x * i), int(s.y * i)); + return wxPoint(int(p.x * i), int(p.y * i)); } -inline wxPoint operator*(const wxPoint& s, double i) +inline wxPoint operator*(const wxPoint& p, double f) { - return wxPoint(int(s.x * i), int(s.y * i)); + return wxPoint(int(p.x * f), int(p.y * f)); } -inline wxPoint operator*(double i, const wxPoint& s) +inline wxPoint operator*(double f, const wxPoint& p) { - return wxPoint(int(s.x * i), int(s.y * i)); + return wxPoint(int(p.x * f), int(p.y * f)); } inline wxPoint operator/(const wxPoint& p, double f) diff --git a/interface/wx/gdicmn.h b/interface/wx/gdicmn.h index 53fcc348dc..9305d54a31 100644 --- a/interface/wx/gdicmn.h +++ b/interface/wx/gdicmn.h @@ -227,13 +227,13 @@ public: wxRealPoint& operator +=(const wxSize& sz); wxRealPoint& operator -=(const wxSize& sz); - wxRealPoint operator /(const wxRealPoint& sz, int factor); + wxRealPoint operator /(const wxRealPoint& sz, int divisor); wxRealPoint operator *(const wxRealPoint& sz, int factor); - wxRealPoint operator *(int factor, const wxRealPoint& sz); - wxRealPoint& operator /=(int factor); + wxRealPoint operator *(int factor, const wxRealPoint& pt); + wxRealPoint& operator /=(int divisor); wxRealPoint& operator *=(int factor); - wxRealPoint operator /(const wxRealPoint& pt, double factor); + wxRealPoint operator /(const wxRealPoint& pt, double divisor); ///@} /** @@ -733,13 +733,13 @@ public: wxPoint& operator +=(const wxSize& sz); wxPoint& operator -=(const wxSize& sz); - wxPoint operator /(const wxPoint& sz, int factor); + wxPoint operator /(const wxPoint& sz, int divisor); wxPoint operator *(const wxPoint& sz, int factor); wxPoint operator *(int factor, const wxPoint& sz); - wxPoint& operator /=(int factor); + wxPoint& operator /=(int divisor); wxPoint& operator *=(int factor); - wxPoint operator /(const wxPoint& pt, double factor); + wxPoint operator /(const wxPoint& pt, double divisor); ///@} From 8ccbd7e95df96f836f3b539250f78a27c5d244aa Mon Sep 17 00:00:00 2001 From: David Miguel Susano Pinto Date: Thu, 4 Jan 2024 01:16:48 +0000 Subject: [PATCH 2/8] Implement operator/=(int) and operator*=(int) for wxPoint and wxRealPoint. These operators are part of the documented interface but were never implemented. This commit implements them. --- include/wx/gdicmn.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/wx/gdicmn.h b/include/wx/gdicmn.h index 5467575e2c..6c8ac67ce4 100644 --- a/include/wx/gdicmn.h +++ b/include/wx/gdicmn.h @@ -469,6 +469,9 @@ public: wxRealPoint& operator+=(const wxSize& s) { x += s.GetWidth(); y += s.GetHeight(); return *this; } wxRealPoint& operator-=(const wxSize& s) { x -= s.GetWidth(); y -= s.GetHeight(); return *this; } + + wxRealPoint& operator/=(int i) { x *= i; y *= i; return *this; } + wxRealPoint& operator*=(int i) { x /= i; y /= i; return *this; } }; @@ -592,6 +595,9 @@ public: wxPoint& operator+=(const wxSize& s) { x += s.GetWidth(); y += s.GetHeight(); return *this; } wxPoint& operator-=(const wxSize& s) { x -= s.GetWidth(); y -= s.GetHeight(); return *this; } + wxPoint& operator/=(int i) { x /= i, y /= i; return *this; } + wxPoint& operator*=(int i) { x *= i, y *= i; return *this; } + // check if both components are set/initialized bool IsFullySpecified() const { return x != wxDefaultCoord && y != wxDefaultCoord; } From 66e7d0bce86f214ca8d880c68f311345c8cc46c2 Mon Sep 17 00:00:00 2001 From: David Miguel Susano Pinto Date: Thu, 4 Jan 2024 01:19:09 +0000 Subject: [PATCH 3/8] Implement + and - between wxRealPoint and wxSize. These operators are part of the documented interface for wxRealPoint but were never implemented. This commit implements them. --- include/wx/gdicmn.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/include/wx/gdicmn.h b/include/wx/gdicmn.h index 6c8ac67ce4..6f5d3b6ef8 100644 --- a/include/wx/gdicmn.h +++ b/include/wx/gdicmn.h @@ -490,12 +490,30 @@ inline wxRealPoint operator+(const wxRealPoint& p1, const wxRealPoint& p2) return wxRealPoint(p1.x + p2.x, p1.y + p2.y); } - inline wxRealPoint operator-(const wxRealPoint& p1, const wxRealPoint& p2) { return wxRealPoint(p1.x - p2.x, p1.y - p2.y); } +inline wxRealPoint operator+(const wxRealPoint& pt, const wxSize& sz) +{ + return wxRealPoint(pt.x + sz.GetWidth(), pt.y + sz.GetHeight()); +} + +inline wxRealPoint operator-(const wxRealPoint& pt, const wxSize& sz) +{ + return wxRealPoint(pt.x - sz.GetWidth(), pt.y - sz.GetHeight()); +} + +inline wxRealPoint operator+(const wxSize& sz, const wxRealPoint& pt) +{ + return wxRealPoint(sz.GetWidth() + pt.x, sz.GetHeight() + pt.y); +} + +inline wxRealPoint operator-(const wxSize& sz, const wxRealPoint& pt) +{ + return wxRealPoint(sz.GetWidth() - pt.x, sz.GetHeight() - pt.y); +} inline wxRealPoint operator/(const wxRealPoint& p, int i) { From 8638db50dae4d057765c9314bb1da27dcefc30f4 Mon Sep 17 00:00:00 2001 From: David Miguel Susano Pinto Date: Thu, 4 Jan 2024 01:21:47 +0000 Subject: [PATCH 4/8] Document a series of undocumented wxPoint and wxRealPoint operators. Unary minus of wxPoint and multiplication with double are implemented but undocumented. Many of operators that use integers types other than int remain undocumented though. --- interface/wx/gdicmn.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/interface/wx/gdicmn.h b/interface/wx/gdicmn.h index 9305d54a31..f5bacacbce 100644 --- a/interface/wx/gdicmn.h +++ b/interface/wx/gdicmn.h @@ -233,6 +233,8 @@ public: wxRealPoint& operator /=(int divisor); wxRealPoint& operator *=(int factor); + wxRealPoint operator *(const wxRealPoint& pt, double factor); + wxRealPoint operator *(double factor, const wxRealPoint& pt); wxRealPoint operator /(const wxRealPoint& pt, double divisor); ///@} @@ -733,6 +735,8 @@ public: wxPoint& operator +=(const wxSize& sz); wxPoint& operator -=(const wxSize& sz); + wxPoint operator -(const wxPoint& pt); + wxPoint operator /(const wxPoint& sz, int divisor); wxPoint operator *(const wxPoint& sz, int factor); wxPoint operator *(int factor, const wxPoint& sz); @@ -740,6 +744,8 @@ public: wxPoint& operator *=(int factor); wxPoint operator /(const wxPoint& pt, double divisor); + wxPoint operator *(const wxPoint& pt, double factor); + wxPoint operator *(double factor, const wxPoint& pt); ///@} From b9b0cce41b61c8429b1ed75dc058be53462cc538 Mon Sep 17 00:00:00 2001 From: David Miguel Susano Pinto Date: Thu, 4 Jan 2024 01:25:12 +0000 Subject: [PATCH 5/8] include/wx/gdicmn.h: reorder to match the order in interface/wx/gdicmn.h. --- include/wx/gdicmn.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/wx/gdicmn.h b/include/wx/gdicmn.h index 6f5d3b6ef8..6ce7a2d8af 100644 --- a/include/wx/gdicmn.h +++ b/include/wx/gdicmn.h @@ -738,6 +738,11 @@ inline wxPoint operator*(unsigned long i, const wxPoint& p) return wxPoint(int(p.x * i), int(p.y * i)); } +inline wxPoint operator/(const wxPoint& p, double f) +{ + return wxPoint(wxRound(p.x / f), wxRound(p.y / f)); +} + inline wxPoint operator*(const wxPoint& p, double f) { return wxPoint(int(p.x * f), int(p.y * f)); @@ -748,11 +753,6 @@ inline wxPoint operator*(double f, const wxPoint& p) return wxPoint(int(p.x * f), int(p.y * f)); } -inline wxPoint operator/(const wxPoint& p, double f) -{ - return wxPoint(wxRound(p.x / f), wxRound(p.y / f)); -} - WX_DECLARE_LIST_WITH_DECL(wxPoint, wxPointList, class WXDLLIMPEXP_CORE); // --------------------------------------------------------------------------- From 11c3034177c64c33f65dc1833e37f00705e59ace Mon Sep 17 00:00:00 2001 From: David Miguel Susano Pinto Date: Thu, 4 Jan 2024 01:29:40 +0000 Subject: [PATCH 6/8] Implement unary minus for wxRealPoint, same as wxPoint. --- include/wx/gdicmn.h | 5 +++++ interface/wx/gdicmn.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/include/wx/gdicmn.h b/include/wx/gdicmn.h index 6ce7a2d8af..b67f34dbd7 100644 --- a/include/wx/gdicmn.h +++ b/include/wx/gdicmn.h @@ -515,6 +515,11 @@ inline wxRealPoint operator-(const wxSize& sz, const wxRealPoint& pt) return wxRealPoint(sz.GetWidth() - pt.x, sz.GetHeight() - pt.y); } +inline wxRealPoint operator-(const wxRealPoint& pt) +{ + return wxRealPoint(-pt.x, -pt.y); +} + inline wxRealPoint operator/(const wxRealPoint& p, int i) { return wxRealPoint(p.x / i, p.y / i); diff --git a/interface/wx/gdicmn.h b/interface/wx/gdicmn.h index f5bacacbce..83cbe5289f 100644 --- a/interface/wx/gdicmn.h +++ b/interface/wx/gdicmn.h @@ -227,6 +227,8 @@ public: wxRealPoint& operator +=(const wxSize& sz); wxRealPoint& operator -=(const wxSize& sz); + wxRealPoint operator -(const wxRealPoint& pt); + wxRealPoint operator /(const wxRealPoint& sz, int divisor); wxRealPoint operator *(const wxRealPoint& sz, int factor); wxRealPoint operator *(int factor, const wxRealPoint& pt); From 1300c56f0d823e484bbe52d20533895a708d7b6b Mon Sep 17 00:00:00 2001 From: David Miguel Susano Pinto Date: Thu, 4 Jan 2024 01:30:17 +0000 Subject: [PATCH 7/8] Put wxRealPoint operators in the same order as wxPoint ones --- include/wx/gdicmn.h | 10 +++++----- interface/wx/gdicmn.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/wx/gdicmn.h b/include/wx/gdicmn.h index b67f34dbd7..d6615235d5 100644 --- a/include/wx/gdicmn.h +++ b/include/wx/gdicmn.h @@ -580,6 +580,11 @@ inline wxRealPoint operator*(unsigned long i, const wxRealPoint& p) return wxRealPoint(p.x * i, p.y * i); } +inline wxRealPoint operator/(const wxRealPoint& p, double f) +{ + return wxRealPoint(p.x / f, p.y / f); +} + inline wxRealPoint operator*(const wxRealPoint& p, double f) { return wxRealPoint(p.x * f, p.y * f); @@ -590,11 +595,6 @@ inline wxRealPoint operator*(double f, const wxRealPoint& p) return wxRealPoint(p.x * f, p.y * f); } -inline wxRealPoint operator/(const wxRealPoint& p, double f) -{ - return wxRealPoint(p.x / f, p.y / f); -} - // ---------------------------------------------------------------------------- // wxPoint: 2D point with integer coordinates diff --git a/interface/wx/gdicmn.h b/interface/wx/gdicmn.h index 83cbe5289f..09c29b2791 100644 --- a/interface/wx/gdicmn.h +++ b/interface/wx/gdicmn.h @@ -235,9 +235,9 @@ public: wxRealPoint& operator /=(int divisor); wxRealPoint& operator *=(int factor); + wxRealPoint operator /(const wxRealPoint& pt, double divisor); wxRealPoint operator *(const wxRealPoint& pt, double factor); wxRealPoint operator *(double factor, const wxRealPoint& pt); - wxRealPoint operator /(const wxRealPoint& pt, double divisor); ///@} /** From 68bef2fbf3d120305ba48438671d679f6238db2c Mon Sep 17 00:00:00 2001 From: David Miguel Susano Pinto Date: Thu, 4 Jan 2024 02:08:41 +0000 Subject: [PATCH 8/8] Add compound operators * and / to wxPoint and wxRealPoint Also add unit tests for them as well as for the existing additive compound operators. --- include/wx/gdicmn.h | 4 ++++ interface/wx/gdicmn.h | 4 ++++ tests/geometry/point.cpp | 44 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) diff --git a/include/wx/gdicmn.h b/include/wx/gdicmn.h index d6615235d5..555ee6985a 100644 --- a/include/wx/gdicmn.h +++ b/include/wx/gdicmn.h @@ -472,6 +472,8 @@ public: wxRealPoint& operator/=(int i) { x *= i; y *= i; return *this; } wxRealPoint& operator*=(int i) { x /= i; y /= i; return *this; } + wxRealPoint& operator/=(double f) { x /= f; y /= f; return *this; } + wxRealPoint& operator*=(double f) { x *= f; y *= f; return *this; } }; @@ -620,6 +622,8 @@ public: wxPoint& operator/=(int i) { x /= i, y /= i; return *this; } wxPoint& operator*=(int i) { x *= i, y *= i; return *this; } + wxPoint& operator/=(double f) { x = wxRound(x/f); y = wxRound(y/f); return *this; } + wxPoint& operator*=(double f) { x = wxRound(x*f); y = wxRound(y*f); return *this; } // check if both components are set/initialized bool IsFullySpecified() const { return x != wxDefaultCoord && y != wxDefaultCoord; } diff --git a/interface/wx/gdicmn.h b/interface/wx/gdicmn.h index 09c29b2791..12105288c2 100644 --- a/interface/wx/gdicmn.h +++ b/interface/wx/gdicmn.h @@ -238,6 +238,8 @@ public: wxRealPoint operator /(const wxRealPoint& pt, double divisor); wxRealPoint operator *(const wxRealPoint& pt, double factor); wxRealPoint operator *(double factor, const wxRealPoint& pt); + wxRealPoint& operator /=(double divisor); + wxRealPoint& operator *=(double factor); ///@} /** @@ -748,6 +750,8 @@ public: wxPoint operator /(const wxPoint& pt, double divisor); wxPoint operator *(const wxPoint& pt, double factor); wxPoint operator *(double factor, const wxPoint& pt); + wxPoint& operator /=(double divisor); + wxPoint& operator *=(double factor); ///@} diff --git a/tests/geometry/point.cpp b/tests/geometry/point.cpp index aaf2867bd2..2f0dea08ff 100644 --- a/tests/geometry/point.cpp +++ b/tests/geometry/point.cpp @@ -51,6 +51,31 @@ TEST_CASE("wxPoint::Operators", "[point]") p6 = p2; p6 -= s; CHECK( p3 == p5 ); CHECK( p4 == p6 ); + + // Test arithmetic compound assignment operators with scalars + wxPoint p7(3, 5); + p7 /= 2; // chosen to check results truncate + CHECK( p7.x == 1 ); + CHECK( p7.y == 2 ); + p7 *= 2; + CHECK( p7.x == 2 ); + CHECK( p7.y == 4 ); + p7 *= 3.2; // chosen so that x and y rounds down and up respectively + CHECK( p7.x == 6 ); + CHECK( p7.y == 13 ); + p7 /= 1.1; // chosen so that x and y rounds up and down respectively + CHECK( p7.x == 5 ); + CHECK( p7.y == 12 ); + + // Test arithmetic compound assignment operators with wxSizes + wxSize s1(2, 3); + p7 += s1; + CHECK( p7.x == 7 ); + CHECK( p7.y == 15 ); + wxSize s2(3, 4); + p7 -= s2; + CHECK( p7.x == 4 ); + CHECK( p7.y == 11 ); } TEST_CASE("wxRealPoint::Operators", "[point]") @@ -66,4 +91,23 @@ TEST_CASE("wxRealPoint::Operators", "[point]") CHECK( p4.x == Approx(p6.x) ); CHECK( p4.y == Approx(p6.y) ); CHECK( p3.x != Approx(p4.x) ); + + // Test arithmetic compound assignment operators with scalars + wxRealPoint p7(3.0, 5.0); + p7 /= 2.0; + CHECK( p7.x == Approx(1.5) ); + CHECK( p7.y == Approx(2.5) ); + p7 *= 3.0; + CHECK( p7.x == Approx(4.5) ); + CHECK( p7.y == Approx(7.5) ); + + // Test arithmetic compound assignment operators with wxSizes + wxSize s1(2, 3); + p7 += s1; + CHECK( p7.x == Approx(6.5) ); + CHECK( p7.y == Approx(10.5) ); + wxSize s2(3, 4); + p7 -= s2; + CHECK( p7.x == Approx(3.5) ); + CHECK( p7.y == Approx(6.5) ); }