64 bit clean implementation
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50222 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -29,19 +29,33 @@ class WXDLLEXPORT wxRegionRefData : public wxGDIRefData
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxRegionRefData()
|
wxRegionRefData()
|
||||||
{ m_macRgn = NewRgn(); }
|
{
|
||||||
|
m_macRgn.reset( HIShapeCreateMutable() );
|
||||||
|
}
|
||||||
|
|
||||||
|
wxRegionRefData(HIShapeRef hRegion)
|
||||||
|
{
|
||||||
|
m_macRgn.reset( HIShapeCreateMutableCopy(hRegion) );
|
||||||
|
}
|
||||||
|
|
||||||
|
wxRegionRefData(long x, long y, long w, long h)
|
||||||
|
{
|
||||||
|
CGRect r = CGRectMake(x,y,w,h);
|
||||||
|
wxCFRef<HIShapeRef> rect(HIShapeCreateWithRect(&r));
|
||||||
|
m_macRgn.reset( HIShapeCreateMutableCopy(rect) );
|
||||||
|
}
|
||||||
|
|
||||||
wxRegionRefData(const wxRegionRefData& data)
|
wxRegionRefData(const wxRegionRefData& data)
|
||||||
: wxGDIRefData()
|
: wxGDIRefData()
|
||||||
{
|
{
|
||||||
m_macRgn = NewRgn();
|
m_macRgn.reset( HIShapeCreateMutableCopy(data.m_macRgn) );
|
||||||
CopyRgn( data.m_macRgn , m_macRgn );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~wxRegionRefData()
|
virtual ~wxRegionRefData()
|
||||||
{ DisposeRgn( m_macRgn ); }
|
{
|
||||||
|
}
|
||||||
|
|
||||||
RgnHandle m_macRgn;
|
wxCFRef<HIMutableShapeRef> m_macRgn;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define M_REGION (((wxRegionRefData*)m_refData)->m_macRgn)
|
#define M_REGION (((wxRegionRefData*)m_refData)->m_macRgn)
|
||||||
@@ -56,31 +70,29 @@ public:
|
|||||||
*/
|
*/
|
||||||
wxRegion::wxRegion()
|
wxRegion::wxRegion()
|
||||||
{
|
{
|
||||||
m_refData = new wxRegionRefData;
|
m_refData = new wxRegionRefData();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxRegion::wxRegion(WXHRGN hRegion )
|
wxRegion::wxRegion(WXHRGN hRegion )
|
||||||
{
|
{
|
||||||
m_refData = new wxRegionRefData;
|
m_refData = new wxRegionRefData(hRegion);
|
||||||
CopyRgn( (RgnHandle) hRegion , (RgnHandle) M_REGION ) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxRegion::wxRegion(long x, long y, long w, long h)
|
wxRegion::wxRegion(long x, long y, long w, long h)
|
||||||
{
|
{
|
||||||
m_refData = new wxRegionRefData;
|
m_refData = new wxRegionRefData(x , y , w , h );
|
||||||
SetRectRgn( (RgnHandle) M_REGION , x , y , x + w , y + h ) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxRegion::wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight)
|
wxRegion::wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight)
|
||||||
{
|
{
|
||||||
m_refData = new wxRegionRefData;
|
m_refData = new wxRegionRefData(topLeft.x , topLeft.y ,
|
||||||
SetRectRgn( (RgnHandle) M_REGION , topLeft.x , topLeft.y , bottomRight.x , bottomRight.y ) ;
|
topLeft.x - bottomRight.x ,
|
||||||
|
topLeft.y - bottomRight.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxRegion::wxRegion(const wxRect& rect)
|
wxRegion::wxRegion(const wxRect& rect)
|
||||||
{
|
{
|
||||||
m_refData = new wxRegionRefData;
|
m_refData = new wxRegionRefData(rect.x , rect.y , rect.width , rect.height);
|
||||||
SetRectRgn( (RgnHandle) M_REGION , rect.x , rect.y , rect.x + rect.width , rect.y + rect.height ) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxRegion::wxRegion(size_t n, const wxPoint *points, int WXUNUSED(fillStyle))
|
wxRegion::wxRegion(size_t n, const wxPoint *points, int WXUNUSED(fillStyle))
|
||||||
@@ -153,7 +165,7 @@ bool wxRegion::DoOffset(wxCoord x, wxCoord y)
|
|||||||
// nothing to do
|
// nothing to do
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
OffsetRgn( M_REGION , x , y ) ;
|
HIShapeOffset( M_REGION , x , y ) ;
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
@@ -179,24 +191,29 @@ bool wxRegion::DoCombine(const wxRegion& region, wxRegionOp op)
|
|||||||
switch (op)
|
switch (op)
|
||||||
{
|
{
|
||||||
case wxRGN_AND:
|
case wxRGN_AND:
|
||||||
SectRgn( M_REGION , OTHER_M_REGION(region) , M_REGION ) ;
|
HIShapeIntersect( M_REGION , OTHER_M_REGION(region) , M_REGION ) ;
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
case wxRGN_OR:
|
case wxRGN_OR:
|
||||||
UnionRgn( M_REGION , OTHER_M_REGION(region) , M_REGION ) ;
|
HIShapeUnion( M_REGION , OTHER_M_REGION(region) , M_REGION ) ;
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
case wxRGN_XOR:
|
case wxRGN_XOR:
|
||||||
XorRgn( M_REGION , OTHER_M_REGION(region) , M_REGION ) ;
|
{
|
||||||
|
// XOR is defined as the difference between union and intersection
|
||||||
|
wxCFRef< HIShapeRef > unionshape( HIShapeCreateUnion( M_REGION , OTHER_M_REGION(region) ) );
|
||||||
|
wxCFRef< HIShapeRef > intersectionshape( HIShapeCreateIntersection( M_REGION , OTHER_M_REGION(region) ) );
|
||||||
|
HIShapeDifference( unionshape, intersectionshape, M_REGION );
|
||||||
|
}
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
case wxRGN_DIFF:
|
case wxRGN_DIFF:
|
||||||
DiffRgn( M_REGION , OTHER_M_REGION(region) , M_REGION ) ;
|
HIShapeDifference( M_REGION , OTHER_M_REGION(region) , M_REGION ) ;
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
case wxRGN_COPY:
|
case wxRGN_COPY:
|
||||||
default:
|
default:
|
||||||
CopyRgn( OTHER_M_REGION(region) , M_REGION ) ;
|
M_REGION.reset( HIShapeCreateMutableCopy( OTHER_M_REGION(region) ) );
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,12 +236,12 @@ bool wxRegion::DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const
|
|||||||
{
|
{
|
||||||
if (m_refData)
|
if (m_refData)
|
||||||
{
|
{
|
||||||
Rect box ;
|
CGRect box ;
|
||||||
GetRegionBounds( M_REGION , &box ) ;
|
HIShapeGetBounds( M_REGION , &box ) ;
|
||||||
x = box.left ;
|
x = box.origin.x ;
|
||||||
y = box.top ;
|
y = box.origin.y ;
|
||||||
w = box.right - box.left ;
|
w = box.size.width ;
|
||||||
h = box.bottom - box.top ;
|
h = box.size.height ;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -240,7 +257,7 @@ bool wxRegion::DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const
|
|||||||
bool wxRegion::IsEmpty() const
|
bool wxRegion::IsEmpty() const
|
||||||
{
|
{
|
||||||
if ( m_refData )
|
if ( m_refData )
|
||||||
return EmptyRgn( M_REGION ) ;
|
return HIShapeIsEmpty( M_REGION ) ;
|
||||||
else
|
else
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
@@ -260,8 +277,8 @@ wxRegionContain wxRegion::DoContainsPoint(wxCoord x, wxCoord y) const
|
|||||||
if (!m_refData)
|
if (!m_refData)
|
||||||
return wxOutRegion;
|
return wxOutRegion;
|
||||||
|
|
||||||
Point p = { y , x } ;
|
CGPoint p = { y , x } ;
|
||||||
if (PtInRgn( p , M_REGION ) )
|
if (HIShapeContainsPoint( M_REGION , &p ) )
|
||||||
return wxInRegion;
|
return wxInRegion;
|
||||||
|
|
||||||
return wxOutRegion;
|
return wxOutRegion;
|
||||||
@@ -273,8 +290,13 @@ wxRegionContain wxRegion::DoContainsRect(const wxRect& r) const
|
|||||||
if (!m_refData)
|
if (!m_refData)
|
||||||
return wxOutRegion;
|
return wxOutRegion;
|
||||||
|
|
||||||
Rect rect = { r.y , r.x , r.y + r.height , r.x + r.width } ;
|
CGRect rect = CGRectMake(r.x,r.y,r.width,r.height);
|
||||||
if (RectInRgn( &rect , M_REGION ) )
|
wxCFRef<HIShapeRef> rectshape(HIShapeCreateWithRect(&rect));
|
||||||
|
wxCFRef<HIShapeRef> intersect(HIShapeCreateIntersection(rectshape,M_REGION));
|
||||||
|
CGRect bounds;
|
||||||
|
HIShapeGetBounds(intersect, &bounds);
|
||||||
|
|
||||||
|
if ( HIShapeIsRectangular(intersect) && CGRectEqualToRect(rect,bounds) )
|
||||||
return wxInRegion;
|
return wxInRegion;
|
||||||
else
|
else
|
||||||
return wxOutRegion;
|
return wxOutRegion;
|
||||||
@@ -357,6 +379,7 @@ wxRegionIterator::wxRegionIterator(const wxRegion& region)
|
|||||||
* Reset iterator for a new /e region.
|
* Reset iterator for a new /e region.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef __LP64__
|
||||||
OSStatus wxMacRegionToRectsCounterCallback(
|
OSStatus wxMacRegionToRectsCounterCallback(
|
||||||
UInt16 message, RgnHandle WXUNUSED(region), const Rect *WXUNUSED(rect), void *data )
|
UInt16 message, RgnHandle WXUNUSED(region), const Rect *WXUNUSED(rect), void *data )
|
||||||
{
|
{
|
||||||
@@ -391,6 +414,7 @@ OSStatus wxMacRegionToRectsSetterCallback(
|
|||||||
|
|
||||||
return noErr;
|
return noErr;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void wxRegionIterator::Reset(const wxRegion& region)
|
void wxRegionIterator::Reset(const wxRegion& region)
|
||||||
{
|
{
|
||||||
@@ -409,26 +433,22 @@ void wxRegionIterator::Reset(const wxRegion& region)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RegionToRectsUPP proc =
|
#ifdef __LP64__
|
||||||
#ifdef __MACH__
|
// copying this to a path and dissecting the path would be an option
|
||||||
(RegionToRectsUPP) wxMacRegionToRectsCounterCallback;
|
m_numRects = 1;
|
||||||
|
m_rects = new wxRect[m_numRects];
|
||||||
|
m_rects[0] = m_region.GetBox();
|
||||||
|
|
||||||
#else
|
#else
|
||||||
NewRegionToRectsUPP( wxMacRegionToRectsCounterCallback );
|
RegionToRectsUPP proc = (RegionToRectsUPP) wxMacRegionToRectsCounterCallback;
|
||||||
#endif
|
|
||||||
|
|
||||||
OSStatus err = noErr;
|
OSStatus err = noErr;
|
||||||
|
RgnHandle rgn = NewHandle();
|
||||||
|
|
||||||
err = QDRegionToRects (OTHER_M_REGION( region ) , kQDParseRegionFromTopLeft, proc, (void*)&m_numRects);
|
err = QDRegionToRects (OTHER_M_REGION( region ) , kQDParseRegionFromTopLeft, proc, (void*)&m_numRects);
|
||||||
if (err == noErr)
|
if (err == noErr)
|
||||||
{
|
{
|
||||||
#ifndef __MACH__
|
proc = (RegionToRectsUPP) wxMacRegionToRectsSetterCallback;
|
||||||
DisposeRegionToRectsUPP (proc);
|
|
||||||
#endif
|
|
||||||
proc =
|
|
||||||
#ifdef __MACH__
|
|
||||||
(RegionToRectsUPP) wxMacRegionToRectsSetterCallback;
|
|
||||||
#else
|
|
||||||
NewRegionToRectsUPP (wxMacRegionToRectsSetterCallback);
|
|
||||||
#endif
|
|
||||||
m_rects = new wxRect[m_numRects];
|
m_rects = new wxRect[m_numRects];
|
||||||
RegionToRectsCallbackData data ;
|
RegionToRectsCallbackData data ;
|
||||||
data.m_rects = m_rects ;
|
data.m_rects = m_rects ;
|
||||||
@@ -439,9 +459,6 @@ void wxRegionIterator::Reset(const wxRegion& region)
|
|||||||
{
|
{
|
||||||
m_numRects = 0;
|
m_numRects = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __MACH__
|
|
||||||
DisposeRegionToRectsUPP( proc );
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user