X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/524c47aa3adf2af11a3069fd5da035a604f08f66..a12482a357a2ef5feb50f9ace8e173f9aed680e0:/src/osx/carbon/dcclient.cpp diff --git a/src/osx/carbon/dcclient.cpp b/src/osx/carbon/dcclient.cpp index 2a7404bd44..4387f6c2a8 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); @@ -96,6 +96,7 @@ void wxWindowDCImpl::DoGetSize( int* width, int* height ) const *height = m_height; } +#if wxOSX_USE_CARBON wxBitmap wxWindowDCImpl::DoGetAsBitmap(const wxRect *subrect) const { // wxScreenDC is derived from wxWindowDC, so a screen dc will @@ -103,17 +104,13 @@ wxBitmap wxWindowDCImpl::DoGetAsBitmap(const wxRect *subrect) const if (!m_window) return wxNullBitmap; -#if wxOSX_USE_CARBON 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 +119,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 ); @@ -136,10 +133,8 @@ wxBitmap wxWindowDCImpl::DoGetAsBitmap(const wxRect *subrect) const CGContextRestoreGState(context); return bmp; -#else - return wxNullBitmap; -#endif } +#endif /* * wxClientDCImpl @@ -155,7 +150,7 @@ 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() ) @@ -166,6 +161,8 @@ wxClientDCImpl::wxClientDCImpl( wxDC *owner, wxWindow *window ) : wxClientDCImpl::~wxClientDCImpl() { + if( GetGraphicsContext() && GetGraphicsContext()->GetNativeContext() ) + Flush(); } /* @@ -182,6 +179,7 @@ wxPaintDCImpl::wxPaintDCImpl( wxDC *owner ) wxPaintDCImpl::wxPaintDCImpl( wxDC *owner, wxWindow *window ) : wxWindowDCImpl( owner, window ) { + 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 );