X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/514fd350e8b074ad13960adc1b51e4a6058c539d..5dafb071ba85e7329aa4a0ac176f3ec8e13e55dc:/src/mac/carbon/dcmemory.cpp diff --git a/src/mac/carbon/dcmemory.cpp b/src/mac/carbon/dcmemory.cpp index 8985e4edc4..541ad66c4e 100644 --- a/src/mac/carbon/dcmemory.cpp +++ b/src/mac/carbon/dcmemory.cpp @@ -12,6 +12,7 @@ #include "wx/wxprec.h" #include "wx/dcmemory.h" +#include "wx/graphics.h" #include "wx/mac/private.h" @@ -21,7 +22,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxPaintDC) -wxMemoryDC::wxMemoryDC() +wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap ) : m_selected() { m_ok = true; @@ -30,6 +31,9 @@ wxMemoryDC::wxMemoryDC() SetPen(*wxBLACK_PEN); SetFont(*wxNORMAL_FONT); m_ok = false; + + if ( bitmap.IsOk() ) + SelectObject(bitmap); } wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) ) @@ -49,7 +53,7 @@ wxMemoryDC::~wxMemoryDC() { #if wxMAC_USE_CORE_GRAPHICS m_selected.EndRawAccess() ; - CGContextRef bmCtx = ((wxMacCGContext*)(m_graphicContext))->GetNativeContext() ; + CGContextRef bmCtx = (CGContextRef) m_graphicContext->GetNativeContext() ; delete m_graphicContext ; m_graphicContext = NULL ; CGContextRelease( bmCtx ) ; @@ -65,7 +69,7 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) { #if wxMAC_USE_CORE_GRAPHICS m_selected.EndRawAccess() ; - CGContextRef bmCtx = ((wxMacCGContext*)(m_graphicContext))->GetNativeContext() ; + CGContextRef bmCtx = (CGContextRef) m_graphicContext->GetNativeContext() ; delete m_graphicContext ; m_graphicContext = NULL ; CGContextRelease( bmCtx ) ; @@ -86,6 +90,8 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) int bytesPerPixel = 4 ; int w = bitmap.GetWidth() ; int h = bitmap.GetHeight() ; + m_width = w; + m_height = h; // TODO: should this be kCGImageAlphaPremultiplied[First,Last] ? CGImageAlphaInfo a = kCGImageAlphaNoneSkipFirst ; @@ -102,9 +108,10 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) CGContextTranslateCTM( bmCtx , 0 , m_selected.GetHeight() ) ; CGContextScaleCTM( bmCtx , 1 , -1 ) ; - m_graphicContext = new wxMacCGContext( bmCtx ) ; + SetGraphicsContext( wxGraphicsContext::CreateFromNative( bmCtx ) ); m_graphicContext->SetPen( m_pen ) ; m_graphicContext->SetBrush( m_brush ) ; + m_graphicContext->SetFont( m_font ) ; } m_ok = (m_graphicContext != NULL) ;