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