X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d974a4945c7325a83dab9bcb83a5021f77cb65eb..3201a1046ba71ba8e5ef2ed694fde34d12f743f3:/src/generic/graphicc.cpp diff --git a/src/generic/graphicc.cpp b/src/generic/graphicc.cpp index 0c6ff55590..08b92ef8c7 100644 --- a/src/generic/graphicc.cpp +++ b/src/generic/graphicc.cpp @@ -107,7 +107,7 @@ static inline double RadToDeg(double deg) #endif #ifdef __WXMAC__ -#include "wx/mac/private.h" +#include "wx/osx/private.h" #include #include #endif @@ -325,6 +325,7 @@ class WXDLLIMPEXP_CORE wxCairoContext : public wxGraphicsContext public: wxCairoContext( wxGraphicsRenderer* renderer, const wxWindowDC& dc ); wxCairoContext( wxGraphicsRenderer* renderer, const wxMemoryDC& dc ); + wxCairoContext( wxGraphicsRenderer* renderer, const wxPrinterDC& dc ); #ifdef __WXGTK__ wxCairoContext( wxGraphicsRenderer* renderer, GdkDrawable *drawable ); #endif @@ -1034,13 +1035,49 @@ public : bool m_offset; } ; +wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxPrinterDC& dc ) +: wxGraphicsContext(renderer) +{ +#ifdef __WXGTK20__ + const wxDCImpl *impl = dc.GetImpl(); + Init( (cairo_t*) impl->GetCairoContext() ); + + wxPoint org = dc.GetDeviceOrigin(); + cairo_translate( m_context, org.x, org.y ); + + double sx,sy; + dc.GetUserScale( &sx, &sy ); + cairo_scale( m_context, sx, sy ); + + org = dc.GetLogicalOrigin(); + cairo_translate( m_context, -org.x, -org.y ); +#endif +} + wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxWindowDC& dc ) : wxGraphicsContext(renderer) { -#ifdef __WXGTK__ +#ifdef __WXGTK20__ wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl(); Init( gdk_cairo_create( impldc->GetGDKWindow() ) ); + +#if 0 + wxGraphicsMatrix matrix = CreateMatrix(); + + wxPoint org = dc.GetDeviceOrigin(); + matrix.Translate( org.x, org.y ); + + org = dc.GetLogicalOrigin(); + matrix.Translate( -org.x, -org.y ); + + double sx,sy; + dc.GetUserScale( &sx, &sy ); + matrix.Scale( sx, sy ); + + ConcatTransform( matrix ); +#endif #endif + #ifdef __WXMAC__ int width, height; dc.GetSize( &width, &height ); @@ -1054,10 +1091,27 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxWindowDC& wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxMemoryDC& dc ) : wxGraphicsContext(renderer) { -#ifdef __WXGTK__ +#ifdef __WXGTK20__ wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl(); Init( gdk_cairo_create( impldc->GetGDKWindow() ) ); + +#if 0 + wxGraphicsMatrix matrix = CreateMatrix(); + + wxPoint org = dc.GetDeviceOrigin(); + matrix.Translate( org.x, org.y ); + + org = dc.GetLogicalOrigin(); + matrix.Translate( -org.x, -org.y ); + + double sx,sy; + dc.GetUserScale( &sx, &sy ); + matrix.Scale( sx, sy ); + + ConcatTransform( matrix ); #endif +#endif + #ifdef __WXMAC__ int width, height; dc.GetSize( &width, &height ); @@ -1068,7 +1122,7 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxMemoryDC& #endif } -#ifdef __WXGTK__ +#ifdef __WXGTK20__ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, GdkDrawable *drawable ) : wxGraphicsContext(renderer) { @@ -1481,6 +1535,7 @@ public : virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc); virtual wxGraphicsContext * CreateContext( const wxMemoryDC& dc); + virtual wxGraphicsContext * CreateContext( const wxPrinterDC& dc); virtual wxGraphicsContext * CreateContextFromNativeContext( void * context ); @@ -1562,6 +1617,18 @@ wxGraphicsContext * wxCairoRenderer::CreateContext( const wxMemoryDC& dc) return new wxCairoContext(this,dc); } +wxGraphicsContext * wxCairoRenderer::CreateContext( const wxPrinterDC& dc) +{ +#ifdef __WXGTK20__ + const wxDCImpl *impl = dc.GetImpl(); + cairo_t* context = (cairo_t*) impl->GetCairoContext(); + if (context) + return new wxCairoContext(this,dc); + else +#endif + return NULL; +} + wxGraphicsContext * wxCairoRenderer::CreateContextFromNativeContext( void * context ) { return new wxCairoContext(this,(cairo_t*)context);