1 /////////////////////////////////////////////////////////////////////////////
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #pragma implementation "dc.h"
16 #include "wx/mac/uma.h"
17 #include "wx/dcmemory.h"
18 #include "wx/region.h"
26 #include "wx/mac/private.h"
27 #include "ATSUnicode.h"
28 #include "TextCommon.h"
29 #include "TextEncodingConverter.h"
30 #if !USE_SHARED_LIBRARY
31 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxObject
)
33 //-----------------------------------------------------------------------------
35 //-----------------------------------------------------------------------------
36 #define mm2inches 0.0393700787402
37 #define inches2mm 25.4
38 #define mm2twips 56.6929133859
39 #define twips2mm 0.0176388888889
40 #define mm2pt 2.83464566929
41 #define pt2mm 0.352777777778
43 const double M_PI
= 3.14159265358979 ;
45 const double RAD2DEG
= 180.0 / M_PI
;
46 const short kEmulatedMode
= -1 ;
47 const short kUnsupportedMode
= -2 ;
48 wxMacPortSetter::wxMacPortSetter( const wxDC
* dc
) :
49 m_ph( (GrafPtr
) dc
->m_macPort
)
51 wxASSERT( dc
->Ok() ) ;
53 dc
->MacSetupPort(&m_ph
) ;
55 wxMacPortSetter::~wxMacPortSetter()
57 m_dc
->MacCleanupPort(&m_ph
) ;
59 wxMacWindowClipper::wxMacWindowClipper( const wxWindow
* win
)
61 m_formerClip
= NewRgn() ;
62 m_newClip
= NewRgn() ;
63 GetClip( m_formerClip
) ;
67 RgnHandle insidergn
= NewRgn() ;
69 wxWindow
*parent
= win
->GetParent() ;
70 parent
->MacWindowToRootWindow( &x
,&y
) ;
71 wxSize size
= parent
->GetSize() ;
72 SetRectRgn( insidergn
, parent
->MacGetLeftBorderSize() , parent
->MacGetTopBorderSize() ,
73 size
.x
- parent
->MacGetRightBorderSize(),
74 size
.y
- parent
->MacGetBottomBorderSize()) ;
75 CopyRgn( (RgnHandle
) parent
->MacGetVisibleRegion(false).GetWXHRGN() , m_newClip
) ;
76 SectRgn( m_newClip
, insidergn
, m_newClip
) ;
77 OffsetRgn( m_newClip
, x
, y
) ;
78 SetClip( m_newClip
) ;
79 DisposeRgn( insidergn
) ;
82 wxMacWindowClipper::~wxMacWindowClipper()
84 SetClip( m_formerClip
) ;
85 DisposeRgn( m_newClip
) ;
86 DisposeRgn( m_formerClip
) ;
88 //-----------------------------------------------------------------------------
90 //-----------------------------------------------------------------------------
91 static inline double dmin(double a
, double b
) { return a
< b
? a
: b
; }
92 static inline double dmax(double a
, double b
) { return a
> b
? a
: b
; }
93 static inline double DegToRad(double deg
) { return (deg
* M_PI
) / 180.0; }
94 //-----------------------------------------------------------------------------
96 //-----------------------------------------------------------------------------
97 // this function emulates all wx colour manipulations, used to verify the implementation
98 // by setting the mode in the blitting functions to kEmulatedMode
99 void wxMacCalculateColour( int logical_func
, const RGBColor
&srcColor
, RGBColor
&dstColor
) ;
100 void wxMacCalculateColour( int logical_func
, const RGBColor
&srcColor
, RGBColor
&dstColor
)
102 switch ( logical_func
)
104 case wxAND
: // src AND dst
105 dstColor
.red
= dstColor
.red
& srcColor
.red
;
106 dstColor
.green
= dstColor
.green
& srcColor
.green
;
107 dstColor
.blue
= dstColor
.blue
& srcColor
.blue
;
109 case wxAND_INVERT
: // (NOT src) AND dst
110 dstColor
.red
= dstColor
.red
& ~srcColor
.red
;
111 dstColor
.green
= dstColor
.green
& ~srcColor
.green
;
112 dstColor
.blue
= dstColor
.blue
& ~srcColor
.blue
;
114 case wxAND_REVERSE
:// src AND (NOT dst)
115 dstColor
.red
= ~dstColor
.red
& srcColor
.red
;
116 dstColor
.green
= ~dstColor
.green
& srcColor
.green
;
117 dstColor
.blue
= ~dstColor
.blue
& srcColor
.blue
;
125 dstColor
.red
= srcColor
.red
;
126 dstColor
.green
= srcColor
.green
;
127 dstColor
.blue
= srcColor
.blue
;
129 case wxEQUIV
: // (NOT src) XOR dst
130 dstColor
.red
= dstColor
.red
^ ~srcColor
.red
;
131 dstColor
.green
= dstColor
.green
^ ~srcColor
.green
;
132 dstColor
.blue
= dstColor
.blue
^ ~srcColor
.blue
;
134 case wxINVERT
: // NOT dst
135 dstColor
.red
= ~dstColor
.red
;
136 dstColor
.green
= ~dstColor
.green
;
137 dstColor
.blue
= ~dstColor
.blue
;
139 case wxNAND
: // (NOT src) OR (NOT dst)
140 dstColor
.red
= ~dstColor
.red
| ~srcColor
.red
;
141 dstColor
.green
= ~dstColor
.green
| ~srcColor
.green
;
142 dstColor
.blue
= ~dstColor
.blue
| ~srcColor
.blue
;
144 case wxNOR
: // (NOT src) AND (NOT dst)
145 dstColor
.red
= ~dstColor
.red
& ~srcColor
.red
;
146 dstColor
.green
= ~dstColor
.green
& ~srcColor
.green
;
147 dstColor
.blue
= ~dstColor
.blue
& ~srcColor
.blue
;
151 case wxOR
: // src OR dst
152 dstColor
.red
= dstColor
.red
| srcColor
.red
;
153 dstColor
.green
= dstColor
.green
| srcColor
.green
;
154 dstColor
.blue
= dstColor
.blue
| srcColor
.blue
;
156 case wxOR_INVERT
: // (NOT src) OR dst
157 dstColor
.red
= dstColor
.red
| ~srcColor
.red
;
158 dstColor
.green
= dstColor
.green
| ~srcColor
.green
;
159 dstColor
.blue
= dstColor
.blue
| ~srcColor
.blue
;
161 case wxOR_REVERSE
: // src OR (NOT dst)
162 dstColor
.red
= ~dstColor
.red
| srcColor
.red
;
163 dstColor
.green
= ~dstColor
.green
| srcColor
.green
;
164 dstColor
.blue
= ~dstColor
.blue
| srcColor
.blue
;
167 dstColor
.red
= 0xFFFF ;
168 dstColor
.green
= 0xFFFF ;
169 dstColor
.blue
= 0xFFFF ;
171 case wxSRC_INVERT
: // (NOT src)
172 dstColor
.red
= ~srcColor
.red
;
173 dstColor
.green
= ~srcColor
.green
;
174 dstColor
.blue
= ~srcColor
.blue
;
176 case wxXOR
: // src XOR dst
177 dstColor
.red
= dstColor
.red
^ srcColor
.red
;
178 dstColor
.green
= dstColor
.green
^ srcColor
.green
;
179 dstColor
.blue
= dstColor
.blue
^ srcColor
.blue
;
187 m_mm_to_pix_x
= mm2pt
;
188 m_mm_to_pix_y
= mm2pt
;
189 m_internalDeviceOriginX
= 0;
190 m_internalDeviceOriginY
= 0;
191 m_externalDeviceOriginX
= 0;
192 m_externalDeviceOriginY
= 0;
193 m_logicalScaleX
= 1.0;
194 m_logicalScaleY
= 1.0;
199 m_needComputeScaleX
= FALSE
;
200 m_needComputeScaleY
= FALSE
;
204 m_macFontInstalled
= false ;
205 m_macBrushInstalled
= false ;
206 m_macPenInstalled
= false ;
207 m_macLocalOrigin
.x
= m_macLocalOrigin
.y
= 0 ;
208 m_macBoundaryClipRgn
= NewRgn() ;
209 m_macCurrentClipRgn
= NewRgn() ;
210 SetRectRgn( (RgnHandle
) m_macBoundaryClipRgn
, -32000 , -32000 , 32000 , 32000 ) ;
211 SetRectRgn( (RgnHandle
) m_macCurrentClipRgn
, -32000 , -32000 , 32000 , 32000 ) ;
212 m_pen
= *wxBLACK_PEN
;
213 m_font
= *wxNORMAL_FONT
;
214 m_brush
= *wxWHITE_BRUSH
;
215 m_macCurrentPortStateHelper
= NULL
;
216 m_macATSUIStyle
= NULL
;
217 m_macAliasWasEnabled
= false;
218 m_macForegroundPixMap
= NULL
;
219 m_macBackgroundPixMap
= NULL
;
223 DisposeRgn( (RgnHandle
) m_macBoundaryClipRgn
) ;
224 DisposeRgn( (RgnHandle
) m_macCurrentClipRgn
) ;
226 void wxDC::MacSetupPort(wxMacPortStateHelper
* help
) const
228 wxASSERT( m_macCurrentPortStateHelper
== NULL
) ;
229 m_macCurrentPortStateHelper
= help
;
230 SetClip( (RgnHandle
) m_macCurrentClipRgn
);
231 m_macFontInstalled
= false ;
232 m_macBrushInstalled
= false ;
233 m_macPenInstalled
= false ;
235 void wxDC::MacCleanupPort(wxMacPortStateHelper
* help
) const
237 wxASSERT( m_macCurrentPortStateHelper
== help
) ;
238 m_macCurrentPortStateHelper
= NULL
;
239 if( m_macATSUIStyle
)
241 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUIStyle
);
242 m_macATSUIStyle
= NULL
;
244 if ( m_macAliasWasEnabled
)
246 SetAntiAliasedTextEnabled(m_macFormerAliasState
, m_macFormerAliasSize
);
247 m_macAliasWasEnabled
= false ;
249 if ( m_macForegroundPixMap
)
252 ::PenPat(GetQDGlobalsBlack(&blackColor
));
253 DisposePixPat( (PixPatHandle
) m_macForegroundPixMap
) ;
254 m_macForegroundPixMap
= NULL
;
256 if ( m_macBackgroundPixMap
)
259 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
260 DisposePixPat( (PixPatHandle
) m_macBackgroundPixMap
) ;
261 m_macBackgroundPixMap
= NULL
;
264 void wxDC::DoDrawBitmap( const wxBitmap
&bmp
, wxCoord x
, wxCoord y
, bool useMask
)
266 wxCHECK_RET( Ok(), wxT("invalid window dc") );
267 wxCHECK_RET( bmp
.Ok(), wxT("invalid bitmap") );
268 wxMacPortSetter
helper(this) ;
269 wxCoord xx
= XLOG2DEVMAC(x
);
270 wxCoord yy
= YLOG2DEVMAC(y
);
271 wxCoord w
= bmp
.GetWidth();
272 wxCoord h
= bmp
.GetHeight();
273 wxCoord ww
= XLOG2DEVREL(w
);
274 wxCoord hh
= YLOG2DEVREL(h
);
275 // Set up drawing mode
276 short mode
= (m_logicalFunction
== wxCOPY
? srcCopy
:
277 //m_logicalFunction == wxCLEAR ? WHITENESS :
278 //m_logicalFunction == wxSET ? BLACKNESS :
279 m_logicalFunction
== wxINVERT
? hilite
:
280 //m_logicalFunction == wxAND ? MERGECOPY :
281 m_logicalFunction
== wxOR
? srcOr
:
282 m_logicalFunction
== wxSRC_INVERT
? notSrcCopy
:
283 m_logicalFunction
== wxXOR
? srcXor
:
284 m_logicalFunction
== wxOR_REVERSE
? notSrcOr
:
285 //m_logicalFunction == wxAND_REVERSE ? SRCERASE :
286 //m_logicalFunction == wxSRC_OR ? srcOr :
287 //m_logicalFunction == wxSRC_AND ? SRCAND :
289 if ( bmp
.GetBitmapType() == kMacBitmapTypePict
) {
290 Rect bitmaprect
= { 0 , 0 , hh
, ww
};
291 ::OffsetRect( &bitmaprect
, xx
, yy
) ;
292 ::DrawPicture( (PicHandle
) bmp
.GetPict(), &bitmaprect
) ;
294 else if ( bmp
.GetBitmapType() == kMacBitmapTypeGrafWorld
)
296 GWorldPtr bmapworld
= MAC_WXHBITMAP( bmp
.GetHBITMAP() );
297 PixMapHandle bmappixels
;
298 // Set foreground and background colours (for bitmaps depth = 1)
299 if(bmp
.GetDepth() == 1)
301 RGBColor fore
= MAC_WXCOLORREF(m_textForegroundColour
.GetPixel());
302 RGBColor back
= MAC_WXCOLORREF(m_textBackgroundColour
.GetPixel());
308 RGBColor white
= { 0xFFFF, 0xFFFF,0xFFFF} ;
309 RGBColor black
= { 0,0,0} ;
310 RGBForeColor( &black
) ;
311 RGBBackColor( &white
) ;
313 bmappixels
= GetGWorldPixMap( bmapworld
) ;
314 wxCHECK_RET(LockPixels(bmappixels
),
315 wxT("DoDrawBitmap: Unable to lock pixels"));
316 Rect source
= { 0, 0, h
, w
};
317 Rect dest
= { yy
, xx
, yy
+ hh
, xx
+ ww
};
318 if ( useMask
&& bmp
.GetMask() )
320 if( LockPixels(GetGWorldPixMap(MAC_WXHBITMAP(bmp
.GetMask()->GetMaskBitmap()))))
324 GetPortBitMapForCopyBits(bmapworld
),
325 GetPortBitMapForCopyBits(MAC_WXHBITMAP(bmp
.GetMask()->GetMaskBitmap())),
326 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ),
327 &source
, &source
, &dest
, mode
, NULL
329 UnlockPixels(GetGWorldPixMap(MAC_WXHBITMAP(bmp
.GetMask()->GetMaskBitmap())));
333 CopyBits( GetPortBitMapForCopyBits( bmapworld
),
334 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ),
335 &source
, &dest
, mode
, NULL
) ;
337 UnlockPixels( bmappixels
) ;
339 else if ( bmp
.GetBitmapType() == kMacBitmapTypeIcon
)
341 Rect bitmaprect
= { 0 , 0 , bmp
.GetHeight(), bmp
.GetWidth() } ;
342 OffsetRect( &bitmaprect
, xx
, yy
) ;
343 PlotCIconHandle( &bitmaprect
, atNone
, ttNone
, MAC_WXHICON(bmp
.GetHICON()) ) ;
345 m_macPenInstalled
= false ;
346 m_macBrushInstalled
= false ;
347 m_macFontInstalled
= false ;
349 void wxDC::DoDrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
)
351 wxCHECK_RET(Ok(), wxT("Invalid dc wxDC::DoDrawIcon"));
352 wxCHECK_RET(icon
.Ok(), wxT("Invalid icon wxDC::DoDrawIcon"));
353 DoDrawBitmap( icon
, x
, y
, icon
.GetMask() != NULL
) ;
355 void wxDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
357 wxCHECK_RET(Ok(), wxT("wxDC::DoSetClippingRegion Invalid DC"));
358 wxCoord xx
, yy
, ww
, hh
;
361 ww
= XLOG2DEVREL(width
);
362 hh
= YLOG2DEVREL(height
);
363 SetRectRgn( (RgnHandle
) m_macCurrentClipRgn
, xx
, yy
, xx
+ ww
, yy
+ hh
) ;
364 SectRgn( (RgnHandle
) m_macCurrentClipRgn
, (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
367 m_clipX1
= wxMax( m_clipX1
, xx
);
368 m_clipY1
= wxMax( m_clipY1
, yy
);
369 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
));
370 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
));
381 void wxDC::DoSetClippingRegionAsRegion( const wxRegion
®ion
)
383 wxCHECK_RET( Ok(), wxT("invalid window dc") ) ;
384 wxMacPortSetter
helper(this) ;
387 DestroyClippingRegion();
391 region
.GetBox( x
, y
, w
, h
);
392 wxCoord xx
, yy
, ww
, hh
;
397 // if we have a scaling that we cannot map onto native regions
398 // we must use the box
399 if ( ww
!= w
|| hh
!= h
)
401 wxDC::DoSetClippingRegion( x
, y
, w
, h
);
405 CopyRgn( (RgnHandle
) region
.GetWXHRGN() , (RgnHandle
) m_macCurrentClipRgn
) ;
406 if ( xx
!= x
|| yy
!= y
)
408 OffsetRgn( (RgnHandle
) m_macCurrentClipRgn
, xx
- x
, yy
- y
) ;
410 SectRgn( (RgnHandle
) m_macCurrentClipRgn
, (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
413 m_clipX1
= wxMax( m_clipX1
, xx
);
414 m_clipY1
= wxMax( m_clipY1
, yy
);
415 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
));
416 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
));
428 void wxDC::DestroyClippingRegion()
430 wxMacPortSetter
helper(this) ;
431 CopyRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
434 void wxDC::DoGetSize( int* width
, int* height
) const
436 *width
= m_maxX
-m_minX
;
437 *height
= m_maxY
-m_minY
;
439 void wxDC::DoGetSizeMM( int* width
, int* height
) const
444 *width
= long( double(w
) / (m_scaleX
*m_mm_to_pix_x
) );
445 *height
= long( double(h
) / (m_scaleY
*m_mm_to_pix_y
) );
447 void wxDC::SetTextForeground( const wxColour
&col
)
449 wxCHECK_RET(Ok(), wxT("Invalid DC"));
450 m_textForegroundColour
= col
;
451 m_macFontInstalled
= false ;
453 void wxDC::SetTextBackground( const wxColour
&col
)
455 wxCHECK_RET(Ok(), wxT("Invalid DC"));
456 m_textBackgroundColour
= col
;
457 m_macFontInstalled
= false ;
459 void wxDC::SetMapMode( int mode
)
464 SetLogicalScale( twips2mm
*m_mm_to_pix_x
, twips2mm
*m_mm_to_pix_y
);
467 SetLogicalScale( pt2mm
*m_mm_to_pix_x
, pt2mm
*m_mm_to_pix_y
);
470 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
473 SetLogicalScale( m_mm_to_pix_x
/10.0, m_mm_to_pix_y
/10.0 );
477 SetLogicalScale( 1.0, 1.0 );
480 if (mode
!= wxMM_TEXT
)
482 m_needComputeScaleX
= TRUE
;
483 m_needComputeScaleY
= TRUE
;
486 void wxDC::SetUserScale( double x
, double y
)
488 // allow negative ? -> no
491 ComputeScaleAndOrigin();
493 void wxDC::SetLogicalScale( double x
, double y
)
498 ComputeScaleAndOrigin();
500 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
502 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
503 m_logicalOriginY
= y
* m_signY
;
504 ComputeScaleAndOrigin();
506 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
508 m_externalDeviceOriginX
= x
;
509 m_externalDeviceOriginY
= y
;
510 ComputeScaleAndOrigin();
513 void wxDC::SetInternalDeviceOrigin( long x
, long y
)
515 m_internalDeviceOriginX
= x
;
516 m_internalDeviceOriginY
= y
;
517 ComputeScaleAndOrigin();
519 void wxDC::GetInternalDeviceOrigin( long *x
, long *y
)
521 if (x
) *x
= m_internalDeviceOriginX
;
522 if (y
) *y
= m_internalDeviceOriginY
;
525 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
527 m_signX
= (xLeftRight
? 1 : -1);
528 m_signY
= (yBottomUp
? -1 : 1);
529 ComputeScaleAndOrigin();
531 wxSize
wxDC::GetPPI() const
533 return wxSize(72, 72);
535 int wxDC::GetDepth() const
537 if ( IsPortColor( (CGrafPtr
) m_macPort
) )
539 return ( (**GetPortPixMap( (CGrafPtr
) m_macPort
)).pixelSize
) ;
543 void wxDC::ComputeScaleAndOrigin()
545 // CMB: copy scale to see if it changes
546 double origScaleX
= m_scaleX
;
547 double origScaleY
= m_scaleY
;
548 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
549 m_scaleY
= m_logicalScaleY
* m_userScaleY
;
550 m_deviceOriginX
= m_internalDeviceOriginX
+ m_externalDeviceOriginX
;
551 m_deviceOriginY
= m_internalDeviceOriginY
+ m_externalDeviceOriginY
;
552 // CMB: if scale has changed call SetPen to recalulate the line width
553 if (m_scaleX
!= origScaleX
|| m_scaleY
!= origScaleY
)
555 // this is a bit artificial, but we need to force wxDC to think
556 // the pen has changed
557 wxPen
* pen
= & GetPen();
563 void wxDC::SetPalette( const wxPalette
& palette
)
566 void wxDC::SetBackgroundMode( int mode
)
568 m_backgroundMode
= mode
;
570 void wxDC::SetFont( const wxFont
&font
)
573 m_macFontInstalled
= false ;
575 void wxDC::SetPen( const wxPen
&pen
)
580 m_macPenInstalled
= false ;
582 void wxDC::SetBrush( const wxBrush
&brush
)
584 if (m_brush
== brush
)
587 m_macBrushInstalled
= false ;
589 void wxDC::SetBackground( const wxBrush
&brush
)
591 if (m_backgroundBrush
== brush
)
593 m_backgroundBrush
= brush
;
594 if (!m_backgroundBrush
.Ok())
596 m_macBrushInstalled
= false ;
598 void wxDC::SetLogicalFunction( int function
)
600 if (m_logicalFunction
== function
)
602 m_logicalFunction
= function
;
603 m_macFontInstalled
= false ;
604 m_macBrushInstalled
= false ;
605 m_macPenInstalled
= false ;
607 extern bool wxDoFloodFill(wxDC
*dc
, wxCoord x
, wxCoord y
,
608 const wxColour
& col
, int style
);
609 bool wxDC::DoFloodFill(wxCoord x
, wxCoord y
,
610 const wxColour
& col
, int style
)
612 return wxDoFloodFill(this, x
, y
, col
, style
);
614 bool wxDC::DoGetPixel( wxCoord x
, wxCoord y
, wxColour
*col
) const
616 wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel Invalid DC") );
617 wxMacPortSetter
helper(this) ;
619 GetCPixel( XLOG2DEVMAC(x
), YLOG2DEVMAC(y
), &colour
);
620 // Convert from Mac colour to wx
621 col
->Set( colour
.red
>> 8,
626 void wxDC::DoDrawLine( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
628 wxCHECK_RET(Ok(), wxT("Invalid DC"));
629 wxMacPortSetter
helper(this) ;
630 if (m_pen
.GetStyle() != wxTRANSPARENT
)
633 wxCoord offset
= ( (m_pen
.GetWidth() == 0 ? 1 :
634 m_pen
.GetWidth() ) * (wxCoord
)m_scaleX
- 1) / 2;
635 wxCoord xx1
= XLOG2DEVMAC(x1
) - offset
;
636 wxCoord yy1
= YLOG2DEVMAC(y1
) - offset
;
637 wxCoord xx2
= XLOG2DEVMAC(x2
) - offset
;
638 wxCoord yy2
= YLOG2DEVMAC(y2
) - offset
;
639 if ((m_pen
.GetCap() == wxCAP_ROUND
) &&
640 (m_pen
.GetWidth() <= 1))
642 // Implement LAST_NOT for MAC at least for
643 // orthogonal lines. RR.
663 void wxDC::DoCrossHair( wxCoord x
, wxCoord y
)
665 wxCHECK_RET( Ok(), wxT("wxDC::DoCrossHair Invalid window dc") );
666 wxMacPortSetter
helper(this) ;
667 if (m_pen
.GetStyle() != wxTRANSPARENT
)
672 wxCoord xx
= XLOG2DEVMAC(x
);
673 wxCoord yy
= YLOG2DEVMAC(y
);
675 ::MoveTo( XLOG2DEVMAC(0), yy
);
676 ::LineTo( XLOG2DEVMAC(w
), yy
);
677 ::MoveTo( xx
, YLOG2DEVMAC(0) );
678 ::LineTo( xx
, YLOG2DEVMAC(h
) );
679 CalcBoundingBox(x
, y
);
680 CalcBoundingBox(x
+w
, y
+h
);
684 * To draw arcs properly the angles need to be converted from the WX style:
685 * Angles start on the +ve X axis and go anti-clockwise (As you would draw on
686 * a normal axis on paper).
689 * Angles start on the +ve y axis and go clockwise.
691 static double wxConvertWXangleToMACangle(double angle
)
693 double newAngle
= 90 - angle
;
698 void wxDC::DoDrawArc( wxCoord x1
, wxCoord y1
,
699 wxCoord x2
, wxCoord y2
,
700 wxCoord xc
, wxCoord yc
)
702 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawArc Invalid DC"));
703 wxMacPortSetter
helper(this) ;
704 wxCoord xx1
= XLOG2DEVMAC(x1
);
705 wxCoord yy1
= YLOG2DEVMAC(y1
);
706 wxCoord xx2
= XLOG2DEVMAC(x2
);
707 wxCoord yy2
= YLOG2DEVMAC(y2
);
708 wxCoord xxc
= XLOG2DEVMAC(xc
);
709 wxCoord yyc
= YLOG2DEVMAC(yc
);
710 double dx
= xx1
- xxc
;
711 double dy
= yy1
- yyc
;
712 double radius
= sqrt((double)(dx
*dx
+dy
*dy
));
713 wxCoord rad
= (wxCoord
)radius
;
714 double radius1
, radius2
;
715 if (xx1
== xx2
&& yy1
== yy2
)
720 else if (radius
== 0.0)
722 radius1
= radius2
= 0.0;
726 radius1
= (xx1
- xxc
== 0) ?
727 (yy1
- yyc
< 0) ? 90.0 : -90.0 :
728 -atan2(double(yy1
-yyc
), double(xx1
-xxc
)) * RAD2DEG
;
729 radius2
= (xx2
- xxc
== 0) ?
730 (yy2
- yyc
< 0) ? 90.0 : -90.0 :
731 -atan2(double(yy2
-yyc
), double(xx2
-xxc
)) * RAD2DEG
;
733 wxCoord alpha2
= wxCoord(radius2
- radius1
);
734 wxCoord alpha1
= wxCoord(wxConvertWXangleToMACangle(radius1
));
735 if( (xx1
> xx2
) || (yy1
> yy2
) ) {
738 Rect r
= { yyc
- rad
, xxc
- rad
, yyc
+ rad
, xxc
+ rad
};
739 if(m_brush
.GetStyle() != wxTRANSPARENT
) {
741 PaintArc(&r
, alpha1
, alpha2
);
743 if(m_pen
.GetStyle() != wxTRANSPARENT
) {
745 FrameArc(&r
, alpha1
, alpha2
);
748 void wxDC::DoDrawEllipticArc( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
749 double sa
, double ea
)
751 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawEllepticArc Invalid DC"));
752 wxMacPortSetter
helper(this) ;
754 double angle
= sa
- ea
; // Order important Mac in opposite direction to wx
755 // we have to make sure that the filling is always counter-clockwise
758 wxCoord xx
= XLOG2DEVMAC(x
);
759 wxCoord yy
= YLOG2DEVMAC(y
);
760 wxCoord ww
= m_signX
* XLOG2DEVREL(w
);
761 wxCoord hh
= m_signY
* YLOG2DEVREL(h
);
762 // handle -ve width and/or height
763 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
764 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
765 sa
= wxConvertWXangleToMACangle(sa
);
770 if(m_brush
.GetStyle() != wxTRANSPARENT
) {
772 PaintArc(&r
, (short)sa
, (short)angle
);
774 if(m_pen
.GetStyle() != wxTRANSPARENT
) {
776 FrameArc(&r
, (short)sa
, (short)angle
);
779 void wxDC::DoDrawPoint( wxCoord x
, wxCoord y
)
781 wxCHECK_RET(Ok(), wxT("Invalid DC"));
782 wxMacPortSetter
helper(this) ;
783 if (m_pen
.GetStyle() != wxTRANSPARENT
)
785 wxCoord xx1
= XLOG2DEVMAC(x
);
786 wxCoord yy1
= YLOG2DEVMAC(y
);
787 RGBColor pencolor
= MAC_WXCOLORREF( m_pen
.GetColour().GetPixel());
788 ::SetCPixel( xx1
,yy1
,&pencolor
) ;
789 CalcBoundingBox(x
, y
);
792 void wxDC::DoDrawLines(int n
, wxPoint points
[],
793 wxCoord xoffset
, wxCoord yoffset
)
795 wxCHECK_RET(Ok(), wxT("Invalid DC"));
796 wxMacPortSetter
helper(this) ;
797 if (m_pen
.GetStyle() == wxTRANSPARENT
)
800 wxCoord offset
= ( (m_pen
.GetWidth() == 0 ? 1 :
801 m_pen
.GetWidth() ) * (wxCoord
)m_scaleX
- 1) / 2 ;
802 wxCoord x1
, x2
, y1
, y2
;
803 x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
804 y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
805 ::MoveTo(x1
- offset
, y1
- offset
);
806 for (int i
= 0; i
< n
-1; i
++)
808 x2
= XLOG2DEVMAC(points
[i
+1].x
+ xoffset
);
809 y2
= YLOG2DEVMAC(points
[i
+1].y
+ yoffset
);
810 ::LineTo( x2
- offset
, y2
- offset
);
813 void wxDC::DoDrawPolygon(int n
, wxPoint points
[],
814 wxCoord xoffset
, wxCoord yoffset
,
817 wxCHECK_RET(Ok(), wxT("Invalid DC"));
818 wxMacPortSetter
helper(this) ;
819 wxCoord x1
, x2
, y1
, y2
;
820 if ( m_brush
.GetStyle() == wxTRANSPARENT
&& m_pen
.GetStyle() == wxTRANSPARENT
)
822 PolyHandle polygon
= OpenPoly();
823 x2
= x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
824 y2
= y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
826 for (int i
= 1; i
< n
; i
++)
828 x2
= XLOG2DEVMAC(points
[i
].x
+ xoffset
);
829 y2
= YLOG2DEVMAC(points
[i
].y
+ yoffset
);
832 // close the polyline if necessary
833 if ( x1
!= x2
|| y1
!= y2
)
838 if (m_brush
.GetStyle() != wxTRANSPARENT
)
841 ::PaintPoly( polygon
);
843 if (m_pen
.GetStyle() != wxTRANSPARENT
)
846 ::FramePoly( polygon
) ;
850 void wxDC::DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
852 wxCHECK_RET(Ok(), wxT("Invalid DC"));
853 wxMacPortSetter
helper(this) ;
854 wxCoord xx
= XLOG2DEVMAC(x
);
855 wxCoord yy
= YLOG2DEVMAC(y
);
856 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
857 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
858 // CMB: draw nothing if transformed w or h is 0
859 if (ww
== 0 || hh
== 0)
861 // CMB: handle -ve width and/or height
872 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
873 if (m_brush
.GetStyle() != wxTRANSPARENT
)
876 ::PaintRect( &rect
) ;
878 if (m_pen
.GetStyle() != wxTRANSPARENT
)
881 ::FrameRect( &rect
) ;
884 void wxDC::DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
885 wxCoord width
, wxCoord height
,
888 wxCHECK_RET(Ok(), wxT("Invalid DC"));
889 wxMacPortSetter
helper(this) ;
891 radius
= - radius
* ((width
< height
) ? width
: height
);
892 wxCoord xx
= XLOG2DEVMAC(x
);
893 wxCoord yy
= YLOG2DEVMAC(y
);
894 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
895 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
896 // CMB: draw nothing if transformed w or h is 0
897 if (ww
== 0 || hh
== 0)
899 // CMB: handle -ve width and/or height
910 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
911 if (m_brush
.GetStyle() != wxTRANSPARENT
)
914 ::PaintRoundRect( &rect
, int(radius
* 2) , int(radius
* 2) ) ;
916 if (m_pen
.GetStyle() != wxTRANSPARENT
)
919 ::FrameRoundRect( &rect
, int(radius
* 2) , int(radius
* 2) ) ;
922 void wxDC::DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
924 wxCHECK_RET(Ok(), wxT("Invalid DC"));
925 wxMacPortSetter
helper(this) ;
926 wxCoord xx
= XLOG2DEVMAC(x
);
927 wxCoord yy
= YLOG2DEVMAC(y
);
928 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
929 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
930 // CMB: draw nothing if transformed w or h is 0
931 if (ww
== 0 || hh
== 0)
933 // CMB: handle -ve width and/or height
944 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
945 if (m_brush
.GetStyle() != wxTRANSPARENT
)
948 ::PaintOval( &rect
) ;
950 if (m_pen
.GetStyle() != wxTRANSPARENT
)
953 ::FrameOval( &rect
) ;
958 bool wxDC::CanDrawBitmap(void) const
963 bool wxDC::DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
964 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
, int logical_func
, bool useMask
,
965 wxCoord xsrcMask
, wxCoord ysrcMask
)
967 wxCHECK_MSG(Ok(), false, wxT("wxDC::DoBlit Illegal dc"));
968 wxCHECK_MSG(source
->Ok(), false, wxT("wxDC::DoBlit Illegal source DC"));
969 if ( logical_func
== wxNO_OP
)
971 if (xsrcMask
== -1 && ysrcMask
== -1)
973 xsrcMask
= xsrc
; ysrcMask
= ysrc
;
975 // correct the parameter in case this dc does not have a mask at all
976 if ( useMask
&& !source
->m_macMask
)
978 Rect srcrect
, dstrect
;
979 srcrect
.top
= source
->YLOG2DEVMAC(ysrc
) ;
980 srcrect
.left
= source
->XLOG2DEVMAC(xsrc
) ;
981 srcrect
.right
= source
->XLOG2DEVMAC(xsrc
+ width
) ;
982 srcrect
.bottom
= source
->YLOG2DEVMAC(ysrc
+ height
) ;
983 dstrect
.top
= YLOG2DEVMAC(ydest
) ;
984 dstrect
.left
= XLOG2DEVMAC(xdest
) ;
985 dstrect
.bottom
= YLOG2DEVMAC(ydest
+ height
) ;
986 dstrect
.right
= XLOG2DEVMAC(xdest
+ width
) ;
987 short mode
= kUnsupportedMode
;
988 bool invertDestinationFirst
= false ;
989 switch ( logical_func
)
991 case wxAND
: // src AND dst
994 case wxAND_INVERT
: // (NOT src) AND dst
995 mode
= notSrcOr
; // ok
997 case wxAND_REVERSE
:// src AND (NOT dst)
998 invertDestinationFirst
= true ;
1002 mode
= kEmulatedMode
;
1005 mode
= srcCopy
; // ok
1007 case wxEQUIV
: // (NOT src) XOR dst
1008 mode
= srcXor
; // ok
1010 case wxINVERT
: // NOT dst
1011 mode
= kEmulatedMode
; //or hilite ;
1013 case wxNAND
: // (NOT src) OR (NOT dst)
1014 invertDestinationFirst
= true ;
1017 case wxNOR
: // (NOT src) AND (NOT dst)
1018 invertDestinationFirst
= true ;
1021 case wxNO_OP
: // dst
1022 mode
= kEmulatedMode
; // this has already been handled upon entry
1024 case wxOR
: // src OR dst
1027 case wxOR_INVERT
: // (NOT src) OR dst
1030 case wxOR_REVERSE
: // src OR (NOT dst)
1031 invertDestinationFirst
= true ;
1035 mode
= kEmulatedMode
;
1037 case wxSRC_INVERT
: // (NOT src)
1038 mode
= notSrcCopy
; // ok
1040 case wxXOR
: // src XOR dst
1041 mode
= notSrcXor
; // ok
1046 if ( mode
== kUnsupportedMode
)
1048 wxFAIL_MSG("unsupported blitting mode" );
1051 CGrafPtr sourcePort
= (CGrafPtr
) source
->m_macPort
;
1052 PixMapHandle bmappixels
= GetGWorldPixMap( sourcePort
) ;
1053 if ( LockPixels(bmappixels
) )
1055 wxMacPortSetter
helper(this) ;
1056 if ( source
->GetDepth() == 1 )
1058 RGBForeColor( &MAC_WXCOLORREF(m_textForegroundColour
.GetPixel()) ) ;
1059 RGBBackColor( &MAC_WXCOLORREF(m_textBackgroundColour
.GetPixel()) ) ;
1063 // the modes need this, otherwise we'll end up having really nice colors...
1064 RGBColor white
= { 0xFFFF, 0xFFFF,0xFFFF} ;
1065 RGBColor black
= { 0,0,0} ;
1066 RGBForeColor( &black
) ;
1067 RGBBackColor( &white
) ;
1069 if ( useMask
&& source
->m_macMask
)
1071 if ( mode
== srcCopy
)
1073 if ( LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) )
1075 CopyMask( GetPortBitMapForCopyBits( sourcePort
) ,
1076 GetPortBitMapForCopyBits( MAC_WXHBITMAP(source
->m_macMask
) ) ,
1077 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1078 &srcrect
, &srcrect
, &dstrect
) ;
1079 UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1084 RgnHandle clipRgn
= NewRgn() ;
1085 LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1086 BitMapToRegion( clipRgn
, (BitMap
*) *GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1087 UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1088 OffsetRgn( clipRgn
, -srcrect
.left
+ dstrect
.left
, -srcrect
.top
+ dstrect
.top
) ;
1089 if ( mode
== kEmulatedMode
)
1092 ::PenPat(GetQDGlobalsBlack(&pat
));
1093 if ( logical_func
== wxSET
)
1095 RGBColor col
= { 0xFFFF, 0xFFFF, 0xFFFF } ;
1096 ::RGBForeColor( &col
) ;
1097 ::PaintRgn( clipRgn
) ;
1099 else if ( logical_func
== wxCLEAR
)
1101 RGBColor col
= { 0x0000, 0x0000, 0x0000 } ;
1102 ::RGBForeColor( &col
) ;
1103 ::PaintRgn( clipRgn
) ;
1105 else if ( logical_func
== wxINVERT
)
1107 MacInvertRgn( clipRgn
) ;
1111 for ( int y
= 0 ; y
< srcrect
.right
- srcrect
.left
; ++y
)
1113 for ( int x
= 0 ; x
< srcrect
.bottom
- srcrect
.top
; ++x
)
1115 Point dstPoint
= { dstrect
.top
+ y
, dstrect
.left
+ x
} ;
1116 Point srcPoint
= { srcrect
.top
+ y
, srcrect
.left
+ x
} ;
1117 if ( PtInRgn( dstPoint
, clipRgn
) )
1121 SetPort( (GrafPtr
) sourcePort
) ;
1122 GetCPixel( srcPoint
.h
, srcPoint
.v
, &srcColor
) ;
1123 SetPort( (GrafPtr
) m_macPort
) ;
1124 GetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1125 wxMacCalculateColour( logical_func
, srcColor
, dstColor
) ;
1126 SetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1134 if ( invertDestinationFirst
)
1136 MacInvertRgn( clipRgn
) ;
1138 CopyBits( GetPortBitMapForCopyBits( sourcePort
) ,
1139 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1140 &srcrect
, &dstrect
, mode
, clipRgn
) ;
1142 DisposeRgn( clipRgn
) ;
1147 RgnHandle clipRgn
= NewRgn() ;
1148 SetRectRgn( clipRgn
, dstrect
.left
, dstrect
.top
, dstrect
.right
, dstrect
.bottom
) ;
1149 if ( mode
== kEmulatedMode
)
1152 ::PenPat(GetQDGlobalsBlack(&pat
));
1153 if ( logical_func
== wxSET
)
1155 RGBColor col
= { 0xFFFF, 0xFFFF, 0xFFFF } ;
1156 ::RGBForeColor( &col
) ;
1157 ::PaintRgn( clipRgn
) ;
1159 else if ( logical_func
== wxCLEAR
)
1161 RGBColor col
= { 0x0000, 0x0000, 0x0000 } ;
1162 ::RGBForeColor( &col
) ;
1163 ::PaintRgn( clipRgn
) ;
1165 else if ( logical_func
== wxINVERT
)
1167 MacInvertRgn( clipRgn
) ;
1171 for ( int y
= 0 ; y
< srcrect
.right
- srcrect
.left
; ++y
)
1173 for ( int x
= 0 ; x
< srcrect
.bottom
- srcrect
.top
; ++x
)
1175 Point dstPoint
= { dstrect
.top
+ y
, dstrect
.left
+ x
} ;
1176 Point srcPoint
= { srcrect
.top
+ y
, srcrect
.left
+ x
} ;
1180 SetPort( (GrafPtr
) sourcePort
) ;
1181 GetCPixel( srcPoint
.h
, srcPoint
.v
, &srcColor
) ;
1182 SetPort( (GrafPtr
) m_macPort
) ;
1183 GetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1184 wxMacCalculateColour( logical_func
, srcColor
, dstColor
) ;
1185 SetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1193 if ( invertDestinationFirst
)
1195 MacInvertRgn( clipRgn
) ;
1197 CopyBits( GetPortBitMapForCopyBits( sourcePort
) ,
1198 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1199 &srcrect
, &dstrect
, mode
, NULL
) ;
1201 DisposeRgn( clipRgn
) ;
1203 UnlockPixels( bmappixels
) ;
1205 m_macPenInstalled
= false ;
1206 m_macBrushInstalled
= false ;
1207 m_macFontInstalled
= false ;
1210 inline Fixed
IntToFixed( int inInt
)
1212 return (((SInt32
) inInt
) << 16);
1214 inline int FixedToInt( Fixed inFixed
)
1216 return (((SInt32
) inFixed
) >> 16);
1219 void wxDC::DoDrawRotatedText(const wxString
& str
, wxCoord x
, wxCoord y
,
1222 wxCHECK_RET( Ok(), wxT("wxDC::DoDrawRotatedText Invalid window dc") );
1225 DrawText(str
, x
, y
);
1228 if ( str
.Length() == 0 )
1230 wxMacPortSetter
helper(this) ;
1233 if ( wxApp::s_macDefaultEncodingIsPC
)
1235 text
= wxMacMakeMacStringFromPC( str
) ;
1241 wxFontRefData
* font
= (wxFontRefData
*) m_font
.GetRefData() ;
1244 m_macFormerAliasState
= IsAntiAliasedTextEnabled(&m_macFormerAliasSize
);
1245 SetAntiAliasedTextEnabled(true, SInt16(m_scaleY
* font
->m_macFontSize
));
1246 m_macAliasWasEnabled
= true ;
1248 OSStatus status
= noErr
;
1250 status
= TECCreateConverter(&ec
, kTextEncodingMacRoman
, kTextEncodingUnicodeDefault
);
1251 wxASSERT_MSG( status
== noErr
, "couldn't start converter" ) ;
1252 ByteCount byteOutLen
;
1253 ByteCount byteInLen
= text
.Length() ;
1254 ByteCount byteBufferLen
= byteInLen
*2 ;
1255 char* buf
= new char[byteBufferLen
] ;
1256 status
= TECConvertText(ec
, (ConstTextPtr
)text
.c_str() , byteInLen
, &byteInLen
,
1257 (TextPtr
)buf
, byteBufferLen
, &byteOutLen
);
1258 wxASSERT_MSG( status
== noErr
, "couldn't convert text" ) ;
1259 status
= TECDisposeConverter(ec
);
1260 wxASSERT_MSG( status
== noErr
, "couldn't dispose converter" ) ;
1261 ATSUTextLayout atsuLayout
;
1262 UniCharCount chars
= byteOutLen
/ 2 ;
1263 status
= ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr
) buf
, 0 , byteOutLen
/ 2 , byteOutLen
/ 2 , 1 ,
1264 &chars
, (ATSUStyle
*) &m_macATSUIStyle
, &atsuLayout
) ;
1265 wxASSERT_MSG( status
== noErr
, "couldn't create the layout of the rotated text" );
1266 int iAngle
= int( angle
);
1267 int drawX
= XLOG2DEVMAC(x
) ;
1268 int drawY
= YLOG2DEVMAC(y
) ;
1270 ATSUTextMeasurement textBefore
;
1271 ATSUTextMeasurement textAfter
;
1272 ATSUTextMeasurement ascent
;
1273 ATSUTextMeasurement descent
;
1276 if ( abs(iAngle
) > 0 )
1278 Fixed atsuAngle
= IntToFixed( iAngle
) ;
1279 ATSUAttributeTag atsuTags
[] =
1281 kATSULineRotationTag
,
1283 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1287 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1291 status
= ::ATSUSetLayoutControls(atsuLayout
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
),
1292 atsuTags
, atsuSizes
, atsuValues
) ;
1294 status
= ::ATSUMeasureText( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1295 &textBefore
, &textAfter
, &ascent
, &descent
);
1297 drawX
+= sin(angle
/RAD2DEG
) * FixedToInt(ascent
) ;
1298 drawY
+= cos(angle
/RAD2DEG
) * FixedToInt(ascent
) ;
1299 status
= ::ATSUDrawText( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1300 IntToFixed(drawX
) , IntToFixed(drawY
) );
1301 wxASSERT_MSG( status
== noErr
, "couldn't draw the rotated text" );
1303 status
= ::ATSUMeasureTextImage( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1304 IntToFixed(drawX
) , IntToFixed(drawY
) , &rect
);
1305 wxASSERT_MSG( status
== noErr
, "couldn't measure the rotated text" );
1306 OffsetRect( &rect
, -m_macLocalOrigin
.x
, -m_macLocalOrigin
.y
) ;
1307 CalcBoundingBox(XDEV2LOG(rect
.left
), YDEV2LOG(rect
.top
) );
1308 CalcBoundingBox(XDEV2LOG(rect
.right
), YDEV2LOG(rect
.bottom
) );
1309 ::ATSUDisposeTextLayout(atsuLayout
);
1312 void wxDC::DoDrawText(const wxString
& strtext
, wxCoord x
, wxCoord y
)
1314 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawText Invalid DC"));
1315 wxMacPortSetter
helper(this) ;
1316 long xx
= XLOG2DEVMAC(x
);
1317 long yy
= YLOG2DEVMAC(y
);
1319 bool useDrawThemeText
= ( DrawThemeTextBox
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1320 if ( m_font
.GetNoAntiAliasing() )
1321 useDrawThemeText
= false ;
1326 m_macFormerAliasState
= IsAntiAliasedTextEnabled(&m_macFormerAliasSize
);
1327 SetAntiAliasedTextEnabled(true, 8);
1328 m_macAliasWasEnabled
= true ;
1331 ::GetFontInfo( &fi
) ;
1333 if ( !useDrawThemeText
)
1336 ::MoveTo( xx
, yy
);
1337 if ( m_backgroundMode
== wxTRANSPARENT
)
1339 ::TextMode( srcOr
) ;
1343 ::TextMode( srcCopy
) ;
1345 const char *text
= NULL
;
1348 if ( wxApp::s_macDefaultEncodingIsPC
)
1350 macText
= wxMacMakeMacStringFromPC( strtext
) ;
1352 length
= macText
.Length() ;
1357 length
= strtext
.Length() ;
1365 if( text
[i
] == 13 || text
[i
] == 10)
1368 if ( useDrawThemeText
)
1370 Rect frame
= { yy
+ line
*(fi
.descent
+ fi
.ascent
+ fi
.leading
) ,xx
, yy
+ (line
+1)*(fi
.descent
+ fi
.ascent
+ fi
.leading
) , xx
+ 10000 } ;
1371 CFStringRef mString
= CFStringCreateWithBytes( NULL
, (UInt8
*) text
+ laststop
, i
- laststop
, CFStringGetSystemEncoding(), false ) ;
1372 ::DrawThemeTextBox( mString
,
1373 kThemeCurrentPortFont
,
1379 CFRelease( mString
) ;
1385 ::DrawText( text
, laststop
, i
- laststop
) ;
1387 ::MoveTo( xx
, yy
+ line
*(fi
.descent
+ fi
.ascent
+ fi
.leading
) );
1394 if ( useDrawThemeText
)
1396 Rect frame
= { yy
+ line
*(fi
.descent
+ fi
.ascent
+ fi
.leading
) ,xx
, yy
+ (line
+1)*(fi
.descent
+ fi
.ascent
+ fi
.leading
) , xx
+ 10000 } ;
1397 CFStringRef mString
= CFStringCreateWithCString( NULL
, text
+ laststop
, kCFStringEncodingMacRoman
) ;
1398 ::DrawThemeTextBox( mString
,
1399 kThemeCurrentPortFont
,
1405 CFRelease( mString
) ;
1410 ::DrawText( text
, laststop
, i
- laststop
) ;
1413 ::TextMode( srcOr
) ;
1415 bool wxDC::CanGetTextExtent() const
1417 wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
1420 void wxDC::DoGetTextExtent( const wxString
&string
, wxCoord
*width
, wxCoord
*height
,
1421 wxCoord
*descent
, wxCoord
*externalLeading
,
1422 wxFont
*theFont
) const
1424 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1425 wxMacPortSetter
helper(this) ;
1426 wxFont formerFont
= m_font
;
1429 // work around the constness
1430 *((wxFont
*)(&m_font
)) = *theFont
;
1434 ::GetFontInfo( &fi
) ;
1436 bool useGetThemeText
= ( GetThemeTextDimensions
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1437 if ( ((wxFont
*)&m_font
)->GetNoAntiAliasing() )
1438 useGetThemeText
= false ;
1441 *height
= YDEV2LOGREL( fi
.descent
+ fi
.ascent
) ;
1443 *descent
=YDEV2LOGREL( fi
.descent
);
1444 if ( externalLeading
)
1445 *externalLeading
= YDEV2LOGREL( fi
.leading
) ;
1446 const char *text
= NULL
;
1449 if ( wxApp::s_macDefaultEncodingIsPC
)
1451 macText
= wxMacMakeMacStringFromPC( string
) ;
1453 length
= macText
.Length() ;
1458 length
= string
.Length() ;
1468 if( text
[i
] == 13 || text
[i
] == 10)
1471 *height
+= YDEV2LOGREL( fi
.descent
+ fi
.ascent
+ fi
.leading
) ;
1473 if ( useGetThemeText
)
1475 Point bounds
={0,0} ;
1477 CFStringRef mString
= CFStringCreateWithBytes( NULL
, (UInt8
*) text
+ laststop
, i
- laststop
, CFStringGetSystemEncoding(), false ) ;
1478 ::GetThemeTextDimensions( mString
,
1479 kThemeCurrentPortFont
,
1484 CFRelease( mString
) ;
1485 curwidth
= bounds
.h
;
1490 curwidth
= ::TextWidth( text
, laststop
, i
- laststop
) ;
1492 if ( curwidth
> *width
)
1493 *width
= XDEV2LOGREL( curwidth
) ;
1500 if ( useGetThemeText
)
1502 Point bounds
={0,0} ;
1504 CFStringRef mString
= CFStringCreateWithBytes( NULL
, (UInt8
*) text
+ laststop
, i
- laststop
, CFStringGetSystemEncoding(), false ) ;
1505 ::GetThemeTextDimensions( mString
,
1506 kThemeCurrentPortFont
,
1511 CFRelease( mString
) ;
1512 curwidth
= bounds
.h
;
1517 curwidth
= ::TextWidth( text
, laststop
, i
- laststop
) ;
1519 if ( curwidth
> *width
)
1520 *width
= XDEV2LOGREL( curwidth
) ;
1524 // work around the constness
1525 *((wxFont
*)(&m_font
)) = formerFont
;
1526 m_macFontInstalled
= false ;
1529 wxCoord
wxDC::GetCharWidth(void) const
1531 wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
1532 wxMacPortSetter
helper(this) ;
1536 bool useGetThemeText
= ( GetThemeTextDimensions
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1537 if ( ((wxFont
*)&m_font
)->GetNoAntiAliasing() )
1538 useGetThemeText
= false ;
1542 if ( useGetThemeText
)
1544 Point bounds
={0,0} ;
1546 CFStringRef mString
= CFStringCreateWithBytes( NULL
, (UInt8
*) text
, 1 , CFStringGetSystemEncoding(), false ) ;
1547 ::GetThemeTextDimensions( mString
,
1548 kThemeCurrentPortFont
,
1553 CFRelease( mString
) ;
1559 width
= ::TextWidth( text
, 0 , 1 ) ;
1561 return YDEV2LOGREL(width
) ;
1563 wxCoord
wxDC::GetCharHeight(void) const
1565 wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
1566 wxMacPortSetter
helper(this) ;
1569 ::GetFontInfo( &fi
) ;
1570 return YDEV2LOGREL( fi
.descent
+ fi
.ascent
);
1572 void wxDC::Clear(void)
1574 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1575 wxMacPortSetter
helper(this) ;
1576 Rect rect
= { -31000 , -31000 , 31000 , 31000 } ;
1577 if (m_backgroundBrush
.GetStyle() != wxTRANSPARENT
)
1580 //MacInstallBrush() ;
1581 MacSetupBackgroundForCurrentPort( m_backgroundBrush
) ;
1582 ::EraseRect( &rect
) ;
1585 void wxDC::MacInstallFont() const
1587 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1588 // if ( m_macFontInstalled )
1590 Pattern blackColor
;
1591 MacSetupBackgroundForCurrentPort(m_backgroundBrush
) ;
1592 wxFontRefData
* font
= (wxFontRefData
*) m_font
.GetRefData() ;
1595 ::TextFont( font
->m_macFontNum
) ;
1596 ::TextSize( short(m_scaleY
* font
->m_macFontSize
) ) ;
1597 ::TextFace( font
->m_macFontStyle
) ;
1598 m_macFontInstalled
= true ;
1599 m_macBrushInstalled
= false ;
1600 m_macPenInstalled
= false ;
1601 RGBColor forecolor
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel());
1602 RGBColor backcolor
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel());
1603 ::RGBForeColor( &forecolor
);
1604 ::RGBBackColor( &backcolor
);
1608 FontFamilyID fontId
;
1612 GetThemeFont(kThemeSmallSystemFont
, GetApplicationScript() , fontName
, &fontSize
, &fontStyle
) ;
1613 GetFNum( fontName
, &fontId
);
1614 ::TextFont( fontId
) ;
1615 ::TextSize( short(m_scaleY
* fontSize
) ) ;
1616 ::TextFace( fontStyle
) ;
1617 // todo reset after spacing changes - or store the current spacing somewhere
1618 m_macFontInstalled
= true ;
1619 m_macBrushInstalled
= false ;
1620 m_macPenInstalled
= false ;
1621 RGBColor forecolor
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel());
1622 RGBColor backcolor
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel());
1623 ::RGBForeColor( &forecolor
);
1624 ::RGBBackColor( &backcolor
);
1626 short mode
= patCopy
;
1628 switch( m_logicalFunction
)
1633 case wxINVERT
: // NOT dst
1634 ::PenPat(GetQDGlobalsBlack(&blackColor
));
1637 case wxXOR
: // src XOR dst
1640 case wxOR_REVERSE
: // src OR (NOT dst)
1643 case wxSRC_INVERT
: // (NOT src)
1648 case wxAND_REVERSE
:// src AND (NOT dst)
1649 case wxAND
: // src AND dst
1650 case wxAND_INVERT
: // (NOT src) AND dst
1651 case wxNO_OP
: // dst
1652 case wxNOR
: // (NOT src) AND (NOT dst)
1653 case wxEQUIV
: // (NOT src) XOR dst
1654 case wxOR_INVERT
: // (NOT src) OR dst
1655 case wxNAND
: // (NOT src) OR (NOT dst)
1656 case wxOR
: // src OR dst
1658 // case wxSRC_OR: // source _bitmap_ OR destination
1659 // case wxSRC_AND: // source _bitmap_ AND destination
1663 OSStatus status
= noErr
;
1664 Fixed atsuSize
= IntToFixed( int(m_scaleY
* font
->m_macFontSize
) ) ;
1665 Style qdStyle
= font
->m_macFontStyle
;
1666 ATSUFontID atsuFont
= font
->m_macATSUFontID
;
1667 status
= ::ATSUCreateStyle(&(ATSUStyle
)m_macATSUIStyle
) ;
1668 wxASSERT_MSG( status
== noErr
, "couldn't create ATSU style" ) ;
1669 ATSUAttributeTag atsuTags
[] =
1674 // kATSUBaselineClassTag ,
1675 kATSUVerticalCharacterTag
,
1676 kATSUQDBoldfaceTag
,
1678 kATSUQDUnderlineTag
,
1679 kATSUQDCondensedTag
,
1680 kATSUQDExtendedTag
,
1682 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1684 sizeof( ATSUFontID
) ,
1686 // sizeof( RGBColor ) ,
1687 // sizeof( BslnBaselineClass ) ,
1688 sizeof( ATSUVerticalCharacterType
),
1695 Boolean kTrue
= true ;
1696 Boolean kFalse
= false ;
1697 BslnBaselineClass kBaselineDefault
= kBSLNHangingBaseline
;
1698 ATSUVerticalCharacterType kHorizontal
= kATSUStronglyHorizontal
;
1699 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1703 // &MAC_WXCOLORREF( m_textForegroundColour.GetPixel() ) ,
1704 // &kBaselineDefault ,
1706 (qdStyle
& bold
) ? &kTrue
: &kFalse
,
1707 (qdStyle
& italic
) ? &kTrue
: &kFalse
,
1708 (qdStyle
& underline
) ? &kTrue
: &kFalse
,
1709 (qdStyle
& condense
) ? &kTrue
: &kFalse
,
1710 (qdStyle
& extend
) ? &kTrue
: &kFalse
,
1712 status
= ::ATSUSetAttributes((ATSUStyle
)m_macATSUIStyle
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
),
1713 atsuTags
, atsuSizes
, atsuValues
);
1714 wxASSERT_MSG( status
== noErr
, "couldn't set create ATSU style" ) ;
1716 Pattern gHatchPatterns
[] =
1718 { { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF } },
1719 { { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 } },
1720 { { 0x80 , 0x40 , 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , 0x01 } },
1721 { { 0x10 , 0x10 , 0x10 , 0xFF , 0x10 , 0x10 , 0x10 , 0x10 } },
1722 { { 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 } },
1723 { { 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 } },
1724 { { 0x81 , 0x42 , 0x24 , 0x18 , 0x18 , 0x24 , 0x42 , 0x81 } }
1726 static void wxMacGetHatchPattern(int hatchStyle
, Pattern
*pattern
)
1731 case wxBDIAGONAL_HATCH
:
1734 case wxFDIAGONAL_HATCH
:
1740 case wxHORIZONTAL_HATCH
:
1743 case wxVERTICAL_HATCH
:
1746 case wxCROSSDIAG_HATCH
:
1750 theIndex
= 1; // solid pattern
1753 *pattern
= gHatchPatterns
[theIndex
-1] ;
1755 void wxDC::MacInstallPen() const
1757 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1759 // if ( m_macPenInstalled )
1761 RGBColor forecolor
= MAC_WXCOLORREF( m_pen
.GetColour().GetPixel());
1762 RGBColor backcolor
= MAC_WXCOLORREF( m_backgroundBrush
.GetColour().GetPixel());
1763 ::RGBForeColor( &forecolor
);
1764 ::RGBBackColor( &backcolor
);
1766 int penWidth
= m_pen
.GetWidth() * (int) m_scaleX
;
1767 // null means only one pixel, at whatever resolution
1768 if ( penWidth
== 0 )
1770 ::PenSize(penWidth
, penWidth
);
1771 int penStyle
= m_pen
.GetStyle();
1772 if (penStyle
== wxSOLID
)
1774 ::PenPat(GetQDGlobalsBlack(&blackColor
));
1776 else if (IS_HATCH(penStyle
))
1779 wxMacGetHatchPattern(penStyle
, &pat
);
1784 Pattern pat
= *GetQDGlobalsBlack(&blackColor
) ;
1788 for ( int i
= 0 ; i
< 8 ; ++i
)
1794 for ( int i
= 0 ; i
< 8 ; ++i
)
1800 for ( int i
= 0 ; i
< 8 ; ++i
)
1806 for ( int i
= 0 ; i
< 8 ; ++i
)
1814 m_pen
.GetDashes(&dash
) ;
1815 // right now we don't allocate larger pixmaps
1817 m_pen
.GetDashes(&dash
) ;
1818 for ( int i
= 0 ; i
< 8 ; ++i
)
1820 pat
.pat
[i
] = dash
[0] ;
1827 short mode
= patCopy
;
1829 switch( m_logicalFunction
)
1831 case wxCOPY
: // only foreground color, leave background (thus not patCopy)
1834 case wxINVERT
: // NOT dst
1835 // ::PenPat(GetQDGlobalsBlack(&blackColor));
1838 case wxXOR
: // src XOR dst
1841 case wxOR_REVERSE
: // src OR (NOT dst)
1844 case wxSRC_INVERT
: // (NOT src)
1849 case wxAND_REVERSE
:// src AND (NOT dst)
1850 case wxAND
: // src AND dst
1851 case wxAND_INVERT
: // (NOT src) AND dst
1852 case wxNO_OP
: // dst
1853 case wxNOR
: // (NOT src) AND (NOT dst)
1854 case wxEQUIV
: // (NOT src) XOR dst
1855 case wxOR_INVERT
: // (NOT src) OR dst
1856 case wxNAND
: // (NOT src) OR (NOT dst)
1857 case wxOR
: // src OR dst
1859 // case wxSRC_OR: // source _bitmap_ OR destination
1860 // case wxSRC_AND: // source _bitmap_ AND destination
1864 m_macPenInstalled
= true ;
1865 m_macBrushInstalled
= false ;
1866 m_macFontInstalled
= false ;
1868 void wxDC::MacSetupBackgroundForCurrentPort(const wxBrush
& background
)
1870 Pattern whiteColor
;
1871 switch( background
.MacGetBrushKind() )
1873 case kwxMacBrushTheme
:
1875 ::SetThemeBackground( background
.GetMacTheme() , wxDisplayDepth() , true ) ;
1878 case kwxMacBrushThemeBackground
:
1881 ThemeBackgroundKind bg
= background
.GetMacThemeBackground( &extent
) ;
1882 ::ApplyThemeBackground( bg
, &extent
,kThemeStateActive
, wxDisplayDepth() , true ) ;
1885 case kwxMacBrushColour
:
1887 ::RGBBackColor( &MAC_WXCOLORREF( background
.GetColour().GetPixel()) );
1888 int brushStyle
= background
.GetStyle();
1889 if (brushStyle
== wxSOLID
)
1890 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
1891 else if (IS_HATCH(brushStyle
))
1894 wxMacGetHatchPattern(brushStyle
, &pat
);
1899 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
1905 void wxDC::MacInstallBrush() const
1907 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1908 Pattern blackColor
;
1909 // if ( m_macBrushInstalled )
1912 bool backgroundTransparent
= (GetBackgroundMode() == wxTRANSPARENT
) ;
1913 ::RGBForeColor( &MAC_WXCOLORREF( m_brush
.GetColour().GetPixel()) );
1914 ::RGBBackColor( &MAC_WXCOLORREF( m_backgroundBrush
.GetColour().GetPixel()) );
1915 int brushStyle
= m_brush
.GetStyle();
1916 if (brushStyle
== wxSOLID
)
1918 ::PenPat(GetQDGlobalsBlack(&blackColor
));
1920 else if (IS_HATCH(brushStyle
))
1923 wxMacGetHatchPattern(brushStyle
, &pat
);
1926 else if ( m_brush
.GetStyle() == wxSTIPPLE
|| m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
)
1928 // we force this in order to be compliant with wxMSW
1929 backgroundTransparent
= false ;
1930 // for these the text fore (and back for MASK_OPAQUE) colors are used
1931 wxBitmap
* bitmap
= m_brush
.GetStipple() ;
1932 int width
= bitmap
->GetWidth() ;
1933 int height
= bitmap
->GetHeight() ;
1934 GWorldPtr gw
= NULL
;
1935 if ( m_brush
.GetStyle() == wxSTIPPLE
)
1936 gw
= MAC_WXHBITMAP(bitmap
->GetHBITMAP()) ;
1938 gw
= MAC_WXHBITMAP(bitmap
->GetMask()->GetMaskBitmap()) ;
1939 PixMapHandle gwpixmaphandle
= GetGWorldPixMap( gw
) ;
1940 LockPixels( gwpixmaphandle
) ;
1941 bool isMonochrome
= !IsPortColor( gw
) ;
1942 if ( !isMonochrome
)
1944 if ( (**gwpixmaphandle
).pixelSize
== 1 )
1945 isMonochrome
= true ;
1947 if ( isMonochrome
&& width
== 8 && height
== 8 )
1949 ::RGBForeColor( &MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) );
1950 ::RGBForeColor( &MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) );
1951 BitMap
* gwbitmap
= (BitMap
*) *gwpixmaphandle
; // since the color depth is 1 it is a BitMap
1952 UInt8
*gwbits
= (UInt8
*) gwbitmap
->baseAddr
;
1953 int alignment
= gwbitmap
->rowBytes
& 0x7FFF ;
1955 for ( int i
= 0 ; i
< 8 ; ++i
)
1957 pat
.pat
[i
] = gwbits
[i
*alignment
+0] ;
1959 UnlockPixels( GetGWorldPixMap( gw
) ) ;
1964 // this will be the code to handle power of 2 patterns, we will have to arrive at a nice
1965 // caching scheme before putting this into production
1968 PixPatHandle pixpat
= NewPixPat() ;
1969 CopyPixMap(gwpixmaphandle
, (**pixpat
).patMap
);
1970 imageSize
= GetPixRowBytes((**pixpat
).patMap
) *
1971 ((**(**pixpat
).patMap
).bounds
.bottom
-
1972 (**(**pixpat
).patMap
).bounds
.top
);
1973 PtrToHand( (**gwpixmaphandle
).baseAddr
, &image
, imageSize
);
1974 (**pixpat
).patData
= image
;
1977 CTabHandle ctable
= ((**((**pixpat
).patMap
)).pmTable
) ;
1978 ColorSpecPtr ctspec
= (ColorSpecPtr
) &(**ctable
).ctTable
;
1979 if ( ctspec
[0].rgb
.red
== 0x0000 )
1981 ctspec
[1].rgb
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) ;
1982 ctspec
[0].rgb
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) ;
1986 ctspec
[0].rgb
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) ;
1987 ctspec
[1].rgb
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) ;
1989 ::CTabChanged( ctable
) ;
1991 ::PenPixPat(pixpat
);
1992 m_macForegroundPixMap
= pixpat
;
1994 UnlockPixels( gwpixmaphandle
) ;
1998 ::PenPat(GetQDGlobalsBlack(&blackColor
));
2000 short mode
= patCopy
;
2001 switch( m_logicalFunction
)
2004 if ( backgroundTransparent
)
2009 case wxINVERT
: // NOT dst
2010 if ( !backgroundTransparent
)
2012 ::PenPat(GetQDGlobalsBlack(&blackColor
));
2016 case wxXOR
: // src XOR dst
2019 case wxOR_REVERSE
: // src OR (NOT dst)
2022 case wxSRC_INVERT
: // (NOT src)
2027 case wxAND_REVERSE
:// src AND (NOT dst)
2028 case wxAND
: // src AND dst
2029 case wxAND_INVERT
: // (NOT src) AND dst
2030 case wxNO_OP
: // dst
2031 case wxNOR
: // (NOT src) AND (NOT dst)
2032 case wxEQUIV
: // (NOT src) XOR dst
2033 case wxOR_INVERT
: // (NOT src) OR dst
2034 case wxNAND
: // (NOT src) OR (NOT dst)
2035 case wxOR
: // src OR dst
2037 // case wxSRC_OR: // source _bitmap_ OR destination
2038 // case wxSRC_AND: // source _bitmap_ AND destination
2042 m_macBrushInstalled
= true ;
2043 m_macPenInstalled
= false ;
2044 m_macFontInstalled
= false ;
2046 // ---------------------------------------------------------------------------
2047 // coordinates transformations
2048 // ---------------------------------------------------------------------------
2050 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
2052 return ((wxDC
*)this)->XDEV2LOG(x
);
2054 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
2056 return ((wxDC
*)this)->YDEV2LOG(y
);
2058 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
2060 return ((wxDC
*)this)->XDEV2LOGREL(x
);
2062 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
2064 return ((wxDC
*)this)->YDEV2LOGREL(y
);
2066 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
2068 return ((wxDC
*)this)->XLOG2DEV(x
);
2070 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
2072 return ((wxDC
*)this)->YLOG2DEV(y
);
2074 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
2076 return ((wxDC
*)this)->XLOG2DEVREL(x
);
2078 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
2080 return ((wxDC
*)this)->YLOG2DEVREL(y
);