X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/77ffb5937e89927b621128789401db8921fe580f..b5aaf62e977b828214d65c3712478410fb2c8a05:/src/msw/region.cpp diff --git a/src/msw/region.cpp b/src/msw/region.cpp index 424ed9fb89..73d983df89 100644 --- a/src/msw/region.cpp +++ b/src/msw/region.cpp @@ -1,12 +1,12 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: msw/region.cpp +// Name: src/msw/region.cpp // Purpose: wxRegion implementation using Win32 API // Author: Vadim Zeitlin // Modified by: // Created: Fri Oct 24 10:46:34 MET 1997 // RCS-ID: $Id$ // Copyright: (c) 1997-2002 wxWidgets team -// Licence: wxWidgets licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -17,19 +17,18 @@ // headers // ---------------------------------------------------------------------------- -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) - #pragma implementation "region.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" #ifdef __BORLANDC__ -#pragma hdrstop + #pragma hdrstop #endif #include "wx/region.h" -#include "wx/gdicmn.h" + +#ifndef WX_PRECOMP + #include "wx/gdicmn.h" +#endif #include "wx/msw/private.h" @@ -48,7 +47,7 @@ public: m_region = 0; } - wxRegionRefData(const wxRegionRefData& data) + wxRegionRefData(const wxRegionRefData& data) : wxGDIRefData() { #if defined(__WIN32__) && !defined(__WXMICROWIN__) && !defined(__WXWINCE__) DWORD noBytes = ::GetRegionData(data.m_region, 0, NULL); @@ -73,7 +72,7 @@ public: private: // Cannot use -// DECLARE_NO_COPY_CLASS(wxRegionRefData) +// wxDECLARE_NO_COPY_CLASS(wxRegionRefData); // because copy constructor is explicitly declared above; // but no copy assignment operator is defined, so declare // it private to prevent the compiler from defining it: @@ -93,7 +92,7 @@ private: wxRegion::wxRegion() { - m_refData = (wxRegionRefData *)NULL; + m_refData = NULL; } wxRegion::wxRegion(WXHRGN hRegion) @@ -120,9 +119,12 @@ wxRegion::wxRegion(const wxRect& rect) M_REGION = ::CreateRectRgn(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height); } -wxRegion::wxRegion(size_t n, const wxPoint *points, int fillStyle) +wxRegion::wxRegion(size_t n, const wxPoint *points, wxPolygonFillMode fillStyle) { #if defined(__WXMICROWIN__) || defined(__WXWINCE__) + wxUnusedVar(n); + wxUnusedVar(points); + wxUnusedVar(fillStyle); m_refData = NULL; M_REGION = NULL; #else @@ -141,12 +143,12 @@ wxRegion::~wxRegion() // m_refData unrefed in ~wxObject } -wxObjectRefData *wxRegion::CreateRefData() const +wxGDIRefData *wxRegion::CreateGDIRefData() const { return new wxRegionRefData; } -wxObjectRefData *wxRegion::CloneRefData(const wxObjectRefData *data) const +wxGDIRefData *wxRegion::CloneGDIRefData(const wxGDIRefData *data) const { return new wxRegionRefData(*(wxRegionRefData *)data); } @@ -161,30 +163,30 @@ void wxRegion::Clear() UnRef(); } -bool wxRegion::Offset(wxCoord x, wxCoord y) +bool wxRegion::DoOffset(wxCoord x, wxCoord y) { - wxCHECK_MSG( M_REGION, FALSE, _T("invalid wxRegion") ); + wxCHECK_MSG( M_REGION, false, wxT("invalid wxRegion") ); if ( !x && !y ) { // nothing to do - return TRUE; + return true; } AllocExclusive(); if ( ::OffsetRgn(GetHrgn(), x, y) == ERROR ) { - wxLogLastError(_T("OffsetRgn")); + wxLogLastError(wxT("OffsetRgn")); - return FALSE; + return false; } - return TRUE; + return true; } // combine another region with this one -bool wxRegion::Combine(const wxRegion& rgn, wxRegionOp op) +bool wxRegion::DoCombine(const wxRegion& rgn, wxRegionOp op) { // we can't use the API functions if we don't have a valid region handle if ( !m_refData ) @@ -200,13 +202,13 @@ bool wxRegion::Combine(const wxRegion& rgn, wxRegionOp op) break; default: - wxFAIL_MSG( _T("unknown region operation") ); + wxFAIL_MSG( wxT("unknown region operation") ); // fall through case wxRGN_AND: case wxRGN_DIFF: // leave empty/invalid - return FALSE; + return false; } } else // we have a valid region @@ -233,7 +235,7 @@ bool wxRegion::Combine(const wxRegion& rgn, wxRegionOp op) break; default: - wxFAIL_MSG( _T("unknown region operation") ); + wxFAIL_MSG( wxT("unknown region operation") ); // fall through case wxRGN_COPY: @@ -243,27 +245,13 @@ bool wxRegion::Combine(const wxRegion& rgn, wxRegionOp op) if ( ::CombineRgn(M_REGION, M_REGION, M_REGION_OF(rgn), mode) == ERROR ) { - wxLogLastError(_T("CombineRgn")); + wxLogLastError(wxT("CombineRgn")); - return FALSE; + return false; } } - return TRUE; -} - -// Combine rectangle (x, y, w, h) with this. -bool wxRegion::Combine(wxCoord x, wxCoord y, - wxCoord width, wxCoord height, - wxRegionOp op) -{ - return Combine(wxRegion(x, y, width, height), op); -} - -bool wxRegion::Combine(const wxRect& rect, wxRegionOp op) -{ - return Combine(rect.GetLeft(), rect.GetTop(), - rect.GetWidth(), rect.GetHeight(), op); + return true; } // ---------------------------------------------------------------------------- @@ -271,7 +259,7 @@ bool wxRegion::Combine(const wxRect& rect, wxRegionOp op) // ---------------------------------------------------------------------------- // Outer bounds of region -void wxRegion::GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const +bool wxRegion::DoGetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const { if (m_refData) { @@ -281,22 +269,19 @@ 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; + + return true; } else { x = y = w = h = 0; - } -} -wxRect wxRegion::GetBox() const -{ - wxCoord x, y, w, h; - GetBox(x, y, w, h); - return wxRect(x, y, w, h); + return false; + } } // Is region empty? -bool wxRegion::Empty() const +bool wxRegion::IsEmpty() const { wxCoord x, y, w, h; GetBox(x, y, w, h); @@ -304,12 +289,17 @@ bool wxRegion::Empty() const return (w == 0) && (h == 0); } +bool wxRegion::DoIsEqual(const wxRegion& region) const +{ + return ::EqualRgn(M_REGION, M_REGION_OF(region)) != 0; +} + // ---------------------------------------------------------------------------- // wxRegion hit testing // ---------------------------------------------------------------------------- // Does the region contain the point (x,y)? -wxRegionContain wxRegion::Contains(wxCoord x, wxCoord y) const +wxRegionContain wxRegion::DoContainsPoint(wxCoord x, wxCoord y) const { if (!m_refData) return wxOutRegion; @@ -317,32 +307,16 @@ wxRegionContain wxRegion::Contains(wxCoord x, wxCoord y) const return ::PtInRegion(M_REGION, (int) x, (int) y) ? wxInRegion : wxOutRegion; } -// Does the region contain the point pt? -wxRegionContain wxRegion::Contains(const wxPoint& pt) const -{ - return Contains(pt.x, pt.y); -} - // Does the region contain the rectangle (x, y, w, h)? -wxRegionContain wxRegion::Contains(wxCoord x, wxCoord y, - wxCoord w, wxCoord h) const +wxRegionContain wxRegion::DoContainsRect(const wxRect& rect) const { if (!m_refData) return wxOutRegion; - RECT rect; - rect.left = x; - rect.top = y; - rect.right = x + w; - rect.bottom = y + h; + RECT rc; + wxCopyRectToRECT(rect, rc); - return ::RectInRegion(M_REGION, &rect) ? wxInRegion : wxOutRegion; -} - -// Does the region contain the rectangle rect -wxRegionContain wxRegion::Contains(const wxRect& rect) const -{ - return Contains(rect.x, rect.y, rect.width, rect.height); + return ::RectInRegion(M_REGION, &rc) ? wxInRegion : wxOutRegion; } // Get internal region handle @@ -467,29 +441,28 @@ wxRegionIterator wxRegionIterator::operator ++ (int) wxCoord wxRegionIterator::GetX() const { - wxCHECK_MSG( m_current < m_numRects, 0, _T("invalid wxRegionIterator") ); + wxCHECK_MSG( m_current < m_numRects, 0, wxT("invalid wxRegionIterator") ); return m_rects[m_current].x; } wxCoord wxRegionIterator::GetY() const { - wxCHECK_MSG( m_current < m_numRects, 0, _T("invalid wxRegionIterator") ); + wxCHECK_MSG( m_current < m_numRects, 0, wxT("invalid wxRegionIterator") ); return m_rects[m_current].y; } wxCoord wxRegionIterator::GetW() const { - wxCHECK_MSG( m_current < m_numRects, 0, _T("invalid wxRegionIterator") ); + wxCHECK_MSG( m_current < m_numRects, 0, wxT("invalid wxRegionIterator") ); return m_rects[m_current].width; } wxCoord wxRegionIterator::GetH() const { - wxCHECK_MSG( m_current < m_numRects, 0, _T("invalid wxRegionIterator") ); + wxCHECK_MSG( m_current < m_numRects, 0, wxT("invalid wxRegionIterator") ); return m_rects[m_current].height; } -