using GetNativePath instead of dynamic_cast
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42249 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
eec960fa89
commit
f540e5bd06
@ -144,7 +144,12 @@ public :
|
|||||||
virtual void AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r ) ;
|
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 :
|
private :
|
||||||
cairo_t* m_pathContext;
|
cairo_t* m_pathContext;
|
||||||
};
|
};
|
||||||
@ -161,11 +166,16 @@ wxCairoPath::~wxCairoPath()
|
|||||||
cairo_destroy(m_pathContext);
|
cairo_destroy(m_pathContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_path_t* wxCairoPath::GetPath() const
|
cairo_path_t* wxCairoPath::GetNativePath() const
|
||||||
{
|
{
|
||||||
return cairo_copy_path(m_pathContext) ;
|
return cairo_copy_path(m_pathContext) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxCairoPath::UnGetNativePath(void *p)
|
||||||
|
{
|
||||||
|
cairo_path_destroy((cairo_path_t*)p);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// The Primitives
|
// The Primitives
|
||||||
//
|
//
|
||||||
@ -330,13 +340,12 @@ void wxCairoContext::ResetClip()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void wxCairoContext::StrokePath( const wxGraphicsPath *p )
|
void wxCairoContext::StrokePath( const wxGraphicsPath *path )
|
||||||
{
|
{
|
||||||
if ( m_penTransparent )
|
if ( m_penTransparent )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const wxCairoPath* path = (const wxCairoPath *) p;
|
cairo_path_t* cp = (cairo_path_t*) path->GetNativePath() ;
|
||||||
cairo_path_t* cp = path->GetPath() ;
|
|
||||||
cairo_append_path(m_context,cp);
|
cairo_append_path(m_context,cp);
|
||||||
|
|
||||||
// setup pen
|
// setup pen
|
||||||
@ -517,15 +526,14 @@ void wxCairoContext::StrokePath( const wxGraphicsPath *p )
|
|||||||
if ( userLengths )
|
if ( userLengths )
|
||||||
delete[] userLengths;
|
delete[] userLengths;
|
||||||
cairo_stroke(m_context);
|
cairo_stroke(m_context);
|
||||||
cairo_path_destroy(cp);
|
path->UnGetNativePath(cp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxCairoContext::FillPath( const wxGraphicsPath *p , int fillStyle )
|
void wxCairoContext::FillPath( const wxGraphicsPath *path , int fillStyle )
|
||||||
{
|
{
|
||||||
if ( !m_brushTransparent )
|
if ( !m_brushTransparent )
|
||||||
{
|
{
|
||||||
const wxCairoPath* path = (const wxCairoPath *) p;
|
cairo_path_t* cp = (cairo_path_t*) path->GetNativePath() ;
|
||||||
cairo_path_t* cp = path->GetPath() ;
|
|
||||||
cairo_append_path(m_context,cp);
|
cairo_append_path(m_context,cp);
|
||||||
|
|
||||||
if ( m_brushPattern )
|
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_set_fill_rule(m_context,fillStyle==wxODDEVEN_RULE ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
|
||||||
cairo_fill(m_context);
|
cairo_fill(m_context);
|
||||||
cairo_path_destroy(cp);
|
path->UnGetNativePath(cp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +182,12 @@ public :
|
|||||||
virtual void AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r ) ;
|
virtual void AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r ) ;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
GraphicsPath* GetPath() const;
|
// returns the native path
|
||||||
|
virtual void * GetNativePath() const { return m_path; }
|
||||||
|
|
||||||
|
// give the native path returned by GetNativePath() back (there might be some deallocations necessary)
|
||||||
|
virtual void UnGetNativePath(void *p) {}
|
||||||
|
|
||||||
private :
|
private :
|
||||||
GraphicsPath* m_path;
|
GraphicsPath* m_path;
|
||||||
};
|
};
|
||||||
@ -263,11 +268,6 @@ wxGDIPlusPath::~wxGDIPlusPath()
|
|||||||
delete m_path;
|
delete m_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsPath* wxGDIPlusPath::GetPath() const
|
|
||||||
{
|
|
||||||
return m_path;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// The Primitives
|
// The Primitives
|
||||||
//
|
//
|
||||||
@ -409,22 +409,20 @@ void wxGDIPlusContext::ResetClip()
|
|||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGDIPlusContext::StrokePath( const wxGraphicsPath *p )
|
void wxGDIPlusContext::StrokePath( const wxGraphicsPath *path )
|
||||||
{
|
{
|
||||||
if ( m_penTransparent )
|
if ( m_penTransparent )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const wxGDIPlusPath* path = dynamic_cast< const wxGDIPlusPath*>( p );
|
m_context->DrawPath( m_pen , (GraphicsPath*) path->GetNativePath() );
|
||||||
m_context->DrawPath( m_pen , path->GetPath() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGDIPlusContext::FillPath( const wxGraphicsPath *p , int fillStyle )
|
void wxGDIPlusContext::FillPath( const wxGraphicsPath *path , int fillStyle )
|
||||||
{
|
{
|
||||||
if ( !m_brushTransparent )
|
if ( !m_brushTransparent )
|
||||||
{
|
{
|
||||||
const wxGDIPlusPath* path = dynamic_cast< const wxGDIPlusPath*>( p );
|
((GraphicsPath*) path->GetNativePath())->SetFillMode( fillStyle == wxODDEVEN_RULE ? FillModeAlternate : FillModeWinding);
|
||||||
path->GetPath()->SetFillMode( fillStyle == wxODDEVEN_RULE ? FillModeAlternate : FillModeWinding);
|
m_context->FillPath( m_brush , (GraphicsPath*) path->GetNativePath());
|
||||||
m_context->FillPath( m_brush , path->GetPath() );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user