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
);
421 wxCoord w
= icon
.GetWidth();
422 wxCoord h
= icon
.GetHeight();
423 wxCoord ww
= XLOG2DEVREL(w
);
424 wxCoord hh
= YLOG2DEVREL(h
);
426 Rect r
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
427 PlotIconRef( &r
, kAlignNone
, kTransformNone
, kPlotIconRefNormalFlags
, MAC_WXHICON( icon
.GetHICON() ) ) ;
430 void wxDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
432 wxCHECK_RET(Ok(), wxT("wxDC::DoSetClippingRegion Invalid DC"));
433 wxCoord xx
, yy
, ww
, hh
;
436 ww
= XLOG2DEVREL(width
);
437 hh
= YLOG2DEVREL(height
);
438 SetRectRgn( (RgnHandle
) m_macCurrentClipRgn
, xx
, yy
, xx
+ ww
, yy
+ hh
) ;
439 SectRgn( (RgnHandle
) m_macCurrentClipRgn
, (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
442 m_clipX1
= wxMax( m_clipX1
, xx
);
443 m_clipY1
= wxMax( m_clipY1
, yy
);
444 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
));
445 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
));
457 void wxDC::DoSetClippingRegionAsRegion( const wxRegion
®ion
)
459 wxCHECK_RET( Ok(), wxT("invalid window dc") ) ;
462 DestroyClippingRegion();
465 wxMacFastPortSetter
helper(this) ;
467 region
.GetBox( x
, y
, w
, h
);
468 wxCoord xx
, yy
, ww
, hh
;
473 // if we have a scaling that we cannot map onto native regions
474 // we must use the box
475 if ( ww
!= w
|| hh
!= h
)
477 wxDC::DoSetClippingRegion( x
, y
, w
, h
);
481 CopyRgn( (RgnHandle
) region
.GetWXHRGN() , (RgnHandle
) m_macCurrentClipRgn
) ;
482 if ( xx
!= x
|| yy
!= y
)
484 OffsetRgn( (RgnHandle
) m_macCurrentClipRgn
, xx
- x
, yy
- y
) ;
486 SectRgn( (RgnHandle
) m_macCurrentClipRgn
, (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
489 m_clipX1
= wxMax( m_clipX1
, xx
);
490 m_clipY1
= wxMax( m_clipY1
, yy
);
491 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
));
492 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
));
505 void wxDC::DestroyClippingRegion()
507 wxMacFastPortSetter
helper(this) ;
508 CopyRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
512 void wxDC::DoGetSizeMM( int* width
, int* height
) const
517 *width
= long( double(w
) / (m_scaleX
*m_mm_to_pix_x
) );
518 *height
= long( double(h
) / (m_scaleY
*m_mm_to_pix_y
) );
521 void wxDC::SetTextForeground( const wxColour
&col
)
523 wxCHECK_RET(Ok(), wxT("Invalid DC"));
524 m_textForegroundColour
= col
;
525 m_macFontInstalled
= false ;
528 void wxDC::SetTextBackground( const wxColour
&col
)
530 wxCHECK_RET(Ok(), wxT("Invalid DC"));
531 m_textBackgroundColour
= col
;
532 m_macFontInstalled
= false ;
535 void wxDC::SetMapMode( int mode
)
540 SetLogicalScale( twips2mm
*m_mm_to_pix_x
, twips2mm
*m_mm_to_pix_y
);
543 SetLogicalScale( pt2mm
*m_mm_to_pix_x
, pt2mm
*m_mm_to_pix_y
);
546 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
549 SetLogicalScale( m_mm_to_pix_x
/10.0, m_mm_to_pix_y
/10.0 );
553 SetLogicalScale( 1.0, 1.0 );
556 if (mode
!= wxMM_TEXT
)
558 m_needComputeScaleX
= true;
559 m_needComputeScaleY
= true;
563 void wxDC::SetUserScale( double x
, double y
)
565 // allow negative ? -> no
568 ComputeScaleAndOrigin();
571 void wxDC::SetLogicalScale( double x
, double y
)
576 ComputeScaleAndOrigin();
579 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
581 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
582 m_logicalOriginY
= y
* m_signY
;
583 ComputeScaleAndOrigin();
586 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
588 m_externalDeviceOriginX
= x
;
589 m_externalDeviceOriginY
= y
;
590 ComputeScaleAndOrigin();
593 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
595 m_signX
= (xLeftRight
? 1 : -1);
596 m_signY
= (yBottomUp
? -1 : 1);
597 ComputeScaleAndOrigin();
600 wxSize
wxDC::GetPPI() const
602 return wxSize(72, 72);
605 int wxDC::GetDepth() const
607 if ( IsPortColor( (CGrafPtr
) m_macPort
) )
609 return ( (**GetPortPixMap( (CGrafPtr
) m_macPort
)).pixelSize
) ;
614 void wxDC::ComputeScaleAndOrigin()
616 // CMB: copy scale to see if it changes
617 double origScaleX
= m_scaleX
;
618 double origScaleY
= m_scaleY
;
619 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
620 m_scaleY
= m_logicalScaleY
* m_userScaleY
;
621 m_deviceOriginX
= m_internalDeviceOriginX
+ m_externalDeviceOriginX
;
622 m_deviceOriginY
= m_internalDeviceOriginY
+ m_externalDeviceOriginY
;
623 // CMB: if scale has changed call SetPen to recalulate the line width
624 if (m_scaleX
!= origScaleX
|| m_scaleY
!= origScaleY
)
626 // this is a bit artificial, but we need to force wxDC to think
627 // the pen has changed
634 void wxDC::SetPalette( const wxPalette
& palette
)
638 void wxDC::SetBackgroundMode( int mode
)
640 m_backgroundMode
= mode
;
643 void wxDC::SetFont( const wxFont
&font
)
646 m_macFontInstalled
= false ;
649 void wxDC::SetPen( const wxPen
&pen
)
654 m_macPenInstalled
= false ;
657 void wxDC::SetBrush( const wxBrush
&brush
)
659 if (m_brush
== brush
)
662 m_macBrushInstalled
= false ;
665 void wxDC::SetBackground( const wxBrush
&brush
)
667 if (m_backgroundBrush
== brush
)
669 m_backgroundBrush
= brush
;
670 if (!m_backgroundBrush
.Ok())
672 m_macBrushInstalled
= false ;
675 void wxDC::SetLogicalFunction( int function
)
677 if (m_logicalFunction
== function
)
679 m_logicalFunction
= function
;
680 m_macFontInstalled
= false ;
681 m_macBrushInstalled
= false ;
682 m_macPenInstalled
= false ;
685 extern bool wxDoFloodFill(wxDC
*dc
, wxCoord x
, wxCoord y
,
686 const wxColour
& col
, int style
);
688 bool wxDC::DoFloodFill(wxCoord x
, wxCoord y
,
689 const wxColour
& col
, int style
)
691 return wxDoFloodFill(this, x
, y
, col
, style
);
694 bool wxDC::DoGetPixel( wxCoord x
, wxCoord y
, wxColour
*col
) const
696 wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel Invalid DC") );
697 wxMacFastPortSetter
helper(this) ;
699 GetCPixel( XLOG2DEVMAC(x
), YLOG2DEVMAC(y
), &colour
);
700 // Convert from Mac colour to wx
701 col
->Set( colour
.red
>> 8,
707 void wxDC::DoDrawLine( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
709 wxCHECK_RET(Ok(), wxT("Invalid DC"));
710 wxMacFastPortSetter
helper(this) ;
711 if (m_pen
.GetStyle() != wxTRANSPARENT
)
714 wxCoord offset
= ( (m_pen
.GetWidth() == 0 ? 1 :
715 m_pen
.GetWidth() ) * (wxCoord
)m_scaleX
- 1) / 2;
716 wxCoord xx1
= XLOG2DEVMAC(x1
) - offset
;
717 wxCoord yy1
= YLOG2DEVMAC(y1
) - offset
;
718 wxCoord xx2
= XLOG2DEVMAC(x2
) - offset
;
719 wxCoord yy2
= YLOG2DEVMAC(y2
) - offset
;
720 if ((m_pen
.GetCap() == wxCAP_ROUND
) &&
721 (m_pen
.GetWidth() <= 1))
723 // Implement LAST_NOT for MAC at least for
724 // orthogonal lines. RR.
745 void wxDC::DoCrossHair( wxCoord x
, wxCoord y
)
747 wxCHECK_RET( Ok(), wxT("wxDC::DoCrossHair Invalid window dc") );
748 wxMacFastPortSetter
helper(this) ;
749 if (m_pen
.GetStyle() != wxTRANSPARENT
)
754 wxCoord xx
= XLOG2DEVMAC(x
);
755 wxCoord yy
= YLOG2DEVMAC(y
);
757 ::MoveTo( XLOG2DEVMAC(0), yy
);
758 ::LineTo( XLOG2DEVMAC(w
), yy
);
759 ::MoveTo( xx
, YLOG2DEVMAC(0) );
760 ::LineTo( xx
, YLOG2DEVMAC(h
) );
761 CalcBoundingBox(x
, y
);
762 CalcBoundingBox(x
+w
, y
+h
);
767 * To draw arcs properly the angles need to be converted from the WX style:
768 * Angles start on the +ve X axis and go anti-clockwise (As you would draw on
769 * a normal axis on paper).
772 * Angles start on the +ve y axis and go clockwise.
775 static double wxConvertWXangleToMACangle(double angle
)
777 double newAngle
= 90 - angle
;
778 while ( newAngle
> 360 ) newAngle
-= 360 ;
779 while ( newAngle
< 0 ) newAngle
+= 360 ;
783 void wxDC::DoDrawArc( wxCoord x1
, wxCoord y1
,
784 wxCoord x2
, wxCoord y2
,
785 wxCoord xc
, wxCoord yc
)
787 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawArc Invalid DC"));
788 wxMacFastPortSetter
helper(this) ;
789 wxCoord xx1
= XLOG2DEVMAC(x1
);
790 wxCoord yy1
= YLOG2DEVMAC(y1
);
791 wxCoord xx2
= XLOG2DEVMAC(x2
);
792 wxCoord yy2
= YLOG2DEVMAC(y2
);
793 wxCoord xxc
= XLOG2DEVMAC(xc
);
794 wxCoord yyc
= YLOG2DEVMAC(yc
);
795 double dx
= xx1
- xxc
;
796 double dy
= yy1
- yyc
;
797 double radius
= sqrt((double)(dx
*dx
+dy
*dy
));
798 wxCoord rad
= (wxCoord
)radius
;
799 double radius1
, radius2
;
800 if (xx1
== xx2
&& yy1
== yy2
)
805 else if (radius
== 0.0)
807 radius1
= radius2
= 0.0;
811 radius1
= (xx1
- xxc
== 0) ?
812 (yy1
- yyc
< 0) ? 90.0 : -90.0 :
813 -atan2(double(yy1
-yyc
), double(xx1
-xxc
)) * RAD2DEG
;
814 radius2
= (xx2
- xxc
== 0) ?
815 (yy2
- yyc
< 0) ? 90.0 : -90.0 :
816 -atan2(double(yy2
-yyc
), double(xx2
-xxc
)) * RAD2DEG
;
818 wxCoord alpha2
= wxCoord(radius2
- radius1
);
819 wxCoord alpha1
= wxCoord(wxConvertWXangleToMACangle(radius1
));
820 while( alpha2
< 0 ) alpha2
+= 360 ;
822 Rect r
= { yyc
- rad
, xxc
- rad
, yyc
+ rad
, xxc
+ rad
};
823 if(m_brush
.GetStyle() != wxTRANSPARENT
) {
825 PaintArc(&r
, alpha1
, alpha2
);
827 if(m_pen
.GetStyle() != wxTRANSPARENT
) {
829 FrameArc(&r
, alpha1
, alpha2
);
833 void wxDC::DoDrawEllipticArc( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
834 double sa
, double ea
)
836 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawEllepticArc Invalid DC"));
837 wxMacFastPortSetter
helper(this) ;
839 double angle
= sa
- ea
; // Order important Mac in opposite direction to wx
840 // we have to make sure that the filling is always counter-clockwise
843 wxCoord xx
= XLOG2DEVMAC(x
);
844 wxCoord yy
= YLOG2DEVMAC(y
);
845 wxCoord ww
= m_signX
* XLOG2DEVREL(w
);
846 wxCoord hh
= m_signY
* YLOG2DEVREL(h
);
847 // handle -ve width and/or height
848 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
849 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
850 sa
= wxConvertWXangleToMACangle(sa
);
855 if(m_brush
.GetStyle() != wxTRANSPARENT
) {
857 PaintArc(&r
, (short)sa
, (short)angle
);
859 if(m_pen
.GetStyle() != wxTRANSPARENT
) {
861 FrameArc(&r
, (short)sa
, (short)angle
);
865 void wxDC::DoDrawPoint( wxCoord x
, wxCoord y
)
867 wxCHECK_RET(Ok(), wxT("Invalid DC"));
868 wxMacFastPortSetter
helper(this) ;
869 if (m_pen
.GetStyle() != wxTRANSPARENT
)
871 wxCoord xx1
= XLOG2DEVMAC(x
);
872 wxCoord yy1
= YLOG2DEVMAC(y
);
873 RGBColor pencolor
= MAC_WXCOLORREF( m_pen
.GetColour().GetPixel());
874 ::SetCPixel( xx1
,yy1
,&pencolor
) ;
875 CalcBoundingBox(x
, y
);
879 void wxDC::DoDrawLines(int n
, wxPoint points
[],
880 wxCoord xoffset
, wxCoord yoffset
)
882 wxCHECK_RET(Ok(), wxT("Invalid DC"));
883 wxMacFastPortSetter
helper(this) ;
884 if (m_pen
.GetStyle() == wxTRANSPARENT
)
887 wxCoord offset
= ( (m_pen
.GetWidth() == 0 ? 1 :
888 m_pen
.GetWidth() ) * (wxCoord
)m_scaleX
- 1) / 2 ;
889 wxCoord x1
, x2
, y1
, y2
;
890 x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
891 y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
892 ::MoveTo(x1
- offset
, y1
- offset
);
893 for (int i
= 0; i
< n
-1; i
++)
895 x2
= XLOG2DEVMAC(points
[i
+1].x
+ xoffset
);
896 y2
= YLOG2DEVMAC(points
[i
+1].y
+ yoffset
);
897 ::LineTo( x2
- offset
, y2
- offset
);
901 void wxDC::DoDrawPolygon(int n
, wxPoint points
[],
902 wxCoord xoffset
, wxCoord yoffset
,
905 wxCHECK_RET(Ok(), wxT("Invalid DC"));
906 wxMacFastPortSetter
helper(this) ;
907 wxCoord x1
, x2
, y1
, y2
;
908 if ( m_brush
.GetStyle() == wxTRANSPARENT
&& m_pen
.GetStyle() == wxTRANSPARENT
)
910 PolyHandle polygon
= OpenPoly();
911 x2
= x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
912 y2
= y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
914 for (int i
= 1; i
< n
; i
++)
916 x2
= XLOG2DEVMAC(points
[i
].x
+ xoffset
);
917 y2
= YLOG2DEVMAC(points
[i
].y
+ yoffset
);
920 // close the polyline if necessary
921 if ( x1
!= x2
|| y1
!= y2
)
926 if (m_brush
.GetStyle() != wxTRANSPARENT
)
929 ::PaintPoly( polygon
);
931 if (m_pen
.GetStyle() != wxTRANSPARENT
)
934 ::FramePoly( polygon
) ;
939 void wxDC::DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
941 wxCHECK_RET(Ok(), wxT("Invalid DC"));
942 wxMacFastPortSetter
helper(this) ;
943 wxCoord xx
= XLOG2DEVMAC(x
);
944 wxCoord yy
= YLOG2DEVMAC(y
);
945 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
946 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
947 // CMB: draw nothing if transformed w or h is 0
948 if (ww
== 0 || hh
== 0)
950 // CMB: handle -ve width and/or height
961 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
962 if (m_brush
.GetStyle() != wxTRANSPARENT
)
965 ::PaintRect( &rect
) ;
967 if (m_pen
.GetStyle() != wxTRANSPARENT
)
970 ::FrameRect( &rect
) ;
974 void wxDC::DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
975 wxCoord width
, wxCoord height
,
978 wxCHECK_RET(Ok(), wxT("Invalid DC"));
979 wxMacFastPortSetter
helper(this) ;
981 radius
= - radius
* ((width
< height
) ? width
: height
);
982 wxCoord xx
= XLOG2DEVMAC(x
);
983 wxCoord yy
= YLOG2DEVMAC(y
);
984 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
985 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
986 // CMB: draw nothing if transformed w or h is 0
987 if (ww
== 0 || hh
== 0)
989 // CMB: handle -ve width and/or height
1000 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
1001 if (m_brush
.GetStyle() != wxTRANSPARENT
)
1004 ::PaintRoundRect( &rect
, int(radius
* 2) , int(radius
* 2) ) ;
1006 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1009 ::FrameRoundRect( &rect
, int(radius
* 2) , int(radius
* 2) ) ;
1013 void wxDC::DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1015 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1016 wxMacFastPortSetter
helper(this) ;
1017 wxCoord xx
= XLOG2DEVMAC(x
);
1018 wxCoord yy
= YLOG2DEVMAC(y
);
1019 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1020 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1021 // CMB: draw nothing if transformed w or h is 0
1022 if (ww
== 0 || hh
== 0)
1024 // CMB: handle -ve width and/or height
1035 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
1036 if (m_brush
.GetStyle() != wxTRANSPARENT
)
1039 ::PaintOval( &rect
) ;
1041 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1044 ::FrameOval( &rect
) ;
1048 bool wxDC::CanDrawBitmap(void) const
1053 bool wxDC::DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1054 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
, int logical_func
, bool useMask
,
1055 wxCoord xsrcMask
, wxCoord ysrcMask
)
1057 wxCHECK_MSG(Ok(), false, wxT("wxDC::DoBlit Illegal dc"));
1058 wxCHECK_MSG(source
->Ok(), false, wxT("wxDC::DoBlit Illegal source DC"));
1059 if ( logical_func
== wxNO_OP
)
1061 if (xsrcMask
== -1 && ysrcMask
== -1)
1063 xsrcMask
= xsrc
; ysrcMask
= ysrc
;
1065 // correct the parameter in case this dc does not have a mask at all
1066 if ( useMask
&& !source
->m_macMask
)
1068 Rect srcrect
, dstrect
;
1069 srcrect
.top
= source
->YLOG2DEVMAC(ysrc
) ;
1070 srcrect
.left
= source
->XLOG2DEVMAC(xsrc
) ;
1071 srcrect
.right
= source
->XLOG2DEVMAC(xsrc
+ width
) ;
1072 srcrect
.bottom
= source
->YLOG2DEVMAC(ysrc
+ height
) ;
1073 dstrect
.top
= YLOG2DEVMAC(ydest
) ;
1074 dstrect
.left
= XLOG2DEVMAC(xdest
) ;
1075 dstrect
.bottom
= YLOG2DEVMAC(ydest
+ height
) ;
1076 dstrect
.right
= XLOG2DEVMAC(xdest
+ width
) ;
1077 short mode
= kUnsupportedMode
;
1078 bool invertDestinationFirst
= false ;
1079 switch ( logical_func
)
1081 case wxAND
: // src AND dst
1082 mode
= adMin
; // ok
1084 case wxAND_INVERT
: // (NOT src) AND dst
1085 mode
= notSrcOr
; // ok
1087 case wxAND_REVERSE
:// src AND (NOT dst)
1088 invertDestinationFirst
= true ;
1092 mode
= kEmulatedMode
;
1095 mode
= srcCopy
; // ok
1097 case wxEQUIV
: // (NOT src) XOR dst
1098 mode
= srcXor
; // ok
1100 case wxINVERT
: // NOT dst
1101 mode
= kEmulatedMode
; //or hilite ;
1103 case wxNAND
: // (NOT src) OR (NOT dst)
1104 invertDestinationFirst
= true ;
1107 case wxNOR
: // (NOT src) AND (NOT dst)
1108 invertDestinationFirst
= true ;
1111 case wxNO_OP
: // dst
1112 mode
= kEmulatedMode
; // this has already been handled upon entry
1114 case wxOR
: // src OR dst
1117 case wxOR_INVERT
: // (NOT src) OR dst
1120 case wxOR_REVERSE
: // src OR (NOT dst)
1121 invertDestinationFirst
= true ;
1125 mode
= kEmulatedMode
;
1127 case wxSRC_INVERT
: // (NOT src)
1128 mode
= notSrcCopy
; // ok
1130 case wxXOR
: // src XOR dst
1131 mode
= notSrcXor
; // ok
1136 if ( mode
== kUnsupportedMode
)
1138 wxFAIL_MSG(wxT("unsupported blitting mode" ));
1141 CGrafPtr sourcePort
= (CGrafPtr
) source
->m_macPort
;
1142 PixMapHandle bmappixels
= GetGWorldPixMap( sourcePort
) ;
1143 if ( LockPixels(bmappixels
) )
1145 wxMacFastPortSetter
helper(this) ;
1146 if ( source
->GetDepth() == 1 )
1148 RGBForeColor( &MAC_WXCOLORREF(m_textForegroundColour
.GetPixel()) ) ;
1149 RGBBackColor( &MAC_WXCOLORREF(m_textBackgroundColour
.GetPixel()) ) ;
1153 // the modes need this, otherwise we'll end up having really nice colors...
1154 RGBColor white
= { 0xFFFF, 0xFFFF,0xFFFF} ;
1155 RGBColor black
= { 0,0,0} ;
1156 RGBForeColor( &black
) ;
1157 RGBBackColor( &white
) ;
1159 if ( useMask
&& source
->m_macMask
)
1161 if ( mode
== srcCopy
)
1163 if ( LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) )
1165 CopyMask( GetPortBitMapForCopyBits( sourcePort
) ,
1166 GetPortBitMapForCopyBits( MAC_WXHBITMAP(source
->m_macMask
) ) ,
1167 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1168 &srcrect
, &srcrect
, &dstrect
) ;
1169 UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1174 RgnHandle clipRgn
= NewRgn() ;
1175 LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1176 BitMapToRegion( clipRgn
, (BitMap
*) *GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1177 UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1178 OffsetRgn( clipRgn
, -srcrect
.left
+ dstrect
.left
, -srcrect
.top
+ dstrect
.top
) ;
1179 if ( mode
== kEmulatedMode
)
1182 ::PenPat(GetQDGlobalsBlack(&pat
));
1183 if ( logical_func
== wxSET
)
1185 RGBColor col
= { 0xFFFF, 0xFFFF, 0xFFFF } ;
1186 ::RGBForeColor( &col
) ;
1187 ::PaintRgn( clipRgn
) ;
1189 else if ( logical_func
== wxCLEAR
)
1191 RGBColor col
= { 0x0000, 0x0000, 0x0000 } ;
1192 ::RGBForeColor( &col
) ;
1193 ::PaintRgn( clipRgn
) ;
1195 else if ( logical_func
== wxINVERT
)
1197 MacInvertRgn( clipRgn
) ;
1201 for ( int y
= 0 ; y
< srcrect
.right
- srcrect
.left
; ++y
)
1203 for ( int x
= 0 ; x
< srcrect
.bottom
- srcrect
.top
; ++x
)
1205 Point dstPoint
= { dstrect
.top
+ y
, dstrect
.left
+ x
} ;
1206 Point srcPoint
= { srcrect
.top
+ y
, srcrect
.left
+ x
} ;
1207 if ( PtInRgn( dstPoint
, clipRgn
) )
1211 SetPort( (GrafPtr
) sourcePort
) ;
1212 GetCPixel( srcPoint
.h
, srcPoint
.v
, &srcColor
) ;
1213 SetPort( (GrafPtr
) m_macPort
) ;
1214 GetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1215 wxMacCalculateColour( logical_func
, srcColor
, dstColor
) ;
1216 SetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1224 if ( invertDestinationFirst
)
1226 MacInvertRgn( clipRgn
) ;
1228 CopyBits( GetPortBitMapForCopyBits( sourcePort
) ,
1229 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1230 &srcrect
, &dstrect
, mode
, clipRgn
) ;
1232 DisposeRgn( clipRgn
) ;
1237 RgnHandle clipRgn
= NewRgn() ;
1238 SetRectRgn( clipRgn
, dstrect
.left
, dstrect
.top
, dstrect
.right
, dstrect
.bottom
) ;
1239 if ( mode
== kEmulatedMode
)
1242 ::PenPat(GetQDGlobalsBlack(&pat
));
1243 if ( logical_func
== wxSET
)
1245 RGBColor col
= { 0xFFFF, 0xFFFF, 0xFFFF } ;
1246 ::RGBForeColor( &col
) ;
1247 ::PaintRgn( clipRgn
) ;
1249 else if ( logical_func
== wxCLEAR
)
1251 RGBColor col
= { 0x0000, 0x0000, 0x0000 } ;
1252 ::RGBForeColor( &col
) ;
1253 ::PaintRgn( clipRgn
) ;
1255 else if ( logical_func
== wxINVERT
)
1257 MacInvertRgn( clipRgn
) ;
1261 for ( int y
= 0 ; y
< srcrect
.right
- srcrect
.left
; ++y
)
1263 for ( int x
= 0 ; x
< srcrect
.bottom
- srcrect
.top
; ++x
)
1265 Point dstPoint
= { dstrect
.top
+ y
, dstrect
.left
+ x
} ;
1266 Point srcPoint
= { srcrect
.top
+ y
, srcrect
.left
+ x
} ;
1270 SetPort( (GrafPtr
) sourcePort
) ;
1271 GetCPixel( srcPoint
.h
, srcPoint
.v
, &srcColor
) ;
1272 SetPort( (GrafPtr
) m_macPort
) ;
1273 GetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1274 wxMacCalculateColour( logical_func
, srcColor
, dstColor
) ;
1275 SetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1283 if ( invertDestinationFirst
)
1285 MacInvertRgn( clipRgn
) ;
1287 CopyBits( GetPortBitMapForCopyBits( sourcePort
) ,
1288 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1289 &srcrect
, &dstrect
, mode
, NULL
) ;
1291 DisposeRgn( clipRgn
) ;
1293 UnlockPixels( bmappixels
) ;
1295 m_macPenInstalled
= false ;
1296 m_macBrushInstalled
= false ;
1297 m_macFontInstalled
= false ;
1301 void wxDC::DoDrawRotatedText(const wxString
& str
, wxCoord x
, wxCoord y
,
1304 // TODO support text background color (only possible by hand, ATSUI does not support it)
1305 wxCHECK_RET( Ok(), wxT("wxDC::DoDrawRotatedText Invalid window dc") );
1307 if ( str
.Length() == 0 )
1310 wxMacFastPortSetter
helper(this) ;
1315 m_macFormerAliasState
= IsAntiAliasedTextEnabled(&m_macFormerAliasSize
);
1316 SetAntiAliasedTextEnabled(true, SInt16(m_scaleY
* m_font
.MacGetFontSize()));
1317 m_macAliasWasEnabled
= true ;
1319 OSStatus status
= noErr
;
1320 ATSUTextLayout atsuLayout
;
1321 UniCharCount chars
= str
.Length() ;
1322 UniChar
* ubuf
= NULL
;
1323 #if SIZEOF_WCHAR_T == 4
1324 wxMBConvUTF16BE converter
;
1326 size_t unicharlen
= converter
.WC2MB( NULL
, str
.wc_str() , 0 ) ;
1327 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1328 converter
.WC2MB( (char*) ubuf
, str
.wc_str(), unicharlen
+ 2 ) ;
1330 const wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1331 size_t unicharlen
= converter
.WC2MB( NULL
, wchar
.data() , 0 ) ;
1332 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1333 converter
.WC2MB( (char*) ubuf
, wchar
.data() , unicharlen
+ 2 ) ;
1335 chars
= unicharlen
/ 2 ;
1338 ubuf
= (UniChar
*) str
.wc_str() ;
1340 wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1341 chars
= wxWcslen( wchar
.data() ) ;
1342 ubuf
= (UniChar
*) wchar
.data() ;
1346 status
= ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr
) ubuf
, 0 , chars
, chars
, 1 ,
1347 &chars
, (ATSUStyle
*) &m_macATSUIStyle
, &atsuLayout
) ;
1349 wxASSERT_MSG( status
== noErr
, wxT("couldn't create the layout of the rotated text") );
1351 status
= ::ATSUSetTransientFontMatching( atsuLayout
, true ) ;
1352 wxASSERT_MSG( status
== noErr
, wxT("couldn't setup transient font matching") );
1354 int iAngle
= int( angle
);
1355 int drawX
= XLOG2DEVMAC(x
) ;
1356 int drawY
= YLOG2DEVMAC(y
) ;
1358 ATSUTextMeasurement textBefore
;
1359 ATSUTextMeasurement textAfter
;
1360 ATSUTextMeasurement ascent
;
1361 ATSUTextMeasurement descent
;
1364 if ( abs(iAngle
) > 0 )
1366 Fixed atsuAngle
= IntToFixed( iAngle
) ;
1367 ATSUAttributeTag atsuTags
[] =
1369 kATSULineRotationTag
,
1371 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1375 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1379 status
= ::ATSUSetLayoutControls(atsuLayout
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
),
1380 atsuTags
, atsuSizes
, atsuValues
) ;
1382 status
= ::ATSUMeasureText( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1383 &textBefore
, &textAfter
, &ascent
, &descent
);
1385 drawX
+= (int)(sin(angle
/RAD2DEG
) * FixedToInt(ascent
));
1386 drawY
+= (int)(cos(angle
/RAD2DEG
) * FixedToInt(ascent
));
1387 status
= ::ATSUDrawText( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1388 IntToFixed(drawX
) , IntToFixed(drawY
) );
1389 wxASSERT_MSG( status
== noErr
, wxT("couldn't draw the rotated text") );
1391 status
= ::ATSUMeasureTextImage( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1392 IntToFixed(drawX
) , IntToFixed(drawY
) , &rect
);
1393 wxASSERT_MSG( status
== noErr
, wxT("couldn't measure the rotated text") );
1394 OffsetRect( &rect
, -m_macLocalOrigin
.x
, -m_macLocalOrigin
.y
) ;
1395 CalcBoundingBox(XDEV2LOG(rect
.left
), YDEV2LOG(rect
.top
) );
1396 CalcBoundingBox(XDEV2LOG(rect
.right
), YDEV2LOG(rect
.bottom
) );
1397 ::ATSUDisposeTextLayout(atsuLayout
);
1398 #if SIZEOF_WCHAR_T == 4
1403 void wxDC::DoDrawText(const wxString
& strtext
, wxCoord x
, wxCoord y
)
1405 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawText Invalid DC"));
1407 wxMacFastPortSetter
helper(this) ;
1408 long xx
= XLOG2DEVMAC(x
);
1409 long yy
= YLOG2DEVMAC(y
);
1411 bool useDrawThemeText
= ( DrawThemeTextBox
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1412 if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC
) ) || m_font
.GetNoAntiAliasing() )
1413 useDrawThemeText
= false ;
1418 ::GetFontInfo( &fi
) ;
1420 if ( !useDrawThemeText
)
1423 ::MoveTo( xx
, yy
);
1424 if ( m_backgroundMode
== wxTRANSPARENT
)
1426 ::TextMode( srcOr
) ;
1430 ::TextMode( srcCopy
) ;
1434 wxString linetext
= strtext
;
1436 if ( useDrawThemeText
)
1438 Rect frame
= { yy
+ line
*(fi
.descent
+ fi
.ascent
+ fi
.leading
) ,xx
, yy
+ (line
+1)*(fi
.descent
+ fi
.ascent
+ fi
.leading
) , xx
+ 10000 } ;
1439 wxMacCFStringHolder
mString( linetext
, m_font
.GetEncoding()) ;
1441 if ( m_backgroundMode
!= wxTRANSPARENT
)
1443 Point bounds
={0,0} ;
1444 Rect background
= frame
;
1446 ::GetThemeTextDimensions( mString
,
1447 m_font
.MacGetThemeFontID() ,
1452 background
.right
= background
.left
+ bounds
.h
;
1453 background
.bottom
= background
.top
+ bounds
.v
;
1454 ::EraseRect( &background
) ;
1456 ::DrawThemeTextBox( mString
,
1457 m_font
.MacGetThemeFontID() ,
1467 wxCharBuffer text
= linetext
.mb_str(wxConvLocal
) ;
1468 ::DrawText( text
, 0 , strlen(text
) ) ;
1471 ::TextMode( srcOr
) ;
1474 bool wxDC::CanGetTextExtent() const
1476 wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
1480 void wxDC::DoGetTextExtent( const wxString
&strtext
, wxCoord
*width
, wxCoord
*height
,
1481 wxCoord
*descent
, wxCoord
*externalLeading
,
1482 wxFont
*theFont
) const
1484 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1485 wxMacFastPortSetter
helper(this) ;
1486 wxFont formerFont
= m_font
;
1489 // work around the constness
1490 *((wxFont
*)(&m_font
)) = *theFont
;
1494 ::GetFontInfo( &fi
) ;
1496 bool useGetThemeText
= ( GetThemeTextDimensions
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1497 if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC
) ) || ((wxFont
*)&m_font
)->GetNoAntiAliasing() )
1498 useGetThemeText
= false ;
1501 *height
= YDEV2LOGREL( fi
.descent
+ fi
.ascent
) ;
1503 *descent
=YDEV2LOGREL( fi
.descent
);
1504 if ( externalLeading
)
1505 *externalLeading
= YDEV2LOGREL( fi
.leading
) ;
1511 wxString linetext
= strtext
;
1513 if ( useGetThemeText
)
1515 Point bounds
={0,0} ;
1517 wxMacCFStringHolder
mString( linetext
, m_font
.GetEncoding() ) ;
1518 ThemeFontID themeFont
= m_font
.MacGetThemeFontID() ;
1519 ::GetThemeTextDimensions( mString
,
1525 curwidth
= bounds
.h
;
1529 wxCharBuffer text
= linetext
.mb_str(wxConvLocal
) ;
1530 curwidth
= ::TextWidth( text
, 0 , strlen(text
) ) ;
1532 if ( curwidth
> *width
)
1533 *width
= XDEV2LOGREL( curwidth
) ;
1537 // work around the constness
1538 *((wxFont
*)(&m_font
)) = formerFont
;
1539 m_macFontInstalled
= false ;
1544 bool wxDC::DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
1546 wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
1549 widths
.Add(0, text
.Length());
1551 if (text
.Length() == 0)
1554 wxMacFastPortSetter
helper(this) ;
1557 bool useGetThemeText
= ( GetThemeTextDimensions
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1558 if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC
) ) || ((wxFont
*)&m_font
)->GetNoAntiAliasing() )
1559 useGetThemeText
= false ;
1561 if ( useGetThemeText
)
1563 // If anybody knows how to do this more efficiently yet still handle
1564 // the fractional glyph widths that may be present when using AA
1565 // fonts, please change it. Currently it is measuring from the
1566 // begining of the string for each succeding substring, which is much
1567 // slower than this should be.
1568 for (size_t i
=0; i
<text
.Length(); i
++)
1570 wxString
str(text
.Left(i
+1));
1571 Point bounds
= {0,0};
1573 wxMacCFStringHolder
mString(str
, m_font
.GetEncoding());
1574 ::GetThemeTextDimensions( mString
,
1575 m_font
.MacGetThemeFontID(),
1580 widths
[i
] = XDEV2LOGREL(bounds
.h
);
1586 wxCharBuffer buff
= text
.mb_str(wxConvLocal
);
1587 size_t len
= strlen(buff
);
1588 short* measurements
= new short[len
+1];
1589 MeasureText(len
, buff
.data(), measurements
);
1591 // Copy to widths, starting at measurements[1]
1592 // NOTE: this doesn't take into account any multi-byte characters
1593 // in buff, it probabkly should...
1594 for (size_t i
=0; i
<text
.Length(); i
++)
1595 widths
[i
] = XDEV2LOGREL(measurements
[i
+1]);
1597 delete [] measurements
;
1605 wxCoord
wxDC::GetCharWidth(void) const
1607 wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
1608 wxMacFastPortSetter
helper(this) ;
1612 bool useGetThemeText
= ( GetThemeTextDimensions
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1613 if ( UMAGetSystemVersion() < 0x1000 || ((wxFont
*)&m_font
)->GetNoAntiAliasing() )
1614 useGetThemeText
= false ;
1618 if ( useGetThemeText
)
1620 Point bounds
={0,0} ;
1622 CFStringRef mString
= CFStringCreateWithBytes( NULL
, (UInt8
*) text
, 1 , CFStringGetSystemEncoding(), false ) ;
1623 ::GetThemeTextDimensions( mString
,
1624 m_font
.MacGetThemeFontID(),
1629 CFRelease( mString
) ;
1635 width
= ::TextWidth( text
, 0 , 1 ) ;
1637 return YDEV2LOGREL(width
) ;
1640 wxCoord
wxDC::GetCharHeight(void) const
1642 wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
1643 wxMacFastPortSetter
helper(this) ;
1646 ::GetFontInfo( &fi
) ;
1647 return YDEV2LOGREL( fi
.descent
+ fi
.ascent
);
1650 void wxDC::Clear(void)
1652 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1653 wxMacFastPortSetter
helper(this) ;
1654 Rect rect
= { -31000 , -31000 , 31000 , 31000 } ;
1655 if ( m_backgroundBrush
.Ok() && m_backgroundBrush
.GetStyle() != wxTRANSPARENT
)
1658 MacSetupBackgroundForCurrentPort( m_backgroundBrush
) ;
1659 ::EraseRect( &rect
) ;
1663 void wxDC::MacInstallFont() const
1665 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1666 // if ( m_macFontInstalled )
1668 Pattern blackColor
;
1669 MacSetupBackgroundForCurrentPort(m_backgroundBrush
) ;
1670 if ( m_backgroundMode
!= wxTRANSPARENT
)
1672 Pattern whiteColor
;
1673 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
1676 wxASSERT( m_font
.Ok() ) ;
1679 ::TextFont( m_font
.MacGetFontNum() ) ;
1680 ::TextSize( (short)(m_scaleY
* m_font
.MacGetFontSize()) ) ;
1681 ::TextFace( m_font
.MacGetFontStyle() ) ;
1682 m_macFontInstalled
= true ;
1683 m_macBrushInstalled
= false ;
1684 m_macPenInstalled
= false ;
1685 RGBColor forecolor
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel());
1686 RGBColor backcolor
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel());
1687 ::RGBForeColor( &forecolor
);
1688 ::RGBBackColor( &backcolor
);
1690 short mode
= patCopy
;
1692 switch( m_logicalFunction
)
1697 case wxINVERT
: // NOT dst
1698 ::PenPat(GetQDGlobalsBlack(&blackColor
));
1701 case wxXOR
: // src XOR dst
1704 case wxOR_REVERSE
: // src OR (NOT dst)
1707 case wxSRC_INVERT
: // (NOT src)
1710 case wxAND
: // src AND dst
1715 case wxAND_REVERSE
:// src AND (NOT dst)
1716 case wxAND_INVERT
: // (NOT src) AND dst
1717 case wxNO_OP
: // dst
1718 case wxNOR
: // (NOT src) AND (NOT dst)
1719 case wxEQUIV
: // (NOT src) XOR dst
1720 case wxOR_INVERT
: // (NOT src) OR dst
1721 case wxNAND
: // (NOT src) OR (NOT dst)
1722 case wxOR
: // src OR dst
1724 // case wxSRC_OR: // source _bitmap_ OR destination
1725 // case wxSRC_AND: // source _bitmap_ AND destination
1729 OSStatus status
= noErr
;
1730 status
= ATSUCreateAndCopyStyle( (ATSUStyle
) m_font
.MacGetATSUStyle() , (ATSUStyle
*) &m_macATSUIStyle
) ;
1731 wxASSERT_MSG( status
== noErr
, wxT("couldn't set create ATSU style") ) ;
1733 Fixed atsuSize
= IntToFixed( int(m_scaleY
* m_font
.MacGetFontSize()) ) ;
1734 ATSUAttributeTag atsuTags
[] =
1738 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1742 // Boolean kTrue = true ;
1743 // Boolean kFalse = false ;
1745 // ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal;
1746 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1750 status
= ::ATSUSetAttributes((ATSUStyle
)m_macATSUIStyle
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
) ,
1751 atsuTags
, atsuSizes
, atsuValues
);
1753 wxASSERT_MSG( status
== noErr
, wxT("couldn't Modify ATSU style") ) ;
1757 Pattern gPatterns
[] =
1759 { { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF } } ,
1760 { { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 } } ,
1761 { { 0x80 , 0x40 , 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , 0x01 } } ,
1762 { { 0x10 , 0x10 , 0x10 , 0xFF , 0x10 , 0x10 , 0x10 , 0x10 } } ,
1763 { { 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 } } ,
1764 { { 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 } } ,
1765 { { 0x81 , 0x42 , 0x24 , 0x18 , 0x18 , 0x24 , 0x42 , 0x81 } } ,
1767 { { 0xCC , 0x99 , 0x33 , 0x66 , 0xCC , 0x99 , 0x33 , 0x66 } } , // DOT
1768 { { 0xFE , 0xFD , 0xFB , 0xF7 , 0xEF , 0xDF , 0xBF , 0x7F } } , // LONG_DASH
1769 { { 0xEE , 0xDD , 0xBB , 0x77 , 0xEE , 0xDD , 0xBB , 0x77 } } , // SHORT_DASH
1770 { { 0xDE , 0xBD , 0x7B , 0xF6 , 0xED , 0xDB , 0xB7 , 0x6F } } , // DOT_DASH
1773 static void wxMacGetPattern(int penStyle
, Pattern
*pattern
)
1775 int index
= 0; // solid pattern by default
1779 case wxBDIAGONAL_HATCH
: index
= 1; break;
1780 case wxFDIAGONAL_HATCH
: index
= 2; break;
1781 case wxCROSS_HATCH
: index
= 3; break;
1782 case wxHORIZONTAL_HATCH
: index
= 4; break;
1783 case wxVERTICAL_HATCH
: index
= 5; break;
1784 case wxCROSSDIAG_HATCH
: index
= 6; break;
1786 case wxDOT
: index
= 7; break;
1787 case wxLONG_DASH
: index
= 8; break;
1788 case wxSHORT_DASH
: index
= 9; break;
1789 case wxDOT_DASH
: index
= 10; break;
1791 *pattern
= gPatterns
[index
];
1794 void wxDC::MacInstallPen() const
1796 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1797 //Pattern blackColor;
1798 // if ( m_macPenInstalled )
1800 RGBColor forecolor
= MAC_WXCOLORREF( m_pen
.GetColour().GetPixel());
1801 RGBColor backcolor
= MAC_WXCOLORREF( m_backgroundBrush
.GetColour().GetPixel());
1802 ::RGBForeColor( &forecolor
);
1803 ::RGBBackColor( &backcolor
);
1805 int penWidth
= (int) (m_pen
.GetWidth() * m_scaleX
) ; ;
1806 // null means only one pixel, at whatever resolution
1807 if ( penWidth
== 0 )
1809 ::PenSize(penWidth
, penWidth
);
1811 int penStyle
= m_pen
.GetStyle();
1813 if (penStyle
== wxUSER_DASH
)
1815 // FIXME: there should be exactly 8 items in the dash
1817 int number
= m_pen
.GetDashes(&dash
) ;
1819 for ( int i
= 0 ; i
< 8 ; ++i
)
1821 pat
.pat
[i
] = dash
[index
] ;
1822 if (index
< number
- 1)
1828 wxMacGetPattern(penStyle
, &pat
);
1832 short mode
= patCopy
;
1834 switch( m_logicalFunction
)
1836 case wxCOPY
: // only foreground color, leave background (thus not patCopy)
1839 case wxINVERT
: // NOT dst
1840 // ::PenPat(GetQDGlobalsBlack(&blackColor));
1843 case wxXOR
: // src XOR dst
1846 case wxOR_REVERSE
: // src OR (NOT dst)
1849 case wxSRC_INVERT
: // (NOT src)
1852 case wxAND
: // src AND dst
1857 case wxAND_REVERSE
:// src AND (NOT dst)
1858 case wxAND_INVERT
: // (NOT src) AND dst
1859 case wxNO_OP
: // dst
1860 case wxNOR
: // (NOT src) AND (NOT dst)
1861 case wxEQUIV
: // (NOT src) XOR dst
1862 case wxOR_INVERT
: // (NOT src) OR dst
1863 case wxNAND
: // (NOT src) OR (NOT dst)
1864 case wxOR
: // src OR dst
1866 // case wxSRC_OR: // source _bitmap_ OR destination
1867 // case wxSRC_AND: // source _bitmap_ AND destination
1871 m_macPenInstalled
= true ;
1872 m_macBrushInstalled
= false ;
1873 m_macFontInstalled
= false ;
1876 void wxDC::MacSetupBackgroundForCurrentPort(const wxBrush
& background
)
1878 Pattern whiteColor
;
1879 if ( background
.Ok() )
1881 switch( background
.MacGetBrushKind() )
1883 case kwxMacBrushTheme
:
1885 ::SetThemeBackground( background
.MacGetTheme() , wxDisplayDepth() , true ) ;
1888 case kwxMacBrushThemeBackground
:
1891 ThemeBackgroundKind bg
= background
.MacGetThemeBackground( &extent
) ;
1892 ::ApplyThemeBackground( bg
, &extent
,kThemeStateActive
, wxDisplayDepth() , true ) ;
1895 case kwxMacBrushColour
:
1897 ::RGBBackColor( &MAC_WXCOLORREF( background
.GetColour().GetPixel()) );
1898 int brushStyle
= background
.GetStyle();
1899 if (brushStyle
== wxSOLID
)
1900 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
1901 else if (background
.IsHatch())
1904 wxMacGetPattern(brushStyle
, &pat
);
1909 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
1917 void wxDC::MacInstallBrush() const
1919 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1920 Pattern blackColor
;
1921 // if ( m_macBrushInstalled )
1924 bool backgroundTransparent
= (GetBackgroundMode() == wxTRANSPARENT
) ;
1925 ::RGBForeColor( &MAC_WXCOLORREF( m_brush
.GetColour().GetPixel()) );
1926 ::RGBBackColor( &MAC_WXCOLORREF( m_backgroundBrush
.GetColour().GetPixel()) );
1927 int brushStyle
= m_brush
.GetStyle();
1928 if (brushStyle
== wxSOLID
)
1930 ::PenPat(GetQDGlobalsBlack(&blackColor
));
1932 else if (m_brush
.IsHatch())
1935 wxMacGetPattern(brushStyle
, &pat
);
1938 else if ( m_brush
.GetStyle() == wxSTIPPLE
|| m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
)
1940 // we force this in order to be compliant with wxMSW
1941 backgroundTransparent
= false ;
1942 // for these the text fore (and back for MASK_OPAQUE) colors are used
1943 wxBitmap
* bitmap
= m_brush
.GetStipple() ;
1944 int width
= bitmap
->GetWidth() ;
1945 int height
= bitmap
->GetHeight() ;
1946 GWorldPtr gw
= NULL
;
1947 if ( m_brush
.GetStyle() == wxSTIPPLE
)
1948 gw
= MAC_WXHBITMAP(bitmap
->GetHBITMAP(NULL
)) ;
1950 gw
= MAC_WXHBITMAP(bitmap
->GetMask()->GetHBITMAP()) ;
1951 PixMapHandle gwpixmaphandle
= GetGWorldPixMap( gw
) ;
1952 LockPixels( gwpixmaphandle
) ;
1953 bool isMonochrome
= !IsPortColor( gw
) ;
1954 if ( !isMonochrome
)
1956 if ( (**gwpixmaphandle
).pixelSize
== 1 )
1957 isMonochrome
= true ;
1959 if ( isMonochrome
&& width
== 8 && height
== 8 )
1961 ::RGBForeColor( &MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) );
1962 ::RGBForeColor( &MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) );
1963 BitMap
* gwbitmap
= (BitMap
*) *gwpixmaphandle
; // since the color depth is 1 it is a BitMap
1964 UInt8
*gwbits
= (UInt8
*) gwbitmap
->baseAddr
;
1965 int alignment
= gwbitmap
->rowBytes
& 0x7FFF ;
1967 for ( int i
= 0 ; i
< 8 ; ++i
)
1969 pat
.pat
[i
] = gwbits
[i
*alignment
+0] ;
1971 UnlockPixels( GetGWorldPixMap( gw
) ) ;
1976 // this will be the code to handle power of 2 patterns, we will have to arrive at a nice
1977 // caching scheme before putting this into production
1980 PixPatHandle pixpat
= NewPixPat() ;
1981 CopyPixMap(gwpixmaphandle
, (**pixpat
).patMap
);
1982 imageSize
= GetPixRowBytes((**pixpat
).patMap
) *
1983 ((**(**pixpat
).patMap
).bounds
.bottom
-
1984 (**(**pixpat
).patMap
).bounds
.top
);
1985 PtrToHand( (**gwpixmaphandle
).baseAddr
, &image
, imageSize
);
1986 (**pixpat
).patData
= image
;
1989 CTabHandle ctable
= ((**((**pixpat
).patMap
)).pmTable
) ;
1990 ColorSpecPtr ctspec
= (ColorSpecPtr
) &(**ctable
).ctTable
;
1991 if ( ctspec
[0].rgb
.red
== 0x0000 )
1993 ctspec
[1].rgb
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) ;
1994 ctspec
[0].rgb
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) ;
1998 ctspec
[0].rgb
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) ;
1999 ctspec
[1].rgb
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) ;
2001 ::CTabChanged( ctable
) ;
2003 ::PenPixPat(pixpat
);
2004 m_macForegroundPixMap
= pixpat
;
2006 UnlockPixels( gwpixmaphandle
) ;
2010 ::PenPat(GetQDGlobalsBlack(&blackColor
));
2012 short mode
= patCopy
;
2013 switch( m_logicalFunction
)
2016 if ( backgroundTransparent
)
2021 case wxINVERT
: // NOT dst
2022 if ( !backgroundTransparent
)
2024 ::PenPat(GetQDGlobalsBlack(&blackColor
));
2028 case wxXOR
: // src XOR dst
2031 case wxOR_REVERSE
: // src OR (NOT dst)
2034 case wxSRC_INVERT
: // (NOT src)
2037 case wxAND
: // src AND dst
2042 case wxAND_REVERSE
:// src AND (NOT dst)
2043 case wxAND_INVERT
: // (NOT src) AND dst
2044 case wxNO_OP
: // dst
2045 case wxNOR
: // (NOT src) AND (NOT dst)
2046 case wxEQUIV
: // (NOT src) XOR dst
2047 case wxOR_INVERT
: // (NOT src) OR dst
2048 case wxNAND
: // (NOT src) OR (NOT dst)
2049 case wxOR
: // src OR dst
2051 // case wxSRC_OR: // source _bitmap_ OR destination
2052 // case wxSRC_AND: // source _bitmap_ AND destination
2056 m_macBrushInstalled
= true ;
2057 m_macPenInstalled
= false ;
2058 m_macFontInstalled
= false ;
2061 // ---------------------------------------------------------------------------
2062 // coordinates transformations
2063 // ---------------------------------------------------------------------------
2065 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
2067 return ((wxDC
*)this)->XDEV2LOG(x
);
2070 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
2072 return ((wxDC
*)this)->YDEV2LOG(y
);
2075 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
2077 return ((wxDC
*)this)->XDEV2LOGREL(x
);
2080 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
2082 return ((wxDC
*)this)->YDEV2LOGREL(y
);
2085 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
2087 return ((wxDC
*)this)->XLOG2DEV(x
);
2090 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
2092 return ((wxDC
*)this)->YLOG2DEV(y
);
2095 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
2097 return ((wxDC
*)this)->XLOG2DEVREL(x
);
2100 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
2102 return ((wxDC
*)this)->YLOG2DEVREL(y
);
2105 #endif // !wxMAC_USE_CORE_GRAPHICS