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") ) ;
460 wxMacFastPortSetter
helper(this) ;
462 region
.GetBox( x
, y
, w
, h
);
463 wxCoord xx
, yy
, ww
, hh
;
468 // if we have a scaling that we cannot map onto native regions
469 // we must use the box
470 if ( ww
!= w
|| hh
!= h
)
472 wxDC::DoSetClippingRegion( x
, y
, w
, h
);
476 CopyRgn( (RgnHandle
) region
.GetWXHRGN() , (RgnHandle
) m_macCurrentClipRgn
) ;
477 if ( xx
!= x
|| yy
!= y
)
479 OffsetRgn( (RgnHandle
) m_macCurrentClipRgn
, xx
- x
, yy
- y
) ;
481 SectRgn( (RgnHandle
) m_macCurrentClipRgn
, (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
484 m_clipX1
= wxMax( m_clipX1
, xx
);
485 m_clipY1
= wxMax( m_clipY1
, yy
);
486 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
));
487 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
));
500 void wxDC::DestroyClippingRegion()
502 wxMacFastPortSetter
helper(this) ;
503 CopyRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
507 void wxDC::DoGetSizeMM( int* width
, int* height
) const
512 *width
= long( double(w
) / (m_scaleX
*m_mm_to_pix_x
) );
513 *height
= long( double(h
) / (m_scaleY
*m_mm_to_pix_y
) );
516 void wxDC::SetTextForeground( const wxColour
&col
)
518 wxCHECK_RET(Ok(), wxT("Invalid DC"));
519 m_textForegroundColour
= col
;
520 m_macFontInstalled
= false ;
523 void wxDC::SetTextBackground( const wxColour
&col
)
525 wxCHECK_RET(Ok(), wxT("Invalid DC"));
526 m_textBackgroundColour
= col
;
527 m_macFontInstalled
= false ;
530 void wxDC::SetMapMode( int mode
)
535 SetLogicalScale( twips2mm
*m_mm_to_pix_x
, twips2mm
*m_mm_to_pix_y
);
538 SetLogicalScale( pt2mm
*m_mm_to_pix_x
, pt2mm
*m_mm_to_pix_y
);
541 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
544 SetLogicalScale( m_mm_to_pix_x
/10.0, m_mm_to_pix_y
/10.0 );
548 SetLogicalScale( 1.0, 1.0 );
551 if (mode
!= wxMM_TEXT
)
553 m_needComputeScaleX
= true;
554 m_needComputeScaleY
= true;
558 void wxDC::SetUserScale( double x
, double y
)
560 // allow negative ? -> no
563 ComputeScaleAndOrigin();
566 void wxDC::SetLogicalScale( double x
, double y
)
571 ComputeScaleAndOrigin();
574 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
576 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
577 m_logicalOriginY
= y
* m_signY
;
578 ComputeScaleAndOrigin();
581 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
583 m_externalDeviceOriginX
= x
;
584 m_externalDeviceOriginY
= y
;
585 ComputeScaleAndOrigin();
588 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
590 m_signX
= (xLeftRight
? 1 : -1);
591 m_signY
= (yBottomUp
? -1 : 1);
592 ComputeScaleAndOrigin();
595 wxSize
wxDC::GetPPI() const
597 return wxSize(72, 72);
600 int wxDC::GetDepth() const
602 if ( IsPortColor( (CGrafPtr
) m_macPort
) )
604 return ( (**GetPortPixMap( (CGrafPtr
) m_macPort
)).pixelSize
) ;
609 void wxDC::ComputeScaleAndOrigin()
611 // CMB: copy scale to see if it changes
612 double origScaleX
= m_scaleX
;
613 double origScaleY
= m_scaleY
;
614 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
615 m_scaleY
= m_logicalScaleY
* m_userScaleY
;
616 m_deviceOriginX
= m_internalDeviceOriginX
+ m_externalDeviceOriginX
;
617 m_deviceOriginY
= m_internalDeviceOriginY
+ m_externalDeviceOriginY
;
618 // CMB: if scale has changed call SetPen to recalulate the line width
619 if (m_scaleX
!= origScaleX
|| m_scaleY
!= origScaleY
)
621 // this is a bit artificial, but we need to force wxDC to think
622 // the pen has changed
629 void wxDC::SetPalette( const wxPalette
& palette
)
633 void wxDC::SetBackgroundMode( int mode
)
635 m_backgroundMode
= mode
;
638 void wxDC::SetFont( const wxFont
&font
)
641 m_macFontInstalled
= false ;
644 void wxDC::SetPen( const wxPen
&pen
)
649 m_macPenInstalled
= false ;
652 void wxDC::SetBrush( const wxBrush
&brush
)
654 if (m_brush
== brush
)
657 m_macBrushInstalled
= false ;
660 void wxDC::SetBackground( const wxBrush
&brush
)
662 if (m_backgroundBrush
== brush
)
664 m_backgroundBrush
= brush
;
665 if (!m_backgroundBrush
.Ok())
667 m_macBrushInstalled
= false ;
670 void wxDC::SetLogicalFunction( int function
)
672 if (m_logicalFunction
== function
)
674 m_logicalFunction
= function
;
675 m_macFontInstalled
= false ;
676 m_macBrushInstalled
= false ;
677 m_macPenInstalled
= false ;
680 extern bool wxDoFloodFill(wxDC
*dc
, wxCoord x
, wxCoord y
,
681 const wxColour
& col
, int style
);
683 bool wxDC::DoFloodFill(wxCoord x
, wxCoord y
,
684 const wxColour
& col
, int style
)
686 return wxDoFloodFill(this, x
, y
, col
, style
);
689 bool wxDC::DoGetPixel( wxCoord x
, wxCoord y
, wxColour
*col
) const
691 wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel Invalid DC") );
692 wxMacFastPortSetter
helper(this) ;
694 GetCPixel( XLOG2DEVMAC(x
), YLOG2DEVMAC(y
), &colour
);
695 // Convert from Mac colour to wx
696 col
->Set( colour
.red
>> 8,
702 void wxDC::DoDrawLine( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
704 wxCHECK_RET(Ok(), wxT("Invalid DC"));
705 wxMacFastPortSetter
helper(this) ;
706 if (m_pen
.GetStyle() != wxTRANSPARENT
)
709 wxCoord offset
= ( (m_pen
.GetWidth() == 0 ? 1 :
710 m_pen
.GetWidth() ) * (wxCoord
)m_scaleX
- 1) / 2;
711 wxCoord xx1
= XLOG2DEVMAC(x1
) - offset
;
712 wxCoord yy1
= YLOG2DEVMAC(y1
) - offset
;
713 wxCoord xx2
= XLOG2DEVMAC(x2
) - offset
;
714 wxCoord yy2
= YLOG2DEVMAC(y2
) - offset
;
715 if ((m_pen
.GetCap() == wxCAP_ROUND
) &&
716 (m_pen
.GetWidth() <= 1))
718 // Implement LAST_NOT for MAC at least for
719 // orthogonal lines. RR.
740 void wxDC::DoCrossHair( wxCoord x
, wxCoord y
)
742 wxCHECK_RET( Ok(), wxT("wxDC::DoCrossHair Invalid window dc") );
743 wxMacFastPortSetter
helper(this) ;
744 if (m_pen
.GetStyle() != wxTRANSPARENT
)
749 wxCoord xx
= XLOG2DEVMAC(x
);
750 wxCoord yy
= YLOG2DEVMAC(y
);
752 ::MoveTo( XLOG2DEVMAC(0), yy
);
753 ::LineTo( XLOG2DEVMAC(w
), yy
);
754 ::MoveTo( xx
, YLOG2DEVMAC(0) );
755 ::LineTo( xx
, YLOG2DEVMAC(h
) );
756 CalcBoundingBox(x
, y
);
757 CalcBoundingBox(x
+w
, y
+h
);
762 * To draw arcs properly the angles need to be converted from the WX style:
763 * Angles start on the +ve X axis and go anti-clockwise (As you would draw on
764 * a normal axis on paper).
767 * Angles start on the +ve y axis and go clockwise.
770 static double wxConvertWXangleToMACangle(double angle
)
772 double newAngle
= 90 - angle
;
773 while ( newAngle
> 360 ) newAngle
-= 360 ;
774 while ( newAngle
< 0 ) newAngle
+= 360 ;
778 void wxDC::DoDrawArc( wxCoord x1
, wxCoord y1
,
779 wxCoord x2
, wxCoord y2
,
780 wxCoord xc
, wxCoord yc
)
782 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawArc Invalid DC"));
783 wxMacFastPortSetter
helper(this) ;
784 wxCoord xx1
= XLOG2DEVMAC(x1
);
785 wxCoord yy1
= YLOG2DEVMAC(y1
);
786 wxCoord xx2
= XLOG2DEVMAC(x2
);
787 wxCoord yy2
= YLOG2DEVMAC(y2
);
788 wxCoord xxc
= XLOG2DEVMAC(xc
);
789 wxCoord yyc
= YLOG2DEVMAC(yc
);
790 double dx
= xx1
- xxc
;
791 double dy
= yy1
- yyc
;
792 double radius
= sqrt((double)(dx
*dx
+dy
*dy
));
793 wxCoord rad
= (wxCoord
)radius
;
794 double radius1
, radius2
;
795 if (xx1
== xx2
&& yy1
== yy2
)
800 else if (radius
== 0.0)
802 radius1
= radius2
= 0.0;
806 radius1
= (xx1
- xxc
== 0) ?
807 (yy1
- yyc
< 0) ? 90.0 : -90.0 :
808 -atan2(double(yy1
-yyc
), double(xx1
-xxc
)) * RAD2DEG
;
809 radius2
= (xx2
- xxc
== 0) ?
810 (yy2
- yyc
< 0) ? 90.0 : -90.0 :
811 -atan2(double(yy2
-yyc
), double(xx2
-xxc
)) * RAD2DEG
;
813 wxCoord alpha2
= wxCoord(radius2
- radius1
);
814 wxCoord alpha1
= wxCoord(wxConvertWXangleToMACangle(radius1
));
815 while( alpha2
< 0 ) alpha2
+= 360 ;
817 Rect r
= { yyc
- rad
, xxc
- rad
, yyc
+ rad
, xxc
+ rad
};
818 if(m_brush
.GetStyle() != wxTRANSPARENT
) {
820 PaintArc(&r
, alpha1
, alpha2
);
822 if(m_pen
.GetStyle() != wxTRANSPARENT
) {
824 FrameArc(&r
, alpha1
, alpha2
);
828 void wxDC::DoDrawEllipticArc( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
829 double sa
, double ea
)
831 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawEllepticArc Invalid DC"));
832 wxMacFastPortSetter
helper(this) ;
834 double angle
= sa
- ea
; // Order important Mac in opposite direction to wx
835 // we have to make sure that the filling is always counter-clockwise
838 wxCoord xx
= XLOG2DEVMAC(x
);
839 wxCoord yy
= YLOG2DEVMAC(y
);
840 wxCoord ww
= m_signX
* XLOG2DEVREL(w
);
841 wxCoord hh
= m_signY
* YLOG2DEVREL(h
);
842 // handle -ve width and/or height
843 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
844 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
845 sa
= wxConvertWXangleToMACangle(sa
);
850 if(m_brush
.GetStyle() != wxTRANSPARENT
) {
852 PaintArc(&r
, (short)sa
, (short)angle
);
854 if(m_pen
.GetStyle() != wxTRANSPARENT
) {
856 FrameArc(&r
, (short)sa
, (short)angle
);
860 void wxDC::DoDrawPoint( wxCoord x
, wxCoord y
)
862 wxCHECK_RET(Ok(), wxT("Invalid DC"));
863 wxMacFastPortSetter
helper(this) ;
864 if (m_pen
.GetStyle() != wxTRANSPARENT
)
866 wxCoord xx1
= XLOG2DEVMAC(x
);
867 wxCoord yy1
= YLOG2DEVMAC(y
);
868 RGBColor pencolor
= MAC_WXCOLORREF( m_pen
.GetColour().GetPixel());
869 ::SetCPixel( xx1
,yy1
,&pencolor
) ;
870 CalcBoundingBox(x
, y
);
874 void wxDC::DoDrawLines(int n
, wxPoint points
[],
875 wxCoord xoffset
, wxCoord yoffset
)
877 wxCHECK_RET(Ok(), wxT("Invalid DC"));
878 wxMacFastPortSetter
helper(this) ;
879 if (m_pen
.GetStyle() == wxTRANSPARENT
)
882 wxCoord offset
= ( (m_pen
.GetWidth() == 0 ? 1 :
883 m_pen
.GetWidth() ) * (wxCoord
)m_scaleX
- 1) / 2 ;
884 wxCoord x1
, x2
, y1
, y2
;
885 x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
886 y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
887 ::MoveTo(x1
- offset
, y1
- offset
);
888 for (int i
= 0; i
< n
-1; i
++)
890 x2
= XLOG2DEVMAC(points
[i
+1].x
+ xoffset
);
891 y2
= YLOG2DEVMAC(points
[i
+1].y
+ yoffset
);
892 ::LineTo( x2
- offset
, y2
- offset
);
896 void wxDC::DoDrawPolygon(int n
, wxPoint points
[],
897 wxCoord xoffset
, wxCoord yoffset
,
900 wxCHECK_RET(Ok(), wxT("Invalid DC"));
901 wxMacFastPortSetter
helper(this) ;
902 wxCoord x1
, x2
, y1
, y2
;
903 if ( m_brush
.GetStyle() == wxTRANSPARENT
&& m_pen
.GetStyle() == wxTRANSPARENT
)
905 PolyHandle polygon
= OpenPoly();
906 x2
= x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
907 y2
= y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
909 for (int i
= 1; i
< n
; i
++)
911 x2
= XLOG2DEVMAC(points
[i
].x
+ xoffset
);
912 y2
= YLOG2DEVMAC(points
[i
].y
+ yoffset
);
915 // close the polyline if necessary
916 if ( x1
!= x2
|| y1
!= y2
)
921 if (m_brush
.GetStyle() != wxTRANSPARENT
)
924 ::PaintPoly( polygon
);
926 if (m_pen
.GetStyle() != wxTRANSPARENT
)
929 ::FramePoly( polygon
) ;
934 void wxDC::DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
936 wxCHECK_RET(Ok(), wxT("Invalid DC"));
937 wxMacFastPortSetter
helper(this) ;
938 wxCoord xx
= XLOG2DEVMAC(x
);
939 wxCoord yy
= YLOG2DEVMAC(y
);
940 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
941 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
942 // CMB: draw nothing if transformed w or h is 0
943 if (ww
== 0 || hh
== 0)
945 // CMB: handle -ve width and/or height
956 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
957 if (m_brush
.GetStyle() != wxTRANSPARENT
)
960 ::PaintRect( &rect
) ;
962 if (m_pen
.GetStyle() != wxTRANSPARENT
)
965 ::FrameRect( &rect
) ;
969 void wxDC::DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
970 wxCoord width
, wxCoord height
,
973 wxCHECK_RET(Ok(), wxT("Invalid DC"));
974 wxMacFastPortSetter
helper(this) ;
976 radius
= - radius
* ((width
< height
) ? width
: height
);
977 wxCoord xx
= XLOG2DEVMAC(x
);
978 wxCoord yy
= YLOG2DEVMAC(y
);
979 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
980 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
981 // CMB: draw nothing if transformed w or h is 0
982 if (ww
== 0 || hh
== 0)
984 // CMB: handle -ve width and/or height
995 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
996 if (m_brush
.GetStyle() != wxTRANSPARENT
)
999 ::PaintRoundRect( &rect
, int(radius
* 2) , int(radius
* 2) ) ;
1001 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1004 ::FrameRoundRect( &rect
, int(radius
* 2) , int(radius
* 2) ) ;
1008 void wxDC::DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1010 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1011 wxMacFastPortSetter
helper(this) ;
1012 wxCoord xx
= XLOG2DEVMAC(x
);
1013 wxCoord yy
= YLOG2DEVMAC(y
);
1014 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1015 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1016 // CMB: draw nothing if transformed w or h is 0
1017 if (ww
== 0 || hh
== 0)
1019 // CMB: handle -ve width and/or height
1030 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
1031 if (m_brush
.GetStyle() != wxTRANSPARENT
)
1034 ::PaintOval( &rect
) ;
1036 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1039 ::FrameOval( &rect
) ;
1043 bool wxDC::CanDrawBitmap(void) const
1048 bool wxDC::DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1049 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
, int logical_func
, bool useMask
,
1050 wxCoord xsrcMask
, wxCoord ysrcMask
)
1052 wxCHECK_MSG(Ok(), false, wxT("wxDC::DoBlit Illegal dc"));
1053 wxCHECK_MSG(source
->Ok(), false, wxT("wxDC::DoBlit Illegal source DC"));
1054 if ( logical_func
== wxNO_OP
)
1056 if (xsrcMask
== -1 && ysrcMask
== -1)
1058 xsrcMask
= xsrc
; ysrcMask
= ysrc
;
1060 // correct the parameter in case this dc does not have a mask at all
1061 if ( useMask
&& !source
->m_macMask
)
1063 Rect srcrect
, dstrect
;
1064 srcrect
.top
= source
->YLOG2DEVMAC(ysrc
) ;
1065 srcrect
.left
= source
->XLOG2DEVMAC(xsrc
) ;
1066 srcrect
.right
= source
->XLOG2DEVMAC(xsrc
+ width
) ;
1067 srcrect
.bottom
= source
->YLOG2DEVMAC(ysrc
+ height
) ;
1068 dstrect
.top
= YLOG2DEVMAC(ydest
) ;
1069 dstrect
.left
= XLOG2DEVMAC(xdest
) ;
1070 dstrect
.bottom
= YLOG2DEVMAC(ydest
+ height
) ;
1071 dstrect
.right
= XLOG2DEVMAC(xdest
+ width
) ;
1072 short mode
= kUnsupportedMode
;
1073 bool invertDestinationFirst
= false ;
1074 switch ( logical_func
)
1076 case wxAND
: // src AND dst
1077 mode
= adMin
; // ok
1079 case wxAND_INVERT
: // (NOT src) AND dst
1080 mode
= notSrcOr
; // ok
1082 case wxAND_REVERSE
:// src AND (NOT dst)
1083 invertDestinationFirst
= true ;
1087 mode
= kEmulatedMode
;
1090 mode
= srcCopy
; // ok
1092 case wxEQUIV
: // (NOT src) XOR dst
1093 mode
= srcXor
; // ok
1095 case wxINVERT
: // NOT dst
1096 mode
= kEmulatedMode
; //or hilite ;
1098 case wxNAND
: // (NOT src) OR (NOT dst)
1099 invertDestinationFirst
= true ;
1102 case wxNOR
: // (NOT src) AND (NOT dst)
1103 invertDestinationFirst
= true ;
1106 case wxNO_OP
: // dst
1107 mode
= kEmulatedMode
; // this has already been handled upon entry
1109 case wxOR
: // src OR dst
1112 case wxOR_INVERT
: // (NOT src) OR dst
1115 case wxOR_REVERSE
: // src OR (NOT dst)
1116 invertDestinationFirst
= true ;
1120 mode
= kEmulatedMode
;
1122 case wxSRC_INVERT
: // (NOT src)
1123 mode
= notSrcCopy
; // ok
1125 case wxXOR
: // src XOR dst
1126 mode
= notSrcXor
; // ok
1131 if ( mode
== kUnsupportedMode
)
1133 wxFAIL_MSG(wxT("unsupported blitting mode" ));
1136 CGrafPtr sourcePort
= (CGrafPtr
) source
->m_macPort
;
1137 PixMapHandle bmappixels
= GetGWorldPixMap( sourcePort
) ;
1138 if ( LockPixels(bmappixels
) )
1140 wxMacFastPortSetter
helper(this) ;
1141 if ( source
->GetDepth() == 1 )
1143 RGBForeColor( &MAC_WXCOLORREF(m_textForegroundColour
.GetPixel()) ) ;
1144 RGBBackColor( &MAC_WXCOLORREF(m_textBackgroundColour
.GetPixel()) ) ;
1148 // the modes need this, otherwise we'll end up having really nice colors...
1149 RGBColor white
= { 0xFFFF, 0xFFFF,0xFFFF} ;
1150 RGBColor black
= { 0,0,0} ;
1151 RGBForeColor( &black
) ;
1152 RGBBackColor( &white
) ;
1154 if ( useMask
&& source
->m_macMask
)
1156 if ( mode
== srcCopy
)
1158 if ( LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) )
1160 CopyMask( GetPortBitMapForCopyBits( sourcePort
) ,
1161 GetPortBitMapForCopyBits( MAC_WXHBITMAP(source
->m_macMask
) ) ,
1162 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1163 &srcrect
, &srcrect
, &dstrect
) ;
1164 UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1169 RgnHandle clipRgn
= NewRgn() ;
1170 LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1171 BitMapToRegion( clipRgn
, (BitMap
*) *GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1172 UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1173 OffsetRgn( clipRgn
, -srcrect
.left
+ dstrect
.left
, -srcrect
.top
+ dstrect
.top
) ;
1174 if ( mode
== kEmulatedMode
)
1177 ::PenPat(GetQDGlobalsBlack(&pat
));
1178 if ( logical_func
== wxSET
)
1180 RGBColor col
= { 0xFFFF, 0xFFFF, 0xFFFF } ;
1181 ::RGBForeColor( &col
) ;
1182 ::PaintRgn( clipRgn
) ;
1184 else if ( logical_func
== wxCLEAR
)
1186 RGBColor col
= { 0x0000, 0x0000, 0x0000 } ;
1187 ::RGBForeColor( &col
) ;
1188 ::PaintRgn( clipRgn
) ;
1190 else if ( logical_func
== wxINVERT
)
1192 MacInvertRgn( clipRgn
) ;
1196 for ( int y
= 0 ; y
< srcrect
.right
- srcrect
.left
; ++y
)
1198 for ( int x
= 0 ; x
< srcrect
.bottom
- srcrect
.top
; ++x
)
1200 Point dstPoint
= { dstrect
.top
+ y
, dstrect
.left
+ x
} ;
1201 Point srcPoint
= { srcrect
.top
+ y
, srcrect
.left
+ x
} ;
1202 if ( PtInRgn( dstPoint
, clipRgn
) )
1206 SetPort( (GrafPtr
) sourcePort
) ;
1207 GetCPixel( srcPoint
.h
, srcPoint
.v
, &srcColor
) ;
1208 SetPort( (GrafPtr
) m_macPort
) ;
1209 GetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1210 wxMacCalculateColour( logical_func
, srcColor
, dstColor
) ;
1211 SetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1219 if ( invertDestinationFirst
)
1221 MacInvertRgn( clipRgn
) ;
1223 CopyBits( GetPortBitMapForCopyBits( sourcePort
) ,
1224 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1225 &srcrect
, &dstrect
, mode
, clipRgn
) ;
1227 DisposeRgn( clipRgn
) ;
1232 RgnHandle clipRgn
= NewRgn() ;
1233 SetRectRgn( clipRgn
, dstrect
.left
, dstrect
.top
, dstrect
.right
, dstrect
.bottom
) ;
1234 if ( mode
== kEmulatedMode
)
1237 ::PenPat(GetQDGlobalsBlack(&pat
));
1238 if ( logical_func
== wxSET
)
1240 RGBColor col
= { 0xFFFF, 0xFFFF, 0xFFFF } ;
1241 ::RGBForeColor( &col
) ;
1242 ::PaintRgn( clipRgn
) ;
1244 else if ( logical_func
== wxCLEAR
)
1246 RGBColor col
= { 0x0000, 0x0000, 0x0000 } ;
1247 ::RGBForeColor( &col
) ;
1248 ::PaintRgn( clipRgn
) ;
1250 else if ( logical_func
== wxINVERT
)
1252 MacInvertRgn( clipRgn
) ;
1256 for ( int y
= 0 ; y
< srcrect
.right
- srcrect
.left
; ++y
)
1258 for ( int x
= 0 ; x
< srcrect
.bottom
- srcrect
.top
; ++x
)
1260 Point dstPoint
= { dstrect
.top
+ y
, dstrect
.left
+ x
} ;
1261 Point srcPoint
= { srcrect
.top
+ y
, srcrect
.left
+ x
} ;
1265 SetPort( (GrafPtr
) sourcePort
) ;
1266 GetCPixel( srcPoint
.h
, srcPoint
.v
, &srcColor
) ;
1267 SetPort( (GrafPtr
) m_macPort
) ;
1268 GetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1269 wxMacCalculateColour( logical_func
, srcColor
, dstColor
) ;
1270 SetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1278 if ( invertDestinationFirst
)
1280 MacInvertRgn( clipRgn
) ;
1282 CopyBits( GetPortBitMapForCopyBits( sourcePort
) ,
1283 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1284 &srcrect
, &dstrect
, mode
, NULL
) ;
1286 DisposeRgn( clipRgn
) ;
1288 UnlockPixels( bmappixels
) ;
1290 m_macPenInstalled
= false ;
1291 m_macBrushInstalled
= false ;
1292 m_macFontInstalled
= false ;
1296 void wxDC::DoDrawRotatedText(const wxString
& str
, wxCoord x
, wxCoord y
,
1299 // TODO support text background color (only possible by hand, ATSUI does not support it)
1300 wxCHECK_RET( Ok(), wxT("wxDC::DoDrawRotatedText Invalid window dc") );
1302 if ( str
.Length() == 0 )
1305 wxMacFastPortSetter
helper(this) ;
1310 m_macFormerAliasState
= IsAntiAliasedTextEnabled(&m_macFormerAliasSize
);
1311 SetAntiAliasedTextEnabled(true, SInt16(m_scaleY
* m_font
.MacGetFontSize()));
1312 m_macAliasWasEnabled
= true ;
1314 OSStatus status
= noErr
;
1315 ATSUTextLayout atsuLayout
;
1316 UniCharCount chars
= str
.Length() ;
1317 UniChar
* ubuf
= NULL
;
1318 #if SIZEOF_WCHAR_T == 4
1319 wxMBConvUTF16BE converter
;
1321 size_t unicharlen
= converter
.WC2MB( NULL
, str
.wc_str() , 0 ) ;
1322 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1323 converter
.WC2MB( (char*) ubuf
, str
.wc_str(), unicharlen
+ 2 ) ;
1325 const wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1326 size_t unicharlen
= converter
.WC2MB( NULL
, wchar
.data() , 0 ) ;
1327 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1328 converter
.WC2MB( (char*) ubuf
, wchar
.data() , unicharlen
+ 2 ) ;
1330 chars
= unicharlen
/ 2 ;
1333 ubuf
= (UniChar
*) str
.wc_str() ;
1335 wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1336 chars
= wxWcslen( wchar
.data() ) ;
1337 ubuf
= (UniChar
*) wchar
.data() ;
1341 status
= ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr
) ubuf
, 0 , chars
, chars
, 1 ,
1342 &chars
, (ATSUStyle
*) &m_macATSUIStyle
, &atsuLayout
) ;
1344 wxASSERT_MSG( status
== noErr
, wxT("couldn't create the layout of the rotated text") );
1346 status
= ::ATSUSetTransientFontMatching( atsuLayout
, true ) ;
1347 wxASSERT_MSG( status
== noErr
, wxT("couldn't setup transient font matching") );
1349 int iAngle
= int( angle
);
1350 int drawX
= XLOG2DEVMAC(x
) ;
1351 int drawY
= YLOG2DEVMAC(y
) ;
1353 ATSUTextMeasurement textBefore
;
1354 ATSUTextMeasurement textAfter
;
1355 ATSUTextMeasurement ascent
;
1356 ATSUTextMeasurement descent
;
1359 if ( abs(iAngle
) > 0 )
1361 Fixed atsuAngle
= IntToFixed( iAngle
) ;
1362 ATSUAttributeTag atsuTags
[] =
1364 kATSULineRotationTag
,
1366 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1370 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1374 status
= ::ATSUSetLayoutControls(atsuLayout
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
),
1375 atsuTags
, atsuSizes
, atsuValues
) ;
1377 status
= ::ATSUMeasureText( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1378 &textBefore
, &textAfter
, &ascent
, &descent
);
1380 drawX
+= (int)(sin(angle
/RAD2DEG
) * FixedToInt(ascent
));
1381 drawY
+= (int)(cos(angle
/RAD2DEG
) * FixedToInt(ascent
));
1382 status
= ::ATSUDrawText( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1383 IntToFixed(drawX
) , IntToFixed(drawY
) );
1384 wxASSERT_MSG( status
== noErr
, wxT("couldn't draw the rotated text") );
1386 status
= ::ATSUMeasureTextImage( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1387 IntToFixed(drawX
) , IntToFixed(drawY
) , &rect
);
1388 wxASSERT_MSG( status
== noErr
, wxT("couldn't measure the rotated text") );
1389 OffsetRect( &rect
, -m_macLocalOrigin
.x
, -m_macLocalOrigin
.y
) ;
1390 CalcBoundingBox(XDEV2LOG(rect
.left
), YDEV2LOG(rect
.top
) );
1391 CalcBoundingBox(XDEV2LOG(rect
.right
), YDEV2LOG(rect
.bottom
) );
1392 ::ATSUDisposeTextLayout(atsuLayout
);
1393 #if SIZEOF_WCHAR_T == 4
1398 void wxDC::DoDrawText(const wxString
& strtext
, wxCoord x
, wxCoord y
)
1400 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawText Invalid DC"));
1402 wxMacFastPortSetter
helper(this) ;
1403 long xx
= XLOG2DEVMAC(x
);
1404 long yy
= YLOG2DEVMAC(y
);
1406 bool useDrawThemeText
= ( DrawThemeTextBox
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1407 if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC
) ) || m_font
.GetNoAntiAliasing() )
1408 useDrawThemeText
= false ;
1413 ::GetFontInfo( &fi
) ;
1415 if ( !useDrawThemeText
)
1418 ::MoveTo( xx
, yy
);
1419 if ( m_backgroundMode
== wxTRANSPARENT
)
1421 ::TextMode( srcOr
) ;
1425 ::TextMode( srcCopy
) ;
1429 wxString linetext
= strtext
;
1431 if ( useDrawThemeText
)
1433 Rect frame
= { yy
+ line
*(fi
.descent
+ fi
.ascent
+ fi
.leading
) ,xx
, yy
+ (line
+1)*(fi
.descent
+ fi
.ascent
+ fi
.leading
) , xx
+ 10000 } ;
1434 wxMacCFStringHolder
mString( linetext
, m_font
.GetEncoding()) ;
1436 if ( m_backgroundMode
!= wxTRANSPARENT
)
1438 Point bounds
={0,0} ;
1439 Rect background
= frame
;
1441 ::GetThemeTextDimensions( mString
,
1442 m_font
.MacGetThemeFontID() ,
1447 background
.right
= background
.left
+ bounds
.h
;
1448 background
.bottom
= background
.top
+ bounds
.v
;
1449 ::EraseRect( &background
) ;
1451 ::DrawThemeTextBox( mString
,
1452 m_font
.MacGetThemeFontID() ,
1462 wxCharBuffer text
= linetext
.mb_str(wxConvLocal
) ;
1463 ::DrawText( text
, 0 , strlen(text
) ) ;
1466 ::TextMode( srcOr
) ;
1469 bool wxDC::CanGetTextExtent() const
1471 wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
1475 void wxDC::DoGetTextExtent( const wxString
&strtext
, wxCoord
*width
, wxCoord
*height
,
1476 wxCoord
*descent
, wxCoord
*externalLeading
,
1477 wxFont
*theFont
) const
1479 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1480 wxMacFastPortSetter
helper(this) ;
1481 wxFont formerFont
= m_font
;
1484 // work around the constness
1485 *((wxFont
*)(&m_font
)) = *theFont
;
1489 ::GetFontInfo( &fi
) ;
1491 bool useGetThemeText
= ( GetThemeTextDimensions
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1492 if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC
) ) || ((wxFont
*)&m_font
)->GetNoAntiAliasing() )
1493 useGetThemeText
= false ;
1496 *height
= YDEV2LOGREL( fi
.descent
+ fi
.ascent
) ;
1498 *descent
=YDEV2LOGREL( fi
.descent
);
1499 if ( externalLeading
)
1500 *externalLeading
= YDEV2LOGREL( fi
.leading
) ;
1506 wxString linetext
= strtext
;
1508 if ( useGetThemeText
)
1510 Point bounds
={0,0} ;
1512 wxMacCFStringHolder
mString( linetext
, m_font
.GetEncoding() ) ;
1513 ThemeFontID themeFont
= m_font
.MacGetThemeFontID() ;
1514 ::GetThemeTextDimensions( mString
,
1520 curwidth
= bounds
.h
;
1524 wxCharBuffer text
= linetext
.mb_str(wxConvLocal
) ;
1525 curwidth
= ::TextWidth( text
, 0 , strlen(text
) ) ;
1527 if ( curwidth
> *width
)
1528 *width
= XDEV2LOGREL( curwidth
) ;
1532 // work around the constness
1533 *((wxFont
*)(&m_font
)) = formerFont
;
1534 m_macFontInstalled
= false ;
1539 bool wxDC::DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
1541 wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
1544 widths
.Add(0, text
.Length());
1546 if (text
.Length() == 0)
1549 wxMacFastPortSetter
helper(this) ;
1552 bool useGetThemeText
= ( GetThemeTextDimensions
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1553 if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC
) ) || ((wxFont
*)&m_font
)->GetNoAntiAliasing() )
1554 useGetThemeText
= false ;
1556 if ( useGetThemeText
)
1558 // If anybody knows how to do this more efficiently yet still handle
1559 // the fractional glyph widths that may be present when using AA
1560 // fonts, please change it. Currently it is measuring from the
1561 // begining of the string for each succeding substring, which is much
1562 // slower than this should be.
1563 for (size_t i
=0; i
<text
.Length(); i
++)
1565 wxString
str(text
.Left(i
+1));
1566 Point bounds
= {0,0};
1568 wxMacCFStringHolder
mString(str
, m_font
.GetEncoding());
1569 ::GetThemeTextDimensions( mString
,
1570 m_font
.MacGetThemeFontID(),
1575 widths
[i
] = XDEV2LOGREL(bounds
.h
);
1581 wxCharBuffer buff
= text
.mb_str(wxConvLocal
);
1582 size_t len
= strlen(buff
);
1583 short* measurements
= new short[len
+1];
1584 MeasureText(len
, buff
.data(), measurements
);
1586 // Copy to widths, starting at measurements[1]
1587 // NOTE: this doesn't take into account any multi-byte characters
1588 // in buff, it probabkly should...
1589 for (size_t i
=0; i
<text
.Length(); i
++)
1590 widths
[i
] = XDEV2LOGREL(measurements
[i
+1]);
1592 delete [] measurements
;
1600 wxCoord
wxDC::GetCharWidth(void) const
1602 wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
1603 wxMacFastPortSetter
helper(this) ;
1607 bool useGetThemeText
= ( GetThemeTextDimensions
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1608 if ( UMAGetSystemVersion() < 0x1000 || ((wxFont
*)&m_font
)->GetNoAntiAliasing() )
1609 useGetThemeText
= false ;
1613 if ( useGetThemeText
)
1615 Point bounds
={0,0} ;
1617 CFStringRef mString
= CFStringCreateWithBytes( NULL
, (UInt8
*) text
, 1 , CFStringGetSystemEncoding(), false ) ;
1618 ::GetThemeTextDimensions( mString
,
1619 m_font
.MacGetThemeFontID(),
1624 CFRelease( mString
) ;
1630 width
= ::TextWidth( text
, 0 , 1 ) ;
1632 return YDEV2LOGREL(width
) ;
1635 wxCoord
wxDC::GetCharHeight(void) const
1637 wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
1638 wxMacFastPortSetter
helper(this) ;
1641 ::GetFontInfo( &fi
) ;
1642 return YDEV2LOGREL( fi
.descent
+ fi
.ascent
);
1645 void wxDC::Clear(void)
1647 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1648 wxMacFastPortSetter
helper(this) ;
1649 Rect rect
= { -31000 , -31000 , 31000 , 31000 } ;
1650 if ( m_backgroundBrush
.Ok() && m_backgroundBrush
.GetStyle() != wxTRANSPARENT
)
1653 MacSetupBackgroundForCurrentPort( m_backgroundBrush
) ;
1654 ::EraseRect( &rect
) ;
1658 void wxDC::MacInstallFont() const
1660 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1661 // if ( m_macFontInstalled )
1663 Pattern blackColor
;
1664 MacSetupBackgroundForCurrentPort(m_backgroundBrush
) ;
1665 if ( m_backgroundMode
!= wxTRANSPARENT
)
1667 Pattern whiteColor
;
1668 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
1671 wxASSERT( m_font
.Ok() ) ;
1674 ::TextFont( m_font
.MacGetFontNum() ) ;
1675 ::TextSize( (short)(m_scaleY
* m_font
.MacGetFontSize()) ) ;
1676 ::TextFace( m_font
.MacGetFontStyle() ) ;
1677 m_macFontInstalled
= true ;
1678 m_macBrushInstalled
= false ;
1679 m_macPenInstalled
= false ;
1680 RGBColor forecolor
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel());
1681 RGBColor backcolor
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel());
1682 ::RGBForeColor( &forecolor
);
1683 ::RGBBackColor( &backcolor
);
1685 short mode
= patCopy
;
1687 switch( m_logicalFunction
)
1692 case wxINVERT
: // NOT dst
1693 ::PenPat(GetQDGlobalsBlack(&blackColor
));
1696 case wxXOR
: // src XOR dst
1699 case wxOR_REVERSE
: // src OR (NOT dst)
1702 case wxSRC_INVERT
: // (NOT src)
1705 case wxAND
: // src AND dst
1710 case wxAND_REVERSE
:// src AND (NOT dst)
1711 case wxAND_INVERT
: // (NOT src) AND dst
1712 case wxNO_OP
: // dst
1713 case wxNOR
: // (NOT src) AND (NOT dst)
1714 case wxEQUIV
: // (NOT src) XOR dst
1715 case wxOR_INVERT
: // (NOT src) OR dst
1716 case wxNAND
: // (NOT src) OR (NOT dst)
1717 case wxOR
: // src OR dst
1719 // case wxSRC_OR: // source _bitmap_ OR destination
1720 // case wxSRC_AND: // source _bitmap_ AND destination
1724 OSStatus status
= noErr
;
1725 status
= ATSUCreateAndCopyStyle( (ATSUStyle
) m_font
.MacGetATSUStyle() , (ATSUStyle
*) &m_macATSUIStyle
) ;
1726 wxASSERT_MSG( status
== noErr
, wxT("couldn't set create ATSU style") ) ;
1728 Fixed atsuSize
= IntToFixed( int(m_scaleY
* m_font
.MacGetFontSize()) ) ;
1729 ATSUAttributeTag atsuTags
[] =
1733 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1737 // Boolean kTrue = true ;
1738 // Boolean kFalse = false ;
1740 // ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal;
1741 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1745 status
= ::ATSUSetAttributes((ATSUStyle
)m_macATSUIStyle
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
) ,
1746 atsuTags
, atsuSizes
, atsuValues
);
1748 wxASSERT_MSG( status
== noErr
, wxT("couldn't Modify ATSU style") ) ;
1752 Pattern gPatterns
[] =
1754 { { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF } } ,
1755 { { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 } } ,
1756 { { 0x80 , 0x40 , 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , 0x01 } } ,
1757 { { 0x10 , 0x10 , 0x10 , 0xFF , 0x10 , 0x10 , 0x10 , 0x10 } } ,
1758 { { 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 } } ,
1759 { { 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 } } ,
1760 { { 0x81 , 0x42 , 0x24 , 0x18 , 0x18 , 0x24 , 0x42 , 0x81 } } ,
1762 { { 0xCC , 0x99 , 0x33 , 0x66 , 0xCC , 0x99 , 0x33 , 0x66 } } , // DOT
1763 { { 0xFE , 0xFD , 0xFB , 0xF7 , 0xEF , 0xDF , 0xBF , 0x7F } } , // LONG_DASH
1764 { { 0xEE , 0xDD , 0xBB , 0x77 , 0xEE , 0xDD , 0xBB , 0x77 } } , // SHORT_DASH
1765 { { 0xDE , 0xBD , 0x7B , 0xF6 , 0xED , 0xDB , 0xB7 , 0x6F } } , // DOT_DASH
1768 static void wxMacGetPattern(int penStyle
, Pattern
*pattern
)
1770 int index
= 0; // solid pattern by default
1774 case wxBDIAGONAL_HATCH
: index
= 1; break;
1775 case wxFDIAGONAL_HATCH
: index
= 2; break;
1776 case wxCROSS_HATCH
: index
= 3; break;
1777 case wxHORIZONTAL_HATCH
: index
= 4; break;
1778 case wxVERTICAL_HATCH
: index
= 5; break;
1779 case wxCROSSDIAG_HATCH
: index
= 6; break;
1781 case wxDOT
: index
= 7; break;
1782 case wxLONG_DASH
: index
= 8; break;
1783 case wxSHORT_DASH
: index
= 9; break;
1784 case wxDOT_DASH
: index
= 10; break;
1786 *pattern
= gPatterns
[index
];
1789 void wxDC::MacInstallPen() const
1791 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1792 //Pattern blackColor;
1793 // if ( m_macPenInstalled )
1795 RGBColor forecolor
= MAC_WXCOLORREF( m_pen
.GetColour().GetPixel());
1796 RGBColor backcolor
= MAC_WXCOLORREF( m_backgroundBrush
.GetColour().GetPixel());
1797 ::RGBForeColor( &forecolor
);
1798 ::RGBBackColor( &backcolor
);
1800 int penWidth
= (int) (m_pen
.GetWidth() * m_scaleX
) ; ;
1801 // null means only one pixel, at whatever resolution
1802 if ( penWidth
== 0 )
1804 ::PenSize(penWidth
, penWidth
);
1806 int penStyle
= m_pen
.GetStyle();
1808 if (penStyle
== wxUSER_DASH
)
1810 // FIXME: there should be exactly 8 items in the dash
1812 int number
= m_pen
.GetDashes(&dash
) ;
1814 for ( int i
= 0 ; i
< 8 ; ++i
)
1816 pat
.pat
[i
] = dash
[index
] ;
1817 if (index
< number
- 1)
1823 wxMacGetPattern(penStyle
, &pat
);
1827 short mode
= patCopy
;
1829 switch( m_logicalFunction
)
1831 case wxCOPY
: // only foreground color, leave background (thus not patCopy)
1834 case wxINVERT
: // NOT dst
1835 // ::PenPat(GetQDGlobalsBlack(&blackColor));
1838 case wxXOR
: // src XOR dst
1841 case wxOR_REVERSE
: // src OR (NOT dst)
1844 case wxSRC_INVERT
: // (NOT src)
1847 case wxAND
: // src AND dst
1852 case wxAND_REVERSE
:// src AND (NOT dst)
1853 case wxAND_INVERT
: // (NOT src) AND dst
1854 case wxNO_OP
: // dst
1855 case wxNOR
: // (NOT src) AND (NOT dst)
1856 case wxEQUIV
: // (NOT src) XOR dst
1857 case wxOR_INVERT
: // (NOT src) OR dst
1858 case wxNAND
: // (NOT src) OR (NOT dst)
1859 case wxOR
: // src OR dst
1861 // case wxSRC_OR: // source _bitmap_ OR destination
1862 // case wxSRC_AND: // source _bitmap_ AND destination
1866 m_macPenInstalled
= true ;
1867 m_macBrushInstalled
= false ;
1868 m_macFontInstalled
= false ;
1871 void wxDC::MacSetupBackgroundForCurrentPort(const wxBrush
& background
)
1873 Pattern whiteColor
;
1874 if ( background
.Ok() )
1876 switch( background
.MacGetBrushKind() )
1878 case kwxMacBrushTheme
:
1880 ::SetThemeBackground( background
.MacGetTheme() , wxDisplayDepth() , true ) ;
1883 case kwxMacBrushThemeBackground
:
1886 ThemeBackgroundKind bg
= background
.MacGetThemeBackground( &extent
) ;
1887 ::ApplyThemeBackground( bg
, &extent
,kThemeStateActive
, wxDisplayDepth() , true ) ;
1890 case kwxMacBrushColour
:
1892 ::RGBBackColor( &MAC_WXCOLORREF( background
.GetColour().GetPixel()) );
1893 int brushStyle
= background
.GetStyle();
1894 if (brushStyle
== wxSOLID
)
1895 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
1896 else if (background
.IsHatch())
1899 wxMacGetPattern(brushStyle
, &pat
);
1904 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
1912 void wxDC::MacInstallBrush() const
1914 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1915 Pattern blackColor
;
1916 // if ( m_macBrushInstalled )
1919 bool backgroundTransparent
= (GetBackgroundMode() == wxTRANSPARENT
) ;
1920 ::RGBForeColor( &MAC_WXCOLORREF( m_brush
.GetColour().GetPixel()) );
1921 ::RGBBackColor( &MAC_WXCOLORREF( m_backgroundBrush
.GetColour().GetPixel()) );
1922 int brushStyle
= m_brush
.GetStyle();
1923 if (brushStyle
== wxSOLID
)
1925 ::PenPat(GetQDGlobalsBlack(&blackColor
));
1927 else if (m_brush
.IsHatch())
1930 wxMacGetPattern(brushStyle
, &pat
);
1933 else if ( m_brush
.GetStyle() == wxSTIPPLE
|| m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
)
1935 // we force this in order to be compliant with wxMSW
1936 backgroundTransparent
= false ;
1937 // for these the text fore (and back for MASK_OPAQUE) colors are used
1938 wxBitmap
* bitmap
= m_brush
.GetStipple() ;
1939 int width
= bitmap
->GetWidth() ;
1940 int height
= bitmap
->GetHeight() ;
1941 GWorldPtr gw
= NULL
;
1942 if ( m_brush
.GetStyle() == wxSTIPPLE
)
1943 gw
= MAC_WXHBITMAP(bitmap
->GetHBITMAP(NULL
)) ;
1945 gw
= MAC_WXHBITMAP(bitmap
->GetMask()->GetHBITMAP()) ;
1946 PixMapHandle gwpixmaphandle
= GetGWorldPixMap( gw
) ;
1947 LockPixels( gwpixmaphandle
) ;
1948 bool isMonochrome
= !IsPortColor( gw
) ;
1949 if ( !isMonochrome
)
1951 if ( (**gwpixmaphandle
).pixelSize
== 1 )
1952 isMonochrome
= true ;
1954 if ( isMonochrome
&& width
== 8 && height
== 8 )
1956 ::RGBForeColor( &MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) );
1957 ::RGBForeColor( &MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) );
1958 BitMap
* gwbitmap
= (BitMap
*) *gwpixmaphandle
; // since the color depth is 1 it is a BitMap
1959 UInt8
*gwbits
= (UInt8
*) gwbitmap
->baseAddr
;
1960 int alignment
= gwbitmap
->rowBytes
& 0x7FFF ;
1962 for ( int i
= 0 ; i
< 8 ; ++i
)
1964 pat
.pat
[i
] = gwbits
[i
*alignment
+0] ;
1966 UnlockPixels( GetGWorldPixMap( gw
) ) ;
1971 // this will be the code to handle power of 2 patterns, we will have to arrive at a nice
1972 // caching scheme before putting this into production
1975 PixPatHandle pixpat
= NewPixPat() ;
1976 CopyPixMap(gwpixmaphandle
, (**pixpat
).patMap
);
1977 imageSize
= GetPixRowBytes((**pixpat
).patMap
) *
1978 ((**(**pixpat
).patMap
).bounds
.bottom
-
1979 (**(**pixpat
).patMap
).bounds
.top
);
1980 PtrToHand( (**gwpixmaphandle
).baseAddr
, &image
, imageSize
);
1981 (**pixpat
).patData
= image
;
1984 CTabHandle ctable
= ((**((**pixpat
).patMap
)).pmTable
) ;
1985 ColorSpecPtr ctspec
= (ColorSpecPtr
) &(**ctable
).ctTable
;
1986 if ( ctspec
[0].rgb
.red
== 0x0000 )
1988 ctspec
[1].rgb
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) ;
1989 ctspec
[0].rgb
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) ;
1993 ctspec
[0].rgb
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) ;
1994 ctspec
[1].rgb
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) ;
1996 ::CTabChanged( ctable
) ;
1998 ::PenPixPat(pixpat
);
1999 m_macForegroundPixMap
= pixpat
;
2001 UnlockPixels( gwpixmaphandle
) ;
2005 ::PenPat(GetQDGlobalsBlack(&blackColor
));
2007 short mode
= patCopy
;
2008 switch( m_logicalFunction
)
2011 if ( backgroundTransparent
)
2016 case wxINVERT
: // NOT dst
2017 if ( !backgroundTransparent
)
2019 ::PenPat(GetQDGlobalsBlack(&blackColor
));
2023 case wxXOR
: // src XOR dst
2026 case wxOR_REVERSE
: // src OR (NOT dst)
2029 case wxSRC_INVERT
: // (NOT src)
2032 case wxAND
: // src AND dst
2037 case wxAND_REVERSE
:// src AND (NOT dst)
2038 case wxAND_INVERT
: // (NOT src) AND dst
2039 case wxNO_OP
: // dst
2040 case wxNOR
: // (NOT src) AND (NOT dst)
2041 case wxEQUIV
: // (NOT src) XOR dst
2042 case wxOR_INVERT
: // (NOT src) OR dst
2043 case wxNAND
: // (NOT src) OR (NOT dst)
2044 case wxOR
: // src OR dst
2046 // case wxSRC_OR: // source _bitmap_ OR destination
2047 // case wxSRC_AND: // source _bitmap_ AND destination
2051 m_macBrushInstalled
= true ;
2052 m_macPenInstalled
= false ;
2053 m_macFontInstalled
= false ;
2056 // ---------------------------------------------------------------------------
2057 // coordinates transformations
2058 // ---------------------------------------------------------------------------
2060 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
2062 return ((wxDC
*)this)->XDEV2LOG(x
);
2065 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
2067 return ((wxDC
*)this)->YDEV2LOG(y
);
2070 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
2072 return ((wxDC
*)this)->XDEV2LOGREL(x
);
2075 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
2077 return ((wxDC
*)this)->YDEV2LOGREL(y
);
2080 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
2082 return ((wxDC
*)this)->XLOG2DEV(x
);
2085 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
2087 return ((wxDC
*)this)->YLOG2DEV(y
);
2090 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
2092 return ((wxDC
*)this)->XLOG2DEVREL(x
);
2095 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
2097 return ((wxDC
*)this)->YLOG2DEVREL(y
);
2100 #endif // !wxMAC_USE_CORE_GRAPHICS