// Purpose: cairo device context class
// Author: Stefan Csomor
// Modified by:
-// Created: 01/02/97
+// Created: 2006-10-03
// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
+// Copyright: (c) 2006 Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/dc.h"
-// For compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
#ifdef __BORLANDC__
#pragma hdrstop
#endif
virtual void AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r ) ;
*/
- cairo_path_t* GetPath() const;
+ // returns the native path
+ virtual void * GetNativePath() const ;
+
+ // give the native path returned by GetNativePath() back (there might be some deallocations necessary)
+ virtual void UnGetNativePath(void *p) ;
+
private :
cairo_t* m_pathContext;
};
cairo_destroy(m_pathContext);
}
-cairo_path_t* wxCairoPath::GetPath() const
+void* wxCairoPath::GetNativePath() const
{
return cairo_copy_path(m_pathContext) ;
}
+void wxCairoPath::UnGetNativePath(void *p)
+{
+ cairo_path_destroy((cairo_path_t*)p);
+}
+
//
// The Primitives
//
virtual ~wxCairoContext();
virtual void Clip( const wxRegion ®ion );
+
+ // clips drawings to the rect
+ virtual void Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h );
+
+ // resets the clipping to original extent
+ virtual void ResetClip();
+
+ virtual void * GetNativeContext();
+
virtual void StrokePath( const wxGraphicsPath *p );
virtual void FillPath( const wxGraphicsPath *p , int fillStyle = wxWINDING_RULE );
}
-void wxCairoContext::Clip( const wxRegion ®ion )
+void wxCairoContext::Clip( const wxRegion & WXUNUSED(region) )
+{
+// TODO
+}
+
+void wxCairoContext::Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h )
{
- // ClipCGContextToRegion ( m_context, &bounds , (RgnHandle) dc->m_macCurrentClipRgn );
+// TODO
}
-void wxCairoContext::StrokePath( const wxGraphicsPath *p )
+void wxCairoContext::ResetClip()
+{
+// TODO
+}
+
+
+void wxCairoContext::StrokePath( const wxGraphicsPath *path )
{
if ( m_penTransparent )
return;
- const wxCairoPath* path = dynamic_cast< const wxCairoPath*>( p );
- cairo_path_t* cp = path->GetPath() ;
+ cairo_path_t* cp = (cairo_path_t*) path->GetNativePath() ;
cairo_append_path(m_context,cp);
// setup pen
if ( userLengths )
delete[] userLengths;
cairo_stroke(m_context);
- cairo_path_destroy(cp);
+ wxConstCast(path, wxGraphicsPath)->UnGetNativePath(cp);
}
-void wxCairoContext::FillPath( const wxGraphicsPath *p , int fillStyle )
+void wxCairoContext::FillPath( const wxGraphicsPath *path , int fillStyle )
{
if ( !m_brushTransparent )
{
- const wxCairoPath* path = dynamic_cast< const wxCairoPath*>( p );
- cairo_path_t* cp = path->GetPath() ;
+ cairo_path_t* cp = (cairo_path_t*) path->GetNativePath() ;
cairo_append_path(m_context,cp);
if ( m_brushPattern )
cairo_set_fill_rule(m_context,fillStyle==wxODDEVEN_RULE ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
cairo_fill(m_context);
- cairo_path_destroy(cp);
+ wxConstCast(path, wxGraphicsPath)->UnGetNativePath(cp);
}
}
// TODO FIX SIZE
}
+void * wxCairoContext::GetNativeContext()
+{
+ return m_context;
+}
+
wxGraphicsContext* wxGraphicsContext::Create( const wxWindowDC& dc )
{
return new wxCairoContext(dc);
}
+wxGraphicsContext* wxGraphicsContext::Create( wxWindow * window )
+{
+ return NULL; // TODO
+}
+
+wxGraphicsContext* wxGraphicsContext::CreateFromNative( void * context )
+{
+ return NULL; // TODO
+}
+
#endif // wxUSE_GRAPHICS_CONTEXT