diff --git a/include/wx/dc.h b/include/wx/dc.h index 38edf9da5f..cfc57cd1bd 100644 --- a/include/wx/dc.h +++ b/include/wx/dc.h @@ -1437,18 +1437,15 @@ class WXDLLIMPEXP_CORE wxDCClipper public: wxDCClipper(wxDC& dc, const wxRegion& r) : m_dc(dc) { - dc.GetClippingBox(m_oldClipRect); - dc.SetClippingRegion(r.GetBox()); + Init(r.GetBox()); } wxDCClipper(wxDC& dc, const wxRect& r) : m_dc(dc) { - dc.GetClippingBox(m_oldClipRect); - dc.SetClippingRegion(r.x, r.y, r.width, r.height); + Init(r); } wxDCClipper(wxDC& dc, wxCoord x, wxCoord y, wxCoord w, wxCoord h) : m_dc(dc) { - dc.GetClippingBox(m_oldClipRect); - dc.SetClippingRegion(x, y, w, h); + Init(wxRect(x, y, w, h)); } ~wxDCClipper() @@ -1459,6 +1456,13 @@ public: } private: + // Common part of all ctors. + void Init(const wxRect& r) + { + m_dc.GetClippingBox(m_oldClipRect); + m_dc.SetClippingRegion(r); + } + wxDC& m_dc; wxRect m_oldClipRect;