1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "dc.h"
16 #include "wx/wxprec.h"
20 #if !wxMAC_USE_CORE_GRAPHICS
22 #include "wx/mac/uma.h"
23 #include "wx/dcmemory.h"
24 #include "wx/dcprint.h"
25 #include "wx/region.h"
34 #include "wx/mac/private.h"
35 #include <ATSUnicode.h>
36 #include <TextCommon.h>
37 #include <TextEncodingConverter.h>
38 #if !USE_SHARED_LIBRARY
39 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxObject
)
42 //-----------------------------------------------------------------------------
44 //-----------------------------------------------------------------------------
46 const double RAD2DEG
= 180.0 / M_PI
;
47 const short kEmulatedMode
= -1 ;
48 const short kUnsupportedMode
= -2 ;
50 extern TECObjectRef s_TECNativeCToUnicode
;
52 // set to 0 if problems arise
53 #define wxMAC_EXPERIMENTAL_DC 1
55 wxMacPortSetter::wxMacPortSetter( const wxDC
* dc
) :
56 m_ph( (GrafPtr
) dc
->m_macPort
)
58 wxASSERT( dc
->Ok() ) ;
60 dc
->MacSetupPort(&m_ph
) ;
62 wxMacPortSetter::~wxMacPortSetter()
64 m_dc
->MacCleanupPort(&m_ph
) ;
67 #if wxMAC_EXPERIMENTAL_DC
68 class wxMacFastPortSetter
71 wxMacFastPortSetter( const wxDC
*dc
)
73 wxASSERT( dc
->Ok() ) ;
74 m_swapped
= QDSwapPort( (GrafPtr
) dc
->m_macPort
, &m_oldPort
) ;
75 m_clipRgn
= NewRgn() ;
76 GetClip( m_clipRgn
) ;
78 dc
->MacSetupPort( NULL
) ;
80 ~wxMacFastPortSetter()
82 // SetPort( (GrafPtr) m_dc->m_macPort ) ;
83 SetClip( m_clipRgn
) ;
85 SetPort( m_oldPort
) ;
86 m_dc
->MacCleanupPort( NULL
) ;
87 DisposeRgn( m_clipRgn
) ;
97 typedef wxMacPortSetter wxMacFastPortSetter
;
100 wxMacWindowClipper::wxMacWindowClipper( const wxWindow
* win
) :
101 wxMacPortSaver( (GrafPtr
) GetWindowPort((WindowRef
) win
->MacGetTopLevelWindowRef()) )
103 m_newPort
=(GrafPtr
) GetWindowPort((WindowRef
) win
->MacGetTopLevelWindowRef()) ;
104 m_formerClip
= NewRgn() ;
105 m_newClip
= NewRgn() ;
106 GetClip( m_formerClip
) ;
110 // guard against half constructed objects, this just leads to a empty clip
114 win
->MacWindowToRootWindow( &x
,&y
) ;
115 // get area including focus rect
116 CopyRgn( (RgnHandle
) ((wxWindow
*)win
)->MacGetVisibleRegion(true).GetWXHRGN() , m_newClip
) ;
117 if ( !EmptyRgn( m_newClip
) )
118 OffsetRgn( m_newClip
, x
, y
) ;
120 SetClip( m_newClip
) ;
124 wxMacWindowClipper::~wxMacWindowClipper()
126 SetPort( m_newPort
) ;
127 SetClip( m_formerClip
) ;
128 DisposeRgn( m_newClip
) ;
129 DisposeRgn( m_formerClip
) ;
132 wxMacWindowStateSaver::wxMacWindowStateSaver( const wxWindow
* win
) :
133 wxMacWindowClipper( win
)
135 // the port is already set at this point
136 m_newPort
=(GrafPtr
) GetWindowPort((WindowRef
) win
->MacGetTopLevelWindowRef()) ;
137 GetThemeDrawingState( &m_themeDrawingState
) ;
140 wxMacWindowStateSaver::~wxMacWindowStateSaver()
142 SetPort( m_newPort
) ;
143 SetThemeDrawingState( m_themeDrawingState
, true ) ;
146 //-----------------------------------------------------------------------------
148 //-----------------------------------------------------------------------------
149 static inline double dmin(double a
, double b
) { return a
< b
? a
: b
; }
150 static inline double dmax(double a
, double b
) { return a
> b
? a
: b
; }
151 static inline double DegToRad(double deg
) { return (deg
* M_PI
) / 180.0; }
153 //-----------------------------------------------------------------------------
155 //-----------------------------------------------------------------------------
156 // this function emulates all wx colour manipulations, used to verify the implementation
157 // by setting the mode in the blitting functions to kEmulatedMode
158 void wxMacCalculateColour( int logical_func
, const RGBColor
&srcColor
, RGBColor
&dstColor
) ;
160 void wxMacCalculateColour( int logical_func
, const RGBColor
&srcColor
, RGBColor
&dstColor
)
162 switch ( logical_func
)
164 case wxAND
: // src AND dst
165 dstColor
.red
= dstColor
.red
& srcColor
.red
;
166 dstColor
.green
= dstColor
.green
& srcColor
.green
;
167 dstColor
.blue
= dstColor
.blue
& srcColor
.blue
;
169 case wxAND_INVERT
: // (NOT src) AND dst
170 dstColor
.red
= dstColor
.red
& ~srcColor
.red
;
171 dstColor
.green
= dstColor
.green
& ~srcColor
.green
;
172 dstColor
.blue
= dstColor
.blue
& ~srcColor
.blue
;
174 case wxAND_REVERSE
:// src AND (NOT dst)
175 dstColor
.red
= ~dstColor
.red
& srcColor
.red
;
176 dstColor
.green
= ~dstColor
.green
& srcColor
.green
;
177 dstColor
.blue
= ~dstColor
.blue
& srcColor
.blue
;
185 dstColor
.red
= srcColor
.red
;
186 dstColor
.green
= srcColor
.green
;
187 dstColor
.blue
= srcColor
.blue
;
189 case wxEQUIV
: // (NOT src) XOR dst
190 dstColor
.red
= dstColor
.red
^ ~srcColor
.red
;
191 dstColor
.green
= dstColor
.green
^ ~srcColor
.green
;
192 dstColor
.blue
= dstColor
.blue
^ ~srcColor
.blue
;
194 case wxINVERT
: // NOT dst
195 dstColor
.red
= ~dstColor
.red
;
196 dstColor
.green
= ~dstColor
.green
;
197 dstColor
.blue
= ~dstColor
.blue
;
199 case wxNAND
: // (NOT src) OR (NOT dst)
200 dstColor
.red
= ~dstColor
.red
| ~srcColor
.red
;
201 dstColor
.green
= ~dstColor
.green
| ~srcColor
.green
;
202 dstColor
.blue
= ~dstColor
.blue
| ~srcColor
.blue
;
204 case wxNOR
: // (NOT src) AND (NOT dst)
205 dstColor
.red
= ~dstColor
.red
& ~srcColor
.red
;
206 dstColor
.green
= ~dstColor
.green
& ~srcColor
.green
;
207 dstColor
.blue
= ~dstColor
.blue
& ~srcColor
.blue
;
211 case wxOR
: // src OR dst
212 dstColor
.red
= dstColor
.red
| srcColor
.red
;
213 dstColor
.green
= dstColor
.green
| srcColor
.green
;
214 dstColor
.blue
= dstColor
.blue
| srcColor
.blue
;
216 case wxOR_INVERT
: // (NOT src) OR dst
217 dstColor
.red
= dstColor
.red
| ~srcColor
.red
;
218 dstColor
.green
= dstColor
.green
| ~srcColor
.green
;
219 dstColor
.blue
= dstColor
.blue
| ~srcColor
.blue
;
221 case wxOR_REVERSE
: // src OR (NOT dst)
222 dstColor
.red
= ~dstColor
.red
| srcColor
.red
;
223 dstColor
.green
= ~dstColor
.green
| srcColor
.green
;
224 dstColor
.blue
= ~dstColor
.blue
| srcColor
.blue
;
227 dstColor
.red
= 0xFFFF ;
228 dstColor
.green
= 0xFFFF ;
229 dstColor
.blue
= 0xFFFF ;
231 case wxSRC_INVERT
: // (NOT src)
232 dstColor
.red
= ~srcColor
.red
;
233 dstColor
.green
= ~srcColor
.green
;
234 dstColor
.blue
= ~srcColor
.blue
;
236 case wxXOR
: // src XOR dst
237 dstColor
.red
= dstColor
.red
^ srcColor
.red
;
238 dstColor
.green
= dstColor
.green
^ srcColor
.green
;
239 dstColor
.blue
= dstColor
.blue
^ srcColor
.blue
;
248 m_mm_to_pix_x
= mm2pt
;
249 m_mm_to_pix_y
= mm2pt
;
250 m_internalDeviceOriginX
= 0;
251 m_internalDeviceOriginY
= 0;
252 m_externalDeviceOriginX
= 0;
253 m_externalDeviceOriginY
= 0;
254 m_logicalScaleX
= 1.0;
255 m_logicalScaleY
= 1.0;
260 m_needComputeScaleX
= false;
261 m_needComputeScaleY
= false;
265 m_macFontInstalled
= false ;
266 m_macBrushInstalled
= false ;
267 m_macPenInstalled
= false ;
268 m_macLocalOrigin
.x
= m_macLocalOrigin
.y
= 0 ;
269 m_macBoundaryClipRgn
= NewRgn() ;
270 m_macCurrentClipRgn
= NewRgn() ;
271 SetRectRgn( (RgnHandle
) m_macBoundaryClipRgn
, -32000 , -32000 , 32000 , 32000 ) ;
272 SetRectRgn( (RgnHandle
) m_macCurrentClipRgn
, -32000 , -32000 , 32000 , 32000 ) ;
273 m_pen
= *wxBLACK_PEN
;
274 m_font
= *wxNORMAL_FONT
;
275 m_brush
= *wxWHITE_BRUSH
;
277 // needed to debug possible errors with two active drawing methods at the same time on
279 m_macCurrentPortStateHelper
= NULL
;
281 m_macATSUIStyle
= NULL
;
282 m_macAliasWasEnabled
= false;
283 m_macForegroundPixMap
= NULL
;
284 m_macBackgroundPixMap
= NULL
;
289 DisposeRgn( (RgnHandle
) m_macBoundaryClipRgn
) ;
290 DisposeRgn( (RgnHandle
) m_macCurrentClipRgn
) ;
293 void wxDC::MacSetupPort(wxMacPortStateHelper
* help
) const
296 wxASSERT( m_macCurrentPortStateHelper
== NULL
) ;
297 m_macCurrentPortStateHelper
= help
;
299 SetClip( (RgnHandle
) m_macCurrentClipRgn
);
300 #if ! wxMAC_EXPERIMENTAL_DC
301 m_macFontInstalled
= false ;
302 m_macBrushInstalled
= false ;
303 m_macPenInstalled
= false ;
306 void wxDC::MacCleanupPort(wxMacPortStateHelper
* help
) const
309 wxASSERT( m_macCurrentPortStateHelper
== help
) ;
310 m_macCurrentPortStateHelper
= NULL
;
312 if( m_macATSUIStyle
)
314 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUIStyle
);
315 m_macATSUIStyle
= NULL
;
317 if ( m_macAliasWasEnabled
)
319 SetAntiAliasedTextEnabled(m_macFormerAliasState
, m_macFormerAliasSize
);
320 m_macAliasWasEnabled
= false ;
322 if ( m_macForegroundPixMap
)
325 ::PenPat(GetQDGlobalsBlack(&blackColor
));
326 DisposePixPat( (PixPatHandle
) m_macForegroundPixMap
) ;
327 m_macForegroundPixMap
= NULL
;
329 if ( m_macBackgroundPixMap
)
332 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
333 DisposePixPat( (PixPatHandle
) m_macBackgroundPixMap
) ;
334 m_macBackgroundPixMap
= NULL
;
338 void wxDC::DoDrawBitmap( const wxBitmap
&bmp
, wxCoord x
, wxCoord y
, bool useMask
)
340 wxCHECK_RET( Ok(), wxT("invalid window dc") );
341 wxCHECK_RET( bmp
.Ok(), wxT("invalid bitmap") );
342 wxMacFastPortSetter
helper(this) ;
343 wxCoord xx
= XLOG2DEVMAC(x
);
344 wxCoord yy
= YLOG2DEVMAC(y
);
345 wxCoord w
= bmp
.GetWidth();
346 wxCoord h
= bmp
.GetHeight();
347 wxCoord ww
= XLOG2DEVREL(w
);
348 wxCoord hh
= YLOG2DEVREL(h
);
349 // Set up drawing mode
350 short mode
= (m_logicalFunction
== wxCOPY
? srcCopy
:
351 //m_logicalFunction == wxCLEAR ? WHITENESS :
352 //m_logicalFunction == wxSET ? BLACKNESS :
353 m_logicalFunction
== wxINVERT
? hilite
:
354 //m_logicalFunction == wxAND ? MERGECOPY :
355 m_logicalFunction
== wxOR
? srcOr
:
356 m_logicalFunction
== wxSRC_INVERT
? notSrcCopy
:
357 m_logicalFunction
== wxXOR
? srcXor
:
358 m_logicalFunction
== wxOR_REVERSE
? notSrcOr
:
359 //m_logicalFunction == wxAND_REVERSE ? SRCERASE :
360 //m_logicalFunction == wxSRC_OR ? srcOr :
361 //m_logicalFunction == wxSRC_AND ? SRCAND :
364 GWorldPtr maskworld
= NULL
;
365 GWorldPtr bmapworld
= MAC_WXHBITMAP( bmp
.GetHBITMAP((WXHBITMAP
*)&maskworld
) );
366 PixMapHandle bmappixels
;
367 // Set foreground and background colours (for bitmaps depth = 1)
368 if(bmp
.GetDepth() == 1)
370 RGBColor fore
= MAC_WXCOLORREF(m_textForegroundColour
.GetPixel());
371 RGBColor back
= MAC_WXCOLORREF(m_textBackgroundColour
.GetPixel());
377 RGBColor white
= { 0xFFFF, 0xFFFF,0xFFFF} ;
378 RGBColor black
= { 0,0,0} ;
379 RGBForeColor( &black
) ;
380 RGBBackColor( &white
) ;
382 bmappixels
= GetGWorldPixMap( bmapworld
) ;
383 wxCHECK_RET(LockPixels(bmappixels
),
384 wxT("DoDrawBitmap: Unable to lock pixels"));
385 Rect source
= { 0, 0, h
, w
};
386 Rect dest
= { yy
, xx
, yy
+ hh
, xx
+ ww
};
387 if ( useMask
&& maskworld
)
389 if( LockPixels(GetGWorldPixMap(MAC_WXHBITMAP(maskworld
))))
393 GetPortBitMapForCopyBits(bmapworld
),
394 GetPortBitMapForCopyBits(MAC_WXHBITMAP(maskworld
)),
395 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ),
396 &source
, &source
, &dest
, mode
, NULL
398 UnlockPixels(GetGWorldPixMap(MAC_WXHBITMAP(maskworld
)));
402 CopyBits( GetPortBitMapForCopyBits( bmapworld
),
403 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ),
404 &source
, &dest
, mode
, NULL
) ;
406 UnlockPixels( bmappixels
) ;
408 m_macPenInstalled
= false ;
409 m_macBrushInstalled
= false ;
410 m_macFontInstalled
= false ;
413 void wxDC::DoDrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
)
415 wxCHECK_RET(Ok(), wxT("Invalid dc wxDC::DoDrawIcon"));
416 wxCHECK_RET(icon
.Ok(), wxT("Invalid icon wxDC::DoDrawIcon"));
417 wxMacFastPortSetter
helper(this) ;
419 wxCoord xx
= XLOG2DEVMAC(x
);
420 wxCoord yy
= YLOG2DEVMAC(y
);
422 Rect r
= { yy
, xx
, yy
+ 32 , xx
+ 32 } ;
423 PlotIconRef( &r
, kAlignNone
, kTransformNone
, kPlotIconRefNormalFlags
, MAC_WXHICON( icon
.GetHICON() ) ) ;
426 void wxDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
428 wxCHECK_RET(Ok(), wxT("wxDC::DoSetClippingRegion Invalid DC"));
429 wxCoord xx
, yy
, ww
, hh
;
432 ww
= XLOG2DEVREL(width
);
433 hh
= YLOG2DEVREL(height
);
434 SetRectRgn( (RgnHandle
) m_macCurrentClipRgn
, xx
, yy
, xx
+ ww
, yy
+ hh
) ;
435 SectRgn( (RgnHandle
) m_macCurrentClipRgn
, (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
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
));
453 void wxDC::DoSetClippingRegionAsRegion( const wxRegion
®ion
)
455 wxCHECK_RET( Ok(), wxT("invalid window dc") ) ;
458 DestroyClippingRegion();
461 wxMacFastPortSetter
helper(this) ;
463 region
.GetBox( x
, y
, w
, h
);
464 wxCoord xx
, yy
, ww
, hh
;
469 // if we have a scaling that we cannot map onto native regions
470 // we must use the box
471 if ( ww
!= w
|| hh
!= h
)
473 wxDC::DoSetClippingRegion( x
, y
, w
, h
);
477 CopyRgn( (RgnHandle
) region
.GetWXHRGN() , (RgnHandle
) m_macCurrentClipRgn
) ;
478 if ( xx
!= x
|| yy
!= y
)
480 OffsetRgn( (RgnHandle
) m_macCurrentClipRgn
, xx
- x
, yy
- y
) ;
482 SectRgn( (RgnHandle
) m_macCurrentClipRgn
, (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
485 m_clipX1
= wxMax( m_clipX1
, xx
);
486 m_clipY1
= wxMax( m_clipY1
, yy
);
487 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
));
488 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
));
501 void wxDC::DestroyClippingRegion()
503 wxMacFastPortSetter
helper(this) ;
504 CopyRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
508 void wxDC::DoGetSizeMM( int* width
, int* height
) const
513 *width
= long( double(w
) / (m_scaleX
*m_mm_to_pix_x
) );
514 *height
= long( double(h
) / (m_scaleY
*m_mm_to_pix_y
) );
517 void wxDC::SetTextForeground( const wxColour
&col
)
519 wxCHECK_RET(Ok(), wxT("Invalid DC"));
520 m_textForegroundColour
= col
;
521 m_macFontInstalled
= false ;
524 void wxDC::SetTextBackground( const wxColour
&col
)
526 wxCHECK_RET(Ok(), wxT("Invalid DC"));
527 m_textBackgroundColour
= col
;
528 m_macFontInstalled
= false ;
531 void wxDC::SetMapMode( int mode
)
536 SetLogicalScale( twips2mm
*m_mm_to_pix_x
, twips2mm
*m_mm_to_pix_y
);
539 SetLogicalScale( pt2mm
*m_mm_to_pix_x
, pt2mm
*m_mm_to_pix_y
);
542 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
545 SetLogicalScale( m_mm_to_pix_x
/10.0, m_mm_to_pix_y
/10.0 );
549 SetLogicalScale( 1.0, 1.0 );
552 if (mode
!= wxMM_TEXT
)
554 m_needComputeScaleX
= true;
555 m_needComputeScaleY
= true;
559 void wxDC::SetUserScale( double x
, double y
)
561 // allow negative ? -> no
564 ComputeScaleAndOrigin();
567 void wxDC::SetLogicalScale( double x
, double y
)
572 ComputeScaleAndOrigin();
575 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
577 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
578 m_logicalOriginY
= y
* m_signY
;
579 ComputeScaleAndOrigin();
582 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
584 m_externalDeviceOriginX
= x
;
585 m_externalDeviceOriginY
= y
;
586 ComputeScaleAndOrigin();
589 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
591 m_signX
= (xLeftRight
? 1 : -1);
592 m_signY
= (yBottomUp
? -1 : 1);
593 ComputeScaleAndOrigin();
596 wxSize
wxDC::GetPPI() const
598 return wxSize(72, 72);
601 int wxDC::GetDepth() const
603 if ( IsPortColor( (CGrafPtr
) m_macPort
) )
605 return ( (**GetPortPixMap( (CGrafPtr
) m_macPort
)).pixelSize
) ;
610 void wxDC::ComputeScaleAndOrigin()
612 // CMB: copy scale to see if it changes
613 double origScaleX
= m_scaleX
;
614 double origScaleY
= m_scaleY
;
615 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
616 m_scaleY
= m_logicalScaleY
* m_userScaleY
;
617 m_deviceOriginX
= m_internalDeviceOriginX
+ m_externalDeviceOriginX
;
618 m_deviceOriginY
= m_internalDeviceOriginY
+ m_externalDeviceOriginY
;
619 // CMB: if scale has changed call SetPen to recalulate the line width
620 if (m_scaleX
!= origScaleX
|| m_scaleY
!= origScaleY
)
622 // this is a bit artificial, but we need to force wxDC to think
623 // the pen has changed
630 void wxDC::SetPalette( const wxPalette
& palette
)
634 void wxDC::SetBackgroundMode( int mode
)
636 m_backgroundMode
= mode
;
639 void wxDC::SetFont( const wxFont
&font
)
642 m_macFontInstalled
= false ;
645 void wxDC::SetPen( const wxPen
&pen
)
650 m_macPenInstalled
= false ;
653 void wxDC::SetBrush( const wxBrush
&brush
)
655 if (m_brush
== brush
)
658 m_macBrushInstalled
= false ;
661 void wxDC::SetBackground( const wxBrush
&brush
)
663 if (m_backgroundBrush
== brush
)
665 m_backgroundBrush
= brush
;
666 if (!m_backgroundBrush
.Ok())
668 m_macBrushInstalled
= false ;
671 void wxDC::SetLogicalFunction( int function
)
673 if (m_logicalFunction
== function
)
675 m_logicalFunction
= function
;
676 m_macFontInstalled
= false ;
677 m_macBrushInstalled
= false ;
678 m_macPenInstalled
= false ;
681 extern bool wxDoFloodFill(wxDC
*dc
, wxCoord x
, wxCoord y
,
682 const wxColour
& col
, int style
);
684 bool wxDC::DoFloodFill(wxCoord x
, wxCoord y
,
685 const wxColour
& col
, int style
)
687 return wxDoFloodFill(this, x
, y
, col
, style
);
690 bool wxDC::DoGetPixel( wxCoord x
, wxCoord y
, wxColour
*col
) const
692 wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel Invalid DC") );
693 wxMacFastPortSetter
helper(this) ;
695 GetCPixel( XLOG2DEVMAC(x
), YLOG2DEVMAC(y
), &colour
);
696 // Convert from Mac colour to wx
697 col
->Set( colour
.red
>> 8,
703 void wxDC::DoDrawLine( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
705 wxCHECK_RET(Ok(), wxT("Invalid DC"));
706 wxMacFastPortSetter
helper(this) ;
707 if (m_pen
.GetStyle() != wxTRANSPARENT
)
710 wxCoord offset
= ( (m_pen
.GetWidth() == 0 ? 1 :
711 m_pen
.GetWidth() ) * (wxCoord
)m_scaleX
- 1) / 2;
712 wxCoord xx1
= XLOG2DEVMAC(x1
) - offset
;
713 wxCoord yy1
= YLOG2DEVMAC(y1
) - offset
;
714 wxCoord xx2
= XLOG2DEVMAC(x2
) - offset
;
715 wxCoord yy2
= YLOG2DEVMAC(y2
) - offset
;
716 if ((m_pen
.GetCap() == wxCAP_ROUND
) &&
717 (m_pen
.GetWidth() <= 1))
719 // Implement LAST_NOT for MAC at least for
720 // orthogonal lines. RR.
741 void wxDC::DoCrossHair( wxCoord x
, wxCoord y
)
743 wxCHECK_RET( Ok(), wxT("wxDC::DoCrossHair Invalid window dc") );
744 wxMacFastPortSetter
helper(this) ;
745 if (m_pen
.GetStyle() != wxTRANSPARENT
)
750 wxCoord xx
= XLOG2DEVMAC(x
);
751 wxCoord yy
= YLOG2DEVMAC(y
);
753 ::MoveTo( XLOG2DEVMAC(0), yy
);
754 ::LineTo( XLOG2DEVMAC(w
), yy
);
755 ::MoveTo( xx
, YLOG2DEVMAC(0) );
756 ::LineTo( xx
, YLOG2DEVMAC(h
) );
757 CalcBoundingBox(x
, y
);
758 CalcBoundingBox(x
+w
, y
+h
);
763 * To draw arcs properly the angles need to be converted from the WX style:
764 * Angles start on the +ve X axis and go anti-clockwise (As you would draw on
765 * a normal axis on paper).
768 * Angles start on the +ve y axis and go clockwise.
771 static double wxConvertWXangleToMACangle(double angle
)
773 double newAngle
= 90 - angle
;
774 while ( newAngle
> 360 ) newAngle
-= 360 ;
775 while ( newAngle
< 0 ) newAngle
+= 360 ;
779 void wxDC::DoDrawArc( wxCoord x1
, wxCoord y1
,
780 wxCoord x2
, wxCoord y2
,
781 wxCoord xc
, wxCoord yc
)
783 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawArc Invalid DC"));
784 wxMacFastPortSetter
helper(this) ;
785 wxCoord xx1
= XLOG2DEVMAC(x1
);
786 wxCoord yy1
= YLOG2DEVMAC(y1
);
787 wxCoord xx2
= XLOG2DEVMAC(x2
);
788 wxCoord yy2
= YLOG2DEVMAC(y2
);
789 wxCoord xxc
= XLOG2DEVMAC(xc
);
790 wxCoord yyc
= YLOG2DEVMAC(yc
);
791 double dx
= xx1
- xxc
;
792 double dy
= yy1
- yyc
;
793 double radius
= sqrt((double)(dx
*dx
+dy
*dy
));
794 wxCoord rad
= (wxCoord
)radius
;
795 double radius1
, radius2
;
796 if (xx1
== xx2
&& yy1
== yy2
)
801 else if (radius
== 0.0)
803 radius1
= radius2
= 0.0;
807 radius1
= (xx1
- xxc
== 0) ?
808 (yy1
- yyc
< 0) ? 90.0 : -90.0 :
809 -atan2(double(yy1
-yyc
), double(xx1
-xxc
)) * RAD2DEG
;
810 radius2
= (xx2
- xxc
== 0) ?
811 (yy2
- yyc
< 0) ? 90.0 : -90.0 :
812 -atan2(double(yy2
-yyc
), double(xx2
-xxc
)) * RAD2DEG
;
814 wxCoord alpha2
= wxCoord(radius2
- radius1
);
815 wxCoord alpha1
= wxCoord(wxConvertWXangleToMACangle(radius1
));
816 while( alpha2
< 0 ) alpha2
+= 360 ;
818 Rect r
= { yyc
- rad
, xxc
- rad
, yyc
+ rad
, xxc
+ rad
};
819 if(m_brush
.GetStyle() != wxTRANSPARENT
) {
821 PaintArc(&r
, alpha1
, alpha2
);
823 if(m_pen
.GetStyle() != wxTRANSPARENT
) {
825 FrameArc(&r
, alpha1
, alpha2
);
829 void wxDC::DoDrawEllipticArc( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
830 double sa
, double ea
)
832 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawEllepticArc Invalid DC"));
833 wxMacFastPortSetter
helper(this) ;
835 double angle
= sa
- ea
; // Order important Mac in opposite direction to wx
836 // we have to make sure that the filling is always counter-clockwise
839 wxCoord xx
= XLOG2DEVMAC(x
);
840 wxCoord yy
= YLOG2DEVMAC(y
);
841 wxCoord ww
= m_signX
* XLOG2DEVREL(w
);
842 wxCoord hh
= m_signY
* YLOG2DEVREL(h
);
843 // handle -ve width and/or height
844 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
845 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
846 sa
= wxConvertWXangleToMACangle(sa
);
851 if(m_brush
.GetStyle() != wxTRANSPARENT
) {
853 PaintArc(&r
, (short)sa
, (short)angle
);
855 if(m_pen
.GetStyle() != wxTRANSPARENT
) {
857 FrameArc(&r
, (short)sa
, (short)angle
);
861 void wxDC::DoDrawPoint( wxCoord x
, wxCoord y
)
863 wxCHECK_RET(Ok(), wxT("Invalid DC"));
864 wxMacFastPortSetter
helper(this) ;
865 if (m_pen
.GetStyle() != wxTRANSPARENT
)
867 wxCoord xx1
= XLOG2DEVMAC(x
);
868 wxCoord yy1
= YLOG2DEVMAC(y
);
869 RGBColor pencolor
= MAC_WXCOLORREF( m_pen
.GetColour().GetPixel());
870 ::SetCPixel( xx1
,yy1
,&pencolor
) ;
871 CalcBoundingBox(x
, y
);
875 void wxDC::DoDrawLines(int n
, wxPoint points
[],
876 wxCoord xoffset
, wxCoord yoffset
)
878 wxCHECK_RET(Ok(), wxT("Invalid DC"));
879 wxMacFastPortSetter
helper(this) ;
880 if (m_pen
.GetStyle() == wxTRANSPARENT
)
883 wxCoord offset
= ( (m_pen
.GetWidth() == 0 ? 1 :
884 m_pen
.GetWidth() ) * (wxCoord
)m_scaleX
- 1) / 2 ;
885 wxCoord x1
, x2
, y1
, y2
;
886 x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
887 y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
888 ::MoveTo(x1
- offset
, y1
- offset
);
889 for (int i
= 0; i
< n
-1; i
++)
891 x2
= XLOG2DEVMAC(points
[i
+1].x
+ xoffset
);
892 y2
= YLOG2DEVMAC(points
[i
+1].y
+ yoffset
);
893 ::LineTo( x2
- offset
, y2
- offset
);
897 void wxDC::DoDrawPolygon(int n
, wxPoint points
[],
898 wxCoord xoffset
, wxCoord yoffset
,
901 wxCHECK_RET(Ok(), wxT("Invalid DC"));
902 wxMacFastPortSetter
helper(this) ;
903 wxCoord x1
, x2
, y1
, y2
;
904 if ( m_brush
.GetStyle() == wxTRANSPARENT
&& m_pen
.GetStyle() == wxTRANSPARENT
)
906 PolyHandle polygon
= OpenPoly();
907 x2
= x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
908 y2
= y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
910 for (int i
= 1; i
< n
; i
++)
912 x2
= XLOG2DEVMAC(points
[i
].x
+ xoffset
);
913 y2
= YLOG2DEVMAC(points
[i
].y
+ yoffset
);
916 // close the polyline if necessary
917 if ( x1
!= x2
|| y1
!= y2
)
922 if (m_brush
.GetStyle() != wxTRANSPARENT
)
925 ::PaintPoly( polygon
);
927 if (m_pen
.GetStyle() != wxTRANSPARENT
)
930 ::FramePoly( polygon
) ;
935 void wxDC::DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
937 wxCHECK_RET(Ok(), wxT("Invalid DC"));
938 wxMacFastPortSetter
helper(this) ;
939 wxCoord xx
= XLOG2DEVMAC(x
);
940 wxCoord yy
= YLOG2DEVMAC(y
);
941 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
942 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
943 // CMB: draw nothing if transformed w or h is 0
944 if (ww
== 0 || hh
== 0)
946 // CMB: handle -ve width and/or height
957 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
958 if (m_brush
.GetStyle() != wxTRANSPARENT
)
961 ::PaintRect( &rect
) ;
963 if (m_pen
.GetStyle() != wxTRANSPARENT
)
966 ::FrameRect( &rect
) ;
970 void wxDC::DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
971 wxCoord width
, wxCoord height
,
974 wxCHECK_RET(Ok(), wxT("Invalid DC"));
975 wxMacFastPortSetter
helper(this) ;
977 radius
= - radius
* ((width
< height
) ? width
: height
);
978 wxCoord xx
= XLOG2DEVMAC(x
);
979 wxCoord yy
= YLOG2DEVMAC(y
);
980 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
981 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
982 // CMB: draw nothing if transformed w or h is 0
983 if (ww
== 0 || hh
== 0)
985 // CMB: handle -ve width and/or height
996 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
997 if (m_brush
.GetStyle() != wxTRANSPARENT
)
1000 ::PaintRoundRect( &rect
, int(radius
* 2) , int(radius
* 2) ) ;
1002 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1005 ::FrameRoundRect( &rect
, int(radius
* 2) , int(radius
* 2) ) ;
1009 void wxDC::DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1011 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1012 wxMacFastPortSetter
helper(this) ;
1013 wxCoord xx
= XLOG2DEVMAC(x
);
1014 wxCoord yy
= YLOG2DEVMAC(y
);
1015 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1016 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1017 // CMB: draw nothing if transformed w or h is 0
1018 if (ww
== 0 || hh
== 0)
1020 // CMB: handle -ve width and/or height
1031 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
1032 if (m_brush
.GetStyle() != wxTRANSPARENT
)
1035 ::PaintOval( &rect
) ;
1037 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1040 ::FrameOval( &rect
) ;
1044 bool wxDC::CanDrawBitmap(void) const
1049 bool wxDC::DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1050 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
, int logical_func
, bool useMask
,
1051 wxCoord xsrcMask
, wxCoord ysrcMask
)
1053 wxCHECK_MSG(Ok(), false, wxT("wxDC::DoBlit Illegal dc"));
1054 wxCHECK_MSG(source
->Ok(), false, wxT("wxDC::DoBlit Illegal source DC"));
1055 if ( logical_func
== wxNO_OP
)
1057 if (xsrcMask
== -1 && ysrcMask
== -1)
1059 xsrcMask
= xsrc
; ysrcMask
= ysrc
;
1061 // correct the parameter in case this dc does not have a mask at all
1062 if ( useMask
&& !source
->m_macMask
)
1064 Rect srcrect
, dstrect
;
1065 srcrect
.top
= source
->YLOG2DEVMAC(ysrc
) ;
1066 srcrect
.left
= source
->XLOG2DEVMAC(xsrc
) ;
1067 srcrect
.right
= source
->XLOG2DEVMAC(xsrc
+ width
) ;
1068 srcrect
.bottom
= source
->YLOG2DEVMAC(ysrc
+ height
) ;
1069 dstrect
.top
= YLOG2DEVMAC(ydest
) ;
1070 dstrect
.left
= XLOG2DEVMAC(xdest
) ;
1071 dstrect
.bottom
= YLOG2DEVMAC(ydest
+ height
) ;
1072 dstrect
.right
= XLOG2DEVMAC(xdest
+ width
) ;
1073 short mode
= kUnsupportedMode
;
1074 bool invertDestinationFirst
= false ;
1075 switch ( logical_func
)
1077 case wxAND
: // src AND dst
1078 mode
= adMin
; // ok
1080 case wxAND_INVERT
: // (NOT src) AND dst
1081 mode
= notSrcOr
; // ok
1083 case wxAND_REVERSE
:// src AND (NOT dst)
1084 invertDestinationFirst
= true ;
1088 mode
= kEmulatedMode
;
1091 mode
= srcCopy
; // ok
1093 case wxEQUIV
: // (NOT src) XOR dst
1094 mode
= srcXor
; // ok
1096 case wxINVERT
: // NOT dst
1097 mode
= kEmulatedMode
; //or hilite ;
1099 case wxNAND
: // (NOT src) OR (NOT dst)
1100 invertDestinationFirst
= true ;
1103 case wxNOR
: // (NOT src) AND (NOT dst)
1104 invertDestinationFirst
= true ;
1107 case wxNO_OP
: // dst
1108 mode
= kEmulatedMode
; // this has already been handled upon entry
1110 case wxOR
: // src OR dst
1113 case wxOR_INVERT
: // (NOT src) OR dst
1116 case wxOR_REVERSE
: // src OR (NOT dst)
1117 invertDestinationFirst
= true ;
1121 mode
= kEmulatedMode
;
1123 case wxSRC_INVERT
: // (NOT src)
1124 mode
= notSrcCopy
; // ok
1126 case wxXOR
: // src XOR dst
1127 mode
= notSrcXor
; // ok
1132 if ( mode
== kUnsupportedMode
)
1134 wxFAIL_MSG(wxT("unsupported blitting mode" ));
1137 CGrafPtr sourcePort
= (CGrafPtr
) source
->m_macPort
;
1138 PixMapHandle bmappixels
= GetGWorldPixMap( sourcePort
) ;
1139 if ( LockPixels(bmappixels
) )
1141 wxMacFastPortSetter
helper(this) ;
1142 if ( source
->GetDepth() == 1 )
1144 RGBForeColor( &MAC_WXCOLORREF(m_textForegroundColour
.GetPixel()) ) ;
1145 RGBBackColor( &MAC_WXCOLORREF(m_textBackgroundColour
.GetPixel()) ) ;
1149 // the modes need this, otherwise we'll end up having really nice colors...
1150 RGBColor white
= { 0xFFFF, 0xFFFF,0xFFFF} ;
1151 RGBColor black
= { 0,0,0} ;
1152 RGBForeColor( &black
) ;
1153 RGBBackColor( &white
) ;
1155 if ( useMask
&& source
->m_macMask
)
1157 if ( mode
== srcCopy
)
1159 if ( LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) )
1161 CopyMask( GetPortBitMapForCopyBits( sourcePort
) ,
1162 GetPortBitMapForCopyBits( MAC_WXHBITMAP(source
->m_macMask
) ) ,
1163 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1164 &srcrect
, &srcrect
, &dstrect
) ;
1165 UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1170 RgnHandle clipRgn
= NewRgn() ;
1171 LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1172 BitMapToRegion( clipRgn
, (BitMap
*) *GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1173 UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1174 OffsetRgn( clipRgn
, -srcrect
.left
+ dstrect
.left
, -srcrect
.top
+ dstrect
.top
) ;
1175 if ( mode
== kEmulatedMode
)
1178 ::PenPat(GetQDGlobalsBlack(&pat
));
1179 if ( logical_func
== wxSET
)
1181 RGBColor col
= { 0xFFFF, 0xFFFF, 0xFFFF } ;
1182 ::RGBForeColor( &col
) ;
1183 ::PaintRgn( clipRgn
) ;
1185 else if ( logical_func
== wxCLEAR
)
1187 RGBColor col
= { 0x0000, 0x0000, 0x0000 } ;
1188 ::RGBForeColor( &col
) ;
1189 ::PaintRgn( clipRgn
) ;
1191 else if ( logical_func
== wxINVERT
)
1193 MacInvertRgn( clipRgn
) ;
1197 for ( int y
= 0 ; y
< srcrect
.right
- srcrect
.left
; ++y
)
1199 for ( int x
= 0 ; x
< srcrect
.bottom
- srcrect
.top
; ++x
)
1201 Point dstPoint
= { dstrect
.top
+ y
, dstrect
.left
+ x
} ;
1202 Point srcPoint
= { srcrect
.top
+ y
, srcrect
.left
+ x
} ;
1203 if ( PtInRgn( dstPoint
, clipRgn
) )
1207 SetPort( (GrafPtr
) sourcePort
) ;
1208 GetCPixel( srcPoint
.h
, srcPoint
.v
, &srcColor
) ;
1209 SetPort( (GrafPtr
) m_macPort
) ;
1210 GetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1211 wxMacCalculateColour( logical_func
, srcColor
, dstColor
) ;
1212 SetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1220 if ( invertDestinationFirst
)
1222 MacInvertRgn( clipRgn
) ;
1224 CopyBits( GetPortBitMapForCopyBits( sourcePort
) ,
1225 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1226 &srcrect
, &dstrect
, mode
, clipRgn
) ;
1228 DisposeRgn( clipRgn
) ;
1233 RgnHandle clipRgn
= NewRgn() ;
1234 SetRectRgn( clipRgn
, dstrect
.left
, dstrect
.top
, dstrect
.right
, dstrect
.bottom
) ;
1235 if ( mode
== kEmulatedMode
)
1238 ::PenPat(GetQDGlobalsBlack(&pat
));
1239 if ( logical_func
== wxSET
)
1241 RGBColor col
= { 0xFFFF, 0xFFFF, 0xFFFF } ;
1242 ::RGBForeColor( &col
) ;
1243 ::PaintRgn( clipRgn
) ;
1245 else if ( logical_func
== wxCLEAR
)
1247 RGBColor col
= { 0x0000, 0x0000, 0x0000 } ;
1248 ::RGBForeColor( &col
) ;
1249 ::PaintRgn( clipRgn
) ;
1251 else if ( logical_func
== wxINVERT
)
1253 MacInvertRgn( clipRgn
) ;
1257 for ( int y
= 0 ; y
< srcrect
.right
- srcrect
.left
; ++y
)
1259 for ( int x
= 0 ; x
< srcrect
.bottom
- srcrect
.top
; ++x
)
1261 Point dstPoint
= { dstrect
.top
+ y
, dstrect
.left
+ x
} ;
1262 Point srcPoint
= { srcrect
.top
+ y
, srcrect
.left
+ x
} ;
1266 SetPort( (GrafPtr
) sourcePort
) ;
1267 GetCPixel( srcPoint
.h
, srcPoint
.v
, &srcColor
) ;
1268 SetPort( (GrafPtr
) m_macPort
) ;
1269 GetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1270 wxMacCalculateColour( logical_func
, srcColor
, dstColor
) ;
1271 SetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1279 if ( invertDestinationFirst
)
1281 MacInvertRgn( clipRgn
) ;
1283 CopyBits( GetPortBitMapForCopyBits( sourcePort
) ,
1284 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1285 &srcrect
, &dstrect
, mode
, NULL
) ;
1287 DisposeRgn( clipRgn
) ;
1289 UnlockPixels( bmappixels
) ;
1291 m_macPenInstalled
= false ;
1292 m_macBrushInstalled
= false ;
1293 m_macFontInstalled
= false ;
1297 void wxDC::DoDrawRotatedText(const wxString
& str
, wxCoord x
, wxCoord y
,
1300 // TODO support text background color (only possible by hand, ATSUI does not support it)
1301 wxCHECK_RET( Ok(), wxT("wxDC::DoDrawRotatedText Invalid window dc") );
1303 if ( str
.Length() == 0 )
1306 wxMacFastPortSetter
helper(this) ;
1311 m_macFormerAliasState
= IsAntiAliasedTextEnabled(&m_macFormerAliasSize
);
1312 SetAntiAliasedTextEnabled(true, SInt16(m_scaleY
* m_font
.MacGetFontSize()));
1313 m_macAliasWasEnabled
= true ;
1315 OSStatus status
= noErr
;
1316 ATSUTextLayout atsuLayout
;
1317 UniCharCount chars
= str
.Length() ;
1318 UniChar
* ubuf
= NULL
;
1319 #if SIZEOF_WCHAR_T == 4
1320 wxMBConvUTF16BE converter
;
1322 size_t unicharlen
= converter
.WC2MB( NULL
, str
.wc_str() , 0 ) ;
1323 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1324 converter
.WC2MB( (char*) ubuf
, str
.wc_str(), unicharlen
+ 2 ) ;
1326 const wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1327 size_t unicharlen
= converter
.WC2MB( NULL
, wchar
.data() , 0 ) ;
1328 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1329 converter
.WC2MB( (char*) ubuf
, wchar
.data() , unicharlen
+ 2 ) ;
1331 chars
= unicharlen
/ 2 ;
1334 ubuf
= (UniChar
*) str
.wc_str() ;
1336 wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1337 chars
= wxWcslen( wchar
.data() ) ;
1338 ubuf
= (UniChar
*) wchar
.data() ;
1342 status
= ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr
) ubuf
, 0 , chars
, chars
, 1 ,
1343 &chars
, (ATSUStyle
*) &m_macATSUIStyle
, &atsuLayout
) ;
1345 wxASSERT_MSG( status
== noErr
, wxT("couldn't create the layout of the rotated text") );
1346 int iAngle
= int( angle
);
1347 int drawX
= XLOG2DEVMAC(x
) ;
1348 int drawY
= YLOG2DEVMAC(y
) ;
1350 ATSUTextMeasurement textBefore
;
1351 ATSUTextMeasurement textAfter
;
1352 ATSUTextMeasurement ascent
;
1353 ATSUTextMeasurement descent
;
1356 if ( abs(iAngle
) > 0 )
1358 Fixed atsuAngle
= IntToFixed( iAngle
) ;
1359 ATSUAttributeTag atsuTags
[] =
1361 kATSULineRotationTag
,
1363 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1367 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1371 status
= ::ATSUSetLayoutControls(atsuLayout
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
),
1372 atsuTags
, atsuSizes
, atsuValues
) ;
1374 status
= ::ATSUMeasureText( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1375 &textBefore
, &textAfter
, &ascent
, &descent
);
1377 drawX
+= (int)(sin(angle
/RAD2DEG
) * FixedToInt(ascent
));
1378 drawY
+= (int)(cos(angle
/RAD2DEG
) * FixedToInt(ascent
));
1379 status
= ::ATSUDrawText( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1380 IntToFixed(drawX
) , IntToFixed(drawY
) );
1381 wxASSERT_MSG( status
== noErr
, wxT("couldn't draw the rotated text") );
1383 status
= ::ATSUMeasureTextImage( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1384 IntToFixed(drawX
) , IntToFixed(drawY
) , &rect
);
1385 wxASSERT_MSG( status
== noErr
, wxT("couldn't measure the rotated text") );
1386 OffsetRect( &rect
, -m_macLocalOrigin
.x
, -m_macLocalOrigin
.y
) ;
1387 CalcBoundingBox(XDEV2LOG(rect
.left
), YDEV2LOG(rect
.top
) );
1388 CalcBoundingBox(XDEV2LOG(rect
.right
), YDEV2LOG(rect
.bottom
) );
1389 ::ATSUDisposeTextLayout(atsuLayout
);
1390 #if SIZEOF_WCHAR_T == 4
1395 void wxDC::DoDrawText(const wxString
& strtext
, wxCoord x
, wxCoord y
)
1397 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawText Invalid DC"));
1399 wxMacFastPortSetter
helper(this) ;
1400 long xx
= XLOG2DEVMAC(x
);
1401 long yy
= YLOG2DEVMAC(y
);
1403 bool useDrawThemeText
= ( DrawThemeTextBox
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1404 if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC
) ) || m_font
.GetNoAntiAliasing() )
1405 useDrawThemeText
= false ;
1410 ::GetFontInfo( &fi
) ;
1412 if ( !useDrawThemeText
)
1415 ::MoveTo( xx
, yy
);
1416 if ( m_backgroundMode
== wxTRANSPARENT
)
1418 ::TextMode( srcOr
) ;
1422 ::TextMode( srcCopy
) ;
1426 wxString linetext
= strtext
;
1428 if ( useDrawThemeText
)
1430 Rect frame
= { yy
+ line
*(fi
.descent
+ fi
.ascent
+ fi
.leading
) ,xx
, yy
+ (line
+1)*(fi
.descent
+ fi
.ascent
+ fi
.leading
) , xx
+ 10000 } ;
1431 wxMacCFStringHolder
mString( linetext
, m_font
.GetEncoding()) ;
1433 if ( m_backgroundMode
!= wxTRANSPARENT
)
1435 Point bounds
={0,0} ;
1436 Rect background
= frame
;
1438 ::GetThemeTextDimensions( mString
,
1439 m_font
.MacGetThemeFontID() ,
1444 background
.right
= background
.left
+ bounds
.h
;
1445 background
.bottom
= background
.top
+ bounds
.v
;
1446 ::EraseRect( &background
) ;
1448 ::DrawThemeTextBox( mString
,
1449 m_font
.MacGetThemeFontID() ,
1459 wxCharBuffer text
= linetext
.mb_str(wxConvLocal
) ;
1460 ::DrawText( text
, 0 , strlen(text
) ) ;
1463 ::TextMode( srcOr
) ;
1466 bool wxDC::CanGetTextExtent() const
1468 wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
1472 void wxDC::DoGetTextExtent( const wxString
&strtext
, wxCoord
*width
, wxCoord
*height
,
1473 wxCoord
*descent
, wxCoord
*externalLeading
,
1474 wxFont
*theFont
) const
1476 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1477 wxMacFastPortSetter
helper(this) ;
1478 wxFont formerFont
= m_font
;
1481 // work around the constness
1482 *((wxFont
*)(&m_font
)) = *theFont
;
1486 ::GetFontInfo( &fi
) ;
1488 bool useGetThemeText
= ( GetThemeTextDimensions
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1489 if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC
) ) || ((wxFont
*)&m_font
)->GetNoAntiAliasing() )
1490 useGetThemeText
= false ;
1493 *height
= YDEV2LOGREL( fi
.descent
+ fi
.ascent
) ;
1495 *descent
=YDEV2LOGREL( fi
.descent
);
1496 if ( externalLeading
)
1497 *externalLeading
= YDEV2LOGREL( fi
.leading
) ;
1503 wxString linetext
= strtext
;
1505 if ( useGetThemeText
)
1507 Point bounds
={0,0} ;
1509 wxMacCFStringHolder
mString( linetext
, m_font
.GetEncoding() ) ;
1510 ThemeFontID themeFont
= m_font
.MacGetThemeFontID() ;
1511 ::GetThemeTextDimensions( mString
,
1517 curwidth
= bounds
.h
;
1521 wxCharBuffer text
= linetext
.mb_str(wxConvLocal
) ;
1522 curwidth
= ::TextWidth( text
, 0 , strlen(text
) ) ;
1524 if ( curwidth
> *width
)
1525 *width
= XDEV2LOGREL( curwidth
) ;
1529 // work around the constness
1530 *((wxFont
*)(&m_font
)) = formerFont
;
1531 m_macFontInstalled
= false ;
1536 bool wxDC::DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
1538 wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
1541 widths
.Add(0, text
.Length());
1543 if (text
.Length() == 0)
1546 wxMacFastPortSetter
helper(this) ;
1549 bool useGetThemeText
= ( GetThemeTextDimensions
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1550 if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC
) ) || ((wxFont
*)&m_font
)->GetNoAntiAliasing() )
1551 useGetThemeText
= false ;
1553 if ( useGetThemeText
)
1555 // If anybody knows how to do this more efficiently yet still handle
1556 // the fractional glyph widths that may be present when using AA
1557 // fonts, please change it. Currently it is measuring from the
1558 // begining of the string for each succeding substring, which is much
1559 // slower than this should be.
1560 for (size_t i
=0; i
<text
.Length(); i
++)
1562 wxString
str(text
.Left(i
+1));
1563 Point bounds
= {0,0};
1565 wxMacCFStringHolder
mString(str
, m_font
.GetEncoding());
1566 ::GetThemeTextDimensions( mString
,
1567 m_font
.MacGetThemeFontID(),
1572 widths
[i
] = XDEV2LOGREL(bounds
.h
);
1578 wxCharBuffer buff
= text
.mb_str(wxConvLocal
);
1579 size_t len
= strlen(buff
);
1580 short* measurements
= new short[len
+1];
1581 MeasureText(len
, buff
.data(), measurements
);
1583 // Copy to widths, starting at measurements[1]
1584 // NOTE: this doesn't take into account any multi-byte characters
1585 // in buff, it probabkly should...
1586 for (size_t i
=0; i
<text
.Length(); i
++)
1587 widths
[i
] = XDEV2LOGREL(measurements
[i
+1]);
1589 delete [] measurements
;
1597 wxCoord
wxDC::GetCharWidth(void) const
1599 wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
1600 wxMacFastPortSetter
helper(this) ;
1604 bool useGetThemeText
= ( GetThemeTextDimensions
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1605 if ( UMAGetSystemVersion() < 0x1000 || ((wxFont
*)&m_font
)->GetNoAntiAliasing() )
1606 useGetThemeText
= false ;
1610 if ( useGetThemeText
)
1612 Point bounds
={0,0} ;
1614 CFStringRef mString
= CFStringCreateWithBytes( NULL
, (UInt8
*) text
, 1 , CFStringGetSystemEncoding(), false ) ;
1615 ::GetThemeTextDimensions( mString
,
1616 m_font
.MacGetThemeFontID(),
1621 CFRelease( mString
) ;
1627 width
= ::TextWidth( text
, 0 , 1 ) ;
1629 return YDEV2LOGREL(width
) ;
1632 wxCoord
wxDC::GetCharHeight(void) const
1634 wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
1635 wxMacFastPortSetter
helper(this) ;
1638 ::GetFontInfo( &fi
) ;
1639 return YDEV2LOGREL( fi
.descent
+ fi
.ascent
);
1642 void wxDC::Clear(void)
1644 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1645 wxMacFastPortSetter
helper(this) ;
1646 Rect rect
= { -31000 , -31000 , 31000 , 31000 } ;
1647 if ( m_backgroundBrush
.Ok() && m_backgroundBrush
.GetStyle() != wxTRANSPARENT
)
1650 MacSetupBackgroundForCurrentPort( m_backgroundBrush
) ;
1651 ::EraseRect( &rect
) ;
1655 void wxDC::MacInstallFont() const
1657 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1658 // if ( m_macFontInstalled )
1660 Pattern blackColor
;
1661 MacSetupBackgroundForCurrentPort(m_backgroundBrush
) ;
1662 if ( m_backgroundMode
!= wxTRANSPARENT
)
1664 Pattern whiteColor
;
1665 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
1668 wxASSERT( m_font
.Ok() ) ;
1671 ::TextFont( m_font
.MacGetFontNum() ) ;
1672 ::TextSize( (short)(m_scaleY
* m_font
.MacGetFontSize()) ) ;
1673 ::TextFace( m_font
.MacGetFontStyle() ) ;
1674 m_macFontInstalled
= true ;
1675 m_macBrushInstalled
= false ;
1676 m_macPenInstalled
= false ;
1677 RGBColor forecolor
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel());
1678 RGBColor backcolor
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel());
1679 ::RGBForeColor( &forecolor
);
1680 ::RGBBackColor( &backcolor
);
1682 short mode
= patCopy
;
1684 switch( m_logicalFunction
)
1689 case wxINVERT
: // NOT dst
1690 ::PenPat(GetQDGlobalsBlack(&blackColor
));
1693 case wxXOR
: // src XOR dst
1696 case wxOR_REVERSE
: // src OR (NOT dst)
1699 case wxSRC_INVERT
: // (NOT src)
1702 case wxAND
: // src AND dst
1707 case wxAND_REVERSE
:// src AND (NOT dst)
1708 case wxAND_INVERT
: // (NOT src) AND dst
1709 case wxNO_OP
: // dst
1710 case wxNOR
: // (NOT src) AND (NOT dst)
1711 case wxEQUIV
: // (NOT src) XOR dst
1712 case wxOR_INVERT
: // (NOT src) OR dst
1713 case wxNAND
: // (NOT src) OR (NOT dst)
1714 case wxOR
: // src OR dst
1716 // case wxSRC_OR: // source _bitmap_ OR destination
1717 // case wxSRC_AND: // source _bitmap_ AND destination
1721 OSStatus status
= noErr
;
1722 status
= ATSUCreateAndCopyStyle( (ATSUStyle
) m_font
.MacGetATSUStyle() , (ATSUStyle
*) &m_macATSUIStyle
) ;
1723 wxASSERT_MSG( status
== noErr
, wxT("couldn't set create ATSU style") ) ;
1725 Fixed atsuSize
= IntToFixed( int(m_scaleY
* m_font
.MacGetFontSize()) ) ;
1726 ATSUAttributeTag atsuTags
[] =
1730 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1734 // Boolean kTrue = true ;
1735 // Boolean kFalse = false ;
1737 // ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal;
1738 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1742 status
= ::ATSUSetAttributes((ATSUStyle
)m_macATSUIStyle
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
) ,
1743 atsuTags
, atsuSizes
, atsuValues
);
1745 wxASSERT_MSG( status
== noErr
, wxT("couldn't Modify ATSU style") ) ;
1749 Pattern gPatterns
[] =
1751 { { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF } } ,
1752 { { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 } } ,
1753 { { 0x80 , 0x40 , 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , 0x01 } } ,
1754 { { 0x10 , 0x10 , 0x10 , 0xFF , 0x10 , 0x10 , 0x10 , 0x10 } } ,
1755 { { 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 } } ,
1756 { { 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 } } ,
1757 { { 0x81 , 0x42 , 0x24 , 0x18 , 0x18 , 0x24 , 0x42 , 0x81 } } ,
1759 { { 0xCC , 0x99 , 0x33 , 0x66 , 0xCC , 0x99 , 0x33 , 0x66 } } , // DOT
1760 { { 0xFE , 0xFD , 0xFB , 0xF7 , 0xEF , 0xDF , 0xBF , 0x7F } } , // LONG_DASH
1761 { { 0xEE , 0xDD , 0xBB , 0x77 , 0xEE , 0xDD , 0xBB , 0x77 } } , // SHORT_DASH
1762 { { 0xDE , 0xBD , 0x7B , 0xF6 , 0xED , 0xDB , 0xB7 , 0x6F } } , // DOT_DASH
1765 static void wxMacGetPattern(int penStyle
, Pattern
*pattern
)
1767 int index
= 0; // solid pattern by default
1771 case wxBDIAGONAL_HATCH
: index
= 1; break;
1772 case wxFDIAGONAL_HATCH
: index
= 2; break;
1773 case wxCROSS_HATCH
: index
= 3; break;
1774 case wxHORIZONTAL_HATCH
: index
= 4; break;
1775 case wxVERTICAL_HATCH
: index
= 5; break;
1776 case wxCROSSDIAG_HATCH
: index
= 6; break;
1778 case wxDOT
: index
= 7; break;
1779 case wxLONG_DASH
: index
= 8; break;
1780 case wxSHORT_DASH
: index
= 9; break;
1781 case wxDOT_DASH
: index
= 10; break;
1783 *pattern
= gPatterns
[index
];
1786 void wxDC::MacInstallPen() const
1788 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1789 //Pattern blackColor;
1790 // if ( m_macPenInstalled )
1792 RGBColor forecolor
= MAC_WXCOLORREF( m_pen
.GetColour().GetPixel());
1793 RGBColor backcolor
= MAC_WXCOLORREF( m_backgroundBrush
.GetColour().GetPixel());
1794 ::RGBForeColor( &forecolor
);
1795 ::RGBBackColor( &backcolor
);
1797 int penWidth
= (int) (m_pen
.GetWidth() * m_scaleX
) ; ;
1798 // null means only one pixel, at whatever resolution
1799 if ( penWidth
== 0 )
1801 ::PenSize(penWidth
, penWidth
);
1803 int penStyle
= m_pen
.GetStyle();
1805 if (penStyle
== wxUSER_DASH
)
1807 // FIXME: there should be exactly 8 items in the dash
1809 int number
= m_pen
.GetDashes(&dash
) ;
1811 for ( int i
= 0 ; i
< 8 ; ++i
)
1813 pat
.pat
[i
] = dash
[index
] ;
1814 if (index
< number
- 1)
1820 wxMacGetPattern(penStyle
, &pat
);
1824 short mode
= patCopy
;
1826 switch( m_logicalFunction
)
1828 case wxCOPY
: // only foreground color, leave background (thus not patCopy)
1831 case wxINVERT
: // NOT dst
1832 // ::PenPat(GetQDGlobalsBlack(&blackColor));
1835 case wxXOR
: // src XOR dst
1838 case wxOR_REVERSE
: // src OR (NOT dst)
1841 case wxSRC_INVERT
: // (NOT src)
1844 case wxAND
: // src AND dst
1849 case wxAND_REVERSE
:// src AND (NOT dst)
1850 case wxAND_INVERT
: // (NOT src) AND dst
1851 case wxNO_OP
: // dst
1852 case wxNOR
: // (NOT src) AND (NOT dst)
1853 case wxEQUIV
: // (NOT src) XOR dst
1854 case wxOR_INVERT
: // (NOT src) OR dst
1855 case wxNAND
: // (NOT src) OR (NOT dst)
1856 case wxOR
: // src OR dst
1858 // case wxSRC_OR: // source _bitmap_ OR destination
1859 // case wxSRC_AND: // source _bitmap_ AND destination
1863 m_macPenInstalled
= true ;
1864 m_macBrushInstalled
= false ;
1865 m_macFontInstalled
= false ;
1868 void wxDC::MacSetupBackgroundForCurrentPort(const wxBrush
& background
)
1870 Pattern whiteColor
;
1871 if ( background
.Ok() )
1873 switch( background
.MacGetBrushKind() )
1875 case kwxMacBrushTheme
:
1877 ::SetThemeBackground( background
.MacGetTheme() , wxDisplayDepth() , true ) ;
1880 case kwxMacBrushThemeBackground
:
1883 ThemeBackgroundKind bg
= background
.MacGetThemeBackground( &extent
) ;
1884 ::ApplyThemeBackground( bg
, &extent
,kThemeStateActive
, wxDisplayDepth() , true ) ;
1887 case kwxMacBrushColour
:
1889 ::RGBBackColor( &MAC_WXCOLORREF( background
.GetColour().GetPixel()) );
1890 int brushStyle
= background
.GetStyle();
1891 if (brushStyle
== wxSOLID
)
1892 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
1893 else if (background
.IsHatch())
1896 wxMacGetPattern(brushStyle
, &pat
);
1901 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
1909 void wxDC::MacInstallBrush() const
1911 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1912 Pattern blackColor
;
1913 // if ( m_macBrushInstalled )
1916 bool backgroundTransparent
= (GetBackgroundMode() == wxTRANSPARENT
) ;
1917 ::RGBForeColor( &MAC_WXCOLORREF( m_brush
.GetColour().GetPixel()) );
1918 ::RGBBackColor( &MAC_WXCOLORREF( m_backgroundBrush
.GetColour().GetPixel()) );
1919 int brushStyle
= m_brush
.GetStyle();
1920 if (brushStyle
== wxSOLID
)
1922 ::PenPat(GetQDGlobalsBlack(&blackColor
));
1924 else if (m_brush
.IsHatch())
1927 wxMacGetPattern(brushStyle
, &pat
);
1930 else if ( m_brush
.GetStyle() == wxSTIPPLE
|| m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
)
1932 // we force this in order to be compliant with wxMSW
1933 backgroundTransparent
= false ;
1934 // for these the text fore (and back for MASK_OPAQUE) colors are used
1935 wxBitmap
* bitmap
= m_brush
.GetStipple() ;
1936 int width
= bitmap
->GetWidth() ;
1937 int height
= bitmap
->GetHeight() ;
1938 GWorldPtr gw
= NULL
;
1939 if ( m_brush
.GetStyle() == wxSTIPPLE
)
1940 gw
= MAC_WXHBITMAP(bitmap
->GetHBITMAP(NULL
)) ;
1942 gw
= MAC_WXHBITMAP(bitmap
->GetMask()->GetHBITMAP()) ;
1943 PixMapHandle gwpixmaphandle
= GetGWorldPixMap( gw
) ;
1944 LockPixels( gwpixmaphandle
) ;
1945 bool isMonochrome
= !IsPortColor( gw
) ;
1946 if ( !isMonochrome
)
1948 if ( (**gwpixmaphandle
).pixelSize
== 1 )
1949 isMonochrome
= true ;
1951 if ( isMonochrome
&& width
== 8 && height
== 8 )
1953 ::RGBForeColor( &MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) );
1954 ::RGBForeColor( &MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) );
1955 BitMap
* gwbitmap
= (BitMap
*) *gwpixmaphandle
; // since the color depth is 1 it is a BitMap
1956 UInt8
*gwbits
= (UInt8
*) gwbitmap
->baseAddr
;
1957 int alignment
= gwbitmap
->rowBytes
& 0x7FFF ;
1959 for ( int i
= 0 ; i
< 8 ; ++i
)
1961 pat
.pat
[i
] = gwbits
[i
*alignment
+0] ;
1963 UnlockPixels( GetGWorldPixMap( gw
) ) ;
1968 // this will be the code to handle power of 2 patterns, we will have to arrive at a nice
1969 // caching scheme before putting this into production
1972 PixPatHandle pixpat
= NewPixPat() ;
1973 CopyPixMap(gwpixmaphandle
, (**pixpat
).patMap
);
1974 imageSize
= GetPixRowBytes((**pixpat
).patMap
) *
1975 ((**(**pixpat
).patMap
).bounds
.bottom
-
1976 (**(**pixpat
).patMap
).bounds
.top
);
1977 PtrToHand( (**gwpixmaphandle
).baseAddr
, &image
, imageSize
);
1978 (**pixpat
).patData
= image
;
1981 CTabHandle ctable
= ((**((**pixpat
).patMap
)).pmTable
) ;
1982 ColorSpecPtr ctspec
= (ColorSpecPtr
) &(**ctable
).ctTable
;
1983 if ( ctspec
[0].rgb
.red
== 0x0000 )
1985 ctspec
[1].rgb
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) ;
1986 ctspec
[0].rgb
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) ;
1990 ctspec
[0].rgb
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) ;
1991 ctspec
[1].rgb
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) ;
1993 ::CTabChanged( ctable
) ;
1995 ::PenPixPat(pixpat
);
1996 m_macForegroundPixMap
= pixpat
;
1998 UnlockPixels( gwpixmaphandle
) ;
2002 ::PenPat(GetQDGlobalsBlack(&blackColor
));
2004 short mode
= patCopy
;
2005 switch( m_logicalFunction
)
2008 if ( backgroundTransparent
)
2013 case wxINVERT
: // NOT dst
2014 if ( !backgroundTransparent
)
2016 ::PenPat(GetQDGlobalsBlack(&blackColor
));
2020 case wxXOR
: // src XOR dst
2023 case wxOR_REVERSE
: // src OR (NOT dst)
2026 case wxSRC_INVERT
: // (NOT src)
2029 case wxAND
: // src AND dst
2034 case wxAND_REVERSE
:// src AND (NOT dst)
2035 case wxAND_INVERT
: // (NOT src) AND dst
2036 case wxNO_OP
: // dst
2037 case wxNOR
: // (NOT src) AND (NOT dst)
2038 case wxEQUIV
: // (NOT src) XOR dst
2039 case wxOR_INVERT
: // (NOT src) OR dst
2040 case wxNAND
: // (NOT src) OR (NOT dst)
2041 case wxOR
: // src OR dst
2043 // case wxSRC_OR: // source _bitmap_ OR destination
2044 // case wxSRC_AND: // source _bitmap_ AND destination
2048 m_macBrushInstalled
= true ;
2049 m_macPenInstalled
= false ;
2050 m_macFontInstalled
= false ;
2053 // ---------------------------------------------------------------------------
2054 // coordinates transformations
2055 // ---------------------------------------------------------------------------
2057 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
2059 return ((wxDC
*)this)->XDEV2LOG(x
);
2062 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
2064 return ((wxDC
*)this)->YDEV2LOG(y
);
2067 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
2069 return ((wxDC
*)this)->XDEV2LOGREL(x
);
2072 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
2074 return ((wxDC
*)this)->YDEV2LOGREL(y
);
2077 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
2079 return ((wxDC
*)this)->XLOG2DEV(x
);
2082 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
2084 return ((wxDC
*)this)->YLOG2DEV(y
);
2087 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
2089 return ((wxDC
*)this)->XLOG2DEVREL(x
);
2092 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
2094 return ((wxDC
*)this)->YLOG2DEVREL(y
);
2097 #endif // !wxMAC_USE_CORE_GRAPHICS