]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/graphicc.cpp
Adding support for item font/style/color customization, unfortunately, it does not...
[wxWidgets.git] / src / generic / graphicc.cpp
index bd612032c88669359880e783b1f7ab4ed937ef60..83e1eda97b370daa9f84630b99f6493bd4d19159 100755 (executable)
@@ -144,7 +144,12 @@ public :
     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;
 };
@@ -161,11 +166,16 @@ wxCairoPath::~wxCairoPath()
     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
 //
@@ -241,12 +251,12 @@ public:
 
     // 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();
-       
+    // 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 );
 
@@ -323,20 +333,19 @@ void wxCairoContext::Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h )
 {
 // TODO
 }
-       
+
 void wxCairoContext::ResetClip()
 {
 // TODO
 }
 
 
-void wxCairoContext::StrokePath( const wxGraphicsPath *p )
+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
@@ -517,15 +526,14 @@ void wxCairoContext::StrokePath( const wxGraphicsPath *p )
     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 )
@@ -542,7 +550,7 @@ void wxCairoContext::FillPath( const wxGraphicsPath *p , int fillStyle )
 
         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);
     }
 }
 
@@ -883,7 +891,7 @@ void wxCairoContext::SetFont( const wxFont &font )
 
 void * wxCairoContext::GetNativeContext() 
 {
-       return m_context;
+    return m_context;
 }
 
 wxGraphicsContext* wxGraphicsContext::Create( const wxWindowDC& dc )
@@ -893,12 +901,12 @@ wxGraphicsContext* wxGraphicsContext::Create( const wxWindowDC& dc )
 
 wxGraphicsContext* wxGraphicsContext::Create( wxWindow * window )
 {
-       return NULL; // TODO
+    return NULL; // TODO
 }
 
 wxGraphicsContext* wxGraphicsContext::CreateFromNative( void * context )
 {
-       return NULL; // TODO
+    return NULL; // TODO
 }
 
 #endif  // wxUSE_GRAPHICS_CONTEXT