]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/dc.cpp
updated mac sources (CW 5.3 working , CW6 still having code gen problems)
[wxWidgets.git] / src / mac / carbon / dc.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: dc.cpp
3 // Purpose: wxDC class
4 // Author: AUTHOR
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "dc.h"
14 #endif
15
16 #include "wx/dc.h"
17 #include "wx/mac/uma.h"
18
19 #if __MSL__ >= 0x6000
20 #include "math.h"
21 #endif
22
23 #if !USE_SHARED_LIBRARY
24 IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
25 #endif
26
27 //-----------------------------------------------------------------------------
28 // constants
29 //-----------------------------------------------------------------------------
30
31 #define mm2inches 0.0393700787402
32 #define inches2mm 25.4
33 #define mm2twips 56.6929133859
34 #define twips2mm 0.0176388888889
35 #define mm2pt 2.83464566929
36 #define pt2mm 0.352777777778
37
38 long wxDC::m_macCurrentPortId = 1 ;
39
40 //-----------------------------------------------------------------------------
41 // wxDC
42 //-----------------------------------------------------------------------------
43
44 wxDC::wxDC()
45 {
46 m_ok = FALSE;
47 m_optimize = FALSE;
48 m_autoSetting = FALSE;
49 m_colour = TRUE;
50 m_clipping = FALSE;
51
52 m_mm_to_pix_x = mm2pt;
53 m_mm_to_pix_y = mm2pt;
54
55 m_logicalOriginX = 0;
56 m_logicalOriginY = 0;
57 m_deviceOriginX = 0;
58 m_deviceOriginY = 0;
59 m_internalDeviceOriginX = 0;
60 m_internalDeviceOriginY = 0;
61 m_externalDeviceOriginX = 0;
62 m_externalDeviceOriginY = 0;
63
64 m_logicalScaleX = 1.0;
65 m_logicalScaleY = 1.0;
66 m_userScaleX = 1.0;
67 m_userScaleY = 1.0;
68 m_scaleX = 1.0;
69 m_scaleY = 1.0;
70
71 m_mappingMode = wxMM_TEXT;
72 m_needComputeScaleX = FALSE;
73 m_needComputeScaleY = FALSE;
74
75 m_signX = 1; // default x-axis left to right
76 m_signY = 1; // default y-axis top down
77
78 m_maxX = m_maxY = -100000;
79 m_minY = m_minY = 100000;
80
81 m_logicalFunction = wxCOPY;
82 // m_textAlignment = wxALIGN_TOP_LEFT;
83 m_backgroundMode = wxTRANSPARENT;
84
85 m_textForegroundColour = *wxBLACK;
86 m_textBackgroundColour = *wxWHITE;
87 m_pen = *wxBLACK_PEN;
88 m_font = *wxNORMAL_FONT;
89 m_brush = *wxTRANSPARENT_BRUSH;
90 m_backgroundBrush = *wxWHITE_BRUSH;
91
92 // m_palette = wxAPP_COLOURMAP;
93 m_macPort = NULL ;
94 m_macMask = NULL ;
95 m_ok = FALSE ;
96
97 m_macFontInstalled = false ;
98 m_macBrushInstalled = false ;
99 m_macPenInstalled = false ;
100
101 m_macPortId = 0 ;
102 m_macLocalOrigin.h = m_macLocalOrigin.v = 0 ;
103 m_macClipRect.left = -32000 ;
104 m_macClipRect.top = -32000 ;
105 m_macClipRect.right = 32000 ;
106 m_macClipRect.bottom = 32000 ;
107 ::GetPort( &m_macOrigPort ) ;
108 };
109
110 wxDC::~wxDC(void)
111 {
112 if ( !m_macPortHelper.IsCleared() )
113 {
114 GrafPtr port ;
115 GetPort( &port ) ;
116 SetPort( m_macPortHelper.GetCurrentPort() ) ;
117 SetOrigin( 0 , 0 ) ;
118 SetPort( port ) ;
119 }
120 /*
121 if ( m_macPort )
122 {
123 ::SetPort( m_macPort ) ;
124 ::SetOrigin( 0 , 0 ) ;
125 ::ClipRect( &m_macPort->portRect ) ;
126 ::PenNormal() ;
127 ::SetPort( m_macOrigPort ) ;
128 }
129 */
130 ++m_macCurrentPortId ;
131 };
132
133 void wxDC::MacSetupPort() const
134 {
135 AGAPortHelper* help = (AGAPortHelper*) &m_macPortHelper ;
136 help->Setup( m_macPort ) ;
137 m_macPortId = ++m_macCurrentPortId ;
138 ::SetOrigin(-m_macLocalOrigin.h, -m_macLocalOrigin.v);
139 ::ClipRect(&m_macClipRect);
140
141 m_macFontInstalled = false ;
142 m_macBrushInstalled = false ;
143 m_macPenInstalled = false ;
144 }
145
146 void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask )
147 {
148 float scale = 1.0 ;
149
150 if (!Ok())
151 return;
152 MacVerifySetup() ;
153
154 long xx1 = XLOG2DEV(x);
155 long yy1 = YLOG2DEV(y);
156
157 {
158 wxBitmapRefData * bmap = (wxBitmapRefData*) ( bmp.GetRefData()) ;
159
160 if ( bmap )
161 {
162 if ( bmap->m_bitmapType == kMacBitmapTypePict )
163 {
164 Rect bitmaprect = { 0 , 0 , bmap->m_height * scale , bmap->m_width * scale} ;
165 ::OffsetRect( &bitmaprect , xx1 , yy1 ) ;
166 ::DrawPicture( bmap->m_hPict , &bitmaprect ) ;
167 }
168 else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld )
169 {
170 if ( bmap->m_hBitmap )
171 {
172 GWorldPtr bmapworld = bmap->m_hBitmap ;
173 PixMapHandle bmappixels ;
174 RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ;
175 RGBColor black = { 0,0,0} ;
176 RGBForeColor( &black ) ;
177 RGBBackColor( &white ) ;
178
179 bmappixels = GetGWorldPixMap( bmapworld ) ;
180 if ( LockPixels(bmappixels) )
181 {
182 Rect source , dest ;
183 source.top = 0 ;
184 source.left = 0 ;
185 source.right = bmap->m_width ;
186 source.bottom = bmap->m_height ;
187 dest.top = YLOG2DEV(y) ;
188 dest.left = XLOG2DEV(x) ;
189 dest.bottom = YLOG2DEV(y + bmap->m_height * scale) ;
190 dest.right = XLOG2DEV(x + bmap->m_width * scale ) ;
191
192 if ( useMask && bmp.GetMask() )
193 {
194 if ( LockPixels( GetGWorldPixMap( bmp.GetMask()->GetMaskBitmap( ) ) ) )
195 {
196 CopyMask( GetPortBitMapForCopyBits( bmapworld ) , GetPortBitMapForCopyBits( bmp.GetMask()->GetMaskBitmap( ) ) ,
197 GetPortBitMapForCopyBits( m_macPort ) ,
198 &source, &source , &dest ) ;
199 UnlockPixels( GetGWorldPixMap( bmp.GetMask()->GetMaskBitmap( ) ) ) ;
200 }
201 }
202 else
203 CopyBits( GetPortBitMapForCopyBits( bmapworld ) , GetPortBitMapForCopyBits( m_macPort ),
204 &source, &dest, srcCopy, NULL ) ;
205
206 UnlockPixels( bmappixels ) ;
207 }
208 m_macPenInstalled = false ;
209 m_macBrushInstalled = false ;
210 m_macFontInstalled = false ;
211 }
212 }
213 }
214 }
215 }
216
217 void wxDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y )
218 {
219 if (!Ok())
220 return;
221 MacVerifySetup() ;
222
223 long xx1 = XLOG2DEV(x);
224 long yy1 = YLOG2DEV(y);
225
226 {
227 wxIconRefData * iconref = (wxIconRefData*) ( icon.GetRefData()) ;
228
229 if ( iconref && iconref->m_ok && iconref->m_hIcon )
230 {
231 Rect bitmaprect = { 0 , 0 , iconref->m_height , iconref->m_width } ;
232 OffsetRect( &bitmaprect , xx1 , yy1 ) ;
233 PlotCIconHandle( &bitmaprect , atNone , ttNone , iconref->m_hIcon ) ;
234 }
235 }
236 };
237
238 void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
239 {
240 MacVerifySetup() ;
241 if( m_clipping )
242 {
243 m_clipX1 = wxMax( m_clipX1 , x ) ;
244 m_clipY1 = wxMax( m_clipY1 ,y );
245 m_clipX2 = wxMin( m_clipX2, (x + width));
246 m_clipY2 = wxMin( m_clipY2,(y + height));
247
248 }
249 else
250 {
251 m_clipping = TRUE;
252 m_clipX1 = x;
253 m_clipY1 = y;
254 m_clipX2 = x + width;
255 m_clipY2 = y + height;
256 }
257
258 long x1 = XLOG2DEV(m_clipX1);
259 long y1 = YLOG2DEV(m_clipY1);
260 long x2 = XLOG2DEV(m_clipX2);
261 long y2 = YLOG2DEV(m_clipY2);
262
263 Rect clip = { y1 , x1 , y2 , x2 } ;
264
265 ::ClipRect( &clip ) ;
266
267 };
268
269 void wxDC::DoSetClippingRegionAsRegion( const wxRegion &region )
270 {
271 wxCHECK_RET( Ok(), wxT("invalid window dc") );
272
273 MacVerifySetup() ;
274 if (region.Empty())
275 {
276 DestroyClippingRegion();
277 return;
278 }
279
280 wxCoord xx, yy, ww, hh;
281 region.GetBox( xx, yy, ww, hh );
282 wxDC::DoSetClippingRegion( xx, yy, ww, hh );
283 }
284
285 void wxDC::DestroyClippingRegion(void)
286 {
287 MacVerifySetup() ;
288 m_clipping = FALSE;
289 // Rect clip = { -32000 , -32000 , 32000 , 32000 } ;
290 ::ClipRect(&m_macClipRect);
291 };
292
293 void wxDC::DoGetSize( int* width, int* height ) const
294 {
295 *width = m_maxX-m_minX;
296 *height = m_maxY-m_minY;
297 };
298
299 void wxDC::DoGetSizeMM( int* width, int* height ) const
300 {
301 int w = 0;
302 int h = 0;
303 GetSize( &w, &h );
304 *width = long( double(w) / (m_scaleX*m_mm_to_pix_x) );
305 *height = long( double(h) / (m_scaleY*m_mm_to_pix_y) );
306 };
307
308 void wxDC::SetTextForeground( const wxColour &col )
309 {
310 if (!Ok()) return;
311 m_textForegroundColour = col;
312 m_macFontInstalled = false ;
313 };
314
315 void wxDC::SetTextBackground( const wxColour &col )
316 {
317 if (!Ok()) return;
318 m_textBackgroundColour = col;
319 m_macFontInstalled = false ;
320 };
321
322 void wxDC::SetMapMode( int mode )
323 {
324 switch (mode)
325 {
326 case wxMM_TWIPS:
327 SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y );
328 break;
329 case wxMM_POINTS:
330 SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y );
331 break;
332 case wxMM_METRIC:
333 SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y );
334 break;
335 case wxMM_LOMETRIC:
336 SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 );
337 break;
338 default:
339 case wxMM_TEXT:
340 SetLogicalScale( 1.0, 1.0 );
341 break;
342 };
343 if (mode != wxMM_TEXT)
344 {
345 m_needComputeScaleX = TRUE;
346 m_needComputeScaleY = TRUE;
347 };
348 };
349
350 void wxDC::SetUserScale( double x, double y )
351 {
352 // allow negative ? -> no
353 m_userScaleX = x;
354 m_userScaleY = y;
355 ComputeScaleAndOrigin();
356 };
357
358 void wxDC::SetLogicalScale( double x, double y )
359 {
360 // allow negative ?
361 m_logicalScaleX = x;
362 m_logicalScaleY = y;
363 ComputeScaleAndOrigin();
364 };
365
366 void wxDC::SetLogicalOrigin( wxCoord x, wxCoord y )
367 {
368 m_logicalOriginX = x * m_signX; // is this still correct ?
369 m_logicalOriginY = y * m_signY;
370 ComputeScaleAndOrigin();
371 };
372
373 void wxDC::SetDeviceOrigin( wxCoord x, wxCoord y )
374 {
375 m_externalDeviceOriginX = x;
376 m_externalDeviceOriginY = y;
377 ComputeScaleAndOrigin();
378 };
379 /*
380 void wxDC::SetInternalDeviceOrigin( long x, long y )
381 {
382 m_internalDeviceOriginX = x;
383 m_internalDeviceOriginY = y;
384 ComputeScaleAndOrigin();
385 };
386
387 void wxDC::GetInternalDeviceOrigin( long *x, long *y )
388 {
389 if (x) *x = m_internalDeviceOriginX;
390 if (y) *y = m_internalDeviceOriginY;
391 };
392 */
393 void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
394 {
395 m_signX = (xLeftRight ? 1 : -1);
396 m_signY = (yBottomUp ? -1 : 1);
397 ComputeScaleAndOrigin();
398 };
399 /*
400
401 void wxDC::CalcBoundingBox( long x, long y )
402 {
403 if (x < m_minX) m_minX = x;
404 if (y < m_minY) m_minY = y;
405 if (x > m_maxX) m_maxX = x;
406 if (y > m_maxY) m_maxY = y;
407 };
408 */
409 wxSize wxDC::GetPPI() const
410 {
411 return wxSize(72, 72);
412 }
413
414 int wxDC::GetDepth() const
415 {
416 return wxDisplayDepth() ;
417 }
418
419 void wxDC::ComputeScaleAndOrigin(void)
420 {
421 // CMB: copy scale to see if it changes
422 double origScaleX = m_scaleX;
423 double origScaleY = m_scaleY;
424
425 m_scaleX = m_logicalScaleX * m_userScaleX;
426 m_scaleY = m_logicalScaleY * m_userScaleY;
427
428 m_deviceOriginX = m_internalDeviceOriginX + m_externalDeviceOriginX;
429 m_deviceOriginY = m_internalDeviceOriginY + m_externalDeviceOriginY;
430
431 // CMB: if scale has changed call SetPen to recalulate the line width
432 if (m_scaleX != origScaleX || m_scaleY != origScaleY)
433 {
434 // this is a bit artificial, but we need to force wxDC to think
435 // the pen has changed
436 wxPen* pen = & GetPen();
437 wxPen tempPen;
438 m_pen = tempPen;
439 SetPen(* pen);
440 }
441 };
442
443 void wxDC::SetPalette( const wxPalette& palette )
444 {
445 }
446
447 void wxDC::SetBackgroundMode( int mode )
448 {
449 m_backgroundMode = mode ;
450 }
451
452 void wxDC::SetFont( const wxFont &font )
453 {
454 if (!Ok())
455 return;
456
457 MacVerifySetup() ;
458
459 m_font = font;
460 m_macFontInstalled = false ;
461 }
462
463 void wxDC::SetPen( const wxPen &pen )
464 {
465 if (!Ok() )
466 return;
467
468 MacVerifySetup() ;
469
470 if ( m_pen == pen )
471 return ;
472
473 m_pen = pen;
474 /*
475 if (!m_pen.Ok())
476 return;
477 */
478 m_macPenInstalled = false ;
479 }
480
481 void wxDC::SetBrush( const wxBrush &brush )
482 {
483 if (!Ok() )
484 return;
485 MacVerifySetup() ;
486
487 if (m_brush == brush)
488 return;
489
490 m_brush = brush;
491 m_macBrushInstalled = false ;
492 }
493
494 void wxDC::SetBackground( const wxBrush &brush )
495 {
496 if (!Ok())
497 return;
498 MacVerifySetup() ;
499
500 if (m_backgroundBrush == brush)
501 return;
502
503 m_backgroundBrush = brush;
504
505 if (!m_backgroundBrush.Ok())
506 return;
507 m_macBrushInstalled = false ;
508 }
509
510 void wxDC::SetLogicalFunction( int function )
511 {
512 if (m_logicalFunction == function)
513 return;
514
515 m_logicalFunction = function ;
516 m_macFontInstalled = false ;
517 m_macBrushInstalled = false ;
518 m_macPenInstalled = false ;
519 }
520
521 void wxDC::DoFloodFill( wxCoord x, wxCoord y, const wxColour& col,
522 int style )
523 {
524 }
525
526 bool wxDC::DoGetPixel( wxCoord x, wxCoord y, wxColour *col ) const
527 {
528 return true ;
529 }
530
531 void wxDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
532 {
533 if (!Ok())
534 return;
535
536 MacVerifySetup() ;
537
538 if (m_pen.GetStyle() != wxTRANSPARENT)
539 {
540 MacInstallPen() ;
541 int offset = (m_pen.GetWidth() - 1) / 2 ;
542 long xx1 = XLOG2DEV(x1);
543 long yy1 = YLOG2DEV(y1);
544 long xx2 = XLOG2DEV(x2);
545 long yy2 = YLOG2DEV(y2);
546
547 ::MoveTo(xx1 - offset ,yy1 - offset);
548 ::LineTo(xx2 - offset , yy2 - offset );
549 };
550 }
551
552 void wxDC::DoCrossHair( wxCoord x, wxCoord y )
553 {
554 }
555
556 void wxDC::DoDrawArc( wxCoord x1, wxCoord y1,
557 wxCoord x2, wxCoord y2,
558 wxCoord xc, wxCoord yc )
559 {
560 }
561
562 void wxDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h,
563 double sa, double ea )
564 {
565 }
566
567 void wxDC::DoDrawPoint( wxCoord x, wxCoord y )
568 {
569 if (!Ok())
570 return;
571
572 MacVerifySetup() ;
573
574 if (m_pen.GetStyle() != wxTRANSPARENT)
575 {
576 MacInstallPen() ;
577 long xx1 = XLOG2DEV(x);
578 long yy1 = YLOG2DEV(y);
579
580 ::MoveTo(xx1,yy1);
581 ::LineTo(xx1+1, yy1+1);
582 };
583 }
584
585 void wxDC::DoDrawLines(int n, wxPoint points[],
586 wxCoord xoffset, wxCoord yoffset)
587 {
588 if (!Ok())
589 return;
590 MacVerifySetup() ;
591
592 if (m_pen.GetStyle() == wxTRANSPARENT)
593 return;
594
595 MacInstallPen() ;
596
597 int offset = (m_pen.GetWidth() - 1 ) / 2 ;
598 long x1, x2 , y1 , y2 ;
599 x1 = XLOG2DEV(points[0].x + xoffset);
600 y1 = YLOG2DEV(points[0].y + yoffset);
601 ::MoveTo(x1 - offset ,y1 - offset );
602
603 for (int i = 0; i < n-1; i++)
604 {
605 long x2 = XLOG2DEV(points[i+1].x + xoffset);
606 long y2 = YLOG2DEV(points[i+1].y + yoffset);
607 ::LineTo(x2 - offset , y2 - offset );
608 }
609 }
610
611 void wxDC::DoDrawPolygon(int n, wxPoint points[],
612 wxCoord xoffset, wxCoord yoffset,
613 int fillStyle )
614 {
615 if (!Ok())
616 return;
617 MacVerifySetup() ;
618
619 PolyHandle polygon = OpenPoly() ;
620 long x1, x2 , y1 , y2 ;
621 x1 = XLOG2DEV(points[0].x + xoffset);
622 y1 = YLOG2DEV(points[0].y + yoffset);
623 ::MoveTo(x1,y1);
624
625 for (int i = 0; i < n-1; i++)
626 {
627 long x2 = XLOG2DEV(points[i+1].x + xoffset);
628 long y2 = YLOG2DEV(points[i+1].y + yoffset);
629 ::LineTo(x2, y2);
630 }
631
632 ClosePoly() ;
633 if (m_brush.GetStyle() != wxTRANSPARENT)
634 {
635 MacInstallBrush() ;
636 ::PaintPoly( polygon ) ;
637 };
638
639 if (m_pen.GetStyle() != wxTRANSPARENT)
640 {
641 MacInstallPen() ;
642 ::FramePoly( polygon ) ;
643 };
644 KillPoly( polygon ) ;
645 }
646
647 void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
648 {
649 if (!Ok())
650 return;
651 MacVerifySetup() ;
652
653 long xx = XLOG2DEV(x);
654 long yy = YLOG2DEV(y);
655 long ww = m_signX * XLOG2DEVREL(width);
656 long hh = m_signY * YLOG2DEVREL(height);
657
658 // CMB: draw nothing if transformed w or h is 0
659 if (ww == 0 || hh == 0)
660 return;
661
662 // CMB: handle -ve width and/or height
663 if (ww < 0)
664 {
665 ww = -ww;
666 xx = xx - ww;
667 }
668
669 if (hh < 0)
670 {
671 hh = -hh;
672 yy = yy - hh;
673 }
674
675 Rect rect = { yy , xx , yy + hh , xx + ww } ;
676
677 if (m_brush.GetStyle() != wxTRANSPARENT)
678 {
679 MacInstallBrush() ;
680 ::PaintRect( &rect ) ;
681 };
682
683 if (m_pen.GetStyle() != wxTRANSPARENT)
684 {
685 MacInstallPen() ;
686 ::FrameRect( &rect ) ;
687 };
688 }
689
690 void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y,
691 wxCoord width, wxCoord height,
692 double radius)
693 {
694 if (!Ok())
695 return;
696 MacVerifySetup() ;
697
698 if (radius < 0.0)
699 radius = - radius * ((width < height) ? width : height);
700
701 long xx = XLOG2DEV(x);
702 long yy = YLOG2DEV(y);
703 long ww = m_signX * XLOG2DEVREL(width);
704 long hh = m_signY * YLOG2DEVREL(height);
705
706 // CMB: draw nothing if transformed w or h is 0
707 if (ww == 0 || hh == 0)
708 return;
709
710 // CMB: handle -ve width and/or height
711 if (ww < 0)
712 {
713 ww = -ww;
714 xx = xx - ww;
715 }
716
717 if (hh < 0)
718 {
719 hh = -hh;
720 yy = yy - hh;
721 }
722
723 Rect rect = { yy , xx , yy + hh , xx + ww } ;
724
725 if (m_brush.GetStyle() != wxTRANSPARENT)
726 {
727 MacInstallBrush() ;
728 ::PaintRoundRect( &rect , radius * 2 , radius * 2 ) ;
729 };
730
731 if (m_pen.GetStyle() != wxTRANSPARENT)
732 {
733 MacInstallPen() ;
734 ::FrameRoundRect( &rect , radius * 2 , radius * 2 ) ;
735 };
736 }
737
738 void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
739 {
740 if (!Ok())
741 return;
742 MacVerifySetup() ;
743
744 long xx = XLOG2DEV(x);
745 long yy = YLOG2DEV(y);
746 long ww = m_signX * XLOG2DEVREL(width);
747 long hh = m_signY * YLOG2DEVREL(height);
748
749 // CMB: draw nothing if transformed w or h is 0
750 if (ww == 0 || hh == 0)
751 return;
752
753 // CMB: handle -ve width and/or height
754 if (ww < 0)
755 {
756 ww = -ww;
757 xx = xx - ww;
758 }
759
760 if (hh < 0)
761 {
762 hh = -hh;
763 yy = yy - hh;
764 }
765
766 Rect rect = { yy , xx , yy + hh , xx + ww } ;
767
768 if (m_brush.GetStyle() != wxTRANSPARENT)
769 {
770 MacInstallBrush() ;
771 ::PaintOval( &rect ) ;
772 };
773
774 if (m_pen.GetStyle() != wxTRANSPARENT)
775 {
776 MacInstallPen() ;
777 ::FrameOval( &rect ) ;
778 };
779 }
780
781 // ----------------------------------- spline code ----------------------------------------
782
783 static void wx_quadratic_spline(double a1, double b1, double a2, double b2,
784 double a3, double b3, double a4, double b4);
785 static void wx_clear_stack(void);
786 static int wx_spline_pop(double *x1, double *y1, double *x2, double *y2, double *x3,
787 double *y3, double *x4, double *y4);
788 static void wx_spline_push(double x1, double y1, double x2, double y2, double x3, double y3,
789 double x4, double y4);
790 static bool wx_spline_add_point(double x, double y);
791 static void wx_spline_draw_point_array(wxDC *dc);
792
793 static wxList wx_spline_point_list;
794
795 #define half(z1, z2) ((z1+z2)/2.0)
796 #define THRESHOLD 5
797
798 /* iterative version */
799
800 static void wx_quadratic_spline(double a1, double b1, double a2, double b2, double a3, double b3, double a4,
801 double b4)
802 {
803 register double xmid, ymid;
804 double x1, y1, x2, y2, x3, y3, x4, y4;
805
806 wx_clear_stack();
807 wx_spline_push(a1, b1, a2, b2, a3, b3, a4, b4);
808
809 while (wx_spline_pop(&x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4)) {
810 xmid = (double)half(x2, x3);
811 ymid = (double)half(y2, y3);
812 if (fabs(x1 - xmid) < THRESHOLD && fabs(y1 - ymid) < THRESHOLD &&
813 fabs(xmid - x4) < THRESHOLD && fabs(ymid - y4) < THRESHOLD) {
814 wx_spline_add_point( x1, y1 );
815 wx_spline_add_point( xmid, ymid );
816 } else {
817 wx_spline_push(xmid, ymid, (double)half(xmid, x3), (double)half(ymid, y3),
818 (double)half(x3, x4), (double)half(y3, y4), x4, y4);
819 wx_spline_push(x1, y1, (double)half(x1, x2), (double)half(y1, y2),
820 (double)half(x2, xmid), (double)half(y2, ymid), xmid, ymid);
821 }
822 }
823 }
824
825 /* utilities used by spline drawing routines */
826
827 typedef struct wx_spline_stack_struct {
828 double x1, y1, x2, y2, x3, y3, x4, y4;
829 } Stack;
830
831 #define SPLINE_STACK_DEPTH 20
832 static Stack wx_spline_stack[SPLINE_STACK_DEPTH];
833 static Stack *wx_stack_top;
834 static int wx_stack_count;
835
836 static void wx_clear_stack(void)
837 {
838 wx_stack_top = wx_spline_stack;
839 wx_stack_count = 0;
840 }
841
842 static void wx_spline_push(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
843 {
844 wx_stack_top->x1 = x1;
845 wx_stack_top->y1 = y1;
846 wx_stack_top->x2 = x2;
847 wx_stack_top->y2 = y2;
848 wx_stack_top->x3 = x3;
849 wx_stack_top->y3 = y3;
850 wx_stack_top->x4 = x4;
851 wx_stack_top->y4 = y4;
852 wx_stack_top++;
853 wx_stack_count++;
854 }
855
856 static int wx_spline_pop(double *x1, double *y1, double *x2, double *y2,
857 double *x3, double *y3, double *x4, double *y4)
858 {
859 if (wx_stack_count == 0)
860 return (0);
861 wx_stack_top--;
862 wx_stack_count--;
863 *x1 = wx_stack_top->x1;
864 *y1 = wx_stack_top->y1;
865 *x2 = wx_stack_top->x2;
866 *y2 = wx_stack_top->y2;
867 *x3 = wx_stack_top->x3;
868 *y3 = wx_stack_top->y3;
869 *x4 = wx_stack_top->x4;
870 *y4 = wx_stack_top->y4;
871 return (1);
872 }
873
874 static bool wx_spline_add_point(double x, double y)
875 {
876 wxPoint *point = new wxPoint ;
877 point->x = (int) x;
878 point->y = (int) y;
879 wx_spline_point_list.Append((wxObject*)point);
880 return TRUE;
881 }
882
883 static void wx_spline_draw_point_array(wxDC *dc)
884 {
885 dc->DrawLines(&wx_spline_point_list, 0, 0 );
886 wxNode *node = wx_spline_point_list.First();
887 while (node)
888 {
889 wxPoint *point = (wxPoint *)node->Data();
890 delete point;
891 delete node;
892 node = wx_spline_point_list.First();
893 }
894 }
895
896 void wxDC::DoDrawSpline(wxList *points)
897 {
898 wxPoint *p;
899 double cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4;
900 double x1, y1, x2, y2;
901
902 wxNode *node = points->First();
903 p = (wxPoint *)node->Data();
904
905 x1 = p->x;
906 y1 = p->y;
907
908 node = node->Next();
909 p = (wxPoint *)node->Data();
910
911 x2 = p->x;
912 y2 = p->y;
913 cx1 = (double)((x1 + x2) / 2);
914 cy1 = (double)((y1 + y2) / 2);
915 cx2 = (double)((cx1 + x2) / 2);
916 cy2 = (double)((cy1 + y2) / 2);
917
918 wx_spline_add_point(x1, y1);
919
920 while ((node = node->Next()) != NULL)
921 {
922 p = (wxPoint *)node->Data();
923 x1 = x2;
924 y1 = y2;
925 x2 = p->x;
926 y2 = p->y;
927 cx4 = (double)(x1 + x2) / 2;
928 cy4 = (double)(y1 + y2) / 2;
929 cx3 = (double)(x1 + cx4) / 2;
930 cy3 = (double)(y1 + cy4) / 2;
931
932 wx_quadratic_spline(cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4);
933
934 cx1 = cx4;
935 cy1 = cy4;
936 cx2 = (double)(cx1 + x2) / 2;
937 cy2 = (double)(cy1 + y2) / 2;
938 }
939
940 wx_spline_add_point( cx1, cy1 );
941 wx_spline_add_point( x2, y2 );
942
943 wx_spline_draw_point_array( this );
944 }
945
946
947
948 bool wxDC::CanDrawBitmap(void) const
949 {
950 return true ;
951 }
952
953
954 bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
955 wxDC *source, wxCoord xsrc, wxCoord ysrc, int logical_func , bool useMask )
956 {
957 if (!Ok()) return FALSE;
958 MacVerifySetup() ;
959
960 CGrafPtr sourcePort = (CGrafPtr) source->m_macPort ;
961 PixMapHandle bmappixels = GetGWorldPixMap( sourcePort ) ;
962 RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ;
963 RGBColor black = { 0,0,0} ;
964 RGBForeColor( &m_textForegroundColour.GetPixel() ) ;
965 RGBBackColor( &m_textBackgroundColour.GetPixel() ) ;
966
967 if ( LockPixels(bmappixels) )
968 {
969 Rect srcrect , dstrect ;
970 srcrect.top = source->YLOG2DEV(ysrc) ;
971 srcrect.left = source->XLOG2DEV(xsrc) ;
972 srcrect.right = source->XLOG2DEV(xsrc + width ) ;
973 srcrect.bottom = source->YLOG2DEV(ysrc + height) ;
974 dstrect.top = YLOG2DEV(ydest) ;
975 dstrect.left = XLOG2DEV(xdest) ;
976 dstrect.bottom = YLOG2DEV(ydest + height ) ;
977 dstrect.right = XLOG2DEV(xdest + width ) ;
978
979 short mode = (logical_func == wxCOPY ? srcCopy :
980 // logical_func == wxCLEAR ? WHITENESS :
981 // logical_func == wxSET ? BLACKNESS :
982 logical_func == wxINVERT ? hilite :
983 // logical_func == wxAND ? MERGECOPY :
984 logical_func == wxOR ? srcOr :
985 logical_func == wxSRC_INVERT ? notSrcCopy :
986 logical_func == wxXOR ? srcXor :
987 // logical_func == wxOR_REVERSE ? MERGEPAINT :
988 // logical_func == wxAND_REVERSE ? SRCERASE :
989 // logical_func == wxSRC_OR ? srcOr :
990 // logical_func == wxSRC_AND ? SRCAND :
991 srcCopy );
992
993 if ( useMask && source->m_macMask )
994 {
995 wxASSERT( mode == srcCopy ) ;
996 if ( LockPixels( GetGWorldPixMap( source->m_macMask ) ) )
997 {
998 CopyMask( GetPortBitMapForCopyBits( sourcePort ) , GetPortBitMapForCopyBits( source->m_macMask ) ,
999 GetPortBitMapForCopyBits( m_macPort ) ,
1000 &srcrect, &srcrect , &dstrect ) ;
1001 UnlockPixels( GetGWorldPixMap( source->m_macMask ) ) ;
1002 }
1003 }
1004 else
1005 {
1006 CopyBits( GetPortBitMapForCopyBits( sourcePort ) , GetPortBitMapForCopyBits( m_macPort ) ,
1007 &srcrect, &dstrect, mode, NULL ) ;
1008 }
1009 UnlockPixels( bmappixels ) ;
1010 }
1011
1012 m_macPenInstalled = false ;
1013 m_macBrushInstalled = false ;
1014 m_macFontInstalled = false ;
1015
1016 return TRUE;
1017 }
1018
1019 void wxDC::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
1020 double angle)
1021 {
1022 }
1023 void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y)
1024 {
1025 if (!Ok())
1026 return;
1027 MacVerifySetup() ;
1028
1029 long xx = XLOG2DEV(x);
1030 long yy = YLOG2DEV(y);
1031
1032 // if (m_pen.GetStyle() != wxTRANSPARENT)
1033 {
1034 MacInstallFont() ;
1035 /*
1036 Rect clip = { -32000 , -32000 , 32000 , 32000 } ;
1037
1038 ::ClipRect( &clip ) ;
1039 */
1040
1041 FontInfo fi ;
1042 ::GetFontInfo( &fi ) ;
1043
1044 yy += fi.ascent ;
1045 ::MoveTo( xx , yy );
1046 if ( m_backgroundMode == wxTRANSPARENT )
1047 {
1048 ::TextMode( srcOr) ;
1049 }
1050 else
1051 {
1052 ::TextMode( srcCopy ) ;
1053 }
1054
1055 const char *text = NULL ;
1056 int length = 0 ;
1057 wxString macText ;
1058
1059 if ( wxApp::s_macDefaultEncodingIsPC )
1060 {
1061 macText = wxMacMakeMacStringFromPC( strtext ) ;
1062 text = macText ;
1063 length = macText.Length() ;
1064 }
1065 else
1066 {
1067 text = strtext ;
1068 length = strtext.Length() ;
1069 }
1070
1071 int laststop = 0 ;
1072 int i = 0 ;
1073 int line = 0 ;
1074
1075 while( i < length )
1076 {
1077 if( text[i] == 13 || text[i] == 10)
1078 {
1079 ::DrawText( text , laststop , i - laststop ) ;
1080 line++ ;
1081 ::MoveTo( xx , yy + line*(fi.descent + fi.ascent + fi.leading) );
1082 laststop = i+1 ;
1083 }
1084 i++ ;
1085 }
1086
1087 ::DrawText( text , laststop , i - laststop ) ;
1088 ::TextMode( srcOr ) ;
1089 }
1090 }
1091
1092 bool wxDC::CanGetTextExtent(void) const
1093 {
1094 if ( !Ok() )
1095 return false ;
1096
1097 return true ;
1098 }
1099
1100 void wxDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *height,
1101 wxCoord *descent, wxCoord *externalLeading ,
1102 wxFont *theFont ) const
1103 {
1104 if (!Ok())
1105 return;
1106
1107 MacVerifySetup() ;
1108
1109 wxFont formerFont = m_font ;
1110
1111 if ( theFont )
1112 {
1113 wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ;
1114
1115 if ( font )
1116 {
1117 ::TextFont( font->m_macFontNum ) ;
1118 ::TextSize( YLOG2DEVREL( font->m_macFontSize) ) ;
1119 ::TextFace( font->m_macFontStyle ) ;
1120 }
1121 }
1122 else
1123 {
1124 MacInstallFont() ;
1125 }
1126
1127 FontInfo fi ;
1128 ::GetFontInfo( &fi ) ;
1129
1130 if ( height )
1131 *height = YDEV2LOGREL( fi.descent + fi.ascent ) ;
1132 if ( descent )
1133 *descent =YDEV2LOGREL( fi.descent );
1134 if ( externalLeading )
1135 *externalLeading = YDEV2LOGREL( fi.leading ) ;
1136
1137 const char *text = NULL ;
1138 int length = 0 ;
1139 wxString macText ;
1140 if ( wxApp::s_macDefaultEncodingIsPC )
1141 {
1142 macText = wxMacMakeMacStringFromPC( string ) ;
1143 text = macText ;
1144 length = macText.Length() ;
1145 }
1146 else
1147 {
1148 text = string ;
1149 length = string.Length() ;
1150 }
1151
1152 int laststop = 0 ;
1153 int i = 0 ;
1154 int curwidth = 0 ;
1155 if ( width )
1156 {
1157 *width = 0 ;
1158
1159 while( i < length )
1160 {
1161 if( text[i] == 13 || text[i] == 10)
1162 {
1163 if ( height )
1164 *height += YDEV2LOGREL( fi.descent + fi.ascent + fi.leading ) ;
1165 curwidth = ::TextWidth( text , laststop , i - laststop ) ;
1166 if ( curwidth > *width )
1167 *width = XDEV2LOGREL( curwidth ) ;
1168 laststop = i+1 ;
1169 }
1170 i++ ;
1171 }
1172
1173 curwidth = ::TextWidth( text , laststop , i - laststop ) ;
1174 if ( curwidth > *width )
1175 *width = XDEV2LOGREL( curwidth ) ;
1176 }
1177
1178 if ( theFont )
1179 {
1180 m_macFontInstalled = false ;
1181 }
1182 }
1183
1184 wxCoord wxDC::GetCharWidth(void) const
1185 {
1186 if (!Ok())
1187 return 1;
1188
1189 MacVerifySetup() ;
1190
1191 MacInstallFont() ;
1192
1193 FontInfo fi ;
1194 ::GetFontInfo( &fi ) ;
1195
1196 return YDEV2LOGREL((fi.descent + fi.ascent) / 2) ;
1197 }
1198
1199 wxCoord wxDC::GetCharHeight(void) const
1200 {
1201 if (!Ok())
1202 return 1;
1203
1204 MacVerifySetup() ;
1205
1206 MacInstallFont() ;
1207
1208 FontInfo fi ;
1209 ::GetFontInfo( &fi ) ;
1210
1211 return YDEV2LOGREL( fi.descent + fi.ascent );
1212 }
1213
1214 void wxDC::Clear(void)
1215 {
1216 if (!Ok())
1217 return;
1218 MacVerifySetup() ;
1219 Rect rect = { -32767 , -32767 , 32767 , 32767 } ;
1220
1221 if (m_backgroundBrush.GetStyle() != wxTRANSPARENT)
1222 {
1223 MacInstallBrush() ;
1224 ::EraseRect( &rect ) ;
1225 };
1226 }
1227
1228 void wxDC::MacInstallFont() const
1229 {
1230 if (!Ok())
1231 return;
1232 MacVerifySetup() ;
1233
1234 if ( m_macFontInstalled )
1235 return ;
1236 Pattern blackColor ;
1237
1238 wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ;
1239
1240 if ( font )
1241 {
1242 ::TextFont( font->m_macFontNum ) ;
1243 ::TextSize( m_scaleY * font->m_macFontSize ) ;
1244 ::TextFace( font->m_macFontStyle ) ;
1245
1246 m_macFontInstalled = true ;
1247 m_macBrushInstalled = false ;
1248 m_macPenInstalled = false ;
1249
1250 ::RGBForeColor(&m_textForegroundColour.GetPixel() );
1251 ::RGBBackColor(&m_textBackgroundColour.GetPixel() );
1252 }
1253 else
1254 {
1255 short fontnum ;
1256
1257 GetFNum( "\pGeneva" , &fontnum ) ;
1258 ::TextFont( fontnum ) ;
1259 ::TextSize( m_scaleY * 10 ) ;
1260 ::TextFace( 0 ) ;
1261
1262 // todo reset after spacing changes - or store the current spacing somewhere
1263
1264 m_macFontInstalled = true ;
1265 m_macBrushInstalled = false ;
1266 m_macPenInstalled = false ;
1267 ::RGBForeColor( &(m_textForegroundColour.GetPixel()) );
1268 ::RGBBackColor(&m_textBackgroundColour.GetPixel() );
1269 }
1270
1271
1272 short mode = patCopy ;
1273
1274 // todo :
1275
1276 switch( m_logicalFunction )
1277 {
1278 case wxCOPY: // src
1279 mode = patCopy ;
1280 break ;
1281 case wxINVERT: // NOT dst
1282 ::PenPat(GetQDGlobalsBlack(&blackColor));
1283 mode = patXor ;
1284 break ;
1285 case wxXOR: // src XOR dst
1286 mode = patXor ;
1287 break ;
1288 case wxOR_REVERSE: // src OR (NOT dst)
1289 mode = notPatOr ;
1290 break ;
1291 case wxSRC_INVERT: // (NOT src)
1292 mode = notPatCopy ;
1293 break ;
1294
1295 // unsupported TODO
1296
1297 case wxCLEAR: // 0
1298 case wxAND_REVERSE:// src AND (NOT dst)
1299 case wxAND: // src AND dst
1300 case wxAND_INVERT: // (NOT src) AND dst
1301 case wxNO_OP: // dst
1302 case wxNOR: // (NOT src) AND (NOT dst)
1303 case wxEQUIV: // (NOT src) XOR dst
1304 case wxOR_INVERT: // (NOT src) OR dst
1305 case wxNAND: // (NOT src) OR (NOT dst)
1306 case wxOR: // src OR dst
1307 case wxSET: // 1
1308 // case wxSRC_OR: // source _bitmap_ OR destination
1309 // case wxSRC_AND: // source _bitmap_ AND destination
1310 break ;
1311 }
1312 ::PenMode( mode ) ;
1313 }
1314
1315 static void wxMacGetHatchPattern(int hatchStyle, Pattern *pattern)
1316 {
1317 int thePatListID = sysPatListID;
1318 int theIndex;
1319 switch(hatchStyle)
1320 {
1321 case wxBDIAGONAL_HATCH:
1322 theIndex = 34; // WCH: this is not good
1323 break;
1324 case wxFDIAGONAL_HATCH:
1325 theIndex = 26;
1326 break;
1327 case wxCROSS_HATCH:
1328 theIndex = 5;
1329 break;
1330 case wxHORIZONTAL_HATCH:
1331 theIndex = 25;
1332 break;
1333 case wxVERTICAL_HATCH:
1334 theIndex = 6;
1335 break;
1336 case wxCROSSDIAG_HATCH:
1337 theIndex = 4; // WCH: this is not good
1338 break;
1339 default:
1340 theIndex = 1; // solid pattern
1341 break;
1342 }
1343 GetIndPattern( pattern, thePatListID, theIndex);
1344 }
1345
1346 void wxDC::MacInstallPen() const
1347 {
1348 if (!Ok())
1349 return;
1350 MacVerifySetup() ;
1351
1352 Pattern blackColor;
1353
1354 if ( m_macPenInstalled )
1355 return ;
1356
1357 ::RGBForeColor(&m_pen.GetColour().GetPixel() );
1358 ::RGBBackColor(&m_backgroundBrush.GetColour().GetPixel() );
1359
1360 ::PenNormal() ;
1361 int penWidth = m_pen.GetWidth();
1362 ::PenSize(penWidth, penWidth);
1363
1364 int penStyle = m_pen.GetStyle();
1365
1366 if (penStyle == wxSOLID)
1367 ::PenPat(GetQDGlobalsBlack(&blackColor));
1368 else if (IS_HATCH(penStyle))
1369 {
1370 Pattern pat ;
1371 wxMacGetHatchPattern(penStyle, &pat);
1372 ::PenPat(&pat);
1373 }
1374 else
1375 {
1376 ::PenPat(GetQDGlobalsBlack(&blackColor));
1377 }
1378
1379 short mode = patCopy ;
1380
1381 // todo :
1382
1383 switch( m_logicalFunction )
1384 {
1385 case wxCOPY: // src
1386 mode = patCopy ;
1387 break ;
1388 case wxINVERT: // NOT dst
1389 ::PenPat(GetQDGlobalsBlack(&blackColor));
1390 mode = patXor ;
1391 break ;
1392 case wxXOR: // src XOR dst
1393 mode = patXor ;
1394 break ;
1395 case wxOR_REVERSE: // src OR (NOT dst)
1396 mode = notPatOr ;
1397 break ;
1398 case wxSRC_INVERT: // (NOT src)
1399 mode = notPatCopy ;
1400 break ;
1401
1402 // unsupported TODO
1403
1404 case wxCLEAR: // 0
1405 case wxAND_REVERSE:// src AND (NOT dst)
1406 case wxAND: // src AND dst
1407 case wxAND_INVERT: // (NOT src) AND dst
1408 case wxNO_OP: // dst
1409 case wxNOR: // (NOT src) AND (NOT dst)
1410 case wxEQUIV: // (NOT src) XOR dst
1411 case wxOR_INVERT: // (NOT src) OR dst
1412 case wxNAND: // (NOT src) OR (NOT dst)
1413 case wxOR: // src OR dst
1414 case wxSET: // 1
1415 // case wxSRC_OR: // source _bitmap_ OR destination
1416 // case wxSRC_AND: // source _bitmap_ AND destination
1417 break ;
1418 }
1419 ::PenMode( mode ) ;
1420 m_macPenInstalled = true ;
1421 m_macBrushInstalled = false ;
1422 m_macFontInstalled = false ;
1423 }
1424
1425 void wxDC::MacInstallBrush() const
1426 {
1427 if (!Ok())
1428 return;
1429 MacVerifySetup() ;
1430 Pattern blackColor, whiteColor ;
1431 if ( m_macBrushInstalled )
1432 return ;
1433
1434 // foreground
1435
1436 ::RGBForeColor(&m_brush.GetColour().GetPixel() );
1437 ::RGBBackColor(&m_backgroundBrush.GetColour().GetPixel() );
1438
1439 int brushStyle = m_brush.GetStyle();
1440 if (brushStyle == wxSOLID)
1441 ::PenPat(GetQDGlobalsBlack(&blackColor));
1442 else if (IS_HATCH(brushStyle))
1443 {
1444 Pattern pat ;
1445 wxMacGetHatchPattern(brushStyle, &pat);
1446 ::PenPat(&pat);
1447 }
1448 else
1449 {
1450 ::PenPat(GetQDGlobalsBlack(&blackColor));
1451 }
1452
1453
1454 // background
1455
1456 brushStyle = m_backgroundBrush.GetStyle();
1457 if (brushStyle == wxSOLID)
1458 ::BackPat(GetQDGlobalsWhite(&whiteColor));
1459 else if (IS_HATCH(brushStyle))
1460 {
1461 Pattern pat ;
1462 wxMacGetHatchPattern(brushStyle, &pat);
1463 ::BackPat(&pat);
1464 }
1465 else
1466 {
1467 ::BackPat(GetQDGlobalsWhite(&whiteColor));
1468 }
1469
1470 short mode = patCopy ;
1471
1472 // todo :
1473
1474 switch( m_logicalFunction )
1475 {
1476 case wxCOPY: // src
1477 mode = patCopy ;
1478 break ;
1479 case wxINVERT: // NOT dst
1480 ::PenPat(GetQDGlobalsBlack(&blackColor));
1481 mode = patXor ;
1482 break ;
1483 case wxXOR: // src XOR dst
1484 mode = patXor ;
1485 break ;
1486 case wxOR_REVERSE: // src OR (NOT dst)
1487 mode = notPatOr ;
1488 break ;
1489 case wxSRC_INVERT: // (NOT src)
1490 mode = notPatCopy ;
1491 break ;
1492
1493 // unsupported TODO
1494
1495 case wxCLEAR: // 0
1496 case wxAND_REVERSE:// src AND (NOT dst)
1497 case wxAND: // src AND dst
1498 case wxAND_INVERT: // (NOT src) AND dst
1499 case wxNO_OP: // dst
1500 case wxNOR: // (NOT src) AND (NOT dst)
1501 case wxEQUIV: // (NOT src) XOR dst
1502 case wxOR_INVERT: // (NOT src) OR dst
1503 case wxNAND: // (NOT src) OR (NOT dst)
1504 case wxOR: // src OR dst
1505 case wxSET: // 1
1506 // case wxSRC_OR: // source _bitmap_ OR destination
1507 // case wxSRC_AND: // source _bitmap_ AND destination
1508 break ;
1509 }
1510 ::PenMode( mode ) ;
1511 m_macBrushInstalled = true ;
1512 m_macPenInstalled = false ;
1513 m_macFontInstalled = false ;
1514 }
1515
1516 // ---------------------------------------------------------------------------
1517 // coordinates transformations
1518 // ---------------------------------------------------------------------------
1519
1520
1521 wxCoord wxDCBase::DeviceToLogicalX(wxCoord x) const
1522 {
1523 return ((wxDC *)this)->XDEV2LOG(x);
1524 }
1525
1526 wxCoord wxDCBase::DeviceToLogicalY(wxCoord y) const
1527 {
1528 return ((wxDC *)this)->YDEV2LOG(y);
1529 }
1530
1531 wxCoord wxDCBase::DeviceToLogicalXRel(wxCoord x) const
1532 {
1533 return ((wxDC *)this)->XDEV2LOGREL(x);
1534 }
1535
1536 wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const
1537 {
1538 return ((wxDC *)this)->YDEV2LOGREL(y);
1539 }
1540
1541 wxCoord wxDCBase::LogicalToDeviceX(wxCoord x) const
1542 {
1543 return ((wxDC *)this)->XLOG2DEV(x);
1544 }
1545
1546 wxCoord wxDCBase::LogicalToDeviceY(wxCoord y) const
1547 {
1548 return ((wxDC *)this)->YLOG2DEV(y);
1549 }
1550
1551 wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const
1552 {
1553 return ((wxDC *)this)->XLOG2DEVREL(x);
1554 }
1555
1556 wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const
1557 {
1558 return ((wxDC *)this)->YLOG2DEVREL(y);
1559 }