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>
39 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxObject
)
41 //-----------------------------------------------------------------------------
43 //-----------------------------------------------------------------------------
45 const double RAD2DEG
= 180.0 / M_PI
;
46 const short kEmulatedMode
= -1 ;
47 const short kUnsupportedMode
= -2 ;
49 extern TECObjectRef s_TECNativeCToUnicode
;
51 // set to 0 if problems arise
52 #define wxMAC_EXPERIMENTAL_DC 1
54 wxMacPortSetter::wxMacPortSetter( const wxDC
* dc
) :
55 m_ph( (GrafPtr
) dc
->m_macPort
)
57 wxASSERT( dc
->Ok() ) ;
59 dc
->MacSetupPort(&m_ph
) ;
61 wxMacPortSetter::~wxMacPortSetter()
63 m_dc
->MacCleanupPort(&m_ph
) ;
66 #if wxMAC_EXPERIMENTAL_DC
67 class wxMacFastPortSetter
70 wxMacFastPortSetter( const wxDC
*dc
)
72 wxASSERT( dc
->Ok() ) ;
73 m_swapped
= QDSwapPort( (GrafPtr
) dc
->m_macPort
, &m_oldPort
) ;
74 m_clipRgn
= NewRgn() ;
75 GetClip( m_clipRgn
) ;
77 dc
->MacSetupPort( NULL
) ;
79 ~wxMacFastPortSetter()
81 // SetPort( (GrafPtr) m_dc->m_macPort ) ;
82 SetClip( m_clipRgn
) ;
84 SetPort( m_oldPort
) ;
85 m_dc
->MacCleanupPort( NULL
) ;
86 DisposeRgn( m_clipRgn
) ;
96 typedef wxMacPortSetter wxMacFastPortSetter
;
99 wxMacWindowClipper::wxMacWindowClipper( const wxWindow
* win
) :
100 wxMacPortSaver( (GrafPtr
) GetWindowPort((WindowRef
) win
->MacGetTopLevelWindowRef()) )
102 m_newPort
=(GrafPtr
) GetWindowPort((WindowRef
) win
->MacGetTopLevelWindowRef()) ;
103 m_formerClip
= NewRgn() ;
104 m_newClip
= NewRgn() ;
105 GetClip( m_formerClip
) ;
109 // guard against half constructed objects, this just leads to a empty clip
113 win
->MacWindowToRootWindow( &x
,&y
) ;
114 // get area including focus rect
115 CopyRgn( (RgnHandle
) ((wxWindow
*)win
)->MacGetVisibleRegion(true).GetWXHRGN() , m_newClip
) ;
116 if ( !EmptyRgn( m_newClip
) )
117 OffsetRgn( m_newClip
, x
, y
) ;
119 SetClip( m_newClip
) ;
123 wxMacWindowClipper::~wxMacWindowClipper()
125 SetPort( m_newPort
) ;
126 SetClip( m_formerClip
) ;
127 DisposeRgn( m_newClip
) ;
128 DisposeRgn( m_formerClip
) ;
131 wxMacWindowStateSaver::wxMacWindowStateSaver( const wxWindow
* win
) :
132 wxMacWindowClipper( win
)
134 // the port is already set at this point
135 m_newPort
=(GrafPtr
) GetWindowPort((WindowRef
) win
->MacGetTopLevelWindowRef()) ;
136 GetThemeDrawingState( &m_themeDrawingState
) ;
139 wxMacWindowStateSaver::~wxMacWindowStateSaver()
141 SetPort( m_newPort
) ;
142 SetThemeDrawingState( m_themeDrawingState
, true ) ;
145 //-----------------------------------------------------------------------------
147 //-----------------------------------------------------------------------------
148 static inline double dmin(double a
, double b
) { return a
< b
? a
: b
; }
149 static inline double dmax(double a
, double b
) { return a
> b
? a
: b
; }
150 static inline double DegToRad(double deg
) { return (deg
* M_PI
) / 180.0; }
152 //-----------------------------------------------------------------------------
154 //-----------------------------------------------------------------------------
155 // this function emulates all wx colour manipulations, used to verify the implementation
156 // by setting the mode in the blitting functions to kEmulatedMode
157 void wxMacCalculateColour( int logical_func
, const RGBColor
&srcColor
, RGBColor
&dstColor
) ;
159 void wxMacCalculateColour( int logical_func
, const RGBColor
&srcColor
, RGBColor
&dstColor
)
161 switch ( logical_func
)
163 case wxAND
: // src AND dst
164 dstColor
.red
= dstColor
.red
& srcColor
.red
;
165 dstColor
.green
= dstColor
.green
& srcColor
.green
;
166 dstColor
.blue
= dstColor
.blue
& srcColor
.blue
;
168 case wxAND_INVERT
: // (NOT src) AND dst
169 dstColor
.red
= dstColor
.red
& ~srcColor
.red
;
170 dstColor
.green
= dstColor
.green
& ~srcColor
.green
;
171 dstColor
.blue
= dstColor
.blue
& ~srcColor
.blue
;
173 case wxAND_REVERSE
:// src AND (NOT dst)
174 dstColor
.red
= ~dstColor
.red
& srcColor
.red
;
175 dstColor
.green
= ~dstColor
.green
& srcColor
.green
;
176 dstColor
.blue
= ~dstColor
.blue
& srcColor
.blue
;
184 dstColor
.red
= srcColor
.red
;
185 dstColor
.green
= srcColor
.green
;
186 dstColor
.blue
= srcColor
.blue
;
188 case wxEQUIV
: // (NOT src) XOR dst
189 dstColor
.red
= dstColor
.red
^ ~srcColor
.red
;
190 dstColor
.green
= dstColor
.green
^ ~srcColor
.green
;
191 dstColor
.blue
= dstColor
.blue
^ ~srcColor
.blue
;
193 case wxINVERT
: // NOT dst
194 dstColor
.red
= ~dstColor
.red
;
195 dstColor
.green
= ~dstColor
.green
;
196 dstColor
.blue
= ~dstColor
.blue
;
198 case wxNAND
: // (NOT src) OR (NOT dst)
199 dstColor
.red
= ~dstColor
.red
| ~srcColor
.red
;
200 dstColor
.green
= ~dstColor
.green
| ~srcColor
.green
;
201 dstColor
.blue
= ~dstColor
.blue
| ~srcColor
.blue
;
203 case wxNOR
: // (NOT src) AND (NOT dst)
204 dstColor
.red
= ~dstColor
.red
& ~srcColor
.red
;
205 dstColor
.green
= ~dstColor
.green
& ~srcColor
.green
;
206 dstColor
.blue
= ~dstColor
.blue
& ~srcColor
.blue
;
210 case wxOR
: // src OR dst
211 dstColor
.red
= dstColor
.red
| srcColor
.red
;
212 dstColor
.green
= dstColor
.green
| srcColor
.green
;
213 dstColor
.blue
= dstColor
.blue
| srcColor
.blue
;
215 case wxOR_INVERT
: // (NOT src) OR dst
216 dstColor
.red
= dstColor
.red
| ~srcColor
.red
;
217 dstColor
.green
= dstColor
.green
| ~srcColor
.green
;
218 dstColor
.blue
= dstColor
.blue
| ~srcColor
.blue
;
220 case wxOR_REVERSE
: // src OR (NOT dst)
221 dstColor
.red
= ~dstColor
.red
| srcColor
.red
;
222 dstColor
.green
= ~dstColor
.green
| srcColor
.green
;
223 dstColor
.blue
= ~dstColor
.blue
| srcColor
.blue
;
226 dstColor
.red
= 0xFFFF ;
227 dstColor
.green
= 0xFFFF ;
228 dstColor
.blue
= 0xFFFF ;
230 case wxSRC_INVERT
: // (NOT src)
231 dstColor
.red
= ~srcColor
.red
;
232 dstColor
.green
= ~srcColor
.green
;
233 dstColor
.blue
= ~srcColor
.blue
;
235 case wxXOR
: // src XOR dst
236 dstColor
.red
= dstColor
.red
^ srcColor
.red
;
237 dstColor
.green
= dstColor
.green
^ srcColor
.green
;
238 dstColor
.blue
= dstColor
.blue
^ srcColor
.blue
;
247 m_mm_to_pix_x
= mm2pt
;
248 m_mm_to_pix_y
= mm2pt
;
249 m_internalDeviceOriginX
= 0;
250 m_internalDeviceOriginY
= 0;
251 m_externalDeviceOriginX
= 0;
252 m_externalDeviceOriginY
= 0;
253 m_logicalScaleX
= 1.0;
254 m_logicalScaleY
= 1.0;
259 m_needComputeScaleX
= false;
260 m_needComputeScaleY
= false;
264 m_macFontInstalled
= false ;
265 m_macBrushInstalled
= false ;
266 m_macPenInstalled
= false ;
267 m_macLocalOrigin
.x
= m_macLocalOrigin
.y
= 0 ;
268 m_macBoundaryClipRgn
= NewRgn() ;
269 m_macCurrentClipRgn
= NewRgn() ;
270 SetRectRgn( (RgnHandle
) m_macBoundaryClipRgn
, -32000 , -32000 , 32000 , 32000 ) ;
271 SetRectRgn( (RgnHandle
) m_macCurrentClipRgn
, -32000 , -32000 , 32000 , 32000 ) ;
272 m_pen
= *wxBLACK_PEN
;
273 m_font
= *wxNORMAL_FONT
;
274 m_brush
= *wxWHITE_BRUSH
;
276 // needed to debug possible errors with two active drawing methods at the same time on
278 m_macCurrentPortStateHelper
= NULL
;
280 m_macATSUIStyle
= NULL
;
281 m_macAliasWasEnabled
= false;
282 m_macForegroundPixMap
= NULL
;
283 m_macBackgroundPixMap
= NULL
;
288 DisposeRgn( (RgnHandle
) m_macBoundaryClipRgn
) ;
289 DisposeRgn( (RgnHandle
) m_macCurrentClipRgn
) ;
292 void wxDC::MacSetupPort(wxMacPortStateHelper
* help
) const
295 wxASSERT( m_macCurrentPortStateHelper
== NULL
) ;
296 m_macCurrentPortStateHelper
= help
;
298 SetClip( (RgnHandle
) m_macCurrentClipRgn
);
299 #if ! wxMAC_EXPERIMENTAL_DC
300 m_macFontInstalled
= false ;
301 m_macBrushInstalled
= false ;
302 m_macPenInstalled
= false ;
305 void wxDC::MacCleanupPort(wxMacPortStateHelper
* help
) const
308 wxASSERT( m_macCurrentPortStateHelper
== help
) ;
309 m_macCurrentPortStateHelper
= NULL
;
311 if( m_macATSUIStyle
)
313 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUIStyle
);
314 m_macATSUIStyle
= NULL
;
316 if ( m_macAliasWasEnabled
)
318 SetAntiAliasedTextEnabled(m_macFormerAliasState
, m_macFormerAliasSize
);
319 m_macAliasWasEnabled
= false ;
321 if ( m_macForegroundPixMap
)
324 ::PenPat(GetQDGlobalsBlack(&blackColor
));
325 DisposePixPat( (PixPatHandle
) m_macForegroundPixMap
) ;
326 m_macForegroundPixMap
= NULL
;
328 if ( m_macBackgroundPixMap
)
331 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
332 DisposePixPat( (PixPatHandle
) m_macBackgroundPixMap
) ;
333 m_macBackgroundPixMap
= NULL
;
337 void wxDC::DoDrawBitmap( const wxBitmap
&bmp
, wxCoord x
, wxCoord y
, bool useMask
)
339 wxCHECK_RET( Ok(), wxT("invalid window dc") );
340 wxCHECK_RET( bmp
.Ok(), wxT("invalid bitmap") );
341 wxMacFastPortSetter
helper(this) ;
342 wxCoord xx
= XLOG2DEVMAC(x
);
343 wxCoord yy
= YLOG2DEVMAC(y
);
344 wxCoord w
= bmp
.GetWidth();
345 wxCoord h
= bmp
.GetHeight();
346 wxCoord ww
= XLOG2DEVREL(w
);
347 wxCoord hh
= YLOG2DEVREL(h
);
348 // Set up drawing mode
349 short mode
= (m_logicalFunction
== wxCOPY
? srcCopy
:
350 //m_logicalFunction == wxCLEAR ? WHITENESS :
351 //m_logicalFunction == wxSET ? BLACKNESS :
352 m_logicalFunction
== wxINVERT
? hilite
:
353 //m_logicalFunction == wxAND ? MERGECOPY :
354 m_logicalFunction
== wxOR
? srcOr
:
355 m_logicalFunction
== wxSRC_INVERT
? notSrcCopy
:
356 m_logicalFunction
== wxXOR
? srcXor
:
357 m_logicalFunction
== wxOR_REVERSE
? notSrcOr
:
358 //m_logicalFunction == wxAND_REVERSE ? SRCERASE :
359 //m_logicalFunction == wxSRC_OR ? srcOr :
360 //m_logicalFunction == wxSRC_AND ? SRCAND :
363 GWorldPtr maskworld
= NULL
;
364 GWorldPtr bmapworld
= MAC_WXHBITMAP( bmp
.GetHBITMAP((WXHBITMAP
*)&maskworld
) );
365 PixMapHandle bmappixels
;
366 // Set foreground and background colours (for bitmaps depth = 1)
367 if(bmp
.GetDepth() == 1)
369 RGBColor fore
= MAC_WXCOLORREF(m_textForegroundColour
.GetPixel());
370 RGBColor back
= MAC_WXCOLORREF(m_textBackgroundColour
.GetPixel());
376 RGBColor white
= { 0xFFFF, 0xFFFF,0xFFFF} ;
377 RGBColor black
= { 0,0,0} ;
378 RGBForeColor( &black
) ;
379 RGBBackColor( &white
) ;
381 bmappixels
= GetGWorldPixMap( bmapworld
) ;
382 wxCHECK_RET(LockPixels(bmappixels
),
383 wxT("DoDrawBitmap: Unable to lock pixels"));
384 Rect source
= { 0, 0, h
, w
};
385 Rect dest
= { yy
, xx
, yy
+ hh
, xx
+ ww
};
386 if ( useMask
&& maskworld
)
388 if( LockPixels(GetGWorldPixMap(MAC_WXHBITMAP(maskworld
))))
392 GetPortBitMapForCopyBits(bmapworld
),
393 GetPortBitMapForCopyBits(MAC_WXHBITMAP(maskworld
)),
394 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ),
395 &source
, &source
, &dest
, mode
, NULL
397 UnlockPixels(GetGWorldPixMap(MAC_WXHBITMAP(maskworld
)));
401 CopyBits( GetPortBitMapForCopyBits( bmapworld
),
402 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ),
403 &source
, &dest
, mode
, NULL
) ;
405 UnlockPixels( bmappixels
) ;
407 m_macPenInstalled
= false ;
408 m_macBrushInstalled
= false ;
409 m_macFontInstalled
= false ;
412 void wxDC::DoDrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
)
414 wxCHECK_RET(Ok(), wxT("Invalid dc wxDC::DoDrawIcon"));
415 wxCHECK_RET(icon
.Ok(), wxT("Invalid icon wxDC::DoDrawIcon"));
416 wxMacFastPortSetter
helper(this) ;
418 wxCoord xx
= XLOG2DEVMAC(x
);
419 wxCoord yy
= YLOG2DEVMAC(y
);
420 wxCoord w
= icon
.GetWidth();
421 wxCoord h
= icon
.GetHeight();
422 wxCoord ww
= XLOG2DEVREL(w
);
423 wxCoord hh
= YLOG2DEVREL(h
);
425 Rect r
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
426 PlotIconRef( &r
, kAlignNone
, kTransformNone
, kPlotIconRefNormalFlags
, MAC_WXHICON( icon
.GetHICON() ) ) ;
429 void wxDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
431 wxCHECK_RET(Ok(), wxT("wxDC::DoSetClippingRegion Invalid DC"));
432 wxCoord xx
, yy
, ww
, hh
;
435 ww
= XLOG2DEVREL(width
);
436 hh
= YLOG2DEVREL(height
);
437 SetRectRgn( (RgnHandle
) m_macCurrentClipRgn
, xx
, yy
, xx
+ ww
, yy
+ hh
) ;
438 SectRgn( (RgnHandle
) m_macCurrentClipRgn
, (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
441 m_clipX1
= wxMax( m_clipX1
, xx
);
442 m_clipY1
= wxMax( m_clipY1
, yy
);
443 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
));
444 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
));
456 void wxDC::DoSetClippingRegionAsRegion( const wxRegion
®ion
)
458 wxCHECK_RET( Ok(), wxT("invalid window dc") ) ;
459 wxMacFastPortSetter
helper(this) ;
461 region
.GetBox( x
, y
, w
, h
);
462 wxCoord xx
, yy
, ww
, hh
;
467 // if we have a scaling that we cannot map onto native regions
468 // we must use the box
469 if ( ww
!= w
|| hh
!= h
)
471 wxDC::DoSetClippingRegion( x
, y
, w
, h
);
475 CopyRgn( (RgnHandle
) region
.GetWXHRGN() , (RgnHandle
) m_macCurrentClipRgn
) ;
476 if ( xx
!= x
|| yy
!= y
)
478 OffsetRgn( (RgnHandle
) m_macCurrentClipRgn
, xx
- x
, yy
- y
) ;
480 SectRgn( (RgnHandle
) m_macCurrentClipRgn
, (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
483 m_clipX1
= wxMax( m_clipX1
, xx
);
484 m_clipY1
= wxMax( m_clipY1
, yy
);
485 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
));
486 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
));
499 void wxDC::DestroyClippingRegion()
501 wxMacFastPortSetter
helper(this) ;
502 CopyRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
506 void wxDC::DoGetSizeMM( int* width
, int* height
) const
511 *width
= long( double(w
) / (m_scaleX
*m_mm_to_pix_x
) );
512 *height
= long( double(h
) / (m_scaleY
*m_mm_to_pix_y
) );
515 void wxDC::SetTextForeground( const wxColour
&col
)
517 wxCHECK_RET(Ok(), wxT("Invalid DC"));
518 m_textForegroundColour
= col
;
519 m_macFontInstalled
= false ;
522 void wxDC::SetTextBackground( const wxColour
&col
)
524 wxCHECK_RET(Ok(), wxT("Invalid DC"));
525 m_textBackgroundColour
= col
;
526 m_macFontInstalled
= false ;
529 void wxDC::SetMapMode( int mode
)
534 SetLogicalScale( twips2mm
*m_mm_to_pix_x
, twips2mm
*m_mm_to_pix_y
);
537 SetLogicalScale( pt2mm
*m_mm_to_pix_x
, pt2mm
*m_mm_to_pix_y
);
540 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
543 SetLogicalScale( m_mm_to_pix_x
/10.0, m_mm_to_pix_y
/10.0 );
547 SetLogicalScale( 1.0, 1.0 );
550 if (mode
!= wxMM_TEXT
)
552 m_needComputeScaleX
= true;
553 m_needComputeScaleY
= true;
557 void wxDC::SetUserScale( double x
, double y
)
559 // allow negative ? -> no
562 ComputeScaleAndOrigin();
565 void wxDC::SetLogicalScale( double x
, double y
)
570 ComputeScaleAndOrigin();
573 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
575 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
576 m_logicalOriginY
= y
* m_signY
;
577 ComputeScaleAndOrigin();
580 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
582 m_externalDeviceOriginX
= x
;
583 m_externalDeviceOriginY
= y
;
584 ComputeScaleAndOrigin();
587 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
589 m_signX
= (xLeftRight
? 1 : -1);
590 m_signY
= (yBottomUp
? -1 : 1);
591 ComputeScaleAndOrigin();
594 wxSize
wxDC::GetPPI() const
596 return wxSize(72, 72);
599 int wxDC::GetDepth() const
601 if ( IsPortColor( (CGrafPtr
) m_macPort
) )
603 return ( (**GetPortPixMap( (CGrafPtr
) m_macPort
)).pixelSize
) ;
608 void wxDC::ComputeScaleAndOrigin()
610 // CMB: copy scale to see if it changes
611 double origScaleX
= m_scaleX
;
612 double origScaleY
= m_scaleY
;
613 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
614 m_scaleY
= m_logicalScaleY
* m_userScaleY
;
615 m_deviceOriginX
= m_internalDeviceOriginX
+ m_externalDeviceOriginX
;
616 m_deviceOriginY
= m_internalDeviceOriginY
+ m_externalDeviceOriginY
;
617 // CMB: if scale has changed call SetPen to recalulate the line width
618 if (m_scaleX
!= origScaleX
|| m_scaleY
!= origScaleY
)
620 // this is a bit artificial, but we need to force wxDC to think
621 // the pen has changed
628 void wxDC::SetPalette( const wxPalette
& palette
)
632 void wxDC::SetBackgroundMode( int mode
)
634 m_backgroundMode
= mode
;
637 void wxDC::SetFont( const wxFont
&font
)
640 m_macFontInstalled
= false ;
643 void wxDC::SetPen( const wxPen
&pen
)
648 m_macPenInstalled
= false ;
651 void wxDC::SetBrush( const wxBrush
&brush
)
653 if (m_brush
== brush
)
656 m_macBrushInstalled
= false ;
659 void wxDC::SetBackground( const wxBrush
&brush
)
661 if (m_backgroundBrush
== brush
)
663 m_backgroundBrush
= brush
;
664 if (!m_backgroundBrush
.Ok())
666 m_macBrushInstalled
= false ;
669 void wxDC::SetLogicalFunction( int function
)
671 if (m_logicalFunction
== function
)
673 m_logicalFunction
= function
;
674 m_macFontInstalled
= false ;
675 m_macBrushInstalled
= false ;
676 m_macPenInstalled
= false ;
679 extern bool wxDoFloodFill(wxDC
*dc
, wxCoord x
, wxCoord y
,
680 const wxColour
& col
, int style
);
682 bool wxDC::DoFloodFill(wxCoord x
, wxCoord y
,
683 const wxColour
& col
, int style
)
685 return wxDoFloodFill(this, x
, y
, col
, style
);
688 bool wxDC::DoGetPixel( wxCoord x
, wxCoord y
, wxColour
*col
) const
690 wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel Invalid DC") );
691 wxMacFastPortSetter
helper(this) ;
693 GetCPixel( XLOG2DEVMAC(x
), YLOG2DEVMAC(y
), &colour
);
694 // Convert from Mac colour to wx
695 col
->Set( colour
.red
>> 8,
701 void wxDC::DoDrawLine( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
703 wxCHECK_RET(Ok(), wxT("Invalid DC"));
704 wxMacFastPortSetter
helper(this) ;
705 if (m_pen
.GetStyle() != wxTRANSPARENT
)
708 wxCoord offset
= ( (m_pen
.GetWidth() == 0 ? 1 :
709 m_pen
.GetWidth() ) * (wxCoord
)m_scaleX
- 1) / 2;
710 wxCoord xx1
= XLOG2DEVMAC(x1
) - offset
;
711 wxCoord yy1
= YLOG2DEVMAC(y1
) - offset
;
712 wxCoord xx2
= XLOG2DEVMAC(x2
) - offset
;
713 wxCoord yy2
= YLOG2DEVMAC(y2
) - offset
;
714 if ((m_pen
.GetCap() == wxCAP_ROUND
) &&
715 (m_pen
.GetWidth() <= 1))
717 // Implement LAST_NOT for MAC at least for
718 // orthogonal lines. RR.
739 void wxDC::DoCrossHair( wxCoord x
, wxCoord y
)
741 wxCHECK_RET( Ok(), wxT("wxDC::DoCrossHair Invalid window dc") );
742 wxMacFastPortSetter
helper(this) ;
743 if (m_pen
.GetStyle() != wxTRANSPARENT
)
748 wxCoord xx
= XLOG2DEVMAC(x
);
749 wxCoord yy
= YLOG2DEVMAC(y
);
751 ::MoveTo( XLOG2DEVMAC(0), yy
);
752 ::LineTo( XLOG2DEVMAC(w
), yy
);
753 ::MoveTo( xx
, YLOG2DEVMAC(0) );
754 ::LineTo( xx
, YLOG2DEVMAC(h
) );
755 CalcBoundingBox(x
, y
);
756 CalcBoundingBox(x
+w
, y
+h
);
761 * To draw arcs properly the angles need to be converted from the WX style:
762 * Angles start on the +ve X axis and go anti-clockwise (As you would draw on
763 * a normal axis on paper).
766 * Angles start on the +ve y axis and go clockwise.
769 static double wxConvertWXangleToMACangle(double angle
)
771 double newAngle
= 90 - angle
;
772 while ( newAngle
> 360 ) newAngle
-= 360 ;
773 while ( newAngle
< 0 ) newAngle
+= 360 ;
777 void wxDC::DoDrawArc( wxCoord x1
, wxCoord y1
,
778 wxCoord x2
, wxCoord y2
,
779 wxCoord xc
, wxCoord yc
)
781 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawArc Invalid DC"));
782 wxMacFastPortSetter
helper(this) ;
783 wxCoord xx1
= XLOG2DEVMAC(x1
);
784 wxCoord yy1
= YLOG2DEVMAC(y1
);
785 wxCoord xx2
= XLOG2DEVMAC(x2
);
786 wxCoord yy2
= YLOG2DEVMAC(y2
);
787 wxCoord xxc
= XLOG2DEVMAC(xc
);
788 wxCoord yyc
= YLOG2DEVMAC(yc
);
789 double dx
= xx1
- xxc
;
790 double dy
= yy1
- yyc
;
791 double radius
= sqrt((double)(dx
*dx
+dy
*dy
));
792 wxCoord rad
= (wxCoord
)radius
;
793 double radius1
, radius2
;
794 if (xx1
== xx2
&& yy1
== yy2
)
799 else if (radius
== 0.0)
801 radius1
= radius2
= 0.0;
805 radius1
= (xx1
- xxc
== 0) ?
806 (yy1
- yyc
< 0) ? 90.0 : -90.0 :
807 -atan2(double(yy1
-yyc
), double(xx1
-xxc
)) * RAD2DEG
;
808 radius2
= (xx2
- xxc
== 0) ?
809 (yy2
- yyc
< 0) ? 90.0 : -90.0 :
810 -atan2(double(yy2
-yyc
), double(xx2
-xxc
)) * RAD2DEG
;
812 wxCoord alpha2
= wxCoord(radius2
- radius1
);
813 wxCoord alpha1
= wxCoord(wxConvertWXangleToMACangle(radius1
));
814 while( alpha2
< 0 ) alpha2
+= 360 ;
816 Rect r
= { yyc
- rad
, xxc
- rad
, yyc
+ rad
, xxc
+ rad
};
817 if(m_brush
.GetStyle() != wxTRANSPARENT
) {
819 PaintArc(&r
, alpha1
, alpha2
);
821 if(m_pen
.GetStyle() != wxTRANSPARENT
) {
823 FrameArc(&r
, alpha1
, alpha2
);
827 void wxDC::DoDrawEllipticArc( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
828 double sa
, double ea
)
830 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawEllepticArc Invalid DC"));
831 wxMacFastPortSetter
helper(this) ;
833 double angle
= sa
- ea
; // Order important Mac in opposite direction to wx
834 // we have to make sure that the filling is always counter-clockwise
837 wxCoord xx
= XLOG2DEVMAC(x
);
838 wxCoord yy
= YLOG2DEVMAC(y
);
839 wxCoord ww
= m_signX
* XLOG2DEVREL(w
);
840 wxCoord hh
= m_signY
* YLOG2DEVREL(h
);
841 // handle -ve width and/or height
842 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
843 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
844 sa
= wxConvertWXangleToMACangle(sa
);
849 if(m_brush
.GetStyle() != wxTRANSPARENT
) {
851 PaintArc(&r
, (short)sa
, (short)angle
);
853 if(m_pen
.GetStyle() != wxTRANSPARENT
) {
855 FrameArc(&r
, (short)sa
, (short)angle
);
859 void wxDC::DoDrawPoint( wxCoord x
, wxCoord y
)
861 wxCHECK_RET(Ok(), wxT("Invalid DC"));
862 wxMacFastPortSetter
helper(this) ;
863 if (m_pen
.GetStyle() != wxTRANSPARENT
)
865 wxCoord xx1
= XLOG2DEVMAC(x
);
866 wxCoord yy1
= YLOG2DEVMAC(y
);
867 RGBColor pencolor
= MAC_WXCOLORREF( m_pen
.GetColour().GetPixel());
868 ::SetCPixel( xx1
,yy1
,&pencolor
) ;
869 CalcBoundingBox(x
, y
);
873 void wxDC::DoDrawLines(int n
, wxPoint points
[],
874 wxCoord xoffset
, wxCoord yoffset
)
876 wxCHECK_RET(Ok(), wxT("Invalid DC"));
877 wxMacFastPortSetter
helper(this) ;
878 if (m_pen
.GetStyle() == wxTRANSPARENT
)
881 wxCoord offset
= ( (m_pen
.GetWidth() == 0 ? 1 :
882 m_pen
.GetWidth() ) * (wxCoord
)m_scaleX
- 1) / 2 ;
883 wxCoord x1
, x2
, y1
, y2
;
884 x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
885 y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
886 ::MoveTo(x1
- offset
, y1
- offset
);
887 for (int i
= 0; i
< n
-1; i
++)
889 x2
= XLOG2DEVMAC(points
[i
+1].x
+ xoffset
);
890 y2
= YLOG2DEVMAC(points
[i
+1].y
+ yoffset
);
891 ::LineTo( x2
- offset
, y2
- offset
);
895 void wxDC::DoDrawPolygon(int n
, wxPoint points
[],
896 wxCoord xoffset
, wxCoord yoffset
,
899 wxCHECK_RET(Ok(), wxT("Invalid DC"));
900 wxMacFastPortSetter
helper(this) ;
901 wxCoord x1
, x2
, y1
, y2
;
902 if ( m_brush
.GetStyle() == wxTRANSPARENT
&& m_pen
.GetStyle() == wxTRANSPARENT
)
904 PolyHandle polygon
= OpenPoly();
905 x2
= x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
906 y2
= y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
908 for (int i
= 1; i
< n
; i
++)
910 x2
= XLOG2DEVMAC(points
[i
].x
+ xoffset
);
911 y2
= YLOG2DEVMAC(points
[i
].y
+ yoffset
);
914 // close the polyline if necessary
915 if ( x1
!= x2
|| y1
!= y2
)
920 if (m_brush
.GetStyle() != wxTRANSPARENT
)
923 ::PaintPoly( polygon
);
925 if (m_pen
.GetStyle() != wxTRANSPARENT
)
928 ::FramePoly( polygon
) ;
933 void wxDC::DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
935 wxCHECK_RET(Ok(), wxT("Invalid DC"));
936 wxMacFastPortSetter
helper(this) ;
937 wxCoord xx
= XLOG2DEVMAC(x
);
938 wxCoord yy
= YLOG2DEVMAC(y
);
939 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
940 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
941 // CMB: draw nothing if transformed w or h is 0
942 if (ww
== 0 || hh
== 0)
944 // CMB: handle -ve width and/or height
955 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
956 if (m_brush
.GetStyle() != wxTRANSPARENT
)
959 ::PaintRect( &rect
) ;
961 if (m_pen
.GetStyle() != wxTRANSPARENT
)
964 ::FrameRect( &rect
) ;
968 void wxDC::DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
969 wxCoord width
, wxCoord height
,
972 wxCHECK_RET(Ok(), wxT("Invalid DC"));
973 wxMacFastPortSetter
helper(this) ;
975 radius
= - radius
* ((width
< height
) ? width
: height
);
976 wxCoord xx
= XLOG2DEVMAC(x
);
977 wxCoord yy
= YLOG2DEVMAC(y
);
978 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
979 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
980 // CMB: draw nothing if transformed w or h is 0
981 if (ww
== 0 || hh
== 0)
983 // CMB: handle -ve width and/or height
994 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
995 if (m_brush
.GetStyle() != wxTRANSPARENT
)
998 ::PaintRoundRect( &rect
, int(radius
* 2) , int(radius
* 2) ) ;
1000 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1003 ::FrameRoundRect( &rect
, int(radius
* 2) , int(radius
* 2) ) ;
1007 void wxDC::DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1009 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1010 wxMacFastPortSetter
helper(this) ;
1011 wxCoord xx
= XLOG2DEVMAC(x
);
1012 wxCoord yy
= YLOG2DEVMAC(y
);
1013 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1014 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1015 // CMB: draw nothing if transformed w or h is 0
1016 if (ww
== 0 || hh
== 0)
1018 // CMB: handle -ve width and/or height
1029 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
1030 if (m_brush
.GetStyle() != wxTRANSPARENT
)
1033 ::PaintOval( &rect
) ;
1035 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1038 ::FrameOval( &rect
) ;
1042 bool wxDC::CanDrawBitmap(void) const
1047 bool wxDC::DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1048 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
, int logical_func
, bool useMask
,
1049 wxCoord xsrcMask
, wxCoord ysrcMask
)
1051 wxCHECK_MSG(Ok(), false, wxT("wxDC::DoBlit Illegal dc"));
1052 wxCHECK_MSG(source
->Ok(), false, wxT("wxDC::DoBlit Illegal source DC"));
1053 if ( logical_func
== wxNO_OP
)
1055 if (xsrcMask
== -1 && ysrcMask
== -1)
1057 xsrcMask
= xsrc
; ysrcMask
= ysrc
;
1059 // correct the parameter in case this dc does not have a mask at all
1060 if ( useMask
&& !source
->m_macMask
)
1062 Rect srcrect
, dstrect
;
1063 srcrect
.top
= source
->YLOG2DEVMAC(ysrc
) ;
1064 srcrect
.left
= source
->XLOG2DEVMAC(xsrc
) ;
1065 srcrect
.right
= source
->XLOG2DEVMAC(xsrc
+ width
) ;
1066 srcrect
.bottom
= source
->YLOG2DEVMAC(ysrc
+ height
) ;
1067 dstrect
.top
= YLOG2DEVMAC(ydest
) ;
1068 dstrect
.left
= XLOG2DEVMAC(xdest
) ;
1069 dstrect
.bottom
= YLOG2DEVMAC(ydest
+ height
) ;
1070 dstrect
.right
= XLOG2DEVMAC(xdest
+ width
) ;
1071 short mode
= kUnsupportedMode
;
1072 bool invertDestinationFirst
= false ;
1073 switch ( logical_func
)
1075 case wxAND
: // src AND dst
1076 mode
= adMin
; // ok
1078 case wxAND_INVERT
: // (NOT src) AND dst
1079 mode
= notSrcOr
; // ok
1081 case wxAND_REVERSE
:// src AND (NOT dst)
1082 invertDestinationFirst
= true ;
1086 mode
= kEmulatedMode
;
1089 mode
= srcCopy
; // ok
1091 case wxEQUIV
: // (NOT src) XOR dst
1092 mode
= srcXor
; // ok
1094 case wxINVERT
: // NOT dst
1095 mode
= kEmulatedMode
; //or hilite ;
1097 case wxNAND
: // (NOT src) OR (NOT dst)
1098 invertDestinationFirst
= true ;
1101 case wxNOR
: // (NOT src) AND (NOT dst)
1102 invertDestinationFirst
= true ;
1105 case wxNO_OP
: // dst
1106 mode
= kEmulatedMode
; // this has already been handled upon entry
1108 case wxOR
: // src OR dst
1111 case wxOR_INVERT
: // (NOT src) OR dst
1114 case wxOR_REVERSE
: // src OR (NOT dst)
1115 invertDestinationFirst
= true ;
1119 mode
= kEmulatedMode
;
1121 case wxSRC_INVERT
: // (NOT src)
1122 mode
= notSrcCopy
; // ok
1124 case wxXOR
: // src XOR dst
1125 mode
= notSrcXor
; // ok
1130 if ( mode
== kUnsupportedMode
)
1132 wxFAIL_MSG(wxT("unsupported blitting mode" ));
1135 CGrafPtr sourcePort
= (CGrafPtr
) source
->m_macPort
;
1136 PixMapHandle bmappixels
= GetGWorldPixMap( sourcePort
) ;
1137 if ( LockPixels(bmappixels
) )
1139 wxMacFastPortSetter
helper(this) ;
1140 if ( source
->GetDepth() == 1 )
1142 RGBForeColor( &MAC_WXCOLORREF(m_textForegroundColour
.GetPixel()) ) ;
1143 RGBBackColor( &MAC_WXCOLORREF(m_textBackgroundColour
.GetPixel()) ) ;
1147 // the modes need this, otherwise we'll end up having really nice colors...
1148 RGBColor white
= { 0xFFFF, 0xFFFF,0xFFFF} ;
1149 RGBColor black
= { 0,0,0} ;
1150 RGBForeColor( &black
) ;
1151 RGBBackColor( &white
) ;
1153 if ( useMask
&& source
->m_macMask
)
1155 if ( mode
== srcCopy
)
1157 if ( LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) )
1159 CopyMask( GetPortBitMapForCopyBits( sourcePort
) ,
1160 GetPortBitMapForCopyBits( MAC_WXHBITMAP(source
->m_macMask
) ) ,
1161 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1162 &srcrect
, &srcrect
, &dstrect
) ;
1163 UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1168 RgnHandle clipRgn
= NewRgn() ;
1169 LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1170 BitMapToRegion( clipRgn
, (BitMap
*) *GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1171 UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1172 OffsetRgn( clipRgn
, -srcrect
.left
+ dstrect
.left
, -srcrect
.top
+ dstrect
.top
) ;
1173 if ( mode
== kEmulatedMode
)
1176 ::PenPat(GetQDGlobalsBlack(&pat
));
1177 if ( logical_func
== wxSET
)
1179 RGBColor col
= { 0xFFFF, 0xFFFF, 0xFFFF } ;
1180 ::RGBForeColor( &col
) ;
1181 ::PaintRgn( clipRgn
) ;
1183 else if ( logical_func
== wxCLEAR
)
1185 RGBColor col
= { 0x0000, 0x0000, 0x0000 } ;
1186 ::RGBForeColor( &col
) ;
1187 ::PaintRgn( clipRgn
) ;
1189 else if ( logical_func
== wxINVERT
)
1191 MacInvertRgn( clipRgn
) ;
1195 for ( int y
= 0 ; y
< srcrect
.right
- srcrect
.left
; ++y
)
1197 for ( int x
= 0 ; x
< srcrect
.bottom
- srcrect
.top
; ++x
)
1199 Point dstPoint
= { dstrect
.top
+ y
, dstrect
.left
+ x
} ;
1200 Point srcPoint
= { srcrect
.top
+ y
, srcrect
.left
+ x
} ;
1201 if ( PtInRgn( dstPoint
, clipRgn
) )
1205 SetPort( (GrafPtr
) sourcePort
) ;
1206 GetCPixel( srcPoint
.h
, srcPoint
.v
, &srcColor
) ;
1207 SetPort( (GrafPtr
) m_macPort
) ;
1208 GetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1209 wxMacCalculateColour( logical_func
, srcColor
, dstColor
) ;
1210 SetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1218 if ( invertDestinationFirst
)
1220 MacInvertRgn( clipRgn
) ;
1222 CopyBits( GetPortBitMapForCopyBits( sourcePort
) ,
1223 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1224 &srcrect
, &dstrect
, mode
, clipRgn
) ;
1226 DisposeRgn( clipRgn
) ;
1231 RgnHandle clipRgn
= NewRgn() ;
1232 SetRectRgn( clipRgn
, dstrect
.left
, dstrect
.top
, dstrect
.right
, dstrect
.bottom
) ;
1233 if ( mode
== kEmulatedMode
)
1236 ::PenPat(GetQDGlobalsBlack(&pat
));
1237 if ( logical_func
== wxSET
)
1239 RGBColor col
= { 0xFFFF, 0xFFFF, 0xFFFF } ;
1240 ::RGBForeColor( &col
) ;
1241 ::PaintRgn( clipRgn
) ;
1243 else if ( logical_func
== wxCLEAR
)
1245 RGBColor col
= { 0x0000, 0x0000, 0x0000 } ;
1246 ::RGBForeColor( &col
) ;
1247 ::PaintRgn( clipRgn
) ;
1249 else if ( logical_func
== wxINVERT
)
1251 MacInvertRgn( clipRgn
) ;
1255 for ( int y
= 0 ; y
< srcrect
.right
- srcrect
.left
; ++y
)
1257 for ( int x
= 0 ; x
< srcrect
.bottom
- srcrect
.top
; ++x
)
1259 Point dstPoint
= { dstrect
.top
+ y
, dstrect
.left
+ x
} ;
1260 Point srcPoint
= { srcrect
.top
+ y
, srcrect
.left
+ x
} ;
1264 SetPort( (GrafPtr
) sourcePort
) ;
1265 GetCPixel( srcPoint
.h
, srcPoint
.v
, &srcColor
) ;
1266 SetPort( (GrafPtr
) m_macPort
) ;
1267 GetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1268 wxMacCalculateColour( logical_func
, srcColor
, dstColor
) ;
1269 SetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1277 if ( invertDestinationFirst
)
1279 MacInvertRgn( clipRgn
) ;
1281 CopyBits( GetPortBitMapForCopyBits( sourcePort
) ,
1282 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1283 &srcrect
, &dstrect
, mode
, NULL
) ;
1285 DisposeRgn( clipRgn
) ;
1287 UnlockPixels( bmappixels
) ;
1289 m_macPenInstalled
= false ;
1290 m_macBrushInstalled
= false ;
1291 m_macFontInstalled
= false ;
1295 void wxDC::DoDrawRotatedText(const wxString
& str
, wxCoord x
, wxCoord y
,
1298 // TODO support text background color (only possible by hand, ATSUI does not support it)
1299 wxCHECK_RET( Ok(), wxT("wxDC::DoDrawRotatedText Invalid window dc") );
1301 if ( str
.Length() == 0 )
1304 wxMacFastPortSetter
helper(this) ;
1309 m_macFormerAliasState
= IsAntiAliasedTextEnabled(&m_macFormerAliasSize
);
1310 SetAntiAliasedTextEnabled(true, SInt16(m_scaleY
* m_font
.MacGetFontSize()));
1311 m_macAliasWasEnabled
= true ;
1313 OSStatus status
= noErr
;
1314 ATSUTextLayout atsuLayout
;
1315 UniCharCount chars
= str
.Length() ;
1316 UniChar
* ubuf
= NULL
;
1317 #if SIZEOF_WCHAR_T == 4
1318 wxMBConvUTF16 converter
;
1320 size_t unicharlen
= converter
.WC2MB( NULL
, str
.wc_str() , 0 ) ;
1321 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1322 converter
.WC2MB( (char*) ubuf
, str
.wc_str(), unicharlen
+ 2 ) ;
1324 const wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1325 size_t unicharlen
= converter
.WC2MB( NULL
, wchar
.data() , 0 ) ;
1326 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1327 converter
.WC2MB( (char*) ubuf
, wchar
.data() , unicharlen
+ 2 ) ;
1329 chars
= unicharlen
/ 2 ;
1332 ubuf
= (UniChar
*) str
.wc_str() ;
1334 wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1335 chars
= wxWcslen( wchar
.data() ) ;
1336 ubuf
= (UniChar
*) wchar
.data() ;
1340 status
= ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr
) ubuf
, 0 , chars
, chars
, 1 ,
1341 &chars
, (ATSUStyle
*) &m_macATSUIStyle
, &atsuLayout
) ;
1343 wxASSERT_MSG( status
== noErr
, wxT("couldn't create the layout of the rotated text") );
1345 status
= ::ATSUSetTransientFontMatching( atsuLayout
, true ) ;
1346 wxASSERT_MSG( status
== noErr
, wxT("couldn't setup transient font matching") );
1348 int iAngle
= int( angle
);
1349 int drawX
= XLOG2DEVMAC(x
) ;
1350 int drawY
= YLOG2DEVMAC(y
) ;
1352 ATSUTextMeasurement textBefore
;
1353 ATSUTextMeasurement textAfter
;
1354 ATSUTextMeasurement ascent
;
1355 ATSUTextMeasurement descent
;
1358 if ( abs(iAngle
) > 0 )
1360 Fixed atsuAngle
= IntToFixed( iAngle
) ;
1361 ATSUAttributeTag atsuTags
[] =
1363 kATSULineRotationTag
,
1365 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1369 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1373 status
= ::ATSUSetLayoutControls(atsuLayout
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
),
1374 atsuTags
, atsuSizes
, atsuValues
) ;
1376 status
= ::ATSUMeasureText( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1377 &textBefore
, &textAfter
, &ascent
, &descent
);
1379 drawX
+= (int)(sin(angle
/RAD2DEG
) * FixedToInt(ascent
));
1380 drawY
+= (int)(cos(angle
/RAD2DEG
) * FixedToInt(ascent
));
1381 status
= ::ATSUDrawText( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1382 IntToFixed(drawX
) , IntToFixed(drawY
) );
1383 wxASSERT_MSG( status
== noErr
, wxT("couldn't draw the rotated text") );
1385 status
= ::ATSUMeasureTextImage( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1386 IntToFixed(drawX
) , IntToFixed(drawY
) , &rect
);
1387 wxASSERT_MSG( status
== noErr
, wxT("couldn't measure the rotated text") );
1388 OffsetRect( &rect
, -m_macLocalOrigin
.x
, -m_macLocalOrigin
.y
) ;
1389 CalcBoundingBox(XDEV2LOG(rect
.left
), YDEV2LOG(rect
.top
) );
1390 CalcBoundingBox(XDEV2LOG(rect
.right
), YDEV2LOG(rect
.bottom
) );
1391 ::ATSUDisposeTextLayout(atsuLayout
);
1392 #if SIZEOF_WCHAR_T == 4
1397 void wxDC::DoDrawText(const wxString
& strtext
, wxCoord x
, wxCoord y
)
1399 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawText Invalid DC"));
1401 wxMacFastPortSetter
helper(this) ;
1402 long xx
= XLOG2DEVMAC(x
);
1403 long yy
= YLOG2DEVMAC(y
);
1405 bool useDrawThemeText
= ( DrawThemeTextBox
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1406 if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC
) ) || m_font
.GetNoAntiAliasing() )
1407 useDrawThemeText
= false ;
1412 ::GetFontInfo( &fi
) ;
1414 if ( !useDrawThemeText
)
1417 ::MoveTo( xx
, yy
);
1418 if ( m_backgroundMode
== wxTRANSPARENT
)
1420 ::TextMode( srcOr
) ;
1424 ::TextMode( srcCopy
) ;
1428 wxString linetext
= strtext
;
1430 if ( useDrawThemeText
)
1432 Rect frame
= { yy
+ line
*(fi
.descent
+ fi
.ascent
+ fi
.leading
) ,xx
, yy
+ (line
+1)*(fi
.descent
+ fi
.ascent
+ fi
.leading
) , xx
+ 10000 } ;
1433 wxMacCFStringHolder
mString( linetext
, m_font
.GetEncoding()) ;
1435 if ( m_backgroundMode
!= wxTRANSPARENT
)
1437 Point bounds
={0,0} ;
1438 Rect background
= frame
;
1440 ::GetThemeTextDimensions( mString
,
1441 m_font
.MacGetThemeFontID() ,
1446 background
.right
= background
.left
+ bounds
.h
;
1447 background
.bottom
= background
.top
+ bounds
.v
;
1448 ::EraseRect( &background
) ;
1450 ::DrawThemeTextBox( mString
,
1451 m_font
.MacGetThemeFontID() ,
1461 wxCharBuffer text
= linetext
.mb_str(wxConvLocal
) ;
1462 ::DrawText( text
, 0 , strlen(text
) ) ;
1465 ::TextMode( srcOr
) ;
1468 bool wxDC::CanGetTextExtent() const
1470 wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
1474 void wxDC::DoGetTextExtent( const wxString
&strtext
, wxCoord
*width
, wxCoord
*height
,
1475 wxCoord
*descent
, wxCoord
*externalLeading
,
1476 wxFont
*theFont
) const
1478 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1479 wxMacFastPortSetter
helper(this) ;
1480 wxFont formerFont
= m_font
;
1483 // work around the constness
1484 *((wxFont
*)(&m_font
)) = *theFont
;
1488 ::GetFontInfo( &fi
) ;
1490 bool useGetThemeText
= ( GetThemeTextDimensions
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1491 if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC
) ) || ((wxFont
*)&m_font
)->GetNoAntiAliasing() )
1492 useGetThemeText
= false ;
1495 *height
= YDEV2LOGREL( fi
.descent
+ fi
.ascent
) ;
1497 *descent
=YDEV2LOGREL( fi
.descent
);
1498 if ( externalLeading
)
1499 *externalLeading
= YDEV2LOGREL( fi
.leading
) ;
1505 wxString linetext
= strtext
;
1507 if ( useGetThemeText
)
1509 Point bounds
={0,0} ;
1511 wxMacCFStringHolder
mString( linetext
, m_font
.GetEncoding() ) ;
1512 ThemeFontID themeFont
= m_font
.MacGetThemeFontID() ;
1513 ::GetThemeTextDimensions( mString
,
1519 curwidth
= bounds
.h
;
1523 wxCharBuffer text
= linetext
.mb_str(wxConvLocal
) ;
1524 curwidth
= ::TextWidth( text
, 0 , strlen(text
) ) ;
1526 if ( curwidth
> *width
)
1527 *width
= XDEV2LOGREL( curwidth
) ;
1531 // work around the constness
1532 *((wxFont
*)(&m_font
)) = formerFont
;
1533 m_macFontInstalled
= false ;
1538 bool wxDC::DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
1540 wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
1543 widths
.Add(0, text
.Length());
1545 if (text
.Length() == 0)
1548 wxMacFastPortSetter
helper(this) ;
1551 bool useGetThemeText
= ( GetThemeTextDimensions
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1552 if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC
) ) || ((wxFont
*)&m_font
)->GetNoAntiAliasing() )
1553 useGetThemeText
= false ;
1555 if ( useGetThemeText
)
1557 // If anybody knows how to do this more efficiently yet still handle
1558 // the fractional glyph widths that may be present when using AA
1559 // fonts, please change it. Currently it is measuring from the
1560 // begining of the string for each succeding substring, which is much
1561 // slower than this should be.
1562 for (size_t i
=0; i
<text
.Length(); i
++)
1564 wxString
str(text
.Left(i
+1));
1565 Point bounds
= {0,0};
1567 wxMacCFStringHolder
mString(str
, m_font
.GetEncoding());
1568 ::GetThemeTextDimensions( mString
,
1569 m_font
.MacGetThemeFontID(),
1574 widths
[i
] = XDEV2LOGREL(bounds
.h
);
1580 wxCharBuffer buff
= text
.mb_str(wxConvLocal
);
1581 size_t len
= strlen(buff
);
1582 short* measurements
= new short[len
+1];
1583 MeasureText(len
, buff
.data(), measurements
);
1585 // Copy to widths, starting at measurements[1]
1586 // NOTE: this doesn't take into account any multi-byte characters
1587 // in buff, it probabkly should...
1588 for (size_t i
=0; i
<text
.Length(); i
++)
1589 widths
[i
] = XDEV2LOGREL(measurements
[i
+1]);
1591 delete [] measurements
;
1599 wxCoord
wxDC::GetCharWidth(void) const
1601 wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
1602 wxMacFastPortSetter
helper(this) ;
1606 bool useGetThemeText
= ( GetThemeTextDimensions
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1607 if ( UMAGetSystemVersion() < 0x1000 || ((wxFont
*)&m_font
)->GetNoAntiAliasing() )
1608 useGetThemeText
= false ;
1612 if ( useGetThemeText
)
1614 Point bounds
={0,0} ;
1616 CFStringRef mString
= CFStringCreateWithBytes( NULL
, (UInt8
*) text
, 1 , CFStringGetSystemEncoding(), false ) ;
1617 ::GetThemeTextDimensions( mString
,
1618 m_font
.MacGetThemeFontID(),
1623 CFRelease( mString
) ;
1629 width
= ::TextWidth( text
, 0 , 1 ) ;
1631 return YDEV2LOGREL(width
) ;
1634 wxCoord
wxDC::GetCharHeight(void) const
1636 wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
1637 wxMacFastPortSetter
helper(this) ;
1640 ::GetFontInfo( &fi
) ;
1641 return YDEV2LOGREL( fi
.descent
+ fi
.ascent
);
1644 void wxDC::Clear(void)
1646 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1647 wxMacFastPortSetter
helper(this) ;
1648 Rect rect
= { -31000 , -31000 , 31000 , 31000 } ;
1649 if ( m_backgroundBrush
.Ok() && m_backgroundBrush
.GetStyle() != wxTRANSPARENT
)
1652 MacSetupBackgroundForCurrentPort( m_backgroundBrush
) ;
1653 ::EraseRect( &rect
) ;
1657 void wxDC::MacInstallFont() const
1659 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1660 // if ( m_macFontInstalled )
1662 Pattern blackColor
;
1663 MacSetupBackgroundForCurrentPort(m_backgroundBrush
) ;
1664 if ( m_backgroundMode
!= wxTRANSPARENT
)
1666 Pattern whiteColor
;
1667 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
1670 wxASSERT( m_font
.Ok() ) ;
1673 ::TextFont( m_font
.MacGetFontNum() ) ;
1674 ::TextSize( (short)(m_scaleY
* m_font
.MacGetFontSize()) ) ;
1675 ::TextFace( m_font
.MacGetFontStyle() ) ;
1676 m_macFontInstalled
= true ;
1677 m_macBrushInstalled
= false ;
1678 m_macPenInstalled
= false ;
1679 RGBColor forecolor
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel());
1680 RGBColor backcolor
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel());
1681 ::RGBForeColor( &forecolor
);
1682 ::RGBBackColor( &backcolor
);
1684 short mode
= patCopy
;
1686 switch( m_logicalFunction
)
1691 case wxINVERT
: // NOT dst
1692 ::PenPat(GetQDGlobalsBlack(&blackColor
));
1695 case wxXOR
: // src XOR dst
1698 case wxOR_REVERSE
: // src OR (NOT dst)
1701 case wxSRC_INVERT
: // (NOT src)
1704 case wxAND
: // src AND dst
1709 case wxAND_REVERSE
:// src AND (NOT dst)
1710 case wxAND_INVERT
: // (NOT src) AND dst
1711 case wxNO_OP
: // dst
1712 case wxNOR
: // (NOT src) AND (NOT dst)
1713 case wxEQUIV
: // (NOT src) XOR dst
1714 case wxOR_INVERT
: // (NOT src) OR dst
1715 case wxNAND
: // (NOT src) OR (NOT dst)
1716 case wxOR
: // src OR dst
1718 // case wxSRC_OR: // source _bitmap_ OR destination
1719 // case wxSRC_AND: // source _bitmap_ AND destination
1723 OSStatus status
= noErr
;
1724 status
= ATSUCreateAndCopyStyle( (ATSUStyle
) m_font
.MacGetATSUStyle() , (ATSUStyle
*) &m_macATSUIStyle
) ;
1725 wxASSERT_MSG( status
== noErr
, wxT("couldn't set create ATSU style") ) ;
1727 Fixed atsuSize
= IntToFixed( int(m_scaleY
* m_font
.MacGetFontSize()) ) ;
1728 ATSUAttributeTag atsuTags
[] =
1732 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1736 // Boolean kTrue = true ;
1737 // Boolean kFalse = false ;
1739 // ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal;
1740 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1744 status
= ::ATSUSetAttributes((ATSUStyle
)m_macATSUIStyle
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
) ,
1745 atsuTags
, atsuSizes
, atsuValues
);
1747 wxASSERT_MSG( status
== noErr
, wxT("couldn't Modify ATSU style") ) ;
1751 Pattern gPatterns
[] =
1753 { { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF } } ,
1754 { { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 } } ,
1755 { { 0x80 , 0x40 , 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , 0x01 } } ,
1756 { { 0x10 , 0x10 , 0x10 , 0xFF , 0x10 , 0x10 , 0x10 , 0x10 } } ,
1757 { { 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 } } ,
1758 { { 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 } } ,
1759 { { 0x81 , 0x42 , 0x24 , 0x18 , 0x18 , 0x24 , 0x42 , 0x81 } } ,
1761 { { 0xCC , 0x99 , 0x33 , 0x66 , 0xCC , 0x99 , 0x33 , 0x66 } } , // DOT
1762 { { 0xFE , 0xFD , 0xFB , 0xF7 , 0xEF , 0xDF , 0xBF , 0x7F } } , // LONG_DASH
1763 { { 0xEE , 0xDD , 0xBB , 0x77 , 0xEE , 0xDD , 0xBB , 0x77 } } , // SHORT_DASH
1764 { { 0xDE , 0xBD , 0x7B , 0xF6 , 0xED , 0xDB , 0xB7 , 0x6F } } , // DOT_DASH
1767 static void wxMacGetPattern(int penStyle
, Pattern
*pattern
)
1769 int index
= 0; // solid pattern by default
1773 case wxBDIAGONAL_HATCH
: index
= 1; break;
1774 case wxFDIAGONAL_HATCH
: index
= 2; break;
1775 case wxCROSS_HATCH
: index
= 3; break;
1776 case wxHORIZONTAL_HATCH
: index
= 4; break;
1777 case wxVERTICAL_HATCH
: index
= 5; break;
1778 case wxCROSSDIAG_HATCH
: index
= 6; break;
1780 case wxDOT
: index
= 7; break;
1781 case wxLONG_DASH
: index
= 8; break;
1782 case wxSHORT_DASH
: index
= 9; break;
1783 case wxDOT_DASH
: index
= 10; break;
1785 *pattern
= gPatterns
[index
];
1788 void wxDC::MacInstallPen() const
1790 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1791 //Pattern blackColor;
1792 // if ( m_macPenInstalled )
1794 RGBColor forecolor
= MAC_WXCOLORREF( m_pen
.GetColour().GetPixel());
1795 RGBColor backcolor
= MAC_WXCOLORREF( m_backgroundBrush
.GetColour().GetPixel());
1796 ::RGBForeColor( &forecolor
);
1797 ::RGBBackColor( &backcolor
);
1799 int penWidth
= (int) (m_pen
.GetWidth() * m_scaleX
) ; ;
1800 // null means only one pixel, at whatever resolution
1801 if ( penWidth
== 0 )
1803 ::PenSize(penWidth
, penWidth
);
1805 int penStyle
= m_pen
.GetStyle();
1807 if (penStyle
== wxUSER_DASH
)
1809 // FIXME: there should be exactly 8 items in the dash
1811 int number
= m_pen
.GetDashes(&dash
) ;
1813 for ( int i
= 0 ; i
< 8 ; ++i
)
1815 pat
.pat
[i
] = dash
[index
] ;
1816 if (index
< number
- 1)
1822 wxMacGetPattern(penStyle
, &pat
);
1826 short mode
= patCopy
;
1828 switch( m_logicalFunction
)
1830 case wxCOPY
: // only foreground color, leave background (thus not patCopy)
1833 case wxINVERT
: // NOT dst
1834 // ::PenPat(GetQDGlobalsBlack(&blackColor));
1837 case wxXOR
: // src XOR dst
1840 case wxOR_REVERSE
: // src OR (NOT dst)
1843 case wxSRC_INVERT
: // (NOT src)
1846 case wxAND
: // src AND dst
1851 case wxAND_REVERSE
:// src AND (NOT dst)
1852 case wxAND_INVERT
: // (NOT src) AND dst
1853 case wxNO_OP
: // dst
1854 case wxNOR
: // (NOT src) AND (NOT dst)
1855 case wxEQUIV
: // (NOT src) XOR dst
1856 case wxOR_INVERT
: // (NOT src) OR dst
1857 case wxNAND
: // (NOT src) OR (NOT dst)
1858 case wxOR
: // src OR dst
1860 // case wxSRC_OR: // source _bitmap_ OR destination
1861 // case wxSRC_AND: // source _bitmap_ AND destination
1865 m_macPenInstalled
= true ;
1866 m_macBrushInstalled
= false ;
1867 m_macFontInstalled
= false ;
1870 void wxDC::MacSetupBackgroundForCurrentPort(const wxBrush
& background
)
1872 Pattern whiteColor
;
1873 if ( background
.Ok() )
1875 switch( background
.MacGetBrushKind() )
1877 case kwxMacBrushTheme
:
1879 ::SetThemeBackground( background
.MacGetTheme() , wxDisplayDepth() , true ) ;
1882 case kwxMacBrushThemeBackground
:
1885 ThemeBackgroundKind bg
= background
.MacGetThemeBackground( &extent
) ;
1886 ::ApplyThemeBackground( bg
, &extent
,kThemeStateActive
, wxDisplayDepth() , true ) ;
1889 case kwxMacBrushColour
:
1891 ::RGBBackColor( &MAC_WXCOLORREF( background
.GetColour().GetPixel()) );
1892 int brushStyle
= background
.GetStyle();
1893 if (brushStyle
== wxSOLID
)
1894 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
1895 else if (background
.IsHatch())
1898 wxMacGetPattern(brushStyle
, &pat
);
1903 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
1911 void wxDC::MacInstallBrush() const
1913 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1914 Pattern blackColor
;
1915 // if ( m_macBrushInstalled )
1918 bool backgroundTransparent
= (GetBackgroundMode() == wxTRANSPARENT
) ;
1919 ::RGBForeColor( &MAC_WXCOLORREF( m_brush
.GetColour().GetPixel()) );
1920 ::RGBBackColor( &MAC_WXCOLORREF( m_backgroundBrush
.GetColour().GetPixel()) );
1921 int brushStyle
= m_brush
.GetStyle();
1922 if (brushStyle
== wxSOLID
)
1924 ::PenPat(GetQDGlobalsBlack(&blackColor
));
1926 else if (m_brush
.IsHatch())
1929 wxMacGetPattern(brushStyle
, &pat
);
1932 else if ( m_brush
.GetStyle() == wxSTIPPLE
|| m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
)
1934 // we force this in order to be compliant with wxMSW
1935 backgroundTransparent
= false ;
1936 // for these the text fore (and back for MASK_OPAQUE) colors are used
1937 wxBitmap
* bitmap
= m_brush
.GetStipple() ;
1938 int width
= bitmap
->GetWidth() ;
1939 int height
= bitmap
->GetHeight() ;
1940 GWorldPtr gw
= NULL
;
1941 if ( m_brush
.GetStyle() == wxSTIPPLE
)
1942 gw
= MAC_WXHBITMAP(bitmap
->GetHBITMAP(NULL
)) ;
1944 gw
= MAC_WXHBITMAP(bitmap
->GetMask()->GetHBITMAP()) ;
1945 PixMapHandle gwpixmaphandle
= GetGWorldPixMap( gw
) ;
1946 LockPixels( gwpixmaphandle
) ;
1947 bool isMonochrome
= !IsPortColor( gw
) ;
1948 if ( !isMonochrome
)
1950 if ( (**gwpixmaphandle
).pixelSize
== 1 )
1951 isMonochrome
= true ;
1953 if ( isMonochrome
&& width
== 8 && height
== 8 )
1955 ::RGBForeColor( &MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) );
1956 ::RGBForeColor( &MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) );
1957 BitMap
* gwbitmap
= (BitMap
*) *gwpixmaphandle
; // since the color depth is 1 it is a BitMap
1958 UInt8
*gwbits
= (UInt8
*) gwbitmap
->baseAddr
;
1959 int alignment
= gwbitmap
->rowBytes
& 0x7FFF ;
1961 for ( int i
= 0 ; i
< 8 ; ++i
)
1963 pat
.pat
[i
] = gwbits
[i
*alignment
+0] ;
1965 UnlockPixels( GetGWorldPixMap( gw
) ) ;
1970 // this will be the code to handle power of 2 patterns, we will have to arrive at a nice
1971 // caching scheme before putting this into production
1974 PixPatHandle pixpat
= NewPixPat() ;
1975 CopyPixMap(gwpixmaphandle
, (**pixpat
).patMap
);
1976 imageSize
= GetPixRowBytes((**pixpat
).patMap
) *
1977 ((**(**pixpat
).patMap
).bounds
.bottom
-
1978 (**(**pixpat
).patMap
).bounds
.top
);
1979 PtrToHand( (**gwpixmaphandle
).baseAddr
, &image
, imageSize
);
1980 (**pixpat
).patData
= image
;
1983 CTabHandle ctable
= ((**((**pixpat
).patMap
)).pmTable
) ;
1984 ColorSpecPtr ctspec
= (ColorSpecPtr
) &(**ctable
).ctTable
;
1985 if ( ctspec
[0].rgb
.red
== 0x0000 )
1987 ctspec
[1].rgb
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) ;
1988 ctspec
[0].rgb
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) ;
1992 ctspec
[0].rgb
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) ;
1993 ctspec
[1].rgb
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) ;
1995 ::CTabChanged( ctable
) ;
1997 ::PenPixPat(pixpat
);
1998 m_macForegroundPixMap
= pixpat
;
2000 UnlockPixels( gwpixmaphandle
) ;
2004 ::PenPat(GetQDGlobalsBlack(&blackColor
));
2006 short mode
= patCopy
;
2007 switch( m_logicalFunction
)
2010 if ( backgroundTransparent
)
2015 case wxINVERT
: // NOT dst
2016 if ( !backgroundTransparent
)
2018 ::PenPat(GetQDGlobalsBlack(&blackColor
));
2022 case wxXOR
: // src XOR dst
2025 case wxOR_REVERSE
: // src OR (NOT dst)
2028 case wxSRC_INVERT
: // (NOT src)
2031 case wxAND
: // src AND dst
2036 case wxAND_REVERSE
:// src AND (NOT dst)
2037 case wxAND_INVERT
: // (NOT src) AND dst
2038 case wxNO_OP
: // dst
2039 case wxNOR
: // (NOT src) AND (NOT dst)
2040 case wxEQUIV
: // (NOT src) XOR dst
2041 case wxOR_INVERT
: // (NOT src) OR dst
2042 case wxNAND
: // (NOT src) OR (NOT dst)
2043 case wxOR
: // src OR dst
2045 // case wxSRC_OR: // source _bitmap_ OR destination
2046 // case wxSRC_AND: // source _bitmap_ AND destination
2050 m_macBrushInstalled
= true ;
2051 m_macPenInstalled
= false ;
2052 m_macFontInstalled
= false ;
2055 // ---------------------------------------------------------------------------
2056 // coordinates transformations
2057 // ---------------------------------------------------------------------------
2059 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
2061 return ((wxDC
*)this)->XDEV2LOG(x
);
2064 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
2066 return ((wxDC
*)this)->YDEV2LOG(y
);
2069 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
2071 return ((wxDC
*)this)->XDEV2LOGREL(x
);
2074 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
2076 return ((wxDC
*)this)->YDEV2LOGREL(y
);
2079 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
2081 return ((wxDC
*)this)->XLOG2DEV(x
);
2084 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
2086 return ((wxDC
*)this)->YLOG2DEV(y
);
2089 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
2091 return ((wxDC
*)this)->XLOG2DEVREL(x
);
2094 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
2096 return ((wxDC
*)this)->YLOG2DEVREL(y
);
2099 #endif // !wxMAC_USE_CORE_GRAPHICS