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 if ( m_graphicContext
)
66 m_matrixOriginal
= m_graphicContext
->GetTransform();
71 wxGCDC::wxGCDC(const wxWindowDC
& dc
)
74 SetGraphicsContext( wxGraphicsContext::Create(dc
) );
75 if ( dc
.GetFont().Ok())
76 m_graphicContext
->SetFont( m_graphicContext
->CreateFont(dc
.GetFont(),dc
.GetTextForeground()));
77 if ( dc
.GetPen().Ok())
78 m_graphicContext
->SetPen( m_graphicContext
->CreatePen(dc
.GetPen()));
79 if ( dc
.GetBrush().Ok())
80 m_graphicContext
->SetBrush( m_graphicContext
->CreateBrush(dc
.GetBrush()));
87 m_mm_to_pix_x
= mm2pt
;
88 m_mm_to_pix_y
= mm2pt
;
91 m_font
= *wxNORMAL_FONT
;
92 m_brush
= *wxWHITE_BRUSH
;
94 m_graphicContext
= NULL
;
100 delete m_graphicContext
;
103 void wxGCDC::DoDrawBitmap( const wxBitmap
&bmp
, wxCoord x
, wxCoord y
, bool WXUNUSED(useMask
) )
105 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid DC") );
106 wxCHECK_RET( bmp
.Ok(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid bitmap") );
108 m_graphicContext
->DrawBitmap( bmp
, x
, y
, bmp
.GetWidth() , bmp
.GetHeight() );
111 void wxGCDC::DoDrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
)
113 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawIcon - invalid DC") );
114 wxCHECK_RET( icon
.Ok(), wxT("wxGCDC(cg)::DoDrawIcon - invalid icon") );
116 wxCoord w
= icon
.GetWidth();
117 wxCoord h
= icon
.GetHeight();
119 m_graphicContext
->DrawIcon( icon
, x
, y
, w
, h
);
122 void wxGCDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
)
124 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoSetClippingRegion - invalid DC") );
126 m_graphicContext
->Clip( x
, y
, w
, h
);
129 m_clipX1
= wxMax( m_clipX1
, x
);
130 m_clipY1
= wxMax( m_clipY1
, y
);
131 m_clipX2
= wxMin( m_clipX2
, (x
+ w
) );
132 m_clipY2
= wxMin( m_clipY2
, (y
+ h
) );
145 void wxGCDC::DoSetClippingRegionAsRegion( const wxRegion
®ion
)
147 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoSetClippingRegionAsRegion - invalid DC") );
151 DestroyClippingRegion();
156 region
.GetBox( x
, y
, w
, h
);
158 m_graphicContext
->Clip( region
);
161 m_clipX1
= wxMax( m_clipX1
, x
);
162 m_clipY1
= wxMax( m_clipY1
, y
);
163 m_clipX2
= wxMin( m_clipX2
, (x
+ w
) );
164 m_clipY2
= wxMin( m_clipY2
, (y
+ h
) );
177 void wxGCDC::DestroyClippingRegion()
179 m_graphicContext
->ResetClip();
180 m_graphicContext
->SetPen( m_pen
);
181 m_graphicContext
->SetBrush( m_brush
);
186 void wxGCDC::DoGetSizeMM( int* width
, int* height
) const
192 *width
= long( double(w
) / (m_scaleX
* m_mm_to_pix_x
) );
194 *height
= long( double(h
) / (m_scaleY
* m_mm_to_pix_y
) );
197 void wxGCDC::SetTextForeground( const wxColour
&col
)
199 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::SetTextForeground - invalid DC") );
201 if ( col
!= m_textForegroundColour
)
203 m_textForegroundColour
= col
;
204 m_graphicContext
->SetFont( m_font
, m_textForegroundColour
);
208 void wxGCDC::SetTextBackground( const wxColour
&col
)
210 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::SetTextBackground - invalid DC") );
212 m_textBackgroundColour
= col
;
215 void wxGCDC::SetMapMode( int mode
)
220 SetLogicalScale( twips2mm
* m_mm_to_pix_x
, twips2mm
* m_mm_to_pix_y
);
224 SetLogicalScale( pt2mm
* m_mm_to_pix_x
, pt2mm
* m_mm_to_pix_y
);
228 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
232 SetLogicalScale( m_mm_to_pix_x
/ 10.0, m_mm_to_pix_y
/ 10.0 );
237 SetLogicalScale( 1.0, 1.0 );
241 ComputeScaleAndOrigin();
244 void wxGCDC::SetUserScale( double x
, double y
)
246 // allow negative ? -> no
250 ComputeScaleAndOrigin();
253 void wxGCDC::SetLogicalScale( double x
, double y
)
258 ComputeScaleAndOrigin();
261 void wxGCDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
263 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
264 m_logicalOriginY
= y
* m_signY
;
265 ComputeScaleAndOrigin();
268 void wxGCDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
272 ComputeScaleAndOrigin();
275 void wxGCDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
277 m_signX
= (xLeftRight
? 1 : -1);
278 m_signY
= (yBottomUp
? -1 : 1);
279 ComputeScaleAndOrigin();
282 wxSize
wxGCDC::GetPPI() const
284 return wxSize(72, 72);
287 int wxGCDC::GetDepth() const
292 void wxGCDC::ComputeScaleAndOrigin()
294 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
295 m_scaleY
= m_logicalScaleY
* m_userScaleY
;
297 m_matrixCurrent
= m_graphicContext
->CreateMatrix();
298 m_matrixCurrent
.Translate( m_deviceOriginX
, m_deviceOriginY
);
299 m_matrixCurrent
.Scale( m_scaleX
, m_scaleY
);
300 m_matrixCurrent
.Translate( m_logicalOriginX
, m_logicalOriginY
);
302 m_graphicContext
->SetTransform( m_matrixOriginal
);
303 m_graphicContext
->ConcatTransform( m_matrixCurrent
);
306 void wxGCDC::SetPalette( const wxPalette
& WXUNUSED(palette
) )
311 void wxGCDC::SetBackgroundMode( int mode
)
313 m_backgroundMode
= mode
;
316 void wxGCDC::SetFont( const wxFont
&font
)
319 if ( m_graphicContext
)
323 f
.SetPointSize( /*LogicalToDeviceYRel*/(font
.GetPointSize()));
324 m_graphicContext
->SetFont( f
, m_textForegroundColour
);
328 void wxGCDC::SetPen( const wxPen
&pen
)
334 if ( m_graphicContext
)
336 m_graphicContext
->SetPen( m_pen
);
340 void wxGCDC::SetBrush( const wxBrush
&brush
)
342 if (m_brush
== brush
)
346 if ( m_graphicContext
)
348 m_graphicContext
->SetBrush( m_brush
);
352 void wxGCDC::SetBackground( const wxBrush
&brush
)
354 if (m_backgroundBrush
== brush
)
357 m_backgroundBrush
= brush
;
358 if (!m_backgroundBrush
.Ok())
362 void wxGCDC::SetLogicalFunction( int function
)
364 if (m_logicalFunction
== function
)
367 m_logicalFunction
= function
;
368 #if wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
370 CGContextRef cgContext
= ((wxCairoContext
*)(m_graphicContext
))->GetNativeContext();
371 if ( m_logicalFunction
== wxCOPY
)
372 CGContextSetBlendMode( cgContext
, kCGBlendModeNormal
);
373 else if ( m_logicalFunction
== wxINVERT
)
374 CGContextSetBlendMode( cgContext
, kCGBlendModeExclusion
);
376 CGContextSetBlendMode( cgContext
, kCGBlendModeNormal
);
381 bool wxGCDC::DoFloodFill(wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
),
382 const wxColour
& WXUNUSED(col
), int WXUNUSED(style
))
387 bool wxGCDC::DoGetPixel( wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
), wxColour
*WXUNUSED(col
) ) const
389 // wxCHECK_MSG( 0 , false, wxT("wxGCDC(cg)::DoGetPixel - not implemented") );
393 void wxGCDC::DoDrawLine( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
395 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawLine - invalid DC") );
397 #if !wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
399 if ( m_logicalFunction
!= wxCOPY
)
403 m_graphicContext
->StrokeLine(x1
,y1
,x2
,y2
);
405 CalcBoundingBox(x1
, y1
);
406 CalcBoundingBox(x2
, y2
);
409 void wxGCDC::DoCrossHair( wxCoord x
, wxCoord y
)
411 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoCrossHair - invalid DC") );
413 if ( m_logicalFunction
!= wxCOPY
)
420 m_graphicContext
->StrokeLine(0,y
,w
,y
);
421 m_graphicContext
->StrokeLine(x
,0,x
,h
);
423 CalcBoundingBox(0, 0);
424 CalcBoundingBox(0+w
, 0+h
);
427 void wxGCDC::DoDrawArc( wxCoord x1
, wxCoord y1
,
428 wxCoord x2
, wxCoord y2
,
429 wxCoord xc
, wxCoord yc
)
431 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawArc - invalid DC") );
433 if ( m_logicalFunction
!= wxCOPY
)
438 double radius
= sqrt((double)(dx
* dx
+ dy
* dy
));
439 wxCoord rad
= (wxCoord
)radius
;
441 if (x1
== x2
&& y1
== y2
)
446 else if (radius
== 0.0)
452 sa
= (x1
- xc
== 0) ?
453 (y1
- yc
< 0) ? 90.0 : -90.0 :
454 -atan2(double(y1
- yc
), double(x1
- xc
)) * RAD2DEG
;
455 ea
= (x2
- xc
== 0) ?
456 (y2
- yc
< 0) ? 90.0 : -90.0 :
457 -atan2(double(y2
- yc
), double(x2
- xc
)) * RAD2DEG
;
460 bool fill
= m_brush
.GetStyle() != wxTRANSPARENT
;
462 wxGraphicsPath path
= m_graphicContext
->CreatePath();
463 if ( fill
&& ((x1
!=x2
)||(y1
!=y2
)) )
464 path
.MoveToPoint( xc
, yc
);
465 path
.AddArc( xc
, yc
, rad
, DegToRad(sa
) , DegToRad(ea
), false );
466 if ( fill
&& ((x1
!=x2
)||(y1
!=y2
)) )
467 path
.AddLineToPoint( xc
, yc
);
468 m_graphicContext
->DrawPath(path
);
471 void wxGCDC::DoDrawEllipticArc( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
472 double sa
, double ea
)
474 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawEllipticArc - invalid DC") );
476 if ( m_logicalFunction
!= wxCOPY
)
479 bool fill
= m_brush
.GetStyle() != wxTRANSPARENT
;
481 wxGraphicsPath path
= m_graphicContext
->CreatePath();
482 m_graphicContext
->PushState();
483 m_graphicContext
->Translate(x
+w
/2,y
+h
/2);
484 wxDouble factor
= ((wxDouble
) w
) / h
;
485 m_graphicContext
->Scale( factor
, 1.0);
486 if ( fill
&& (sa
!=ea
) )
487 path
.MoveToPoint(0,0);
488 // since these angles (ea,sa) are measured counter-clockwise, we invert them to
489 // get clockwise angles
490 path
.AddArc( 0, 0, h
/2 , DegToRad(-sa
) , DegToRad(-ea
), sa
> ea
);
491 if ( fill
&& (sa
!=ea
) )
492 path
.AddLineToPoint(0,0);
493 m_graphicContext
->DrawPath( path
);
494 m_graphicContext
->PopState();
497 void wxGCDC::DoDrawPoint( wxCoord x
, wxCoord y
)
499 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawPoint - invalid DC") );
501 DoDrawLine( x
, y
, x
+ 1 , y
+ 1 );
504 void wxGCDC::DoDrawLines(int n
, wxPoint points
[],
505 wxCoord xoffset
, wxCoord yoffset
)
507 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawLines - invalid DC") );
509 #if !wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
511 if ( m_logicalFunction
!= wxCOPY
)
515 wxPoint2DDouble
* pointsD
= new wxPoint2DDouble
[n
];
516 for( int i
= 0; i
< n
; ++i
)
518 pointsD
[i
].m_x
= points
[i
].x
+ xoffset
;
519 pointsD
[i
].m_y
= points
[i
].y
+ yoffset
;
522 m_graphicContext
->StrokeLines( n
, pointsD
);
527 void wxGCDC::DoDrawSpline(wxList
*points
)
529 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawSpline - invalid DC") );
531 if ( m_logicalFunction
!= wxCOPY
)
534 wxGraphicsPath path
= m_graphicContext
->CreatePath();
536 wxList::compatibility_iterator node
= points
->GetFirst();
537 if (node
== wxList::compatibility_iterator())
541 wxPoint
*p
= (wxPoint
*)node
->GetData();
546 node
= node
->GetNext();
547 p
= (wxPoint
*)node
->GetData();
551 wxCoord cx1
= ( x1
+ x2
) / 2;
552 wxCoord cy1
= ( y1
+ y2
) / 2;
554 path
.MoveToPoint( x1
, y1
);
555 path
.AddLineToPoint( cx1
, cy1
);
558 while ((node
= node
->GetNext()) != NULL
)
561 while ((node
= node
->GetNext()))
565 p
= (wxPoint
*)node
->GetData();
570 wxCoord cx4
= (x1
+ x2
) / 2;
571 wxCoord cy4
= (y1
+ y2
) / 2;
573 path
.AddQuadCurveToPoint(x1
, y1
,cx4
, cy4
);
579 path
.AddLineToPoint( x2
, y2
);
581 m_graphicContext
->StrokePath( path
);
583 #endif // wxUSE_SPLINES
585 void wxGCDC::DoDrawPolygon( int n
, wxPoint points
[],
586 wxCoord xoffset
, wxCoord yoffset
,
589 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawPolygon - invalid DC") );
591 if ( n
<= 0 || (m_brush
.GetStyle() == wxTRANSPARENT
&& m_pen
.GetStyle() == wxTRANSPARENT
) )
593 if ( m_logicalFunction
!= wxCOPY
)
596 bool closeIt
= false;
597 if (points
[n
-1] != points
[0])
600 wxPoint2DDouble
* pointsD
= new wxPoint2DDouble
[n
+(closeIt
?1:0)];
601 for( int i
= 0; i
< n
; ++i
)
603 pointsD
[i
].m_x
= points
[i
].x
+ xoffset
;
604 pointsD
[i
].m_y
= points
[i
].y
+ yoffset
;
607 pointsD
[n
] = pointsD
[0];
609 m_graphicContext
->DrawLines( n
+(closeIt
?1:0) , pointsD
, fillStyle
);
613 void wxGCDC::DoDrawPolyPolygon(int n
,
621 wxGraphicsPath path
= m_graphicContext
->CreatePath();
624 for ( int j
= 0; j
< n
; ++j
)
626 wxPoint start
= points
[i
];
627 path
.MoveToPoint( start
.x
+ xoffset
, start
.y
+ yoffset
);
630 for ( int k
= 1; k
< l
; ++k
)
632 path
.AddLineToPoint( points
[i
].x
+ xoffset
, points
[i
].y
+ yoffset
);
636 if ( start
!= points
[i
-1])
637 path
.AddLineToPoint( start
.x
+ xoffset
, start
.y
+ yoffset
);
639 m_graphicContext
->DrawPath( path
, fillStyle
);
642 void wxGCDC::DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
)
644 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRectangle - invalid DC") );
646 if ( m_logicalFunction
!= wxCOPY
)
649 // CMB: draw nothing if transformed w or h is 0
650 if (w
== 0 || h
== 0)
653 if ( m_graphicContext
->ShouldOffset() )
655 // if we are offsetting the entire rectangle is moved 0.5, so the
656 // border line gets off by 1
660 m_graphicContext
->DrawRectangle(x
,y
,w
,h
);
663 void wxGCDC::DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
664 wxCoord w
, wxCoord h
,
667 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRoundedRectangle - invalid DC") );
669 if ( m_logicalFunction
!= wxCOPY
)
673 radius
= - radius
* ((w
< h
) ? w
: h
);
675 // CMB: draw nothing if transformed w or h is 0
676 if (w
== 0 || h
== 0)
679 m_graphicContext
->DrawRoundedRectangle( x
,y
,w
,h
,radius
);
682 void wxGCDC::DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
)
684 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawEllipse - invalid DC") );
686 if ( m_logicalFunction
!= wxCOPY
)
689 m_graphicContext
->DrawEllipse(x
,y
,w
,h
);
692 bool wxGCDC::CanDrawBitmap() const
698 wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
699 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
, int logical_func
, bool WXUNUSED(useMask
),
700 wxCoord xsrcMask
, wxCoord ysrcMask
)
702 wxCHECK_MSG( Ok(), false, wxT("wxGCDC(cg)::DoBlit - invalid DC") );
703 wxCHECK_MSG( source
->Ok(), false, wxT("wxGCDC(cg)::DoBlit - invalid source DC") );
705 if ( logical_func
== wxNO_OP
)
707 else if ( logical_func
!= wxCOPY
)
709 wxFAIL_MSG( wxT("Blitting is only supported with wxCOPY logical operation.") );
713 if (xsrcMask
== -1 && ysrcMask
== -1)
719 wxRect
subrect(source
-> LogicalToDeviceX(xsrc
),source
-> LogicalToDeviceY(ysrc
),
720 source
-> LogicalToDeviceXRel(width
),source
-> LogicalToDeviceYRel(height
));
722 wxBitmap blit
= source
->GetAsBitmap( &subrect
);
726 m_graphicContext
->DrawBitmap( blit
, xdest
, ydest
, width
, height
);
730 wxFAIL_MSG( wxT("Cannot Blit. Unable to get contents of DC as bitmap.") );
737 void wxGCDC::DoDrawRotatedText(const wxString
& str
, wxCoord x
, wxCoord y
,
740 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRotatedText - invalid DC") );
742 if ( str
.length() == 0 )
744 if ( m_logicalFunction
!= wxCOPY
)
747 m_graphicContext
->DrawText( str
, x
,y
, DegToRad(angle
));
750 void wxGCDC::DoDrawText(const wxString
& str
, wxCoord x
, wxCoord y
)
752 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRotatedText - invalid DC") );
754 if ( str
.length() == 0 )
756 if ( m_logicalFunction
!= wxCOPY
)
759 m_graphicContext
->DrawText( str
, x
,y
);
762 bool wxGCDC::CanGetTextExtent() const
764 wxCHECK_MSG( Ok(), false, wxT("wxGCDC(cg)::CanGetTextExtent - invalid DC") );
769 void wxGCDC::DoGetTextExtent( const wxString
&str
, wxCoord
*width
, wxCoord
*height
,
770 wxCoord
*descent
, wxCoord
*externalLeading
,
771 wxFont
*theFont
) const
773 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoGetTextExtent - invalid DC") );
777 m_graphicContext
->SetFont( *theFont
, m_textForegroundColour
);
780 wxDouble h
, d
, e
, w
;
782 m_graphicContext
->GetTextExtent( str
, &w
, &h
, &d
, &e
);
788 if ( externalLeading
)
795 m_graphicContext
->SetFont( m_font
, m_textForegroundColour
);
799 bool wxGCDC::DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
801 wxCHECK_MSG( Ok(), false, wxT("wxGCDC(cg)::DoGetPartialTextExtents - invalid DC") );
803 widths
.Add(0,text
.Length());
804 if ( text
.IsEmpty() )
807 wxArrayDouble widthsD
;
809 m_graphicContext
->GetPartialTextExtents( text
, widthsD
);
810 for ( size_t i
= 0; i
< widths
.GetCount(); ++i
)
811 widths
[i
] = (wxCoord
)(widthsD
[i
] + 0.5);
816 wxCoord
wxGCDC::GetCharWidth(void) const
819 DoGetTextExtent( wxT("g") , &width
, NULL
, NULL
, NULL
, NULL
);
824 wxCoord
wxGCDC::GetCharHeight(void) const
827 DoGetTextExtent( wxT("g") , NULL
, &height
, NULL
, NULL
, NULL
);
832 void wxGCDC::Clear(void)
834 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::Clear - invalid DC") );
835 // TODO better implementation / incorporate size info into wxGCDC or context
836 m_graphicContext
->SetBrush( m_backgroundBrush
);
837 wxPen p
= *wxTRANSPARENT_PEN
;
838 m_graphicContext
->SetPen( p
);
839 DoDrawRectangle( 0, 0, 32000 , 32000 );
840 m_graphicContext
->SetPen( m_pen
);
841 m_graphicContext
->SetBrush( m_brush
);
844 void wxGCDC::DoGetSize(int *width
, int *height
) const
850 void wxGCDC::DoGradientFillLinear(const wxRect
& rect
,
851 const wxColour
& initialColour
,
852 const wxColour
& destColour
,
853 wxDirection nDirection
)
860 start
= rect
.GetRightBottom();
862 end
= rect
.GetLeftBottom();
865 start
= rect
.GetLeftBottom();
866 end
= rect
.GetRightBottom();
870 start
= rect
.GetLeftBottom();
872 end
= rect
.GetLeftTop();
875 start
= rect
.GetLeftTop();
876 end
= rect
.GetLeftBottom();
883 if (rect
.width
== 0 || rect
.height
== 0)
886 m_graphicContext
->SetBrush( m_graphicContext
->CreateLinearGradientBrush(
887 start
.x
,start
.y
,end
.x
,end
.y
, initialColour
, destColour
));
888 m_graphicContext
->SetPen(*wxTRANSPARENT_PEN
);
889 m_graphicContext
->DrawRectangle(rect
.x
,rect
.y
,rect
.width
,rect
.height
);
890 m_graphicContext
->SetPen(m_pen
);
893 void wxGCDC::DoGradientFillConcentric(const wxRect
& rect
,
894 const wxColour
& initialColour
,
895 const wxColour
& destColour
,
896 const wxPoint
& circleCenter
)
899 wxInt32 cx
= rect
.GetWidth() / 2;
900 wxInt32 cy
= rect
.GetHeight() / 2;
907 // make sure the background is filled (todo move into specific platform implementation ?)
908 m_graphicContext
->SetPen(*wxTRANSPARENT_PEN
);
909 m_graphicContext
->SetBrush( wxBrush( destColour
) );
910 m_graphicContext
->DrawRectangle(rect
.x
,rect
.y
,rect
.width
,rect
.height
);
912 m_graphicContext
->SetBrush( m_graphicContext
->CreateRadialGradientBrush(
913 rect
.x
+circleCenter
.x
,rect
.y
+circleCenter
.y
,
914 rect
.x
+circleCenter
.x
,rect
.y
+circleCenter
.y
,
915 nRadius
,initialColour
,destColour
));
917 m_graphicContext
->DrawRectangle(rect
.x
,rect
.y
,rect
.width
,rect
.height
);
918 m_graphicContext
->SetPen(m_pen
);
921 void wxGCDC::DoDrawCheckMark(wxCoord x
, wxCoord y
,
922 wxCoord width
, wxCoord height
)
924 wxDCBase::DoDrawCheckMark(x
,y
,width
,height
);
927 #endif // wxUSE_GRAPHICS_CONTEXT