1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/graphcmn.cpp
3 // Purpose: graphics context methods common to all platforms
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
15 #if defined(__BORLANDC__)
19 #if wxUSE_GRAPHICS_CONTEXT
21 #include "wx/graphics.h"
25 #include "wx/bitmap.h"
26 #include "wx/dcmemory.h"
27 #include "wx/region.h"
31 #include "wx/private/graphics.h"
33 //-----------------------------------------------------------------------------
35 //-----------------------------------------------------------------------------
37 static inline double DegToRad(double deg
)
39 return (deg
* M_PI
) / 180.0;
42 //-----------------------------------------------------------------------------
44 //-----------------------------------------------------------------------------
46 //-----------------------------------------------------------------------------
48 IMPLEMENT_DYNAMIC_CLASS(wxGraphicsObject
, wxObject
)
50 wxGraphicsObjectRefData::wxGraphicsObjectRefData( wxGraphicsRenderer
* renderer
)
52 m_renderer
= renderer
;
54 wxGraphicsObjectRefData::wxGraphicsObjectRefData( const wxGraphicsObjectRefData
* data
)
56 m_renderer
= data
->m_renderer
;
58 wxGraphicsRenderer
* wxGraphicsObjectRefData::GetRenderer() const
63 wxGraphicsObjectRefData
* wxGraphicsObjectRefData::Clone() const
65 return new wxGraphicsObjectRefData(this);
68 wxGraphicsObject::wxGraphicsObject()
72 wxGraphicsObject::wxGraphicsObject( wxGraphicsRenderer
* renderer
)
74 SetRefData( new wxGraphicsObjectRefData(renderer
));
77 wxGraphicsObject::~wxGraphicsObject()
81 bool wxGraphicsObject::IsNull() const
83 return m_refData
== NULL
;
86 wxGraphicsRenderer
* wxGraphicsObject::GetRenderer() const
88 return ( IsNull() ? NULL
: GetGraphicsData()->GetRenderer() );
91 wxGraphicsObjectRefData
* wxGraphicsObject::GetGraphicsData() const
93 return (wxGraphicsObjectRefData
*) m_refData
;
96 wxObjectRefData
* wxGraphicsObject::CreateRefData() const
98 wxLogDebug(wxT("A Null Object cannot be changed"));
102 wxObjectRefData
* wxGraphicsObject::CloneRefData(const wxObjectRefData
* data
) const
104 const wxGraphicsObjectRefData
* ptr
= (const wxGraphicsObjectRefData
*) data
;
108 //-----------------------------------------------------------------------------
110 //-----------------------------------------------------------------------------
112 IMPLEMENT_DYNAMIC_CLASS(wxGraphicsPen
, wxGraphicsObject
)
113 IMPLEMENT_DYNAMIC_CLASS(wxGraphicsBrush
, wxGraphicsObject
)
114 IMPLEMENT_DYNAMIC_CLASS(wxGraphicsFont
, wxGraphicsObject
)
115 IMPLEMENT_DYNAMIC_CLASS(wxGraphicsBitmap
, wxGraphicsObject
)
117 WXDLLIMPEXP_DATA_CORE(wxGraphicsPen
) wxNullGraphicsPen
;
118 WXDLLIMPEXP_DATA_CORE(wxGraphicsBrush
) wxNullGraphicsBrush
;
119 WXDLLIMPEXP_DATA_CORE(wxGraphicsFont
) wxNullGraphicsFont
;
120 WXDLLIMPEXP_DATA_CORE(wxGraphicsBitmap
) wxNullGraphicsBitmap
;
122 //-----------------------------------------------------------------------------
124 //-----------------------------------------------------------------------------
126 IMPLEMENT_DYNAMIC_CLASS(wxGraphicsMatrix
, wxGraphicsObject
)
127 WXDLLIMPEXP_DATA_CORE(wxGraphicsMatrix
) wxNullGraphicsMatrix
;
129 // concatenates the matrix
130 void wxGraphicsMatrix::Concat( const wxGraphicsMatrix
*t
)
133 GetMatrixData()->Concat(t
->GetMatrixData());
136 // sets the matrix to the respective values
137 void wxGraphicsMatrix::Set(wxDouble a
, wxDouble b
, wxDouble c
, wxDouble d
,
138 wxDouble tx
, wxDouble ty
)
141 GetMatrixData()->Set(a
,b
,c
,d
,tx
,ty
);
144 // gets the component valuess of the matrix
145 void wxGraphicsMatrix::Get(wxDouble
* a
, wxDouble
* b
, wxDouble
* c
,
146 wxDouble
* d
, wxDouble
* tx
, wxDouble
* ty
) const
148 GetMatrixData()->Get(a
, b
, c
, d
, tx
, ty
);
151 // makes this the inverse matrix
152 void wxGraphicsMatrix::Invert()
155 GetMatrixData()->Invert();
158 // returns true if the elements of the transformation matrix are equal ?
159 bool wxGraphicsMatrix::IsEqual( const wxGraphicsMatrix
* t
) const
161 return GetMatrixData()->IsEqual(t
->GetMatrixData());
164 // return true if this is the identity matrix
165 bool wxGraphicsMatrix::IsIdentity() const
167 return GetMatrixData()->IsIdentity();
170 // add the translation to this matrix
171 void wxGraphicsMatrix::Translate( wxDouble dx
, wxDouble dy
)
174 GetMatrixData()->Translate(dx
,dy
);
177 // add the scale to this matrix
178 void wxGraphicsMatrix::Scale( wxDouble xScale
, wxDouble yScale
)
181 GetMatrixData()->Scale(xScale
,yScale
);
184 // add the rotation to this matrix (radians)
185 void wxGraphicsMatrix::Rotate( wxDouble angle
)
188 GetMatrixData()->Rotate(angle
);
192 // apply the transforms
195 // applies that matrix to the point
196 void wxGraphicsMatrix::TransformPoint( wxDouble
*x
, wxDouble
*y
) const
198 GetMatrixData()->TransformPoint(x
,y
);
201 // applies the matrix except for translations
202 void wxGraphicsMatrix::TransformDistance( wxDouble
*dx
, wxDouble
*dy
) const
204 GetMatrixData()->TransformDistance(dx
,dy
);
207 // returns the native representation
208 void * wxGraphicsMatrix::GetNativeMatrix() const
210 return GetMatrixData()->GetNativeMatrix();
213 //-----------------------------------------------------------------------------
215 //-----------------------------------------------------------------------------
217 IMPLEMENT_DYNAMIC_CLASS(wxGraphicsPath
, wxGraphicsObject
)
218 WXDLLIMPEXP_DATA_CORE(wxGraphicsPath
) wxNullGraphicsPath
;
220 // convenience functions, for using wxPoint2DDouble etc
222 wxPoint2DDouble
wxGraphicsPath::GetCurrentPoint() const
225 GetCurrentPoint(&x
,&y
);
226 return wxPoint2DDouble(x
,y
);
229 void wxGraphicsPath::MoveToPoint( const wxPoint2DDouble
& p
)
231 MoveToPoint( p
.m_x
, p
.m_y
);
234 void wxGraphicsPath::AddLineToPoint( const wxPoint2DDouble
& p
)
236 AddLineToPoint( p
.m_x
, p
.m_y
);
239 void wxGraphicsPath::AddCurveToPoint( const wxPoint2DDouble
& c1
, const wxPoint2DDouble
& c2
, const wxPoint2DDouble
& e
)
241 AddCurveToPoint(c1
.m_x
, c1
.m_y
, c2
.m_x
, c2
.m_y
, e
.m_x
, e
.m_y
);
244 void wxGraphicsPath::AddArc( const wxPoint2DDouble
& c
, wxDouble r
, wxDouble startAngle
, wxDouble endAngle
, bool clockwise
)
246 AddArc(c
.m_x
, c
.m_y
, r
, startAngle
, endAngle
, clockwise
);
249 wxRect2DDouble
wxGraphicsPath::GetBox() const
253 return wxRect2DDouble( x
,y
,w
,h
);
256 bool wxGraphicsPath::Contains( const wxPoint2DDouble
& c
, wxPolygonFillMode fillStyle
) const
258 return Contains( c
.m_x
, c
.m_y
, fillStyle
);
263 // begins a new subpath at (x,y)
264 void wxGraphicsPath::MoveToPoint( wxDouble x
, wxDouble y
)
267 GetPathData()->MoveToPoint(x
,y
);
270 // adds a straight line from the current point to (x,y)
271 void wxGraphicsPath::AddLineToPoint( wxDouble x
, wxDouble y
)
274 GetPathData()->AddLineToPoint(x
,y
);
277 // adds a cubic Bezier curve from the current point, using two control points and an end point
278 void wxGraphicsPath::AddCurveToPoint( wxDouble cx1
, wxDouble cy1
, wxDouble cx2
, wxDouble cy2
, wxDouble x
, wxDouble y
)
281 GetPathData()->AddCurveToPoint(cx1
,cy1
,cx2
,cy2
,x
,y
);
285 void wxGraphicsPath::AddPath( const wxGraphicsPath
& path
)
288 GetPathData()->AddPath(path
.GetPathData());
291 // closes the current sub-path
292 void wxGraphicsPath::CloseSubpath()
295 GetPathData()->CloseSubpath();
298 // gets the last point of the current path, (0,0) if not yet set
299 void wxGraphicsPath::GetCurrentPoint( wxDouble
* x
, wxDouble
* y
) const
301 GetPathData()->GetCurrentPoint(x
,y
);
304 // adds an arc of a circle centering at (x,y) with radius (r) from startAngle to endAngle
305 void wxGraphicsPath::AddArc( wxDouble x
, wxDouble y
, wxDouble r
, wxDouble startAngle
, wxDouble endAngle
, bool clockwise
)
308 GetPathData()->AddArc(x
,y
,r
,startAngle
,endAngle
,clockwise
);
312 // These are convenience functions which - if not available natively will be assembled
313 // using the primitives from above
316 // adds a quadratic Bezier curve from the current point, using a control point and an end point
317 void wxGraphicsPath::AddQuadCurveToPoint( wxDouble cx
, wxDouble cy
, wxDouble x
, wxDouble y
)
320 GetPathData()->AddQuadCurveToPoint(cx
,cy
,x
,y
);
323 // appends a rectangle as a new closed subpath
324 void wxGraphicsPath::AddRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
)
327 GetPathData()->AddRectangle(x
,y
,w
,h
);
330 // appends an ellipsis as a new closed subpath fitting the passed rectangle
331 void wxGraphicsPath::AddCircle( wxDouble x
, wxDouble y
, wxDouble r
)
334 GetPathData()->AddCircle(x
,y
,r
);
337 // 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)
338 void wxGraphicsPath::AddArcToPoint( wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
, wxDouble r
)
340 GetPathData()->AddArcToPoint(x1
,y1
,x2
,y2
,r
);
343 // appends an ellipse
344 void wxGraphicsPath::AddEllipse( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
)
347 GetPathData()->AddEllipse(x
,y
,w
,h
);
350 // appends a rounded rectangle
351 void wxGraphicsPath::AddRoundedRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
, wxDouble radius
)
354 GetPathData()->AddRoundedRectangle(x
,y
,w
,h
,radius
);
357 // returns the native path
358 void * wxGraphicsPath::GetNativePath() const
360 return GetPathData()->GetNativePath();
363 // give the native path returned by GetNativePath() back (there might be some deallocations necessary)
364 void wxGraphicsPath::UnGetNativePath(void *p
)const
366 GetPathData()->UnGetNativePath(p
);
369 // transforms each point of this path by the matrix
370 void wxGraphicsPath::Transform( const wxGraphicsMatrix
& matrix
)
373 GetPathData()->Transform(matrix
.GetMatrixData());
376 // gets the bounding box enclosing all points (possibly including control points)
377 void wxGraphicsPath::GetBox(wxDouble
*x
, wxDouble
*y
, wxDouble
*w
, wxDouble
*h
) const
379 GetPathData()->GetBox(x
,y
,w
,h
);
382 bool wxGraphicsPath::Contains( wxDouble x
, wxDouble y
, wxPolygonFillMode fillStyle
) const
384 return GetPathData()->Contains(x
,y
,fillStyle
);
388 // Emulations, these mus be implemented in the ...Data classes in order to allow for proper overrides
391 void wxGraphicsPathData::AddQuadCurveToPoint( wxDouble cx
, wxDouble cy
, wxDouble x
, wxDouble y
)
393 // calculate using degree elevation to a cubic bezier
397 wxPoint2DDouble start
;
398 GetCurrentPoint(&start
.m_x
,&start
.m_y
);
399 wxPoint2DDouble
end(x
,y
);
400 wxPoint2DDouble
c(cx
,cy
);
401 c1
= wxDouble(1/3.0) * start
+ wxDouble(2/3.0) * c
;
402 c2
= wxDouble(2/3.0) * c
+ wxDouble(1/3.0) * end
;
403 AddCurveToPoint(c1
.m_x
,c1
.m_y
,c2
.m_x
,c2
.m_y
,x
,y
);
406 void wxGraphicsPathData::AddRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
)
409 AddLineToPoint(x
,y
+h
);
410 AddLineToPoint(x
+w
,y
+h
);
411 AddLineToPoint(x
+w
,y
);
415 void wxGraphicsPathData::AddCircle( wxDouble x
, wxDouble y
, wxDouble r
)
418 AddArc( x
,y
,r
,0,2*M_PI
,false);
422 void wxGraphicsPathData::AddEllipse( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
)
424 if (w
<= 0. || h
<= 0.)
429 wxDouble xc
= x
+ rw
;
430 wxDouble yc
= y
+ rh
;
431 wxGraphicsMatrix m
= GetRenderer()->CreateMatrix();
434 wxGraphicsPath p
= GetRenderer()->CreatePath();
437 AddPath(p
.GetPathData());
440 void wxGraphicsPathData::AddRoundedRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
, wxDouble radius
)
443 AddRectangle(x
,y
,w
,h
);
446 MoveToPoint( x
+ w
, y
+ h
/ 2);
447 AddArcToPoint(x
+ w
, y
+ h
, x
+ w
/ 2, y
+ h
, radius
);
448 AddArcToPoint(x
, y
+ h
, x
, y
+ h
/ 2, radius
);
449 AddArcToPoint(x
, y
, x
+ w
/ 2, y
, radius
);
450 AddArcToPoint(x
+ w
, y
, x
+ w
, y
+ h
/ 2, radius
);
455 // 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)
456 void wxGraphicsPathData::AddArcToPoint( wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
, wxDouble r
)
458 wxPoint2DDouble current
;
459 GetCurrentPoint(¤t
.m_x
,¤t
.m_y
);
460 wxPoint2DDouble
p1(x1
,y1
);
461 wxPoint2DDouble
p2(x2
,y2
);
463 wxPoint2DDouble v1
= current
- p1
;
465 wxPoint2DDouble v2
= p2
- p1
;
468 wxDouble alpha
= v1
.GetVectorAngle() - v2
.GetVectorAngle();
472 // TODO obtuse angles
474 alpha
= DegToRad(alpha
);
476 wxDouble dist
= r
/ sin(alpha
/2) * cos(alpha
/2);
477 // calculate tangential points
478 wxPoint2DDouble t1
= dist
*v1
+ p1
;
480 wxPoint2DDouble nv1
= v1
;
481 nv1
.SetVectorAngle(v1
.GetVectorAngle()-90);
482 wxPoint2DDouble c
= t1
+ r
*nv1
;
484 wxDouble a1
= v1
.GetVectorAngle()+90;
485 wxDouble a2
= v2
.GetVectorAngle()-90;
487 AddLineToPoint(t1
.m_x
,t1
.m_y
);
488 AddArc(c
.m_x
,c
.m_y
,r
,DegToRad(a1
),DegToRad(a2
),true);
489 AddLineToPoint(p2
.m_x
,p2
.m_y
);
492 //-----------------------------------------------------------------------------
493 // wxGraphicsGradientStops
494 //-----------------------------------------------------------------------------
496 void wxGraphicsGradientStops::Add(const wxGraphicsGradientStop
& stop
)
498 for ( wxVector
<wxGraphicsGradientStop
>::iterator it
= m_stops
.begin();
502 if ( stop
.GetPosition() < it
->GetPosition() )
504 if ( it
!= m_stops
.begin() )
506 m_stops
.insert(it
, stop
);
508 else // we shouldn't be inserting it at the beginning
510 wxFAIL_MSG( "invalid gradient stop position < 0" );
517 if ( stop
.GetPosition() == 1. )
519 m_stops
.insert(m_stops
.end() - 1, stop
);
523 wxFAIL_MSG( "invalid gradient stop position > 1" );
527 //-----------------------------------------------------------------------------
528 // wxGraphicsContext Convenience Methods
529 //-----------------------------------------------------------------------------
531 IMPLEMENT_ABSTRACT_CLASS(wxGraphicsContext
, wxObject
)
534 wxGraphicsContext::wxGraphicsContext(wxGraphicsRenderer
* renderer
) :
535 wxGraphicsObject(renderer
),
536 m_antialias(wxANTIALIAS_DEFAULT
),
537 m_composition(wxCOMPOSITION_OVER
),
538 m_enableOffset(false)
542 wxGraphicsContext::~wxGraphicsContext()
546 bool wxGraphicsContext::StartDoc(const wxString
& WXUNUSED(message
))
551 void wxGraphicsContext::EndDoc()
555 void wxGraphicsContext::StartPage(wxDouble
WXUNUSED(width
),
556 wxDouble
WXUNUSED(height
))
560 void wxGraphicsContext::EndPage()
564 void wxGraphicsContext::Flush()
568 void wxGraphicsContext::EnableOffset(bool enable
)
570 m_enableOffset
= enable
;
574 void wxGraphicsContext::SetAlpha( wxDouble
WXUNUSED(alpha
) )
578 wxDouble
wxGraphicsContext::GetAlpha() const
584 void wxGraphicsContext::GetDPI( wxDouble
* dpiX
, wxDouble
* dpiY
)
591 void wxGraphicsContext::SetPen( const wxGraphicsPen
& pen
)
596 void wxGraphicsContext::SetPen( const wxPen
& pen
)
598 if ( !pen
.IsOk() || pen
.GetStyle() == wxPENSTYLE_TRANSPARENT
)
599 SetPen( wxNullGraphicsPen
);
601 SetPen( CreatePen( pen
) );
604 // sets the brush for filling
605 void wxGraphicsContext::SetBrush( const wxGraphicsBrush
& brush
)
610 void wxGraphicsContext::SetBrush( const wxBrush
& brush
)
612 if ( !brush
.IsOk() || brush
.GetStyle() == wxBRUSHSTYLE_TRANSPARENT
)
613 SetBrush( wxNullGraphicsBrush
);
615 SetBrush( CreateBrush( brush
) );
618 // sets the brush for filling
619 void wxGraphicsContext::SetFont( const wxGraphicsFont
& font
)
624 void wxGraphicsContext::SetFont( const wxFont
& font
, const wxColour
& colour
)
627 SetFont( CreateFont( font
, colour
) );
629 SetFont( wxNullGraphicsFont
);
632 void wxGraphicsContext::DrawPath( const wxGraphicsPath
& path
, wxPolygonFillMode fillStyle
)
634 FillPath( path
, fillStyle
);
639 wxGraphicsContext::DoDrawRotatedText(const wxString
&str
,
646 DrawText( str
, 0, 0 );
652 wxGraphicsContext::DoDrawFilledText(const wxString
&str
,
655 const wxGraphicsBrush
& backgroundBrush
)
657 wxGraphicsBrush formerBrush
= m_brush
;
658 wxGraphicsPen formerPen
= m_pen
;
662 wxDouble externalLeading
;
663 GetTextExtent( str
, &width
, &height
, &descent
, &externalLeading
);
664 SetBrush( backgroundBrush
);
665 // to make sure our 'OffsetToPixelBoundaries' doesn't move the fill shape
666 SetPen( wxNullGraphicsPen
);
668 wxGraphicsPath path
= CreatePath();
669 path
.AddRectangle( x
, y
, width
, height
);
672 DrawText( str
, x
,y
);
673 SetBrush( formerBrush
);
678 wxGraphicsContext::DoDrawRotatedFilledText(const wxString
&str
,
679 wxDouble x
, wxDouble y
,
681 const wxGraphicsBrush
& backgroundBrush
)
683 wxGraphicsBrush formerBrush
= m_brush
;
684 wxGraphicsPen formerPen
= m_pen
;
689 wxDouble externalLeading
;
690 GetTextExtent( str
, &width
, &height
, &descent
, &externalLeading
);
691 SetBrush( backgroundBrush
);
692 // to make sure our 'OffsetToPixelBoundaries' doesn't move the fill shape
693 SetPen( wxNullGraphicsPen
);
695 wxGraphicsPath path
= CreatePath();
696 path
.MoveToPoint( x
, y
);
697 path
.AddLineToPoint( (int) (x
+ sin(angle
) * height
) , (int) (y
+ cos(angle
) * height
) );
699 (int) (x
+ sin(angle
) * height
+ cos(angle
) * width
) ,
700 (int) (y
+ cos(angle
) * height
- sin(angle
) * width
));
701 path
.AddLineToPoint((int) (x
+ cos(angle
) * width
) , (int) (y
- sin(angle
) * width
) );
703 DrawText( str
, x
,y
, angle
);
704 SetBrush( formerBrush
);
708 void wxGraphicsContext::StrokeLine( wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
)
710 wxGraphicsPath path
= CreatePath();
711 path
.MoveToPoint(x1
, y1
);
712 path
.AddLineToPoint( x2
, y2
);
716 void wxGraphicsContext::DrawRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
)
718 wxGraphicsPath path
= CreatePath();
719 path
.AddRectangle( x
, y
, w
, h
);
723 void wxGraphicsContext::DrawEllipse( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
)
725 wxGraphicsPath path
= CreatePath();
726 path
.AddEllipse(x
,y
,w
,h
);
730 void wxGraphicsContext::DrawRoundedRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
, wxDouble radius
)
732 wxGraphicsPath path
= CreatePath();
733 path
.AddRoundedRectangle(x
,y
,w
,h
,radius
);
737 void wxGraphicsContext::StrokeLines( size_t n
, const wxPoint2DDouble
*points
)
740 wxGraphicsPath path
= CreatePath();
741 path
.MoveToPoint(points
[0].m_x
, points
[0].m_y
);
742 for ( size_t i
= 1; i
< n
; ++i
)
743 path
.AddLineToPoint( points
[i
].m_x
, points
[i
].m_y
);
747 void wxGraphicsContext::DrawLines( size_t n
, const wxPoint2DDouble
*points
, wxPolygonFillMode fillStyle
)
750 wxGraphicsPath path
= CreatePath();
751 path
.MoveToPoint(points
[0].m_x
, points
[0].m_y
);
752 for ( size_t i
= 1; i
< n
; ++i
)
753 path
.AddLineToPoint( points
[i
].m_x
, points
[i
].m_y
);
754 DrawPath( path
, fillStyle
);
757 void wxGraphicsContext::StrokeLines( size_t n
, const wxPoint2DDouble
*beginPoints
, const wxPoint2DDouble
*endPoints
)
760 wxGraphicsPath path
= CreatePath();
761 for ( size_t i
= 0; i
< n
; ++i
)
763 path
.MoveToPoint(beginPoints
[i
].m_x
, beginPoints
[i
].m_y
);
764 path
.AddLineToPoint( endPoints
[i
].m_x
, endPoints
[i
].m_y
);
769 // create a 'native' matrix corresponding to these values
770 wxGraphicsMatrix
wxGraphicsContext::CreateMatrix( wxDouble a
, wxDouble b
, wxDouble c
, wxDouble d
,
771 wxDouble tx
, wxDouble ty
) const
773 return GetRenderer()->CreateMatrix(a
,b
,c
,d
,tx
,ty
);
776 wxGraphicsPath
wxGraphicsContext::CreatePath() const
778 return GetRenderer()->CreatePath();
781 wxGraphicsPen
wxGraphicsContext::CreatePen(const wxPen
& pen
) const
783 return GetRenderer()->CreatePen(pen
);
786 wxGraphicsBrush
wxGraphicsContext::CreateBrush(const wxBrush
& brush
) const
788 return GetRenderer()->CreateBrush(brush
);
792 wxGraphicsContext::CreateLinearGradientBrush(
793 wxDouble x1
, wxDouble y1
,
794 wxDouble x2
, wxDouble y2
,
795 const wxColour
& c1
, const wxColour
& c2
) const
797 return GetRenderer()->CreateLinearGradientBrush
801 wxGraphicsGradientStops(c1
,c2
)
806 wxGraphicsContext::CreateLinearGradientBrush(
807 wxDouble x1
, wxDouble y1
,
808 wxDouble x2
, wxDouble y2
,
809 const wxGraphicsGradientStops
& gradientStops
) const
811 return GetRenderer()->CreateLinearGradientBrush(x1
,y1
,x2
,y2
, gradientStops
);
815 wxGraphicsContext::CreateRadialGradientBrush(
816 wxDouble xo
, wxDouble yo
,
817 wxDouble xc
, wxDouble yc
, wxDouble radius
,
818 const wxColour
&oColor
, const wxColour
&cColor
) const
820 return GetRenderer()->CreateRadialGradientBrush
824 wxGraphicsGradientStops(oColor
, cColor
)
829 wxGraphicsContext::CreateRadialGradientBrush(
830 wxDouble xo
, wxDouble yo
,
831 wxDouble xc
, wxDouble yc
, wxDouble radius
,
832 const wxGraphicsGradientStops
& gradientStops
) const
834 return GetRenderer()->CreateRadialGradientBrush
843 wxGraphicsFont
wxGraphicsContext::CreateFont( const wxFont
&font
, const wxColour
&col
) const
845 return GetRenderer()->CreateFont(font
,col
);
848 wxGraphicsBitmap
wxGraphicsContext::CreateBitmap( const wxBitmap
& bmp
) const
850 return GetRenderer()->CreateBitmap(bmp
);
853 wxGraphicsBitmap
wxGraphicsContext::CreateSubBitmap( const wxGraphicsBitmap
&bmp
, wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
) const
855 return GetRenderer()->CreateSubBitmap(bmp
,x
,y
,w
,h
);
858 /* static */ wxGraphicsContext
* wxGraphicsContext::Create( const wxWindowDC
& dc
)
860 return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(dc
);
863 /* static */ wxGraphicsContext
* wxGraphicsContext::Create( const wxMemoryDC
& dc
)
865 return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(dc
);
868 #if wxUSE_PRINTING_ARCHITECTURE
869 /* static */ wxGraphicsContext
* wxGraphicsContext::Create( const wxPrinterDC
& dc
)
871 return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(dc
);
876 #if wxUSE_ENH_METAFILE
877 /* static */ wxGraphicsContext
* wxGraphicsContext::Create( const wxEnhMetaFileDC
& dc
)
879 return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(dc
);
884 wxGraphicsContext
* wxGraphicsContext::CreateFromNative( void * context
)
886 return wxGraphicsRenderer::GetDefaultRenderer()->CreateContextFromNativeContext(context
);
889 wxGraphicsContext
* wxGraphicsContext::CreateFromNativeWindow( void * window
)
891 return wxGraphicsRenderer::GetDefaultRenderer()->CreateContextFromNativeWindow(window
);
894 wxGraphicsContext
* wxGraphicsContext::Create( wxWindow
* window
)
896 return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(window
);
899 wxGraphicsContext
* wxGraphicsContext::Create()
901 return wxGraphicsRenderer::GetDefaultRenderer()->CreateMeasuringContext();
904 //-----------------------------------------------------------------------------
905 // wxGraphicsRenderer
906 //-----------------------------------------------------------------------------
908 IMPLEMENT_ABSTRACT_CLASS(wxGraphicsRenderer
, wxObject
)
910 #endif // wxUSE_GRAPHICS_CONTEXT