faster portsetting backpatched
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23565 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -55,6 +55,9 @@ const double RAD2DEG = 180.0 / M_PI;
|
|||||||
const short kEmulatedMode = -1 ;
|
const short kEmulatedMode = -1 ;
|
||||||
const short kUnsupportedMode = -2 ;
|
const short kUnsupportedMode = -2 ;
|
||||||
|
|
||||||
|
// set to 0 if problems arise
|
||||||
|
#define wxMAC_EXPERIMENTAL_DC 1
|
||||||
|
|
||||||
wxMacPortSetter::wxMacPortSetter( const wxDC* dc ) :
|
wxMacPortSetter::wxMacPortSetter( const wxDC* dc ) :
|
||||||
m_ph( (GrafPtr) dc->m_macPort )
|
m_ph( (GrafPtr) dc->m_macPort )
|
||||||
{
|
{
|
||||||
@@ -62,12 +65,37 @@ wxMacPortSetter::wxMacPortSetter( const wxDC* dc ) :
|
|||||||
m_dc = dc ;
|
m_dc = dc ;
|
||||||
dc->MacSetupPort(&m_ph) ;
|
dc->MacSetupPort(&m_ph) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMacPortSetter::~wxMacPortSetter()
|
wxMacPortSetter::~wxMacPortSetter()
|
||||||
{
|
{
|
||||||
m_dc->MacCleanupPort(&m_ph) ;
|
m_dc->MacCleanupPort(&m_ph) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxMAC_EXPERIMENTAL_DC
|
||||||
|
class wxMacFastPortSetter
|
||||||
|
{
|
||||||
|
public :
|
||||||
|
wxMacFastPortSetter( const wxDC *dc )
|
||||||
|
{
|
||||||
|
wxASSERT( dc->Ok() ) ;
|
||||||
|
GetPort( &m_oldPort ) ;
|
||||||
|
SetPort( (GrafPtr) dc->m_macPort ) ;
|
||||||
|
m_dc = dc ;
|
||||||
|
dc->MacSetupPort( NULL ) ;
|
||||||
|
}
|
||||||
|
~wxMacFastPortSetter()
|
||||||
|
{
|
||||||
|
SetPort( m_oldPort ) ;
|
||||||
|
m_dc->MacCleanupPort( NULL ) ;
|
||||||
|
}
|
||||||
|
private :
|
||||||
|
GrafPtr m_oldPort ;
|
||||||
|
const wxDC* m_dc ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
#else
|
||||||
|
typedef wxMacPortSetter wxMacFastPortSetter ;
|
||||||
|
#endif
|
||||||
|
|
||||||
wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win )
|
wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win )
|
||||||
{
|
{
|
||||||
m_formerClip = NewRgn() ;
|
m_formerClip = NewRgn() ;
|
||||||
@@ -263,11 +291,12 @@ void wxDC::MacSetupPort(wxMacPortStateHelper* help) const
|
|||||||
m_macCurrentPortStateHelper = help ;
|
m_macCurrentPortStateHelper = help ;
|
||||||
#endif
|
#endif
|
||||||
SetClip( (RgnHandle) m_macCurrentClipRgn);
|
SetClip( (RgnHandle) m_macCurrentClipRgn);
|
||||||
|
#if ! wxMAC_EXPERIMENTAL_DC
|
||||||
m_macFontInstalled = false ;
|
m_macFontInstalled = false ;
|
||||||
m_macBrushInstalled = false ;
|
m_macBrushInstalled = false ;
|
||||||
m_macPenInstalled = false ;
|
m_macPenInstalled = false ;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDC::MacCleanupPort(wxMacPortStateHelper* help) const
|
void wxDC::MacCleanupPort(wxMacPortStateHelper* help) const
|
||||||
{
|
{
|
||||||
#ifdef __WXDEBUG__
|
#ifdef __WXDEBUG__
|
||||||
@@ -304,7 +333,7 @@ void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask
|
|||||||
{
|
{
|
||||||
wxCHECK_RET( Ok(), wxT("invalid window dc") );
|
wxCHECK_RET( Ok(), wxT("invalid window dc") );
|
||||||
wxCHECK_RET( bmp.Ok(), wxT("invalid bitmap") );
|
wxCHECK_RET( bmp.Ok(), wxT("invalid bitmap") );
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
wxCoord xx = XLOG2DEVMAC(x);
|
wxCoord xx = XLOG2DEVMAC(x);
|
||||||
wxCoord yy = YLOG2DEVMAC(y);
|
wxCoord yy = YLOG2DEVMAC(y);
|
||||||
wxCoord w = bmp.GetWidth();
|
wxCoord w = bmp.GetWidth();
|
||||||
@@ -428,7 +457,7 @@ void wxDC::DoSetClippingRegionAsRegion( const wxRegion ®ion )
|
|||||||
DestroyClippingRegion();
|
DestroyClippingRegion();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
wxCoord x, y, w, h;
|
wxCoord x, y, w, h;
|
||||||
region.GetBox( x, y, w, h );
|
region.GetBox( x, y, w, h );
|
||||||
wxCoord xx, yy, ww, hh;
|
wxCoord xx, yy, ww, hh;
|
||||||
@@ -470,7 +499,7 @@ void wxDC::DoSetClippingRegionAsRegion( const wxRegion ®ion )
|
|||||||
|
|
||||||
void wxDC::DestroyClippingRegion()
|
void wxDC::DestroyClippingRegion()
|
||||||
{
|
{
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
||||||
m_clipping = FALSE;
|
m_clipping = FALSE;
|
||||||
}
|
}
|
||||||
@@ -675,7 +704,7 @@ bool wxDC::DoFloodFill(wxCoord x, wxCoord y,
|
|||||||
bool wxDC::DoGetPixel( wxCoord x, wxCoord y, wxColour *col ) const
|
bool wxDC::DoGetPixel( wxCoord x, wxCoord y, wxColour *col ) const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel Invalid DC") );
|
wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel Invalid DC") );
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
RGBColor colour;
|
RGBColor colour;
|
||||||
GetCPixel( XLOG2DEVMAC(x), YLOG2DEVMAC(y), &colour );
|
GetCPixel( XLOG2DEVMAC(x), YLOG2DEVMAC(y), &colour );
|
||||||
// Convert from Mac colour to wx
|
// Convert from Mac colour to wx
|
||||||
@@ -688,7 +717,7 @@ bool wxDC::DoGetPixel( wxCoord x, wxCoord y, wxColour *col ) const
|
|||||||
void wxDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
|
void wxDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
|
||||||
{
|
{
|
||||||
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
if (m_pen.GetStyle() != wxTRANSPARENT)
|
if (m_pen.GetStyle() != wxTRANSPARENT)
|
||||||
{
|
{
|
||||||
MacInstallPen() ;
|
MacInstallPen() ;
|
||||||
@@ -726,7 +755,7 @@ void wxDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
|
|||||||
void wxDC::DoCrossHair( wxCoord x, wxCoord y )
|
void wxDC::DoCrossHair( wxCoord x, wxCoord y )
|
||||||
{
|
{
|
||||||
wxCHECK_RET( Ok(), wxT("wxDC::DoCrossHair Invalid window dc") );
|
wxCHECK_RET( Ok(), wxT("wxDC::DoCrossHair Invalid window dc") );
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
if (m_pen.GetStyle() != wxTRANSPARENT)
|
if (m_pen.GetStyle() != wxTRANSPARENT)
|
||||||
{
|
{
|
||||||
int w = 0;
|
int w = 0;
|
||||||
@@ -766,7 +795,7 @@ void wxDC::DoDrawArc( wxCoord x1, wxCoord y1,
|
|||||||
wxCoord xc, wxCoord yc )
|
wxCoord xc, wxCoord yc )
|
||||||
{
|
{
|
||||||
wxCHECK_RET(Ok(), wxT("wxDC::DoDrawArc Invalid DC"));
|
wxCHECK_RET(Ok(), wxT("wxDC::DoDrawArc Invalid DC"));
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
wxCoord xx1 = XLOG2DEVMAC(x1);
|
wxCoord xx1 = XLOG2DEVMAC(x1);
|
||||||
wxCoord yy1 = YLOG2DEVMAC(y1);
|
wxCoord yy1 = YLOG2DEVMAC(y1);
|
||||||
wxCoord xx2 = XLOG2DEVMAC(x2);
|
wxCoord xx2 = XLOG2DEVMAC(x2);
|
||||||
@@ -816,7 +845,7 @@ void wxDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h,
|
|||||||
double sa, double ea )
|
double sa, double ea )
|
||||||
{
|
{
|
||||||
wxCHECK_RET(Ok(), wxT("wxDC::DoDrawEllepticArc Invalid DC"));
|
wxCHECK_RET(Ok(), wxT("wxDC::DoDrawEllepticArc Invalid DC"));
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
Rect r;
|
Rect r;
|
||||||
double angle = sa - ea; // Order important Mac in opposite direction to wx
|
double angle = sa - ea; // Order important Mac in opposite direction to wx
|
||||||
// we have to make sure that the filling is always counter-clockwise
|
// we have to make sure that the filling is always counter-clockwise
|
||||||
@@ -847,7 +876,7 @@ void wxDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h,
|
|||||||
void wxDC::DoDrawPoint( wxCoord x, wxCoord y )
|
void wxDC::DoDrawPoint( wxCoord x, wxCoord y )
|
||||||
{
|
{
|
||||||
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
if (m_pen.GetStyle() != wxTRANSPARENT)
|
if (m_pen.GetStyle() != wxTRANSPARENT)
|
||||||
{
|
{
|
||||||
wxCoord xx1 = XLOG2DEVMAC(x);
|
wxCoord xx1 = XLOG2DEVMAC(x);
|
||||||
@@ -862,7 +891,7 @@ void wxDC::DoDrawLines(int n, wxPoint points[],
|
|||||||
wxCoord xoffset, wxCoord yoffset)
|
wxCoord xoffset, wxCoord yoffset)
|
||||||
{
|
{
|
||||||
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
if (m_pen.GetStyle() == wxTRANSPARENT)
|
if (m_pen.GetStyle() == wxTRANSPARENT)
|
||||||
return;
|
return;
|
||||||
MacInstallPen() ;
|
MacInstallPen() ;
|
||||||
@@ -885,7 +914,7 @@ void wxDC::DoDrawPolygon(int n, wxPoint points[],
|
|||||||
int fillStyle )
|
int fillStyle )
|
||||||
{
|
{
|
||||||
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
wxCoord x1, x2 , y1 , y2 ;
|
wxCoord x1, x2 , y1 , y2 ;
|
||||||
if ( m_brush.GetStyle() == wxTRANSPARENT && m_pen.GetStyle() == wxTRANSPARENT )
|
if ( m_brush.GetStyle() == wxTRANSPARENT && m_pen.GetStyle() == wxTRANSPARENT )
|
||||||
return ;
|
return ;
|
||||||
@@ -921,7 +950,7 @@ void wxDC::DoDrawPolygon(int n, wxPoint points[],
|
|||||||
void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
|
void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
|
||||||
{
|
{
|
||||||
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
wxCoord xx = XLOG2DEVMAC(x);
|
wxCoord xx = XLOG2DEVMAC(x);
|
||||||
wxCoord yy = YLOG2DEVMAC(y);
|
wxCoord yy = YLOG2DEVMAC(y);
|
||||||
wxCoord ww = m_signX * XLOG2DEVREL(width);
|
wxCoord ww = m_signX * XLOG2DEVREL(width);
|
||||||
@@ -958,7 +987,7 @@ void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y,
|
|||||||
double radius)
|
double radius)
|
||||||
{
|
{
|
||||||
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
if (radius < 0.0)
|
if (radius < 0.0)
|
||||||
radius = - radius * ((width < height) ? width : height);
|
radius = - radius * ((width < height) ? width : height);
|
||||||
wxCoord xx = XLOG2DEVMAC(x);
|
wxCoord xx = XLOG2DEVMAC(x);
|
||||||
@@ -995,7 +1024,7 @@ void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y,
|
|||||||
void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
|
void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
|
||||||
{
|
{
|
||||||
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
wxCoord xx = XLOG2DEVMAC(x);
|
wxCoord xx = XLOG2DEVMAC(x);
|
||||||
wxCoord yy = YLOG2DEVMAC(y);
|
wxCoord yy = YLOG2DEVMAC(y);
|
||||||
wxCoord ww = m_signX * XLOG2DEVREL(width);
|
wxCoord ww = m_signX * XLOG2DEVREL(width);
|
||||||
@@ -1124,7 +1153,7 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
|
|||||||
PixMapHandle bmappixels = GetGWorldPixMap( sourcePort ) ;
|
PixMapHandle bmappixels = GetGWorldPixMap( sourcePort ) ;
|
||||||
if ( LockPixels(bmappixels) )
|
if ( LockPixels(bmappixels) )
|
||||||
{
|
{
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
if ( source->GetDepth() == 1 )
|
if ( source->GetDepth() == 1 )
|
||||||
{
|
{
|
||||||
RGBForeColor( &MAC_WXCOLORREF(m_textForegroundColour.GetPixel()) ) ;
|
RGBForeColor( &MAC_WXCOLORREF(m_textForegroundColour.GetPixel()) ) ;
|
||||||
@@ -1307,7 +1336,7 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y,
|
|||||||
if ( str.Length() == 0 )
|
if ( str.Length() == 0 )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
MacInstallFont() ;
|
MacInstallFont() ;
|
||||||
|
|
||||||
wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ;
|
wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ;
|
||||||
@@ -1399,7 +1428,7 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y)
|
|||||||
{
|
{
|
||||||
wxCHECK_RET(Ok(), wxT("wxDC::DoDrawText Invalid DC"));
|
wxCHECK_RET(Ok(), wxT("wxDC::DoDrawText Invalid DC"));
|
||||||
|
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
long xx = XLOG2DEVMAC(x);
|
long xx = XLOG2DEVMAC(x);
|
||||||
long yy = YLOG2DEVMAC(y);
|
long yy = YLOG2DEVMAC(y);
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
@@ -1532,7 +1561,7 @@ void wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *h
|
|||||||
wxFont *theFont ) const
|
wxFont *theFont ) const
|
||||||
{
|
{
|
||||||
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
wxFont formerFont = m_font ;
|
wxFont formerFont = m_font ;
|
||||||
if ( theFont )
|
if ( theFont )
|
||||||
{
|
{
|
||||||
@@ -1644,7 +1673,7 @@ void wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *h
|
|||||||
wxCoord wxDC::GetCharWidth(void) const
|
wxCoord wxDC::GetCharWidth(void) const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
|
wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
MacInstallFont() ;
|
MacInstallFont() ;
|
||||||
int width = 0 ;
|
int width = 0 ;
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
@@ -1679,7 +1708,7 @@ wxCoord wxDC::GetCharWidth(void) const
|
|||||||
wxCoord wxDC::GetCharHeight(void) const
|
wxCoord wxDC::GetCharHeight(void) const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
|
wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
MacInstallFont() ;
|
MacInstallFont() ;
|
||||||
FontInfo fi ;
|
FontInfo fi ;
|
||||||
::GetFontInfo( &fi ) ;
|
::GetFontInfo( &fi ) ;
|
||||||
@@ -1689,7 +1718,7 @@ wxCoord wxDC::GetCharHeight(void) const
|
|||||||
void wxDC::Clear(void)
|
void wxDC::Clear(void)
|
||||||
{
|
{
|
||||||
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
Rect rect = { -31000 , -31000 , 31000 , 31000 } ;
|
Rect rect = { -31000 , -31000 , 31000 , 31000 } ;
|
||||||
if (m_backgroundBrush.GetStyle() != wxTRANSPARENT)
|
if (m_backgroundBrush.GetStyle() != wxTRANSPARENT)
|
||||||
{
|
{
|
||||||
|
@@ -55,6 +55,9 @@ const double RAD2DEG = 180.0 / M_PI;
|
|||||||
const short kEmulatedMode = -1 ;
|
const short kEmulatedMode = -1 ;
|
||||||
const short kUnsupportedMode = -2 ;
|
const short kUnsupportedMode = -2 ;
|
||||||
|
|
||||||
|
// set to 0 if problems arise
|
||||||
|
#define wxMAC_EXPERIMENTAL_DC 1
|
||||||
|
|
||||||
wxMacPortSetter::wxMacPortSetter( const wxDC* dc ) :
|
wxMacPortSetter::wxMacPortSetter( const wxDC* dc ) :
|
||||||
m_ph( (GrafPtr) dc->m_macPort )
|
m_ph( (GrafPtr) dc->m_macPort )
|
||||||
{
|
{
|
||||||
@@ -62,12 +65,37 @@ wxMacPortSetter::wxMacPortSetter( const wxDC* dc ) :
|
|||||||
m_dc = dc ;
|
m_dc = dc ;
|
||||||
dc->MacSetupPort(&m_ph) ;
|
dc->MacSetupPort(&m_ph) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMacPortSetter::~wxMacPortSetter()
|
wxMacPortSetter::~wxMacPortSetter()
|
||||||
{
|
{
|
||||||
m_dc->MacCleanupPort(&m_ph) ;
|
m_dc->MacCleanupPort(&m_ph) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxMAC_EXPERIMENTAL_DC
|
||||||
|
class wxMacFastPortSetter
|
||||||
|
{
|
||||||
|
public :
|
||||||
|
wxMacFastPortSetter( const wxDC *dc )
|
||||||
|
{
|
||||||
|
wxASSERT( dc->Ok() ) ;
|
||||||
|
GetPort( &m_oldPort ) ;
|
||||||
|
SetPort( (GrafPtr) dc->m_macPort ) ;
|
||||||
|
m_dc = dc ;
|
||||||
|
dc->MacSetupPort( NULL ) ;
|
||||||
|
}
|
||||||
|
~wxMacFastPortSetter()
|
||||||
|
{
|
||||||
|
SetPort( m_oldPort ) ;
|
||||||
|
m_dc->MacCleanupPort( NULL ) ;
|
||||||
|
}
|
||||||
|
private :
|
||||||
|
GrafPtr m_oldPort ;
|
||||||
|
const wxDC* m_dc ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
#else
|
||||||
|
typedef wxMacPortSetter wxMacFastPortSetter ;
|
||||||
|
#endif
|
||||||
|
|
||||||
wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win )
|
wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win )
|
||||||
{
|
{
|
||||||
m_formerClip = NewRgn() ;
|
m_formerClip = NewRgn() ;
|
||||||
@@ -263,11 +291,12 @@ void wxDC::MacSetupPort(wxMacPortStateHelper* help) const
|
|||||||
m_macCurrentPortStateHelper = help ;
|
m_macCurrentPortStateHelper = help ;
|
||||||
#endif
|
#endif
|
||||||
SetClip( (RgnHandle) m_macCurrentClipRgn);
|
SetClip( (RgnHandle) m_macCurrentClipRgn);
|
||||||
|
#if ! wxMAC_EXPERIMENTAL_DC
|
||||||
m_macFontInstalled = false ;
|
m_macFontInstalled = false ;
|
||||||
m_macBrushInstalled = false ;
|
m_macBrushInstalled = false ;
|
||||||
m_macPenInstalled = false ;
|
m_macPenInstalled = false ;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDC::MacCleanupPort(wxMacPortStateHelper* help) const
|
void wxDC::MacCleanupPort(wxMacPortStateHelper* help) const
|
||||||
{
|
{
|
||||||
#ifdef __WXDEBUG__
|
#ifdef __WXDEBUG__
|
||||||
@@ -304,7 +333,7 @@ void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask
|
|||||||
{
|
{
|
||||||
wxCHECK_RET( Ok(), wxT("invalid window dc") );
|
wxCHECK_RET( Ok(), wxT("invalid window dc") );
|
||||||
wxCHECK_RET( bmp.Ok(), wxT("invalid bitmap") );
|
wxCHECK_RET( bmp.Ok(), wxT("invalid bitmap") );
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
wxCoord xx = XLOG2DEVMAC(x);
|
wxCoord xx = XLOG2DEVMAC(x);
|
||||||
wxCoord yy = YLOG2DEVMAC(y);
|
wxCoord yy = YLOG2DEVMAC(y);
|
||||||
wxCoord w = bmp.GetWidth();
|
wxCoord w = bmp.GetWidth();
|
||||||
@@ -428,7 +457,7 @@ void wxDC::DoSetClippingRegionAsRegion( const wxRegion ®ion )
|
|||||||
DestroyClippingRegion();
|
DestroyClippingRegion();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
wxCoord x, y, w, h;
|
wxCoord x, y, w, h;
|
||||||
region.GetBox( x, y, w, h );
|
region.GetBox( x, y, w, h );
|
||||||
wxCoord xx, yy, ww, hh;
|
wxCoord xx, yy, ww, hh;
|
||||||
@@ -470,7 +499,7 @@ void wxDC::DoSetClippingRegionAsRegion( const wxRegion ®ion )
|
|||||||
|
|
||||||
void wxDC::DestroyClippingRegion()
|
void wxDC::DestroyClippingRegion()
|
||||||
{
|
{
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
||||||
m_clipping = FALSE;
|
m_clipping = FALSE;
|
||||||
}
|
}
|
||||||
@@ -675,7 +704,7 @@ bool wxDC::DoFloodFill(wxCoord x, wxCoord y,
|
|||||||
bool wxDC::DoGetPixel( wxCoord x, wxCoord y, wxColour *col ) const
|
bool wxDC::DoGetPixel( wxCoord x, wxCoord y, wxColour *col ) const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel Invalid DC") );
|
wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel Invalid DC") );
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
RGBColor colour;
|
RGBColor colour;
|
||||||
GetCPixel( XLOG2DEVMAC(x), YLOG2DEVMAC(y), &colour );
|
GetCPixel( XLOG2DEVMAC(x), YLOG2DEVMAC(y), &colour );
|
||||||
// Convert from Mac colour to wx
|
// Convert from Mac colour to wx
|
||||||
@@ -688,7 +717,7 @@ bool wxDC::DoGetPixel( wxCoord x, wxCoord y, wxColour *col ) const
|
|||||||
void wxDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
|
void wxDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
|
||||||
{
|
{
|
||||||
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
if (m_pen.GetStyle() != wxTRANSPARENT)
|
if (m_pen.GetStyle() != wxTRANSPARENT)
|
||||||
{
|
{
|
||||||
MacInstallPen() ;
|
MacInstallPen() ;
|
||||||
@@ -726,7 +755,7 @@ void wxDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
|
|||||||
void wxDC::DoCrossHair( wxCoord x, wxCoord y )
|
void wxDC::DoCrossHair( wxCoord x, wxCoord y )
|
||||||
{
|
{
|
||||||
wxCHECK_RET( Ok(), wxT("wxDC::DoCrossHair Invalid window dc") );
|
wxCHECK_RET( Ok(), wxT("wxDC::DoCrossHair Invalid window dc") );
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
if (m_pen.GetStyle() != wxTRANSPARENT)
|
if (m_pen.GetStyle() != wxTRANSPARENT)
|
||||||
{
|
{
|
||||||
int w = 0;
|
int w = 0;
|
||||||
@@ -766,7 +795,7 @@ void wxDC::DoDrawArc( wxCoord x1, wxCoord y1,
|
|||||||
wxCoord xc, wxCoord yc )
|
wxCoord xc, wxCoord yc )
|
||||||
{
|
{
|
||||||
wxCHECK_RET(Ok(), wxT("wxDC::DoDrawArc Invalid DC"));
|
wxCHECK_RET(Ok(), wxT("wxDC::DoDrawArc Invalid DC"));
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
wxCoord xx1 = XLOG2DEVMAC(x1);
|
wxCoord xx1 = XLOG2DEVMAC(x1);
|
||||||
wxCoord yy1 = YLOG2DEVMAC(y1);
|
wxCoord yy1 = YLOG2DEVMAC(y1);
|
||||||
wxCoord xx2 = XLOG2DEVMAC(x2);
|
wxCoord xx2 = XLOG2DEVMAC(x2);
|
||||||
@@ -816,7 +845,7 @@ void wxDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h,
|
|||||||
double sa, double ea )
|
double sa, double ea )
|
||||||
{
|
{
|
||||||
wxCHECK_RET(Ok(), wxT("wxDC::DoDrawEllepticArc Invalid DC"));
|
wxCHECK_RET(Ok(), wxT("wxDC::DoDrawEllepticArc Invalid DC"));
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
Rect r;
|
Rect r;
|
||||||
double angle = sa - ea; // Order important Mac in opposite direction to wx
|
double angle = sa - ea; // Order important Mac in opposite direction to wx
|
||||||
// we have to make sure that the filling is always counter-clockwise
|
// we have to make sure that the filling is always counter-clockwise
|
||||||
@@ -847,7 +876,7 @@ void wxDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h,
|
|||||||
void wxDC::DoDrawPoint( wxCoord x, wxCoord y )
|
void wxDC::DoDrawPoint( wxCoord x, wxCoord y )
|
||||||
{
|
{
|
||||||
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
if (m_pen.GetStyle() != wxTRANSPARENT)
|
if (m_pen.GetStyle() != wxTRANSPARENT)
|
||||||
{
|
{
|
||||||
wxCoord xx1 = XLOG2DEVMAC(x);
|
wxCoord xx1 = XLOG2DEVMAC(x);
|
||||||
@@ -862,7 +891,7 @@ void wxDC::DoDrawLines(int n, wxPoint points[],
|
|||||||
wxCoord xoffset, wxCoord yoffset)
|
wxCoord xoffset, wxCoord yoffset)
|
||||||
{
|
{
|
||||||
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
if (m_pen.GetStyle() == wxTRANSPARENT)
|
if (m_pen.GetStyle() == wxTRANSPARENT)
|
||||||
return;
|
return;
|
||||||
MacInstallPen() ;
|
MacInstallPen() ;
|
||||||
@@ -885,7 +914,7 @@ void wxDC::DoDrawPolygon(int n, wxPoint points[],
|
|||||||
int fillStyle )
|
int fillStyle )
|
||||||
{
|
{
|
||||||
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
wxCoord x1, x2 , y1 , y2 ;
|
wxCoord x1, x2 , y1 , y2 ;
|
||||||
if ( m_brush.GetStyle() == wxTRANSPARENT && m_pen.GetStyle() == wxTRANSPARENT )
|
if ( m_brush.GetStyle() == wxTRANSPARENT && m_pen.GetStyle() == wxTRANSPARENT )
|
||||||
return ;
|
return ;
|
||||||
@@ -921,7 +950,7 @@ void wxDC::DoDrawPolygon(int n, wxPoint points[],
|
|||||||
void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
|
void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
|
||||||
{
|
{
|
||||||
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
wxCoord xx = XLOG2DEVMAC(x);
|
wxCoord xx = XLOG2DEVMAC(x);
|
||||||
wxCoord yy = YLOG2DEVMAC(y);
|
wxCoord yy = YLOG2DEVMAC(y);
|
||||||
wxCoord ww = m_signX * XLOG2DEVREL(width);
|
wxCoord ww = m_signX * XLOG2DEVREL(width);
|
||||||
@@ -958,7 +987,7 @@ void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y,
|
|||||||
double radius)
|
double radius)
|
||||||
{
|
{
|
||||||
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
if (radius < 0.0)
|
if (radius < 0.0)
|
||||||
radius = - radius * ((width < height) ? width : height);
|
radius = - radius * ((width < height) ? width : height);
|
||||||
wxCoord xx = XLOG2DEVMAC(x);
|
wxCoord xx = XLOG2DEVMAC(x);
|
||||||
@@ -995,7 +1024,7 @@ void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y,
|
|||||||
void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
|
void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
|
||||||
{
|
{
|
||||||
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
wxCoord xx = XLOG2DEVMAC(x);
|
wxCoord xx = XLOG2DEVMAC(x);
|
||||||
wxCoord yy = YLOG2DEVMAC(y);
|
wxCoord yy = YLOG2DEVMAC(y);
|
||||||
wxCoord ww = m_signX * XLOG2DEVREL(width);
|
wxCoord ww = m_signX * XLOG2DEVREL(width);
|
||||||
@@ -1124,7 +1153,7 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
|
|||||||
PixMapHandle bmappixels = GetGWorldPixMap( sourcePort ) ;
|
PixMapHandle bmappixels = GetGWorldPixMap( sourcePort ) ;
|
||||||
if ( LockPixels(bmappixels) )
|
if ( LockPixels(bmappixels) )
|
||||||
{
|
{
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
if ( source->GetDepth() == 1 )
|
if ( source->GetDepth() == 1 )
|
||||||
{
|
{
|
||||||
RGBForeColor( &MAC_WXCOLORREF(m_textForegroundColour.GetPixel()) ) ;
|
RGBForeColor( &MAC_WXCOLORREF(m_textForegroundColour.GetPixel()) ) ;
|
||||||
@@ -1307,7 +1336,7 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y,
|
|||||||
if ( str.Length() == 0 )
|
if ( str.Length() == 0 )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
MacInstallFont() ;
|
MacInstallFont() ;
|
||||||
|
|
||||||
wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ;
|
wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ;
|
||||||
@@ -1399,7 +1428,7 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y)
|
|||||||
{
|
{
|
||||||
wxCHECK_RET(Ok(), wxT("wxDC::DoDrawText Invalid DC"));
|
wxCHECK_RET(Ok(), wxT("wxDC::DoDrawText Invalid DC"));
|
||||||
|
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
long xx = XLOG2DEVMAC(x);
|
long xx = XLOG2DEVMAC(x);
|
||||||
long yy = YLOG2DEVMAC(y);
|
long yy = YLOG2DEVMAC(y);
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
@@ -1532,7 +1561,7 @@ void wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *h
|
|||||||
wxFont *theFont ) const
|
wxFont *theFont ) const
|
||||||
{
|
{
|
||||||
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
wxFont formerFont = m_font ;
|
wxFont formerFont = m_font ;
|
||||||
if ( theFont )
|
if ( theFont )
|
||||||
{
|
{
|
||||||
@@ -1644,7 +1673,7 @@ void wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *h
|
|||||||
wxCoord wxDC::GetCharWidth(void) const
|
wxCoord wxDC::GetCharWidth(void) const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
|
wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
MacInstallFont() ;
|
MacInstallFont() ;
|
||||||
int width = 0 ;
|
int width = 0 ;
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
@@ -1679,7 +1708,7 @@ wxCoord wxDC::GetCharWidth(void) const
|
|||||||
wxCoord wxDC::GetCharHeight(void) const
|
wxCoord wxDC::GetCharHeight(void) const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
|
wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
MacInstallFont() ;
|
MacInstallFont() ;
|
||||||
FontInfo fi ;
|
FontInfo fi ;
|
||||||
::GetFontInfo( &fi ) ;
|
::GetFontInfo( &fi ) ;
|
||||||
@@ -1689,7 +1718,7 @@ wxCoord wxDC::GetCharHeight(void) const
|
|||||||
void wxDC::Clear(void)
|
void wxDC::Clear(void)
|
||||||
{
|
{
|
||||||
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
wxCHECK_RET(Ok(), wxT("Invalid DC"));
|
||||||
wxMacPortSetter helper(this) ;
|
wxMacFastPortSetter helper(this) ;
|
||||||
Rect rect = { -31000 , -31000 , 31000 , 31000 } ;
|
Rect rect = { -31000 , -31000 , 31000 , 31000 } ;
|
||||||
if (m_backgroundBrush.GetStyle() != wxTRANSPARENT)
|
if (m_backgroundBrush.GetStyle() != wxTRANSPARENT)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user