+ }
+ m_penBrush = new HatchBrush(style,Color( pen.GetColour().Alpha() , pen.GetColour().Red() ,
+ pen.GetColour().Green() , pen.GetColour().Blue() ), Color::Transparent );
+ m_pen->SetBrush( m_penBrush );
+ }
+ break;
+ }
+ if ( dashStyle != DashStyleSolid )
+ m_pen->SetDashStyle(dashStyle);
+}
+
+//-----------------------------------------------------------------------------
+// wxGDIPlusBrush implementation
+//-----------------------------------------------------------------------------
+
+wxGDIPlusBrushData::wxGDIPlusBrushData( wxGraphicsRenderer* renderer )
+: wxGraphicsObjectRefData(renderer)
+{
+ Init();
+}
+
+wxGDIPlusBrushData::wxGDIPlusBrushData( wxGraphicsRenderer* renderer , const wxBrush &brush )
+: wxGraphicsObjectRefData(renderer)
+{
+ Init();
+ if ( brush.GetStyle() == wxSOLID)
+ {
+ m_brush = new SolidBrush( Color( brush.GetColour().Alpha() , brush.GetColour().Red() ,
+ brush.GetColour().Green() , brush.GetColour().Blue() ) );
+ }
+ else if ( brush.IsHatch() )
+ {
+ HatchStyle style = HatchStyleHorizontal;
+ switch( brush.GetStyle() )
+ {
+ case wxBDIAGONAL_HATCH :
+ style = HatchStyleBackwardDiagonal;
+ break ;
+ case wxCROSSDIAG_HATCH :
+ style = HatchStyleDiagonalCross;
+ break ;
+ case wxFDIAGONAL_HATCH :
+ style = HatchStyleForwardDiagonal;
+ break ;
+ case wxCROSS_HATCH :
+ style = HatchStyleCross;
+ break ;
+ case wxHORIZONTAL_HATCH :
+ style = HatchStyleHorizontal;
+ break ;
+ case wxVERTICAL_HATCH :
+ style = HatchStyleVertical;
+ break ;
+
+ }
+ m_brush = new HatchBrush(style,Color( brush.GetColour().Alpha() , brush.GetColour().Red() ,
+ brush.GetColour().Green() , brush.GetColour().Blue() ), Color::Transparent );
+ }
+ else
+ {
+ wxBitmap* bmp = brush.GetStipple();
+ if ( bmp && bmp->Ok() )
+ {
+ wxDELETE( m_brushImage );
+ m_brushImage = Bitmap::FromHBITMAP((HBITMAP)bmp->GetHBITMAP(),(HPALETTE)bmp->GetPalette()->GetHPALETTE());
+ m_brush = new TextureBrush(m_brushImage);
+ }
+ }
+}
+
+wxGDIPlusBrushData::~wxGDIPlusBrushData()
+{
+ delete m_brush;
+ delete m_brushImage;
+ delete m_brushPath;
+};
+
+void wxGDIPlusBrushData::Init()
+{
+ m_brush = NULL;
+ m_brushImage= NULL;
+ m_brushPath= NULL;
+}
+
+void wxGDIPlusBrushData::CreateLinearGradientBrush( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2, const wxColour&c1, const wxColour&c2)
+{
+ m_brush = new LinearGradientBrush( PointF( x1,y1) , PointF( x2,y2),
+ Color( c1.Alpha(), c1.Red(),c1.Green() , c1.Blue() ),
+ Color( c2.Alpha(), c2.Red(),c2.Green() , c2.Blue() ));
+}
+
+void wxGDIPlusBrushData::CreateRadialGradientBrush( wxDouble xo, wxDouble yo, wxDouble xc, wxDouble yc, wxDouble radius,
+ const wxColour &oColor, const wxColour &cColor)
+{
+ // Create a path that consists of a single circle.
+ m_brushPath = new GraphicsPath();
+ m_brushPath->AddEllipse( (REAL)(xc-radius), (REAL)(yc-radius), (REAL)(2*radius), (REAL)(2*radius));
+
+ PathGradientBrush *b = new PathGradientBrush(m_brushPath);
+ m_brush = b;
+ b->SetCenterPoint( PointF(xo,yo));
+ b->SetCenterColor(Color( oColor.Alpha(), oColor.Red(),oColor.Green() , oColor.Blue() ));
+
+ Color colors[] = {Color( cColor.Alpha(), cColor.Red(),cColor.Green() , cColor.Blue() )};
+ int count = 1;
+ b->SetSurroundColors(colors, &count);
+}
+
+//-----------------------------------------------------------------------------
+// wxGDIPlusFont implementation
+//-----------------------------------------------------------------------------
+
+wxGDIPlusFontData::wxGDIPlusFontData( wxGraphicsRenderer* renderer, const wxFont &font,
+ const wxColour& col ) : wxGraphicsObjectRefData( 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() ));
+}
+
+wxGDIPlusFontData::~wxGDIPlusFontData()
+{
+ delete m_textBrush;
+ delete m_font;
+}
+
+//-----------------------------------------------------------------------------
+// wxGDIPlusPath implementation
+//-----------------------------------------------------------------------------
+
+wxGDIPlusPathData::wxGDIPlusPathData(wxGraphicsRenderer* renderer, GraphicsPath* path ) : wxGraphicsPathData(renderer)
+{
+ if ( path )
+ m_path = path;
+ else
+ m_path = new GraphicsPath();
+}
+
+wxGDIPlusPathData::~wxGDIPlusPathData()
+{
+ delete m_path;
+}
+
+wxGraphicsObjectRefData* wxGDIPlusPathData::Clone() const
+{
+ return new wxGDIPlusPathData( GetRenderer() , m_path->Clone());
+}
+
+//
+// The Primitives
+//
+
+void wxGDIPlusPathData::MoveToPoint( wxDouble x , wxDouble y )
+{
+ m_path->StartFigure();
+ m_path->AddLine((REAL) x,(REAL) y,(REAL) x,(REAL) y);
+}
+
+void wxGDIPlusPathData::AddLineToPoint( wxDouble x , wxDouble y )
+{
+ m_path->AddLine((REAL) x,(REAL) y,(REAL) x,(REAL) y);
+}
+
+void wxGDIPlusPathData::CloseSubpath()
+{
+ m_path->CloseFigure();
+}
+
+void wxGDIPlusPathData::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 wxGDIPlusPathData::GetCurrentPoint( wxDouble* x, wxDouble* y) const
+{
+ PointF start;
+ m_path->GetLastPoint(&start);
+ *x = start.X ;
+ *y = start.Y ;
+}
+
+void wxGDIPlusPathData::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 wxGDIPlusPathData::AddRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h )
+{
+ m_path->AddRectangle(RectF(x,y,w,h));
+}
+
+void wxGDIPlusPathData::AddPath( const wxGraphicsPathData* path )
+{
+ m_path->AddPath( (GraphicsPath*) path->GetNativePath(), FALSE);
+}
+
+
+// transforms each point of this path by the matrix
+void wxGDIPlusPathData::Transform( const wxGraphicsMatrixData* matrix )
+{
+ m_path->Transform( (Matrix*) matrix->GetNativeMatrix() );
+}
+
+// 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, int 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)
+
+wxGDIPlusContext::wxGDIPlusContext( wxGraphicsRenderer* renderer, HDC hdc )
+ : wxGraphicsContext(renderer)
+{
+ Init();
+ m_context = new Graphics( hdc);
+ SetDefaults();