From 45816ddded844f0bb76b8c44a0ccf429e1aa19f7 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Thu, 17 Feb 2000 14:06:00 +0000
Subject: [PATCH] added wxRect::Inflate()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6111 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 docs/latex/wx/rect.tex | 12 ++++++++++++
 include/wx/gdicmn.h    | 16 ++++++++++++----
 src/common/gdicmn.cpp  | 38 +++++++++++++++++++-------------------
 3 files changed, 43 insertions(+), 23 deletions(-)

diff --git a/docs/latex/wx/rect.tex b/docs/latex/wx/rect.tex
index 28e610f021..79b426e339 100644
--- a/docs/latex/wx/rect.tex
+++ b/docs/latex/wx/rect.tex
@@ -118,6 +118,18 @@ Gets the x member.
 
 Gets the y member.
 
+\membersection{wxRect::Inflate}\label{wxrectinflate}
+
+\func{void}{Inflate}{\param{wxCoord }{dx}, \param{wxCoord }{dy}}
+
+\func{void}{Inflate}{\param{wxCoord }{diff}}
+
+Increase the rectangle size by {\it dx} in x direction and {\it dy} in y
+direction. Both (or one of) parameters may be negative to decrease the
+rectngle size.
+
+The second form uses the same {\it diff} for both {\it dx} and {\it dy}.
+
 \membersection{wxRect::SetHeight}\label{wxrectsetheight}
 
 \func{void}{SetHeight}{\param{int}{ height}}
diff --git a/include/wx/gdicmn.h b/include/wx/gdicmn.h
index c392d75df6..5923c48fbf 100644
--- a/include/wx/gdicmn.h
+++ b/include/wx/gdicmn.h
@@ -285,8 +285,6 @@ public:
     wxPoint GetPosition() const { return wxPoint(x, y); }
     wxSize GetSize() const { return wxSize(width, height); }
 
-    // MFC-like functions
-
     int GetLeft()   const { return x; }
     int GetTop()    const { return y; }
     int GetBottom() const { return y + height - 1; }
@@ -297,12 +295,22 @@ public:
     void SetTop(int top) { y = top; }
     void SetBottom(int bottom) { height = bottom - y + 1; }
 
+    void Inflate(wxCoord dx, wxCoord dy)
+    {
+        x -= dx;
+        y -= dy;
+        width += 2*dx;
+        height += 2*dy;
+    }
+
+    void Inflate(wxCoord d) { Inflate(d, d); }
+
     bool operator==(const wxRect& rect) const;
     bool operator!=(const wxRect& rect) const { return !(*this == rect); }
 
     bool Inside(int cx, int cy) const;
-    wxRect operator + (const wxRect& rect) const;
-    const wxRect& operator += (const wxRect& rect);
+    wxRect operator+(const wxRect& rect) const;
+    wxRect& operator+=(const wxRect& rect);
 
 public:
     int x, y, width, height;
diff --git a/src/common/gdicmn.cpp b/src/common/gdicmn.cpp
index eb97decf64..472650c95c 100644
--- a/src/common/gdicmn.cpp
+++ b/src/common/gdicmn.cpp
@@ -50,14 +50,14 @@
 #endif
 #endif
 
-    IMPLEMENT_CLASS(wxColourDatabase, wxList)
-    IMPLEMENT_DYNAMIC_CLASS(wxFontList, wxList)
-    IMPLEMENT_DYNAMIC_CLASS(wxPenList, wxList)
-    IMPLEMENT_DYNAMIC_CLASS(wxBrushList, wxList)
-    IMPLEMENT_DYNAMIC_CLASS(wxBitmapList, wxList)
-    IMPLEMENT_DYNAMIC_CLASS(wxResourceCache, wxList)
+IMPLEMENT_CLASS(wxColourDatabase, wxList)
+IMPLEMENT_DYNAMIC_CLASS(wxFontList, wxList)
+IMPLEMENT_DYNAMIC_CLASS(wxPenList, wxList)
+IMPLEMENT_DYNAMIC_CLASS(wxBrushList, wxList)
+IMPLEMENT_DYNAMIC_CLASS(wxBitmapList, wxList)
+IMPLEMENT_DYNAMIC_CLASS(wxResourceCache, wxList)
 
-    IMPLEMENT_ABSTRACT_CLASS(wxDCBase, wxObject)
+IMPLEMENT_ABSTRACT_CLASS(wxDCBase, wxObject)
 
 wxRect::wxRect(const wxPoint& topLeft, const wxPoint& bottomRight)
 {
@@ -93,27 +93,27 @@ bool wxRect::operator==(const wxRect& rect) const
           (height == rect.height));
 }
 
-const wxRect& wxRect::operator += (const wxRect& rect)
+wxRect& wxRect::operator += (const wxRect& rect)
 {
-	*this = (*this + rect);
-	return ( *this ) ;
+    *this = (*this + rect);
+    return ( *this ) ;
 }
 
 wxRect wxRect::operator + (const wxRect& rect) const
 {
-	int x1 = wxMin(this->x, rect.x);
-	int y1 = wxMin(this->y, rect.y);
-	int y2 = wxMax(y+height, rect.height+rect.y);
-	int x2 = wxMax(x+width, rect.width+rect.x);
-	return wxRect(x1, y1, x2-x1, y2-y1);
+    int x1 = wxMin(this->x, rect.x);
+    int y1 = wxMin(this->y, rect.y);
+    int y2 = wxMax(y+height, rect.height+rect.y);
+    int x2 = wxMax(x+width, rect.width+rect.x);
+    return wxRect(x1, y1, x2-x1, y2-y1);
 }
 
 bool wxRect::Inside(int cx, int cy) const
 {
-	return ( (cx >= x) && (cy >= y)
-		  && ((cy - y) < height)
-		  && ((cx - x) < width)
-		  );
+    return ( (cx >= x) && (cy >= y)
+          && ((cy - y) < height)
+          && ((cx - x) < width)
+          );
 }
 
 wxColourDatabase::wxColourDatabase (int type) : wxList (type)
-- 
2.50.0

