/////////////////////////////////////////////////////////////////////////////
-// File: region.cpp
+// File: src/mac/carbon/region.cpp
// Purpose: Region class
// Author: Stefan Csomor
// Created: Fri Oct 24 10:46:34 MET 1997
#include "wx/wxprec.h"
#include "wx/region.h"
-#include "wx/gdicmn.h"
+
+#ifndef WX_PRECOMP
+ #include "wx/gdicmn.h"
+#endif
+
#include "wx/mac/uma.h"
IMPLEMENT_DYNAMIC_CLASS(wxRegion, wxGDIObject)
CopyRgn( data.m_macRgn , m_macRgn );
}
- ~wxRegionRefData()
+ virtual ~wxRegionRefData()
{ DisposeRgn( m_macRgn ); }
RgnHandle m_macRgn;
{
m_refData = new wxRegionRefData;
+#ifndef __LP64__
+ // TODO : any APIs ?
// OS X somehow does not collect the region invisibly as before, so sometimes things
// get drawn on screen instead of just being combined into a region, therefore we allocate a temp gworld now
::SetGWorld( oldWorld, oldGDHandle );
}
+#endif
}
wxRegion::~wxRegion()
}
// Move the region
-bool wxRegion::Offset(wxCoord x, wxCoord y)
+bool wxRegion::DoOffset(wxCoord x, wxCoord y)
{
wxCHECK_MSG( M_REGION, false, _T("invalid wxRegion") );
}
-//! Combine rectangle (x, y, w, h) with this.
-bool wxRegion::Combine(long x, long y, long width, long height, wxRegionOp op)
-{
- // Don't change shared data
- if (!m_refData)
- {
- m_refData = new wxRegionRefData();
- }
- else if (m_refData->GetRefCount() > 1)
- {
- wxRegionRefData* ref = (wxRegionRefData*)m_refData;
- UnRef();
- m_refData = new wxRegionRefData( *ref );
- }
-
- RgnHandle rgn = NewRgn() ;
- SetRectRgn( rgn , x , y, x + width, y + height ) ;
-
- switch (op)
- {
- case wxRGN_AND:
- SectRgn( M_REGION , rgn , M_REGION ) ;
- break ;
-
- case wxRGN_OR:
- UnionRgn( M_REGION , rgn , M_REGION ) ;
- break ;
-
- case wxRGN_XOR:
- XorRgn( M_REGION , rgn , M_REGION ) ;
- break ;
-
- case wxRGN_DIFF:
- DiffRgn( M_REGION , rgn , M_REGION ) ;
- break ;
-
- case wxRGN_COPY:
- default:
- CopyRgn( rgn , M_REGION ) ;
- break ;
- }
-
- DisposeRgn( rgn ) ;
-
- return true;
-}
-
//! Union /e region with this.
-bool wxRegion::Combine(const wxRegion& region, wxRegionOp op)
+bool wxRegion::DoCombine(const wxRegion& region, wxRegionOp op)
{
- if (region.Empty())
- return false;
+ wxCHECK_MSG( region.Ok(), false, _T("invalid wxRegion") );
// Don't change shared data
if (!m_refData)
return true;
}
-bool wxRegion::Combine(const wxRect& rect, wxRegionOp op)
-{
- return Combine(rect.GetLeft(), rect.GetTop(), rect.GetWidth(), rect.GetHeight(), op);
-}
-
//-----------------------------------------------------------------------------
//# Information on region
//-----------------------------------------------------------------------------
+bool wxRegion::DoIsEqual(const wxRegion& region) const
+{
+ wxFAIL_MSG( _T("not implemented") );
+
+ return false;
+}
+
// 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)
{
y = box.top ;
w = box.right - box.left ;
h = box.bottom - box.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
{
- return EmptyRgn( M_REGION ) ;
+ if ( m_refData )
+ return EmptyRgn( M_REGION ) ;
+ else
+ return true ;
}
const WXHRGN wxRegion::GetWXHRGN() const
//# Tests
//-----------------------------------------------------------------------------
-// Does the region contain the point (x,y)?
-wxRegionContain wxRegion::Contains(long x, long y) const
-{
- if (!m_refData)
- return wxOutRegion;
-
- // TODO. Return wxInRegion if within region.
-// if (0)
-// return wxInRegion;
-
- return wxOutRegion;
-}
-
// Does the region contain the point?
-wxRegionContain wxRegion::Contains(const wxPoint& pt) const
+wxRegionContain wxRegion::DoContainsPoint(wxCoord x, wxCoord y) const
{
if (!m_refData)
return wxOutRegion;
- Point p = { pt.y , pt.x } ;
+ Point p = { y , x } ;
if (PtInRgn( p , M_REGION ) )
return wxInRegion;
}
// Does the region contain the rectangle (x, y, w, h)?
-wxRegionContain wxRegion::Contains(long x, long y, long w, long h) const
+wxRegionContain wxRegion::DoContainsRect(const wxRect& r) const
{
if (!m_refData)
return wxOutRegion;
- Rect rect = { y , x , y + h , x + w } ;
+ Rect rect = { r.y , r.x , r.y + r.height , r.x + r.width } ;
if (RectInRgn( &rect , M_REGION ) )
return wxInRegion;
else
return wxOutRegion;
}
-// Does the region contain the rectangle rect
-wxRegionContain wxRegion::Contains(const wxRect& rect) const
-{
- if (!m_refData)
- return wxOutRegion;
-
- long x, y, w, h;
-
- x = rect.x;
- y = rect.y;
- w = rect.GetWidth();
- h = rect.GetHeight();
-
- return Contains(x, y, w, h);
-}
-
///////////////////////////////////////////////////////////////////////////////
// //
// wxRegionIterator //
m_rects = NULL;
}
- if (m_region.Empty())
+ if (m_region.IsEmpty())
{
m_numRects = 0;
}
else
{
- RegionToRectsUPP proc = NewRegionToRectsUPP( wxMacRegionToRectsCounterCallback );
+ RegionToRectsUPP proc =
+#ifdef __MACH__
+ (RegionToRectsUPP) wxMacRegionToRectsCounterCallback;
+#else
+ NewRegionToRectsUPP( wxMacRegionToRectsCounterCallback );
+#endif
OSStatus err = noErr;
err = QDRegionToRects (OTHER_M_REGION( region ) , kQDParseRegionFromTopLeft, proc, (void*)&m_numRects);
if (err == noErr)
{
+#ifndef __MACH__
DisposeRegionToRectsUPP (proc);
- proc = NewRegionToRectsUPP (wxMacRegionToRectsSetterCallback);
+#endif
+ proc =
+#ifdef __MACH__
+ (RegionToRectsUPP) wxMacRegionToRectsSetterCallback;
+#else
+ NewRegionToRectsUPP (wxMacRegionToRectsSetterCallback);
+#endif
m_rects = new wxRect[m_numRects];
RegionToRectsCallbackData data ;
data.m_rects = m_rects ;
m_numRects = 0;
}
+#ifndef __MACH__
DisposeRegionToRectsUPP( proc );
+#endif
}
}
{
if (m_current < m_numRects)
++m_current;
-
+
return *this;
}
return 0;
}
-