+private:
+ void Init();
+ void SetDefaults();
+
+ Graphics* m_context;
+ vector<GraphicsState> m_stateStack;
+ GraphicsState m_state1;
+ GraphicsState m_state2;
+
+ DECLARE_DYNAMIC_CLASS_NO_COPY(wxGDIPlusContext)
+};
+
+//-----------------------------------------------------------------------------
+// wxGDIPlusPen implementation
+//-----------------------------------------------------------------------------
+
+wxGDIPlusPenData::~wxGDIPlusPenData()
+{
+ delete m_pen;
+ delete m_penImage;
+ delete m_penBrush;
+}
+
+void wxGDIPlusPenData::Init()
+{
+ m_pen = NULL ;
+ m_penImage = NULL;
+ m_penBrush = NULL;
+}
+
+wxGDIPlusPenData::wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxPen &pen )
+: wxGraphicsObjectRefData(renderer)
+{
+ Init();
+ m_width = pen.GetWidth();
+ if (m_width <= 0.0)
+ m_width = 0.1;
+
+ m_pen = new Pen(Color( pen.GetColour().Alpha() , pen.GetColour().Red() ,
+ pen.GetColour().Green() , pen.GetColour().Blue() ), m_width );
+
+ LineCap cap;
+ switch ( pen.GetCap() )
+ {
+ case wxCAP_ROUND :
+ cap = LineCapRound;
+ break;
+
+ case wxCAP_PROJECTING :
+ cap = LineCapSquare;
+ break;
+
+ case wxCAP_BUTT :
+ cap = LineCapFlat; // TODO verify
+ break;
+
+ default :
+ cap = LineCapFlat;
+ break;
+ }
+ m_pen->SetLineCap(cap,cap, DashCapFlat);
+
+ LineJoin join;
+ switch ( pen.GetJoin() )
+ {
+ case wxJOIN_BEVEL :
+ join = LineJoinBevel;
+ break;
+
+ case wxJOIN_MITER :
+ join = LineJoinMiter;
+ break;
+
+ case wxJOIN_ROUND :
+ join = LineJoinRound;
+ break;
+
+ default :
+ join = LineJoinMiter;
+ break;
+ }
+
+ m_pen->SetLineJoin(join);
+
+ m_pen->SetDashStyle(DashStyleSolid);
+
+ DashStyle dashStyle = DashStyleSolid;
+ switch ( pen.GetStyle() )
+ {
+ case wxSOLID :
+ break;
+
+ case wxDOT :
+ dashStyle = DashStyleDot;
+ break;
+
+ case wxLONG_DASH :
+ dashStyle = DashStyleDash; // TODO verify
+ break;
+
+ case wxSHORT_DASH :
+ dashStyle = DashStyleDash;
+ break;
+
+ case wxDOT_DASH :
+ dashStyle = DashStyleDashDot;
+ break;
+ case wxUSER_DASH :
+ {
+ dashStyle = DashStyleCustom;
+ wxDash *dashes;
+ int count = pen.GetDashes( &dashes );
+ if ((dashes != NULL) && (count > 0))
+ {
+ REAL *userLengths = new REAL[count];
+ for ( int i = 0; i < count; ++i )
+ {
+ userLengths[i] = dashes[i];
+ }
+ m_pen->SetDashPattern( userLengths, count);
+ delete[] userLengths;
+ }
+ }
+ break;
+ case wxSTIPPLE :
+ {
+ wxBitmap* bmp = pen.GetStipple();
+ if ( bmp && bmp->Ok() )
+ {
+ m_penImage = Bitmap::FromHBITMAP((HBITMAP)bmp->GetHBITMAP(),(HPALETTE)bmp->GetPalette()->GetHPALETTE());
+ m_penBrush = new TextureBrush(m_penImage);
+ m_pen->SetBrush( m_penBrush );
+ }
+
+ }
+ 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);
+}
+
+//-----------------------------------------------------------------------------
+// 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
+//-----------------------------------------------------------------------------