]> git.saurik.com Git - wxWidgets.git/blob - src/common/graphcmn.cpp
fixes for non precompiled headers
[wxWidgets.git] / src / common / graphcmn.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/graphcmn.cpp
3 // Purpose: graphics context methods common to all platforms
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created:
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ---------------------------------------------------------------------------
17 // headers
18 // ---------------------------------------------------------------------------
19
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
22
23 #if defined(__BORLANDC__)
24 #pragma hdrstop
25 #endif
26
27 #include "wx/graphics.h"
28
29 #ifndef WX_PRECOMP
30 #include "wx/icon.h"
31 #include "wx/bitmap.h"
32 #include "wx/dcmemory.h"
33 #endif
34
35 #if wxUSE_GRAPHICS_CONTEXT
36
37 //-----------------------------------------------------------------------------
38 // constants
39 //-----------------------------------------------------------------------------
40
41 const double RAD2DEG = 180.0 / M_PI;
42 const short kEmulatedMode = -1;
43 const short kUnsupportedMode = -2;
44
45 //-----------------------------------------------------------------------------
46 // Local functions
47 //-----------------------------------------------------------------------------
48
49 static inline double dmin(double a, double b)
50 {
51 return a < b ? a : b;
52 }
53 static inline double dmax(double a, double b)
54 {
55 return a > b ? a : b;
56 }
57
58 static inline double DegToRad(double deg)
59 {
60 return (deg * M_PI) / 180.0;
61 }
62 static inline double RadToDeg(double deg)
63 {
64 return (deg * 180.0) / M_PI;
65 }
66
67
68 wxPoint2DDouble wxGraphicsPath::GetCurrentPoint()
69 {
70 wxDouble x,y ;
71 GetCurrentPoint(x,y);
72 return wxPoint2DDouble(x,y);
73 }
74
75 void wxGraphicsPath::MoveToPoint( const wxPoint2DDouble& p)
76 {
77 MoveToPoint( p.m_x , p.m_y);
78 }
79
80 void wxGraphicsPath::AddLineToPoint( const wxPoint2DDouble& p)
81 {
82 AddLineToPoint( p.m_x , p.m_y);
83 }
84
85 void wxGraphicsPath::AddCurveToPoint( const wxPoint2DDouble& c1, const wxPoint2DDouble& c2, const wxPoint2DDouble& e)
86 {
87 AddCurveToPoint(c1.m_x, c1.m_y, c2.m_x, c2.m_y, e.m_x, e.m_y);
88 }
89
90 void wxGraphicsPath::AddArc( const wxPoint2DDouble& c, wxDouble r, wxDouble startAngle, wxDouble endAngle, bool clockwise)
91 {
92 AddArc(c.m_x, c.m_y, r, startAngle, endAngle, clockwise);
93 }
94
95 //
96 // Emulations
97 //
98
99 void wxGraphicsPath::AddQuadCurveToPoint( wxDouble cx, wxDouble cy, wxDouble x, wxDouble y )
100 {
101 // calculate using degree elevation to a cubic bezier
102 wxPoint2DDouble c1 ;
103 wxPoint2DDouble c2 ;
104
105 wxPoint2DDouble start = GetCurrentPoint() ;
106 wxPoint2DDouble end(x,y);
107 wxPoint2DDouble c(cx,cy);
108 c1 = (1/3.0) * start + (2/3.0) * c;
109 c2 = (2/3.0) * c + (1/3.0) * end ;
110 AddCurveToPoint(c1.m_x,c1.m_y,c2.m_x,c2.m_y,x,y);
111 }
112
113 void wxGraphicsPath::AddRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h )
114 {
115 MoveToPoint(x,y);
116 AddLineToPoint(x,y+h);
117 AddLineToPoint(x+w,y+h);
118 AddLineToPoint(x+w,y);
119 CloseSubpath();
120 }
121
122 void wxGraphicsPath::AddCircle( wxDouble x, wxDouble y, wxDouble r )
123 {
124 MoveToPoint(x+r,y);
125 AddArc( x,y,r,0,2*M_PI,false);
126 CloseSubpath();
127 }
128
129 // draws a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1) to (x2,y2), also a straight line from (current) to (x1,y1)
130 void wxGraphicsPath::AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r )
131 {
132 wxPoint2DDouble current = GetCurrentPoint();
133 wxPoint2DDouble p1(x1,y1);
134 wxPoint2DDouble p2(x2,y2);
135
136 wxPoint2DDouble v1 = current - p1 ;
137 v1.Normalize();
138 wxPoint2DDouble v2 = p2 - p1 ;
139 v2.Normalize();
140
141 wxDouble alpha = v1.GetVectorAngle() - v2.GetVectorAngle();
142
143 if ( alpha < 0 )
144 alpha = 360 + alpha ;
145 // TODO obtuse angles
146
147 alpha = DegToRad(alpha);
148
149 wxDouble dist = r / sin(alpha/2) * cos(alpha/2) ;
150 // calculate tangential points
151 wxPoint2DDouble t1 = dist*v1 + p1 ;
152 wxPoint2DDouble t2 = dist*v2 + p1 ;
153
154 wxPoint2DDouble nv1 = v1 ;
155 nv1.SetVectorAngle(v1.GetVectorAngle()-90);
156 wxPoint2DDouble c = t1 + r*nv1;
157
158 wxDouble a1 = v1.GetVectorAngle()+90 ;
159 wxDouble a2 = v2.GetVectorAngle()-90 ;
160
161 AddLineToPoint(t1);
162 AddArc(c.m_x,c.m_y,r,DegToRad(a1),DegToRad(a2),true);
163 AddLineToPoint(p2);
164 }
165
166 //-----------------------------------------------------------------------------
167 // wxGraphicsContext Convenience Methods
168 //-----------------------------------------------------------------------------
169
170 void wxGraphicsContext::DrawPath( const wxGraphicsPath *path, int fillStyle )
171 {
172 FillPath( path , fillStyle );
173 StrokePath( path );
174 }
175
176 void wxGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDouble y, wxDouble angle )
177 {
178 Translate(x,y) ;
179 Rotate( -angle );
180 DrawText( str , 0, 0 );
181 Rotate( angle );
182 Translate(-x,-y) ;
183 }
184
185 void wxGraphicsContext::StrokeLine( wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2)
186 {
187 wxGraphicsPath* path = CreatePath();
188 path->MoveToPoint(x1, y1) ;
189 path->AddLineToPoint( x2, y2 );
190 StrokePath( path );
191 delete path;
192 }
193
194 void wxGraphicsContext::DrawRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h)
195 {
196 wxGraphicsPath* path = CreatePath();
197 path->AddRectangle( x , y , w , h );
198 DrawPath( path );
199 delete path;
200 }
201
202 void wxGraphicsContext::DrawEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h)
203 {
204 wxGraphicsPath* path = CreatePath();
205 if ( w == h )
206 {
207 path->AddCircle( x+w/2,y+w/2,w/2);
208 DrawPath(path);
209 }
210 else
211 {
212 PushState();
213 Translate(x+w/2,y+h/2);
214 wxDouble factor = ((wxDouble) w) / h ;
215 Scale( factor , 1.0) ;
216 path->AddCircle(0,0,h/2);
217 DrawPath(path);
218 PopState();
219 }
220 delete path;
221 }
222
223 void wxGraphicsContext::DrawRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius)
224 {
225 wxGraphicsPath* path = CreatePath();
226 if ( radius == 0)
227 {
228 path->AddRectangle( x , y , w , h );
229 DrawPath( path );
230 }
231 else
232 {
233 PushState();
234 Translate( x , y );
235
236 double fw = w / radius;
237 double fh = h / radius;
238
239 path->MoveToPoint(w, h / 2);
240 path->AddArcToPoint(w, h, w / 2, h, radius);
241 path->AddArcToPoint(0, h, 0, h / 2, radius);
242 path->AddArcToPoint(0, 0, w / 2, 0, radius);
243 path->AddArcToPoint(w, 0, w, h / 2, radius);
244 path->CloseSubpath();
245 DrawPath( path );
246 PopState();
247 }
248 delete path;
249 }
250
251 void wxGraphicsContext::StrokeLines( size_t n, const wxPoint2DDouble *points)
252 {
253 wxASSERT(n > 1);
254 wxGraphicsPath* path = CreatePath();
255 path->MoveToPoint(points[0].m_x, points[0].m_y) ;
256 for ( int i = 1 ; i < n; ++i)
257 path->AddLineToPoint( points[i].m_x, points[i].m_y );
258 StrokePath( path );
259 delete path;
260 }
261
262 void wxGraphicsContext::DrawLines( size_t n, const wxPoint2DDouble *points, int fillStyle)
263 {
264 wxASSERT(n > 1);
265 wxGraphicsPath* path = CreatePath();
266 path->MoveToPoint(points[0].m_x, points[0].m_y) ;
267 for ( int i = 1 ; i < n; ++i)
268 path->AddLineToPoint( points[i].m_x, points[i].m_y );
269 DrawPath( path , fillStyle);
270 delete path;
271 }
272
273 void wxGraphicsContext::StrokeLines( size_t n, const wxPoint2DDouble *beginPoints, const wxPoint2DDouble *endPoints)
274 {
275 wxASSERT(n > 0);
276 wxGraphicsPath* path = CreatePath();
277 for ( int i = 0 ; i < n; ++i)
278 {
279 path->MoveToPoint(beginPoints[i].m_x, beginPoints[i].m_y) ;
280 path->AddLineToPoint( endPoints[i].m_x, endPoints[i].m_y );
281 }
282 StrokePath( path );
283 delete path;
284 }
285
286 IMPLEMENT_ABSTRACT_CLASS(wxGCDC, wxObject)
287
288 //-----------------------------------------------------------------------------
289 // wxDC bridge class
290 //-----------------------------------------------------------------------------
291
292 wxGCDC::wxGCDC()
293 {
294 Init();
295 }
296
297
298 wxGCDC::wxGCDC(const wxWindowDC& dc)
299 {
300 Init();
301 m_graphicContext = wxGraphicsContext::Create(dc);
302 m_ok = true;
303 if ( dc.GetFont().Ok())
304 m_graphicContext->SetFont(dc.GetFont());
305 }
306
307 void wxGCDC::Init()
308 {
309 m_ok = false;
310 m_colour = true;
311 m_mm_to_pix_x = mm2pt;
312 m_mm_to_pix_y = mm2pt;
313
314 m_pen = *wxBLACK_PEN;
315 m_font = *wxNORMAL_FONT;
316 m_brush = *wxWHITE_BRUSH;
317
318 m_graphicContext = NULL;
319 }
320
321
322 wxGCDC::~wxGCDC()
323 {
324 delete m_graphicContext;
325 }
326
327 void wxGCDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask )
328 {
329 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid DC") );
330 wxCHECK_RET( bmp.Ok(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid bitmap") );
331
332 wxCoord xx = LogicalToDeviceX(x);
333 wxCoord yy = LogicalToDeviceY(y);
334 wxCoord w = bmp.GetWidth();
335 wxCoord h = bmp.GetHeight();
336 wxCoord ww = LogicalToDeviceXRel(w);
337 wxCoord hh = LogicalToDeviceYRel(h);
338
339 m_graphicContext->DrawBitmap( bmp, xx , yy , ww , hh );
340 }
341
342 void wxGCDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y )
343 {
344 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawIcon - invalid DC") );
345 wxCHECK_RET( icon.Ok(), wxT("wxGCDC(cg)::DoDrawIcon - invalid icon") );
346
347 wxCoord xx = LogicalToDeviceX(x);
348 wxCoord yy = LogicalToDeviceY(y);
349 wxCoord w = icon.GetWidth();
350 wxCoord h = icon.GetHeight();
351 wxCoord ww = LogicalToDeviceXRel(w);
352 wxCoord hh = LogicalToDeviceYRel(h);
353
354 m_graphicContext->DrawIcon( icon , xx, yy, ww, hh );
355 }
356
357 void wxGCDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
358 {
359 // TODO Clipping
360 #if 0
361 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoSetClippingRegion - invalid DC") );
362
363 wxCoord xx, yy, ww, hh;
364 xx = LogicalToDeviceX(x);
365 yy = LogicalToDeviceY(y);
366 ww = LogicalToDeviceXRel(width);
367 hh = LogicalToDeviceYRel(height);
368
369 CGContextRef cgContext = ((wxCairoContext*)(m_graphicContext))->GetNativeContext();
370 CGRect clipRect = CGRectMake( xx , yy , ww, hh );
371 CGContextClipToRect( cgContext , clipRect );
372
373 // SetRectRgn( (RgnHandle) m_macCurrentClipRgn , xx , yy , xx + ww , yy + hh );
374 // SectRgn( (RgnHandle) m_macCurrentClipRgn , (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn );
375
376 if ( m_clipping )
377 {
378 m_clipX1 = wxMax( m_clipX1, xx );
379 m_clipY1 = wxMax( m_clipY1, yy );
380 m_clipX2 = wxMin( m_clipX2, (xx + ww) );
381 m_clipY2 = wxMin( m_clipY2, (yy + hh) );
382 }
383 else
384 {
385 m_clipping = true;
386
387 m_clipX1 = xx;
388 m_clipY1 = yy;
389 m_clipX2 = xx + ww;
390 m_clipY2 = yy + hh;
391 }
392
393 // TODO: as soon as we don't reset the context for each operation anymore
394 // we have to update the context as well
395 #endif
396
397 }
398
399 void wxGCDC::DoSetClippingRegionAsRegion( const wxRegion &region )
400 {
401 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoSetClippingRegionAsRegion - invalid DC") );
402
403 if (region.Empty())
404 {
405 DestroyClippingRegion();
406 return;
407 }
408
409 wxCoord x, y, w, h;
410 region.GetBox( x, y, w, h );
411 wxCoord xx, yy, ww, hh;
412 xx = LogicalToDeviceX(x);
413 yy = LogicalToDeviceY(y);
414 ww = LogicalToDeviceXRel(w);
415 hh = LogicalToDeviceYRel(h);
416
417 // if we have a scaling that we cannot map onto native regions
418 // we must use the box
419 if ( ww != w || hh != h )
420 {
421 wxGCDC::DoSetClippingRegion( x, y, w, h );
422 }
423 else
424 {
425 #if 0
426 CopyRgn( (RgnHandle) region.GetWXHRGN() , (RgnHandle) m_macCurrentClipRgn );
427 if ( xx != x || yy != y )
428 OffsetRgn( (RgnHandle) m_macCurrentClipRgn , xx - x , yy - y );
429 SectRgn( (RgnHandle)m_macCurrentClipRgn , (RgnHandle)m_macBoundaryClipRgn , (RgnHandle)m_macCurrentClipRgn );
430 #endif
431
432 if ( m_clipping )
433 {
434 m_clipX1 = wxMax( m_clipX1, xx );
435 m_clipY1 = wxMax( m_clipY1, yy );
436 m_clipX2 = wxMin( m_clipX2, (xx + ww) );
437 m_clipY2 = wxMin( m_clipY2, (yy + hh) );
438 }
439 else
440 {
441 m_clipping = true;
442
443 m_clipX1 = xx;
444 m_clipY1 = yy;
445 m_clipX2 = xx + ww;
446 m_clipY2 = yy + hh;
447 }
448 }
449 }
450
451 void wxGCDC::DestroyClippingRegion()
452 {
453 // TODO Clipping
454 #if 0
455 // CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn );
456
457 CGContextRef cgContext = ((wxCairoContext*)(m_graphicContext))->GetNativeContext();
458 CGContextRestoreGState( cgContext );
459 CGContextSaveGState( cgContext );
460
461 m_graphicContext->SetPen( m_pen );
462 m_graphicContext->SetBrush( m_brush );
463
464 m_clipping = false;
465 #endif
466
467 }
468
469 void wxGCDC::DoGetSizeMM( int* width, int* height ) const
470 {
471 int w = 0, h = 0;
472
473 GetSize( &w, &h );
474 if (width)
475 *width = long( double(w) / (m_scaleX * m_mm_to_pix_x) );
476 if (height)
477 *height = long( double(h) / (m_scaleY * m_mm_to_pix_y) );
478 }
479
480 void wxGCDC::SetTextForeground( const wxColour &col )
481 {
482 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::SetTextForeground - invalid DC") );
483
484 if ( col != m_textForegroundColour )
485 {
486 m_textForegroundColour = col;
487 m_graphicContext->SetTextColor( col );
488 }
489 }
490
491 void wxGCDC::SetTextBackground( const wxColour &col )
492 {
493 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::SetTextBackground - invalid DC") );
494
495 m_textBackgroundColour = col;
496 }
497
498 void wxGCDC::SetMapMode( int mode )
499 {
500 switch (mode)
501 {
502 case wxMM_TWIPS:
503 SetLogicalScale( twips2mm * m_mm_to_pix_x, twips2mm * m_mm_to_pix_y );
504 break;
505
506 case wxMM_POINTS:
507 SetLogicalScale( pt2mm * m_mm_to_pix_x, pt2mm * m_mm_to_pix_y );
508 break;
509
510 case wxMM_METRIC:
511 SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y );
512 break;
513
514 case wxMM_LOMETRIC:
515 SetLogicalScale( m_mm_to_pix_x / 10.0, m_mm_to_pix_y / 10.0 );
516 break;
517
518 case wxMM_TEXT:
519 default:
520 SetLogicalScale( 1.0, 1.0 );
521 break;
522 }
523
524 ComputeScaleAndOrigin();
525 }
526
527 void wxGCDC::SetUserScale( double x, double y )
528 {
529 // allow negative ? -> no
530 m_userScaleX = x;
531 m_userScaleY = y;
532 ComputeScaleAndOrigin();
533 }
534
535 void wxGCDC::SetLogicalScale( double x, double y )
536 {
537 // allow negative ?
538 m_logicalScaleX = x;
539 m_logicalScaleY = y;
540 ComputeScaleAndOrigin();
541 }
542
543 void wxGCDC::SetLogicalOrigin( wxCoord x, wxCoord y )
544 {
545 m_logicalOriginX = x * m_signX; // is this still correct ?
546 m_logicalOriginY = y * m_signY;
547 ComputeScaleAndOrigin();
548 }
549
550 void wxGCDC::SetDeviceOrigin( wxCoord x, wxCoord y )
551 {
552 m_deviceOriginX = x;
553 m_deviceOriginY = y;
554 ComputeScaleAndOrigin();
555 }
556
557 void wxGCDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
558 {
559 m_signX = (xLeftRight ? 1 : -1);
560 m_signY = (yBottomUp ? -1 : 1);
561 ComputeScaleAndOrigin();
562 }
563
564 wxSize wxGCDC::GetPPI() const
565 {
566 return wxSize(72, 72);
567 }
568
569 int wxGCDC::GetDepth() const
570 {
571 return 32;
572 }
573
574 void wxGCDC::ComputeScaleAndOrigin()
575 {
576 // this is a bit artificial, but we need to force wxGCDC to think
577 // the pen has changed
578 wxPen pen( GetPen() );
579
580 m_pen = wxNullPen;
581 SetPen( pen );
582 }
583
584 void wxGCDC::SetPalette( const wxPalette& palette )
585 {}
586
587 void wxGCDC::SetBackgroundMode( int mode )
588 {
589 m_backgroundMode = mode;
590 }
591
592 void wxGCDC::SetFont( const wxFont &font )
593 {
594 m_font = font;
595 if ( m_graphicContext )
596 m_graphicContext->SetFont( font );
597 }
598
599 void wxGCDC::SetPen( const wxPen &pen )
600 {
601 if ( m_pen == pen )
602 return;
603
604 m_pen = pen;
605 if ( m_graphicContext )
606 {
607 if ( m_pen.GetStyle() == wxSOLID || m_pen.GetStyle() == wxTRANSPARENT )
608 {
609 m_graphicContext->SetPen( m_pen );
610 }
611 else
612 {
613 // we have to compensate for moved device origins etc. otherwise patterned pens are standing still
614 // eg when using a wxScrollWindow and scrolling around
615 int origX = LogicalToDeviceX( 0 );
616 int origY = LogicalToDeviceY( 0 );
617 m_graphicContext->Translate( origX , origY );
618 m_graphicContext->SetPen( m_pen );
619 m_graphicContext->Translate( -origX , -origY );
620 }
621 }
622 }
623
624 void wxGCDC::SetBrush( const wxBrush &brush )
625 {
626 if (m_brush == brush)
627 return;
628
629 m_brush = brush;
630 if ( m_graphicContext )
631 {
632 if ( brush.GetStyle() == wxSOLID || brush.GetStyle() == wxTRANSPARENT )
633 {
634 m_graphicContext->SetBrush( m_brush );
635 }
636 else
637 {
638 // we have to compensate for moved device origins etc. otherwise patterned brushes are standing still
639 // eg when using a wxScrollWindow and scrolling around
640 // TODO on MSW / GDIPlus this still occurs with hatched brushes
641 int origX = LogicalToDeviceX(0);
642 int origY = LogicalToDeviceY(0);
643 m_graphicContext->Translate( origX , origY );
644 m_graphicContext->SetBrush( m_brush );
645 m_graphicContext->Translate( -origX , -origY );
646 }
647 }
648 }
649
650 void wxGCDC::SetBackground( const wxBrush &brush )
651 {
652 if (m_backgroundBrush == brush)
653 return;
654
655 m_backgroundBrush = brush;
656 if (!m_backgroundBrush.Ok())
657 return;
658 }
659
660 void wxGCDC::SetLogicalFunction( int function )
661 {
662 if (m_logicalFunction == function)
663 return;
664
665 m_logicalFunction = function;
666 #if wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
667
668 CGContextRef cgContext = ((wxCairoContext*)(m_graphicContext))->GetNativeContext();
669 if ( m_logicalFunction == wxCOPY )
670 CGContextSetBlendMode( cgContext, kCGBlendModeNormal );
671 else if ( m_logicalFunction == wxINVERT )
672 CGContextSetBlendMode( cgContext, kCGBlendModeExclusion );
673 else
674 CGContextSetBlendMode( cgContext, kCGBlendModeNormal );
675 #endif
676
677 }
678
679 extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y,
680 const wxColour & col, int style);
681
682 bool wxGCDC::DoFloodFill(wxCoord x, wxCoord y,
683 const wxColour& col, int style)
684 {
685 // return wxDoFloodFill(this, x, y, col, style);
686 return false;
687 }
688
689 bool wxGCDC::DoGetPixel( wxCoord x, wxCoord y, wxColour *col ) const
690 {
691 // wxCHECK_MSG( 0 , false, wxT("wxGCDC(cg)::DoGetPixel - not implemented") );
692 return false;
693 }
694
695 void wxGCDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
696 {
697 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawLine - invalid DC") );
698
699 #if !wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
700
701 if ( m_logicalFunction != wxCOPY )
702 return;
703 #endif
704
705 wxCoord xx1 = LogicalToDeviceX(x1);
706 wxCoord yy1 = LogicalToDeviceY(y1);
707 wxCoord xx2 = LogicalToDeviceX(x2);
708 wxCoord yy2 = LogicalToDeviceY(y2);
709
710 m_graphicContext->StrokeLine(xx1,yy1,xx2,yy2);
711
712 CalcBoundingBox(x1, y1);
713 CalcBoundingBox(x2, y2);
714 }
715
716 void wxGCDC::DoCrossHair( wxCoord x, wxCoord y )
717 {
718 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoCrossHair - invalid DC") );
719
720 if ( m_logicalFunction != wxCOPY )
721 return;
722
723 int w = 0, h = 0;
724
725 GetSize( &w, &h );
726
727 wxCoord xx = LogicalToDeviceX(x);
728 wxCoord yy = LogicalToDeviceY(y);
729 wxCoord xw = LogicalToDeviceX(w);
730 wxCoord x0 = LogicalToDeviceX(0);
731 wxCoord y0 = LogicalToDeviceY(0);
732 wxCoord yh = LogicalToDeviceY(h);
733
734 m_graphicContext->StrokeLine(x0,yy,xw,yy);
735 m_graphicContext->StrokeLine(xx,y0,xx,yh);
736
737 CalcBoundingBox(x0, y0);
738 CalcBoundingBox(x0+xw, y0+yh);
739 }
740
741 void wxGCDC::DoDrawArc( wxCoord x1, wxCoord y1,
742 wxCoord x2, wxCoord y2,
743 wxCoord xc, wxCoord yc )
744 {
745 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawArc - invalid DC") );
746
747 if ( m_logicalFunction != wxCOPY )
748 return;
749
750 wxCoord xx1 = LogicalToDeviceX(x1);
751 wxCoord yy1 = LogicalToDeviceY(y1);
752 wxCoord xx2 = LogicalToDeviceX(x2);
753 wxCoord yy2 = LogicalToDeviceY(y2);
754 wxCoord xxc = LogicalToDeviceX(xc);
755 wxCoord yyc = LogicalToDeviceY(yc);
756
757 double dx = xx1 - xxc;
758 double dy = yy1 - yyc;
759 double radius = sqrt((double)(dx * dx + dy * dy));
760 wxCoord rad = (wxCoord)radius;
761 double sa, ea;
762 if (xx1 == xx2 && yy1 == yy2)
763 {
764 sa = 0.0;
765 ea = 360.0;
766 }
767 else if (radius == 0.0)
768 {
769 sa = ea = 0.0;
770 }
771 else
772 {
773 sa = (xx1 - xxc == 0) ?
774 (yy1 - yyc < 0) ? 90.0 : -90.0 :
775 -atan2(double(yy1 - yyc), double(xx1 - xxc)) * RAD2DEG;
776 ea = (xx2 - xxc == 0) ?
777 (yy2 - yyc < 0) ? 90.0 : -90.0 :
778 -atan2(double(yy2 - yyc), double(xx2 - xxc)) * RAD2DEG;
779 }
780
781 bool fill = m_brush.GetStyle() != wxTRANSPARENT;
782
783 wxGraphicsPath* path = m_graphicContext->CreatePath();
784 if ( fill && ((x1!=x2)||(y1!=y2)) )
785 path->MoveToPoint( xxc, yyc );
786 path->AddArc( xxc, yyc , rad , DegToRad(sa) , DegToRad(ea), false );
787 if ( fill && ((x1!=x2)||(y1!=y2)) )
788 path->AddLineToPoint( xxc, yyc );
789 m_graphicContext->DrawPath(path);
790 delete path;
791 }
792
793 void wxGCDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h,
794 double sa, double ea )
795 {
796 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawEllipticArc - invalid DC") );
797
798 if ( m_logicalFunction != wxCOPY )
799 return;
800
801 wxCoord xx = LogicalToDeviceX(x);
802 wxCoord yy = LogicalToDeviceY(y);
803 wxCoord ww = m_signX * LogicalToDeviceXRel(w);
804 wxCoord hh = m_signY * LogicalToDeviceYRel(h);
805
806 // handle -ve width and/or height
807 if (ww < 0)
808 {
809 ww = -ww;
810 xx = xx - ww;
811 }
812 if (hh < 0)
813 {
814 hh = -hh;
815 yy = yy - hh;
816 }
817
818 bool fill = m_brush.GetStyle() != wxTRANSPARENT;
819
820 wxGraphicsPath* path = m_graphicContext->CreatePath();
821 m_graphicContext->PushState();
822 m_graphicContext->Translate(xx+ww/2,yy+hh/2);
823 wxDouble factor = ((wxDouble) ww) / hh ;
824 m_graphicContext->Scale( factor , 1.0) ;
825 if ( fill && (sa!=ea) )
826 path->MoveToPoint(0,0);
827 // since these angles (ea,sa) are measured counter-clockwise, we invert them to
828 // get clockwise angles
829 path->AddArc( 0, 0, hh/2 , DegToRad(-sa) , DegToRad(-ea), sa > ea );
830 if ( fill && (sa!=ea) )
831 path->AddLineToPoint(0,0);
832 m_graphicContext->DrawPath( path );
833 m_graphicContext->PopState();
834 delete path;
835 }
836
837 void wxGCDC::DoDrawPoint( wxCoord x, wxCoord y )
838 {
839 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawPoint - invalid DC") );
840
841 DoDrawLine( x , y , x + 1 , y + 1 );
842 }
843
844 void wxGCDC::DoDrawLines(int n, wxPoint points[],
845 wxCoord xoffset, wxCoord yoffset)
846 {
847 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawLines - invalid DC") );
848
849 #if !wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
850
851 if ( m_logicalFunction != wxCOPY )
852 return;
853 #endif
854
855 wxPoint2DDouble* pointsD = new wxPoint2DDouble[n] ;
856 for( int i = 0 ; i < n; ++i)
857 {
858 pointsD[i].m_x = LogicalToDeviceX(points[i].x + xoffset);
859 pointsD[i].m_y = LogicalToDeviceY(points[i].y + yoffset);
860 }
861
862 m_graphicContext->StrokeLines( n , pointsD) ;
863 delete[] pointsD;
864 }
865
866 #if wxUSE_SPLINES
867 void wxGCDC::DoDrawSpline(wxList *points)
868 {
869 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawSpline - invalid DC") );
870
871 if ( m_logicalFunction != wxCOPY )
872 return;
873
874 wxGraphicsPath* path = m_graphicContext->CreatePath();
875
876 wxList::compatibility_iterator node = points->GetFirst();
877 if (node == wxList::compatibility_iterator())
878 // empty list
879 return;
880
881 wxPoint *p = (wxPoint *)node->GetData();
882
883 wxCoord x1 = p->x;
884 wxCoord y1 = p->y;
885
886 node = node->GetNext();
887 p = (wxPoint *)node->GetData();
888
889 wxCoord x2 = p->x;
890 wxCoord y2 = p->y;
891 wxCoord cx1 = ( x1 + x2 ) / 2;
892 wxCoord cy1 = ( y1 + y2 ) / 2;
893
894 path->MoveToPoint( LogicalToDeviceX( x1 ) , LogicalToDeviceY( y1 ) );
895 path->AddLineToPoint( LogicalToDeviceX( cx1 ) , LogicalToDeviceY( cy1 ) );
896 #if !wxUSE_STL
897
898 while ((node = node->GetNext()) != NULL)
899 #else
900
901 while ((node = node->GetNext()))
902 #endif // !wxUSE_STL
903
904 {
905 p = (wxPoint *)node->GetData();
906 x1 = x2;
907 y1 = y2;
908 x2 = p->x;
909 y2 = p->y;
910 wxCoord cx4 = (x1 + x2) / 2;
911 wxCoord cy4 = (y1 + y2) / 2;
912
913 path->AddQuadCurveToPoint(
914 LogicalToDeviceX( x1 ) , LogicalToDeviceY( y1 ) ,
915 LogicalToDeviceX( cx4 ) , LogicalToDeviceY( cy4 ) );
916
917 cx1 = cx4;
918 cy1 = cy4;
919 }
920
921 path->AddLineToPoint( LogicalToDeviceX( x2 ) , LogicalToDeviceY( y2 ) );
922
923 m_graphicContext->StrokePath( path );
924 delete path;
925 }
926 #endif
927
928 void wxGCDC::DoDrawPolygon( int n, wxPoint points[],
929 wxCoord xoffset, wxCoord yoffset,
930 int fillStyle )
931 {
932 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawPolygon - invalid DC") );
933
934 if ( n <= 0 || (m_brush.GetStyle() == wxTRANSPARENT && m_pen.GetStyle() == wxTRANSPARENT ) )
935 return;
936 if ( m_logicalFunction != wxCOPY )
937 return;
938
939 bool closeIt = false ;
940 if (points[n-1] != points[0])
941 closeIt = true ;
942
943 wxPoint2DDouble* pointsD = new wxPoint2DDouble[n+(closeIt?1:0)] ;
944 for( int i = 0 ; i < n; ++i)
945 {
946 pointsD[i].m_x = LogicalToDeviceX(points[i].x + xoffset);
947 pointsD[i].m_y = LogicalToDeviceY(points[i].y + yoffset);
948 }
949 if ( closeIt )
950 pointsD[n] = pointsD[0];
951
952 m_graphicContext->DrawLines( n+(closeIt?1:0) , pointsD, fillStyle) ;
953 delete[] pointsD;
954 }
955
956 void wxGCDC::DoDrawPolyPolygon(int n,
957 int count[],
958 wxPoint points[],
959 wxCoord xoffset,
960 wxCoord yoffset,
961 int fillStyle)
962 {
963 wxASSERT(n > 1);
964 wxGraphicsPath* path = m_graphicContext->CreatePath();
965
966 int i = 0 ;
967 for ( int j = 0 ; j < n ; ++j)
968 {
969 wxPoint start = points[i];
970 path->MoveToPoint(LogicalToDeviceX(start.x+ xoffset), LogicalToDeviceY(start.y+ yoffset)) ;
971 ++i;
972 int l = count[j];
973 for ( int k = 1 ; k < l ; ++k)
974 {
975 path->AddLineToPoint( LogicalToDeviceX(points[i].x+ xoffset), LogicalToDeviceY(points[i].y+ yoffset));
976 ++i ;
977 }
978 // close the polygon
979 if ( start != points[i-1])
980 path->AddLineToPoint( LogicalToDeviceX(start.x+ xoffset), LogicalToDeviceY(start.y+ yoffset));
981 }
982 m_graphicContext->DrawPath( path , fillStyle);
983 delete path;
984 }
985
986 void wxGCDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
987 {
988 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRectangle - invalid DC") );
989
990 if ( m_logicalFunction != wxCOPY )
991 return;
992
993 wxCoord xx = LogicalToDeviceX(x);
994 wxCoord yy = LogicalToDeviceY(y);
995 wxCoord ww = m_signX * LogicalToDeviceXRel(width);
996 wxCoord hh = m_signY * LogicalToDeviceYRel(height);
997
998 // CMB: draw nothing if transformed w or h is 0
999 if (ww == 0 || hh == 0)
1000 return;
1001
1002 // CMB: handle -ve width and/or height
1003 if (ww < 0)
1004 {
1005 ww = -ww;
1006 xx = xx - ww;
1007 }
1008 if (hh < 0)
1009 {
1010 hh = -hh;
1011 yy = yy - hh;
1012 }
1013 m_graphicContext->DrawRectangle( xx,yy,ww,hh);
1014 }
1015
1016 void wxGCDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y,
1017 wxCoord width, wxCoord height,
1018 double radius)
1019 {
1020 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRoundedRectangle - invalid DC") );
1021
1022 if ( m_logicalFunction != wxCOPY )
1023 return;
1024
1025 if (radius < 0.0)
1026 radius = - radius * ((width < height) ? width : height);
1027 wxCoord xx = LogicalToDeviceX(x);
1028 wxCoord yy = LogicalToDeviceY(y);
1029 wxCoord ww = m_signX * LogicalToDeviceXRel(width);
1030 wxCoord hh = m_signY * LogicalToDeviceYRel(height);
1031
1032 // CMB: draw nothing if transformed w or h is 0
1033 if (ww == 0 || hh == 0)
1034 return;
1035
1036 // CMB: handle -ve width and/or height
1037 if (ww < 0)
1038 {
1039 ww = -ww;
1040 xx = xx - ww;
1041 }
1042 if (hh < 0)
1043 {
1044 hh = -hh;
1045 yy = yy - hh;
1046 }
1047
1048 m_graphicContext->DrawRoundedRectangle( xx,yy,ww,hh,radius);
1049 }
1050
1051 void wxGCDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
1052 {
1053 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawEllipse - invalid DC") );
1054
1055 if ( m_logicalFunction != wxCOPY )
1056 return;
1057
1058 wxCoord xx = LogicalToDeviceX(x);
1059 wxCoord yy = LogicalToDeviceY(y);
1060 wxDouble ww = m_signX * LogicalToDeviceXRel(width);
1061 wxCoord hh = m_signY * LogicalToDeviceYRel(height);
1062
1063 // CMB: draw nothing if transformed w or h is 0
1064 if (ww == 0 || hh == 0)
1065 return;
1066
1067 // CMB: handle -ve width and/or height
1068 if (ww < 0)
1069 {
1070 ww = -ww;
1071 xx = xx - ww;
1072 }
1073 if (hh < 0)
1074 {
1075 hh = -hh;
1076 yy = yy - hh;
1077 }
1078
1079 m_graphicContext->DrawEllipse(xx,yy,ww,hh);
1080 }
1081
1082 bool wxGCDC::CanDrawBitmap() const
1083 {
1084 return true;
1085 }
1086
1087 bool wxGCDC::DoBlit(
1088 wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
1089 wxDC *source, wxCoord xsrc, wxCoord ysrc, int logical_func , bool useMask,
1090 wxCoord xsrcMask, wxCoord ysrcMask )
1091 {
1092 wxCHECK_MSG( Ok(), false, wxT("wxGCDC(cg)::DoBlit - invalid DC") );
1093 wxCHECK_MSG( source->Ok(), false, wxT("wxGCDC(cg)::DoBlit - invalid source DC") );
1094
1095 if ( logical_func == wxNO_OP )
1096 return true;
1097
1098 if (xsrcMask == -1 && ysrcMask == -1)
1099 {
1100 xsrcMask = xsrc;
1101 ysrcMask = ysrc;
1102 }
1103
1104 wxCoord yysrc = source-> LogicalToDeviceY(ysrc);
1105 wxCoord xxsrc = source-> LogicalToDeviceX(xsrc);
1106 wxCoord wwsrc = source-> LogicalToDeviceXRel(width);
1107 wxCoord hhsrc = source-> LogicalToDeviceYRel(height);
1108
1109 wxCoord yydest = LogicalToDeviceY(ydest);
1110 wxCoord xxdest = LogicalToDeviceX(xdest);
1111 wxCoord wwdest = LogicalToDeviceXRel(width);
1112 wxCoord hhdest = LogicalToDeviceYRel(height);
1113
1114 wxMemoryDC* memdc = dynamic_cast<wxMemoryDC*>(source);
1115 if ( memdc && logical_func == wxCOPY )
1116 {
1117 #if 0
1118 wxBitmap blit = memdc->GetSelectedObject();
1119
1120 wxASSERT_MSG( blit.Ok() , wxT("Invalid bitmap for blitting") );
1121
1122 wxCoord bmpwidth = blit.GetWidth();
1123 wxCoord bmpheight = blit.GetHeight();
1124
1125 if ( xxsrc != 0 || yysrc != 0 || bmpwidth != wwsrc || bmpheight != hhsrc )
1126 {
1127 wwsrc = wxMin( wwsrc , bmpwidth - xxsrc );
1128 hhsrc = wxMin( hhsrc , bmpheight - yysrc );
1129 if ( wwsrc > 0 && hhsrc > 0 )
1130 {
1131 if ( xxsrc >= 0 && yysrc >= 0 )
1132 {
1133 wxRect subrect( xxsrc, yysrc, wwsrc , hhsrc );
1134 // TODO we perhaps could add a DrawSubBitmap call to dc for performance reasons
1135 blit = blit.GetSubBitmap( subrect );
1136 }
1137 else
1138 {
1139 // in this case we'd probably have to adjust the different coordinates, but
1140 // we have to find out proper contract first
1141 blit = wxNullBitmap;
1142 }
1143 }
1144 else
1145 {
1146 blit = wxNullBitmap;
1147 }
1148 }
1149
1150 if ( blit.Ok() )
1151 {
1152 m_graphicContext->DrawBitmap( blit, xxdest , yydest , wwdest , hhdest );
1153 }
1154 #endif
1155
1156 }
1157 else
1158 {
1159 wxFAIL_MSG( wxT("Blitting is only supported from bitmap contexts") );
1160 return false;
1161 }
1162
1163 return true;
1164 }
1165
1166 void wxGCDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y,
1167 double angle)
1168 {
1169 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRotatedText - invalid DC") );
1170
1171 if ( str.length() == 0 )
1172 return;
1173 if ( m_logicalFunction != wxCOPY )
1174 return;
1175
1176 int drawX = LogicalToDeviceX(x);
1177 int drawY = LogicalToDeviceY(y);
1178
1179 m_graphicContext->DrawText( str, drawX ,drawY , DegToRad(angle ));
1180 }
1181
1182 void wxGCDC::DoDrawText(const wxString& str, wxCoord x, wxCoord y)
1183 {
1184 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRotatedText - invalid DC") );
1185
1186 if ( str.length() == 0 )
1187 return;
1188 if ( m_logicalFunction != wxCOPY )
1189 return;
1190
1191 int drawX = LogicalToDeviceX(x);
1192 int drawY = LogicalToDeviceY(y);
1193
1194 m_graphicContext->DrawText( str, drawX ,drawY);
1195 }
1196
1197 bool wxGCDC::CanGetTextExtent() const
1198 {
1199 wxCHECK_MSG( Ok(), false, wxT("wxGCDC(cg)::CanGetTextExtent - invalid DC") );
1200
1201 return true;
1202 }
1203
1204 void wxGCDC::DoGetTextExtent( const wxString &str, wxCoord *width, wxCoord *height,
1205 wxCoord *descent, wxCoord *externalLeading ,
1206 wxFont *theFont ) const
1207 {
1208 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoGetTextExtent - invalid DC") );
1209
1210 wxFont formerFont = m_font;
1211 if ( theFont )
1212 {
1213 m_graphicContext->SetFont( *theFont );
1214 }
1215
1216 wxDouble h , d , e , w;
1217
1218 m_graphicContext->GetTextExtent( str, &w, &h, &d, &e );
1219
1220 if ( height )
1221 *height = DeviceToLogicalYRel( h );
1222 if ( descent )
1223 *descent =DeviceToLogicalYRel( d);
1224 if ( externalLeading )
1225 *externalLeading = DeviceToLogicalYRel( e);
1226 if ( width )
1227 *width = DeviceToLogicalXRel( w );
1228
1229 if ( theFont )
1230 {
1231 m_graphicContext->SetFont( m_font );
1232 }
1233 }
1234
1235 bool wxGCDC::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const
1236 {
1237 wxCHECK_MSG( Ok(), false, wxT("wxGCDC(cg)::DoGetPartialTextExtents - invalid DC") );
1238 widths.Clear();
1239 widths.Add(0,text.Length());
1240 if ( text.IsEmpty() )
1241 return true ;
1242
1243 wxArrayDouble widthsD ;
1244
1245 m_graphicContext->GetPartialTextExtents( text, widthsD );
1246 for ( size_t i = 0; i < widths.GetCount(); ++i )
1247 widths[i] = DeviceToLogicalXRel( widthsD[i] + 0.5 ) ;
1248
1249 return true;
1250 }
1251
1252 wxCoord wxGCDC::GetCharWidth(void) const
1253 {
1254 wxCoord width;
1255 DoGetTextExtent( wxT("g") , &width , NULL , NULL , NULL , NULL );
1256
1257 return width;
1258 }
1259
1260 wxCoord wxGCDC::GetCharHeight(void) const
1261 {
1262 wxCoord height;
1263 DoGetTextExtent( wxT("g") , NULL , &height , NULL , NULL , NULL );
1264
1265 return height;
1266 }
1267
1268 void wxGCDC::Clear(void)
1269 {
1270 wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::Clear - invalid DC") );
1271 // TODO
1272 }
1273
1274 void wxGCDC::DoGetSize(int *width, int *height) const
1275 {
1276 *width = 1000;
1277 *height = 1000;
1278 }
1279
1280 void wxGCDC::DoGradientFillLinear(const wxRect& rect,
1281 const wxColour& initialColour,
1282 const wxColour& destColour,
1283 wxDirection nDirection )
1284 {
1285 wxPoint start ;
1286 wxPoint end ;
1287 switch( nDirection)
1288 {
1289 case wxWEST :
1290 start = rect.GetRightBottom();
1291 start.x++;
1292 end = rect.GetLeftBottom();
1293 break ;
1294 case wxEAST :
1295 start = rect.GetLeftBottom();
1296 end = rect.GetRightBottom();
1297 end.x++;
1298 break ;
1299 case wxNORTH :
1300 start = rect.GetLeftBottom();
1301 start.y++;
1302 end = rect.GetLeftTop();
1303 break ;
1304 case wxSOUTH :
1305 start = rect.GetLeftTop();
1306 end = rect.GetLeftBottom();
1307 end.y++;
1308 break ;
1309 }
1310
1311 m_graphicContext->SetLinearGradientBrush(
1312 LogicalToDeviceX(start.x),LogicalToDeviceY(start.y),
1313 LogicalToDeviceX(end.x),LogicalToDeviceY(end.y), initialColour, destColour);
1314
1315 wxCoord xx = LogicalToDeviceX(rect.x);
1316 wxCoord yy = LogicalToDeviceY(rect.y);
1317 wxDouble ww = m_signX * LogicalToDeviceXRel(rect.width);
1318 wxCoord hh = m_signY * LogicalToDeviceYRel(rect.height);
1319
1320 if (ww == 0 || hh == 0)
1321 return;
1322
1323 if (ww < 0)
1324 {
1325 ww = -ww;
1326 xx = xx - ww;
1327 }
1328 if (hh < 0)
1329 {
1330 hh = -hh;
1331 yy = yy - hh;
1332 }
1333
1334 m_graphicContext->SetPen(*wxTRANSPARENT_PEN);
1335 m_graphicContext->DrawRectangle(xx,yy,ww,hh);
1336 m_graphicContext->SetPen(m_pen);
1337 }
1338
1339 void wxGCDC::DoGradientFillConcentric(const wxRect& rect,
1340 const wxColour& initialColour,
1341 const wxColour& destColour,
1342 const wxPoint& circleCenter)
1343 {
1344 //Radius
1345 wxInt32 cx = rect.GetWidth() / 2;
1346 wxInt32 cy = rect.GetHeight() / 2;
1347 wxInt32 nRadius;
1348 if (cx < cy)
1349 nRadius = cx;
1350 else
1351 nRadius = cy;
1352
1353 wxCoord xx = LogicalToDeviceX(rect.x);
1354 wxCoord yy = LogicalToDeviceY(rect.y);
1355 wxDouble ww = m_signX * LogicalToDeviceXRel(rect.width);
1356 wxCoord hh = m_signY * LogicalToDeviceYRel(rect.height);
1357
1358 if (ww == 0 || hh == 0)
1359 return;
1360
1361 if (ww < 0)
1362 {
1363 ww = -ww;
1364 xx = xx - ww;
1365 }
1366 if (hh < 0)
1367 {
1368 hh = -hh;
1369 yy = yy - hh;
1370 }
1371
1372 m_graphicContext->SetPen(*wxTRANSPARENT_PEN);
1373 m_graphicContext->SetBrush( wxBrush( destColour) ) ;
1374 m_graphicContext->DrawRectangle( xx,yy,ww,hh);
1375
1376 m_graphicContext->SetRadialGradientBrush(
1377 xx+LogicalToDeviceX(circleCenter.x),yy+LogicalToDeviceY(circleCenter.y),
1378 xx+LogicalToDeviceX(circleCenter.x),yy+LogicalToDeviceY(circleCenter.y),
1379 LogicalToDeviceXRel(nRadius),
1380 initialColour,destColour);
1381
1382 m_graphicContext->DrawRectangle( xx,yy,ww,hh);
1383 m_graphicContext->SetPen(m_pen);
1384 }
1385
1386 void wxGCDC::DoDrawCheckMark(wxCoord x, wxCoord y,
1387 wxCoord width, wxCoord height)
1388 {
1389 wxDCBase::DoDrawCheckMark(x,y,width,height);
1390 }
1391
1392 #endif
1393