new graphics context implementation
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42160 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -123,34 +123,24 @@ wxWindowDC::wxWindowDC(wxWindow *window)
|
|||||||
int x , y ;
|
int x , y ;
|
||||||
x = y = 0 ;
|
x = y = 0 ;
|
||||||
window->MacWindowToRootWindow( &x , &y ) ;
|
window->MacWindowToRootWindow( &x , &y ) ;
|
||||||
m_macPort = UMAGetWindowPort( windowref ) ;
|
|
||||||
m_ok = true ;
|
m_ok = true ;
|
||||||
|
|
||||||
#if wxMAC_USE_CORE_GRAPHICS
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
m_macLocalOriginInPort.x = x ;
|
m_window->GetSize( &m_width , &m_height);
|
||||||
m_macLocalOriginInPort.y = y ;
|
CGContextRef cg = (CGContextRef) window->MacGetCGContextRef();
|
||||||
|
m_release = false;
|
||||||
if ( window->MacGetCGContextRef() )
|
if ( cg == NULL )
|
||||||
{
|
SetGraphicsContext( wxGraphicsContext::Create( window ) ) ;
|
||||||
m_graphicContext = new wxMacCGContext( (CGContextRef) window->MacGetCGContextRef() ) ;
|
else
|
||||||
m_graphicContext->SetPen( m_pen ) ;
|
SetGraphicsContext( wxGraphicsContext::CreateFromNative( cg ) );
|
||||||
m_graphicContext->SetBrush( m_brush ) ;
|
m_graphicContext->SetPen( m_pen ) ;
|
||||||
}
|
m_graphicContext->SetBrush( m_brush ) ;
|
||||||
else
|
SetClippingRegion( 0 , 0 , m_width , m_height ) ;
|
||||||
{
|
|
||||||
// as out of order redraw is not supported under CQ, we have to create a qd port for these
|
|
||||||
// situations
|
|
||||||
m_macLocalOrigin.x = x ;
|
|
||||||
m_macLocalOrigin.y = y ;
|
|
||||||
|
|
||||||
m_graphicContext = new wxMacCGContext( (CGrafPtr) m_macPort ) ;
|
|
||||||
m_graphicContext->SetPen( m_pen ) ;
|
|
||||||
m_graphicContext->SetBrush( m_brush ) ;
|
|
||||||
}
|
|
||||||
// there is no out-of-order drawing on OSX
|
|
||||||
#else
|
#else
|
||||||
m_macLocalOrigin.x = x ;
|
m_macLocalOrigin.x = x ;
|
||||||
m_macLocalOrigin.y = y ;
|
m_macLocalOrigin.y = y ;
|
||||||
|
m_macPort = UMAGetWindowPort( windowref ) ;
|
||||||
|
|
||||||
CopyRgn( (RgnHandle) window->MacGetVisibleRegion(true).GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ;
|
CopyRgn( (RgnHandle) window->MacGetVisibleRegion(true).GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ;
|
||||||
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
|
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
|
||||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
||||||
@@ -162,13 +152,26 @@ wxWindowDC::wxWindowDC(wxWindow *window)
|
|||||||
|
|
||||||
wxWindowDC::~wxWindowDC()
|
wxWindowDC::~wxWindowDC()
|
||||||
{
|
{
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
if ( m_release && m_graphicContext )
|
||||||
|
{
|
||||||
|
// CGContextRef cg = (CGContextRef) m_graphicContext->GetNativeContext() ;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowDC::DoGetSize( int* width, int* height ) const
|
void wxWindowDC::DoGetSize( int* width, int* height ) const
|
||||||
{
|
{
|
||||||
wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") );
|
wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") );
|
||||||
|
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
if ( width )
|
||||||
|
*width = m_width;
|
||||||
|
if ( height )
|
||||||
|
*height = m_height;
|
||||||
|
#else
|
||||||
m_window->GetSize(width, height);
|
m_window->GetSize(width, height);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -180,6 +183,20 @@ wxClientDC::wxClientDC()
|
|||||||
m_window = NULL ;
|
m_window = NULL ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
wxClientDC::wxClientDC(wxWindow *window) :
|
||||||
|
wxWindowDC( window )
|
||||||
|
{
|
||||||
|
wxPoint origin = window->GetClientAreaOrigin() ;
|
||||||
|
wxSize size = window->GetClientSize() ;
|
||||||
|
int x , y ;
|
||||||
|
x = origin.x ;
|
||||||
|
y = origin.y ;
|
||||||
|
window->MacWindowToRootWindow( &x , &y ) ;
|
||||||
|
m_window->GetClientSize( &m_width , &m_height);
|
||||||
|
SetClippingRegion( 0 , 0 , m_width , m_height ) ;
|
||||||
|
}
|
||||||
|
#else
|
||||||
wxClientDC::wxClientDC(wxWindow *window)
|
wxClientDC::wxClientDC(wxWindow *window)
|
||||||
{
|
{
|
||||||
m_window = window ;
|
m_window = window ;
|
||||||
@@ -197,27 +214,6 @@ wxClientDC::wxClientDC(wxWindow *window)
|
|||||||
m_macPort = UMAGetWindowPort( windowref ) ;
|
m_macPort = UMAGetWindowPort( windowref ) ;
|
||||||
m_ok = true ;
|
m_ok = true ;
|
||||||
|
|
||||||
#if wxMAC_USE_CORE_GRAPHICS
|
|
||||||
m_macLocalOriginInPort.x = x ;
|
|
||||||
m_macLocalOriginInPort.y = y ;
|
|
||||||
if ( window->MacGetCGContextRef() )
|
|
||||||
{
|
|
||||||
m_graphicContext = new wxMacCGContext( (CGContextRef) window->MacGetCGContextRef() ) ;
|
|
||||||
m_graphicContext->SetPen( m_pen ) ;
|
|
||||||
m_graphicContext->SetBrush( m_brush ) ;
|
|
||||||
SetClippingRegion( 0 , 0 , size.x , size.y ) ;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// as out of order redraw is not supported under CQ,
|
|
||||||
// we have to create a QD port for these situations
|
|
||||||
m_macLocalOrigin.x = x ;
|
|
||||||
m_macLocalOrigin.y = y ;
|
|
||||||
m_graphicContext = new wxMacCGContext( (CGrafPtr) m_macPort ) ;
|
|
||||||
m_graphicContext->SetPen( m_pen ) ;
|
|
||||||
m_graphicContext->SetBrush( m_brush ) ;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
m_macLocalOrigin.x = x ;
|
m_macLocalOrigin.x = x ;
|
||||||
m_macLocalOrigin.y = y ;
|
m_macLocalOrigin.y = y ;
|
||||||
SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , origin.x , origin.y , origin.x + size.x , origin.y + size.y ) ;
|
SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , origin.x , origin.y , origin.x + size.x , origin.y + size.y ) ;
|
||||||
@@ -225,31 +221,24 @@ wxClientDC::wxClientDC(wxWindow *window)
|
|||||||
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , -origin.x , -origin.y ) ;
|
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , -origin.x , -origin.y ) ;
|
||||||
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
|
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
|
||||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ;
|
CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ;
|
||||||
#endif
|
|
||||||
|
|
||||||
SetBackground(MacGetBackgroundBrush(window));
|
SetBackground(MacGetBackgroundBrush(window));
|
||||||
SetFont( window->GetFont() ) ;
|
SetFont( window->GetFont() ) ;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
wxClientDC::~wxClientDC()
|
wxClientDC::~wxClientDC()
|
||||||
{
|
{
|
||||||
#if wxMAC_USE_CORE_GRAPHICS
|
|
||||||
/*
|
|
||||||
if ( m_window->MacGetCGContextRef() == 0)
|
|
||||||
{
|
|
||||||
CGContextRef cgContext = (wxMacCGContext*)(m_graphicContext)->GetNativeContext() ;
|
|
||||||
CGContextFlush( cgContext ) ;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !wxMAC_USE_CORE_GRAPHICS
|
||||||
void wxClientDC::DoGetSize(int *width, int *height) const
|
void wxClientDC::DoGetSize(int *width, int *height) const
|
||||||
{
|
{
|
||||||
wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") );
|
wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") );
|
||||||
|
|
||||||
m_window->GetClientSize( width, height );
|
m_window->GetClientSize( width, height );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* wxPaintDC
|
* wxPaintDC
|
||||||
@@ -260,6 +249,20 @@ wxPaintDC::wxPaintDC()
|
|||||||
m_window = NULL ;
|
m_window = NULL ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
|
wxPaintDC::wxPaintDC(wxWindow *window) :
|
||||||
|
wxWindowDC( window )
|
||||||
|
{
|
||||||
|
wxPoint origin = window->GetClientAreaOrigin() ;
|
||||||
|
wxSize size = window->GetClientSize() ;
|
||||||
|
int x , y ;
|
||||||
|
x = origin.x ;
|
||||||
|
y = origin.y ;
|
||||||
|
window->MacWindowToRootWindow( &x , &y ) ;
|
||||||
|
m_window->GetClientSize( &m_width , &m_height);
|
||||||
|
SetClippingRegion( 0 , 0 , m_width , m_height ) ;
|
||||||
|
}
|
||||||
|
#else
|
||||||
wxPaintDC::wxPaintDC(wxWindow *window)
|
wxPaintDC::wxPaintDC(wxWindow *window)
|
||||||
{
|
{
|
||||||
m_window = window ;
|
m_window = window ;
|
||||||
@@ -275,8 +278,6 @@ wxPaintDC::wxPaintDC(wxWindow *window)
|
|||||||
m_ok = true ;
|
m_ok = true ;
|
||||||
|
|
||||||
#if wxMAC_USE_CORE_GRAPHICS
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
m_macLocalOriginInPort.x = x ;
|
|
||||||
m_macLocalOriginInPort.y = y ;
|
|
||||||
if ( window->MacGetCGContextRef() )
|
if ( window->MacGetCGContextRef() )
|
||||||
{
|
{
|
||||||
m_graphicContext = new wxMacCGContext( (CGContextRef) window->MacGetCGContextRef() ) ;
|
m_graphicContext = new wxMacCGContext( (CGContextRef) window->MacGetCGContextRef() ) ;
|
||||||
@@ -305,14 +306,17 @@ wxPaintDC::wxPaintDC(wxWindow *window)
|
|||||||
|
|
||||||
SetFont( window->GetFont() ) ;
|
SetFont( window->GetFont() ) ;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
wxPaintDC::~wxPaintDC()
|
wxPaintDC::~wxPaintDC()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !wxMAC_USE_CORE_GRAPHICS
|
||||||
void wxPaintDC::DoGetSize(int *width, int *height) const
|
void wxPaintDC::DoGetSize(int *width, int *height) const
|
||||||
{
|
{
|
||||||
wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") );
|
wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") );
|
||||||
|
|
||||||
m_window->GetClientSize( width, height );
|
m_window->GetClientSize( width, height );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
Reference in New Issue
Block a user