+// gets the bounding box enclosing all points (possibly including control points)
+void wxGDIPlusPathData::GetBox(wxDouble *x, wxDouble *y, wxDouble *w, wxDouble *h) const
+{
+ RectF bounds;
+ m_path->GetBounds( &bounds, NULL, NULL) ;
+ *x = bounds.X;
+ *y = bounds.Y;
+ *w = bounds.Width;
+ *h = bounds.Height;
+}
+
+bool wxGDIPlusPathData::Contains( wxDouble x, wxDouble y, wxPolygonFillMode fillStyle ) const
+{
+ m_path->SetFillMode( fillStyle == wxODDEVEN_RULE ? FillModeAlternate : FillModeWinding);
+ return m_path->IsVisible( (FLOAT) x,(FLOAT) y) == TRUE ;
+}
+
+//-----------------------------------------------------------------------------
+// wxGDIPlusMatrixData implementation
+//-----------------------------------------------------------------------------
+
+wxGDIPlusMatrixData::wxGDIPlusMatrixData(wxGraphicsRenderer* renderer, Matrix* matrix )
+ : wxGraphicsMatrixData(renderer)
+{
+ if ( matrix )
+ m_matrix = matrix ;
+ else
+ m_matrix = new Matrix();
+}
+
+wxGDIPlusMatrixData::~wxGDIPlusMatrixData()
+{
+ delete m_matrix;
+}
+
+wxGraphicsObjectRefData *wxGDIPlusMatrixData::Clone() const
+{
+ return new wxGDIPlusMatrixData( GetRenderer(), m_matrix->Clone());
+}
+
+// concatenates the matrix
+void wxGDIPlusMatrixData::Concat( const wxGraphicsMatrixData *t )
+{
+ m_matrix->Multiply( (Matrix*) t->GetNativeMatrix());
+}
+
+// sets the matrix to the respective values
+void wxGDIPlusMatrixData::Set(wxDouble a, wxDouble b, wxDouble c, wxDouble d,
+ wxDouble tx, wxDouble ty)
+{
+ m_matrix->SetElements(a,b,c,d,tx,ty);
+}
+
+// gets the component valuess of the matrix
+void wxGDIPlusMatrixData::Get(wxDouble* a, wxDouble* b, wxDouble* c,
+ wxDouble* d, wxDouble* tx, wxDouble* ty) const
+{
+ REAL elements[6];
+ m_matrix->GetElements(elements);
+ if (a) *a = elements[0];
+ if (b) *b = elements[1];
+ if (c) *c = elements[2];
+ if (d) *d = elements[3];
+ if (tx) *tx= elements[4];
+ if (ty) *ty= elements[5];
+}
+
+// makes this the inverse matrix
+void wxGDIPlusMatrixData::Invert()
+{
+ m_matrix->Invert();
+}
+
+// returns true if the elements of the transformation matrix are equal ?
+bool wxGDIPlusMatrixData::IsEqual( const wxGraphicsMatrixData* t) const
+{
+ return m_matrix->Equals((Matrix*) t->GetNativeMatrix())== TRUE ;
+}
+
+// return true if this is the identity matrix
+bool wxGDIPlusMatrixData::IsIdentity() const
+{
+ return m_matrix->IsIdentity() == TRUE ;
+}
+
+//
+// transformation
+//
+
+// add the translation to this matrix
+void wxGDIPlusMatrixData::Translate( wxDouble dx , wxDouble dy )
+{
+ m_matrix->Translate(dx,dy);
+}
+
+// add the scale to this matrix
+void wxGDIPlusMatrixData::Scale( wxDouble xScale , wxDouble yScale )
+{
+ m_matrix->Scale(xScale,yScale);
+}
+
+// add the rotation to this matrix (radians)
+void wxGDIPlusMatrixData::Rotate( wxDouble angle )
+{
+ m_matrix->Rotate( angle );
+}
+
+//
+// apply the transforms
+//
+
+// applies that matrix to the point
+void wxGDIPlusMatrixData::TransformPoint( wxDouble *x, wxDouble *y ) const
+{
+ PointF pt(*x,*y);
+ m_matrix->TransformPoints(&pt);
+ *x = pt.X;
+ *y = pt.Y;
+}
+
+// applies the matrix except for translations
+void wxGDIPlusMatrixData::TransformDistance( wxDouble *dx, wxDouble *dy ) const
+{
+ PointF pt(*dx,*dy);
+ m_matrix->TransformVectors(&pt);
+ *dx = pt.X;
+ *dy = pt.Y;
+}
+
+// returns the native representation
+void * wxGDIPlusMatrixData::GetNativeMatrix() const
+{
+ return m_matrix;
+}
+
+//-----------------------------------------------------------------------------
+// wxGDIPlusContext implementation
+//-----------------------------------------------------------------------------
+
+IMPLEMENT_DYNAMIC_CLASS(wxGDIPlusContext,wxGraphicsContext)
+IMPLEMENT_DYNAMIC_CLASS(wxGDIPlusMeasuringContext,wxGDIPlusContext)
+
+class wxGDIPlusOffsetHelper
+{
+public :
+ wxGDIPlusOffsetHelper( Graphics* gr , bool offset )
+ {
+ m_gr = gr;
+ m_offset = offset;
+ if ( m_offset )
+ m_gr->TranslateTransform( 0.5, 0.5 );
+ }
+ ~wxGDIPlusOffsetHelper( )
+ {
+ if ( m_offset )
+ m_gr->TranslateTransform( -0.5, -0.5 );
+ }
+public :
+ Graphics* m_gr;
+ bool m_offset;
+} ;
+
+wxGDIPlusContext::wxGDIPlusContext( wxGraphicsRenderer* renderer, HDC hdc, wxDouble width, wxDouble height )
+ : wxGraphicsContext(renderer)
+{
+ Init();
+ m_context = new Graphics( hdc);
+ m_width = width;
+ m_height = height;
+ SetDefaults();
+}
+
+wxGDIPlusContext::wxGDIPlusContext( wxGraphicsRenderer* renderer, HWND hwnd )
+ : wxGraphicsContext(renderer)
+{
+ Init();
+ m_context = new Graphics( hwnd);
+ RECT rect = wxGetWindowRect(hwnd);
+ m_width = rect.right - rect.left;
+ m_height = rect.bottom - rect.top;
+ 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;
+ m_height = 0;
+ m_width = 0;
+}
+
+void wxGDIPlusContext::SetDefaults()
+{
+ m_context->SetTextRenderingHint(TextRenderingHintSystemDefault);
+ m_context->SetPixelOffsetMode(PixelOffsetModeHalf);
+ m_context->SetSmoothingMode(SmoothingModeHighQuality);
+ m_state1 = m_context->Save();
+ m_state2 = m_context->Save();
+}
+
+wxGDIPlusContext::~wxGDIPlusContext()
+{
+ if ( m_context )
+ {
+ m_context->Restore( m_state2 );
+ m_context->Restore( m_state1 );
+ delete m_context;
+ }
+}
+
+
+void wxGDIPlusContext::Clip( const wxRegion ®ion )
+{
+ Region rgn((HRGN)region.GetHRGN());
+ m_context->SetClip(&rgn,CombineModeIntersect);
+}
+
+void wxGDIPlusContext::Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h )
+{
+ m_context->SetClip(RectF(x,y,w,h),CombineModeIntersect);
+}
+
+void wxGDIPlusContext::ResetClip()