+public :
+ wxCairoRenderer() {}
+
+ virtual ~wxCairoRenderer() {}
+
+ // Context
+
+ virtual wxGraphicsContext * CreateContext( const wxWindowDC& dc);
+ virtual wxGraphicsContext * CreateContext( const wxMemoryDC& dc);
+ virtual wxGraphicsContext * CreateContext( const wxPrinterDC& dc);
+
+ virtual wxGraphicsContext * CreateContextFromNativeContext( void * context );
+
+ virtual wxGraphicsContext * CreateContextFromNativeWindow( void * window );
+
+ virtual wxGraphicsContext * CreateContext( wxWindow* window );
+
+ virtual wxGraphicsContext * CreateMeasuringContext();
+
+ // Path
+
+ virtual wxGraphicsPath CreatePath();
+
+ // Matrix
+
+ virtual wxGraphicsMatrix CreateMatrix( wxDouble a=1.0, wxDouble b=0.0, wxDouble c=0.0, wxDouble d=1.0,
+ wxDouble tx=0.0, wxDouble ty=0.0);
+
+
+ virtual wxGraphicsPen CreatePen(const wxPen& pen) ;
+
+ virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) ;
+
+ // sets the brush to a linear gradient, starting at (x1,y1) with color c1 to (x2,y2) with color c2
+ virtual wxGraphicsBrush CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
+ const wxColour&c1, const wxColour&c2) ;
+
+ // sets the brush to a radial gradient originating at (xo,yc) with color oColor and ends on a circle around (xc,yc)
+ // with radius r and color cColor
+ virtual wxGraphicsBrush CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius,
+ const wxColour &oColor, const wxColour &cColor) ;
+
+ // sets the font
+ virtual wxGraphicsFont CreateFont( const wxFont &font , const wxColour &col = *wxBLACK ) ;
+
+ // create a native bitmap representation
+#if 0
+ virtual wxGraphicsBitmap CreateBitmap( const wxBitmap &bitmap )
+ {
+ return wxGraphicsBitmap;
+ }
+
+ // create a subimage from a native image representation
+ virtual wxGraphicsBitmap CreateSubBitmap( const wxGraphicsBitmap &bitmap, wxDouble x, wxDouble y, wxDouble w, wxDouble h )
+ {
+ return wxGraphicsBitmap;
+ }
+#endif
+
+private :
+ DECLARE_DYNAMIC_CLASS_NO_COPY(wxCairoRenderer)
+} ;
+
+//-----------------------------------------------------------------------------
+// wxCairoRenderer implementation
+//-----------------------------------------------------------------------------
+
+IMPLEMENT_DYNAMIC_CLASS(wxCairoRenderer,wxGraphicsRenderer)
+
+static wxCairoRenderer gs_cairoGraphicsRenderer;
+// temporary hack to allow creating a cairo context on any platform
+extern wxGraphicsRenderer* gCairoRenderer;
+wxGraphicsRenderer* gCairoRenderer = &gs_cairoGraphicsRenderer;
+
+#ifdef __WXGTK__
+wxGraphicsRenderer* wxGraphicsRenderer::GetDefaultRenderer()
+{
+ return &gs_cairoGraphicsRenderer;
+}
+#endif
+
+wxGraphicsContext * wxCairoRenderer::CreateContext( const wxWindowDC& dc)
+{
+ return new wxCairoContext(this,dc);
+}
+
+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);
+}
+
+
+wxGraphicsContext * wxCairoRenderer::CreateContextFromNativeWindow( void * window )
+{
+#ifdef __WXGTK__
+ return new wxCairoContext(this,(GdkDrawable*)window);
+#else
+ return NULL;
+#endif
+}
+
+wxGraphicsContext * wxCairoRenderer::CreateMeasuringContext()
+{
+ return NULL;
+ // TODO
+}
+
+wxGraphicsContext * wxCairoRenderer::CreateContext( wxWindow* window )
+{
+ return new wxCairoContext(this, window );
+}
+
+// Path
+
+wxGraphicsPath wxCairoRenderer::CreatePath()
+{
+ wxGraphicsPath path;
+ path.SetRefData( new wxCairoPathData(this) );
+ return path;
+}
+
+
+// Matrix
+
+wxGraphicsMatrix wxCairoRenderer::CreateMatrix( wxDouble a, wxDouble b, wxDouble c, wxDouble d,
+ wxDouble tx, wxDouble ty)
+
+{
+ wxGraphicsMatrix m;
+ wxCairoMatrixData* data = new wxCairoMatrixData( this );
+ data->Set( a,b,c,d,tx,ty ) ;
+ m.SetRefData(data);
+ return m;
+}
+
+wxGraphicsPen wxCairoRenderer::CreatePen(const wxPen& pen)
+{
+ if ( !pen.Ok() || pen.GetStyle() == wxPENSTYLE_TRANSPARENT )
+ return wxNullGraphicsPen;
+ else
+ {
+ wxGraphicsPen p;
+ p.SetRefData(new wxCairoPenData( this, pen ));
+ return p;
+ }
+}
+
+wxGraphicsBrush wxCairoRenderer::CreateBrush(const wxBrush& brush )
+{
+ if ( !brush.Ok() || brush.GetStyle() == wxBRUSHSTYLE_TRANSPARENT )
+ return wxNullGraphicsBrush;
+ else
+ {
+ wxGraphicsBrush p;
+ p.SetRefData(new wxCairoBrushData( this, brush ));
+ return p;
+ }
+}
+
+// sets the brush to a linear gradient, starting at (x1,y1) with color c1 to (x2,y2) with color c2
+wxGraphicsBrush wxCairoRenderer::CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,
+ const wxColour&c1, const wxColour&c2)
+{
+ wxGraphicsBrush p;
+ wxCairoBrushData* d = new wxCairoBrushData( this );
+ d->CreateLinearGradientBrush(x1, y1, x2, y2, c1, c2);
+ p.SetRefData(d);
+ return p;
+}
+
+// sets the brush to a radial gradient originating at (xo,yc) with color oColor and ends on a circle around (xc,yc)
+// with radius r and color cColor
+wxGraphicsBrush wxCairoRenderer::CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius,
+ const wxColour &oColor, const wxColour &cColor)
+{
+ wxGraphicsBrush p;
+ wxCairoBrushData* d = new wxCairoBrushData( this );
+ d->CreateRadialGradientBrush(xo,yo,xc,yc,radius,oColor,cColor);
+ p.SetRefData(d);
+ return p;
+}
+
+// sets the font
+wxGraphicsFont wxCairoRenderer::CreateFont( const wxFont &font , const wxColour &col )
+{
+ if ( font.Ok() )
+ {
+ wxGraphicsFont p;
+ p.SetRefData(new wxCairoFontData( this , font, col ));
+ return p;
+ }
+ else
+ return wxNullGraphicsFont;