+ }
+ break;
+ default :
+ if ( pen.GetStyle() >= wxFIRST_HATCH && pen.GetStyle() <= wxLAST_HATCH )
+ {
+ HatchStyle style = HatchStyleHorizontal;
+ switch( pen.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_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);
+}
+
+void wxGDIPlusPen::Apply( wxGraphicsContext* WXUNUSED(context) )
+{
+ // nothing to do here
+}
+
+
+//-----------------------------------------------------------------------------
+// wxGDIPlusBrush implementation
+//-----------------------------------------------------------------------------
+
+IMPLEMENT_DYNAMIC_CLASS(wxGDIPlusBrush,wxGraphicsBrush)
+
+wxGDIPlusBrush::wxGDIPlusBrush( wxGraphicsRenderer* renderer )
+: wxGraphicsBrush(renderer)
+{
+ Init();
+}
+
+wxGDIPlusBrush::wxGDIPlusBrush( )
+: wxGraphicsBrush(NULL)
+{
+ wxLogDebug(wxT("Illegal Constructor called"));
+}
+
+
+wxGDIPlusBrush::wxGDIPlusBrush( wxGraphicsRenderer* renderer , const wxBrush &brush )
+: wxGraphicsBrush(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);
+ }
+ }
+}
+
+wxGDIPlusBrush::~wxGDIPlusBrush()
+{
+ delete m_brush;
+ delete m_brushImage;
+ delete m_brushPath;
+};
+
+void wxGDIPlusBrush::Init()
+{
+ m_brush = NULL;
+ m_brushImage= NULL;
+ m_brushPath= NULL;
+}
+
+void wxGDIPlusBrush::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 wxGDIPlusBrush::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);
+}
+
+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)