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/private/graphics.h"
25 #include "wx/bitmap.h"
26 #include "wx/dcmemory.h"
27 #include "wx/region.h"
31 //-----------------------------------------------------------------------------
33 //-----------------------------------------------------------------------------
35 static const double RAD2DEG
= 180.0 / M_PI
;
37 //-----------------------------------------------------------------------------
39 //-----------------------------------------------------------------------------
41 static inline double DegToRad(double deg
)
43 return (deg
* M_PI
) / 180.0;
46 //-----------------------------------------------------------------------------
48 //-----------------------------------------------------------------------------
50 //-----------------------------------------------------------------------------
52 IMPLEMENT_DYNAMIC_CLASS(wxGraphicsObject
, wxObject
)
54 wxGraphicsObjectRefData::wxGraphicsObjectRefData( wxGraphicsRenderer
* renderer
)
56 m_renderer
= renderer
;
58 wxGraphicsObjectRefData::wxGraphicsObjectRefData( const wxGraphicsObjectRefData
* data
)
60 m_renderer
= data
->m_renderer
;
62 wxGraphicsRenderer
* wxGraphicsObjectRefData::GetRenderer() const
67 wxGraphicsObjectRefData
* wxGraphicsObjectRefData::Clone() const
69 return new wxGraphicsObjectRefData(this);
72 wxGraphicsObject::wxGraphicsObject()
76 wxGraphicsObject::wxGraphicsObject( wxGraphicsRenderer
* renderer
)
78 SetRefData( new wxGraphicsObjectRefData(renderer
));
81 wxGraphicsObject::~wxGraphicsObject()
85 bool wxGraphicsObject::IsNull() const
87 return m_refData
== NULL
;
90 wxGraphicsRenderer
* wxGraphicsObject::GetRenderer() const
92 return ( IsNull() ? NULL
: GetGraphicsData()->GetRenderer() );
95 wxGraphicsObjectRefData
* wxGraphicsObject::GetGraphicsData() const
97 return (wxGraphicsObjectRefData
*) m_refData
;
100 wxObjectRefData
* wxGraphicsObject::CreateRefData() const
102 wxLogDebug(wxT("A Null Object cannot be changed"));
106 wxObjectRefData
* wxGraphicsObject::CloneRefData(const wxObjectRefData
* data
) const
108 const wxGraphicsObjectRefData
* ptr
= (const wxGraphicsObjectRefData
*) data
;
112 //-----------------------------------------------------------------------------
114 //-----------------------------------------------------------------------------
116 IMPLEMENT_DYNAMIC_CLASS(wxGraphicsPen
, wxGraphicsObject
)
117 IMPLEMENT_DYNAMIC_CLASS(wxGraphicsBrush
, wxGraphicsObject
)
118 IMPLEMENT_DYNAMIC_CLASS(wxGraphicsFont
, wxGraphicsObject
)
120 WXDLLIMPEXP_DATA_CORE(wxGraphicsPen
) wxNullGraphicsPen
;
121 WXDLLIMPEXP_DATA_CORE(wxGraphicsBrush
) wxNullGraphicsBrush
;
122 WXDLLIMPEXP_DATA_CORE(wxGraphicsFont
) wxNullGraphicsFont
;
124 //-----------------------------------------------------------------------------
126 //-----------------------------------------------------------------------------
128 IMPLEMENT_DYNAMIC_CLASS(wxGraphicsMatrix
, wxGraphicsObject
)
129 WXDLLIMPEXP_DATA_CORE(wxGraphicsMatrix
) wxNullGraphicsMatrix
;
131 // concatenates the matrix
132 void wxGraphicsMatrix::Concat( const wxGraphicsMatrix
*t
)
135 GetMatrixData()->Concat(t
->GetMatrixData());
138 // sets the matrix to the respective values
139 void wxGraphicsMatrix::Set(wxDouble a
, wxDouble b
, wxDouble c
, wxDouble d
,
140 wxDouble tx
, wxDouble ty
)
143 GetMatrixData()->Set(a
,b
,c
,d
,tx
,ty
);
146 // gets the component valuess of the matrix
147 void wxGraphicsMatrix::Get(wxDouble
* a
, wxDouble
* b
, wxDouble
* c
,
148 wxDouble
* d
, wxDouble
* tx
, wxDouble
* ty
) const
150 GetMatrixData()->Get(a
, b
, c
, d
, tx
, ty
);
153 // makes this the inverse matrix
154 void wxGraphicsMatrix::Invert()
157 GetMatrixData()->Invert();
160 // returns true if the elements of the transformation matrix are equal ?
161 bool wxGraphicsMatrix::IsEqual( const wxGraphicsMatrix
* t
) const
163 return GetMatrixData()->IsEqual(t
->GetMatrixData());
166 // return true if this is the identity matrix
167 bool wxGraphicsMatrix::IsIdentity() const
169 return GetMatrixData()->IsIdentity();
172 // add the translation to this matrix
173 void wxGraphicsMatrix::Translate( wxDouble dx
, wxDouble dy
)
176 GetMatrixData()->Translate(dx
,dy
);
179 // add the scale to this matrix
180 void wxGraphicsMatrix::Scale( wxDouble xScale
, wxDouble yScale
)
183 GetMatrixData()->Scale(xScale
,yScale
);
186 // add the rotation to this matrix (radians)
187 void wxGraphicsMatrix::Rotate( wxDouble angle
)
190 GetMatrixData()->Rotate(angle
);
194 // apply the transforms
197 // applies that matrix to the point
198 void wxGraphicsMatrix::TransformPoint( wxDouble
*x
, wxDouble
*y
) const
200 GetMatrixData()->TransformPoint(x
,y
);
203 // applies the matrix except for translations
204 void wxGraphicsMatrix::TransformDistance( wxDouble
*dx
, wxDouble
*dy
) const
206 GetMatrixData()->TransformDistance(dx
,dy
);
209 // returns the native representation
210 void * wxGraphicsMatrix::GetNativeMatrix() const
212 return GetMatrixData()->GetNativeMatrix();
215 //-----------------------------------------------------------------------------
217 //-----------------------------------------------------------------------------
219 IMPLEMENT_DYNAMIC_CLASS(wxGraphicsPath
, wxGraphicsObject
)
220 WXDLLIMPEXP_DATA_CORE(wxGraphicsPath
) wxNullGraphicsPath
;
222 // convenience functions, for using wxPoint2DDouble etc
224 wxPoint2DDouble
wxGraphicsPath::GetCurrentPoint() const
227 GetCurrentPoint(&x
,&y
);
228 return wxPoint2DDouble(x
,y
);
231 void wxGraphicsPath::MoveToPoint( const wxPoint2DDouble
& p
)
233 MoveToPoint( p
.m_x
, p
.m_y
);
236 void wxGraphicsPath::AddLineToPoint( const wxPoint2DDouble
& p
)
238 AddLineToPoint( p
.m_x
, p
.m_y
);
241 void wxGraphicsPath::AddCurveToPoint( const wxPoint2DDouble
& c1
, const wxPoint2DDouble
& c2
, const wxPoint2DDouble
& e
)
243 AddCurveToPoint(c1
.m_x
, c1
.m_y
, c2
.m_x
, c2
.m_y
, e
.m_x
, e
.m_y
);
246 void wxGraphicsPath::AddArc( const wxPoint2DDouble
& c
, wxDouble r
, wxDouble startAngle
, wxDouble endAngle
, bool clockwise
)
248 AddArc(c
.m_x
, c
.m_y
, r
, startAngle
, endAngle
, clockwise
);
251 wxRect2DDouble
wxGraphicsPath::GetBox() const
255 return wxRect2DDouble( x
,y
,w
,h
);
258 bool wxGraphicsPath::Contains( const wxPoint2DDouble
& c
, int fillStyle
) const
260 return Contains( c
.m_x
, c
.m_y
, fillStyle
);
265 // begins a new subpath at (x,y)
266 void wxGraphicsPath::MoveToPoint( wxDouble x
, wxDouble y
)
269 GetPathData()->MoveToPoint(x
,y
);
272 // adds a straight line from the current point to (x,y)
273 void wxGraphicsPath::AddLineToPoint( wxDouble x
, wxDouble y
)
276 GetPathData()->AddLineToPoint(x
,y
);
279 // adds a cubic Bezier curve from the current point, using two control points and an end point
280 void wxGraphicsPath::AddCurveToPoint( wxDouble cx1
, wxDouble cy1
, wxDouble cx2
, wxDouble cy2
, wxDouble x
, wxDouble y
)
283 GetPathData()->AddCurveToPoint(cx1
,cy1
,cx2
,cy2
,x
,y
);
287 void wxGraphicsPath::AddPath( const wxGraphicsPath
& path
)
290 GetPathData()->AddPath(path
.GetPathData());
293 // closes the current sub-path
294 void wxGraphicsPath::CloseSubpath()
297 GetPathData()->CloseSubpath();
300 // gets the last point of the current path, (0,0) if not yet set
301 void wxGraphicsPath::GetCurrentPoint( wxDouble
* x
, wxDouble
* y
) const
303 GetPathData()->GetCurrentPoint(x
,y
);
306 // adds an arc of a circle centering at (x,y) with radius (r) from startAngle to endAngle
307 void wxGraphicsPath::AddArc( wxDouble x
, wxDouble y
, wxDouble r
, wxDouble startAngle
, wxDouble endAngle
, bool clockwise
)
310 GetPathData()->AddArc(x
,y
,r
,startAngle
,endAngle
,clockwise
);
314 // These are convenience functions which - if not available natively will be assembled
315 // using the primitives from above
318 // adds a quadratic Bezier curve from the current point, using a control point and an end point
319 void wxGraphicsPath::AddQuadCurveToPoint( wxDouble cx
, wxDouble cy
, wxDouble x
, wxDouble y
)
322 GetPathData()->AddQuadCurveToPoint(cx
,cy
,x
,y
);
325 // appends a rectangle as a new closed subpath
326 void wxGraphicsPath::AddRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
)
329 GetPathData()->AddRectangle(x
,y
,w
,h
);
332 // appends an ellipsis as a new closed subpath fitting the passed rectangle
333 void wxGraphicsPath::AddCircle( wxDouble x
, wxDouble y
, wxDouble r
)
336 GetPathData()->AddCircle(x
,y
,r
);
339 // 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)
340 void wxGraphicsPath::AddArcToPoint( wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
, wxDouble r
)
342 GetPathData()->AddArcToPoint(x1
,y1
,x2
,y2
,r
);
345 // appends an ellipse
346 void wxGraphicsPath::AddEllipse( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
)
349 GetPathData()->AddEllipse(x
,y
,w
,h
);
352 // appends a rounded rectangle
353 void wxGraphicsPath::AddRoundedRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
, wxDouble radius
)
356 GetPathData()->AddRoundedRectangle(x
,y
,w
,h
,radius
);
359 // returns the native path
360 void * wxGraphicsPath::GetNativePath() const
362 return GetPathData()->GetNativePath();
365 // give the native path returned by GetNativePath() back (there might be some deallocations necessary)
366 void wxGraphicsPath::UnGetNativePath(void *p
)const
368 GetPathData()->UnGetNativePath(p
);
371 // transforms each point of this path by the matrix
372 void wxGraphicsPath::Transform( const wxGraphicsMatrix
& matrix
)
375 GetPathData()->Transform(matrix
.GetMatrixData());
378 // gets the bounding box enclosing all points (possibly including control points)
379 void wxGraphicsPath::GetBox(wxDouble
*x
, wxDouble
*y
, wxDouble
*w
, wxDouble
*h
) const
381 GetPathData()->GetBox(x
,y
,w
,h
);
384 bool wxGraphicsPath::Contains( wxDouble x
, wxDouble y
, int fillStyle
) const
386 return GetPathData()->Contains(x
,y
,fillStyle
);
390 // Emulations, these mus be implemented in the ...Data classes in order to allow for proper overrides
393 void wxGraphicsPathData::AddQuadCurveToPoint( wxDouble cx
, wxDouble cy
, wxDouble x
, wxDouble y
)
395 // calculate using degree elevation to a cubic bezier
399 wxPoint2DDouble start
;
400 GetCurrentPoint(&start
.m_x
,&start
.m_y
);
401 wxPoint2DDouble
end(x
,y
);
402 wxPoint2DDouble
c(cx
,cy
);
403 c1
= wxDouble(1/3.0) * start
+ wxDouble(2/3.0) * c
;
404 c2
= wxDouble(2/3.0) * c
+ wxDouble(1/3.0) * end
;
405 AddCurveToPoint(c1
.m_x
,c1
.m_y
,c2
.m_x
,c2
.m_y
,x
,y
);
408 void wxGraphicsPathData::AddRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
)
411 AddLineToPoint(x
,y
+h
);
412 AddLineToPoint(x
+w
,y
+h
);
413 AddLineToPoint(x
+w
,y
);
417 void wxGraphicsPathData::AddCircle( wxDouble x
, wxDouble y
, wxDouble r
)
420 AddArc( x
,y
,r
,0,2*M_PI
,false);
424 void wxGraphicsPathData::AddEllipse( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
)
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
;
478 wxPoint2DDouble t2
= dist
*v2
+ 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 // wxGraphicsContext Convenience Methods
494 //-----------------------------------------------------------------------------
496 IMPLEMENT_ABSTRACT_CLASS(wxGraphicsContext
, wxObject
)
499 wxGraphicsContext::wxGraphicsContext(wxGraphicsRenderer
* renderer
) : wxGraphicsObject(renderer
)
501 m_logicalFunction
= wxCOPY
;
504 wxGraphicsContext::~wxGraphicsContext()
508 bool wxGraphicsContext::StartDoc(const wxString
& WXUNUSED(message
))
513 void wxGraphicsContext::EndDoc()
517 void wxGraphicsContext::StartPage(wxDouble
WXUNUSED(width
),
518 wxDouble
WXUNUSED(height
))
522 void wxGraphicsContext::EndPage()
526 void wxGraphicsContext::Flush()
531 void wxGraphicsContext::SetAlpha( wxDouble
WXUNUSED(alpha
) )
535 wxDouble
wxGraphicsContext::GetAlpha() const
541 void wxGraphicsContext::GetSize( wxDouble
* width
, wxDouble
* height
)
547 void wxGraphicsContext::GetDPI( wxDouble
* dpiX
, wxDouble
* dpiY
)
554 void wxGraphicsContext::SetPen( const wxGraphicsPen
& pen
)
559 void wxGraphicsContext::SetPen( const wxPen
& pen
)
561 if ( !pen
.Ok() || pen
.GetStyle() == wxTRANSPARENT
)
562 SetPen( wxNullGraphicsPen
);
564 SetPen( CreatePen( pen
) );
567 // sets the brush for filling
568 void wxGraphicsContext::SetBrush( const wxGraphicsBrush
& brush
)
573 void wxGraphicsContext::SetBrush( const wxBrush
& brush
)
575 if ( !brush
.Ok() || brush
.GetStyle() == wxTRANSPARENT
)
576 SetBrush( wxNullGraphicsBrush
);
578 SetBrush( CreateBrush( brush
) );
581 // sets the brush for filling
582 void wxGraphicsContext::SetFont( const wxGraphicsFont
& font
)
587 bool wxGraphicsContext::SetLogicalFunction( int function
)
589 if ( function
== wxCOPY
)
591 m_logicalFunction
= function
;
597 void wxGraphicsContext::SetFont( const wxFont
& font
, const wxColour
& colour
)
600 SetFont( CreateFont( font
, colour
) );
602 SetFont( wxNullGraphicsFont
);
605 void wxGraphicsContext::DrawPath( const wxGraphicsPath
& path
, int fillStyle
)
607 FillPath( path
, fillStyle
);
611 void wxGraphicsContext::DrawText( const wxString
&str
, wxDouble x
, wxDouble y
, wxDouble angle
)
615 DrawText( str
, 0, 0 );
620 void wxGraphicsContext::DrawText( const wxString
&str
, wxDouble x
, wxDouble y
, const wxGraphicsBrush
& backgroundBrush
)
622 wxGraphicsBrush formerBrush
= m_brush
;
623 wxGraphicsPen formerPen
= m_pen
;
627 wxDouble externalLeading
;
628 GetTextExtent( str
, &width
, &height
, &descent
, &externalLeading
);
629 SetBrush( backgroundBrush
);
630 // to make sure our 'OffsetToPixelBoundaries' doesn't move the fill shape
631 SetPen( wxNullGraphicsPen
);
633 wxGraphicsPath path
= CreatePath();
634 path
.AddRectangle( x
, y
, width
, height
);
637 DrawText( str
, x
,y
);
638 SetBrush( formerBrush
);
642 void wxGraphicsContext::DrawText( const wxString
&str
, wxDouble x
, wxDouble y
, wxDouble angle
, const wxGraphicsBrush
& backgroundBrush
)
644 wxGraphicsBrush formerBrush
= m_brush
;
645 wxGraphicsPen formerPen
= m_pen
;
650 wxDouble externalLeading
;
651 GetTextExtent( str
, &width
, &height
, &descent
, &externalLeading
);
652 SetBrush( backgroundBrush
);
653 // to make sure our 'OffsetToPixelBoundaries' doesn't move the fill shape
654 SetPen( wxNullGraphicsPen
);
656 wxGraphicsPath path
= CreatePath();
657 path
.MoveToPoint( x
, y
);
658 path
.AddLineToPoint( (int) (x
+ sin(angle
) * height
) , (int) (y
+ cos(angle
) * height
) );
660 (int) (x
+ sin(angle
) * height
+ cos(angle
) * width
) ,
661 (int) (y
+ cos(angle
) * height
- sin(angle
) * width
));
662 path
.AddLineToPoint((int) (x
+ cos(angle
) * width
) , (int) (y
- sin(angle
) * width
) );
664 DrawText( str
, x
,y
, angle
);
665 SetBrush( formerBrush
);
669 void wxGraphicsContext::StrokeLine( wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
)
671 wxGraphicsPath path
= CreatePath();
672 path
.MoveToPoint(x1
, y1
);
673 path
.AddLineToPoint( x2
, y2
);
677 void wxGraphicsContext::DrawRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
)
679 wxGraphicsPath path
= CreatePath();
680 path
.AddRectangle( x
, y
, w
, h
);
684 void wxGraphicsContext::DrawEllipse( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
)
686 wxGraphicsPath path
= CreatePath();
687 path
.AddEllipse(x
,y
,w
,h
);
691 void wxGraphicsContext::DrawRoundedRectangle( wxDouble x
, wxDouble y
, wxDouble w
, wxDouble h
, wxDouble radius
)
693 wxGraphicsPath path
= CreatePath();
694 path
.AddRoundedRectangle(x
,y
,w
,h
,radius
);
698 void wxGraphicsContext::StrokeLines( size_t n
, const wxPoint2DDouble
*points
)
701 wxGraphicsPath path
= CreatePath();
702 path
.MoveToPoint(points
[0].m_x
, points
[0].m_y
);
703 for ( size_t i
= 1; i
< n
; ++i
)
704 path
.AddLineToPoint( points
[i
].m_x
, points
[i
].m_y
);
708 void wxGraphicsContext::DrawLines( size_t n
, const wxPoint2DDouble
*points
, int fillStyle
)
711 wxGraphicsPath path
= CreatePath();
712 path
.MoveToPoint(points
[0].m_x
, points
[0].m_y
);
713 for ( size_t i
= 1; i
< n
; ++i
)
714 path
.AddLineToPoint( points
[i
].m_x
, points
[i
].m_y
);
715 DrawPath( path
, fillStyle
);
718 void wxGraphicsContext::StrokeLines( size_t n
, const wxPoint2DDouble
*beginPoints
, const wxPoint2DDouble
*endPoints
)
721 wxGraphicsPath path
= CreatePath();
722 for ( size_t i
= 0; i
< n
; ++i
)
724 path
.MoveToPoint(beginPoints
[i
].m_x
, beginPoints
[i
].m_y
);
725 path
.AddLineToPoint( endPoints
[i
].m_x
, endPoints
[i
].m_y
);
730 // create a 'native' matrix corresponding to these values
731 wxGraphicsMatrix
wxGraphicsContext::CreateMatrix( wxDouble a
, wxDouble b
, wxDouble c
, wxDouble d
,
732 wxDouble tx
, wxDouble ty
) const
734 return GetRenderer()->CreateMatrix(a
,b
,c
,d
,tx
,ty
);
737 wxGraphicsPath
wxGraphicsContext::CreatePath() const
739 return GetRenderer()->CreatePath();
742 wxGraphicsPen
wxGraphicsContext::CreatePen(const wxPen
& pen
) const
744 return GetRenderer()->CreatePen(pen
);
747 wxGraphicsBrush
wxGraphicsContext::CreateBrush(const wxBrush
& brush
) const
749 return GetRenderer()->CreateBrush(brush
);
752 // sets the brush to a linear gradient, starting at (x1,y1) with color c1 to (x2,y2) with color c2
753 wxGraphicsBrush
wxGraphicsContext::CreateLinearGradientBrush( wxDouble x1
, wxDouble y1
, wxDouble x2
, wxDouble y2
,
754 const wxColour
&c1
, const wxColour
&c2
) const
756 return GetRenderer()->CreateLinearGradientBrush(x1
,y1
,x2
,y2
,c1
,c2
);
759 // sets the brush to a radial gradient originating at (xo,yc) with color oColor and ends on a circle around (xc,yc)
760 // with radius r and color cColor
761 wxGraphicsBrush
wxGraphicsContext::CreateRadialGradientBrush( wxDouble xo
, wxDouble yo
, wxDouble xc
, wxDouble yc
, wxDouble radius
,
762 const wxColour
&oColor
, const wxColour
&cColor
) const
764 return GetRenderer()->CreateRadialGradientBrush(xo
,yo
,xc
,yc
,radius
,oColor
,cColor
);
768 wxGraphicsFont
wxGraphicsContext::CreateFont( const wxFont
&font
, const wxColour
&col
) const
770 return GetRenderer()->CreateFont(font
,col
);
773 wxGraphicsContext
* wxGraphicsContext::Create( const wxWindowDC
& dc
)
775 return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(dc
);
778 wxGraphicsContext
* wxGraphicsContext::Create( const wxMemoryDC
& dc
)
780 return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(dc
);
783 wxGraphicsContext
* wxGraphicsContext::CreateFromNative( void * context
)
785 return wxGraphicsRenderer::GetDefaultRenderer()->CreateContextFromNativeContext(context
);
788 wxGraphicsContext
* wxGraphicsContext::CreateFromNativeWindow( void * window
)
790 return wxGraphicsRenderer::GetDefaultRenderer()->CreateContextFromNativeWindow(window
);
793 wxGraphicsContext
* wxGraphicsContext::Create( wxWindow
* window
)
795 return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(window
);
798 wxGraphicsContext
* wxGraphicsContext::Create()
800 return wxGraphicsRenderer::GetDefaultRenderer()->CreateMeasuringContext();
803 //-----------------------------------------------------------------------------
804 // wxGraphicsRenderer
805 //-----------------------------------------------------------------------------
807 IMPLEMENT_ABSTRACT_CLASS(wxGraphicsRenderer
, wxObject
)
809 #endif // wxUSE_GRAPHICS_CONTEXT