X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/df83b840bbf6441a0166848d49a093557e562926..75b324211c094aea8373e3e6b7846e78b7befb89:/src/common/gdicmn.cpp?ds=sidebyside diff --git a/src/common/gdicmn.cpp b/src/common/gdicmn.cpp index a2c7cb5a8c..e2c0f65521 100644 --- a/src/common/gdicmn.cpp +++ b/src/common/gdicmn.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: gdicmn.cpp +// Name: src/common/gdicmn.cpp // Purpose: Common GDI classes // Author: Julian Smart // Modified by: @@ -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(__PALMOS__) +#if defined(__WXMSW__) #include "wx/msw/wrapwin.h" #endif @@ -138,8 +134,13 @@ wxRect wxRect::operator+(const wxRect& rect) const wxRect& wxRect::Union(const wxRect& rect) { - // ignore empty rectangles - if ( rect.width && rect.height ) + // ignore empty rectangles: union with an empty rectangle shouldn't extend + // this one to (0, 0) + if ( !width || !height ) + { + *this = rect; + } + else if ( rect.width && rect.height ) { int x1 = wxMin(x, rect.x); int y1 = wxMin(y, rect.y); @@ -151,29 +152,40 @@ wxRect& wxRect::Union(const wxRect& rect) width = x2 - x1; height = y2 - y1; } + //else: we're not empty and rect is empty return *this; } 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; } @@ -388,7 +400,7 @@ void wxColourDatabase::AddColour(const wxString& name, const wxColour& colour) } else // new colour { - (*m_map)[name] = new wxColour(colour); + (*m_map)[colName] = new wxColour(colour); } } @@ -476,6 +488,7 @@ wxString wxColourDatabase::FindName(const wxColour& colour) const // deprecated wxColourDatabase methods // ---------------------------------------------------------------------------- +#if WXWIN_COMPATIBILITY_2_6 wxColour *wxColourDatabase::FindColour(const wxString& name) { // This function is deprecated, use Find() instead. @@ -504,6 +517,7 @@ wxColour *wxColourDatabase::FindColour(const wxString& name) return new wxColour(s_col); } +#endif // WXWIN_COMPATIBILITY_2_6 // ============================================================================ // stock objects @@ -938,4 +952,3 @@ wxResourceCache::~wxResourceCache () node = node->GetNext (); } } -