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"
36 #include "wx/mac/private.h"
38 #include <ATSUnicode.h>
39 #include <TextCommon.h>
40 #include <TextEncodingConverter.h>
43 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxObject
)
45 //-----------------------------------------------------------------------------
47 //-----------------------------------------------------------------------------
49 const double RAD2DEG
= 180.0 / M_PI
;
50 const short kEmulatedMode
= -1 ;
51 const short kUnsupportedMode
= -2 ;
53 extern TECObjectRef s_TECNativeCToUnicode
;
55 // set to 0 if problems arise
56 #define wxMAC_EXPERIMENTAL_DC 1
58 wxMacPortSetter::wxMacPortSetter( const wxDC
* dc
) :
59 m_ph( (GrafPtr
) dc
->m_macPort
)
61 wxASSERT( dc
->Ok() ) ;
63 dc
->MacSetupPort(&m_ph
) ;
65 wxMacPortSetter::~wxMacPortSetter()
67 m_dc
->MacCleanupPort(&m_ph
) ;
70 #if wxMAC_EXPERIMENTAL_DC
71 class wxMacFastPortSetter
74 wxMacFastPortSetter( const wxDC
*dc
)
76 wxASSERT( dc
->Ok() ) ;
77 m_swapped
= QDSwapPort( (GrafPtr
) dc
->m_macPort
, &m_oldPort
) ;
78 m_clipRgn
= NewRgn() ;
79 GetClip( m_clipRgn
) ;
81 dc
->MacSetupPort( NULL
) ;
83 ~wxMacFastPortSetter()
85 // SetPort( (GrafPtr) m_dc->m_macPort ) ;
86 SetClip( m_clipRgn
) ;
88 SetPort( m_oldPort
) ;
89 m_dc
->MacCleanupPort( NULL
) ;
90 DisposeRgn( m_clipRgn
) ;
100 typedef wxMacPortSetter wxMacFastPortSetter
;
103 wxMacWindowClipper::wxMacWindowClipper( const wxWindow
* win
) :
104 wxMacPortSaver( (GrafPtr
) GetWindowPort((WindowRef
) win
->MacGetTopLevelWindowRef()) )
106 m_newPort
=(GrafPtr
) GetWindowPort((WindowRef
) win
->MacGetTopLevelWindowRef()) ;
107 m_formerClip
= NewRgn() ;
108 m_newClip
= NewRgn() ;
109 GetClip( m_formerClip
) ;
113 // guard against half constructed objects, this just leads to a empty clip
117 win
->MacWindowToRootWindow( &x
,&y
) ;
118 // get area including focus rect
119 CopyRgn( (RgnHandle
) ((wxWindow
*)win
)->MacGetVisibleRegion(true).GetWXHRGN() , m_newClip
) ;
120 if ( !EmptyRgn( m_newClip
) )
121 OffsetRgn( m_newClip
, x
, y
) ;
123 SetClip( m_newClip
) ;
127 wxMacWindowClipper::~wxMacWindowClipper()
129 SetPort( m_newPort
) ;
130 SetClip( m_formerClip
) ;
131 DisposeRgn( m_newClip
) ;
132 DisposeRgn( m_formerClip
) ;
135 wxMacWindowStateSaver::wxMacWindowStateSaver( const wxWindow
* win
) :
136 wxMacWindowClipper( win
)
138 // the port is already set at this point
139 m_newPort
=(GrafPtr
) GetWindowPort((WindowRef
) win
->MacGetTopLevelWindowRef()) ;
140 GetThemeDrawingState( &m_themeDrawingState
) ;
143 wxMacWindowStateSaver::~wxMacWindowStateSaver()
145 SetPort( m_newPort
) ;
146 SetThemeDrawingState( m_themeDrawingState
, true ) ;
149 //-----------------------------------------------------------------------------
151 //-----------------------------------------------------------------------------
152 static inline double dmin(double a
, double b
) { return a
< b
? a
: b
; }
153 static inline double dmax(double a
, double b
) { return a
> b
? a
: b
; }
154 static inline double DegToRad(double deg
) { return (deg
* M_PI
) / 180.0; }
156 //-----------------------------------------------------------------------------
158 //-----------------------------------------------------------------------------
159 // this function emulates all wx colour manipulations, used to verify the implementation
160 // by setting the mode in the blitting functions to kEmulatedMode
161 void wxMacCalculateColour( int logical_func
, const RGBColor
&srcColor
, RGBColor
&dstColor
) ;
163 void wxMacCalculateColour( int logical_func
, const RGBColor
&srcColor
, RGBColor
&dstColor
)
165 switch ( logical_func
)
167 case wxAND
: // src AND dst
168 dstColor
.red
= dstColor
.red
& srcColor
.red
;
169 dstColor
.green
= dstColor
.green
& srcColor
.green
;
170 dstColor
.blue
= dstColor
.blue
& srcColor
.blue
;
172 case wxAND_INVERT
: // (NOT src) AND dst
173 dstColor
.red
= dstColor
.red
& ~srcColor
.red
;
174 dstColor
.green
= dstColor
.green
& ~srcColor
.green
;
175 dstColor
.blue
= dstColor
.blue
& ~srcColor
.blue
;
177 case wxAND_REVERSE
:// src AND (NOT dst)
178 dstColor
.red
= ~dstColor
.red
& srcColor
.red
;
179 dstColor
.green
= ~dstColor
.green
& srcColor
.green
;
180 dstColor
.blue
= ~dstColor
.blue
& srcColor
.blue
;
188 dstColor
.red
= srcColor
.red
;
189 dstColor
.green
= srcColor
.green
;
190 dstColor
.blue
= srcColor
.blue
;
192 case wxEQUIV
: // (NOT src) XOR dst
193 dstColor
.red
= dstColor
.red
^ ~srcColor
.red
;
194 dstColor
.green
= dstColor
.green
^ ~srcColor
.green
;
195 dstColor
.blue
= dstColor
.blue
^ ~srcColor
.blue
;
197 case wxINVERT
: // NOT dst
198 dstColor
.red
= ~dstColor
.red
;
199 dstColor
.green
= ~dstColor
.green
;
200 dstColor
.blue
= ~dstColor
.blue
;
202 case wxNAND
: // (NOT src) OR (NOT dst)
203 dstColor
.red
= ~dstColor
.red
| ~srcColor
.red
;
204 dstColor
.green
= ~dstColor
.green
| ~srcColor
.green
;
205 dstColor
.blue
= ~dstColor
.blue
| ~srcColor
.blue
;
207 case wxNOR
: // (NOT src) AND (NOT dst)
208 dstColor
.red
= ~dstColor
.red
& ~srcColor
.red
;
209 dstColor
.green
= ~dstColor
.green
& ~srcColor
.green
;
210 dstColor
.blue
= ~dstColor
.blue
& ~srcColor
.blue
;
214 case wxOR
: // src OR dst
215 dstColor
.red
= dstColor
.red
| srcColor
.red
;
216 dstColor
.green
= dstColor
.green
| srcColor
.green
;
217 dstColor
.blue
= dstColor
.blue
| srcColor
.blue
;
219 case wxOR_INVERT
: // (NOT src) OR dst
220 dstColor
.red
= dstColor
.red
| ~srcColor
.red
;
221 dstColor
.green
= dstColor
.green
| ~srcColor
.green
;
222 dstColor
.blue
= dstColor
.blue
| ~srcColor
.blue
;
224 case wxOR_REVERSE
: // src OR (NOT dst)
225 dstColor
.red
= ~dstColor
.red
| srcColor
.red
;
226 dstColor
.green
= ~dstColor
.green
| srcColor
.green
;
227 dstColor
.blue
= ~dstColor
.blue
| srcColor
.blue
;
230 dstColor
.red
= 0xFFFF ;
231 dstColor
.green
= 0xFFFF ;
232 dstColor
.blue
= 0xFFFF ;
234 case wxSRC_INVERT
: // (NOT src)
235 dstColor
.red
= ~srcColor
.red
;
236 dstColor
.green
= ~srcColor
.green
;
237 dstColor
.blue
= ~srcColor
.blue
;
239 case wxXOR
: // src XOR dst
240 dstColor
.red
= dstColor
.red
^ srcColor
.red
;
241 dstColor
.green
= dstColor
.green
^ srcColor
.green
;
242 dstColor
.blue
= dstColor
.blue
^ srcColor
.blue
;
251 m_mm_to_pix_x
= mm2pt
;
252 m_mm_to_pix_y
= mm2pt
;
253 m_internalDeviceOriginX
= 0;
254 m_internalDeviceOriginY
= 0;
255 m_externalDeviceOriginX
= 0;
256 m_externalDeviceOriginY
= 0;
257 m_logicalScaleX
= 1.0;
258 m_logicalScaleY
= 1.0;
263 m_needComputeScaleX
= false;
264 m_needComputeScaleY
= false;
268 m_macFontInstalled
= false ;
269 m_macBrushInstalled
= false ;
270 m_macPenInstalled
= false ;
271 m_macLocalOrigin
.x
= m_macLocalOrigin
.y
= 0 ;
272 m_macBoundaryClipRgn
= NewRgn() ;
273 m_macCurrentClipRgn
= NewRgn() ;
274 SetRectRgn( (RgnHandle
) m_macBoundaryClipRgn
, -32000 , -32000 , 32000 , 32000 ) ;
275 SetRectRgn( (RgnHandle
) m_macCurrentClipRgn
, -32000 , -32000 , 32000 , 32000 ) ;
276 m_pen
= *wxBLACK_PEN
;
277 m_font
= *wxNORMAL_FONT
;
278 m_brush
= *wxWHITE_BRUSH
;
280 // needed to debug possible errors with two active drawing methods at the same time on
282 m_macCurrentPortStateHelper
= NULL
;
284 m_macATSUIStyle
= NULL
;
285 m_macAliasWasEnabled
= false;
286 m_macForegroundPixMap
= NULL
;
287 m_macBackgroundPixMap
= NULL
;
292 DisposeRgn( (RgnHandle
) m_macBoundaryClipRgn
) ;
293 DisposeRgn( (RgnHandle
) m_macCurrentClipRgn
) ;
296 void wxDC::MacSetupPort(wxMacPortStateHelper
* help
) const
299 wxASSERT( m_macCurrentPortStateHelper
== NULL
) ;
300 m_macCurrentPortStateHelper
= help
;
302 SetClip( (RgnHandle
) m_macCurrentClipRgn
);
303 #if ! wxMAC_EXPERIMENTAL_DC
304 m_macFontInstalled
= false ;
305 m_macBrushInstalled
= false ;
306 m_macPenInstalled
= false ;
309 void wxDC::MacCleanupPort(wxMacPortStateHelper
* help
) const
312 wxASSERT( m_macCurrentPortStateHelper
== help
) ;
313 m_macCurrentPortStateHelper
= NULL
;
315 if( m_macATSUIStyle
)
317 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUIStyle
);
318 m_macATSUIStyle
= NULL
;
320 if ( m_macAliasWasEnabled
)
322 SetAntiAliasedTextEnabled(m_macFormerAliasState
, m_macFormerAliasSize
);
323 m_macAliasWasEnabled
= false ;
325 if ( m_macForegroundPixMap
)
328 ::PenPat(GetQDGlobalsBlack(&blackColor
));
329 DisposePixPat( (PixPatHandle
) m_macForegroundPixMap
) ;
330 m_macForegroundPixMap
= NULL
;
332 if ( m_macBackgroundPixMap
)
335 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
336 DisposePixPat( (PixPatHandle
) m_macBackgroundPixMap
) ;
337 m_macBackgroundPixMap
= NULL
;
341 void wxDC::DoDrawBitmap( const wxBitmap
&bmp
, wxCoord x
, wxCoord y
, bool useMask
)
343 wxCHECK_RET( Ok(), wxT("invalid window dc") );
344 wxCHECK_RET( bmp
.Ok(), wxT("invalid bitmap") );
345 wxMacFastPortSetter
helper(this) ;
346 wxCoord xx
= XLOG2DEVMAC(x
);
347 wxCoord yy
= YLOG2DEVMAC(y
);
348 wxCoord w
= bmp
.GetWidth();
349 wxCoord h
= bmp
.GetHeight();
350 wxCoord ww
= XLOG2DEVREL(w
);
351 wxCoord hh
= YLOG2DEVREL(h
);
352 // Set up drawing mode
353 short mode
= (m_logicalFunction
== wxCOPY
? srcCopy
:
354 //m_logicalFunction == wxCLEAR ? WHITENESS :
355 //m_logicalFunction == wxSET ? BLACKNESS :
356 m_logicalFunction
== wxINVERT
? hilite
:
357 //m_logicalFunction == wxAND ? MERGECOPY :
358 m_logicalFunction
== wxOR
? srcOr
:
359 m_logicalFunction
== wxSRC_INVERT
? notSrcCopy
:
360 m_logicalFunction
== wxXOR
? srcXor
:
361 m_logicalFunction
== wxOR_REVERSE
? notSrcOr
:
362 //m_logicalFunction == wxAND_REVERSE ? SRCERASE :
363 //m_logicalFunction == wxSRC_OR ? srcOr :
364 //m_logicalFunction == wxSRC_AND ? SRCAND :
367 GWorldPtr maskworld
= NULL
;
368 GWorldPtr bmapworld
= MAC_WXHBITMAP( bmp
.GetHBITMAP((WXHBITMAP
*)&maskworld
) );
369 PixMapHandle bmappixels
;
370 // Set foreground and background colours (for bitmaps depth = 1)
371 if(bmp
.GetDepth() == 1)
373 RGBColor fore
= MAC_WXCOLORREF(m_textForegroundColour
.GetPixel());
374 RGBColor back
= MAC_WXCOLORREF(m_textBackgroundColour
.GetPixel());
380 RGBColor white
= { 0xFFFF, 0xFFFF,0xFFFF} ;
381 RGBColor black
= { 0,0,0} ;
382 RGBForeColor( &black
) ;
383 RGBBackColor( &white
) ;
385 bmappixels
= GetGWorldPixMap( bmapworld
) ;
386 wxCHECK_RET(LockPixels(bmappixels
),
387 wxT("DoDrawBitmap: Unable to lock pixels"));
388 Rect source
= { 0, 0, h
, w
};
389 Rect dest
= { yy
, xx
, yy
+ hh
, xx
+ ww
};
390 if ( useMask
&& maskworld
)
392 if( LockPixels(GetGWorldPixMap(MAC_WXHBITMAP(maskworld
))))
396 GetPortBitMapForCopyBits(bmapworld
),
397 GetPortBitMapForCopyBits(MAC_WXHBITMAP(maskworld
)),
398 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ),
399 &source
, &source
, &dest
, mode
, NULL
401 UnlockPixels(GetGWorldPixMap(MAC_WXHBITMAP(maskworld
)));
405 CopyBits( GetPortBitMapForCopyBits( bmapworld
),
406 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ),
407 &source
, &dest
, mode
, NULL
) ;
409 UnlockPixels( bmappixels
) ;
411 m_macPenInstalled
= false ;
412 m_macBrushInstalled
= false ;
413 m_macFontInstalled
= false ;
416 void wxDC::DoDrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
)
418 wxCHECK_RET(Ok(), wxT("Invalid dc wxDC::DoDrawIcon"));
419 wxCHECK_RET(icon
.Ok(), wxT("Invalid icon wxDC::DoDrawIcon"));
420 wxMacFastPortSetter
helper(this) ;
422 wxCoord xx
= XLOG2DEVMAC(x
);
423 wxCoord yy
= YLOG2DEVMAC(y
);
424 wxCoord w
= icon
.GetWidth();
425 wxCoord h
= icon
.GetHeight();
426 wxCoord ww
= XLOG2DEVREL(w
);
427 wxCoord hh
= YLOG2DEVREL(h
);
429 Rect r
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
430 PlotIconRef( &r
, kAlignNone
, kTransformNone
, kPlotIconRefNormalFlags
, MAC_WXHICON( icon
.GetHICON() ) ) ;
433 void wxDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
435 wxCHECK_RET(Ok(), wxT("wxDC::DoSetClippingRegion Invalid DC"));
436 wxCoord xx
, yy
, ww
, hh
;
439 ww
= XLOG2DEVREL(width
);
440 hh
= YLOG2DEVREL(height
);
441 SetRectRgn( (RgnHandle
) m_macCurrentClipRgn
, xx
, yy
, xx
+ ww
, yy
+ hh
) ;
442 SectRgn( (RgnHandle
) m_macCurrentClipRgn
, (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
445 m_clipX1
= wxMax( m_clipX1
, xx
);
446 m_clipY1
= wxMax( m_clipY1
, yy
);
447 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
));
448 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
));
460 void wxDC::DoSetClippingRegionAsRegion( const wxRegion
®ion
)
462 wxCHECK_RET( Ok(), wxT("invalid window dc") ) ;
463 wxMacFastPortSetter
helper(this) ;
465 region
.GetBox( x
, y
, w
, h
);
466 wxCoord xx
, yy
, ww
, hh
;
471 // if we have a scaling that we cannot map onto native regions
472 // we must use the box
473 if ( ww
!= w
|| hh
!= h
)
475 wxDC::DoSetClippingRegion( x
, y
, w
, h
);
479 CopyRgn( (RgnHandle
) region
.GetWXHRGN() , (RgnHandle
) m_macCurrentClipRgn
) ;
480 if ( xx
!= x
|| yy
!= y
)
482 OffsetRgn( (RgnHandle
) m_macCurrentClipRgn
, xx
- x
, yy
- y
) ;
484 SectRgn( (RgnHandle
) m_macCurrentClipRgn
, (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
487 m_clipX1
= wxMax( m_clipX1
, xx
);
488 m_clipY1
= wxMax( m_clipY1
, yy
);
489 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
));
490 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
));
503 void wxDC::DestroyClippingRegion()
505 wxMacFastPortSetter
helper(this) ;
506 CopyRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
510 void wxDC::DoGetSizeMM( int* width
, int* height
) const
515 *width
= long( double(w
) / (m_scaleX
*m_mm_to_pix_x
) );
516 *height
= long( double(h
) / (m_scaleY
*m_mm_to_pix_y
) );
519 void wxDC::SetTextForeground( const wxColour
&col
)
521 wxCHECK_RET(Ok(), wxT("Invalid DC"));
522 m_textForegroundColour
= col
;
523 m_macFontInstalled
= false ;
526 void wxDC::SetTextBackground( const wxColour
&col
)
528 wxCHECK_RET(Ok(), wxT("Invalid DC"));
529 m_textBackgroundColour
= col
;
530 m_macFontInstalled
= false ;
533 void wxDC::SetMapMode( int mode
)
538 SetLogicalScale( twips2mm
*m_mm_to_pix_x
, twips2mm
*m_mm_to_pix_y
);
541 SetLogicalScale( pt2mm
*m_mm_to_pix_x
, pt2mm
*m_mm_to_pix_y
);
544 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
547 SetLogicalScale( m_mm_to_pix_x
/10.0, m_mm_to_pix_y
/10.0 );
551 SetLogicalScale( 1.0, 1.0 );
554 if (mode
!= wxMM_TEXT
)
556 m_needComputeScaleX
= true;
557 m_needComputeScaleY
= true;
561 void wxDC::SetUserScale( double x
, double y
)
563 // allow negative ? -> no
566 ComputeScaleAndOrigin();
569 void wxDC::SetLogicalScale( double x
, double y
)
574 ComputeScaleAndOrigin();
577 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
579 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
580 m_logicalOriginY
= y
* m_signY
;
581 ComputeScaleAndOrigin();
584 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
586 m_externalDeviceOriginX
= x
;
587 m_externalDeviceOriginY
= y
;
588 ComputeScaleAndOrigin();
591 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
593 m_signX
= (xLeftRight
? 1 : -1);
594 m_signY
= (yBottomUp
? -1 : 1);
595 ComputeScaleAndOrigin();
598 wxSize
wxDC::GetPPI() const
600 return wxSize(72, 72);
603 int wxDC::GetDepth() const
605 if ( IsPortColor( (CGrafPtr
) m_macPort
) )
607 return ( (**GetPortPixMap( (CGrafPtr
) m_macPort
)).pixelSize
) ;
612 void wxDC::ComputeScaleAndOrigin()
614 // CMB: copy scale to see if it changes
615 double origScaleX
= m_scaleX
;
616 double origScaleY
= m_scaleY
;
617 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
618 m_scaleY
= m_logicalScaleY
* m_userScaleY
;
619 m_deviceOriginX
= m_internalDeviceOriginX
+ m_externalDeviceOriginX
;
620 m_deviceOriginY
= m_internalDeviceOriginY
+ m_externalDeviceOriginY
;
621 // CMB: if scale has changed call SetPen to recalulate the line width
622 if (m_scaleX
!= origScaleX
|| m_scaleY
!= origScaleY
)
624 // this is a bit artificial, but we need to force wxDC to think
625 // the pen has changed
632 void wxDC::SetPalette( const wxPalette
& palette
)
636 void wxDC::SetBackgroundMode( int mode
)
638 m_backgroundMode
= mode
;
641 void wxDC::SetFont( const wxFont
&font
)
644 m_macFontInstalled
= false ;
647 void wxDC::SetPen( const wxPen
&pen
)
652 m_macPenInstalled
= false ;
655 void wxDC::SetBrush( const wxBrush
&brush
)
657 if (m_brush
== brush
)
660 m_macBrushInstalled
= false ;
663 void wxDC::SetBackground( const wxBrush
&brush
)
665 if (m_backgroundBrush
== brush
)
667 m_backgroundBrush
= brush
;
668 if (!m_backgroundBrush
.Ok())
670 m_macBrushInstalled
= false ;
673 void wxDC::SetLogicalFunction( int function
)
675 if (m_logicalFunction
== function
)
677 m_logicalFunction
= function
;
678 m_macFontInstalled
= false ;
679 m_macBrushInstalled
= false ;
680 m_macPenInstalled
= false ;
683 extern bool wxDoFloodFill(wxDC
*dc
, wxCoord x
, wxCoord y
,
684 const wxColour
& col
, int style
);
686 bool wxDC::DoFloodFill(wxCoord x
, wxCoord y
,
687 const wxColour
& col
, int style
)
689 return wxDoFloodFill(this, x
, y
, col
, style
);
692 bool wxDC::DoGetPixel( wxCoord x
, wxCoord y
, wxColour
*col
) const
694 wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel Invalid DC") );
695 wxMacFastPortSetter
helper(this) ;
697 GetCPixel( XLOG2DEVMAC(x
), YLOG2DEVMAC(y
), &colour
);
698 // Convert from Mac colour to wx
699 col
->Set( colour
.red
>> 8,
705 void wxDC::DoDrawLine( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
707 wxCHECK_RET(Ok(), wxT("Invalid DC"));
708 wxMacFastPortSetter
helper(this) ;
709 if (m_pen
.GetStyle() != wxTRANSPARENT
)
712 wxCoord offset
= ( (m_pen
.GetWidth() == 0 ? 1 :
713 m_pen
.GetWidth() ) * (wxCoord
)m_scaleX
- 1) / 2;
714 wxCoord xx1
= XLOG2DEVMAC(x1
) - offset
;
715 wxCoord yy1
= YLOG2DEVMAC(y1
) - offset
;
716 wxCoord xx2
= XLOG2DEVMAC(x2
) - offset
;
717 wxCoord yy2
= YLOG2DEVMAC(y2
) - offset
;
718 if ((m_pen
.GetCap() == wxCAP_ROUND
) &&
719 (m_pen
.GetWidth() <= 1))
721 // Implement LAST_NOT for MAC at least for
722 // orthogonal lines. RR.
743 void wxDC::DoCrossHair( wxCoord x
, wxCoord y
)
745 wxCHECK_RET( Ok(), wxT("wxDC::DoCrossHair Invalid window dc") );
746 wxMacFastPortSetter
helper(this) ;
747 if (m_pen
.GetStyle() != wxTRANSPARENT
)
752 wxCoord xx
= XLOG2DEVMAC(x
);
753 wxCoord yy
= YLOG2DEVMAC(y
);
755 ::MoveTo( XLOG2DEVMAC(0), yy
);
756 ::LineTo( XLOG2DEVMAC(w
), yy
);
757 ::MoveTo( xx
, YLOG2DEVMAC(0) );
758 ::LineTo( xx
, YLOG2DEVMAC(h
) );
759 CalcBoundingBox(x
, y
);
760 CalcBoundingBox(x
+w
, y
+h
);
765 * To draw arcs properly the angles need to be converted from the WX style:
766 * Angles start on the +ve X axis and go anti-clockwise (As you would draw on
767 * a normal axis on paper).
770 * Angles start on the +ve y axis and go clockwise.
773 static double wxConvertWXangleToMACangle(double angle
)
775 double newAngle
= 90 - angle
;
776 while ( newAngle
> 360 ) newAngle
-= 360 ;
777 while ( newAngle
< 0 ) newAngle
+= 360 ;
781 void wxDC::DoDrawArc( wxCoord x1
, wxCoord y1
,
782 wxCoord x2
, wxCoord y2
,
783 wxCoord xc
, wxCoord yc
)
785 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawArc Invalid DC"));
786 wxMacFastPortSetter
helper(this) ;
787 wxCoord xx1
= XLOG2DEVMAC(x1
);
788 wxCoord yy1
= YLOG2DEVMAC(y1
);
789 wxCoord xx2
= XLOG2DEVMAC(x2
);
790 wxCoord yy2
= YLOG2DEVMAC(y2
);
791 wxCoord xxc
= XLOG2DEVMAC(xc
);
792 wxCoord yyc
= YLOG2DEVMAC(yc
);
793 double dx
= xx1
- xxc
;
794 double dy
= yy1
- yyc
;
795 double radius
= sqrt((double)(dx
*dx
+dy
*dy
));
796 wxCoord rad
= (wxCoord
)radius
;
797 double radius1
, radius2
;
798 if (xx1
== xx2
&& yy1
== yy2
)
803 else if (radius
== 0.0)
805 radius1
= radius2
= 0.0;
809 radius1
= (xx1
- xxc
== 0) ?
810 (yy1
- yyc
< 0) ? 90.0 : -90.0 :
811 -atan2(double(yy1
-yyc
), double(xx1
-xxc
)) * RAD2DEG
;
812 radius2
= (xx2
- xxc
== 0) ?
813 (yy2
- yyc
< 0) ? 90.0 : -90.0 :
814 -atan2(double(yy2
-yyc
), double(xx2
-xxc
)) * RAD2DEG
;
816 wxCoord alpha2
= wxCoord(radius2
- radius1
);
817 wxCoord alpha1
= wxCoord(wxConvertWXangleToMACangle(radius1
));
818 while( alpha2
< 0 ) alpha2
+= 360 ;
820 Rect r
= { yyc
- rad
, xxc
- rad
, yyc
+ rad
, xxc
+ rad
};
821 if(m_brush
.GetStyle() != wxTRANSPARENT
) {
823 PaintArc(&r
, alpha1
, alpha2
);
825 if(m_pen
.GetStyle() != wxTRANSPARENT
) {
827 FrameArc(&r
, alpha1
, alpha2
);
831 void wxDC::DoDrawEllipticArc( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
832 double sa
, double ea
)
834 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawEllepticArc Invalid DC"));
835 wxMacFastPortSetter
helper(this) ;
837 double angle
= sa
- ea
; // Order important Mac in opposite direction to wx
838 // we have to make sure that the filling is always counter-clockwise
841 wxCoord xx
= XLOG2DEVMAC(x
);
842 wxCoord yy
= YLOG2DEVMAC(y
);
843 wxCoord ww
= m_signX
* XLOG2DEVREL(w
);
844 wxCoord hh
= m_signY
* YLOG2DEVREL(h
);
845 // handle -ve width and/or height
846 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
847 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
848 sa
= wxConvertWXangleToMACangle(sa
);
853 if(m_brush
.GetStyle() != wxTRANSPARENT
) {
855 PaintArc(&r
, (short)sa
, (short)angle
);
857 if(m_pen
.GetStyle() != wxTRANSPARENT
) {
859 FrameArc(&r
, (short)sa
, (short)angle
);
863 void wxDC::DoDrawPoint( wxCoord x
, wxCoord y
)
865 wxCHECK_RET(Ok(), wxT("Invalid DC"));
866 wxMacFastPortSetter
helper(this) ;
867 if (m_pen
.GetStyle() != wxTRANSPARENT
)
869 wxCoord xx1
= XLOG2DEVMAC(x
);
870 wxCoord yy1
= YLOG2DEVMAC(y
);
871 RGBColor pencolor
= MAC_WXCOLORREF( m_pen
.GetColour().GetPixel());
872 ::SetCPixel( xx1
,yy1
,&pencolor
) ;
873 CalcBoundingBox(x
, y
);
877 void wxDC::DoDrawLines(int n
, wxPoint points
[],
878 wxCoord xoffset
, wxCoord yoffset
)
880 wxCHECK_RET(Ok(), wxT("Invalid DC"));
881 wxMacFastPortSetter
helper(this) ;
882 if (m_pen
.GetStyle() == wxTRANSPARENT
)
885 wxCoord offset
= ( (m_pen
.GetWidth() == 0 ? 1 :
886 m_pen
.GetWidth() ) * (wxCoord
)m_scaleX
- 1) / 2 ;
887 wxCoord x1
, x2
, y1
, y2
;
888 x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
889 y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
890 ::MoveTo(x1
- offset
, y1
- offset
);
891 for (int i
= 0; i
< n
-1; i
++)
893 x2
= XLOG2DEVMAC(points
[i
+1].x
+ xoffset
);
894 y2
= YLOG2DEVMAC(points
[i
+1].y
+ yoffset
);
895 ::LineTo( x2
- offset
, y2
- offset
);
899 void wxDC::DoDrawPolygon(int n
, wxPoint points
[],
900 wxCoord xoffset
, wxCoord yoffset
,
903 wxCHECK_RET(Ok(), wxT("Invalid DC"));
904 wxMacFastPortSetter
helper(this) ;
905 wxCoord x1
, x2
, y1
, y2
;
906 if ( m_brush
.GetStyle() == wxTRANSPARENT
&& m_pen
.GetStyle() == wxTRANSPARENT
)
908 PolyHandle polygon
= OpenPoly();
909 x2
= x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
910 y2
= y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
912 for (int i
= 1; i
< n
; i
++)
914 x2
= XLOG2DEVMAC(points
[i
].x
+ xoffset
);
915 y2
= YLOG2DEVMAC(points
[i
].y
+ yoffset
);
918 // close the polyline if necessary
919 if ( x1
!= x2
|| y1
!= y2
)
924 if (m_brush
.GetStyle() != wxTRANSPARENT
)
927 ::PaintPoly( polygon
);
929 if (m_pen
.GetStyle() != wxTRANSPARENT
)
932 ::FramePoly( polygon
) ;
937 void wxDC::DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
939 wxCHECK_RET(Ok(), wxT("Invalid DC"));
940 wxMacFastPortSetter
helper(this) ;
941 wxCoord xx
= XLOG2DEVMAC(x
);
942 wxCoord yy
= YLOG2DEVMAC(y
);
943 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
944 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
945 // CMB: draw nothing if transformed w or h is 0
946 if (ww
== 0 || hh
== 0)
948 // CMB: handle -ve width and/or height
959 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
960 if (m_brush
.GetStyle() != wxTRANSPARENT
)
963 ::PaintRect( &rect
) ;
965 if (m_pen
.GetStyle() != wxTRANSPARENT
)
968 ::FrameRect( &rect
) ;
972 void wxDC::DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
973 wxCoord width
, wxCoord height
,
976 wxCHECK_RET(Ok(), wxT("Invalid DC"));
977 wxMacFastPortSetter
helper(this) ;
979 radius
= - radius
* ((width
< height
) ? width
: height
);
980 wxCoord xx
= XLOG2DEVMAC(x
);
981 wxCoord yy
= YLOG2DEVMAC(y
);
982 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
983 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
984 // CMB: draw nothing if transformed w or h is 0
985 if (ww
== 0 || hh
== 0)
987 // CMB: handle -ve width and/or height
998 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
999 if (m_brush
.GetStyle() != wxTRANSPARENT
)
1002 ::PaintRoundRect( &rect
, int(radius
* 2) , int(radius
* 2) ) ;
1004 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1007 ::FrameRoundRect( &rect
, int(radius
* 2) , int(radius
* 2) ) ;
1011 void wxDC::DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1013 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1014 wxMacFastPortSetter
helper(this) ;
1015 wxCoord xx
= XLOG2DEVMAC(x
);
1016 wxCoord yy
= YLOG2DEVMAC(y
);
1017 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1018 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1019 // CMB: draw nothing if transformed w or h is 0
1020 if (ww
== 0 || hh
== 0)
1022 // CMB: handle -ve width and/or height
1033 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
1034 if (m_brush
.GetStyle() != wxTRANSPARENT
)
1037 ::PaintOval( &rect
) ;
1039 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1042 ::FrameOval( &rect
) ;
1046 bool wxDC::CanDrawBitmap(void) const
1051 bool wxDC::DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1052 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
, int logical_func
, bool useMask
,
1053 wxCoord xsrcMask
, wxCoord ysrcMask
)
1055 wxCHECK_MSG(Ok(), false, wxT("wxDC::DoBlit Illegal dc"));
1056 wxCHECK_MSG(source
->Ok(), false, wxT("wxDC::DoBlit Illegal source DC"));
1057 if ( logical_func
== wxNO_OP
)
1059 if (xsrcMask
== -1 && ysrcMask
== -1)
1061 xsrcMask
= xsrc
; ysrcMask
= ysrc
;
1063 // correct the parameter in case this dc does not have a mask at all
1064 if ( useMask
&& !source
->m_macMask
)
1066 Rect srcrect
, dstrect
;
1067 srcrect
.top
= source
->YLOG2DEVMAC(ysrc
) ;
1068 srcrect
.left
= source
->XLOG2DEVMAC(xsrc
) ;
1069 srcrect
.right
= source
->XLOG2DEVMAC(xsrc
+ width
) ;
1070 srcrect
.bottom
= source
->YLOG2DEVMAC(ysrc
+ height
) ;
1071 dstrect
.top
= YLOG2DEVMAC(ydest
) ;
1072 dstrect
.left
= XLOG2DEVMAC(xdest
) ;
1073 dstrect
.bottom
= YLOG2DEVMAC(ydest
+ height
) ;
1074 dstrect
.right
= XLOG2DEVMAC(xdest
+ width
) ;
1075 short mode
= kUnsupportedMode
;
1076 bool invertDestinationFirst
= false ;
1077 switch ( logical_func
)
1079 case wxAND
: // src AND dst
1080 mode
= adMin
; // ok
1082 case wxAND_INVERT
: // (NOT src) AND dst
1083 mode
= notSrcOr
; // ok
1085 case wxAND_REVERSE
:// src AND (NOT dst)
1086 invertDestinationFirst
= true ;
1090 mode
= kEmulatedMode
;
1093 mode
= srcCopy
; // ok
1095 case wxEQUIV
: // (NOT src) XOR dst
1096 mode
= srcXor
; // ok
1098 case wxINVERT
: // NOT dst
1099 mode
= kEmulatedMode
; //or hilite ;
1101 case wxNAND
: // (NOT src) OR (NOT dst)
1102 invertDestinationFirst
= true ;
1105 case wxNOR
: // (NOT src) AND (NOT dst)
1106 invertDestinationFirst
= true ;
1109 case wxNO_OP
: // dst
1110 mode
= kEmulatedMode
; // this has already been handled upon entry
1112 case wxOR
: // src OR dst
1115 case wxOR_INVERT
: // (NOT src) OR dst
1118 case wxOR_REVERSE
: // src OR (NOT dst)
1119 invertDestinationFirst
= true ;
1123 mode
= kEmulatedMode
;
1125 case wxSRC_INVERT
: // (NOT src)
1126 mode
= notSrcCopy
; // ok
1128 case wxXOR
: // src XOR dst
1129 mode
= notSrcXor
; // ok
1134 if ( mode
== kUnsupportedMode
)
1136 wxFAIL_MSG(wxT("unsupported blitting mode" ));
1139 CGrafPtr sourcePort
= (CGrafPtr
) source
->m_macPort
;
1140 PixMapHandle bmappixels
= GetGWorldPixMap( sourcePort
) ;
1141 if ( LockPixels(bmappixels
) )
1143 wxMacFastPortSetter
helper(this) ;
1144 if ( source
->GetDepth() == 1 )
1146 RGBForeColor( &MAC_WXCOLORREF(m_textForegroundColour
.GetPixel()) ) ;
1147 RGBBackColor( &MAC_WXCOLORREF(m_textBackgroundColour
.GetPixel()) ) ;
1151 // the modes need this, otherwise we'll end up having really nice colors...
1152 RGBColor white
= { 0xFFFF, 0xFFFF,0xFFFF} ;
1153 RGBColor black
= { 0,0,0} ;
1154 RGBForeColor( &black
) ;
1155 RGBBackColor( &white
) ;
1157 if ( useMask
&& source
->m_macMask
)
1159 if ( mode
== srcCopy
)
1161 if ( LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) )
1163 CopyMask( GetPortBitMapForCopyBits( sourcePort
) ,
1164 GetPortBitMapForCopyBits( MAC_WXHBITMAP(source
->m_macMask
) ) ,
1165 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1166 &srcrect
, &srcrect
, &dstrect
) ;
1167 UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1172 RgnHandle clipRgn
= NewRgn() ;
1173 LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1174 BitMapToRegion( clipRgn
, (BitMap
*) *GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1175 UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1176 OffsetRgn( clipRgn
, -srcrect
.left
+ dstrect
.left
, -srcrect
.top
+ dstrect
.top
) ;
1177 if ( mode
== kEmulatedMode
)
1180 ::PenPat(GetQDGlobalsBlack(&pat
));
1181 if ( logical_func
== wxSET
)
1183 RGBColor col
= { 0xFFFF, 0xFFFF, 0xFFFF } ;
1184 ::RGBForeColor( &col
) ;
1185 ::PaintRgn( clipRgn
) ;
1187 else if ( logical_func
== wxCLEAR
)
1189 RGBColor col
= { 0x0000, 0x0000, 0x0000 } ;
1190 ::RGBForeColor( &col
) ;
1191 ::PaintRgn( clipRgn
) ;
1193 else if ( logical_func
== wxINVERT
)
1195 MacInvertRgn( clipRgn
) ;
1199 for ( int y
= 0 ; y
< srcrect
.right
- srcrect
.left
; ++y
)
1201 for ( int x
= 0 ; x
< srcrect
.bottom
- srcrect
.top
; ++x
)
1203 Point dstPoint
= { dstrect
.top
+ y
, dstrect
.left
+ x
} ;
1204 Point srcPoint
= { srcrect
.top
+ y
, srcrect
.left
+ x
} ;
1205 if ( PtInRgn( dstPoint
, clipRgn
) )
1209 SetPort( (GrafPtr
) sourcePort
) ;
1210 GetCPixel( srcPoint
.h
, srcPoint
.v
, &srcColor
) ;
1211 SetPort( (GrafPtr
) m_macPort
) ;
1212 GetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1213 wxMacCalculateColour( logical_func
, srcColor
, dstColor
) ;
1214 SetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1222 if ( invertDestinationFirst
)
1224 MacInvertRgn( clipRgn
) ;
1226 CopyBits( GetPortBitMapForCopyBits( sourcePort
) ,
1227 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1228 &srcrect
, &dstrect
, mode
, clipRgn
) ;
1230 DisposeRgn( clipRgn
) ;
1235 RgnHandle clipRgn
= NewRgn() ;
1236 SetRectRgn( clipRgn
, dstrect
.left
, dstrect
.top
, dstrect
.right
, dstrect
.bottom
) ;
1237 if ( mode
== kEmulatedMode
)
1240 ::PenPat(GetQDGlobalsBlack(&pat
));
1241 if ( logical_func
== wxSET
)
1243 RGBColor col
= { 0xFFFF, 0xFFFF, 0xFFFF } ;
1244 ::RGBForeColor( &col
) ;
1245 ::PaintRgn( clipRgn
) ;
1247 else if ( logical_func
== wxCLEAR
)
1249 RGBColor col
= { 0x0000, 0x0000, 0x0000 } ;
1250 ::RGBForeColor( &col
) ;
1251 ::PaintRgn( clipRgn
) ;
1253 else if ( logical_func
== wxINVERT
)
1255 MacInvertRgn( clipRgn
) ;
1259 for ( int y
= 0 ; y
< srcrect
.right
- srcrect
.left
; ++y
)
1261 for ( int x
= 0 ; x
< srcrect
.bottom
- srcrect
.top
; ++x
)
1263 Point dstPoint
= { dstrect
.top
+ y
, dstrect
.left
+ x
} ;
1264 Point srcPoint
= { srcrect
.top
+ y
, srcrect
.left
+ x
} ;
1268 SetPort( (GrafPtr
) sourcePort
) ;
1269 GetCPixel( srcPoint
.h
, srcPoint
.v
, &srcColor
) ;
1270 SetPort( (GrafPtr
) m_macPort
) ;
1271 GetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1272 wxMacCalculateColour( logical_func
, srcColor
, dstColor
) ;
1273 SetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1281 if ( invertDestinationFirst
)
1283 MacInvertRgn( clipRgn
) ;
1285 CopyBits( GetPortBitMapForCopyBits( sourcePort
) ,
1286 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1287 &srcrect
, &dstrect
, mode
, NULL
) ;
1289 DisposeRgn( clipRgn
) ;
1291 UnlockPixels( bmappixels
) ;
1293 m_macPenInstalled
= false ;
1294 m_macBrushInstalled
= false ;
1295 m_macFontInstalled
= false ;
1299 void wxDC::DoDrawRotatedText(const wxString
& str
, wxCoord x
, wxCoord y
,
1302 // TODO support text background color (only possible by hand, ATSUI does not support it)
1303 wxCHECK_RET( Ok(), wxT("wxDC::DoDrawRotatedText Invalid window dc") );
1305 if ( str
.Length() == 0 )
1308 wxMacFastPortSetter
helper(this) ;
1313 m_macFormerAliasState
= IsAntiAliasedTextEnabled(&m_macFormerAliasSize
);
1314 SetAntiAliasedTextEnabled(true, SInt16(m_scaleY
* m_font
.MacGetFontSize()));
1315 m_macAliasWasEnabled
= true ;
1317 OSStatus status
= noErr
;
1318 ATSUTextLayout atsuLayout
;
1319 UniCharCount chars
= str
.Length() ;
1320 UniChar
* ubuf
= NULL
;
1321 #if SIZEOF_WCHAR_T == 4
1322 wxMBConvUTF16 converter
;
1324 size_t unicharlen
= converter
.WC2MB( NULL
, str
.wc_str() , 0 ) ;
1325 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1326 converter
.WC2MB( (char*) ubuf
, str
.wc_str(), unicharlen
+ 2 ) ;
1328 const wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1329 size_t unicharlen
= converter
.WC2MB( NULL
, wchar
.data() , 0 ) ;
1330 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1331 converter
.WC2MB( (char*) ubuf
, wchar
.data() , unicharlen
+ 2 ) ;
1333 chars
= unicharlen
/ 2 ;
1336 ubuf
= (UniChar
*) str
.wc_str() ;
1338 wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1339 chars
= wxWcslen( wchar
.data() ) ;
1340 ubuf
= (UniChar
*) wchar
.data() ;
1344 status
= ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr
) ubuf
, 0 , chars
, chars
, 1 ,
1345 &chars
, (ATSUStyle
*) &m_macATSUIStyle
, &atsuLayout
) ;
1347 wxASSERT_MSG( status
== noErr
, wxT("couldn't create the layout of the rotated text") );
1349 status
= ::ATSUSetTransientFontMatching( atsuLayout
, true ) ;
1350 wxASSERT_MSG( status
== noErr
, wxT("couldn't setup transient font matching") );
1352 int iAngle
= int( angle
);
1353 int drawX
= XLOG2DEVMAC(x
) ;
1354 int drawY
= YLOG2DEVMAC(y
) ;
1356 ATSUTextMeasurement textBefore
;
1357 ATSUTextMeasurement textAfter
;
1358 ATSUTextMeasurement ascent
;
1359 ATSUTextMeasurement descent
;
1362 if ( abs(iAngle
) > 0 )
1364 Fixed atsuAngle
= IntToFixed( iAngle
) ;
1365 ATSUAttributeTag atsuTags
[] =
1367 kATSULineRotationTag
,
1369 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1373 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1377 status
= ::ATSUSetLayoutControls(atsuLayout
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
),
1378 atsuTags
, atsuSizes
, atsuValues
) ;
1380 status
= ::ATSUMeasureText( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1381 &textBefore
, &textAfter
, &ascent
, &descent
);
1383 drawX
+= (int)(sin(angle
/RAD2DEG
) * FixedToInt(ascent
));
1384 drawY
+= (int)(cos(angle
/RAD2DEG
) * FixedToInt(ascent
));
1385 status
= ::ATSUDrawText( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1386 IntToFixed(drawX
) , IntToFixed(drawY
) );
1387 wxASSERT_MSG( status
== noErr
, wxT("couldn't draw the rotated text") );
1389 status
= ::ATSUMeasureTextImage( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1390 IntToFixed(drawX
) , IntToFixed(drawY
) , &rect
);
1391 wxASSERT_MSG( status
== noErr
, wxT("couldn't measure the rotated text") );
1392 OffsetRect( &rect
, -m_macLocalOrigin
.x
, -m_macLocalOrigin
.y
) ;
1393 CalcBoundingBox(XDEV2LOG(rect
.left
), YDEV2LOG(rect
.top
) );
1394 CalcBoundingBox(XDEV2LOG(rect
.right
), YDEV2LOG(rect
.bottom
) );
1395 ::ATSUDisposeTextLayout(atsuLayout
);
1396 #if SIZEOF_WCHAR_T == 4
1401 void wxDC::DoDrawText(const wxString
& strtext
, wxCoord x
, wxCoord y
)
1403 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawText Invalid DC"));
1405 wxMacFastPortSetter
helper(this) ;
1406 long xx
= XLOG2DEVMAC(x
);
1407 long yy
= YLOG2DEVMAC(y
);
1409 bool useDrawThemeText
= ( DrawThemeTextBox
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1410 if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC
) ) || m_font
.GetNoAntiAliasing() )
1411 useDrawThemeText
= false ;
1416 ::GetFontInfo( &fi
) ;
1418 if ( !useDrawThemeText
)
1421 ::MoveTo( xx
, yy
);
1422 if ( m_backgroundMode
== wxTRANSPARENT
)
1424 ::TextMode( srcOr
) ;
1428 ::TextMode( srcCopy
) ;
1432 wxString linetext
= strtext
;
1434 if ( useDrawThemeText
)
1436 Rect frame
= { yy
+ line
*(fi
.descent
+ fi
.ascent
+ fi
.leading
) ,xx
, yy
+ (line
+1)*(fi
.descent
+ fi
.ascent
+ fi
.leading
) , xx
+ 10000 } ;
1437 wxMacCFStringHolder
mString( linetext
, m_font
.GetEncoding()) ;
1439 if ( m_backgroundMode
!= wxTRANSPARENT
)
1441 Point bounds
={0,0} ;
1442 Rect background
= frame
;
1444 ::GetThemeTextDimensions( mString
,
1445 m_font
.MacGetThemeFontID() ,
1450 background
.right
= background
.left
+ bounds
.h
;
1451 background
.bottom
= background
.top
+ bounds
.v
;
1452 ::EraseRect( &background
) ;
1454 ::DrawThemeTextBox( mString
,
1455 m_font
.MacGetThemeFontID() ,
1465 wxCharBuffer text
= linetext
.mb_str(wxConvLocal
) ;
1466 ::DrawText( text
, 0 , strlen(text
) ) ;
1469 ::TextMode( srcOr
) ;
1472 bool wxDC::CanGetTextExtent() const
1474 wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
1478 void wxDC::DoGetTextExtent( const wxString
&strtext
, wxCoord
*width
, wxCoord
*height
,
1479 wxCoord
*descent
, wxCoord
*externalLeading
,
1480 wxFont
*theFont
) const
1482 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1483 wxMacFastPortSetter
helper(this) ;
1484 wxFont formerFont
= m_font
;
1487 // work around the constness
1488 *((wxFont
*)(&m_font
)) = *theFont
;
1492 ::GetFontInfo( &fi
) ;
1494 bool useGetThemeText
= ( GetThemeTextDimensions
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1495 if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC
) ) || ((wxFont
*)&m_font
)->GetNoAntiAliasing() )
1496 useGetThemeText
= false ;
1499 *height
= YDEV2LOGREL( fi
.descent
+ fi
.ascent
) ;
1501 *descent
=YDEV2LOGREL( fi
.descent
);
1502 if ( externalLeading
)
1503 *externalLeading
= YDEV2LOGREL( fi
.leading
) ;
1509 wxString linetext
= strtext
;
1511 if ( useGetThemeText
)
1513 Point bounds
={0,0} ;
1515 wxMacCFStringHolder
mString( linetext
, m_font
.GetEncoding() ) ;
1516 ThemeFontID themeFont
= m_font
.MacGetThemeFontID() ;
1517 ::GetThemeTextDimensions( mString
,
1523 curwidth
= bounds
.h
;
1527 wxCharBuffer text
= linetext
.mb_str(wxConvLocal
) ;
1528 curwidth
= ::TextWidth( text
, 0 , strlen(text
) ) ;
1530 if ( curwidth
> *width
)
1531 *width
= XDEV2LOGREL( curwidth
) ;
1535 // work around the constness
1536 *((wxFont
*)(&m_font
)) = formerFont
;
1537 m_macFontInstalled
= false ;
1542 bool wxDC::DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
1544 wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
1547 widths
.Add(0, text
.Length());
1549 if (text
.Length() == 0)
1552 wxMacFastPortSetter
helper(this) ;
1555 bool useGetThemeText
= ( GetThemeTextDimensions
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1556 if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC
) ) || ((wxFont
*)&m_font
)->GetNoAntiAliasing() )
1557 useGetThemeText
= false ;
1559 if ( useGetThemeText
)
1561 // If anybody knows how to do this more efficiently yet still handle
1562 // the fractional glyph widths that may be present when using AA
1563 // fonts, please change it. Currently it is measuring from the
1564 // begining of the string for each succeding substring, which is much
1565 // slower than this should be.
1566 for (size_t i
=0; i
<text
.Length(); i
++)
1568 wxString
str(text
.Left(i
+1));
1569 Point bounds
= {0,0};
1571 wxMacCFStringHolder
mString(str
, m_font
.GetEncoding());
1572 ::GetThemeTextDimensions( mString
,
1573 m_font
.MacGetThemeFontID(),
1578 widths
[i
] = XDEV2LOGREL(bounds
.h
);
1584 wxCharBuffer buff
= text
.mb_str(wxConvLocal
);
1585 size_t len
= strlen(buff
);
1586 short* measurements
= new short[len
+1];
1587 MeasureText(len
, buff
.data(), measurements
);
1589 // Copy to widths, starting at measurements[1]
1590 // NOTE: this doesn't take into account any multi-byte characters
1591 // in buff, it probabkly should...
1592 for (size_t i
=0; i
<text
.Length(); i
++)
1593 widths
[i
] = XDEV2LOGREL(measurements
[i
+1]);
1595 delete [] measurements
;
1603 wxCoord
wxDC::GetCharWidth(void) const
1605 wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
1606 wxMacFastPortSetter
helper(this) ;
1610 bool useGetThemeText
= ( GetThemeTextDimensions
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1611 if ( UMAGetSystemVersion() < 0x1000 || ((wxFont
*)&m_font
)->GetNoAntiAliasing() )
1612 useGetThemeText
= false ;
1616 if ( useGetThemeText
)
1618 Point bounds
={0,0} ;
1620 CFStringRef mString
= CFStringCreateWithBytes( NULL
, (UInt8
*) text
, 1 , CFStringGetSystemEncoding(), false ) ;
1621 ::GetThemeTextDimensions( mString
,
1622 m_font
.MacGetThemeFontID(),
1627 CFRelease( mString
) ;
1633 width
= ::TextWidth( text
, 0 , 1 ) ;
1635 return YDEV2LOGREL(width
) ;
1638 wxCoord
wxDC::GetCharHeight(void) const
1640 wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
1641 wxMacFastPortSetter
helper(this) ;
1644 ::GetFontInfo( &fi
) ;
1645 return YDEV2LOGREL( fi
.descent
+ fi
.ascent
);
1648 void wxDC::Clear(void)
1650 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1651 wxMacFastPortSetter
helper(this) ;
1652 Rect rect
= { -31000 , -31000 , 31000 , 31000 } ;
1653 if ( m_backgroundBrush
.Ok() && m_backgroundBrush
.GetStyle() != wxTRANSPARENT
)
1656 MacSetupBackgroundForCurrentPort( m_backgroundBrush
) ;
1657 ::EraseRect( &rect
) ;
1661 void wxDC::MacInstallFont() const
1663 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1664 // if ( m_macFontInstalled )
1666 Pattern blackColor
;
1667 MacSetupBackgroundForCurrentPort(m_backgroundBrush
) ;
1668 if ( m_backgroundMode
!= wxTRANSPARENT
)
1670 Pattern whiteColor
;
1671 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
1674 wxASSERT( m_font
.Ok() ) ;
1677 ::TextFont( m_font
.MacGetFontNum() ) ;
1678 ::TextSize( (short)(m_scaleY
* m_font
.MacGetFontSize()) ) ;
1679 ::TextFace( m_font
.MacGetFontStyle() ) ;
1680 m_macFontInstalled
= true ;
1681 m_macBrushInstalled
= false ;
1682 m_macPenInstalled
= false ;
1683 RGBColor forecolor
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel());
1684 RGBColor backcolor
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel());
1685 ::RGBForeColor( &forecolor
);
1686 ::RGBBackColor( &backcolor
);
1688 short mode
= patCopy
;
1690 switch( m_logicalFunction
)
1695 case wxINVERT
: // NOT dst
1696 ::PenPat(GetQDGlobalsBlack(&blackColor
));
1699 case wxXOR
: // src XOR dst
1702 case wxOR_REVERSE
: // src OR (NOT dst)
1705 case wxSRC_INVERT
: // (NOT src)
1708 case wxAND
: // src AND dst
1713 case wxAND_REVERSE
:// src AND (NOT dst)
1714 case wxAND_INVERT
: // (NOT src) AND dst
1715 case wxNO_OP
: // dst
1716 case wxNOR
: // (NOT src) AND (NOT dst)
1717 case wxEQUIV
: // (NOT src) XOR dst
1718 case wxOR_INVERT
: // (NOT src) OR dst
1719 case wxNAND
: // (NOT src) OR (NOT dst)
1720 case wxOR
: // src OR dst
1722 // case wxSRC_OR: // source _bitmap_ OR destination
1723 // case wxSRC_AND: // source _bitmap_ AND destination
1727 OSStatus status
= noErr
;
1728 status
= ATSUCreateAndCopyStyle( (ATSUStyle
) m_font
.MacGetATSUStyle() , (ATSUStyle
*) &m_macATSUIStyle
) ;
1729 wxASSERT_MSG( status
== noErr
, wxT("couldn't set create ATSU style") ) ;
1731 Fixed atsuSize
= IntToFixed( int(m_scaleY
* m_font
.MacGetFontSize()) ) ;
1732 ATSUAttributeTag atsuTags
[] =
1736 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1740 // Boolean kTrue = true ;
1741 // Boolean kFalse = false ;
1743 // ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal;
1744 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1748 status
= ::ATSUSetAttributes((ATSUStyle
)m_macATSUIStyle
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
) ,
1749 atsuTags
, atsuSizes
, atsuValues
);
1751 wxASSERT_MSG( status
== noErr
, wxT("couldn't Modify ATSU style") ) ;
1755 Pattern gPatterns
[] =
1757 { { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF } } ,
1758 { { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 } } ,
1759 { { 0x80 , 0x40 , 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , 0x01 } } ,
1760 { { 0x10 , 0x10 , 0x10 , 0xFF , 0x10 , 0x10 , 0x10 , 0x10 } } ,
1761 { { 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 } } ,
1762 { { 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 } } ,
1763 { { 0x81 , 0x42 , 0x24 , 0x18 , 0x18 , 0x24 , 0x42 , 0x81 } } ,
1765 { { 0xCC , 0x99 , 0x33 , 0x66 , 0xCC , 0x99 , 0x33 , 0x66 } } , // DOT
1766 { { 0xFE , 0xFD , 0xFB , 0xF7 , 0xEF , 0xDF , 0xBF , 0x7F } } , // LONG_DASH
1767 { { 0xEE , 0xDD , 0xBB , 0x77 , 0xEE , 0xDD , 0xBB , 0x77 } } , // SHORT_DASH
1768 { { 0xDE , 0xBD , 0x7B , 0xF6 , 0xED , 0xDB , 0xB7 , 0x6F } } , // DOT_DASH
1771 static void wxMacGetPattern(int penStyle
, Pattern
*pattern
)
1773 int index
= 0; // solid pattern by default
1777 case wxBDIAGONAL_HATCH
: index
= 1; break;
1778 case wxFDIAGONAL_HATCH
: index
= 2; break;
1779 case wxCROSS_HATCH
: index
= 3; break;
1780 case wxHORIZONTAL_HATCH
: index
= 4; break;
1781 case wxVERTICAL_HATCH
: index
= 5; break;
1782 case wxCROSSDIAG_HATCH
: index
= 6; break;
1784 case wxDOT
: index
= 7; break;
1785 case wxLONG_DASH
: index
= 8; break;
1786 case wxSHORT_DASH
: index
= 9; break;
1787 case wxDOT_DASH
: index
= 10; break;
1789 *pattern
= gPatterns
[index
];
1792 void wxDC::MacInstallPen() const
1794 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1795 //Pattern blackColor;
1796 // if ( m_macPenInstalled )
1798 RGBColor forecolor
= MAC_WXCOLORREF( m_pen
.GetColour().GetPixel());
1799 RGBColor backcolor
= MAC_WXCOLORREF( m_backgroundBrush
.GetColour().GetPixel());
1800 ::RGBForeColor( &forecolor
);
1801 ::RGBBackColor( &backcolor
);
1803 int penWidth
= (int) (m_pen
.GetWidth() * m_scaleX
) ; ;
1804 // null means only one pixel, at whatever resolution
1805 if ( penWidth
== 0 )
1807 ::PenSize(penWidth
, penWidth
);
1809 int penStyle
= m_pen
.GetStyle();
1811 if (penStyle
== wxUSER_DASH
)
1813 // FIXME: there should be exactly 8 items in the dash
1815 int number
= m_pen
.GetDashes(&dash
) ;
1817 for ( int i
= 0 ; i
< 8 ; ++i
)
1819 pat
.pat
[i
] = dash
[index
] ;
1820 if (index
< number
- 1)
1826 wxMacGetPattern(penStyle
, &pat
);
1830 short mode
= patCopy
;
1832 switch( m_logicalFunction
)
1834 case wxCOPY
: // only foreground color, leave background (thus not patCopy)
1837 case wxINVERT
: // NOT dst
1838 // ::PenPat(GetQDGlobalsBlack(&blackColor));
1841 case wxXOR
: // src XOR dst
1844 case wxOR_REVERSE
: // src OR (NOT dst)
1847 case wxSRC_INVERT
: // (NOT src)
1850 case wxAND
: // src AND dst
1855 case wxAND_REVERSE
:// src AND (NOT dst)
1856 case wxAND_INVERT
: // (NOT src) AND dst
1857 case wxNO_OP
: // dst
1858 case wxNOR
: // (NOT src) AND (NOT dst)
1859 case wxEQUIV
: // (NOT src) XOR dst
1860 case wxOR_INVERT
: // (NOT src) OR dst
1861 case wxNAND
: // (NOT src) OR (NOT dst)
1862 case wxOR
: // src OR dst
1864 // case wxSRC_OR: // source _bitmap_ OR destination
1865 // case wxSRC_AND: // source _bitmap_ AND destination
1869 m_macPenInstalled
= true ;
1870 m_macBrushInstalled
= false ;
1871 m_macFontInstalled
= false ;
1874 void wxDC::MacSetupBackgroundForCurrentPort(const wxBrush
& background
)
1876 Pattern whiteColor
;
1877 if ( background
.Ok() )
1879 switch( background
.MacGetBrushKind() )
1881 case kwxMacBrushTheme
:
1883 ::SetThemeBackground( background
.MacGetTheme() , wxDisplayDepth() , true ) ;
1886 case kwxMacBrushThemeBackground
:
1889 ThemeBackgroundKind bg
= background
.MacGetThemeBackground( &extent
) ;
1890 ::ApplyThemeBackground( bg
, &extent
,kThemeStateActive
, wxDisplayDepth() , true ) ;
1893 case kwxMacBrushColour
:
1895 ::RGBBackColor( &MAC_WXCOLORREF( background
.GetColour().GetPixel()) );
1896 int brushStyle
= background
.GetStyle();
1897 if (brushStyle
== wxSOLID
)
1898 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
1899 else if (background
.IsHatch())
1902 wxMacGetPattern(brushStyle
, &pat
);
1907 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
1915 void wxDC::MacInstallBrush() const
1917 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1918 Pattern blackColor
;
1919 // if ( m_macBrushInstalled )
1922 bool backgroundTransparent
= (GetBackgroundMode() == wxTRANSPARENT
) ;
1923 ::RGBForeColor( &MAC_WXCOLORREF( m_brush
.GetColour().GetPixel()) );
1924 ::RGBBackColor( &MAC_WXCOLORREF( m_backgroundBrush
.GetColour().GetPixel()) );
1925 int brushStyle
= m_brush
.GetStyle();
1926 if (brushStyle
== wxSOLID
)
1928 ::PenPat(GetQDGlobalsBlack(&blackColor
));
1930 else if (m_brush
.IsHatch())
1933 wxMacGetPattern(brushStyle
, &pat
);
1936 else if ( m_brush
.GetStyle() == wxSTIPPLE
|| m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
)
1938 // we force this in order to be compliant with wxMSW
1939 backgroundTransparent
= false ;
1940 // for these the text fore (and back for MASK_OPAQUE) colors are used
1941 wxBitmap
* bitmap
= m_brush
.GetStipple() ;
1942 int width
= bitmap
->GetWidth() ;
1943 int height
= bitmap
->GetHeight() ;
1944 GWorldPtr gw
= NULL
;
1945 if ( m_brush
.GetStyle() == wxSTIPPLE
)
1946 gw
= MAC_WXHBITMAP(bitmap
->GetHBITMAP(NULL
)) ;
1948 gw
= MAC_WXHBITMAP(bitmap
->GetMask()->GetHBITMAP()) ;
1949 PixMapHandle gwpixmaphandle
= GetGWorldPixMap( gw
) ;
1950 LockPixels( gwpixmaphandle
) ;
1951 bool isMonochrome
= !IsPortColor( gw
) ;
1952 if ( !isMonochrome
)
1954 if ( (**gwpixmaphandle
).pixelSize
== 1 )
1955 isMonochrome
= true ;
1957 if ( isMonochrome
&& width
== 8 && height
== 8 )
1959 ::RGBForeColor( &MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) );
1960 ::RGBForeColor( &MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) );
1961 BitMap
* gwbitmap
= (BitMap
*) *gwpixmaphandle
; // since the color depth is 1 it is a BitMap
1962 UInt8
*gwbits
= (UInt8
*) gwbitmap
->baseAddr
;
1963 int alignment
= gwbitmap
->rowBytes
& 0x7FFF ;
1965 for ( int i
= 0 ; i
< 8 ; ++i
)
1967 pat
.pat
[i
] = gwbits
[i
*alignment
+0] ;
1969 UnlockPixels( GetGWorldPixMap( gw
) ) ;
1974 // this will be the code to handle power of 2 patterns, we will have to arrive at a nice
1975 // caching scheme before putting this into production
1978 PixPatHandle pixpat
= NewPixPat() ;
1979 CopyPixMap(gwpixmaphandle
, (**pixpat
).patMap
);
1980 imageSize
= GetPixRowBytes((**pixpat
).patMap
) *
1981 ((**(**pixpat
).patMap
).bounds
.bottom
-
1982 (**(**pixpat
).patMap
).bounds
.top
);
1983 PtrToHand( (**gwpixmaphandle
).baseAddr
, &image
, imageSize
);
1984 (**pixpat
).patData
= image
;
1987 CTabHandle ctable
= ((**((**pixpat
).patMap
)).pmTable
) ;
1988 ColorSpecPtr ctspec
= (ColorSpecPtr
) &(**ctable
).ctTable
;
1989 if ( ctspec
[0].rgb
.red
== 0x0000 )
1991 ctspec
[1].rgb
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) ;
1992 ctspec
[0].rgb
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) ;
1996 ctspec
[0].rgb
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) ;
1997 ctspec
[1].rgb
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) ;
1999 ::CTabChanged( ctable
) ;
2001 ::PenPixPat(pixpat
);
2002 m_macForegroundPixMap
= pixpat
;
2004 UnlockPixels( gwpixmaphandle
) ;
2008 ::PenPat(GetQDGlobalsBlack(&blackColor
));
2010 short mode
= patCopy
;
2011 switch( m_logicalFunction
)
2014 if ( backgroundTransparent
)
2019 case wxINVERT
: // NOT dst
2020 if ( !backgroundTransparent
)
2022 ::PenPat(GetQDGlobalsBlack(&blackColor
));
2026 case wxXOR
: // src XOR dst
2029 case wxOR_REVERSE
: // src OR (NOT dst)
2032 case wxSRC_INVERT
: // (NOT src)
2035 case wxAND
: // src AND dst
2040 case wxAND_REVERSE
:// src AND (NOT dst)
2041 case wxAND_INVERT
: // (NOT src) AND dst
2042 case wxNO_OP
: // dst
2043 case wxNOR
: // (NOT src) AND (NOT dst)
2044 case wxEQUIV
: // (NOT src) XOR dst
2045 case wxOR_INVERT
: // (NOT src) OR dst
2046 case wxNAND
: // (NOT src) OR (NOT dst)
2047 case wxOR
: // src OR dst
2049 // case wxSRC_OR: // source _bitmap_ OR destination
2050 // case wxSRC_AND: // source _bitmap_ AND destination
2054 m_macBrushInstalled
= true ;
2055 m_macPenInstalled
= false ;
2056 m_macFontInstalled
= false ;
2059 // ---------------------------------------------------------------------------
2060 // coordinates transformations
2061 // ---------------------------------------------------------------------------
2063 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
2065 return ((wxDC
*)this)->XDEV2LOG(x
);
2068 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
2070 return ((wxDC
*)this)->YDEV2LOG(y
);
2073 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
2075 return ((wxDC
*)this)->XDEV2LOGREL(x
);
2078 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
2080 return ((wxDC
*)this)->YDEV2LOGREL(y
);
2083 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
2085 return ((wxDC
*)this)->XLOG2DEV(x
);
2088 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
2090 return ((wxDC
*)this)->YLOG2DEV(y
);
2093 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
2095 return ((wxDC
*)this)->XLOG2DEVREL(x
);
2098 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
2100 return ((wxDC
*)this)->YLOG2DEVREL(y
);
2103 #endif // !wxMAC_USE_CORE_GRAPHICS