From 80f0a1be1310f868972d1ea4386dd7bb1445f85e Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Fri, 20 Oct 2006 17:24:09 +0000 Subject: [PATCH] offsetting dcs correctly git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42174 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/dcclient.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/mac/carbon/dcclient.cpp b/src/mac/carbon/dcclient.cpp index 07304d1ecd..affb800da1 100644 --- a/src/mac/carbon/dcclient.cpp +++ b/src/mac/carbon/dcclient.cpp @@ -130,9 +130,21 @@ wxWindowDC::wxWindowDC(wxWindow *window) CGContextRef cg = (CGContextRef) window->MacGetCGContextRef(); m_release = false; if ( cg == NULL ) + { SetGraphicsContext( wxGraphicsContext::Create( window ) ) ; + SetDeviceOrigin( x, y ); + } else + { + CGContextSaveGState( cg ); + m_release = true ; + // make sure the context is having its origin at the wx-window coordinates of the + // view (read at the top of window.cpp about the differences) + if ( window->MacGetLeftBorderSize() != 0 || window->MacGetTopBorderSize() != 0 ) + CGContextTranslateCTM( cg , -window->MacGetLeftBorderSize() , -window->MacGetTopBorderSize() ); + SetGraphicsContext( wxGraphicsContext::CreateFromNative( cg ) ); + } m_graphicContext->SetPen( m_pen ) ; m_graphicContext->SetBrush( m_brush ) ; SetClippingRegion( 0 , 0 , m_width , m_height ) ; @@ -155,6 +167,8 @@ wxWindowDC::~wxWindowDC() #if wxMAC_USE_CORE_GRAPHICS if ( m_release && m_graphicContext ) { + CGContextRef cg = (CGContextRef) m_window->MacGetCGContextRef(); + CGContextRestoreGState(cg); // CGContextRef cg = (CGContextRef) m_graphicContext->GetNativeContext() ; } #endif @@ -194,6 +208,7 @@ wxClientDC::wxClientDC(wxWindow *window) : y = origin.y ; window->MacWindowToRootWindow( &x , &y ) ; m_window->GetClientSize( &m_width , &m_height); + SetDeviceOrigin( origin.x, origin.y ); SetClippingRegion( 0 , 0 , m_width , m_height ) ; } #else @@ -260,6 +275,7 @@ wxPaintDC::wxPaintDC(wxWindow *window) : y = origin.y ; window->MacWindowToRootWindow( &x , &y ) ; m_window->GetClientSize( &m_width , &m_height); + SetDeviceOrigin( origin.x, origin.y ); SetClippingRegion( 0 , 0 , m_width , m_height ) ; } #else -- 2.47.2