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 //-----------------------------------------------------------------------------
32 //-----------------------------------------------------------------------------
34 static const double RAD2DEG
= 180.0 / M_PI
;
36 //-----------------------------------------------------------------------------
38 //-----------------------------------------------------------------------------
40 static inline double DegToRad(double deg
)
42 return (deg
* M_PI
) / 180.0;
45 //-----------------------------------------------------------------------------
47 //-----------------------------------------------------------------------------
50 IMPLEMENT_DYNAMIC_CLASS(wxGCDC
, wxDCBase
)
52 IMPLEMENT_DYNAMIC_CLASS(wxGCDC
, wxDC
)
60 void wxGCDC::SetGraphicsContext( wxGraphicsContext
* ctx
)
62 delete m_graphicContext
;
63 m_graphicContext
= ctx
;
64 m_matrixOriginal
= m_graphicContext
->GetTransform();
67 wxGCDC::wxGCDC(const wxWindowDC
& dc
)
70 m_graphicContext
= wxGraphicsContext::Create(dc
);
71 m_matrixOriginal
= m_graphicContext
->GetTransform();
73 if ( dc
.GetFont().Ok())
74 m_graphicContext
->SetFont( m_graphicContext
->CreateFont(dc
.GetFont(),dc
.GetTextForeground()));
75 if ( dc
.GetPen().Ok())
76 m_graphicContext
->SetPen( m_graphicContext
->CreatePen(dc
.GetPen()));
77 if ( dc
.GetBrush().Ok())
78 m_graphicContext
->SetBrush( m_graphicContext
->CreateBrush(dc
.GetBrush()));
85 m_mm_to_pix_x
= mm2pt
;
86 m_mm_to_pix_y
= mm2pt
;
89 m_font
= *wxNORMAL_FONT
;
90 m_brush
= *wxWHITE_BRUSH
;
92 m_graphicContext
= NULL
;
98 delete m_graphicContext
;
101 void wxGCDC::DoDrawBitmap( const wxBitmap
&bmp
, wxCoord x
, wxCoord y
, bool WXUNUSED(useMask
) )
103 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid DC") );
104 wxCHECK_RET( bmp
.Ok(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid bitmap") );
106 m_graphicContext
->DrawBitmap( bmp
, x
, y
, bmp
.GetWidth() , bmp
.GetHeight() );
109 void wxGCDC::DoDrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
)
111 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawIcon - invalid DC") );
112 wxCHECK_RET( icon
.Ok(), wxT("wxGCDC(cg)::DoDrawIcon - invalid icon") );
114 wxCoord w
= icon
.GetWidth();
115 wxCoord h
= icon
.GetHeight();
117 m_graphicContext
->DrawIcon( icon
, x
, y
, w
, h
);
120 void wxGCDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
)
122 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoSetClippingRegion - invalid DC") );
124 m_graphicContext
->Clip( x
, y
, w
, h
);
127 m_clipX1
= wxMax( m_clipX1
, x
);
128 m_clipY1
= wxMax( m_clipY1
, y
);
129 m_clipX2
= wxMin( m_clipX2
, (x
+ w
) );
130 m_clipY2
= wxMin( m_clipY2
, (y
+ h
) );
143 void wxGCDC::DoSetClippingRegionAsRegion( const wxRegion
®ion
)
145 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoSetClippingRegionAsRegion - invalid DC") );
149 DestroyClippingRegion();
154 region
.GetBox( x
, y
, w
, h
);
156 m_graphicContext
->Clip( region
);
159 m_clipX1
= wxMax( m_clipX1
, x
);
160 m_clipY1
= wxMax( m_clipY1
, y
);
161 m_clipX2
= wxMin( m_clipX2
, (x
+ w
) );
162 m_clipY2
= wxMin( m_clipY2
, (y
+ h
) );
175 void wxGCDC::DestroyClippingRegion()
177 m_graphicContext
->ResetClip();
178 m_graphicContext
->SetPen( m_pen
);
179 m_graphicContext
->SetBrush( m_brush
);
184 void wxGCDC::DoGetSizeMM( int* width
, int* height
) const
190 *width
= long( double(w
) / (m_scaleX
* m_mm_to_pix_x
) );
192 *height
= long( double(h
) / (m_scaleY
* m_mm_to_pix_y
) );
195 void wxGCDC::SetTextForeground( const wxColour
&col
)
197 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::SetTextForeground - invalid DC") );
199 if ( col
!= m_textForegroundColour
)
201 m_textForegroundColour
= col
;
202 m_graphicContext
->SetFont( m_font
, m_textForegroundColour
);
206 void wxGCDC::SetTextBackground( const wxColour
&col
)
208 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::SetTextBackground - invalid DC") );
210 m_textBackgroundColour
= col
;
213 void wxGCDC::SetMapMode( int mode
)
218 SetLogicalScale( twips2mm
* m_mm_to_pix_x
, twips2mm
* m_mm_to_pix_y
);
222 SetLogicalScale( pt2mm
* m_mm_to_pix_x
, pt2mm
* m_mm_to_pix_y
);
226 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
230 SetLogicalScale( m_mm_to_pix_x
/ 10.0, m_mm_to_pix_y
/ 10.0 );
235 SetLogicalScale( 1.0, 1.0 );
239 ComputeScaleAndOrigin();
242 void wxGCDC::SetUserScale( double x
, double y
)
244 // allow negative ? -> no
248 ComputeScaleAndOrigin();
251 void wxGCDC::SetLogicalScale( double x
, double y
)
256 ComputeScaleAndOrigin();
259 void wxGCDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
261 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
262 m_logicalOriginY
= y
* m_signY
;
263 ComputeScaleAndOrigin();
266 void wxGCDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
270 ComputeScaleAndOrigin();
273 void wxGCDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
275 m_signX
= (xLeftRight
? 1 : -1);
276 m_signY
= (yBottomUp
? -1 : 1);
277 ComputeScaleAndOrigin();
280 wxSize
wxGCDC::GetPPI() const
282 return wxSize(72, 72);
285 int wxGCDC::GetDepth() const
290 void wxGCDC::ComputeScaleAndOrigin()
292 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
293 m_scaleY
= m_logicalScaleY
* m_userScaleY
;
295 m_matrixCurrent
= m_graphicContext
->CreateMatrix();
296 m_matrixCurrent
.Translate( m_deviceOriginX
, m_deviceOriginY
);
297 m_matrixCurrent
.Scale( m_scaleX
, m_scaleY
);
298 m_matrixCurrent
.Translate( m_logicalOriginX
, m_logicalOriginY
);
300 m_graphicContext
->SetTransform( m_matrixOriginal
);
301 m_graphicContext
->ConcatTransform( m_matrixCurrent
);
304 void wxGCDC::SetPalette( const wxPalette
& WXUNUSED(palette
) )
309 void wxGCDC::SetBackgroundMode( int mode
)
311 m_backgroundMode
= mode
;
314 void wxGCDC::SetFont( const wxFont
&font
)
317 if ( m_graphicContext
)
321 f
.SetPointSize( /*LogicalToDeviceYRel*/(font
.GetPointSize()));
322 m_graphicContext
->SetFont( f
, m_textForegroundColour
);
326 void wxGCDC::SetPen( const wxPen
&pen
)
332 if ( m_graphicContext
)
334 m_graphicContext
->SetPen( m_pen
);
338 void wxGCDC::SetBrush( const wxBrush
&brush
)
340 if (m_brush
== brush
)
344 if ( m_graphicContext
)
346 m_graphicContext
->SetBrush( m_brush
);
350 void wxGCDC::SetBackground( const wxBrush
&brush
)
352 if (m_backgroundBrush
== brush
)
355 m_backgroundBrush
= brush
;
356 if (!m_backgroundBrush
.Ok())
360 void wxGCDC::SetLogicalFunction( int function
)
362 if (m_logicalFunction
== function
)
365 m_logicalFunction
= function
;
366 #if wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
368 CGContextRef cgContext
= ((wxCairoContext
*)(m_graphicContext
))->GetNativeContext();
369 if ( m_logicalFunction
== wxCOPY
)
370 CGContextSetBlendMode( cgContext
, kCGBlendModeNormal
);
371 else if ( m_logicalFunction
== wxINVERT
)
372 CGContextSetBlendMode( cgContext
, kCGBlendModeExclusion
);
374 CGContextSetBlendMode( cgContext
, kCGBlendModeNormal
);
379 bool wxGCDC::DoFloodFill(wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
),
380 const wxColour
& WXUNUSED(col
), int WXUNUSED(style
))
385 bool wxGCDC::DoGetPixel( wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
), wxColour
*WXUNUSED(col
) ) const
387 // wxCHECK_MSG( 0 , false, wxT("wxGCDC(cg)::DoGetPixel - not implemented") );
391 void wxGCDC::DoDrawLine( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
393 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawLine - invalid DC") );
395 #if !wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
397 if ( m_logicalFunction
!= wxCOPY
)
401 m_graphicContext
->StrokeLine(x1
,y1
,x2
,y2
);
403 CalcBoundingBox(x1
, y1
);
404 CalcBoundingBox(x2
, y2
);
407 void wxGCDC::DoCrossHair( wxCoord x
, wxCoord y
)
409 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoCrossHair - invalid DC") );
411 if ( m_logicalFunction
!= wxCOPY
)
418 m_graphicContext
->StrokeLine(0,y
,w
,y
);
419 m_graphicContext
->StrokeLine(x
,0,x
,h
);
421 CalcBoundingBox(0, 0);
422 CalcBoundingBox(0+w
, 0+h
);
425 void wxGCDC::DoDrawArc( wxCoord x1
, wxCoord y1
,
426 wxCoord x2
, wxCoord y2
,
427 wxCoord xc
, wxCoord yc
)
429 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawArc - invalid DC") );
431 if ( m_logicalFunction
!= wxCOPY
)
436 double radius
= sqrt((double)(dx
* dx
+ dy
* dy
));
437 wxCoord rad
= (wxCoord
)radius
;
439 if (x1
== x2
&& y1
== y2
)
444 else if (radius
== 0.0)
450 sa
= (x1
- xc
== 0) ?
451 (y1
- yc
< 0) ? 90.0 : -90.0 :
452 -atan2(double(y1
- yc
), double(x1
- xc
)) * RAD2DEG
;
453 ea
= (x2
- xc
== 0) ?
454 (y2
- yc
< 0) ? 90.0 : -90.0 :
455 -atan2(double(y2
- yc
), double(x2
- xc
)) * RAD2DEG
;
458 bool fill
= m_brush
.GetStyle() != wxTRANSPARENT
;
460 wxGraphicsPath path
= m_graphicContext
->CreatePath();
461 if ( fill
&& ((x1
!=x2
)||(y1
!=y2
)) )
462 path
.MoveToPoint( xc
, yc
);
463 path
.AddArc( xc
, yc
, rad
, DegToRad(sa
) , DegToRad(ea
), false );
464 if ( fill
&& ((x1
!=x2
)||(y1
!=y2
)) )
465 path
.AddLineToPoint( xc
, yc
);
466 m_graphicContext
->DrawPath(path
);
469 void wxGCDC::DoDrawEllipticArc( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
470 double sa
, double ea
)
472 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawEllipticArc - invalid DC") );
474 if ( m_logicalFunction
!= wxCOPY
)
477 bool fill
= m_brush
.GetStyle() != wxTRANSPARENT
;
479 wxGraphicsPath path
= m_graphicContext
->CreatePath();
480 m_graphicContext
->PushState();
481 m_graphicContext
->Translate(x
+w
/2,y
+h
/2);
482 wxDouble factor
= ((wxDouble
) w
) / h
;
483 m_graphicContext
->Scale( factor
, 1.0);
484 if ( fill
&& (sa
!=ea
) )
485 path
.MoveToPoint(0,0);
486 // since these angles (ea,sa) are measured counter-clockwise, we invert them to
487 // get clockwise angles
488 path
.AddArc( 0, 0, h
/2 , DegToRad(-sa
) , DegToRad(-ea
), sa
> ea
);
489 if ( fill
&& (sa
!=ea
) )
490 path
.AddLineToPoint(0,0);
491 m_graphicContext
->DrawPath( path
);
492 m_graphicContext
->PopState();
495 void wxGCDC::DoDrawPoint( wxCoord x
, wxCoord y
)
497 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawPoint - invalid DC") );
499 DoDrawLine( x
, y
, x
+ 1 , y
+ 1 );
502 void wxGCDC::DoDrawLines(int n
, wxPoint points
[],
503 wxCoord xoffset
, wxCoord yoffset
)
505 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawLines - invalid DC") );
507 #if !wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
509 if ( m_logicalFunction
!= wxCOPY
)
513 wxPoint2DDouble
* pointsD
= new wxPoint2DDouble
[n
];
514 for( int i
= 0; i
< n
; ++i
)
516 pointsD
[i
].m_x
= points
[i
].x
+ xoffset
;
517 pointsD
[i
].m_y
= points
[i
].y
+ yoffset
;
520 m_graphicContext
->StrokeLines( n
, pointsD
);
525 void wxGCDC::DoDrawSpline(wxList
*points
)
527 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawSpline - invalid DC") );
529 if ( m_logicalFunction
!= wxCOPY
)
532 wxGraphicsPath path
= m_graphicContext
->CreatePath();
534 wxList::compatibility_iterator node
= points
->GetFirst();
535 if (node
== wxList::compatibility_iterator())
539 wxPoint
*p
= (wxPoint
*)node
->GetData();
544 node
= node
->GetNext();
545 p
= (wxPoint
*)node
->GetData();
549 wxCoord cx1
= ( x1
+ x2
) / 2;
550 wxCoord cy1
= ( y1
+ y2
) / 2;
552 path
.MoveToPoint( x1
, y1
);
553 path
.AddLineToPoint( cx1
, cy1
);
556 while ((node
= node
->GetNext()) != NULL
)
559 while ((node
= node
->GetNext()))
563 p
= (wxPoint
*)node
->GetData();
568 wxCoord cx4
= (x1
+ x2
) / 2;
569 wxCoord cy4
= (y1
+ y2
) / 2;
571 path
.AddQuadCurveToPoint(x1
, y1
,cx4
, cy4
);
577 path
.AddLineToPoint( x2
, y2
);
579 m_graphicContext
->StrokePath( path
);
581 #endif // wxUSE_SPLINES
583 void wxGCDC::DoDrawPolygon( int n
, wxPoint points
[],
584 wxCoord xoffset
, wxCoord yoffset
,
587 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawPolygon - invalid DC") );
589 if ( n
<= 0 || (m_brush
.GetStyle() == wxTRANSPARENT
&& m_pen
.GetStyle() == wxTRANSPARENT
) )
591 if ( m_logicalFunction
!= wxCOPY
)
594 bool closeIt
= false;
595 if (points
[n
-1] != points
[0])
598 wxPoint2DDouble
* pointsD
= new wxPoint2DDouble
[n
+(closeIt
?1:0)];
599 for( int i
= 0; i
< n
; ++i
)
601 pointsD
[i
].m_x
= points
[i
].x
+ xoffset
;
602 pointsD
[i
].m_y
= points
[i
].y
+ yoffset
;
605 pointsD
[n
] = pointsD
[0];
607 m_graphicContext
->DrawLines( n
+(closeIt
?1:0) , pointsD
, fillStyle
);
611 void wxGCDC::DoDrawPolyPolygon(int n
,
619 wxGraphicsPath path
= m_graphicContext
->CreatePath();
622 for ( int j
= 0; j
< n
; ++j
)
624 wxPoint start
= points
[i
];
625 path
.MoveToPoint( start
.x
+ xoffset
, start
.y
+ yoffset
);
628 for ( int k
= 1; k
< l
; ++k
)
630 path
.AddLineToPoint( points
[i
].x
+ xoffset
, points
[i
].y
+ yoffset
);
634 if ( start
!= points
[i
-1])
635 path
.AddLineToPoint( start
.x
+ xoffset
, start
.y
+ yoffset
);
637 m_graphicContext
->DrawPath( path
, fillStyle
);
640 void wxGCDC::DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
)
642 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRectangle - invalid DC") );
644 if ( m_logicalFunction
!= wxCOPY
)
647 // CMB: draw nothing if transformed w or h is 0
648 if (w
== 0 || h
== 0)
651 if ( m_graphicContext
->ShouldOffset() )
653 // if we are offsetting the entire rectangle is moved 0.5, so the
654 // border line gets off by 1
658 m_graphicContext
->DrawRectangle(x
,y
,w
,h
);
661 void wxGCDC::DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
662 wxCoord w
, wxCoord h
,
665 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRoundedRectangle - invalid DC") );
667 if ( m_logicalFunction
!= wxCOPY
)
671 radius
= - radius
* ((w
< h
) ? w
: h
);
673 // CMB: draw nothing if transformed w or h is 0
674 if (w
== 0 || h
== 0)
677 m_graphicContext
->DrawRoundedRectangle( x
,y
,w
,h
,radius
);
680 void wxGCDC::DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
)
682 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawEllipse - invalid DC") );
684 if ( m_logicalFunction
!= wxCOPY
)
687 m_graphicContext
->DrawEllipse(x
,y
,w
,h
);
690 bool wxGCDC::CanDrawBitmap() const
696 wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
697 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
, int logical_func
, bool WXUNUSED(useMask
),
698 wxCoord xsrcMask
, wxCoord ysrcMask
)
700 wxCHECK_MSG( Ok(), false, wxT("wxGCDC(cg)::DoBlit - invalid DC") );
701 wxCHECK_MSG( source
->Ok(), false, wxT("wxGCDC(cg)::DoBlit - invalid source DC") );
703 if ( logical_func
== wxNO_OP
)
705 else if ( logical_func
!= wxCOPY
)
707 wxFAIL_MSG( wxT("Blitting is only supported with wxCOPY logical operation.") );
711 if (xsrcMask
== -1 && ysrcMask
== -1)
717 wxRect
subrect(source
-> LogicalToDeviceX(xsrc
),source
-> LogicalToDeviceY(ysrc
),
718 source
-> LogicalToDeviceXRel(width
),source
-> LogicalToDeviceYRel(height
));
720 wxBitmap blit
= source
->GetAsBitmap( &subrect
);
724 m_graphicContext
->DrawBitmap( blit
, xdest
, ydest
, width
, height
);
728 wxFAIL_MSG( wxT("Cannot Blit. Unable to get contents of DC as bitmap.") );
735 void wxGCDC::DoDrawRotatedText(const wxString
& str
, wxCoord x
, wxCoord y
,
738 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRotatedText - invalid DC") );
740 if ( str
.length() == 0 )
742 if ( m_logicalFunction
!= wxCOPY
)
745 m_graphicContext
->DrawText( str
, x
,y
, DegToRad(angle
));
748 void wxGCDC::DoDrawText(const wxString
& str
, wxCoord x
, wxCoord y
)
750 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRotatedText - invalid DC") );
752 if ( str
.length() == 0 )
754 if ( m_logicalFunction
!= wxCOPY
)
757 m_graphicContext
->DrawText( str
, x
,y
);
760 bool wxGCDC::CanGetTextExtent() const
762 wxCHECK_MSG( Ok(), false, wxT("wxGCDC(cg)::CanGetTextExtent - invalid DC") );
767 void wxGCDC::DoGetTextExtent( const wxString
&str
, wxCoord
*width
, wxCoord
*height
,
768 wxCoord
*descent
, wxCoord
*externalLeading
,
769 wxFont
*theFont
) const
771 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoGetTextExtent - invalid DC") );
775 m_graphicContext
->SetFont( *theFont
, m_textForegroundColour
);
778 wxDouble h
, d
, e
, w
;
780 m_graphicContext
->GetTextExtent( str
, &w
, &h
, &d
, &e
);
786 if ( externalLeading
)
793 m_graphicContext
->SetFont( m_font
, m_textForegroundColour
);
797 bool wxGCDC::DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
799 wxCHECK_MSG( Ok(), false, wxT("wxGCDC(cg)::DoGetPartialTextExtents - invalid DC") );
801 widths
.Add(0,text
.Length());
802 if ( text
.IsEmpty() )
805 wxArrayDouble widthsD
;
807 m_graphicContext
->GetPartialTextExtents( text
, widthsD
);
808 for ( size_t i
= 0; i
< widths
.GetCount(); ++i
)
809 widths
[i
] = (wxCoord
)(widthsD
[i
] + 0.5);
814 wxCoord
wxGCDC::GetCharWidth(void) const
817 DoGetTextExtent( wxT("g") , &width
, NULL
, NULL
, NULL
, NULL
);
822 wxCoord
wxGCDC::GetCharHeight(void) const
825 DoGetTextExtent( wxT("g") , NULL
, &height
, NULL
, NULL
, NULL
);
830 void wxGCDC::Clear(void)
832 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::Clear - invalid DC") );
833 // TODO better implementation / incorporate size info into wxGCDC or context
834 m_graphicContext
->SetBrush( m_backgroundBrush
);
835 wxPen p
= *wxTRANSPARENT_PEN
;
836 m_graphicContext
->SetPen( p
);
837 DoDrawRectangle( 0, 0, 32000 , 32000 );
838 m_graphicContext
->SetPen( m_pen
);
839 m_graphicContext
->SetBrush( m_brush
);
842 void wxGCDC::DoGetSize(int *width
, int *height
) const
848 void wxGCDC::DoGradientFillLinear(const wxRect
& rect
,
849 const wxColour
& initialColour
,
850 const wxColour
& destColour
,
851 wxDirection nDirection
)
858 start
= rect
.GetRightBottom();
860 end
= rect
.GetLeftBottom();
863 start
= rect
.GetLeftBottom();
864 end
= rect
.GetRightBottom();
868 start
= rect
.GetLeftBottom();
870 end
= rect
.GetLeftTop();
873 start
= rect
.GetLeftTop();
874 end
= rect
.GetLeftBottom();
881 if (rect
.width
== 0 || rect
.height
== 0)
884 m_graphicContext
->SetBrush( m_graphicContext
->CreateLinearGradientBrush(
885 start
.x
,start
.y
,end
.x
,end
.y
, initialColour
, destColour
));
886 m_graphicContext
->SetPen(*wxTRANSPARENT_PEN
);
887 m_graphicContext
->DrawRectangle(rect
.x
,rect
.y
,rect
.width
,rect
.height
);
888 m_graphicContext
->SetPen(m_pen
);
891 void wxGCDC::DoGradientFillConcentric(const wxRect
& rect
,
892 const wxColour
& initialColour
,
893 const wxColour
& destColour
,
894 const wxPoint
& circleCenter
)
897 wxInt32 cx
= rect
.GetWidth() / 2;
898 wxInt32 cy
= rect
.GetHeight() / 2;
905 // make sure the background is filled (todo move into specific platform implementation ?)
906 m_graphicContext
->SetPen(*wxTRANSPARENT_PEN
);
907 m_graphicContext
->SetBrush( wxBrush( destColour
) );
908 m_graphicContext
->DrawRectangle(rect
.x
,rect
.y
,rect
.width
,rect
.height
);
910 m_graphicContext
->SetBrush( m_graphicContext
->CreateRadialGradientBrush(
911 rect
.x
+circleCenter
.x
,rect
.y
+circleCenter
.y
,
912 rect
.x
+circleCenter
.x
,rect
.y
+circleCenter
.y
,
913 nRadius
,initialColour
,destColour
));
915 m_graphicContext
->DrawRectangle(rect
.x
,rect
.y
,rect
.width
,rect
.height
);
916 m_graphicContext
->SetPen(m_pen
);
919 void wxGCDC::DoDrawCheckMark(wxCoord x
, wxCoord y
,
920 wxCoord width
, wxCoord height
)
922 wxDCBase::DoDrawCheckMark(x
,y
,width
,height
);
925 #endif // wxUSE_GRAPHICS_CONTEXT