class WXDLLEXPORT wxGDIPlusPath : public wxGraphicsPath
{
- DECLARE_NO_COPY_CLASS(wxGDIPlusPath)
public :
wxGDIPlusPath();
~wxGDIPlusPath();
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 * WXUNUSED(path)) {}
+
private :
GraphicsPath* m_path;
+ DECLARE_DYNAMIC_CLASS_NO_COPY(wxGDIPlusPath)
};
class WXDLLEXPORT wxGDIPlusContext : public wxGraphicsContext
{
- DECLARE_NO_COPY_CLASS(wxGDIPlusContext)
-
public:
- wxGDIPlusContext( WXHDC hdc );
+ wxGDIPlusContext( HDC hdc );
+ wxGDIPlusContext( HWND hwnd );
+ wxGDIPlusContext( Graphics* gr);
wxGDIPlusContext();
+
virtual ~wxGDIPlusContext();
virtual void Clip( const wxRegion ®ion );
virtual void GetPartialTextExtents(const wxString& text, wxArrayDouble& widths) const;
private:
+ void Init();
+ void SetDefaults();
+
Graphics* m_context;
vector<GraphicsState> m_stateStack;
GraphicsState m_state1;
Font* m_font;
// wxPen m_pen;
// wxBrush m_brush;
+ DECLARE_DYNAMIC_CLASS_NO_COPY(wxGDIPlusContext)
};
+IMPLEMENT_DYNAMIC_CLASS(wxGDIPlusPath,wxGraphicsPath)
+
wxGDIPlusPath::wxGDIPlusPath()
{
m_path = new GraphicsPath();
delete m_path;
}
-GraphicsPath* wxGDIPlusPath::GetPath() const
-{
- return m_path;
-}
-
//
// The Primitives
//
m_path->AddRectangle(RectF(x,y,w,h));
}
-//
-//
-//
-/*
-// closes the current subpath
-void wxGDIPlusPath::AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r )
+//-----------------------------------------------------------------------------
+// wxGDIPlusContext implementation
+//-----------------------------------------------------------------------------
+
+IMPLEMENT_DYNAMIC_CLASS(wxGDIPlusContext,wxGraphicsContext)
+
+wxGDIPlusContext::wxGDIPlusContext( HDC hdc )
{
-// CGPathAddArcToPoint( m_path, NULL , x1, y1, x2, y2, r);
+ Init();
+ m_context = new Graphics( hdc);
+ SetDefaults();
}
-*/
+wxGDIPlusContext::wxGDIPlusContext( HWND hwnd )
+{
+ Init();
+ m_context = new Graphics( hwnd);
+ SetDefaults();
+}
-//-----------------------------------------------------------------------------
-// wxGDIPlusContext implementation
-//-----------------------------------------------------------------------------
+wxGDIPlusContext::wxGDIPlusContext( Graphics* gr )
+{
+ Init();
+ m_context = gr;
+ SetDefaults();
+}
-wxGDIPlusContext::wxGDIPlusContext( WXHDC hdc )
+wxGDIPlusContext::wxGDIPlusContext()
+{
+ Init();
+}
+
+void wxGDIPlusContext::Init()
{
gGDILoader.EnsureIsLoaded();
- m_context = new Graphics( (HDC) hdc);
+ m_context = NULL;
+ m_state1 = 0;
+ m_state2= 0;
+
+ m_pen = NULL;
+ m_penTransparent = true;
+ m_penImage = NULL;
+ m_penBrush = NULL;
+
+ m_brush = NULL;
+ m_brushTransparent = true;
+ m_brushImage = NULL;
+ m_brushPath = NULL;
+
+ m_textBrush = NULL;
+ m_font = NULL;
+}
+
+void wxGDIPlusContext::SetDefaults()
+{
m_context->SetSmoothingMode(SmoothingModeHighQuality);
m_state1 = m_context->Save();
m_state2 = m_context->Save();
-
// set defaults
m_penTransparent = false;
}
-void wxGDIPlusContext::Clip( const wxRegion & WXUNUSED(region) )
+void wxGDIPlusContext::Clip( const wxRegion ®ion )
{
-// TODO
+ m_context->SetClip((HRGN)region.GetHRGN(),CombineModeIntersect);
}
void wxGDIPlusContext::Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h )
{
-// TODO
+ m_context->SetClip(RectF(x,y,w,h),CombineModeIntersect);
}
void wxGDIPlusContext::ResetClip()
{
-// TODO
+ m_context->ResetClip();
}
-void wxGDIPlusContext::StrokePath( const wxGraphicsPath *p )
+void wxGDIPlusContext::StrokePath( const wxGraphicsPath *path )
{
if ( m_penTransparent )
return;
- const wxGDIPlusPath* path = dynamic_cast< const wxGDIPlusPath*>( p );
- m_context->DrawPath( m_pen , path->GetPath() );
+ m_context->DrawPath( m_pen , (GraphicsPath*) path->GetNativePath() );
}
-void wxGDIPlusContext::FillPath( const wxGraphicsPath *p , int fillStyle )
+void wxGDIPlusContext::FillPath( const wxGraphicsPath *path , int fillStyle )
{
if ( !m_brushTransparent )
{
- const wxGDIPlusPath* path = dynamic_cast< const wxGDIPlusPath*>( p );
- path->GetPath()->SetFillMode( fillStyle == wxODDEVEN_RULE ? FillModeAlternate : FillModeWinding);
- m_context->FillPath( m_brush , path->GetPath() );
+ ((GraphicsPath*) path->GetNativePath())->SetFillMode( fillStyle == wxODDEVEN_RULE ? FillModeAlternate : FillModeWinding);
+ m_context->FillPath( m_brush , (GraphicsPath*) path->GetNativePath());
}
}
m_font = new Font( s , size , style );
}
-void * wxCairoContext::GetNativeContext()
+void* wxGDIPlusContext::GetNativeContext()
{
return m_context;
}
wxGraphicsContext* wxGraphicsContext::Create( wxWindow * window )
{
- return NULL; // TODO
+ return new wxGDIPlusContext( (HWND) window->GetHWND() );
}
wxGraphicsContext* wxGraphicsContext::CreateFromNative( void * context )
{
- return NULL; // TODO
+ return new wxGDIPlusContext( (Graphics*) context );
}