]> git.saurik.com Git - wxWidgets.git/blame - src/common/dcgraph.cpp
Make brush hatches in wxGTK consistent with wxMSW.
[wxWidgets.git] / src / common / dcgraph.cpp
CommitLineData
1b89a5cd
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/common/graphcmn.cpp
3// Purpose: graphics context methods common to all platforms
4// Author: Stefan Csomor
5// Modified by:
6c0aace2 6// Created:
1b89a5cd
SC
7// RCS-ID: $Id$
8// Copyright: (c) Stefan Csomor
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
15#if defined(__BORLANDC__)
16 #pragma hdrstop
17#endif
18
19#if wxUSE_GRAPHICS_CONTEXT
20
21#include "wx/graphics.h"
888dde65 22#include "wx/dcgraph.h"
1b89a5cd
SC
23
24#ifndef WX_PRECOMP
25 #include "wx/icon.h"
26 #include "wx/bitmap.h"
27 #include "wx/dcmemory.h"
28 #include "wx/region.h"
29#endif
30
b02d4340
VZ
31#include "wx/dcclient.h"
32
0b6a49c2 33#ifdef __WXOSX_OR_COCOA__
c933e267
SC
34#ifdef __WXOSX_IPHONE__
35 #include <CoreGraphics/CoreGraphics.h>
36#else
37 #include <ApplicationServices/ApplicationServices.h>
38#endif
fcaea2fa 39#endif
b02d4340 40
1b89a5cd
SC
41//-----------------------------------------------------------------------------
42// constants
43//-----------------------------------------------------------------------------
44
45static const double RAD2DEG = 180.0 / M_PI;
46
47//-----------------------------------------------------------------------------
48// Local functions
49//-----------------------------------------------------------------------------
50
51static inline double DegToRad(double deg)
52{
53 return (deg * M_PI) / 180.0;
54}
55
bf02a7f9
SC
56static bool TranslateRasterOp(wxRasterOperationMode function, wxCompositionMode *op)
57{
58 switch ( function )
59 {
954c66fa
SC
60 case wxCOPY: // src
61 // since we are supporting alpha, _OVER is closer to the intention than _SOURCE
62 // since the latter would overwrite even when alpha is is not set to opaque
63 *op = wxCOMPOSITION_OVER;
bf02a7f9
SC
64 break;
65 case wxOR: // src OR dst
66 *op = wxCOMPOSITION_ADD;
67 break;
68 case wxNO_OP: // dst
69 *op = wxCOMPOSITION_DEST; // ignore the source
70 break;
71 case wxCLEAR: // 0
72 *op = wxCOMPOSITION_CLEAR;// clear dst
73 break;
74 case wxXOR: // src XOR dst
75 *op = wxCOMPOSITION_XOR;
76 break;
03647350 77
bf02a7f9
SC
78 case wxAND: // src AND dst
79 case wxAND_INVERT: // (NOT src) AND dst
80 case wxAND_REVERSE:// src AND (NOT dst)
81 case wxEQUIV: // (NOT src) XOR dst
82 case wxINVERT: // NOT dst
83 case wxNAND: // (NOT src) OR (NOT dst)
84 case wxNOR: // (NOT src) AND (NOT dst)
85 case wxOR_INVERT: // (NOT src) OR dst
86 case wxOR_REVERSE: // src OR (NOT dst)
87 case wxSET: // 1
88 case wxSRC_INVERT: // NOT src
89 default:
90 return false;
91 }
92 return true;
93}
94
1b89a5cd
SC
95//-----------------------------------------------------------------------------
96// wxDC bridge class
97//-----------------------------------------------------------------------------
98
1b89a5cd 99IMPLEMENT_DYNAMIC_CLASS(wxGCDC, wxDC)
888dde65 100
7b1a66bb
RR
101wxGCDC::wxGCDC(const wxWindowDC& dc) :
102 wxDC( new wxGCDCImpl( this, dc ) )
888dde65 103{
888dde65
RR
104}
105
7b1a66bb
RR
106wxGCDC::wxGCDC( const wxMemoryDC& dc) :
107 wxDC( new wxGCDCImpl( this, dc ) )
888dde65 108{
888dde65 109}
1b89a5cd 110
6d0d8455 111#if wxUSE_PRINTING_ARCHITECTURE
b25c34aa
RR
112wxGCDC::wxGCDC( const wxPrinterDC& dc) :
113 wxDC( new wxGCDCImpl( this, dc ) )
114{
115}
6d0d8455 116#endif
b25c34aa 117
7b1a66bb
RR
118wxGCDC::wxGCDC() :
119 wxDC( new wxGCDCImpl( this ) )
1b89a5cd 120{
888dde65
RR
121}
122
9412ee9a
SC
123wxGCDC::~wxGCDC()
124{
125}
126
888dde65
RR
127wxGraphicsContext* wxGCDC::GetGraphicsContext()
128{
129 if (!m_pimpl) return NULL;
130 wxGCDCImpl *gc_impl = (wxGCDCImpl*) m_pimpl;
131 return gc_impl->GetGraphicsContext();
1b89a5cd
SC
132}
133
134void wxGCDC::SetGraphicsContext( wxGraphicsContext* ctx )
888dde65
RR
135{
136 if (!m_pimpl) return;
137 wxGCDCImpl *gc_impl = (wxGCDCImpl*) m_pimpl;
138 gc_impl->SetGraphicsContext( ctx );
139}
140
141IMPLEMENT_ABSTRACT_CLASS(wxGCDCImpl, wxDCImpl)
142
143wxGCDCImpl::wxGCDCImpl( wxDC *owner ) :
144 wxDCImpl( owner )
145{
146 Init();
147}
148
149void wxGCDCImpl::SetGraphicsContext( wxGraphicsContext* ctx )
6c0aace2 150{
1b89a5cd
SC
151 delete m_graphicContext;
152 m_graphicContext = ctx;
914fd3f1
SC
153 if ( m_graphicContext )
154 {
155 m_matrixOriginal = m_graphicContext->GetTransform();
156 m_ok = true;
fd791571
SC
157 // apply the stored transformations to the passed in context
158 ComputeScaleAndOrigin();
ad667945
SC
159 m_graphicContext->SetFont( m_font , m_textForegroundColour );
160 m_graphicContext->SetPen( m_pen );
161 m_graphicContext->SetBrush( m_brush);
914fd3f1 162 }
1b89a5cd
SC
163}
164
888dde65
RR
165wxGCDCImpl::wxGCDCImpl( wxDC *owner, const wxWindowDC& dc ) :
166 wxDCImpl( owner )
1b89a5cd
SC
167{
168 Init();
914fd3f1 169 SetGraphicsContext( wxGraphicsContext::Create(dc) );
7b98cf02 170 m_window = dc.GetWindow();
1b89a5cd
SC
171}
172
888dde65
RR
173wxGCDCImpl::wxGCDCImpl( wxDC *owner, const wxMemoryDC& dc ) :
174 wxDCImpl( owner )
773ccc31
SC
175{
176 Init();
c0e69d72
KO
177 wxGraphicsContext* context;
178#if wxUSE_CAIRO
179 wxGraphicsRenderer* renderer = wxGraphicsRenderer::GetCairoRenderer();
180 context = renderer->CreateContext(dc);
181#else
182 context = wxGraphicsContext::Create(dc);
183#endif
184
185 SetGraphicsContext( context );
773ccc31 186}
773ccc31 187
6d0d8455 188#if wxUSE_PRINTING_ARCHITECTURE
b25c34aa
RR
189wxGCDCImpl::wxGCDCImpl( wxDC *owner, const wxPrinterDC& dc ) :
190 wxDCImpl( owner )
191{
192 Init();
193 SetGraphicsContext( wxGraphicsContext::Create(dc) );
194}
6d0d8455 195#endif
b25c34aa 196
888dde65 197void wxGCDCImpl::Init()
1b89a5cd
SC
198{
199 m_ok = false;
200 m_colour = true;
201 m_mm_to_pix_x = mm2pt;
202 m_mm_to_pix_y = mm2pt;
203
204 m_pen = *wxBLACK_PEN;
205 m_font = *wxNORMAL_FONT;
206 m_brush = *wxWHITE_BRUSH;
207
d9edff06 208 m_graphicContext = wxGraphicsContext::Create();
4280b879 209 m_logicalFunctionSupported = true;
1b89a5cd
SC
210}
211
212
888dde65 213wxGCDCImpl::~wxGCDCImpl()
1b89a5cd
SC
214{
215 delete m_graphicContext;
216}
217
08de4403
VZ
218void wxGCDCImpl::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y,
219 bool useMask )
1b89a5cd 220{
888dde65
RR
221 wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid DC") );
222 wxCHECK_RET( bmp.IsOk(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid bitmap") );
1b89a5cd 223
08de4403
VZ
224 int w = bmp.GetWidth();
225 int h = bmp.GetHeight();
f889bdb3
SC
226 if ( bmp.GetDepth() == 1 )
227 {
228 m_graphicContext->SetPen(*wxTRANSPARENT_PEN);
229 m_graphicContext->SetBrush( wxBrush( m_textBackgroundColour , wxSOLID ) );
08de4403 230 m_graphicContext->DrawRectangle( x, y, w, h );
f889bdb3 231 m_graphicContext->SetBrush( wxBrush( m_textForegroundColour , wxSOLID ) );
08de4403 232 m_graphicContext->DrawBitmap( bmp, x, y, w, h );
f889bdb3
SC
233 m_graphicContext->SetBrush( m_graphicContext->CreateBrush(m_brush));
234 m_graphicContext->SetPen( m_graphicContext->CreatePen(m_pen));
235 }
08de4403
VZ
236 else // not a monochrome bitmap, handle it normally
237 {
238 // make a copy in case we need to remove its mask, if we don't modify
239 // it the copy is cheap as bitmaps are reference-counted
240 wxBitmap bmpCopy(bmp);
241 if ( !useMask && bmp.GetMask() )
242 bmpCopy.SetMask(NULL);
243
244 m_graphicContext->DrawBitmap( bmpCopy, x, y, w, h );
245 }
1b89a5cd
SC
246}
247
888dde65 248void wxGCDCImpl::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y )
1b89a5cd 249{
888dde65
RR
250 wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawIcon - invalid DC") );
251 wxCHECK_RET( icon.IsOk(), wxT("wxGCDC(cg)::DoDrawIcon - invalid icon") );
1b89a5cd 252
1b89a5cd
SC
253 wxCoord w = icon.GetWidth();
254 wxCoord h = icon.GetHeight();
1b89a5cd 255
0ebd9515 256 m_graphicContext->DrawIcon( icon , x, y, w, h );
1b89a5cd
SC
257}
258
b02d4340 259bool wxGCDCImpl::StartDoc( const wxString& WXUNUSED(message) )
fcaea2fa 260{
26dfebbd 261 return true;
fcaea2fa
SC
262}
263
b02d4340 264void wxGCDCImpl::EndDoc()
fcaea2fa
SC
265{
266}
267
888dde65 268void wxGCDCImpl::StartPage()
fcaea2fa
SC
269{
270}
271
b02d4340 272void wxGCDCImpl::EndPage()
fcaea2fa
SC
273{
274}
b02d4340 275
888dde65 276void wxGCDCImpl::Flush()
fcaea2fa 277{
50211394 278 m_graphicContext->Flush();
fcaea2fa
SC
279}
280
888dde65 281void wxGCDCImpl::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord w, wxCoord h )
1b89a5cd 282{
888dde65 283 wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoSetClippingRegion - invalid DC") );
1b89a5cd 284
0ebd9515 285 m_graphicContext->Clip( x, y, w, h );
1b89a5cd
SC
286 if ( m_clipping )
287 {
0ebd9515
SC
288 m_clipX1 = wxMax( m_clipX1, x );
289 m_clipY1 = wxMax( m_clipY1, y );
290 m_clipX2 = wxMin( m_clipX2, (x + w) );
291 m_clipY2 = wxMin( m_clipY2, (y + h) );
1b89a5cd
SC
292 }
293 else
294 {
295 m_clipping = true;
296
0ebd9515
SC
297 m_clipX1 = x;
298 m_clipY1 = y;
299 m_clipX2 = x + w;
300 m_clipY2 = y + h;
1b89a5cd
SC
301 }
302}
303
fdaad94e 304void wxGCDCImpl::DoSetDeviceClippingRegion( const wxRegion &region )
1b89a5cd 305{
4bae004c 306 // region is in device coordinates
fdaad94e 307 wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoSetDeviceClippingRegion - invalid DC") );
1b89a5cd
SC
308
309 if (region.Empty())
310 {
fcaea2fa 311 //DestroyClippingRegion();
1b89a5cd
SC
312 return;
313 }
314
4bae004c 315 wxRegion logRegion( region );
1b89a5cd 316 wxCoord x, y, w, h;
0ebd9515 317
4bae004c
SC
318 logRegion.Offset( DeviceToLogicalX(0), DeviceToLogicalY(0) );
319 logRegion.GetBox( x, y, w, h );
320
321 m_graphicContext->Clip( logRegion );
0ebd9515 322 if ( m_clipping )
1b89a5cd 323 {
0ebd9515
SC
324 m_clipX1 = wxMax( m_clipX1, x );
325 m_clipY1 = wxMax( m_clipY1, y );
326 m_clipX2 = wxMin( m_clipX2, (x + w) );
327 m_clipY2 = wxMin( m_clipY2, (y + h) );
1b89a5cd
SC
328 }
329 else
330 {
0ebd9515 331 m_clipping = true;
1b89a5cd 332
0ebd9515
SC
333 m_clipX1 = x;
334 m_clipY1 = y;
335 m_clipX2 = x + w;
336 m_clipY2 = y + h;
1b89a5cd
SC
337 }
338}
339
888dde65 340void wxGCDCImpl::DestroyClippingRegion()
1b89a5cd
SC
341{
342 m_graphicContext->ResetClip();
cb6e26b8
SC
343 // currently the clip eg of a window extends to the area between the scrollbars
344 // so we must explicitely make sure it only covers the area we want it to draw
345 int width, height ;
888dde65 346 GetOwner()->GetSize( &width , &height ) ;
fcaea2fa 347 m_graphicContext->Clip( DeviceToLogicalX(0) , DeviceToLogicalY(0) , DeviceToLogicalXRel(width), DeviceToLogicalYRel(height) );
b02d4340 348
1b89a5cd
SC
349 m_graphicContext->SetPen( m_pen );
350 m_graphicContext->SetBrush( m_brush );
351
352 m_clipping = false;
353}
354
888dde65 355void wxGCDCImpl::DoGetSizeMM( int* width, int* height ) const
1b89a5cd
SC
356{
357 int w = 0, h = 0;
358
888dde65 359 GetOwner()->GetSize( &w, &h );
1b89a5cd
SC
360 if (width)
361 *width = long( double(w) / (m_scaleX * m_mm_to_pix_x) );
362 if (height)
363 *height = long( double(h) / (m_scaleY * m_mm_to_pix_y) );
364}
365
888dde65 366void wxGCDCImpl::SetTextForeground( const wxColour &col )
1b89a5cd 367{
888dde65 368 wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::SetTextForeground - invalid DC") );
1b89a5cd
SC
369
370 if ( col != m_textForegroundColour )
371 {
372 m_textForegroundColour = col;
373 m_graphicContext->SetFont( m_font, m_textForegroundColour );
374 }
375}
376
888dde65 377void wxGCDCImpl::SetTextBackground( const wxColour &col )
1b89a5cd 378{
888dde65 379 wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::SetTextBackground - invalid DC") );
1b89a5cd
SC
380
381 m_textBackgroundColour = col;
382}
383
89efaf2b 384void wxGCDCImpl::SetMapMode( wxMappingMode mode )
1b89a5cd
SC
385{
386 switch (mode)
387 {
388 case wxMM_TWIPS:
389 SetLogicalScale( twips2mm * m_mm_to_pix_x, twips2mm * m_mm_to_pix_y );
390 break;
391
392 case wxMM_POINTS:
393 SetLogicalScale( pt2mm * m_mm_to_pix_x, pt2mm * m_mm_to_pix_y );
394 break;
395
396 case wxMM_METRIC:
397 SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y );
398 break;
399
400 case wxMM_LOMETRIC:
401 SetLogicalScale( m_mm_to_pix_x / 10.0, m_mm_to_pix_y / 10.0 );
402 break;
403
404 case wxMM_TEXT:
405 default:
406 SetLogicalScale( 1.0, 1.0 );
407 break;
408 }
409
410 ComputeScaleAndOrigin();
411}
412
888dde65 413wxSize wxGCDCImpl::GetPPI() const
1b89a5cd
SC
414{
415 return wxSize(72, 72);
416}
417
888dde65 418int wxGCDCImpl::GetDepth() const
1b89a5cd
SC
419{
420 return 32;
421}
422
888dde65 423void wxGCDCImpl::ComputeScaleAndOrigin()
b02d4340 424{
2dedef25 425 wxDCImpl::ComputeScaleAndOrigin();
1b89a5cd 426
fd791571
SC
427 if ( m_graphicContext )
428 {
429 m_matrixCurrent = m_graphicContext->CreateMatrix();
08de4403 430
fd791571 431 // the logical origin sets the origin to have new coordinates
08de4403 432 m_matrixCurrent.Translate( m_deviceOriginX - m_logicalOriginX * m_signX * m_scaleX,
d225267e 433 m_deviceOriginY-m_logicalOriginY * m_signY * m_scaleY);
08de4403 434
d225267e 435 m_matrixCurrent.Scale( m_scaleX * m_signX, m_scaleY * m_signY );
08de4403 436
fd791571
SC
437 m_graphicContext->SetTransform( m_matrixOriginal );
438 m_graphicContext->ConcatTransform( m_matrixCurrent );
439 }
1b89a5cd
SC
440}
441
888dde65 442void wxGCDCImpl::SetPalette( const wxPalette& WXUNUSED(palette) )
1b89a5cd
SC
443{
444
445}
446
888dde65 447void wxGCDCImpl::SetBackgroundMode( int mode )
1b89a5cd
SC
448{
449 m_backgroundMode = mode;
450}
451
888dde65 452void wxGCDCImpl::SetFont( const wxFont &font )
1b89a5cd
SC
453{
454 m_font = font;
455 if ( m_graphicContext )
456 {
457 wxFont f = font;
888dde65 458 if ( f.IsOk() )
0ebd9515 459 f.SetPointSize( /*LogicalToDeviceYRel*/(font.GetPointSize()));
1b89a5cd
SC
460 m_graphicContext->SetFont( f, m_textForegroundColour );
461 }
462}
463
888dde65 464void wxGCDCImpl::SetPen( const wxPen &pen )
1b89a5cd
SC
465{
466 if ( m_pen == pen )
467 return;
468
469 m_pen = pen;
470 if ( m_graphicContext )
471 {
0ebd9515 472 m_graphicContext->SetPen( m_pen );
1b89a5cd
SC
473 }
474}
475
888dde65 476void wxGCDCImpl::SetBrush( const wxBrush &brush )
1b89a5cd
SC
477{
478 if (m_brush == brush)
479 return;
480
481 m_brush = brush;
482 if ( m_graphicContext )
483 {
0ebd9515 484 m_graphicContext->SetBrush( m_brush );
1b89a5cd
SC
485 }
486}
b02d4340 487
888dde65 488void wxGCDCImpl::SetBackground( const wxBrush &brush )
1b89a5cd
SC
489{
490 if (m_backgroundBrush == brush)
491 return;
492
493 m_backgroundBrush = brush;
888dde65 494 if (!m_backgroundBrush.IsOk())
1b89a5cd
SC
495 return;
496}
497
89efaf2b 498void wxGCDCImpl::SetLogicalFunction( wxRasterOperationMode function )
1b89a5cd
SC
499{
500 if (m_logicalFunction == function)
501 return;
502
503 m_logicalFunction = function;
03647350 504
bf02a7f9
SC
505 wxCompositionMode mode;
506 m_logicalFunctionSupported = TranslateRasterOp( function, &mode);
507 if (m_logicalFunctionSupported)
508 m_logicalFunctionSupported = m_graphicContext->SetCompositionMode(mode);
03647350 509
584be856 510 if ( function == wxXOR )
bf02a7f9 511 m_graphicContext->SetAntialiasMode(wxANTIALIAS_NONE);
1b89a5cd 512 else
bf02a7f9 513 m_graphicContext->SetAntialiasMode(wxANTIALIAS_DEFAULT);
1b89a5cd
SC
514}
515
888dde65 516bool wxGCDCImpl::DoFloodFill(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
03647350 517 const wxColour& WXUNUSED(col),
89efaf2b 518 wxFloodFillStyle WXUNUSED(style))
1b89a5cd
SC
519{
520 return false;
521}
522
888dde65 523bool wxGCDCImpl::DoGetPixel( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), wxColour *WXUNUSED(col) ) const
1b89a5cd
SC
524{
525 // wxCHECK_MSG( 0 , false, wxT("wxGCDC(cg)::DoGetPixel - not implemented") );
526 return false;
527}
528
888dde65 529void wxGCDCImpl::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
1b89a5cd 530{
888dde65 531 wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawLine - invalid DC") );
1b89a5cd 532
4280b879 533 if ( !m_logicalFunctionSupported )
1b89a5cd 534 return;
1b89a5cd 535
0ebd9515 536 m_graphicContext->StrokeLine(x1,y1,x2,y2);
1b89a5cd
SC
537
538 CalcBoundingBox(x1, y1);
539 CalcBoundingBox(x2, y2);
540}
541
888dde65 542void wxGCDCImpl::DoCrossHair( wxCoord x, wxCoord y )
1b89a5cd 543{
888dde65 544 wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoCrossHair - invalid DC") );
1b89a5cd 545
4280b879 546 if ( !m_logicalFunctionSupported )
1b89a5cd
SC
547 return;
548
549 int w = 0, h = 0;
550
888dde65 551 GetOwner()->GetSize( &w, &h );
1b89a5cd 552
0ebd9515
SC
553 m_graphicContext->StrokeLine(0,y,w,y);
554 m_graphicContext->StrokeLine(x,0,x,h);
1b89a5cd 555
0ebd9515
SC
556 CalcBoundingBox(0, 0);
557 CalcBoundingBox(0+w, 0+h);
1b89a5cd
SC
558}
559
888dde65 560void wxGCDCImpl::DoDrawArc( wxCoord x1, wxCoord y1,
1b89a5cd
SC
561 wxCoord x2, wxCoord y2,
562 wxCoord xc, wxCoord yc )
563{
888dde65 564 wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawArc - invalid DC") );
1b89a5cd 565
4280b879 566 if ( !m_logicalFunctionSupported )
1b89a5cd
SC
567 return;
568
0ebd9515
SC
569 double dx = x1 - xc;
570 double dy = y1 - yc;
1b89a5cd
SC
571 double radius = sqrt((double)(dx * dx + dy * dy));
572 wxCoord rad = (wxCoord)radius;
573 double sa, ea;
0ebd9515 574 if (x1 == x2 && y1 == y2)
1b89a5cd
SC
575 {
576 sa = 0.0;
577 ea = 360.0;
578 }
579 else if (radius == 0.0)
580 {
581 sa = ea = 0.0;
582 }
583 else
584 {
0ebd9515
SC
585 sa = (x1 - xc == 0) ?
586 (y1 - yc < 0) ? 90.0 : -90.0 :
587 -atan2(double(y1 - yc), double(x1 - xc)) * RAD2DEG;
588 ea = (x2 - xc == 0) ?
589 (y2 - yc < 0) ? 90.0 : -90.0 :
590 -atan2(double(y2 - yc), double(x2 - xc)) * RAD2DEG;
1b89a5cd
SC
591 }
592
593 bool fill = m_brush.GetStyle() != wxTRANSPARENT;
594
a4e73390 595 wxGraphicsPath path = m_graphicContext->CreatePath();
1b89a5cd 596 if ( fill && ((x1!=x2)||(y1!=y2)) )
0ebd9515 597 path.MoveToPoint( xc, yc );
4bae004c
SC
598 // since these angles (ea,sa) are measured counter-clockwise, we invert them to
599 // get clockwise angles
600 path.AddArc( xc, yc , rad , DegToRad(-sa) , DegToRad(-ea), false );
1b89a5cd 601 if ( fill && ((x1!=x2)||(y1!=y2)) )
0ebd9515 602 path.AddLineToPoint( xc, yc );
1b89a5cd 603 m_graphicContext->DrawPath(path);
1b89a5cd
SC
604}
605
888dde65 606void wxGCDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h,
1b89a5cd
SC
607 double sa, double ea )
608{
888dde65 609 wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawEllipticArc - invalid DC") );
1b89a5cd 610
4280b879 611 if ( !m_logicalFunctionSupported )
1b89a5cd
SC
612 return;
613
1b89a5cd 614 m_graphicContext->PushState();
d9485f89 615 m_graphicContext->Translate(x+w/2.0,y+h/2.0);
0ebd9515 616 wxDouble factor = ((wxDouble) w) / h;
1b89a5cd 617 m_graphicContext->Scale( factor , 1.0);
d9485f89 618
1b89a5cd
SC
619 // since these angles (ea,sa) are measured counter-clockwise, we invert them to
620 // get clockwise angles
fcaea2fa
SC
621 if ( m_brush.GetStyle() != wxTRANSPARENT )
622 {
623 wxGraphicsPath path = m_graphicContext->CreatePath();
624 path.MoveToPoint( 0, 0 );
47c1bb95 625 path.AddArc( 0, 0, h/2.0 , DegToRad(-sa) , DegToRad(-ea), sa > ea );
fcaea2fa
SC
626 path.AddLineToPoint( 0, 0 );
627 m_graphicContext->FillPath( path );
628
629 path = m_graphicContext->CreatePath();
630 path.AddArc( 0, 0, h/2.0 , DegToRad(-sa) , DegToRad(-ea), sa > ea );
fcaea2fa
SC
631 m_graphicContext->StrokePath( path );
632 }
633 else
634 {
635 wxGraphicsPath path = m_graphicContext->CreatePath();
47c1bb95
SC
636 path.AddArc( 0, 0, h/2.0 , DegToRad(-sa) , DegToRad(-ea), sa > ea );
637 m_graphicContext->DrawPath( path );
fcaea2fa
SC
638 }
639
1b89a5cd 640 m_graphicContext->PopState();
1b89a5cd
SC
641}
642
888dde65 643void wxGCDCImpl::DoDrawPoint( wxCoord x, wxCoord y )
1b89a5cd 644{
888dde65 645 wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawPoint - invalid DC") );
1b89a5cd
SC
646
647 DoDrawLine( x , y , x + 1 , y + 1 );
648}
649
888dde65 650void wxGCDCImpl::DoDrawLines(int n, wxPoint points[],
1b89a5cd
SC
651 wxCoord xoffset, wxCoord yoffset)
652{
888dde65 653 wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawLines - invalid DC") );
1b89a5cd 654
4280b879 655 if ( !m_logicalFunctionSupported )
1b89a5cd 656 return;
1b89a5cd
SC
657
658 wxPoint2DDouble* pointsD = new wxPoint2DDouble[n];
659 for( int i = 0; i < n; ++i)
660 {
0ebd9515
SC
661 pointsD[i].m_x = points[i].x + xoffset;
662 pointsD[i].m_y = points[i].y + yoffset;
1b89a5cd
SC
663 }
664
665 m_graphicContext->StrokeLines( n , pointsD);
666 delete[] pointsD;
667}
668
669#if wxUSE_SPLINES
888dde65 670void wxGCDCImpl::DoDrawSpline(const wxPointList *points)
1b89a5cd 671{
888dde65 672 wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawSpline - invalid DC") );
1b89a5cd 673
4280b879 674 if ( !m_logicalFunctionSupported )
1b89a5cd
SC
675 return;
676
a4e73390 677 wxGraphicsPath path = m_graphicContext->CreatePath();
1b89a5cd 678
b0d7707b 679 wxPointList::compatibility_iterator node = points->GetFirst();
cb98e78b 680 if ( !node )
1b89a5cd
SC
681 // empty list
682 return;
683
b0d7707b 684 wxPoint *p = node->GetData();
1b89a5cd
SC
685
686 wxCoord x1 = p->x;
687 wxCoord y1 = p->y;
688
689 node = node->GetNext();
b0d7707b 690 p = node->GetData();
1b89a5cd
SC
691
692 wxCoord x2 = p->x;
693 wxCoord y2 = p->y;
694 wxCoord cx1 = ( x1 + x2 ) / 2;
695 wxCoord cy1 = ( y1 + y2 ) / 2;
696
0ebd9515
SC
697 path.MoveToPoint( x1 , y1 );
698 path.AddLineToPoint( cx1 , cy1 );
1b89a5cd
SC
699#if !wxUSE_STL
700
701 while ((node = node->GetNext()) != NULL)
702#else
703
704 while ((node = node->GetNext()))
705#endif // !wxUSE_STL
706
707 {
b0d7707b 708 p = node->GetData();
1b89a5cd
SC
709 x1 = x2;
710 y1 = y2;
711 x2 = p->x;
712 y2 = p->y;
713 wxCoord cx4 = (x1 + x2) / 2;
714 wxCoord cy4 = (y1 + y2) / 2;
715
0ebd9515 716 path.AddQuadCurveToPoint(x1 , y1 ,cx4 , cy4 );
1b89a5cd
SC
717
718 cx1 = cx4;
719 cy1 = cy4;
720 }
721
0ebd9515 722 path.AddLineToPoint( x2 , y2 );
1b89a5cd
SC
723
724 m_graphicContext->StrokePath( path );
1b89a5cd
SC
725}
726#endif // wxUSE_SPLINES
727
888dde65 728void wxGCDCImpl::DoDrawPolygon( int n, wxPoint points[],
89efaf2b
FM
729 wxCoord xoffset, wxCoord yoffset,
730 wxPolygonFillMode fillStyle )
1b89a5cd 731{
888dde65 732 wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawPolygon - invalid DC") );
1b89a5cd
SC
733
734 if ( n <= 0 || (m_brush.GetStyle() == wxTRANSPARENT && m_pen.GetStyle() == wxTRANSPARENT ) )
735 return;
4280b879 736 if ( !m_logicalFunctionSupported )
1b89a5cd
SC
737 return;
738
739 bool closeIt = false;
740 if (points[n-1] != points[0])
741 closeIt = true;
742
743 wxPoint2DDouble* pointsD = new wxPoint2DDouble[n+(closeIt?1:0)];
744 for( int i = 0; i < n; ++i)
745 {
0ebd9515
SC
746 pointsD[i].m_x = points[i].x + xoffset;
747 pointsD[i].m_y = points[i].y + yoffset;
1b89a5cd
SC
748 }
749 if ( closeIt )
750 pointsD[n] = pointsD[0];
751
752 m_graphicContext->DrawLines( n+(closeIt?1:0) , pointsD, fillStyle);
753 delete[] pointsD;
754}
755
888dde65 756void wxGCDCImpl::DoDrawPolyPolygon(int n,
1b89a5cd
SC
757 int count[],
758 wxPoint points[],
759 wxCoord xoffset,
760 wxCoord yoffset,
89efaf2b 761 wxPolygonFillMode fillStyle)
1b89a5cd
SC
762{
763 wxASSERT(n > 1);
a4e73390 764 wxGraphicsPath path = m_graphicContext->CreatePath();
1b89a5cd
SC
765
766 int i = 0;
767 for ( int j = 0; j < n; ++j)
768 {
769 wxPoint start = points[i];
0ebd9515 770 path.MoveToPoint( start.x+ xoffset, start.y+ yoffset);
1b89a5cd
SC
771 ++i;
772 int l = count[j];
773 for ( int k = 1; k < l; ++k)
774 {
0ebd9515 775 path.AddLineToPoint( points[i].x+ xoffset, points[i].y+ yoffset);
1b89a5cd
SC
776 ++i;
777 }
778 // close the polygon
779 if ( start != points[i-1])
0ebd9515 780 path.AddLineToPoint( start.x+ xoffset, start.y+ yoffset);
1b89a5cd
SC
781 }
782 m_graphicContext->DrawPath( path , fillStyle);
1b89a5cd
SC
783}
784
888dde65 785void wxGCDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
1b89a5cd 786{
888dde65 787 wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawRectangle - invalid DC") );
1b89a5cd 788
4280b879 789 if ( !m_logicalFunctionSupported )
1b89a5cd
SC
790 return;
791
1b89a5cd 792 // CMB: draw nothing if transformed w or h is 0
0ebd9515 793 if (w == 0 || h == 0)
1b89a5cd
SC
794 return;
795
5ebfdf41
SC
796 if ( m_graphicContext->ShouldOffset() )
797 {
798 // if we are offsetting the entire rectangle is moved 0.5, so the
799 // border line gets off by 1
0ebd9515
SC
800 w -= 1;
801 h -= 1;
5ebfdf41 802 }
0ebd9515 803 m_graphicContext->DrawRectangle(x,y,w,h);
1b89a5cd
SC
804}
805
888dde65 806void wxGCDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y,
0ebd9515 807 wxCoord w, wxCoord h,
1b89a5cd
SC
808 double radius)
809{
888dde65 810 wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawRoundedRectangle - invalid DC") );
1b89a5cd 811
4280b879 812 if ( !m_logicalFunctionSupported )
1b89a5cd
SC
813 return;
814
815 if (radius < 0.0)
0ebd9515 816 radius = - radius * ((w < h) ? w : h);
1b89a5cd
SC
817
818 // CMB: draw nothing if transformed w or h is 0
0ebd9515 819 if (w == 0 || h == 0)
1b89a5cd
SC
820 return;
821
d9485f89
RD
822 if ( m_graphicContext->ShouldOffset() )
823 {
824 // if we are offsetting the entire rectangle is moved 0.5, so the
825 // border line gets off by 1
826 w -= 1;
827 h -= 1;
828 }
0ebd9515 829 m_graphicContext->DrawRoundedRectangle( x,y,w,h,radius);
1b89a5cd
SC
830}
831
888dde65 832void wxGCDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
1b89a5cd 833{
888dde65 834 wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawEllipse - invalid DC") );
1b89a5cd 835
4280b879 836 if ( !m_logicalFunctionSupported )
1b89a5cd
SC
837 return;
838
d9485f89
RD
839 if ( m_graphicContext->ShouldOffset() )
840 {
841 // if we are offsetting the entire rectangle is moved 0.5, so the
842 // border line gets off by 1
843 w -= 1;
844 h -= 1;
845 }
0ebd9515 846 m_graphicContext->DrawEllipse(x,y,w,h);
1b89a5cd
SC
847}
848
888dde65 849bool wxGCDCImpl::CanDrawBitmap() const
1b89a5cd
SC
850{
851 return true;
852}
853
888dde65 854bool wxGCDCImpl::DoBlit(
1b89a5cd 855 wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
03647350 856 wxDC *source, wxCoord xsrc, wxCoord ysrc,
89efaf2b 857 wxRasterOperationMode logical_func , bool useMask,
1b89a5cd
SC
858 wxCoord xsrcMask, wxCoord ysrcMask )
859{
e3b81044
VZ
860 return DoStretchBlit( xdest, ydest, width, height,
861 source, xsrc, ysrc, width, height, logical_func, useMask,
862 xsrcMask,ysrcMask );
863}
864
888dde65 865bool wxGCDCImpl::DoStretchBlit(
e3b81044
VZ
866 wxCoord xdest, wxCoord ydest, wxCoord dstWidth, wxCoord dstHeight,
867 wxDC *source, wxCoord xsrc, wxCoord ysrc, wxCoord srcWidth, wxCoord srcHeight,
89efaf2b 868 wxRasterOperationMode logical_func , bool useMask,
e3b81044
VZ
869 wxCoord xsrcMask, wxCoord ysrcMask )
870{
888dde65
RR
871 wxCHECK_MSG( IsOk(), false, wxT("wxGCDC(cg)::DoStretchBlit - invalid DC") );
872 wxCHECK_MSG( source->IsOk(), false, wxT("wxGCDC(cg)::DoStretchBlit - invalid source DC") );
6c0aace2 873
1b89a5cd
SC
874 if ( logical_func == wxNO_OP )
875 return true;
03647350 876
bf02a7f9
SC
877 wxCompositionMode mode;
878 if ( !TranslateRasterOp(logical_func, &mode) )
c64c9cd3 879 {
bf02a7f9 880 wxFAIL_MSG( wxT("Blitting is not supported with this logical operation.") );
c64c9cd3
KO
881 return false;
882 }
1b89a5cd 883
bf02a7f9 884 bool retval = true;
03647350 885
bf02a7f9
SC
886 wxCompositionMode formerMode = m_graphicContext->GetCompositionMode();
887 if (m_graphicContext->SetCompositionMode(mode))
1b89a5cd 888 {
bf02a7f9
SC
889 wxAntialiasMode formerAa = m_graphicContext->GetAntialiasMode();
890 if (mode == wxCOMPOSITION_XOR)
891 {
892 m_graphicContext->SetAntialiasMode(wxANTIALIAS_NONE);
893 }
03647350 894
bf02a7f9
SC
895 if (xsrcMask == -1 && ysrcMask == -1)
896 {
897 xsrcMask = xsrc;
898 ysrcMask = ysrc;
899 }
1b89a5cd 900
bf02a7f9
SC
901 wxRect subrect(source->LogicalToDeviceX(xsrc),
902 source->LogicalToDeviceY(ysrc),
903 source->LogicalToDeviceXRel(srcWidth),
904 source->LogicalToDeviceYRel(srcHeight));
cce4a2ce 905
bf02a7f9
SC
906 // if needed clip the subrect down to the size of the source DC
907 wxCoord sw, sh;
908 source->GetSize(&sw, &sh);
909 sw = source->LogicalToDeviceXRel(sw);
910 sh = source->LogicalToDeviceYRel(sh);
911 if (subrect.x + subrect.width > sw)
912 subrect.width = sw - subrect.x;
913 if (subrect.y + subrect.height > sh)
914 subrect.height = sh - subrect.y;
6c0aace2 915
bf02a7f9 916 wxBitmap blit = source->GetAsBitmap( &subrect );
6c0aace2 917
bf02a7f9
SC
918 if ( blit.IsOk() )
919 {
920 if ( !useMask && blit.GetMask() )
921 blit.SetMask(NULL);
08de4403 922
bf02a7f9
SC
923 m_graphicContext->DrawBitmap( blit, xdest, ydest,
924 dstWidth, dstHeight);
925 }
926 else
927 {
928 wxFAIL_MSG( wxT("Cannot Blit. Unable to get contents of DC as bitmap.") );
929 retval = false;
930 }
03647350 931
bf02a7f9
SC
932 if (mode == wxCOMPOSITION_XOR)
933 {
934 m_graphicContext->SetAntialiasMode(formerAa);
935 }
1b89a5cd 936 }
bf02a7f9
SC
937 // reset composition
938 m_graphicContext->SetCompositionMode(formerMode);
1b89a5cd 939
bf02a7f9 940 return retval;
1b89a5cd
SC
941}
942
888dde65 943void wxGCDCImpl::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y,
1b89a5cd
SC
944 double angle)
945{
888dde65 946 wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawRotatedText - invalid DC") );
1b89a5cd 947
6636ef8d 948 if ( str.empty() )
1b89a5cd 949 return;
4280b879 950 if ( !m_logicalFunctionSupported )
1b89a5cd
SC
951 return;
952
068eb463
SC
953 if ( m_backgroundMode == wxTRANSPARENT )
954 m_graphicContext->DrawText( str, x ,y , DegToRad(angle ));
955 else
956 m_graphicContext->DrawText( str, x ,y , DegToRad(angle ), m_graphicContext->CreateBrush( wxBrush(m_textBackgroundColour,wxSOLID) ) );
1b89a5cd
SC
957}
958
888dde65 959void wxGCDCImpl::DoDrawText(const wxString& str, wxCoord x, wxCoord y)
1b89a5cd 960{
08de4403 961 wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawText - invalid DC") );
1b89a5cd 962
6636ef8d 963 if ( str.empty() )
1b89a5cd 964 return;
4280b879
SC
965
966 if ( !m_logicalFunctionSupported )
1b89a5cd
SC
967 return;
968
068eb463
SC
969 if ( m_backgroundMode == wxTRANSPARENT )
970 m_graphicContext->DrawText( str, x ,y);
971 else
972 m_graphicContext->DrawText( str, x ,y , m_graphicContext->CreateBrush( wxBrush(m_textBackgroundColour,wxSOLID) ) );
1b89a5cd
SC
973}
974
888dde65 975bool wxGCDCImpl::CanGetTextExtent() const
1b89a5cd 976{
888dde65 977 wxCHECK_MSG( IsOk(), false, wxT("wxGCDC(cg)::CanGetTextExtent - invalid DC") );
1b89a5cd
SC
978
979 return true;
980}
981
888dde65 982void wxGCDCImpl::DoGetTextExtent( const wxString &str, wxCoord *width, wxCoord *height,
1b89a5cd 983 wxCoord *descent, wxCoord *externalLeading ,
c94f845b 984 const wxFont *theFont ) const
1b89a5cd 985{
d9edff06 986 wxCHECK_RET( m_graphicContext, wxT("wxGCDC(cg)::DoGetTextExtent - invalid DC") );
1b89a5cd
SC
987
988 if ( theFont )
989 {
990 m_graphicContext->SetFont( *theFont, m_textForegroundColour );
991 }
992
993 wxDouble h , d , e , w;
994
995 m_graphicContext->GetTextExtent( str, &w, &h, &d, &e );
996
997 if ( height )
fcaea2fa 998 *height = (wxCoord)(h+0.5);
1b89a5cd 999 if ( descent )
fcaea2fa 1000 *descent = (wxCoord)(d+0.5);
1b89a5cd 1001 if ( externalLeading )
fcaea2fa 1002 *externalLeading = (wxCoord)(e+0.5);
1b89a5cd 1003 if ( width )
fcaea2fa 1004 *width = (wxCoord)(w+0.5);
1b89a5cd
SC
1005
1006 if ( theFont )
1007 {
1008 m_graphicContext->SetFont( m_font, m_textForegroundColour );
1009 }
1010}
1011
888dde65 1012bool wxGCDCImpl::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const
1b89a5cd 1013{
d9edff06 1014 wxCHECK_MSG( m_graphicContext, false, wxT("wxGCDC(cg)::DoGetPartialTextExtents - invalid DC") );
1b89a5cd
SC
1015 widths.Clear();
1016 widths.Add(0,text.Length());
1017 if ( text.IsEmpty() )
1018 return true;
1019
1020 wxArrayDouble widthsD;
1021
1022 m_graphicContext->GetPartialTextExtents( text, widthsD );
1023 for ( size_t i = 0; i < widths.GetCount(); ++i )
0ebd9515 1024 widths[i] = (wxCoord)(widthsD[i] + 0.5);
1b89a5cd
SC
1025
1026 return true;
1027}
1028
888dde65 1029wxCoord wxGCDCImpl::GetCharWidth(void) const
1b89a5cd
SC
1030{
1031 wxCoord width;
1032 DoGetTextExtent( wxT("g") , &width , NULL , NULL , NULL , NULL );
1033
1034 return width;
1035}
1036
888dde65 1037wxCoord wxGCDCImpl::GetCharHeight(void) const
1b89a5cd
SC
1038{
1039 wxCoord height;
1040 DoGetTextExtent( wxT("g") , NULL , &height , NULL , NULL , NULL );
1041
1042 return height;
1043}
1044
888dde65 1045void wxGCDCImpl::Clear(void)
1b89a5cd 1046{
888dde65 1047 wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::Clear - invalid DC") );
1b89a5cd
SC
1048 // TODO better implementation / incorporate size info into wxGCDC or context
1049 m_graphicContext->SetBrush( m_backgroundBrush );
1050 wxPen p = *wxTRANSPARENT_PEN;
1051 m_graphicContext->SetPen( p );
954c66fa
SC
1052 wxCompositionMode formerMode = m_graphicContext->GetCompositionMode();
1053 m_graphicContext->SetCompositionMode(wxCOMPOSITION_SOURCE);
1b89a5cd 1054 DoDrawRectangle( 0, 0, 32000 , 32000 );
954c66fa 1055 m_graphicContext->SetCompositionMode(formerMode);
6c0aace2 1056 m_graphicContext->SetPen( m_pen );
1b89a5cd
SC
1057 m_graphicContext->SetBrush( m_brush );
1058}
1059
888dde65 1060void wxGCDCImpl::DoGetSize(int *width, int *height) const
1b89a5cd 1061{
1cc7d13a
SC
1062 wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoGetSize - invalid DC") );
1063 wxDouble w,h;
1064 m_graphicContext->GetSize( &w, &h );
1065 if ( height )
1066 *height = (int) (h+0.5);
1067 if ( width )
1068 *width = (int) (w+0.5);
1b89a5cd
SC
1069}
1070
888dde65 1071void wxGCDCImpl::DoGradientFillLinear(const wxRect& rect,
1b89a5cd
SC
1072 const wxColour& initialColour,
1073 const wxColour& destColour,
1074 wxDirection nDirection )
1075{
1076 wxPoint start;
1077 wxPoint end;
1078 switch( nDirection)
1079 {
1080 case wxWEST :
1081 start = rect.GetRightBottom();
1082 start.x++;
1083 end = rect.GetLeftBottom();
1084 break;
1085 case wxEAST :
1086 start = rect.GetLeftBottom();
1087 end = rect.GetRightBottom();
1088 end.x++;
1089 break;
1090 case wxNORTH :
1091 start = rect.GetLeftBottom();
1092 start.y++;
1093 end = rect.GetLeftTop();
1094 break;
1095 case wxSOUTH :
1096 start = rect.GetLeftTop();
1097 end = rect.GetLeftBottom();
1098 end.y++;
1099 break;
1100 default :
1101 break;
1102 }
1103
0ebd9515 1104 if (rect.width == 0 || rect.height == 0)
1b89a5cd
SC
1105 return;
1106
0ebd9515
SC
1107 m_graphicContext->SetBrush( m_graphicContext->CreateLinearGradientBrush(
1108 start.x,start.y,end.x,end.y, initialColour, destColour));
1b89a5cd 1109 m_graphicContext->SetPen(*wxTRANSPARENT_PEN);
0ebd9515 1110 m_graphicContext->DrawRectangle(rect.x,rect.y,rect.width,rect.height);
1b89a5cd
SC
1111 m_graphicContext->SetPen(m_pen);
1112}
1113
888dde65 1114void wxGCDCImpl::DoGradientFillConcentric(const wxRect& rect,
1b89a5cd
SC
1115 const wxColour& initialColour,
1116 const wxColour& destColour,
1117 const wxPoint& circleCenter)
1118{
1119 //Radius
1120 wxInt32 cx = rect.GetWidth() / 2;
1121 wxInt32 cy = rect.GetHeight() / 2;
1122 wxInt32 nRadius;
1123 if (cx < cy)
1124 nRadius = cx;
1125 else
1126 nRadius = cy;
1127
0ebd9515 1128 // make sure the background is filled (todo move into specific platform implementation ?)
1b89a5cd
SC
1129 m_graphicContext->SetPen(*wxTRANSPARENT_PEN);
1130 m_graphicContext->SetBrush( wxBrush( destColour) );
0ebd9515 1131 m_graphicContext->DrawRectangle(rect.x,rect.y,rect.width,rect.height);
1b89a5cd
SC
1132
1133 m_graphicContext->SetBrush( m_graphicContext->CreateRadialGradientBrush(
0ebd9515
SC
1134 rect.x+circleCenter.x,rect.y+circleCenter.y,
1135 rect.x+circleCenter.x,rect.y+circleCenter.y,
1136 nRadius,initialColour,destColour));
1b89a5cd 1137
0ebd9515 1138 m_graphicContext->DrawRectangle(rect.x,rect.y,rect.width,rect.height);
1b89a5cd
SC
1139 m_graphicContext->SetPen(m_pen);
1140}
1141
888dde65 1142void wxGCDCImpl::DoDrawCheckMark(wxCoord x, wxCoord y,
1b89a5cd
SC
1143 wxCoord width, wxCoord height)
1144{
888dde65 1145 wxDCImpl::DoDrawCheckMark(x,y,width,height);
1b89a5cd
SC
1146}
1147
1148#endif // wxUSE_GRAPHICS_CONTEXT