+void wxGDIPlusBrush::Apply( wxGraphicsContext* WXUNUSED(context) )
+{
+ // nothing to do here
+}
+
+//-----------------------------------------------------------------------------
+// wxGDIPlusFont implementation
+//-----------------------------------------------------------------------------
+
+IMPLEMENT_DYNAMIC_CLASS(wxGDIPlusFont,wxGraphicsFont)
+
+wxGDIPlusFont::wxGDIPlusFont() : wxGraphicsFont( NULL )
+{
+ wxLogDebug(wxT("Illegal Constructor called"));
+}
+
+wxGDIPlusFont::wxGDIPlusFont( wxGraphicsRenderer* renderer, const wxFont &font,
+ const wxColour& col ) : wxGraphicsFont( renderer )
+{
+ m_textBrush = NULL;
+ m_font = NULL;
+
+ wxWCharBuffer s = font.GetFaceName().wc_str( *wxConvUI );
+ int size = font.GetPointSize();
+ int style = FontStyleRegular;
+ if ( font.GetStyle() == wxFONTSTYLE_ITALIC )
+ style |= FontStyleItalic;
+ if ( font.GetUnderlined() )
+ style |= FontStyleUnderline;
+ if ( font.GetWeight() == wxFONTWEIGHT_BOLD )
+ style |= FontStyleBold;
+ m_font = new Font( s , size , style );
+ m_textBrush = new SolidBrush( Color( col.Alpha() , col.Red() ,
+ col.Green() , col.Blue() ));
+}
+
+wxGDIPlusFont::~wxGDIPlusFont()
+{
+ delete m_textBrush;
+ delete m_font;
+}
+
+void wxGDIPlusFont::Apply( wxGraphicsContext* WXUNUSED(context) )
+{
+ // nothing to do here
+}
+
+//-----------------------------------------------------------------------------
+// wxGDIPlusPath implementation
+//-----------------------------------------------------------------------------
+
+IMPLEMENT_DYNAMIC_CLASS(wxGDIPlusPath,wxGraphicsPath)
+
+wxGDIPlusPath::wxGDIPlusPath(wxGraphicsRenderer* renderer, GraphicsPath* path ) : wxGraphicsPath(renderer)
+{
+ if ( path )
+ m_path = path;
+ else
+ m_path = new GraphicsPath();
+}
+
+wxGDIPlusPath::wxGDIPlusPath() : wxGraphicsPath(NULL)
+{
+ wxLogDebug(wxT("Illegal Constructor called"));
+}
+
+
+wxGDIPlusPath::~wxGDIPlusPath()
+{
+ delete m_path;
+}
+
+wxGraphicsPath* wxGDIPlusPath::Clone() const
+{
+ return new wxGDIPlusPath( GetRenderer() , m_path->Clone());
+}
+
+
+
+//
+// The Primitives
+//
+
+void wxGDIPlusPath::MoveToPoint( wxDouble x , wxDouble y )
+{
+ m_path->StartFigure();
+ m_path->AddLine((REAL) x,(REAL) y,(REAL) x,(REAL) y);
+}
+
+void wxGDIPlusPath::AddLineToPoint( wxDouble x , wxDouble y )
+{
+ m_path->AddLine((REAL) x,(REAL) y,(REAL) x,(REAL) y);
+}
+
+void wxGDIPlusPath::CloseSubpath()
+{
+ m_path->CloseFigure();
+}
+
+void wxGDIPlusPath::AddCurveToPoint( wxDouble cx1, wxDouble cy1, wxDouble cx2, wxDouble cy2, wxDouble x, wxDouble y )
+{
+ PointF c1(cx1,cy1);
+ PointF c2(cx2,cy2);
+ PointF end(x,y);
+ PointF start;
+ m_path->GetLastPoint(&start);
+ m_path->AddBezier(start,c1,c2,end);
+}
+
+// gets the last point of the current path, (0,0) if not yet set
+void wxGDIPlusPath::GetCurrentPoint( wxDouble& x, wxDouble&y)
+{
+ PointF start;
+ m_path->GetLastPoint(&start);
+ x = start.X ;
+ y = start.Y ;
+}
+
+void wxGDIPlusPath::AddArc( wxDouble x, wxDouble y, wxDouble r, double startAngle, double endAngle, bool clockwise )
+{
+ double sweepAngle = endAngle - startAngle ;
+ if( abs(sweepAngle) >= 2*M_PI)
+ {
+ sweepAngle = 2 * M_PI;
+ }
+ else
+ {
+ if ( clockwise )
+ {
+ if( sweepAngle < 0 )
+ sweepAngle += 2 * M_PI;
+ }
+ else
+ {
+ if( sweepAngle > 0 )
+ sweepAngle -= 2 * M_PI;
+
+ }
+ }
+ m_path->AddArc((REAL) (x-r),(REAL) (y-r),(REAL) (2*r),(REAL) (2*r),RadToDeg(startAngle),RadToDeg(sweepAngle));
+}
+
+void wxGDIPlusPath::AddRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h )
+{
+ m_path->AddRectangle(RectF(x,y,w,h));
+}
+
+void wxGDIPlusPath::AddPath( const wxGraphicsPath* path )
+{
+ m_path->AddPath( (GraphicsPath*) path->GetNativePath(), FALSE);
+}
+
+
+// transforms each point of this path by the matrix
+void wxGDIPlusPath::Transform( wxGraphicsMatrix* matrix )
+{
+ m_path->Transform( (Matrix*) matrix->GetNativeMatrix() );
+}
+
+// gets the bounding box enclosing all points (possibly including control points)
+void wxGDIPlusPath::GetBox(wxDouble *x, wxDouble *y, wxDouble *w, wxDouble *h)
+{
+ RectF bounds;
+ m_path->GetBounds( &bounds, NULL, NULL) ;
+ *x = bounds.X;
+ *y = bounds.Y;
+ *w = bounds.Width;
+ *h = bounds.Height;
+}
+
+bool wxGDIPlusPath::Contains( wxDouble x, wxDouble y, int fillStyle )
+{
+ m_path->SetFillMode( fillStyle == wxODDEVEN_RULE ? FillModeAlternate : FillModeWinding);
+ return m_path->IsVisible( (FLOAT) x,(FLOAT) y) == TRUE ;
+}
+
+//-----------------------------------------------------------------------------
+// wxGDIPlusMatrix implementation
+//-----------------------------------------------------------------------------
+
+IMPLEMENT_DYNAMIC_CLASS(wxGDIPlusMatrix,wxGraphicsMatrix)
+
+wxGDIPlusMatrix::wxGDIPlusMatrix() : wxGraphicsMatrix(NULL)
+{
+ wxLogDebug(wxT("Illegal Constructor called"));
+}
+
+wxGDIPlusMatrix::wxGDIPlusMatrix(wxGraphicsRenderer* renderer, Matrix* matrix )
+ : wxGraphicsMatrix(renderer)
+{
+ if ( matrix )
+ m_matrix = matrix ;
+ else
+ m_matrix = new Matrix();
+}
+
+wxGDIPlusMatrix::~wxGDIPlusMatrix()
+{
+ delete m_matrix;
+}
+
+wxGraphicsMatrix *wxGDIPlusMatrix::Clone() const
+{
+ return new wxGDIPlusMatrix( GetRenderer(), m_matrix->Clone());
+}
+
+// concatenates the matrix
+void wxGDIPlusMatrix::Concat( const wxGraphicsMatrix *t )
+{
+ m_matrix->Multiply( (Matrix*) t->GetNativeMatrix());
+}
+
+// copies the passed in matrix
+void wxGDIPlusMatrix::Copy( const wxGraphicsMatrix *t )
+{
+ delete m_matrix;
+ m_matrix = ((Matrix*) t->GetNativeMatrix())->Clone();
+}
+
+// sets the matrix to the respective values
+void wxGDIPlusMatrix::Set(wxDouble a, wxDouble b, wxDouble c, wxDouble d,
+ wxDouble tx, wxDouble ty)
+{
+ m_matrix->SetElements(a,b,c,d,tx,ty);
+}
+
+// makes this the inverse matrix
+void wxGDIPlusMatrix::Invert()
+{
+ m_matrix->Invert();
+}
+
+// returns true if the elements of the transformation matrix are equal ?
+bool wxGDIPlusMatrix::IsEqual( const wxGraphicsMatrix* t) const
+{
+ return m_matrix->Equals((Matrix*) t->GetNativeMatrix())== TRUE ;
+}
+
+// return true if this is the identity matrix
+bool wxGDIPlusMatrix::IsIdentity()
+{
+ return m_matrix->IsIdentity() == TRUE ;
+}
+
+//
+// transformation
+//
+
+// add the translation to this matrix
+void wxGDIPlusMatrix::Translate( wxDouble dx , wxDouble dy )
+{
+ m_matrix->Translate(dx,dy);
+}
+
+// add the scale to this matrix
+void wxGDIPlusMatrix::Scale( wxDouble xScale , wxDouble yScale )
+{
+ m_matrix->Scale(xScale,yScale);
+}
+
+// add the rotation to this matrix (radians)
+void wxGDIPlusMatrix::Rotate( wxDouble angle )
+{
+ m_matrix->Rotate( angle );
+}
+
+//
+// apply the transforms
+//
+
+// applies that matrix to the point
+void wxGDIPlusMatrix::TransformPoint( wxDouble *x, wxDouble *y )
+{
+ PointF pt(*x,*y);
+ m_matrix->TransformPoints(&pt);
+ *x = pt.X;
+ *y = pt.Y;
+}
+
+// applies the matrix except for translations
+void wxGDIPlusMatrix::TransformDistance( wxDouble *dx, wxDouble *dy )
+{
+ PointF pt(*dx,*dy);
+ m_matrix->TransformVectors(&pt);
+ *dx = pt.X;
+ *dy = pt.Y;
+}
+
+// returns the native representation
+void * wxGDIPlusMatrix::GetNativeMatrix() const
+{
+ return m_matrix;
+}
+
+//-----------------------------------------------------------------------------
+// wxGDIPlusContext implementation
+//-----------------------------------------------------------------------------
+
+IMPLEMENT_DYNAMIC_CLASS(wxGDIPlusContext,wxGraphicsContext)
+
+wxGDIPlusContext::wxGDIPlusContext( wxGraphicsRenderer* renderer, HDC hdc )
+ : wxGraphicsContext(renderer)
+{
+ Init();
+ m_context = new Graphics( hdc);
+ SetDefaults();
+}
+
+wxGDIPlusContext::wxGDIPlusContext( wxGraphicsRenderer* renderer, HWND hwnd )
+ : wxGraphicsContext(renderer)
+{
+ Init();
+ m_context = new Graphics( hwnd);
+ SetDefaults();
+}
+
+wxGDIPlusContext::wxGDIPlusContext( wxGraphicsRenderer* renderer, Graphics* gr )
+ : wxGraphicsContext(renderer)
+{
+ Init();
+ m_context = gr;
+ SetDefaults();
+}
+
+wxGDIPlusContext::wxGDIPlusContext() : wxGraphicsContext(NULL)
+{
+ Init();
+}
+
+void wxGDIPlusContext::Init()
+{
+ m_context = NULL;
+ m_state1 = 0;
+ m_state2= 0;
+}
+
+void wxGDIPlusContext::SetDefaults()
+{
+ m_context->SetSmoothingMode(SmoothingModeHighQuality);
+ m_state1 = m_context->Save();
+ m_state2 = m_context->Save();
+}
+
+wxGDIPlusContext::~wxGDIPlusContext()
+{
+ SetBrush(NULL);
+ SetFont(NULL);
+ SetPen(NULL);
+
+ if ( m_context )
+ {
+ m_context->Restore( m_state2 );
+ m_context->Restore( m_state1 );
+ delete m_context;
+ }
+}
+
+
+void wxGDIPlusContext::Clip( const wxRegion ®ion )
+{
+ m_context->SetClip((HRGN)region.GetHRGN(),CombineModeIntersect);
+}
+
+void wxGDIPlusContext::Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h )
+{
+ m_context->SetClip(RectF(x,y,w,h),CombineModeIntersect);
+}
+
+void wxGDIPlusContext::ResetClip()
+{
+ m_context->ResetClip();
+}
+
+void wxGDIPlusContext::StrokePath( const wxGraphicsPath *path )
+{
+ if ( m_pen )
+ {
+ m_context->DrawPath( ((wxGDIPlusPen*)m_pen)->GetGDIPlusPen() , (GraphicsPath*) path->GetNativePath() );
+ }
+}
+
+void wxGDIPlusContext::FillPath( const wxGraphicsPath *path , int fillStyle )
+{
+ if ( m_brush )
+ {
+ ((GraphicsPath*) path->GetNativePath())->SetFillMode( fillStyle == wxODDEVEN_RULE ? FillModeAlternate : FillModeWinding);
+ m_context->FillPath( ((wxGDIPlusBrush*)m_brush)->GetGDIPlusBrush() ,
+ (GraphicsPath*) path->GetNativePath());
+ }
+}
+
+void wxGDIPlusContext::Rotate( wxDouble angle )
+{
+ m_context->RotateTransform( RadToDeg(angle) );
+}
+
+void wxGDIPlusContext::Translate( wxDouble dx , wxDouble dy )
+{
+ m_context->TranslateTransform( dx , dy );
+}
+
+void wxGDIPlusContext::Scale( wxDouble xScale , wxDouble yScale )
+{
+ m_context->ScaleTransform(xScale,yScale);
+}
+
+void wxGDIPlusContext::PushState()
+{
+ GraphicsState state = m_context->Save();
+ m_stateStack.push_back(state);
+}
+
+void wxGDIPlusContext::PopState()
+{
+ GraphicsState state = m_stateStack.back();
+ m_stateStack.pop_back();
+ m_context->Restore(state);
+}
+