X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4055ed8281971e3d35bf04177193c27043d42ed1..74ebd40690d3676e74a7cfc239eee6c7e9764f05:/src/common/gdicmn.cpp diff --git a/src/common/gdicmn.cpp b/src/common/gdicmn.cpp index 49df9a3f89..f2f3c71420 100644 --- a/src/common/gdicmn.cpp +++ b/src/common/gdicmn.cpp @@ -9,10 +9,6 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma implementation "gdicmn.h" -#endif - #ifdef __VMS #define XtDisplay XTDISPLAY #endif @@ -42,7 +38,7 @@ #include "wx/log.h" #include -#if defined(__WXMSW__) && !defined(__WXPALMOS__) +#if defined(__WXMSW__) #include "wx/msw/wrapwin.h" #endif @@ -163,23 +159,33 @@ wxRect& wxRect::Union(const wxRect& rect) wxRect& wxRect::Inflate(wxCoord dx, wxCoord dy) { - x -= dx; - y -= dy; - width += 2*dx; - height += 2*dy; - - // check that we didn't make the rectangle invalid by accident (you almost - // never want to have negative coords and never want negative size) - if ( x < 0 ) - x = 0; - if ( y < 0 ) - y = 0; - - // what else can we do? - if ( width < 0 ) - width = 0; - if ( height < 0 ) - height = 0; + if (-2*dx>width) + { + // Don't allow deflate to eat more width than we have, + // a well-defined rectangle cannot have negative width. + x+=width/2; + width=0; + } + else + { + // The inflate is valid. + x-=dx; + width+=2*dx; + } + + if (-2*dy>height) + { + // Don't allow deflate to eat more height than we have, + // a well-defined rectangle cannot have negative height. + y+=height/2; + height=0; + } + else + { + // The inflate is valid. + y-=dy; + height+=2*dy; + } return *this; }