From 11ebffe7b09d42ff62485d2304ffc20654616e38 Mon Sep 17 00:00:00 2001 From: David Miguel Susano Pinto Date: Wed, 3 Jan 2024 21:19:01 +0000 Subject: [PATCH] Add operator/(wxPoint, double) and operator/(wxRealPoint, double) Do this for consistency with wxSize which already had this operator/() overload and operator*() in these classes which was already overloaded for double. Closes #24185. Closes #24187. --- include/wx/gdicmn.h | 10 ++++++++++ interface/wx/gdicmn.h | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/include/wx/gdicmn.h b/include/wx/gdicmn.h index 30a54326c2..ae0287ac8d 100644 --- a/include/wx/gdicmn.h +++ b/include/wx/gdicmn.h @@ -564,6 +564,11 @@ inline wxRealPoint operator*(double i, const wxRealPoint& s) return wxRealPoint(s.x * i, s.y * i); } +inline wxRealPoint operator/(const wxRealPoint& p, double f) +{ + return wxRealPoint(p.x / f, p.y / f); +} + // ---------------------------------------------------------------------------- // wxPoint: 2D point with integer coordinates @@ -719,6 +724,11 @@ inline wxPoint operator*(double i, const wxPoint& s) return wxPoint(int(s.x * i), int(s.y * i)); } +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); // --------------------------------------------------------------------------- diff --git a/interface/wx/gdicmn.h b/interface/wx/gdicmn.h index 5f2a3b5c48..53fcc348dc 100644 --- a/interface/wx/gdicmn.h +++ b/interface/wx/gdicmn.h @@ -232,6 +232,8 @@ public: wxRealPoint operator *(int factor, const wxRealPoint& sz); wxRealPoint& operator /=(int factor); wxRealPoint& operator *=(int factor); + + wxRealPoint operator /(const wxRealPoint& pt, double factor); ///@} /** @@ -736,6 +738,8 @@ public: wxPoint operator *(int factor, const wxPoint& sz); wxPoint& operator /=(int factor); wxPoint& operator *=(int factor); + + wxPoint operator /(const wxPoint& pt, double factor); ///@}