X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/14f355c2b5c71fc7c3d680aea366582d2ac60f7b..7dbe942aaaa9a8f32c9f901bdcf83d7941362b71:/src/mgl/region.cpp diff --git a/src/mgl/region.cpp b/src/mgl/region.cpp index b7ba0b5c09..bd1da90543 100644 --- a/src/mgl/region.cpp +++ b/src/mgl/region.cpp @@ -1,16 +1,12 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: region.cpp -// Purpose: Region handling for wxWindows/MGL +// Name: src/mgl/region.cpp +// Purpose: Region handling for wxWidgets/MGL // Author: Vaclav Slavik // RCS-ID: $Id$ // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com) // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma implementation "region.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -76,7 +72,7 @@ wxRegion::wxRegion() } wxRegion::wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h) -{ +{ m_refData = new wxRegionRefData; MGLRect rect(x, y, x + w, y + h); M_REGION = rect; @@ -130,7 +126,7 @@ void wxRegion::Clear() // Outer bounds of region void wxRegion::GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const { - if (m_refData) + if (m_refData) { rect_t rect; rect = M_REGION.getBounds(); @@ -138,8 +134,8 @@ void wxRegion::GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const y = rect.top; w = rect.right - rect.left; h = rect.bottom - rect.top; - } - else + } + else { x = y = w = h = 0; } @@ -155,8 +151,10 @@ wxRect wxRegion::GetBox() const // Is region empty? bool wxRegion::Empty() const { - if (!m_refData) return TRUE; - return M_REGION.isEmpty(); + if (!m_refData) + return true; + + return (bool)(M_REGION.isEmpty()); } //----------------------------------------------------------------------------- @@ -167,7 +165,7 @@ bool wxRegion::Offset(wxCoord x, wxCoord y) { AllocExclusive(); M_REGION.offset(x, y); - return TRUE; + return true; } // Union rectangle or region with this. @@ -175,14 +173,14 @@ bool wxRegion::Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { AllocExclusive(); M_REGION += MGLRect(x, y, x + width, y + height); - return TRUE; + return true; } bool wxRegion::Union(const wxRegion& region) { AllocExclusive(); M_REGION += M_REGION_OF(region); - return TRUE; + return true; } // Intersect rectangle or region with this. @@ -190,14 +188,14 @@ bool wxRegion::Intersect(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { AllocExclusive(); M_REGION &= MGLRect(x, y, x + width, y + height); - return TRUE; + return true; } bool wxRegion::Intersect(const wxRegion& region) { AllocExclusive(); M_REGION &= M_REGION_OF(region); - return TRUE; + return true; } // Subtract rectangle or region from this: @@ -206,14 +204,14 @@ bool wxRegion::Subtract(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { AllocExclusive(); M_REGION -= MGLRect(x, y, x + width, y + height); - return TRUE; + return true; } bool wxRegion::Subtract(const wxRegion& region) { AllocExclusive(); M_REGION -= M_REGION_OF(region); - return TRUE; + return true; } // XOR: the union of two combined regions except for any overlapping areas. @@ -224,7 +222,7 @@ bool wxRegion::Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height) MGLRegion rg1 = M_REGION + rect, rg2 = M_REGION & rect; M_REGION = rg1 - rg2; - return TRUE; + return true; } bool wxRegion::Xor(const wxRegion& region) @@ -233,7 +231,7 @@ bool wxRegion::Xor(const wxRegion& region) MGLRegion rg1 = M_REGION + M_REGION_OF(region), rg2 = M_REGION & M_REGION_OF(region); M_REGION = rg1 - rg2; - return TRUE; + return true; } @@ -267,11 +265,11 @@ wxRegionContain wxRegion::Contains(wxCoord x, wxCoord y, wxCoord w, wxCoord h) c MGLRect rect(x, y, x + w, y + h); MGLRegion rg; - + // 1) is the rectangle entirely covered by the region? rg = MGLRegion(rect) - M_REGION; if (rg.isEmpty()) return wxInRegion; - + // 2) is the rectangle completely outside the region? rg = M_REGION & rect; // intersection if (rg.isEmpty()) return wxOutRegion; @@ -300,7 +298,7 @@ public: virtual bool OnInit() { gs_mutexIterator = new wxMutex(); - return TRUE; + return true; } virtual void OnExit() { @@ -317,7 +315,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMglRegionModule, wxModule) */ wxRegionIterator::wxRegionIterator() : m_currentNode(NULL) { - m_rects.DeleteContents(TRUE); + m_rects.DeleteContents(true); } wxRegionIterator::~wxRegionIterator() @@ -329,23 +327,23 @@ wxRegionIterator::~wxRegionIterator() */ wxRegionIterator::wxRegionIterator(const wxRegion& region) { - m_rects.DeleteContents(TRUE); + m_rects.DeleteContents(true); Reset(region); } /* * Reset iterator for a new /e region. */ - + static wxRegionRectList *gs_rectList; static void MGLAPI wxMGL_region_callback(const rect_t *r) { - gs_rectList->Append(new wxRect(r->left, r->top, + gs_rectList->Append(new wxRect(r->left, r->top, r->right - r->left, r->bottom - r->top)); } - + void wxRegionIterator::Reset(const wxRegion& region) { m_currentNode = NULL; @@ -354,7 +352,7 @@ void wxRegionIterator::Reset(const wxRegion& region) if (!region.Empty()) { #if wxUSE_THREADS - wxMutexLocker(*gs_mutexIterator); + wxMutexLocker lock(*gs_mutexIterator); #endif gs_rectList = &m_rects; M_REGION_OF(region).traverse(wxMGL_region_callback);