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"
30 #ifndef wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
31 #define wxMAC_USE_CORE_GRAPHICS_BLEND_MODES 0
34 //-----------------------------------------------------------------------------
36 //-----------------------------------------------------------------------------
38 static const double RAD2DEG
= 180.0 / M_PI
;
40 //-----------------------------------------------------------------------------
42 //-----------------------------------------------------------------------------
44 static inline double DegToRad(double deg
)
46 return (deg
* M_PI
) / 180.0;
49 //-----------------------------------------------------------------------------
51 //-----------------------------------------------------------------------------
54 IMPLEMENT_DYNAMIC_CLASS(wxGCDC
, wxDCBase
)
56 IMPLEMENT_DYNAMIC_CLASS(wxGCDC
, wxDC
)
64 void wxGCDC::SetGraphicsContext( wxGraphicsContext
* ctx
)
66 delete m_graphicContext
;
67 m_graphicContext
= ctx
;
68 if ( m_graphicContext
)
70 m_matrixOriginal
= m_graphicContext
->GetTransform();
75 wxGCDC::wxGCDC(const wxWindowDC
& dc
)
78 SetGraphicsContext( wxGraphicsContext::Create(dc
) );
79 if ( dc
.GetFont().Ok())
80 m_graphicContext
->SetFont( m_graphicContext
->CreateFont(dc
.GetFont(),dc
.GetTextForeground()));
81 if ( dc
.GetPen().Ok())
82 m_graphicContext
->SetPen( m_graphicContext
->CreatePen(dc
.GetPen()));
83 if ( dc
.GetBrush().Ok())
84 m_graphicContext
->SetBrush( m_graphicContext
->CreateBrush(dc
.GetBrush()));
91 m_mm_to_pix_x
= mm2pt
;
92 m_mm_to_pix_y
= mm2pt
;
95 m_font
= *wxNORMAL_FONT
;
96 m_brush
= *wxWHITE_BRUSH
;
98 m_graphicContext
= NULL
;
104 delete m_graphicContext
;
107 void wxGCDC::DoDrawBitmap( const wxBitmap
&bmp
, wxCoord x
, wxCoord y
, bool WXUNUSED(useMask
) )
109 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid DC") );
110 wxCHECK_RET( bmp
.Ok(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid bitmap") );
112 m_graphicContext
->DrawBitmap( bmp
, x
, y
, bmp
.GetWidth() , bmp
.GetHeight() );
115 void wxGCDC::DoDrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
)
117 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawIcon - invalid DC") );
118 wxCHECK_RET( icon
.Ok(), wxT("wxGCDC(cg)::DoDrawIcon - invalid icon") );
120 wxCoord w
= icon
.GetWidth();
121 wxCoord h
= icon
.GetHeight();
123 m_graphicContext
->DrawIcon( icon
, x
, y
, w
, h
);
126 void wxGCDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
)
128 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoSetClippingRegion - invalid DC") );
130 m_graphicContext
->Clip( x
, y
, w
, h
);
133 m_clipX1
= wxMax( m_clipX1
, x
);
134 m_clipY1
= wxMax( m_clipY1
, y
);
135 m_clipX2
= wxMin( m_clipX2
, (x
+ w
) );
136 m_clipY2
= wxMin( m_clipY2
, (y
+ h
) );
149 void wxGCDC::DoSetClippingRegionAsRegion( const wxRegion
®ion
)
151 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoSetClippingRegionAsRegion - invalid DC") );
155 DestroyClippingRegion();
160 region
.GetBox( x
, y
, w
, h
);
162 m_graphicContext
->Clip( region
);
165 m_clipX1
= wxMax( m_clipX1
, x
);
166 m_clipY1
= wxMax( m_clipY1
, y
);
167 m_clipX2
= wxMin( m_clipX2
, (x
+ w
) );
168 m_clipY2
= wxMin( m_clipY2
, (y
+ h
) );
181 void wxGCDC::DestroyClippingRegion()
183 m_graphicContext
->ResetClip();
184 m_graphicContext
->SetPen( m_pen
);
185 m_graphicContext
->SetBrush( m_brush
);
190 void wxGCDC::DoGetSizeMM( int* width
, int* height
) const
196 *width
= long( double(w
) / (m_scaleX
* m_mm_to_pix_x
) );
198 *height
= long( double(h
) / (m_scaleY
* m_mm_to_pix_y
) );
201 void wxGCDC::SetTextForeground( const wxColour
&col
)
203 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::SetTextForeground - invalid DC") );
205 if ( col
!= m_textForegroundColour
)
207 m_textForegroundColour
= col
;
208 m_graphicContext
->SetFont( m_font
, m_textForegroundColour
);
212 void wxGCDC::SetTextBackground( const wxColour
&col
)
214 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::SetTextBackground - invalid DC") );
216 m_textBackgroundColour
= col
;
219 void wxGCDC::SetMapMode( int mode
)
224 SetLogicalScale( twips2mm
* m_mm_to_pix_x
, twips2mm
* m_mm_to_pix_y
);
228 SetLogicalScale( pt2mm
* m_mm_to_pix_x
, pt2mm
* m_mm_to_pix_y
);
232 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
236 SetLogicalScale( m_mm_to_pix_x
/ 10.0, m_mm_to_pix_y
/ 10.0 );
241 SetLogicalScale( 1.0, 1.0 );
245 ComputeScaleAndOrigin();
248 void wxGCDC::SetUserScale( double x
, double y
)
250 // allow negative ? -> no
254 ComputeScaleAndOrigin();
257 void wxGCDC::SetLogicalScale( double x
, double y
)
262 ComputeScaleAndOrigin();
265 void wxGCDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
267 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
268 m_logicalOriginY
= y
* m_signY
;
269 ComputeScaleAndOrigin();
272 void wxGCDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
276 ComputeScaleAndOrigin();
279 void wxGCDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
281 m_signX
= (xLeftRight
? 1 : -1);
282 m_signY
= (yBottomUp
? -1 : 1);
283 ComputeScaleAndOrigin();
286 wxSize
wxGCDC::GetPPI() const
288 return wxSize(72, 72);
291 int wxGCDC::GetDepth() const
296 void wxGCDC::ComputeScaleAndOrigin()
298 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
299 m_scaleY
= m_logicalScaleY
* m_userScaleY
;
301 m_matrixCurrent
= m_graphicContext
->CreateMatrix();
302 m_matrixCurrent
.Translate( m_deviceOriginX
, m_deviceOriginY
);
303 m_matrixCurrent
.Scale( m_scaleX
, m_scaleY
);
304 m_matrixCurrent
.Translate( m_logicalOriginX
, m_logicalOriginY
);
306 m_graphicContext
->SetTransform( m_matrixOriginal
);
307 m_graphicContext
->ConcatTransform( m_matrixCurrent
);
310 void wxGCDC::SetPalette( const wxPalette
& WXUNUSED(palette
) )
315 void wxGCDC::SetBackgroundMode( int mode
)
317 m_backgroundMode
= mode
;
320 void wxGCDC::SetFont( const wxFont
&font
)
323 if ( m_graphicContext
)
327 f
.SetPointSize( /*LogicalToDeviceYRel*/(font
.GetPointSize()));
328 m_graphicContext
->SetFont( f
, m_textForegroundColour
);
332 void wxGCDC::SetPen( const wxPen
&pen
)
338 if ( m_graphicContext
)
340 m_graphicContext
->SetPen( m_pen
);
344 void wxGCDC::SetBrush( const wxBrush
&brush
)
346 if (m_brush
== brush
)
350 if ( m_graphicContext
)
352 m_graphicContext
->SetBrush( m_brush
);
356 void wxGCDC::SetBackground( const wxBrush
&brush
)
358 if (m_backgroundBrush
== brush
)
361 m_backgroundBrush
= brush
;
362 if (!m_backgroundBrush
.Ok())
366 void wxGCDC::SetLogicalFunction( int function
)
368 if (m_logicalFunction
== function
)
371 m_logicalFunction
= function
;
372 #if wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
374 CGContextRef cgContext
= ((wxCairoContext
*)(m_graphicContext
))->GetNativeContext();
375 if ( m_logicalFunction
== wxCOPY
)
376 CGContextSetBlendMode( cgContext
, kCGBlendModeNormal
);
377 else if ( m_logicalFunction
== wxINVERT
)
378 CGContextSetBlendMode( cgContext
, kCGBlendModeExclusion
);
380 CGContextSetBlendMode( cgContext
, kCGBlendModeNormal
);
385 bool wxGCDC::DoFloodFill(wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
),
386 const wxColour
& WXUNUSED(col
), int WXUNUSED(style
))
391 bool wxGCDC::DoGetPixel( wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
), wxColour
*WXUNUSED(col
) ) const
393 // wxCHECK_MSG( 0 , false, wxT("wxGCDC(cg)::DoGetPixel - not implemented") );
397 void wxGCDC::DoDrawLine( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
399 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawLine - invalid DC") );
401 #if !wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
403 if ( m_logicalFunction
!= wxCOPY
)
407 m_graphicContext
->StrokeLine(x1
,y1
,x2
,y2
);
409 CalcBoundingBox(x1
, y1
);
410 CalcBoundingBox(x2
, y2
);
413 void wxGCDC::DoCrossHair( wxCoord x
, wxCoord y
)
415 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoCrossHair - invalid DC") );
417 if ( m_logicalFunction
!= wxCOPY
)
424 m_graphicContext
->StrokeLine(0,y
,w
,y
);
425 m_graphicContext
->StrokeLine(x
,0,x
,h
);
427 CalcBoundingBox(0, 0);
428 CalcBoundingBox(0+w
, 0+h
);
431 void wxGCDC::DoDrawArc( wxCoord x1
, wxCoord y1
,
432 wxCoord x2
, wxCoord y2
,
433 wxCoord xc
, wxCoord yc
)
435 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawArc - invalid DC") );
437 if ( m_logicalFunction
!= wxCOPY
)
442 double radius
= sqrt((double)(dx
* dx
+ dy
* dy
));
443 wxCoord rad
= (wxCoord
)radius
;
445 if (x1
== x2
&& y1
== y2
)
450 else if (radius
== 0.0)
456 sa
= (x1
- xc
== 0) ?
457 (y1
- yc
< 0) ? 90.0 : -90.0 :
458 -atan2(double(y1
- yc
), double(x1
- xc
)) * RAD2DEG
;
459 ea
= (x2
- xc
== 0) ?
460 (y2
- yc
< 0) ? 90.0 : -90.0 :
461 -atan2(double(y2
- yc
), double(x2
- xc
)) * RAD2DEG
;
464 bool fill
= m_brush
.GetStyle() != wxTRANSPARENT
;
466 wxGraphicsPath path
= m_graphicContext
->CreatePath();
467 if ( fill
&& ((x1
!=x2
)||(y1
!=y2
)) )
468 path
.MoveToPoint( xc
, yc
);
469 path
.AddArc( xc
, yc
, rad
, DegToRad(sa
) , DegToRad(ea
), false );
470 if ( fill
&& ((x1
!=x2
)||(y1
!=y2
)) )
471 path
.AddLineToPoint( xc
, yc
);
472 m_graphicContext
->DrawPath(path
);
475 void wxGCDC::DoDrawEllipticArc( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
476 double sa
, double ea
)
478 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawEllipticArc - invalid DC") );
480 if ( m_logicalFunction
!= wxCOPY
)
483 bool fill
= m_brush
.GetStyle() != wxTRANSPARENT
;
485 wxGraphicsPath path
= m_graphicContext
->CreatePath();
486 m_graphicContext
->PushState();
487 m_graphicContext
->Translate(x
+w
/2,y
+h
/2);
488 wxDouble factor
= ((wxDouble
) w
) / h
;
489 m_graphicContext
->Scale( factor
, 1.0);
490 if ( fill
&& (sa
!=ea
) )
491 path
.MoveToPoint(0,0);
492 // since these angles (ea,sa) are measured counter-clockwise, we invert them to
493 // get clockwise angles
494 path
.AddArc( 0, 0, h
/2 , DegToRad(-sa
) , DegToRad(-ea
), sa
> ea
);
495 if ( fill
&& (sa
!=ea
) )
496 path
.AddLineToPoint(0,0);
497 m_graphicContext
->DrawPath( path
);
498 m_graphicContext
->PopState();
501 void wxGCDC::DoDrawPoint( wxCoord x
, wxCoord y
)
503 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawPoint - invalid DC") );
505 DoDrawLine( x
, y
, x
+ 1 , y
+ 1 );
508 void wxGCDC::DoDrawLines(int n
, wxPoint points
[],
509 wxCoord xoffset
, wxCoord yoffset
)
511 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawLines - invalid DC") );
513 #if !wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
515 if ( m_logicalFunction
!= wxCOPY
)
519 wxPoint2DDouble
* pointsD
= new wxPoint2DDouble
[n
];
520 for( int i
= 0; i
< n
; ++i
)
522 pointsD
[i
].m_x
= points
[i
].x
+ xoffset
;
523 pointsD
[i
].m_y
= points
[i
].y
+ yoffset
;
526 m_graphicContext
->StrokeLines( n
, pointsD
);
531 void wxGCDC::DoDrawSpline(wxList
*points
)
533 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawSpline - invalid DC") );
535 if ( m_logicalFunction
!= wxCOPY
)
538 wxGraphicsPath path
= m_graphicContext
->CreatePath();
540 wxList::compatibility_iterator node
= points
->GetFirst();
541 if (node
== wxList::compatibility_iterator())
545 wxPoint
*p
= (wxPoint
*)node
->GetData();
550 node
= node
->GetNext();
551 p
= (wxPoint
*)node
->GetData();
555 wxCoord cx1
= ( x1
+ x2
) / 2;
556 wxCoord cy1
= ( y1
+ y2
) / 2;
558 path
.MoveToPoint( x1
, y1
);
559 path
.AddLineToPoint( cx1
, cy1
);
562 while ((node
= node
->GetNext()) != NULL
)
565 while ((node
= node
->GetNext()))
569 p
= (wxPoint
*)node
->GetData();
574 wxCoord cx4
= (x1
+ x2
) / 2;
575 wxCoord cy4
= (y1
+ y2
) / 2;
577 path
.AddQuadCurveToPoint(x1
, y1
,cx4
, cy4
);
583 path
.AddLineToPoint( x2
, y2
);
585 m_graphicContext
->StrokePath( path
);
587 #endif // wxUSE_SPLINES
589 void wxGCDC::DoDrawPolygon( int n
, wxPoint points
[],
590 wxCoord xoffset
, wxCoord yoffset
,
593 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawPolygon - invalid DC") );
595 if ( n
<= 0 || (m_brush
.GetStyle() == wxTRANSPARENT
&& m_pen
.GetStyle() == wxTRANSPARENT
) )
597 if ( m_logicalFunction
!= wxCOPY
)
600 bool closeIt
= false;
601 if (points
[n
-1] != points
[0])
604 wxPoint2DDouble
* pointsD
= new wxPoint2DDouble
[n
+(closeIt
?1:0)];
605 for( int i
= 0; i
< n
; ++i
)
607 pointsD
[i
].m_x
= points
[i
].x
+ xoffset
;
608 pointsD
[i
].m_y
= points
[i
].y
+ yoffset
;
611 pointsD
[n
] = pointsD
[0];
613 m_graphicContext
->DrawLines( n
+(closeIt
?1:0) , pointsD
, fillStyle
);
617 void wxGCDC::DoDrawPolyPolygon(int n
,
625 wxGraphicsPath path
= m_graphicContext
->CreatePath();
628 for ( int j
= 0; j
< n
; ++j
)
630 wxPoint start
= points
[i
];
631 path
.MoveToPoint( start
.x
+ xoffset
, start
.y
+ yoffset
);
634 for ( int k
= 1; k
< l
; ++k
)
636 path
.AddLineToPoint( points
[i
].x
+ xoffset
, points
[i
].y
+ yoffset
);
640 if ( start
!= points
[i
-1])
641 path
.AddLineToPoint( start
.x
+ xoffset
, start
.y
+ yoffset
);
643 m_graphicContext
->DrawPath( path
, fillStyle
);
646 void wxGCDC::DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
)
648 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRectangle - invalid DC") );
650 if ( m_logicalFunction
!= wxCOPY
)
653 // CMB: draw nothing if transformed w or h is 0
654 if (w
== 0 || h
== 0)
657 if ( m_graphicContext
->ShouldOffset() )
659 // if we are offsetting the entire rectangle is moved 0.5, so the
660 // border line gets off by 1
664 m_graphicContext
->DrawRectangle(x
,y
,w
,h
);
667 void wxGCDC::DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
668 wxCoord w
, wxCoord h
,
671 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRoundedRectangle - invalid DC") );
673 if ( m_logicalFunction
!= wxCOPY
)
677 radius
= - radius
* ((w
< h
) ? w
: h
);
679 // CMB: draw nothing if transformed w or h is 0
680 if (w
== 0 || h
== 0)
683 m_graphicContext
->DrawRoundedRectangle( x
,y
,w
,h
,radius
);
686 void wxGCDC::DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
)
688 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawEllipse - invalid DC") );
690 if ( m_logicalFunction
!= wxCOPY
)
693 m_graphicContext
->DrawEllipse(x
,y
,w
,h
);
696 bool wxGCDC::CanDrawBitmap() const
702 wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
703 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
, int logical_func
, bool WXUNUSED(useMask
),
704 wxCoord xsrcMask
, wxCoord ysrcMask
)
706 wxCHECK_MSG( Ok(), false, wxT("wxGCDC(cg)::DoBlit - invalid DC") );
707 wxCHECK_MSG( source
->Ok(), false, wxT("wxGCDC(cg)::DoBlit - invalid source DC") );
709 if ( logical_func
== wxNO_OP
)
711 else if ( logical_func
!= wxCOPY
)
713 wxFAIL_MSG( wxT("Blitting is only supported with wxCOPY logical operation.") );
717 if (xsrcMask
== -1 && ysrcMask
== -1)
723 wxRect
subrect(source
-> LogicalToDeviceX(xsrc
),source
-> LogicalToDeviceY(ysrc
),
724 source
-> LogicalToDeviceXRel(width
),source
-> LogicalToDeviceYRel(height
));
726 wxBitmap blit
= source
->GetAsBitmap( &subrect
);
730 m_graphicContext
->DrawBitmap( blit
, xdest
, ydest
, width
, height
);
734 wxFAIL_MSG( wxT("Cannot Blit. Unable to get contents of DC as bitmap.") );
741 void wxGCDC::DoDrawRotatedText(const wxString
& str
, wxCoord x
, wxCoord y
,
744 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRotatedText - invalid DC") );
746 if ( str
.length() == 0 )
748 if ( m_logicalFunction
!= wxCOPY
)
751 m_graphicContext
->DrawText( str
, x
,y
, DegToRad(angle
));
754 void wxGCDC::DoDrawText(const wxString
& str
, wxCoord x
, wxCoord y
)
756 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRotatedText - invalid DC") );
758 if ( str
.length() == 0 )
760 if ( m_logicalFunction
!= wxCOPY
)
763 m_graphicContext
->DrawText( str
, x
,y
);
766 bool wxGCDC::CanGetTextExtent() const
768 wxCHECK_MSG( Ok(), false, wxT("wxGCDC(cg)::CanGetTextExtent - invalid DC") );
773 void wxGCDC::DoGetTextExtent( const wxString
&str
, wxCoord
*width
, wxCoord
*height
,
774 wxCoord
*descent
, wxCoord
*externalLeading
,
775 wxFont
*theFont
) const
777 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoGetTextExtent - invalid DC") );
781 m_graphicContext
->SetFont( *theFont
, m_textForegroundColour
);
784 wxDouble h
, d
, e
, w
;
786 m_graphicContext
->GetTextExtent( str
, &w
, &h
, &d
, &e
);
789 *height
= (wxCoord
)h
;
791 *descent
= (wxCoord
)d
;
792 if ( externalLeading
)
793 *externalLeading
= (wxCoord
)e
;
799 m_graphicContext
->SetFont( m_font
, m_textForegroundColour
);
803 bool wxGCDC::DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
805 wxCHECK_MSG( Ok(), false, wxT("wxGCDC(cg)::DoGetPartialTextExtents - invalid DC") );
807 widths
.Add(0,text
.Length());
808 if ( text
.IsEmpty() )
811 wxArrayDouble widthsD
;
813 m_graphicContext
->GetPartialTextExtents( text
, widthsD
);
814 for ( size_t i
= 0; i
< widths
.GetCount(); ++i
)
815 widths
[i
] = (wxCoord
)(widthsD
[i
] + 0.5);
820 wxCoord
wxGCDC::GetCharWidth(void) const
823 DoGetTextExtent( wxT("g") , &width
, NULL
, NULL
, NULL
, NULL
);
828 wxCoord
wxGCDC::GetCharHeight(void) const
831 DoGetTextExtent( wxT("g") , NULL
, &height
, NULL
, NULL
, NULL
);
836 void wxGCDC::Clear(void)
838 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::Clear - invalid DC") );
839 // TODO better implementation / incorporate size info into wxGCDC or context
840 m_graphicContext
->SetBrush( m_backgroundBrush
);
841 wxPen p
= *wxTRANSPARENT_PEN
;
842 m_graphicContext
->SetPen( p
);
843 DoDrawRectangle( 0, 0, 32000 , 32000 );
844 m_graphicContext
->SetPen( m_pen
);
845 m_graphicContext
->SetBrush( m_brush
);
848 void wxGCDC::DoGetSize(int *width
, int *height
) const
854 void wxGCDC::DoGradientFillLinear(const wxRect
& rect
,
855 const wxColour
& initialColour
,
856 const wxColour
& destColour
,
857 wxDirection nDirection
)
864 start
= rect
.GetRightBottom();
866 end
= rect
.GetLeftBottom();
869 start
= rect
.GetLeftBottom();
870 end
= rect
.GetRightBottom();
874 start
= rect
.GetLeftBottom();
876 end
= rect
.GetLeftTop();
879 start
= rect
.GetLeftTop();
880 end
= rect
.GetLeftBottom();
887 if (rect
.width
== 0 || rect
.height
== 0)
890 m_graphicContext
->SetBrush( m_graphicContext
->CreateLinearGradientBrush(
891 start
.x
,start
.y
,end
.x
,end
.y
, initialColour
, destColour
));
892 m_graphicContext
->SetPen(*wxTRANSPARENT_PEN
);
893 m_graphicContext
->DrawRectangle(rect
.x
,rect
.y
,rect
.width
,rect
.height
);
894 m_graphicContext
->SetPen(m_pen
);
897 void wxGCDC::DoGradientFillConcentric(const wxRect
& rect
,
898 const wxColour
& initialColour
,
899 const wxColour
& destColour
,
900 const wxPoint
& circleCenter
)
903 wxInt32 cx
= rect
.GetWidth() / 2;
904 wxInt32 cy
= rect
.GetHeight() / 2;
911 // make sure the background is filled (todo move into specific platform implementation ?)
912 m_graphicContext
->SetPen(*wxTRANSPARENT_PEN
);
913 m_graphicContext
->SetBrush( wxBrush( destColour
) );
914 m_graphicContext
->DrawRectangle(rect
.x
,rect
.y
,rect
.width
,rect
.height
);
916 m_graphicContext
->SetBrush( m_graphicContext
->CreateRadialGradientBrush(
917 rect
.x
+circleCenter
.x
,rect
.y
+circleCenter
.y
,
918 rect
.x
+circleCenter
.x
,rect
.y
+circleCenter
.y
,
919 nRadius
,initialColour
,destColour
));
921 m_graphicContext
->DrawRectangle(rect
.x
,rect
.y
,rect
.width
,rect
.height
);
922 m_graphicContext
->SetPen(m_pen
);
925 void wxGCDC::DoDrawCheckMark(wxCoord x
, wxCoord y
,
926 wxCoord width
, wxCoord height
)
928 wxDCBase::DoDrawCheckMark(x
,y
,width
,height
);
931 #endif // wxUSE_GRAPHICS_CONTEXT