1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/graphcmn.cpp
3 // Purpose: graphics context methods common to all platforms
4 // Author: Stefan Csomor
7 // Copyright: (c) Stefan Csomor
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
14 #if defined(__BORLANDC__)
18 #if wxUSE_GRAPHICS_CONTEXT
20 #include "wx/graphics.h"
24 #include "wx/bitmap.h"
25 #include "wx/dcmemory.h"
26 #include "wx/region.h"
30 #include "wx/private/graphics.h"
32 //-----------------------------------------------------------------------------
34 //-----------------------------------------------------------------------------
36 static inline double DegToRad(double deg
)
38 return (deg
* M_PI
) / 180.0;
41 //-----------------------------------------------------------------------------
43 //-----------------------------------------------------------------------------
45 //-----------------------------------------------------------------------------
47 IMPLEMENT_DYNAMIC_CLASS(wxGraphicsObject
, wxObject
)
49 wxGraphicsObjectRefData::wxGraphicsObjectRefData( wxGraphicsRenderer
* renderer
)
51 m_renderer
= renderer
;
53 wxGraphicsObjectRefData::wxGraphicsObjectRefData( const wxGraphicsObjectRefData
* data
)
55 m_renderer
= data
->m_renderer
;
57 wxGraphicsRenderer
* wxGraphicsObjectRefData::GetRenderer() const
62 wxGraphicsObjectRefData
* wxGraphicsObjectRefData::Clone() const
64 return new wxGraphicsObjectRefData(this);
67 wxGraphicsObject::wxGraphicsObject()
71 wxGraphicsObject::wxGraphicsObject( wxGraphicsRenderer
* renderer
)
73 SetRefData( new wxGraphicsObjectRefData(renderer
));
76 wxGraphicsObject::~wxGraphicsObject()
80 bool wxGraphicsObject::IsNull() const
82 return m_refData
== NULL
;
85 wxGraphicsRenderer
* wxGraphicsObject::GetRenderer() const
87 return ( IsNull() ? NULL
: GetGraphicsData()->GetRenderer() );
90 wxGraphicsObjectRefData
* wxGraphicsObject::GetGraphicsData() const
92 return (wxGraphicsObjectRefData
*) m_refData
;
95 wxObjectRefData
* wxGraphicsObject::CreateRefData() const
97 wxLogDebug(wxT("A Null Object cannot be changed"));
101 wxObjectRefData
* wxGraphicsObject::CloneRefData(const wxObjectRefData
* data
) const
103 const wxGraphicsObjectRefData
* ptr
= (const wxGraphicsObjectRefData
*) data
;
107 //-----------------------------------------------------------------------------
109 //-----------------------------------------------------------------------------
111 IMPLEMENT_DYNAMIC_CLASS(wxGraphicsPen
, wxGraphicsObject
)
112 IMPLEMENT_DYNAMIC_CLASS(wxGraphicsBrush
, wxGraphicsObject
)
113 IMPLEMENT_DYNAMIC_CLASS(wxGraphicsFont
, wxGraphicsObject
)
114 IMPLEMENT_DYNAMIC_CLASS(wxGraphicsBitmap
, wxGraphicsObject
)
116 WXDLLIMPEXP_DATA_CORE(wxGraphicsPen
) wxNullGraphicsPen
;
117 WXDLLIMPEXP_DATA_CORE(wxGraphicsBrush
) wxNullGraphicsBrush
;
118 WXDLLIMPEXP_DATA_CORE(wxGraphicsFont
) wxNullGraphicsFont
;
119 WXDLLIMPEXP_DATA_CORE(wxGraphicsBitmap
) wxNullGraphicsBitmap
;
121 //-----------------------------------------------------------------------------
123 //-----------------------------------------------------------------------------
125 IMPLEMENT_DYNAMIC_CLASS(wxGraphicsMatrix
, wxGraphicsObject
)
126 WXDLLIMPEXP_DATA_CORE(wxGraphicsMatrix
) wxNullGraphicsMatrix
;
128 // concatenates the matrix
129 void wxGraphicsMatrix::Concat( const wxGraphicsMatrix
*t
)
132 GetMatrixData()->Concat(t
->GetMatrixData());
135 // sets the matrix to the respective values
136 void wxGraphicsMatrix::Set(wxDouble a
, wxDouble b
, wxDouble c
, wxDouble d
,
137 wxDouble tx
, wxDouble ty
)
140 GetMatrixData()->Set(a
,b
,c
,d
,tx
,ty
);
143 // gets the component valuess of the matrix
144 void wxGraphicsMatrix::Get(wxDouble
* a
, wxDouble
* b
, wxDouble
* c
,
145 wxDouble
* d
, wxDouble
* tx
, wxDouble
* ty
) const
147 GetMatrixData()->Get(a
, b
, c
, d
, tx
, ty
);
150 // makes this the inverse matrix
151 void wxGraphicsMatrix::Invert()
154 GetMatrixData()->Invert();
157 // returns true if the elements of the transformation matrix are equal ?
158 bool wxGraphicsMatrix::IsEqual( const wxGraphicsMatrix
* t
) const
160 return GetMatrixData()->IsEqual(t
->GetMatrixData());
163 // return true if this is the identity matrix
164 bool wxGraphicsMatrix::IsIdentity() const
166 return GetMatrixData()->IsIdentity();
169 // add the translation to this matrix
170 void wxGraphicsMatrix::Translate( wxDouble dx
, wxDouble dy
)
173 GetMatrixData()->Translate(dx
,dy
);
176 // add the scale to this matrix
177 void wxGraphicsMatrix::Scale( wxDouble xScale
, wxDouble yScale
)
180 GetMatrixData()->Scale(xScale
,yScale
);
183 // add the rotation to this matrix (radians)
184 void wxGraphicsMatrix::Rotate( wxDouble angle
)
187 GetMatrixData()->Rotate(angle
);
191 // apply the transforms
194 // applies that matrix to the point
195 void wxGraphicsMatrix::TransformPoint( wxDouble
*x
, wxDouble
*y
) const
197 GetMatrixData()->TransformPoint(x
,y
);
200 // applies the matrix except for translations
201 void wxGraphicsMatrix::TransformDistance( wxDouble
*dx
, wxDouble
*dy
) const
203 GetMatrixData()->TransformDistance(dx
,dy
);
206 // returns the native representation
207 void * wxGraphicsMatrix::GetNativeMatrix() const
209 return GetMatrixData()->GetNativeMatrix();
212 //-----------------------------------------------------------------------------
214 //-----------------------------------------------------------------------------
216 IMPLEMENT_DYNAMIC_CLASS(wxGraphicsPath
, wxGraphicsObject
)
217 WXDLLIMPEXP_DATA_CORE(wxGraphicsPath
) wxNullGraphicsPath
;
219 // convenience functions, for using wxPoint2DDouble etc
221 wxPoint2DDouble
wxGraphicsPath::GetCurrentPoint() const
224 GetCurrentPoint(&x
,&y
);
225 return wxPoint2DDouble(x
,y
);
228 void wxGraphicsPath::MoveToPoint( const wxPoint2DDouble
& p
)
230 MoveToPoint( p
.m_x
, p
.m_y
);
233 void wxGraphicsPath::AddLineToPoint( const wxPoint2DDouble
& p
)
235 AddLineToPoint( p
.m_x
, p
.m_y
);
238 void wxGraphicsPath::AddCurveToPoint( const wxPoint2DDouble
& c1
, const wxPoint2DDouble
& c2
, const wxPoint2DDouble
& e
)
240 AddCurveToPoint(c1
.m_x
, c1
.m_y
, c2
.m_x
, c2
.m_y
, e
.m_x
, e
.m_y
);
243 void wxGraphicsPath::AddArc( const wxPoint2DDouble
& c
, wxDouble r
, wxDouble startAngle
, wxDouble endAngle
, bool clockwise
)
245 AddArc(c
.m_x
, c
.m_y
, r
, startAngle
, endAngle
, clockwise
);
248 wxRect2DDouble
wxGraphicsPath::GetBox() const
252 return wxRect2DDouble( x
,y
,w
,h
);
255 bool wxGraphicsPath::Contains( const wxPoint2DDouble
& c
, wxPolygonFillMode fillStyle
) const
257 return Contains( c
.m_x
, c
.m_y
, fillStyle
);
262 // begins a new subpath at (x,y)
263 void wxGraphicsPath::MoveToPoint( wxDouble x
, wxDouble y
)
266 GetPathData()->MoveToPoint(x
,y
);
269 // adds a straight line from the current point to (x,y)
270 void wxGraphicsPath::AddLineToPoint( wxDouble x
, wxDouble y
)
273 GetPathData()->AddLineToPoint(x
,y
);
276 // adds a cubic Bezier curve from the current point, using two control points and an end point
277 void wxGraphicsPath::AddCurveToPoint( wxDouble cx1
, wxDouble cy1
, wxDouble cx2
, wxDouble cy2
, wxDouble x
, wxDouble y
)
280 GetPathData()->AddCurveToPoint(cx1
,cy1
,cx2
,cy2
,x
,y
);
284 void wxGraphicsPath::AddPath( const wxGraphicsPath
& path
)
287 GetPathData()->AddPath(path
.GetPathData());
290 // closes the current sub-path
291 void wxGraphicsPath::CloseSubpath()
294 GetPathData()->CloseSubpath();
297 // gets the last point of the current path, (0,0) if not yet set
298 void wxGraphicsPath::GetCurrentPoint( wxDouble
* x
, wxDouble
* y
) const
300 GetPathData()->GetCurrentPoint(x
,y
);
303 // adds an arc of a circle centering at (x,y) with radius (r) from startAngle to endAngle
304 void wxGraphicsPath::AddArc( wxDouble x
, wxDouble y
, wxDouble r
, wxDouble startAngle
, wxDouble endAngle
, bool clockwise
)
307 GetPathData()->AddArc(x
,y
,r
,startAngle
,endAngle
,clockwise
);
311 // These are convenience functions which - if not available natively will be assembled
312 // using the primitives from above
315 // adds a quadratic Bezier curve from the current point, using a control point and an end point
316 void wxGraphicsPath::AddQuadCurveToPoint( wxDouble cx
, wxDouble cy
, wxDouble x
, wxDouble y
)
319 GetPathData()->AddQuadCurveToPoint(cx
,cy
,x
,y
);
322 // appends a rectangle as a new closed subpath
323 void wxGraphicsPath::AddRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
)
326 GetPathData()->AddRectangle(x
,y
,w
,h
);
329 // appends an ellipsis as a new closed subpath fitting the passed rectangle
330 void wxGraphicsPath::AddCircle( wxDouble x
, wxDouble y
, wxDouble r
)
333 GetPathData()->AddCircle(x
,y
,r
);
336 // appends a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1) to (x2,y2), also a straight line from (current) to (x1,y1)
337 void wxGraphicsPath::AddArcToPoint( wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
, wxDouble r
)
339 GetPathData()->AddArcToPoint(x1
,y1
,x2
,y2
,r
);
342 // appends an ellipse
343 void wxGraphicsPath::AddEllipse( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
)
346 GetPathData()->AddEllipse(x
,y
,w
,h
);
349 // appends a rounded rectangle
350 void wxGraphicsPath::AddRoundedRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
, wxDouble radius
)
353 GetPathData()->AddRoundedRectangle(x
,y
,w
,h
,radius
);
356 // returns the native path
357 void * wxGraphicsPath::GetNativePath() const
359 return GetPathData()->GetNativePath();
362 // give the native path returned by GetNativePath() back (there might be some deallocations necessary)
363 void wxGraphicsPath::UnGetNativePath(void *p
)const
365 GetPathData()->UnGetNativePath(p
);
368 // transforms each point of this path by the matrix
369 void wxGraphicsPath::Transform( const wxGraphicsMatrix
& matrix
)
372 GetPathData()->Transform(matrix
.GetMatrixData());
375 // gets the bounding box enclosing all points (possibly including control points)
376 void wxGraphicsPath::GetBox(wxDouble
*x
, wxDouble
*y
, wxDouble
*w
, wxDouble
*h
) const
378 GetPathData()->GetBox(x
,y
,w
,h
);
381 bool wxGraphicsPath::Contains( wxDouble x
, wxDouble y
, wxPolygonFillMode fillStyle
) const
383 return GetPathData()->Contains(x
,y
,fillStyle
);
387 // Emulations, these mus be implemented in the ...Data classes in order to allow for proper overrides
390 void wxGraphicsPathData::AddQuadCurveToPoint( wxDouble cx
, wxDouble cy
, wxDouble x
, wxDouble y
)
392 // calculate using degree elevation to a cubic bezier
396 wxPoint2DDouble start
;
397 GetCurrentPoint(&start
.m_x
,&start
.m_y
);
398 wxPoint2DDouble
end(x
,y
);
399 wxPoint2DDouble
c(cx
,cy
);
400 c1
= wxDouble(1/3.0) * start
+ wxDouble(2/3.0) * c
;
401 c2
= wxDouble(2/3.0) * c
+ wxDouble(1/3.0) * end
;
402 AddCurveToPoint(c1
.m_x
,c1
.m_y
,c2
.m_x
,c2
.m_y
,x
,y
);
405 void wxGraphicsPathData::AddRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
)
408 AddLineToPoint(x
,y
+h
);
409 AddLineToPoint(x
+w
,y
+h
);
410 AddLineToPoint(x
+w
,y
);
414 void wxGraphicsPathData::AddCircle( wxDouble x
, wxDouble y
, wxDouble r
)
417 AddArc( x
,y
,r
,0,2*M_PI
,false);
421 void wxGraphicsPathData::AddEllipse( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
)
423 if (w
<= 0. || h
<= 0.)
428 wxDouble xc
= x
+ rw
;
429 wxDouble yc
= y
+ rh
;
430 wxGraphicsMatrix m
= GetRenderer()->CreateMatrix();
433 wxGraphicsPath p
= GetRenderer()->CreatePath();
436 AddPath(p
.GetPathData());
439 void wxGraphicsPathData::AddRoundedRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
, wxDouble radius
)
442 AddRectangle(x
,y
,w
,h
);
445 MoveToPoint( x
+ w
, y
+ h
/ 2);
446 AddArcToPoint(x
+ w
, y
+ h
, x
+ w
/ 2, y
+ h
, radius
);
447 AddArcToPoint(x
, y
+ h
, x
, y
+ h
/ 2, radius
);
448 AddArcToPoint(x
, y
, x
+ w
/ 2, y
, radius
);
449 AddArcToPoint(x
+ w
, y
, x
+ w
, y
+ h
/ 2, radius
);
454 // draws a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1) to (x2,y2), also a straight line from (current) to (x1,y1)
455 void wxGraphicsPathData::AddArcToPoint( wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
, wxDouble r
)
457 wxPoint2DDouble current
;
458 GetCurrentPoint(¤t
.m_x
,¤t
.m_y
);
459 wxPoint2DDouble
p1(x1
,y1
);
460 wxPoint2DDouble
p2(x2
,y2
);
462 wxPoint2DDouble v1
= current
- p1
;
464 wxPoint2DDouble v2
= p2
- p1
;
467 wxDouble alpha
= v1
.GetVectorAngle() - v2
.GetVectorAngle();
471 // TODO obtuse angles
473 alpha
= DegToRad(alpha
);
475 wxDouble dist
= r
/ sin(alpha
/2) * cos(alpha
/2);
476 // calculate tangential points
477 wxPoint2DDouble t1
= dist
*v1
+ p1
;
479 wxPoint2DDouble nv1
= v1
;
480 nv1
.SetVectorAngle(v1
.GetVectorAngle()-90);
481 wxPoint2DDouble c
= t1
+ r
*nv1
;
483 wxDouble a1
= v1
.GetVectorAngle()+90;
484 wxDouble a2
= v2
.GetVectorAngle()-90;
486 AddLineToPoint(t1
.m_x
,t1
.m_y
);
487 AddArc(c
.m_x
,c
.m_y
,r
,DegToRad(a1
),DegToRad(a2
),true);
488 AddLineToPoint(p2
.m_x
,p2
.m_y
);
491 //-----------------------------------------------------------------------------
492 // wxGraphicsGradientStops
493 //-----------------------------------------------------------------------------
495 void wxGraphicsGradientStops::Add(const wxGraphicsGradientStop
& stop
)
497 for ( wxVector
<wxGraphicsGradientStop
>::iterator it
= m_stops
.begin();
501 if ( stop
.GetPosition() < it
->GetPosition() )
503 if ( it
!= m_stops
.begin() )
505 m_stops
.insert(it
, stop
);
507 else // we shouldn't be inserting it at the beginning
509 wxFAIL_MSG( "invalid gradient stop position < 0" );
516 if ( stop
.GetPosition() == 1. )
518 m_stops
.insert(m_stops
.end() - 1, stop
);
522 wxFAIL_MSG( "invalid gradient stop position > 1" );
526 void * wxGraphicsBitmap::GetNativeBitmap() const
528 return GetBitmapData()->GetNativeBitmap();
531 //-----------------------------------------------------------------------------
532 // wxGraphicsContext Convenience Methods
533 //-----------------------------------------------------------------------------
535 IMPLEMENT_ABSTRACT_CLASS(wxGraphicsContext
, wxObject
)
538 wxGraphicsContext::wxGraphicsContext(wxGraphicsRenderer
* renderer
) :
539 wxGraphicsObject(renderer
),
540 m_antialias(wxANTIALIAS_DEFAULT
),
541 m_composition(wxCOMPOSITION_OVER
),
542 m_enableOffset(false)
546 wxGraphicsContext::~wxGraphicsContext()
550 bool wxGraphicsContext::StartDoc(const wxString
& WXUNUSED(message
))
555 void wxGraphicsContext::EndDoc()
559 void wxGraphicsContext::StartPage(wxDouble
WXUNUSED(width
),
560 wxDouble
WXUNUSED(height
))
564 void wxGraphicsContext::EndPage()
568 void wxGraphicsContext::Flush()
572 void wxGraphicsContext::EnableOffset(bool enable
)
574 m_enableOffset
= enable
;
578 void wxGraphicsContext::SetAlpha( wxDouble
WXUNUSED(alpha
) )
582 wxDouble
wxGraphicsContext::GetAlpha() const
588 void wxGraphicsContext::GetDPI( wxDouble
* dpiX
, wxDouble
* dpiY
)
595 void wxGraphicsContext::SetPen( const wxGraphicsPen
& pen
)
600 void wxGraphicsContext::SetPen( const wxPen
& pen
)
602 if ( !pen
.IsOk() || pen
.GetStyle() == wxPENSTYLE_TRANSPARENT
)
603 SetPen( wxNullGraphicsPen
);
605 SetPen( CreatePen( pen
) );
608 // sets the brush for filling
609 void wxGraphicsContext::SetBrush( const wxGraphicsBrush
& brush
)
614 void wxGraphicsContext::SetBrush( const wxBrush
& brush
)
616 if ( !brush
.IsOk() || brush
.GetStyle() == wxBRUSHSTYLE_TRANSPARENT
)
617 SetBrush( wxNullGraphicsBrush
);
619 SetBrush( CreateBrush( brush
) );
622 // sets the brush for filling
623 void wxGraphicsContext::SetFont( const wxGraphicsFont
& font
)
628 void wxGraphicsContext::SetFont( const wxFont
& font
, const wxColour
& colour
)
631 SetFont( CreateFont( font
, colour
) );
633 SetFont( wxNullGraphicsFont
);
636 void wxGraphicsContext::DrawPath( const wxGraphicsPath
& path
, wxPolygonFillMode fillStyle
)
638 FillPath( path
, fillStyle
);
643 wxGraphicsContext::DoDrawRotatedText(const wxString
&str
,
650 DrawText( str
, 0, 0 );
656 wxGraphicsContext::DoDrawFilledText(const wxString
&str
,
659 const wxGraphicsBrush
& backgroundBrush
)
661 wxGraphicsBrush formerBrush
= m_brush
;
662 wxGraphicsPen formerPen
= m_pen
;
666 wxDouble externalLeading
;
667 GetTextExtent( str
, &width
, &height
, &descent
, &externalLeading
);
668 SetBrush( backgroundBrush
);
669 // to make sure our 'OffsetToPixelBoundaries' doesn't move the fill shape
670 SetPen( wxNullGraphicsPen
);
672 DrawRectangle(x
, y
, width
, height
);
674 DrawText( str
, x
,y
);
675 SetBrush( formerBrush
);
680 wxGraphicsContext::DoDrawRotatedFilledText(const wxString
&str
,
681 wxDouble x
, wxDouble y
,
683 const wxGraphicsBrush
& backgroundBrush
)
685 wxGraphicsBrush formerBrush
= m_brush
;
686 wxGraphicsPen formerPen
= m_pen
;
691 wxDouble externalLeading
;
692 GetTextExtent( str
, &width
, &height
, &descent
, &externalLeading
);
693 SetBrush( backgroundBrush
);
694 // to make sure our 'OffsetToPixelBoundaries' doesn't move the fill shape
695 SetPen( wxNullGraphicsPen
);
697 wxGraphicsPath path
= CreatePath();
698 path
.MoveToPoint( x
, y
);
699 path
.AddLineToPoint( (int) (x
+ sin(angle
) * height
) , (int) (y
+ cos(angle
) * height
) );
701 (int) (x
+ sin(angle
) * height
+ cos(angle
) * width
) ,
702 (int) (y
+ cos(angle
) * height
- sin(angle
) * width
));
703 path
.AddLineToPoint((int) (x
+ cos(angle
) * width
) , (int) (y
- sin(angle
) * width
) );
705 DrawText( str
, x
,y
, angle
);
706 SetBrush( formerBrush
);
710 void wxGraphicsContext::StrokeLine( wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
)
712 wxGraphicsPath path
= CreatePath();
713 path
.MoveToPoint(x1
, y1
);
714 path
.AddLineToPoint( x2
, y2
);
718 void wxGraphicsContext::DrawRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
)
720 wxGraphicsPath path
= CreatePath();
721 path
.AddRectangle( x
, y
, w
, h
);
725 void wxGraphicsContext::DrawEllipse( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
)
727 wxGraphicsPath path
= CreatePath();
728 path
.AddEllipse(x
,y
,w
,h
);
732 void wxGraphicsContext::DrawRoundedRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
, wxDouble radius
)
734 wxGraphicsPath path
= CreatePath();
735 path
.AddRoundedRectangle(x
,y
,w
,h
,radius
);
739 void wxGraphicsContext::StrokeLines( size_t n
, const wxPoint2DDouble
*points
)
742 wxGraphicsPath path
= CreatePath();
743 path
.MoveToPoint(points
[0].m_x
, points
[0].m_y
);
744 for ( size_t i
= 1; i
< n
; ++i
)
745 path
.AddLineToPoint( points
[i
].m_x
, points
[i
].m_y
);
749 void wxGraphicsContext::DrawLines( size_t n
, const wxPoint2DDouble
*points
, wxPolygonFillMode fillStyle
)
752 wxGraphicsPath path
= CreatePath();
753 path
.MoveToPoint(points
[0].m_x
, points
[0].m_y
);
754 for ( size_t i
= 1; i
< n
; ++i
)
755 path
.AddLineToPoint( points
[i
].m_x
, points
[i
].m_y
);
756 DrawPath( path
, fillStyle
);
759 void wxGraphicsContext::StrokeLines( size_t n
, const wxPoint2DDouble
*beginPoints
, const wxPoint2DDouble
*endPoints
)
762 wxGraphicsPath path
= CreatePath();
763 for ( size_t i
= 0; i
< n
; ++i
)
765 path
.MoveToPoint(beginPoints
[i
].m_x
, beginPoints
[i
].m_y
);
766 path
.AddLineToPoint( endPoints
[i
].m_x
, endPoints
[i
].m_y
);
771 // create a 'native' matrix corresponding to these values
772 wxGraphicsMatrix
wxGraphicsContext::CreateMatrix( wxDouble a
, wxDouble b
, wxDouble c
, wxDouble d
,
773 wxDouble tx
, wxDouble ty
) const
775 return GetRenderer()->CreateMatrix(a
,b
,c
,d
,tx
,ty
);
778 wxGraphicsPath
wxGraphicsContext::CreatePath() const
780 return GetRenderer()->CreatePath();
783 wxGraphicsPen
wxGraphicsContext::CreatePen(const wxPen
& pen
) const
785 return GetRenderer()->CreatePen(pen
);
788 wxGraphicsBrush
wxGraphicsContext::CreateBrush(const wxBrush
& brush
) const
790 return GetRenderer()->CreateBrush(brush
);
794 wxGraphicsContext::CreateLinearGradientBrush(
795 wxDouble x1
, wxDouble y1
,
796 wxDouble x2
, wxDouble y2
,
797 const wxColour
& c1
, const wxColour
& c2
) const
799 return GetRenderer()->CreateLinearGradientBrush
803 wxGraphicsGradientStops(c1
,c2
)
808 wxGraphicsContext::CreateLinearGradientBrush(
809 wxDouble x1
, wxDouble y1
,
810 wxDouble x2
, wxDouble y2
,
811 const wxGraphicsGradientStops
& gradientStops
) const
813 return GetRenderer()->CreateLinearGradientBrush(x1
,y1
,x2
,y2
, gradientStops
);
817 wxGraphicsContext::CreateRadialGradientBrush(
818 wxDouble xo
, wxDouble yo
,
819 wxDouble xc
, wxDouble yc
, wxDouble radius
,
820 const wxColour
&oColor
, const wxColour
&cColor
) const
822 return GetRenderer()->CreateRadialGradientBrush
826 wxGraphicsGradientStops(oColor
, cColor
)
831 wxGraphicsContext::CreateRadialGradientBrush(
832 wxDouble xo
, wxDouble yo
,
833 wxDouble xc
, wxDouble yc
, wxDouble radius
,
834 const wxGraphicsGradientStops
& gradientStops
) const
836 return GetRenderer()->CreateRadialGradientBrush
844 wxGraphicsFont
wxGraphicsContext::CreateFont( const wxFont
&font
, const wxColour
&col
) const
846 return GetRenderer()->CreateFont(font
,col
);
850 wxGraphicsContext::CreateFont(double size
,
851 const wxString
& facename
,
853 const wxColour
& col
) const
855 return GetRenderer()->CreateFont(size
, facename
, flags
, col
);
858 wxGraphicsBitmap
wxGraphicsContext::CreateBitmap( const wxBitmap
& bmp
) const
860 return GetRenderer()->CreateBitmap(bmp
);
864 wxGraphicsBitmap
wxGraphicsContext::CreateBitmapFromImage(const wxImage
& image
) const
866 return GetRenderer()->CreateBitmapFromImage(image
);
868 #endif // wxUSE_IMAGE
870 wxGraphicsBitmap
wxGraphicsContext::CreateSubBitmap( const wxGraphicsBitmap
&bmp
, wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
) const
872 return GetRenderer()->CreateSubBitmap(bmp
,x
,y
,w
,h
);
875 /* static */ wxGraphicsContext
* wxGraphicsContext::Create( const wxWindowDC
& dc
)
877 return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(dc
);
880 /* static */ wxGraphicsContext
* wxGraphicsContext::Create( const wxMemoryDC
& dc
)
882 return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(dc
);
885 #if wxUSE_PRINTING_ARCHITECTURE
886 /* static */ wxGraphicsContext
* wxGraphicsContext::Create( const wxPrinterDC
& dc
)
888 return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(dc
);
893 #if wxUSE_ENH_METAFILE
894 /* static */ wxGraphicsContext
* wxGraphicsContext::Create( const wxEnhMetaFileDC
& dc
)
896 return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(dc
);
901 wxGraphicsContext
* wxGraphicsContext::CreateFromNative( void * context
)
903 return wxGraphicsRenderer::GetDefaultRenderer()->CreateContextFromNativeContext(context
);
906 wxGraphicsContext
* wxGraphicsContext::CreateFromNativeWindow( void * window
)
908 return wxGraphicsRenderer::GetDefaultRenderer()->CreateContextFromNativeWindow(window
);
911 wxGraphicsContext
* wxGraphicsContext::Create( wxWindow
* window
)
913 return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(window
);
917 /* static */ wxGraphicsContext
* wxGraphicsContext::Create(wxImage
& image
)
919 return wxGraphicsRenderer::GetDefaultRenderer()->CreateContextFromImage(image
);
921 #endif // wxUSE_IMAGE
923 wxGraphicsContext
* wxGraphicsContext::Create()
925 return wxGraphicsRenderer::GetDefaultRenderer()->CreateMeasuringContext();
928 //-----------------------------------------------------------------------------
929 // wxGraphicsRenderer
930 //-----------------------------------------------------------------------------
932 IMPLEMENT_ABSTRACT_CLASS(wxGraphicsRenderer
, wxObject
)
934 #endif // wxUSE_GRAPHICS_CONTEXT