X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3e700936123465187e5c662a0a3d11f5e91fbd5f..8df26961603924444b44272d34e0c2cab95cfdb5:/src/generic/graphicc.cpp diff --git a/src/generic/graphicc.cpp b/src/generic/graphicc.cpp index 79493bbb99..b70fbd4f9a 100644 --- a/src/generic/graphicc.cpp +++ b/src/generic/graphicc.cpp @@ -34,7 +34,7 @@ #include "wx/module.h" #endif -#include "wx/graphics.h" +#include "wx/private/graphics.h" #include "wx/rawbmp.h" #include @@ -99,6 +99,7 @@ static inline double RadToDeg(double deg) #ifdef __WXGTK__ #include #include "wx/fontutil.h" +#include "wx/gtk/dc.h" #endif #ifdef __WXMSW__ @@ -323,6 +324,7 @@ class WXDLLIMPEXP_CORE wxCairoContext : public wxGraphicsContext public: wxCairoContext( wxGraphicsRenderer* renderer, const wxWindowDC& dc ); + wxCairoContext( wxGraphicsRenderer* renderer, const wxMemoryDC& dc ); #ifdef __WXGTK__ wxCairoContext( wxGraphicsRenderer* renderer, GdkDrawable *drawable ); #endif @@ -1036,7 +1038,25 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxWindowDC& : wxGraphicsContext(renderer) { #ifdef __WXGTK__ - Init( gdk_cairo_create( dc.m_window ) ); + wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl(); + Init( gdk_cairo_create( impldc->GetGDKWindow() ) ); +#endif +#ifdef __WXMAC__ + int width, height; + dc.GetSize( &width, &height ); + CGContextRef cgcontext = (CGContextRef)dc.GetWindow()->MacGetCGContextRef(); + cairo_surface_t* surface = cairo_quartz_surface_create_for_cg_context(cgcontext, width, height); + Init( cairo_create( surface ) ); + cairo_surface_destroy( surface ); +#endif +} + +wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxMemoryDC& dc ) +: wxGraphicsContext(renderer) +{ +#ifdef __WXGTK__ + wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl(); + Init( gdk_cairo_create( impldc->GetGDKWindow() ) ); #endif #ifdef __WXMAC__ int width, height; @@ -1328,7 +1348,7 @@ void wxCairoContext::DrawText( const wxString &str, wxDouble x, wxDouble y ) return; #ifdef __WXGTK__ - const wxCharBuffer data = wxConvUTF8.cWC2MB( str ); + const wxCharBuffer data = str.utf8_str(); if ( !data ) return; size_t datalen = strlen(data); @@ -1374,7 +1394,7 @@ void wxCairoContext::GetTextExtent( const wxString &str, wxDouble *width, wxDoub PangoLayout *layout = pango_cairo_create_layout (m_context); pango_layout_set_font_description( layout, ((wxCairoFontData*)m_font.GetRefData())->GetFont()); - const wxCharBuffer data = wxConvUTF8.cWC2MB( str ); + const wxCharBuffer data = str.utf8_str(); if ( !data ) { return; @@ -1460,10 +1480,7 @@ public : // Context virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc); - -#ifdef __WXMSW__ virtual wxGraphicsContext * CreateContext( const wxMemoryDC& dc); -#endif virtual wxGraphicsContext * CreateContextFromNativeContext( void * context ); @@ -1526,12 +1543,10 @@ wxGraphicsContext * wxCairoRenderer::CreateContext( const wxWindowDC& dc) return new wxCairoContext(this,dc); } -#ifdef __WXMSW__ wxGraphicsContext * wxCairoRenderer::CreateContext( const wxMemoryDC& dc) { - return NULL; + return new wxCairoContext(this,dc); } -#endif wxGraphicsContext * wxCairoRenderer::CreateContextFromNativeContext( void * context ) {