]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/graphics.cpp
textctrl always needs ATSU...
[wxWidgets.git] / src / mac / carbon / graphics.cpp
index e4b9212d91865d85b852a747a09d38603ff19cd0..4b550355b3ffaed0d6805a965d18004b1ec639e8 100644 (file)
@@ -718,8 +718,6 @@ private :
 
 wxMacCoreGraphicsFontData::wxMacCoreGraphicsFontData(wxGraphicsRenderer* renderer, const wxFont &font, const wxColour& col) : wxGraphicsObjectRefData( renderer )
 {
-    m_macATSUIStyle = NULL;
-    OSStatus status = noErr;
     m_colour = col;
     m_underlined = font.GetUnderlined();
 
@@ -727,6 +725,8 @@ wxMacCoreGraphicsFontData::wxMacCoreGraphicsFontData(wxGraphicsRenderer* rendere
     m_ctFont.reset( wxCFRetain((CTFontRef) font.MacGetCTFont()) );
 #endif
 #if wxMAC_USE_ATSU_TEXT
+    OSStatus status = noErr;
+    m_macATSUIStyle = NULL;
 
     status = ATSUCreateAndCopyStyle( (ATSUStyle) font.MacGetATSUStyle() , &m_macATSUIStyle );
 
@@ -2166,6 +2166,7 @@ public :
     // Context
 
     virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc);
+    virtual wxGraphicsContext * CreateContext( const wxMemoryDC& dc);
 
     virtual wxGraphicsContext * CreateContextFromNativeContext( void * context );
 
@@ -2218,18 +2219,26 @@ wxGraphicsRenderer* wxGraphicsRenderer::GetDefaultRenderer()
     return &gs_MacCoreGraphicsRenderer;
 }
 
-wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateContext( const wxWindowDC& dc)
+wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateContext( const wxWindowDC& dc )
 {
-    wxMemoryDC* mdc = wxDynamicCast(&dc, wxMemoryDC);
-    if ( mdc )
-    {
-        return new wxMacCoreGraphicsContext(this, 
-            (CGContextRef)mdc->GetGraphicsContext()->GetNativeContext());
-    }
-    else
-    {
-        return new wxMacCoreGraphicsContext(this,(CGContextRef)dc.GetWindow()->MacGetCGContextRef() );
-    }
+    const wxDCImpl* impl = dc.GetImpl();
+    wxWindowDCImpl *win_impl = wxDynamicCast( impl, wxWindowDCImpl );
+    if (win_impl)
+        return new wxMacCoreGraphicsContext( this,
+           (CGContextRef)(win_impl->GetWindow()->MacGetCGContextRef()) );
+           
+    return NULL;
+}
+
+wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateContext( const wxMemoryDC& dc )
+{
+    const wxDCImpl* impl = dc.GetImpl();
+    wxMemoryDCImpl *mem_impl = wxDynamicCast( impl, wxMemoryDCImpl );
+    if (mem_impl)
+        return new wxMacCoreGraphicsContext( this, 
+            (CGContextRef)(mem_impl->GetGraphicsContext()->GetNativeContext()) );
+            
+    return NULL;
 }
 
 wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateContextFromNativeContext( void * context )