X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/15fc716c570947057fcceaee6c0e0c4c757b0865..47e175a24f862aa8b7ca7dd4a2bb5957991e7f2d:/src/osx/carbon/dcclient.cpp diff --git a/src/osx/carbon/dcclient.cpp b/src/osx/carbon/dcclient.cpp index 2ade63d5cc..97929e1093 100644 --- a/src/osx/carbon/dcclient.cpp +++ b/src/osx/carbon/dcclient.cpp @@ -45,7 +45,7 @@ wxWindowDCImpl::wxWindowDCImpl( wxDC *owner, wxWindow *window ) : wxGCDCImpl( owner ) { m_window = window; - + m_ok = true ; m_window->GetSize( &m_width , &m_height); @@ -58,6 +58,7 @@ wxWindowDCImpl::wxWindowDCImpl( wxDC *owner, wxWindow *window ) if ( cg == NULL ) { SetGraphicsContext( wxGraphicsContext::Create( window ) ) ; + SetDeviceOrigin(-window->MacGetLeftBorderSize() , -window->MacGetTopBorderSize()); } else { @@ -68,7 +69,9 @@ wxWindowDCImpl::wxWindowDCImpl( wxDC *owner, wxWindow *window ) if ( window->MacGetLeftBorderSize() != 0 || window->MacGetTopBorderSize() != 0 ) CGContextTranslateCTM( cg , -window->MacGetLeftBorderSize() , -window->MacGetTopBorderSize() ); - SetGraphicsContext( wxGraphicsContext::CreateFromNative( cg ) ); + wxGraphicsContext* context = wxGraphicsContext::CreateFromNative( cg ); + context->EnableOffset(true); + SetGraphicsContext( context ); } DoSetClippingRegion( 0 , 0 , m_width , m_height ) ; @@ -107,13 +110,10 @@ wxBitmap wxWindowDCImpl::DoGetAsBitmap(const wxRect *subrect) const ControlRef handle = (ControlRef) m_window->GetHandle(); if ( !handle ) return wxNullBitmap; - + HIRect rect; CGImageRef image; CGContextRef context; - void* data; - - size_t bytesPerRow; HIViewCreateOffscreenImage( handle, 0, &rect, &image); @@ -122,11 +122,11 @@ wxBitmap wxWindowDCImpl::DoGetAsBitmap(const wxRect *subrect) const int height = subrect != NULL ? subrect->height : (int)rect.size.height ; wxBitmap bmp = wxBitmap(width, height, 32); - + context = (CGContextRef)bmp.GetHBITMAP(); - + CGContextSaveGState(context); - + CGContextTranslateCTM( context, 0, height ); CGContextScaleCTM( context, 1, -1 ); @@ -153,17 +153,23 @@ wxClientDCImpl::wxClientDCImpl( wxDC *owner ) wxClientDCImpl::wxClientDCImpl( wxDC *owner, wxWindow *window ) : wxWindowDCImpl( owner, window ) { - wxCHECK_RET( window, _T("invalid window in wxClientDCImpl") ); + wxCHECK_RET( window, wxT("invalid window in wxClientDCImpl") ); wxPoint origin = window->GetClientAreaOrigin() ; m_window->GetClientSize( &m_width , &m_height); if ( !m_window->IsShownOnScreen() ) m_width = m_height = 0; - SetDeviceOrigin( origin.x, origin.y ); + + int x0,y0; + DoGetDeviceOrigin(&x0,&y0); + SetDeviceOrigin( origin.x + x0, origin.y + y0 ); + DoSetClippingRegion( 0 , 0 , m_width , m_height ) ; } wxClientDCImpl::~wxClientDCImpl() { + if( GetGraphicsContext() && GetGraphicsContext()->GetNativeContext() ) + Flush(); } /* @@ -180,7 +186,7 @@ wxPaintDCImpl::wxPaintDCImpl( wxDC *owner ) wxPaintDCImpl::wxPaintDCImpl( wxDC *owner, wxWindow *window ) : wxWindowDCImpl( owner, window ) { - wxASSERT_MSG( window->MacGetCGContextRef() != NULL, _T("using wxPaintDC without being in a native paint event") ); + wxASSERT_MSG( window->MacGetCGContextRef() != NULL, wxT("using wxPaintDC without being in a native paint event") ); wxPoint origin = window->GetClientAreaOrigin() ; m_window->GetClientSize( &m_width , &m_height); SetDeviceOrigin( origin.x, origin.y );