1 /////////////////////////////////////////////////////////////////////////////
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "dc.h"
18 #include "wx/mac/uma.h"
19 #include "wx/dcmemory.h"
20 #include "wx/region.h"
30 #include "wx/mac/private.h"
31 #include "ATSUnicode.h"
32 #include "TextCommon.h"
33 #include "TextEncodingConverter.h"
35 #if !USE_SHARED_LIBRARY
36 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxObject
)
39 //-----------------------------------------------------------------------------
41 //-----------------------------------------------------------------------------
43 #define mm2inches 0.0393700787402
44 #define inches2mm 25.4
45 #define mm2twips 56.6929133859
46 #define twips2mm 0.0176388888889
47 #define mm2pt 2.83464566929
48 #define pt2mm 0.352777777778
50 const double M_PI
= 3.14159265358979 ;
52 const double RAD2DEG
= 180.0 / M_PI
;
53 const short kEmulatedMode
= -1 ;
54 const short kUnsupportedMode
= -2 ;
56 wxMacPortSetter::wxMacPortSetter( const wxDC
* dc
) :
57 m_ph( (GrafPtr
) dc
->m_macPort
)
59 wxASSERT( dc
->Ok() ) ;
61 dc
->MacSetupPort(&m_ph
) ;
64 wxMacPortSetter::~wxMacPortSetter()
66 m_dc
->MacCleanupPort(&m_ph
) ;
69 wxMacWindowClipper::wxMacWindowClipper( const wxWindow
* win
)
71 m_formerClip
= NewRgn() ;
72 m_newClip
= NewRgn() ;
73 GetClip( m_formerClip
) ;
77 RgnHandle insidergn
= NewRgn() ;
79 wxWindow
*parent
= win
->GetParent() ;
80 parent
->MacWindowToRootWindow( &x
,&y
) ;
82 wxSize size
= parent
->GetSize() ;
83 SetRectRgn( insidergn
, parent
->MacGetLeftBorderSize() , parent
->MacGetTopBorderSize() ,
84 size
.x
- parent
->MacGetLeftBorderSize() - parent
->MacGetRightBorderSize(),
85 size
.y
- parent
->MacGetTopBorderSize() - parent
->MacGetBottomBorderSize()) ;
87 CopyRgn( (RgnHandle
) parent
->MacGetVisibleRegion(false).GetWXHRGN() , m_newClip
) ;
88 SectRgn( m_newClip
, insidergn
, m_newClip
) ;
89 OffsetRgn( m_newClip
, x
, y
) ;
90 SetClip( m_newClip
) ;
91 DisposeRgn( insidergn
) ;
95 wxMacWindowClipper::~wxMacWindowClipper()
97 SetClip( m_formerClip
) ;
98 DisposeRgn( m_newClip
) ;
99 DisposeRgn( m_formerClip
) ;
102 //-----------------------------------------------------------------------------
104 //-----------------------------------------------------------------------------
106 static inline double dmin(double a
, double b
) { return a
< b
? a
: b
; }
107 static inline double dmax(double a
, double b
) { return a
> b
? a
: b
; }
108 static inline double DegToRad(double deg
) { return (deg
* M_PI
) / 180.0; }
110 //-----------------------------------------------------------------------------
112 //-----------------------------------------------------------------------------
114 // this function emulates all wx colour manipulations, used to verify the implementation
115 // by setting the mode in the blitting functions to kEmulatedMode
117 void wxMacCalculateColour( int logical_func
, const RGBColor
&srcColor
, RGBColor
&dstColor
) ;
118 void wxMacCalculateColour( int logical_func
, const RGBColor
&srcColor
, RGBColor
&dstColor
)
120 switch ( logical_func
)
122 case wxAND
: // src AND dst
123 dstColor
.red
= dstColor
.red
& srcColor
.red
;
124 dstColor
.green
= dstColor
.green
& srcColor
.green
;
125 dstColor
.blue
= dstColor
.blue
& srcColor
.blue
;
127 case wxAND_INVERT
: // (NOT src) AND dst
128 dstColor
.red
= dstColor
.red
& ~srcColor
.red
;
129 dstColor
.green
= dstColor
.green
& ~srcColor
.green
;
130 dstColor
.blue
= dstColor
.blue
& ~srcColor
.blue
;
132 case wxAND_REVERSE
:// src AND (NOT dst)
133 dstColor
.red
= ~dstColor
.red
& srcColor
.red
;
134 dstColor
.green
= ~dstColor
.green
& srcColor
.green
;
135 dstColor
.blue
= ~dstColor
.blue
& srcColor
.blue
;
143 dstColor
.red
= srcColor
.red
;
144 dstColor
.green
= srcColor
.green
;
145 dstColor
.blue
= srcColor
.blue
;
147 case wxEQUIV
: // (NOT src) XOR dst
148 dstColor
.red
= dstColor
.red
^ ~srcColor
.red
;
149 dstColor
.green
= dstColor
.green
^ ~srcColor
.green
;
150 dstColor
.blue
= dstColor
.blue
^ ~srcColor
.blue
;
152 case wxINVERT
: // NOT dst
153 dstColor
.red
= ~dstColor
.red
;
154 dstColor
.green
= ~dstColor
.green
;
155 dstColor
.blue
= ~dstColor
.blue
;
157 case wxNAND
: // (NOT src) OR (NOT dst)
158 dstColor
.red
= ~dstColor
.red
| ~srcColor
.red
;
159 dstColor
.green
= ~dstColor
.green
| ~srcColor
.green
;
160 dstColor
.blue
= ~dstColor
.blue
| ~srcColor
.blue
;
162 case wxNOR
: // (NOT src) AND (NOT dst)
163 dstColor
.red
= ~dstColor
.red
& ~srcColor
.red
;
164 dstColor
.green
= ~dstColor
.green
& ~srcColor
.green
;
165 dstColor
.blue
= ~dstColor
.blue
& ~srcColor
.blue
;
169 case wxOR
: // src OR dst
170 dstColor
.red
= dstColor
.red
| srcColor
.red
;
171 dstColor
.green
= dstColor
.green
| srcColor
.green
;
172 dstColor
.blue
= dstColor
.blue
| srcColor
.blue
;
174 case wxOR_INVERT
: // (NOT src) OR dst
175 dstColor
.red
= dstColor
.red
| ~srcColor
.red
;
176 dstColor
.green
= dstColor
.green
| ~srcColor
.green
;
177 dstColor
.blue
= dstColor
.blue
| ~srcColor
.blue
;
179 case wxOR_REVERSE
: // src OR (NOT dst)
180 dstColor
.red
= ~dstColor
.red
| srcColor
.red
;
181 dstColor
.green
= ~dstColor
.green
| srcColor
.green
;
182 dstColor
.blue
= ~dstColor
.blue
| srcColor
.blue
;
185 dstColor
.red
= 0xFFFF ;
186 dstColor
.green
= 0xFFFF ;
187 dstColor
.blue
= 0xFFFF ;
189 case wxSRC_INVERT
: // (NOT src)
190 dstColor
.red
= ~srcColor
.red
;
191 dstColor
.green
= ~srcColor
.green
;
192 dstColor
.blue
= ~srcColor
.blue
;
194 case wxXOR
: // src XOR dst
195 dstColor
.red
= dstColor
.red
^ srcColor
.red
;
196 dstColor
.green
= dstColor
.green
^ srcColor
.green
;
197 dstColor
.blue
= dstColor
.blue
^ srcColor
.blue
;
208 m_mm_to_pix_x
= mm2pt
;
209 m_mm_to_pix_y
= mm2pt
;
211 m_internalDeviceOriginX
= 0;
212 m_internalDeviceOriginY
= 0;
213 m_externalDeviceOriginX
= 0;
214 m_externalDeviceOriginY
= 0;
216 m_logicalScaleX
= 1.0;
217 m_logicalScaleY
= 1.0;
223 m_needComputeScaleX
= FALSE
;
224 m_needComputeScaleY
= FALSE
;
230 m_macFontInstalled
= false ;
231 m_macBrushInstalled
= false ;
232 m_macPenInstalled
= false ;
234 m_macLocalOrigin
.x
= m_macLocalOrigin
.y
= 0 ;
235 m_macBoundaryClipRgn
= NewRgn() ;
236 m_macCurrentClipRgn
= NewRgn() ;
238 SetRectRgn( (RgnHandle
) m_macBoundaryClipRgn
, -32000 , -32000 , 32000 , 32000 ) ;
239 SetRectRgn( (RgnHandle
) m_macCurrentClipRgn
, -32000 , -32000 , 32000 , 32000 ) ;
241 m_pen
= *wxBLACK_PEN
;
242 m_font
= *wxNORMAL_FONT
;
243 m_brush
= *wxWHITE_BRUSH
;
244 m_macCurrentPortStateHelper
= NULL
;
245 m_macATSUIStyle
= NULL
;
246 m_macAliasWasEnabled
= false;
247 m_macForegroundPixMap
= NULL
;
248 m_macBackgroundPixMap
= NULL
;
253 DisposeRgn( (RgnHandle
) m_macBoundaryClipRgn
) ;
254 DisposeRgn( (RgnHandle
) m_macCurrentClipRgn
) ;
256 void wxDC::MacSetupPort(wxMacPortStateHelper
* help
) const
258 wxASSERT( m_macCurrentPortStateHelper
== NULL
) ;
259 m_macCurrentPortStateHelper
= help
;
260 SetClip( (RgnHandle
) m_macCurrentClipRgn
);
262 m_macFontInstalled
= false ;
263 m_macBrushInstalled
= false ;
264 m_macPenInstalled
= false ;
267 void wxDC::MacCleanupPort(wxMacPortStateHelper
* help
) const
269 wxASSERT( m_macCurrentPortStateHelper
== help
) ;
270 m_macCurrentPortStateHelper
= NULL
;
271 if( m_macATSUIStyle
)
273 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUIStyle
);
274 m_macATSUIStyle
= NULL
;
276 if ( m_macAliasWasEnabled
)
278 SetAntiAliasedTextEnabled(m_macFormerAliasState
, m_macFormerAliasSize
);
279 m_macAliasWasEnabled
= false ;
281 if ( m_macForegroundPixMap
)
284 ::PenPat(GetQDGlobalsBlack(&blackColor
));
285 DisposePixPat( (PixPatHandle
) m_macForegroundPixMap
) ;
286 m_macForegroundPixMap
= NULL
;
288 if ( m_macBackgroundPixMap
)
291 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
292 DisposePixPat( (PixPatHandle
) m_macBackgroundPixMap
) ;
293 m_macBackgroundPixMap
= NULL
;
297 void wxDC::DoDrawBitmap( const wxBitmap
&bmp
, wxCoord x
, wxCoord y
, bool useMask
)
299 wxCHECK_RET( Ok(), wxT("invalid window dc") );
301 wxCHECK_RET( bmp
.Ok(), wxT("invalid bitmap") );
303 wxMacPortSetter
helper(this) ;
305 wxCoord xx
= XLOG2DEVMAC(x
);
306 wxCoord yy
= YLOG2DEVMAC(y
);
307 wxCoord w
= bmp
.GetWidth();
308 wxCoord h
= bmp
.GetHeight();
309 wxCoord ww
= XLOG2DEVREL(w
);
310 wxCoord hh
= YLOG2DEVREL(h
);
312 // Set up drawing mode
313 short mode
= (m_logicalFunction
== wxCOPY
? srcCopy
:
314 //m_logicalFunction == wxCLEAR ? WHITENESS :
315 //m_logicalFunction == wxSET ? BLACKNESS :
316 m_logicalFunction
== wxINVERT
? hilite
:
317 //m_logicalFunction == wxAND ? MERGECOPY :
318 m_logicalFunction
== wxOR
? srcOr
:
319 m_logicalFunction
== wxSRC_INVERT
? notSrcCopy
:
320 m_logicalFunction
== wxXOR
? srcXor
:
321 m_logicalFunction
== wxOR_REVERSE
? notSrcOr
:
322 //m_logicalFunction == wxAND_REVERSE ? SRCERASE :
323 //m_logicalFunction == wxSRC_OR ? srcOr :
324 //m_logicalFunction == wxSRC_AND ? SRCAND :
327 if ( bmp
.GetBitmapType() == kMacBitmapTypePict
) {
328 Rect bitmaprect
= { 0 , 0 , hh
, ww
};
329 ::OffsetRect( &bitmaprect
, xx
, yy
) ;
330 ::DrawPicture( (PicHandle
) bmp
.GetPict(), &bitmaprect
) ;
332 else if ( bmp
.GetBitmapType() == kMacBitmapTypeGrafWorld
)
334 GWorldPtr bmapworld
= MAC_WXHBITMAP( bmp
.GetHBITMAP() );
335 PixMapHandle bmappixels
;
337 // Set foreground and background colours (for bitmaps depth = 1)
338 if(bmp
.GetDepth() == 1)
340 RGBColor fore
= MAC_WXCOLORREF(m_textForegroundColour
.GetPixel());
341 RGBColor back
= MAC_WXCOLORREF(m_textBackgroundColour
.GetPixel());
347 RGBColor white
= { 0xFFFF, 0xFFFF,0xFFFF} ;
348 RGBColor black
= { 0,0,0} ;
349 RGBForeColor( &black
) ;
350 RGBBackColor( &white
) ;
353 bmappixels
= GetGWorldPixMap( bmapworld
) ;
355 wxCHECK_RET(LockPixels(bmappixels
),
356 wxT("DoDrawBitmap: Unable to lock pixels"));
358 Rect source
= { 0, 0, h
, w
};
359 Rect dest
= { yy
, xx
, yy
+ hh
, xx
+ ww
};
361 if ( useMask
&& bmp
.GetMask() )
363 if( LockPixels(GetGWorldPixMap(MAC_WXHBITMAP(bmp
.GetMask()->GetMaskBitmap()))))
367 GetPortBitMapForCopyBits(bmapworld
),
368 GetPortBitMapForCopyBits(MAC_WXHBITMAP(bmp
.GetMask()->GetMaskBitmap())),
369 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ),
370 &source
, &source
, &dest
, mode
, NULL
372 UnlockPixels(GetGWorldPixMap(MAC_WXHBITMAP(bmp
.GetMask()->GetMaskBitmap())));
376 CopyBits( GetPortBitMapForCopyBits( bmapworld
),
377 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ),
378 &source
, &dest
, mode
, NULL
) ;
380 UnlockPixels( bmappixels
) ;
382 else if ( bmp
.GetBitmapType() == kMacBitmapTypeIcon
)
384 Rect bitmaprect
= { 0 , 0 , bmp
.GetHeight(), bmp
.GetWidth() } ;
385 OffsetRect( &bitmaprect
, xx
, yy
) ;
386 PlotCIconHandle( &bitmaprect
, atNone
, ttNone
, MAC_WXHICON(bmp
.GetHICON()) ) ;
388 m_macPenInstalled
= false ;
389 m_macBrushInstalled
= false ;
390 m_macFontInstalled
= false ;
394 void wxDC::DoDrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
)
396 wxCHECK_RET(Ok(), wxT("Invalid dc wxDC::DoDrawIcon"));
398 wxCHECK_RET(icon
.Ok(), wxT("Invalid icon wxDC::DoDrawIcon"));
400 DoDrawBitmap( icon
, x
, y
, icon
.GetMask() != NULL
) ;
402 void wxDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
404 wxCHECK_RET(Ok(), wxT("wxDC::DoSetClippingRegion Invalid DC"));
405 wxCoord xx
, yy
, ww
, hh
;
409 ww
= XLOG2DEVREL(width
);
410 hh
= YLOG2DEVREL(height
);
412 SetRectRgn( (RgnHandle
) m_macCurrentClipRgn
, xx
, yy
, xx
+ ww
, yy
+ hh
) ;
413 SectRgn( (RgnHandle
) m_macCurrentClipRgn
, (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
417 m_clipX1
= wxMax( m_clipX1
, xx
);
418 m_clipY1
= wxMax( m_clipY1
, yy
);
419 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
));
420 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
));
432 void wxDC::DoSetClippingRegionAsRegion( const wxRegion
®ion
)
434 wxCHECK_RET( Ok(), wxT("invalid window dc") ) ;
436 wxMacPortSetter
helper(this) ;
439 DestroyClippingRegion();
444 region
.GetBox( x
, y
, w
, h
);
445 wxCoord xx
, yy
, ww
, hh
;
452 // if we have a scaling that we cannot map onto native regions
453 // we must use the box
455 if ( ww
!= w
|| hh
!= h
)
457 wxDC::DoSetClippingRegion( x
, y
, w
, h
);
461 CopyRgn( (RgnHandle
) region
.GetWXHRGN() , (RgnHandle
) m_macCurrentClipRgn
) ;
462 if ( xx
!= x
|| yy
!= y
)
464 OffsetRgn( (RgnHandle
) m_macCurrentClipRgn
, xx
- x
, yy
- y
) ;
466 SectRgn( (RgnHandle
) m_macCurrentClipRgn
, (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
469 m_clipX1
= wxMax( m_clipX1
, xx
);
470 m_clipY1
= wxMax( m_clipY1
, yy
);
471 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
));
472 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
));
486 void wxDC::DestroyClippingRegion()
488 wxMacPortSetter
helper(this) ;
489 CopyRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
492 void wxDC::DoGetSize( int* width
, int* height
) const
494 *width
= m_maxX
-m_minX
;
495 *height
= m_maxY
-m_minY
;
497 void wxDC::DoGetSizeMM( int* width
, int* height
) const
502 *width
= long( double(w
) / (m_scaleX
*m_mm_to_pix_x
) );
503 *height
= long( double(h
) / (m_scaleY
*m_mm_to_pix_y
) );
505 void wxDC::SetTextForeground( const wxColour
&col
)
507 wxCHECK_RET(Ok(), wxT("Invalid DC"));
508 m_textForegroundColour
= col
;
509 m_macFontInstalled
= false ;
511 void wxDC::SetTextBackground( const wxColour
&col
)
513 wxCHECK_RET(Ok(), wxT("Invalid DC"));
514 m_textBackgroundColour
= col
;
515 m_macFontInstalled
= false ;
517 void wxDC::SetMapMode( int mode
)
522 SetLogicalScale( twips2mm
*m_mm_to_pix_x
, twips2mm
*m_mm_to_pix_y
);
525 SetLogicalScale( pt2mm
*m_mm_to_pix_x
, pt2mm
*m_mm_to_pix_y
);
528 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
531 SetLogicalScale( m_mm_to_pix_x
/10.0, m_mm_to_pix_y
/10.0 );
535 SetLogicalScale( 1.0, 1.0 );
538 if (mode
!= wxMM_TEXT
)
540 m_needComputeScaleX
= TRUE
;
541 m_needComputeScaleY
= TRUE
;
544 void wxDC::SetUserScale( double x
, double y
)
546 // allow negative ? -> no
549 ComputeScaleAndOrigin();
551 void wxDC::SetLogicalScale( double x
, double y
)
556 ComputeScaleAndOrigin();
558 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
560 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
561 m_logicalOriginY
= y
* m_signY
;
562 ComputeScaleAndOrigin();
564 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
566 m_externalDeviceOriginX
= x
;
567 m_externalDeviceOriginY
= y
;
568 ComputeScaleAndOrigin();
572 void wxDC::SetInternalDeviceOrigin( long x
, long y
)
574 m_internalDeviceOriginX
= x
;
575 m_internalDeviceOriginY
= y
;
576 ComputeScaleAndOrigin();
578 void wxDC::GetInternalDeviceOrigin( long *x
, long *y
)
580 if (x
) *x
= m_internalDeviceOriginX
;
581 if (y
) *y
= m_internalDeviceOriginY
;
584 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
586 m_signX
= (xLeftRight
? 1 : -1);
587 m_signY
= (yBottomUp
? -1 : 1);
588 ComputeScaleAndOrigin();
591 wxSize
wxDC::GetPPI() const
593 return wxSize(72, 72);
596 int wxDC::GetDepth() const
598 if ( IsPortColor( (CGrafPtr
) m_macPort
) )
600 return ( (**GetPortPixMap( (CGrafPtr
) m_macPort
)).pixelSize
) ;
605 void wxDC::ComputeScaleAndOrigin()
607 // CMB: copy scale to see if it changes
608 double origScaleX
= m_scaleX
;
609 double origScaleY
= m_scaleY
;
611 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
612 m_scaleY
= m_logicalScaleY
* m_userScaleY
;
614 m_deviceOriginX
= m_internalDeviceOriginX
+ m_externalDeviceOriginX
;
615 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
622 wxPen
* pen
= & GetPen();
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
)
650 m_macPenInstalled
= false ;
653 void wxDC::SetBrush( const wxBrush
&brush
)
655 if (m_brush
== brush
)
659 m_macBrushInstalled
= false ;
662 void wxDC::SetBackground( const wxBrush
&brush
)
664 if (m_backgroundBrush
== brush
)
667 m_backgroundBrush
= brush
;
669 if (!m_backgroundBrush
.Ok())
671 m_macBrushInstalled
= false ;
674 void wxDC::SetLogicalFunction( int function
)
676 if (m_logicalFunction
== function
)
679 m_logicalFunction
= function
;
680 m_macFontInstalled
= false ;
681 m_macBrushInstalled
= false ;
682 m_macPenInstalled
= false ;
685 extern bool wxDoFloodFill(wxDC
*dc
, wxCoord x
, wxCoord y
,
686 const wxColour
& col
, int style
);
688 bool wxDC::DoFloodFill(wxCoord x
, wxCoord y
,
689 const wxColour
& col
, int style
)
691 return wxDoFloodFill(this, x
, y
, col
, style
);
694 bool wxDC::DoGetPixel( wxCoord x
, wxCoord y
, wxColour
*col
) const
696 wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel Invalid DC") );
697 wxMacPortSetter
helper(this) ;
701 GetCPixel( XLOG2DEVMAC(x
), YLOG2DEVMAC(y
), &colour
);
703 // Convert from Mac colour to wx
704 col
->Set( colour
.red
>> 8,
711 void wxDC::DoDrawLine( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
713 wxCHECK_RET(Ok(), wxT("Invalid DC"));
715 wxMacPortSetter
helper(this) ;
717 if (m_pen
.GetStyle() != wxTRANSPARENT
)
720 wxCoord offset
= ( (m_pen
.GetWidth() == 0 ? 1 :
721 m_pen
.GetWidth() ) * (wxCoord
)m_scaleX
- 1) / 2;
723 wxCoord xx1
= XLOG2DEVMAC(x1
) - offset
;
724 wxCoord yy1
= YLOG2DEVMAC(y1
) - offset
;
725 wxCoord xx2
= XLOG2DEVMAC(x2
) - offset
;
726 wxCoord yy2
= YLOG2DEVMAC(y2
) - offset
;
728 if ((m_pen
.GetCap() == wxCAP_ROUND
) &&
729 (m_pen
.GetWidth() <= 1))
731 // Implement LAST_NOT for MAC at least for
732 // orthogonal lines. RR.
754 void wxDC::DoCrossHair( wxCoord x
, wxCoord y
)
756 wxCHECK_RET( Ok(), wxT("wxDC::DoCrossHair Invalid window dc") );
757 wxMacPortSetter
helper(this) ;
759 if (m_pen
.GetStyle() != wxTRANSPARENT
)
764 wxCoord xx
= XLOG2DEVMAC(x
);
765 wxCoord yy
= YLOG2DEVMAC(y
);
768 ::MoveTo( XLOG2DEVMAC(0), yy
);
769 ::LineTo( XLOG2DEVMAC(w
), yy
);
770 ::MoveTo( xx
, YLOG2DEVMAC(0) );
771 ::LineTo( xx
, YLOG2DEVMAC(h
) );
773 CalcBoundingBox(x
, y
);
774 CalcBoundingBox(x
+w
, y
+h
);
780 * To draw arcs properly the angles need to be converted from the WX style:
781 * Angles start on the +ve X axis and go anti-clockwise (As you would draw on
782 * a normal axis on paper).
785 * Angles start on the +ve y axis and go clockwise.
786 * To achive this I work out which quadrant the angle lies in then map this to
787 * the equivalent quadrant on the Mac. (Sin and Cos values reveal which
788 * quadrant you are in).
790 static double wxConvertWXangleToMACangle(double angle
)
794 sin_a
= sin(angle
/ RAD2DEG
);
795 cos_a
= cos(angle
/ RAD2DEG
);
797 if( (sin_a
>= 0.0) && (cos_a
>= 0.0) ) {
798 angle
= acos(sin_a
) * RAD2DEG
;
800 else if( (sin_a
>= 0.0) && (cos_a
<= 0.0) ) {
802 angle
= acos(sin_a
) * RAD2DEG
+ 180;
804 else if( (sin_a
<= 0.0) && (cos_a
>= 0.0) ) {
805 angle
= acos(sin_a
) * RAD2DEG
+ 180;
807 else if( (sin_a
< 0.0) && (cos_a
< 0.0) ) {
809 angle
= acos(sin_a
) * RAD2DEG
+ 180;
814 void wxDC::DoDrawArc( wxCoord x1
, wxCoord y1
,
815 wxCoord x2
, wxCoord y2
,
816 wxCoord xc
, wxCoord yc
)
818 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawArc Invalid DC"));
819 wxMacPortSetter
helper(this) ;
821 wxCoord xx1
= XLOG2DEVMAC(x1
);
822 wxCoord yy1
= YLOG2DEVMAC(y1
);
823 wxCoord xx2
= XLOG2DEVMAC(x2
);
824 wxCoord yy2
= YLOG2DEVMAC(y2
);
825 wxCoord xxc
= XLOG2DEVMAC(xc
);
826 wxCoord yyc
= YLOG2DEVMAC(yc
);
827 double dx
= xx1
- xxc
;
828 double dy
= yy1
- yyc
;
829 double radius
= sqrt((double)(dx
*dx
+dy
*dy
));
830 wxCoord rad
= (wxCoord
)radius
;
831 double radius1
, radius2
;
833 if (xx1
== xx2
&& yy1
== yy2
)
838 else if (radius
== 0.0)
840 radius1
= radius2
= 0.0;
844 radius1
= (xx1
- xxc
== 0) ?
845 (yy1
- yyc
< 0) ? 90.0 : -90.0 :
846 -atan2(double(yy1
-yyc
), double(xx1
-xxc
)) * RAD2DEG
;
847 radius2
= (xx2
- xxc
== 0) ?
848 (yy2
- yyc
< 0) ? 90.0 : -90.0 :
849 -atan2(double(yy2
-yyc
), double(xx2
-xxc
)) * RAD2DEG
;
851 wxCoord alpha2
= wxCoord(radius2
- radius1
);
852 wxCoord alpha1
= wxCoord(wxConvertWXangleToMACangle(radius1
));
853 if( (xx1
> xx2
) || (yy1
> yy2
) ) {
857 Rect r
= { yyc
- rad
, xxc
- rad
, yyc
+ rad
, xxc
+ rad
};
859 if(m_brush
.GetStyle() != wxTRANSPARENT
) {
861 PaintArc(&r
, alpha1
, alpha2
);
863 if(m_pen
.GetStyle() != wxTRANSPARENT
) {
865 FrameArc(&r
, alpha1
, alpha2
);
869 void wxDC::DoDrawEllipticArc( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
870 double sa
, double ea
)
872 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawEllepticArc Invalid DC"));
873 wxMacPortSetter
helper(this) ;
876 double angle
= sa
- ea
; // Order important Mac in opposite direction to wx
878 wxCoord xx
= XLOG2DEVMAC(x
);
879 wxCoord yy
= YLOG2DEVMAC(y
);
880 wxCoord ww
= m_signX
* XLOG2DEVREL(w
);
881 wxCoord hh
= m_signY
* YLOG2DEVREL(h
);
883 // handle -ve width and/or height
884 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
885 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
887 sa
= wxConvertWXangleToMACangle(sa
);
894 if(m_brush
.GetStyle() != wxTRANSPARENT
) {
896 PaintArc(&r
, (short)sa
, (short)angle
);
898 if(m_pen
.GetStyle() != wxTRANSPARENT
) {
900 FrameArc(&r
, (short)sa
, (short)angle
);
904 void wxDC::DoDrawPoint( wxCoord x
, wxCoord y
)
906 wxCHECK_RET(Ok(), wxT("Invalid DC"));
908 wxMacPortSetter
helper(this) ;
910 if (m_pen
.GetStyle() != wxTRANSPARENT
)
912 wxCoord xx1
= XLOG2DEVMAC(x
);
913 wxCoord yy1
= YLOG2DEVMAC(y
);
914 RGBColor pencolor
= MAC_WXCOLORREF( m_pen
.GetColour().GetPixel());
915 ::SetCPixel( xx1
,yy1
,&pencolor
) ;
916 CalcBoundingBox(x
, y
);
920 void wxDC::DoDrawLines(int n
, wxPoint points
[],
921 wxCoord xoffset
, wxCoord yoffset
)
923 wxCHECK_RET(Ok(), wxT("Invalid DC"));
924 wxMacPortSetter
helper(this) ;
926 if (m_pen
.GetStyle() == wxTRANSPARENT
)
931 wxCoord offset
= ( (m_pen
.GetWidth() == 0 ? 1 :
932 m_pen
.GetWidth() ) * (wxCoord
)m_scaleX
- 1) / 2 ;
934 wxCoord x1
, x2
, y1
, y2
;
935 x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
936 y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
937 ::MoveTo(x1
- offset
, y1
- offset
);
939 for (int i
= 0; i
< n
-1; i
++)
941 x2
= XLOG2DEVMAC(points
[i
+1].x
+ xoffset
);
942 y2
= YLOG2DEVMAC(points
[i
+1].y
+ yoffset
);
943 ::LineTo( x2
- offset
, y2
- offset
);
947 void wxDC::DoDrawPolygon(int n
, wxPoint points
[],
948 wxCoord xoffset
, wxCoord yoffset
,
951 wxCHECK_RET(Ok(), wxT("Invalid DC"));
952 wxMacPortSetter
helper(this) ;
954 wxCoord x1
, x2
, y1
, y2
;
956 if ( m_brush
.GetStyle() == wxTRANSPARENT
&& m_pen
.GetStyle() == wxTRANSPARENT
)
959 PolyHandle polygon
= OpenPoly();
961 x2
= x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
962 y2
= y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
965 for (int i
= 1; i
< n
; i
++)
967 x2
= XLOG2DEVMAC(points
[i
].x
+ xoffset
);
968 y2
= YLOG2DEVMAC(points
[i
].y
+ yoffset
);
972 // close the polyline if necessary
973 if ( x1
!= x2
|| y1
!= y2
)
980 if (m_brush
.GetStyle() != wxTRANSPARENT
)
984 ::PaintPoly( polygon
);
988 if (m_pen
.GetStyle() != wxTRANSPARENT
)
992 ::FramePoly( polygon
) ;
998 void wxDC::DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1000 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1001 wxMacPortSetter
helper(this) ;
1003 wxCoord xx
= XLOG2DEVMAC(x
);
1004 wxCoord yy
= YLOG2DEVMAC(y
);
1005 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1006 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1008 // CMB: draw nothing if transformed w or h is 0
1009 if (ww
== 0 || hh
== 0)
1012 // CMB: handle -ve width and/or height
1025 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
1027 if (m_brush
.GetStyle() != wxTRANSPARENT
)
1030 ::PaintRect( &rect
) ;
1033 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1036 ::FrameRect( &rect
) ;
1040 void wxDC::DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
1041 wxCoord width
, wxCoord height
,
1044 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1045 wxMacPortSetter
helper(this) ;
1048 radius
= - radius
* ((width
< height
) ? width
: height
);
1050 wxCoord xx
= XLOG2DEVMAC(x
);
1051 wxCoord yy
= YLOG2DEVMAC(y
);
1052 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1053 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1055 // CMB: draw nothing if transformed w or h is 0
1056 if (ww
== 0 || hh
== 0)
1059 // CMB: handle -ve width and/or height
1072 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
1074 if (m_brush
.GetStyle() != wxTRANSPARENT
)
1077 ::PaintRoundRect( &rect
, int(radius
* 2) , int(radius
* 2) ) ;
1080 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1083 ::FrameRoundRect( &rect
, int(radius
* 2) , int(radius
* 2) ) ;
1087 void wxDC::DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1089 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1090 wxMacPortSetter
helper(this) ;
1092 wxCoord xx
= XLOG2DEVMAC(x
);
1093 wxCoord yy
= YLOG2DEVMAC(y
);
1094 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1095 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1097 // CMB: draw nothing if transformed w or h is 0
1098 if (ww
== 0 || hh
== 0)
1101 // CMB: handle -ve width and/or height
1114 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
1116 if (m_brush
.GetStyle() != wxTRANSPARENT
)
1119 ::PaintOval( &rect
) ;
1122 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1125 ::FrameOval( &rect
) ;
1131 bool wxDC::CanDrawBitmap(void) const
1137 bool wxDC::DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1138 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
, int logical_func
, bool useMask
,
1139 wxCoord xsrcMask
, wxCoord ysrcMask
)
1141 wxCHECK_MSG(Ok(), false, wxT("wxDC::DoBlit Illegal dc"));
1142 wxCHECK_MSG(source
->Ok(), false, wxT("wxDC::DoBlit Illegal source DC"));
1144 if ( logical_func
== wxNO_OP
)
1147 if (xsrcMask
== -1 && ysrcMask
== -1)
1149 xsrcMask
= xsrc
; ysrcMask
= ysrc
;
1152 // correct the parameter in case this dc does not have a mask at all
1154 if ( useMask
&& !source
->m_macMask
)
1157 Rect srcrect
, dstrect
;
1158 srcrect
.top
= source
->YLOG2DEVMAC(ysrc
) ;
1159 srcrect
.left
= source
->XLOG2DEVMAC(xsrc
) ;
1160 srcrect
.right
= source
->XLOG2DEVMAC(xsrc
+ width
) ;
1161 srcrect
.bottom
= source
->YLOG2DEVMAC(ysrc
+ height
) ;
1162 dstrect
.top
= YLOG2DEVMAC(ydest
) ;
1163 dstrect
.left
= XLOG2DEVMAC(xdest
) ;
1164 dstrect
.bottom
= YLOG2DEVMAC(ydest
+ height
) ;
1165 dstrect
.right
= XLOG2DEVMAC(xdest
+ width
) ;
1167 short mode
= kUnsupportedMode
;
1168 bool invertDestinationFirst
= false ;
1169 switch ( logical_func
)
1171 case wxAND
: // src AND dst
1172 mode
= srcOr
; // ok
1174 case wxAND_INVERT
: // (NOT src) AND dst
1175 mode
= notSrcOr
; // ok
1177 case wxAND_REVERSE
:// src AND (NOT dst)
1178 invertDestinationFirst
= true ;
1182 mode
= kEmulatedMode
;
1185 mode
= srcCopy
; // ok
1187 case wxEQUIV
: // (NOT src) XOR dst
1188 mode
= srcXor
; // ok
1190 case wxINVERT
: // NOT dst
1191 mode
= kEmulatedMode
; //or hilite ;
1193 case wxNAND
: // (NOT src) OR (NOT dst)
1194 invertDestinationFirst
= true ;
1197 case wxNOR
: // (NOT src) AND (NOT dst)
1198 invertDestinationFirst
= true ;
1201 case wxNO_OP
: // dst
1202 mode
= kEmulatedMode
; // this has already been handled upon entry
1204 case wxOR
: // src OR dst
1207 case wxOR_INVERT
: // (NOT src) OR dst
1210 case wxOR_REVERSE
: // src OR (NOT dst)
1211 invertDestinationFirst
= true ;
1215 mode
= kEmulatedMode
;
1217 case wxSRC_INVERT
: // (NOT src)
1218 mode
= notSrcCopy
; // ok
1220 case wxXOR
: // src XOR dst
1221 mode
= notSrcXor
; // ok
1229 if ( mode
== kUnsupportedMode
)
1231 wxFAIL_MSG("unsupported blitting mode" );
1235 CGrafPtr sourcePort
= (CGrafPtr
) source
->m_macPort
;
1236 PixMapHandle bmappixels
= GetGWorldPixMap( sourcePort
) ;
1237 if ( LockPixels(bmappixels
) )
1239 wxMacPortSetter
helper(this) ;
1241 if ( source
->GetDepth() == 1 )
1243 RGBForeColor( &MAC_WXCOLORREF(m_textForegroundColour
.GetPixel()) ) ;
1244 RGBBackColor( &MAC_WXCOLORREF(m_textBackgroundColour
.GetPixel()) ) ;
1248 // the modes need this, otherwise we'll end up having really nice colors...
1249 RGBColor white
= { 0xFFFF, 0xFFFF,0xFFFF} ;
1250 RGBColor black
= { 0,0,0} ;
1251 RGBForeColor( &black
) ;
1252 RGBBackColor( &white
) ;
1255 if ( useMask
&& source
->m_macMask
)
1257 if ( mode
== srcCopy
)
1259 if ( LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) )
1261 CopyMask( GetPortBitMapForCopyBits( sourcePort
) ,
1262 GetPortBitMapForCopyBits( MAC_WXHBITMAP(source
->m_macMask
) ) ,
1263 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1264 &srcrect
, &srcrect
, &dstrect
) ;
1265 UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1270 RgnHandle clipRgn
= NewRgn() ;
1271 LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1272 BitMapToRegion( clipRgn
, (BitMap
*) *GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1273 UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1274 OffsetRgn( clipRgn
, -srcrect
.left
+ dstrect
.left
, -srcrect
.top
+ dstrect
.top
) ;
1275 if ( mode
== kEmulatedMode
)
1278 ::PenPat(GetQDGlobalsBlack(&pat
));
1279 if ( logical_func
== wxSET
)
1281 RGBColor col
= { 0xFFFF, 0xFFFF, 0xFFFF } ;
1282 ::RGBForeColor( &col
) ;
1283 ::PaintRgn( clipRgn
) ;
1285 else if ( logical_func
== wxCLEAR
)
1287 RGBColor col
= { 0x0000, 0x0000, 0x0000 } ;
1288 ::RGBForeColor( &col
) ;
1289 ::PaintRgn( clipRgn
) ;
1291 else if ( logical_func
== wxINVERT
)
1293 MacInvertRgn( clipRgn
) ;
1297 for ( int y
= 0 ; y
< srcrect
.right
- srcrect
.left
; ++y
)
1299 for ( int x
= 0 ; x
< srcrect
.bottom
- srcrect
.top
; ++x
)
1301 Point dstPoint
= { dstrect
.top
+ y
, dstrect
.left
+ x
} ;
1302 Point srcPoint
= { srcrect
.top
+ y
, srcrect
.left
+ x
} ;
1303 if ( PtInRgn( dstPoint
, clipRgn
) )
1308 SetPort( (GrafPtr
) sourcePort
) ;
1309 GetCPixel( srcPoint
.h
, srcPoint
.v
, &srcColor
) ;
1310 SetPort( (GrafPtr
) m_macPort
) ;
1311 GetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1313 wxMacCalculateColour( logical_func
, srcColor
, dstColor
) ;
1314 SetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1322 if ( invertDestinationFirst
)
1324 MacInvertRgn( clipRgn
) ;
1326 CopyBits( GetPortBitMapForCopyBits( sourcePort
) ,
1327 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1328 &srcrect
, &dstrect
, mode
, clipRgn
) ;
1330 DisposeRgn( clipRgn
) ;
1335 RgnHandle clipRgn
= NewRgn() ;
1336 SetRectRgn( clipRgn
, dstrect
.left
, dstrect
.top
, dstrect
.right
, dstrect
.bottom
) ;
1337 if ( mode
== kEmulatedMode
)
1340 ::PenPat(GetQDGlobalsBlack(&pat
));
1341 if ( logical_func
== wxSET
)
1343 RGBColor col
= { 0xFFFF, 0xFFFF, 0xFFFF } ;
1344 ::RGBForeColor( &col
) ;
1345 ::PaintRgn( clipRgn
) ;
1347 else if ( logical_func
== wxCLEAR
)
1349 RGBColor col
= { 0x0000, 0x0000, 0x0000 } ;
1350 ::RGBForeColor( &col
) ;
1351 ::PaintRgn( clipRgn
) ;
1353 else if ( logical_func
== wxINVERT
)
1355 MacInvertRgn( clipRgn
) ;
1359 for ( int y
= 0 ; y
< srcrect
.right
- srcrect
.left
; ++y
)
1361 for ( int x
= 0 ; x
< srcrect
.bottom
- srcrect
.top
; ++x
)
1363 Point dstPoint
= { dstrect
.top
+ y
, dstrect
.left
+ x
} ;
1364 Point srcPoint
= { srcrect
.top
+ y
, srcrect
.left
+ x
} ;
1370 SetPort( (GrafPtr
) sourcePort
) ;
1371 GetCPixel( srcPoint
.h
, srcPoint
.v
, &srcColor
) ;
1372 SetPort( (GrafPtr
) m_macPort
) ;
1373 GetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1375 wxMacCalculateColour( logical_func
, srcColor
, dstColor
) ;
1376 SetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1385 if ( invertDestinationFirst
)
1387 MacInvertRgn( clipRgn
) ;
1389 CopyBits( GetPortBitMapForCopyBits( sourcePort
) ,
1390 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1391 &srcrect
, &dstrect
, mode
, NULL
) ;
1393 DisposeRgn( clipRgn
) ;
1395 UnlockPixels( bmappixels
) ;
1398 m_macPenInstalled
= false ;
1399 m_macBrushInstalled
= false ;
1400 m_macFontInstalled
= false ;
1405 inline Fixed
IntToFixed( int inInt
)
1407 return (((SInt32
) inInt
) << 16);
1411 void wxDC::DoDrawRotatedText(const wxString
& str
, wxCoord x
, wxCoord y
,
1414 wxCHECK_RET( Ok(), wxT("wxDC::DoDrawRotatedText Invalid window dc") );
1418 DrawText(str
, x
, y
);
1422 if ( str
.Length() == 0 )
1425 wxMacPortSetter
helper(this) ;
1429 if ( wxApp::s_macDefaultEncodingIsPC
)
1431 text
= wxMacMakeMacStringFromPC( str
) ;
1438 wxFontRefData
* font
= (wxFontRefData
*) m_font
.GetRefData() ;
1441 m_macFormerAliasState
= IsAntiAliasedTextEnabled(&m_macFormerAliasSize
);
1442 SetAntiAliasedTextEnabled(true, SInt16(m_scaleY
* font
->m_macFontSize
));
1443 m_macAliasWasEnabled
= true ;
1446 OSStatus status
= noErr
;
1449 status
= TECCreateConverter(&ec
, kTextEncodingMacRoman
, kTextEncodingUnicodeDefault
);
1450 wxASSERT_MSG( status
== noErr
, "couldn't start converter" ) ;
1452 ByteCount byteOutLen
;
1453 ByteCount byteInLen
= text
.Length() ;
1454 ByteCount byteBufferLen
= byteInLen
*2 ;
1455 char* buf
= new char[byteBufferLen
] ;
1457 status
= TECConvertText(ec
, (ConstTextPtr
)text
.c_str() , byteInLen
, &byteInLen
,
1458 (TextPtr
)buf
, byteBufferLen
, &byteOutLen
);
1460 wxASSERT_MSG( status
== noErr
, "couldn't convert text" ) ;
1461 status
= TECDisposeConverter(ec
);
1462 wxASSERT_MSG( status
== noErr
, "couldn't dispose converter" ) ;
1464 ATSUTextLayout atsuLayout
;
1465 UniCharCount chars
= byteOutLen
/ 2 ;
1466 status
= ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr
) buf
, 0 , byteOutLen
/ 2 , byteOutLen
/ 2 , 1 ,
1467 &chars
, (ATSUStyle
*) &m_macATSUIStyle
, &atsuLayout
) ;
1468 wxASSERT_MSG( status
== noErr
, "couldn't create the layout of the rotated text" );
1470 int iAngle
= int( angle
);
1471 if ( abs(iAngle
) > 0 )
1473 Fixed atsuAngle
= IntToFixed( iAngle
) ;
1474 ByteCount angleSize
= sizeof(Fixed
) ;
1475 ATSUAttributeTag rotationTag
= kATSULineRotationTag
;
1476 ATSUAttributeValuePtr angleValue
= &atsuAngle
;
1477 status
= ::ATSUSetLayoutControls(atsuLayout
, 1 , &rotationTag
, &angleSize
, &angleValue
) ;
1480 status
= ::ATSUDrawText( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1481 IntToFixed(XLOG2DEVMAC(x
) ) , IntToFixed(YLOG2DEVMAC(y
) ) );
1482 wxASSERT_MSG( status
== noErr
, "couldn't draw the rotated text" );
1484 status
= ::ATSUMeasureTextImage( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1485 IntToFixed(XLOG2DEVMAC(x
) ) , IntToFixed(YLOG2DEVMAC(y
) ) , &rect
);
1486 wxASSERT_MSG( status
== noErr
, "couldn't measure the rotated text" );
1488 OffsetRect( &rect
, -m_macLocalOrigin
.x
, -m_macLocalOrigin
.y
) ;
1489 CalcBoundingBox(XDEV2LOG(rect
.left
), YDEV2LOG(rect
.top
) );
1490 CalcBoundingBox(XDEV2LOG(rect
.right
), YDEV2LOG(rect
.bottom
) );
1491 ::ATSUDisposeTextLayout(atsuLayout
);
1495 void wxDC::DoDrawText(const wxString
& strtext
, wxCoord x
, wxCoord y
)
1497 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawText Invalid DC"));
1498 wxMacPortSetter
helper(this) ;
1500 long xx
= XLOG2DEVMAC(x
);
1501 long yy
= YLOG2DEVMAC(y
);
1503 bool useDrawThemeText
= ( DrawThemeTextBox
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1504 useDrawThemeText
= false ;
1509 m_macFormerAliasState
= IsAntiAliasedTextEnabled(&m_macFormerAliasSize
);
1510 SetAntiAliasedTextEnabled(true, 8);
1511 m_macAliasWasEnabled
= true ;
1515 ::GetFontInfo( &fi
) ;
1518 if ( !useDrawThemeText
)
1522 ::MoveTo( xx
, yy
);
1523 if ( m_backgroundMode
== wxTRANSPARENT
)
1525 ::TextMode( srcOr
) ;
1529 ::TextMode( srcCopy
) ;
1532 const char *text
= NULL
;
1536 if ( wxApp::s_macDefaultEncodingIsPC
)
1538 macText
= wxMacMakeMacStringFromPC( strtext
) ;
1540 length
= macText
.Length() ;
1545 length
= strtext
.Length() ;
1556 if( text
[i
] == 13 || text
[i
] == 10)
1559 if ( useDrawThemeText
)
1561 Rect frame
= { yy
+ line
*(fi
.descent
+ fi
.ascent
+ fi
.leading
) ,xx
, yy
+ (line
+1)*(fi
.descent
+ fi
.ascent
+ fi
.leading
) , xx
+ 1000 } ;
1562 CFStringRef mString
= CFStringCreateWithBytes( NULL
, (UInt8
*) text
+ laststop
, i
- laststop
, CFStringGetSystemEncoding(), false ) ;
1563 ::DrawThemeTextBox( mString
,
1564 kThemeCurrentPortFont
,
1570 CFRelease( mString
) ;
1576 ::DrawText( text
, laststop
, i
- laststop
) ;
1578 ::MoveTo( xx
, yy
+ line
*(fi
.descent
+ fi
.ascent
+ fi
.leading
) );
1585 if ( useDrawThemeText
)
1587 Rect frame
= { yy
+ line
*(fi
.descent
+ fi
.ascent
+ fi
.leading
) ,xx
, yy
+ (line
+1)*(fi
.descent
+ fi
.ascent
+ fi
.leading
) , xx
+ 1000 } ;
1588 CFStringRef mString
= CFStringCreateWithCString( NULL
, text
+ laststop
, kCFStringEncodingMacRoman
) ;
1589 ::DrawThemeTextBox( mString
,
1590 kThemeCurrentPortFont
,
1596 CFRelease( mString
) ;
1601 ::DrawText( text
, laststop
, i
- laststop
) ;
1604 ::TextMode( srcOr
) ;
1607 bool wxDC::CanGetTextExtent() const
1609 wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
1614 void wxDC::DoGetTextExtent( const wxString
&string
, wxCoord
*width
, wxCoord
*height
,
1615 wxCoord
*descent
, wxCoord
*externalLeading
,
1616 wxFont
*theFont
) const
1618 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1619 wxMacPortSetter
helper(this) ;
1621 wxFont formerFont
= m_font
;
1625 // work around the constness
1626 *((wxFont
*)(&m_font
)) = *theFont
;
1632 ::GetFontInfo( &fi
) ;
1634 bool useGetThemeText
= ( GetThemeTextDimensions
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1635 useGetThemeText
= false ;
1639 *height
= YDEV2LOGREL( fi
.descent
+ fi
.ascent
) ;
1641 *descent
=YDEV2LOGREL( fi
.descent
);
1642 if ( externalLeading
)
1643 *externalLeading
= YDEV2LOGREL( fi
.leading
) ;
1645 const char *text
= NULL
;
1648 if ( wxApp::s_macDefaultEncodingIsPC
)
1650 macText
= wxMacMakeMacStringFromPC( string
) ;
1652 length
= macText
.Length() ;
1657 length
= string
.Length() ;
1669 if( text
[i
] == 13 || text
[i
] == 10)
1672 *height
+= YDEV2LOGREL( fi
.descent
+ fi
.ascent
+ fi
.leading
) ;
1674 if ( useGetThemeText
)
1676 Point bounds
={0,0} ;
1678 CFStringRef mString
= CFStringCreateWithBytes( NULL
, (UInt8
*) text
+ laststop
, i
- laststop
, CFStringGetSystemEncoding(), false ) ;
1679 ::GetThemeTextDimensions( mString
,
1680 kThemeCurrentPortFont
,
1685 CFRelease( mString
) ;
1686 curwidth
= bounds
.h
;
1691 curwidth
= ::TextWidth( text
, laststop
, i
- laststop
) ;
1693 if ( curwidth
> *width
)
1694 *width
= XDEV2LOGREL( curwidth
) ;
1701 if ( useGetThemeText
)
1703 Point bounds
={0,0} ;
1705 CFStringRef mString
= CFStringCreateWithBytes( NULL
, (UInt8
*) text
+ laststop
, i
- laststop
, CFStringGetSystemEncoding(), false ) ;
1706 ::GetThemeTextDimensions( mString
,
1707 kThemeCurrentPortFont
,
1712 CFRelease( mString
) ;
1713 curwidth
= bounds
.h
;
1718 curwidth
= ::TextWidth( text
, laststop
, i
- laststop
) ;
1720 if ( curwidth
> *width
)
1721 *width
= XDEV2LOGREL( curwidth
) ;
1726 // work around the constness
1727 *((wxFont
*)(&m_font
)) = formerFont
;
1728 m_macFontInstalled
= false ;
1732 wxCoord
wxDC::GetCharWidth(void) const
1734 wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
1736 wxMacPortSetter
helper(this) ;
1740 int width
= ::TextWidth( "n" , 0 , 1 ) ;
1742 return YDEV2LOGREL(width
) ;
1745 wxCoord
wxDC::GetCharHeight(void) const
1747 wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
1749 wxMacPortSetter
helper(this) ;
1754 ::GetFontInfo( &fi
) ;
1756 return YDEV2LOGREL( fi
.descent
+ fi
.ascent
);
1759 void wxDC::Clear(void)
1761 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1762 wxMacPortSetter
helper(this) ;
1763 Rect rect
= { -31000 , -31000 , 31000 , 31000 } ;
1765 if (m_backgroundBrush
.GetStyle() != wxTRANSPARENT
)
1768 //MacInstallBrush() ;
1769 MacSetupBackgroundForCurrentPort( m_backgroundBrush
) ;
1770 ::EraseRect( &rect
) ;
1774 void wxDC::MacInstallFont() const
1776 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1777 // if ( m_macFontInstalled )
1779 Pattern blackColor
;
1781 MacSetupBackgroundForCurrentPort(m_backgroundBrush
) ;
1783 wxFontRefData
* font
= (wxFontRefData
*) m_font
.GetRefData() ;
1787 ::TextFont( font
->m_macFontNum
) ;
1788 ::TextSize( short(m_scaleY
* font
->m_macFontSize
) ) ;
1789 ::TextFace( font
->m_macFontStyle
) ;
1791 m_macFontInstalled
= true ;
1792 m_macBrushInstalled
= false ;
1793 m_macPenInstalled
= false ;
1795 RGBColor forecolor
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel());
1796 RGBColor backcolor
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel());
1797 ::RGBForeColor( &forecolor
);
1798 ::RGBBackColor( &backcolor
);
1802 FontFamilyID fontId
;
1806 GetThemeFont(kThemeSmallSystemFont
, GetApplicationScript() , fontName
, &fontSize
, &fontStyle
) ;
1807 GetFNum( fontName
, &fontId
);
1809 ::TextFont( fontId
) ;
1810 ::TextSize( short(m_scaleY
* fontSize
) ) ;
1811 ::TextFace( fontStyle
) ;
1813 // todo reset after spacing changes - or store the current spacing somewhere
1815 m_macFontInstalled
= true ;
1816 m_macBrushInstalled
= false ;
1817 m_macPenInstalled
= false ;
1819 RGBColor forecolor
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel());
1820 RGBColor backcolor
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel());
1821 ::RGBForeColor( &forecolor
);
1822 ::RGBBackColor( &backcolor
);
1825 short mode
= patCopy
;
1829 switch( m_logicalFunction
)
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)
1851 case wxAND_REVERSE
:// src AND (NOT dst)
1852 case wxAND
: // src AND dst
1853 case wxAND_INVERT
: // (NOT src) AND dst
1854 case wxNO_OP
: // dst
1855 case wxNOR
: // (NOT src) AND (NOT dst)
1856 case wxEQUIV
: // (NOT src) XOR dst
1857 case wxOR_INVERT
: // (NOT src) OR dst
1858 case wxNAND
: // (NOT src) OR (NOT dst)
1859 case wxOR
: // src OR dst
1861 // case wxSRC_OR: // source _bitmap_ OR destination
1862 // case wxSRC_AND: // source _bitmap_ AND destination
1867 OSStatus status
= noErr
;
1869 Fixed atsuSize
= IntToFixed( int(m_scaleY
* font
->m_macFontSize
) ) ;
1871 Style qdStyle
= font
->m_macFontStyle
;
1872 ATSUFontID atsuFont
= font
->m_macATSUFontID
;
1874 status
= ::ATSUCreateStyle(&(ATSUStyle
)m_macATSUIStyle
) ;
1875 wxASSERT_MSG( status
== noErr
, "couldn't create ATSU style" ) ;
1877 ATSUAttributeTag atsuTags
[] =
1882 kATSUBaselineClassTag
,
1883 kATSUVerticalCharacterTag
,
1885 kATSUQDBoldfaceTag
,
1887 kATSUQDUnderlineTag
,
1888 kATSUQDCondensedTag
,
1889 kATSUQDExtendedTag
,
1893 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1895 sizeof( ATSUFontID
) ,
1897 // sizeof( RGBColor ) ,
1898 sizeof( BslnBaselineClass
) ,
1899 sizeof( ATSUVerticalCharacterType
),
1909 Boolean kTrue
= true ;
1910 Boolean kFalse
= false ;
1911 BslnBaselineClass kBaselineDefault
= kBSLNHangingBaseline
;
1913 ATSUVerticalCharacterType kHorizontal
= kATSUStronglyHorizontal
;
1915 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1919 // &MAC_WXCOLORREF( m_textForegroundColour.GetPixel() ) ,
1923 (qdStyle
& bold
) ? &kTrue
: &kFalse
,
1924 (qdStyle
& italic
) ? &kTrue
: &kFalse
,
1925 (qdStyle
& underline
) ? &kTrue
: &kFalse
,
1926 (qdStyle
& condense
) ? &kTrue
: &kFalse
,
1927 (qdStyle
& extend
) ? &kTrue
: &kFalse
,
1930 status
= ::ATSUSetAttributes((ATSUStyle
)m_macATSUIStyle
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
),
1931 atsuTags
, atsuSizes
, atsuValues
);
1932 wxASSERT_MSG( status
== noErr
, "couldn't set create ATSU style" ) ;
1936 Pattern gHatchPatterns
[] =
1938 { { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF } },
1939 { { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 } },
1940 { { 0x80 , 0x40 , 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , 0x01 } },
1941 { { 0x10 , 0x10 , 0x10 , 0xFF , 0x10 , 0x10 , 0x10 , 0x10 } },
1942 { { 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 } },
1943 { { 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 } },
1944 { { 0x81 , 0x42 , 0x24 , 0x18 , 0x18 , 0x24 , 0x42 , 0x81 } }
1947 static void wxMacGetHatchPattern(int hatchStyle
, Pattern
*pattern
)
1953 case wxBDIAGONAL_HATCH
:
1956 case wxFDIAGONAL_HATCH
:
1962 case wxHORIZONTAL_HATCH
:
1965 case wxVERTICAL_HATCH
:
1968 case wxCROSSDIAG_HATCH
:
1972 theIndex
= 1; // solid pattern
1975 *pattern
= gHatchPatterns
[theIndex
-1] ;
1978 void wxDC::MacInstallPen() const
1980 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1984 // if ( m_macPenInstalled )
1987 RGBColor forecolor
= MAC_WXCOLORREF( m_pen
.GetColour().GetPixel());
1988 RGBColor backcolor
= MAC_WXCOLORREF( m_backgroundBrush
.GetColour().GetPixel());
1989 ::RGBForeColor( &forecolor
);
1990 ::RGBBackColor( &backcolor
);
1993 int penWidth
= m_pen
.GetWidth() * (int) m_scaleX
;
1995 // null means only one pixel, at whatever resolution
1996 if ( penWidth
== 0 )
1998 ::PenSize(penWidth
, penWidth
);
2000 int penStyle
= m_pen
.GetStyle();
2002 if (penStyle
== wxSOLID
)
2004 ::PenPat(GetQDGlobalsBlack(&blackColor
));
2006 else if (IS_HATCH(penStyle
))
2009 wxMacGetHatchPattern(penStyle
, &pat
);
2014 Pattern pat
= *GetQDGlobalsBlack(&blackColor
) ;
2018 for ( int i
= 0 ; i
< 8 ; ++i
)
2024 for ( int i
= 0 ; i
< 8 ; ++i
)
2030 for ( int i
= 0 ; i
< 8 ; ++i
)
2036 for ( int i
= 0 ; i
< 8 ; ++i
)
2044 m_pen
.GetDashes(&dash
) ;
2046 // right now we don't allocate larger pixmaps
2048 m_pen
.GetDashes(&dash
) ;
2049 for ( int i
= 0 ; i
< 8 ; ++i
)
2051 pat
.pat
[i
] = dash
[0] ;
2059 short mode
= patCopy
;
2063 switch( m_logicalFunction
)
2065 case wxCOPY
: // only foreground color, leave background (thus not patCopy)
2068 case wxINVERT
: // NOT dst
2069 // ::PenPat(GetQDGlobalsBlack(&blackColor));
2072 case wxXOR
: // src XOR dst
2075 case wxOR_REVERSE
: // src OR (NOT dst)
2078 case wxSRC_INVERT
: // (NOT src)
2085 case wxAND_REVERSE
:// src AND (NOT dst)
2086 case wxAND
: // src AND dst
2087 case wxAND_INVERT
: // (NOT src) AND dst
2088 case wxNO_OP
: // dst
2089 case wxNOR
: // (NOT src) AND (NOT dst)
2090 case wxEQUIV
: // (NOT src) XOR dst
2091 case wxOR_INVERT
: // (NOT src) OR dst
2092 case wxNAND
: // (NOT src) OR (NOT dst)
2093 case wxOR
: // src OR dst
2095 // case wxSRC_OR: // source _bitmap_ OR destination
2096 // case wxSRC_AND: // source _bitmap_ AND destination
2100 m_macPenInstalled
= true ;
2101 m_macBrushInstalled
= false ;
2102 m_macFontInstalled
= false ;
2105 void wxDC::MacSetupBackgroundForCurrentPort(const wxBrush
& background
)
2107 Pattern whiteColor
;
2108 switch( background
.MacGetBrushKind() )
2110 case kwxMacBrushTheme
:
2112 ::SetThemeBackground( background
.GetMacTheme() , wxDisplayDepth() , true ) ;
2115 case kwxMacBrushThemeBackground
:
2118 ThemeBackgroundKind bg
= background
.GetMacThemeBackground( &extent
) ;
2119 ::ApplyThemeBackground( bg
, &extent
,kThemeStateActive
, wxDisplayDepth() , true ) ;
2122 case kwxMacBrushColour
:
2124 ::RGBBackColor( &MAC_WXCOLORREF( background
.GetColour().GetPixel()) );
2125 int brushStyle
= background
.GetStyle();
2126 if (brushStyle
== wxSOLID
)
2127 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
2128 else if (IS_HATCH(brushStyle
))
2131 wxMacGetHatchPattern(brushStyle
, &pat
);
2136 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
2143 void wxDC::MacInstallBrush() const
2145 wxCHECK_RET(Ok(), wxT("Invalid DC"));
2147 Pattern blackColor
;
2148 // if ( m_macBrushInstalled )
2153 bool backgroundTransparent
= (GetBackgroundMode() == wxTRANSPARENT
) ;
2155 ::RGBForeColor( &MAC_WXCOLORREF( m_brush
.GetColour().GetPixel()) );
2156 ::RGBBackColor( &MAC_WXCOLORREF( m_backgroundBrush
.GetColour().GetPixel()) );
2158 int brushStyle
= m_brush
.GetStyle();
2159 if (brushStyle
== wxSOLID
)
2161 ::PenPat(GetQDGlobalsBlack(&blackColor
));
2163 else if (IS_HATCH(brushStyle
))
2166 wxMacGetHatchPattern(brushStyle
, &pat
);
2169 else if ( m_brush
.GetStyle() == wxSTIPPLE
|| m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
)
2171 // we force this in order to be compliant with wxMSW
2172 backgroundTransparent
= false ;
2173 // for these the text fore (and back for MASK_OPAQUE) colors are used
2174 wxBitmap
* bitmap
= m_brush
.GetStipple() ;
2175 int width
= bitmap
->GetWidth() ;
2176 int height
= bitmap
->GetHeight() ;
2177 GWorldPtr gw
= NULL
;
2179 if ( m_brush
.GetStyle() == wxSTIPPLE
)
2180 gw
= MAC_WXHBITMAP(bitmap
->GetHBITMAP()) ;
2182 gw
= MAC_WXHBITMAP(bitmap
->GetMask()->GetMaskBitmap()) ;
2184 PixMapHandle gwpixmaphandle
= GetGWorldPixMap( gw
) ;
2185 LockPixels( gwpixmaphandle
) ;
2187 bool isMonochrome
= !IsPortColor( gw
) ;
2189 if ( !isMonochrome
)
2191 if ( (**gwpixmaphandle
).pixelSize
== 1 )
2192 isMonochrome
= true ;
2195 if ( isMonochrome
&& width
== 8 && height
== 8 )
2197 ::RGBForeColor( &MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) );
2198 ::RGBForeColor( &MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) );
2199 BitMap
* gwbitmap
= (BitMap
*) *gwpixmaphandle
; // since the color depth is 1 it is a BitMap
2200 UInt8
*gwbits
= (UInt8
*) gwbitmap
->baseAddr
;
2201 int alignment
= gwbitmap
->rowBytes
& 0x7FFF ;
2203 for ( int i
= 0 ; i
< 8 ; ++i
)
2205 pat
.pat
[i
] = gwbits
[i
*alignment
+0] ;
2207 UnlockPixels( GetGWorldPixMap( gw
) ) ;
2212 // this will be the code to handle power of 2 patterns, we will have to arrive at a nice
2213 // caching scheme before putting this into production
2216 PixPatHandle pixpat
= NewPixPat() ;
2218 CopyPixMap(gwpixmaphandle
, (**pixpat
).patMap
);
2219 imageSize
= GetPixRowBytes((**pixpat
).patMap
) *
2220 ((**(**pixpat
).patMap
).bounds
.bottom
-
2221 (**(**pixpat
).patMap
).bounds
.top
);
2223 PtrToHand( (**gwpixmaphandle
).baseAddr
, &image
, imageSize
);
2224 (**pixpat
).patData
= image
;
2227 CTabHandle ctable
= ((**((**pixpat
).patMap
)).pmTable
) ;
2228 ColorSpecPtr ctspec
= (ColorSpecPtr
) &(**ctable
).ctTable
;
2229 if ( ctspec
[0].rgb
.red
== 0x0000 )
2231 ctspec
[1].rgb
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) ;
2232 ctspec
[0].rgb
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) ;
2236 ctspec
[0].rgb
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) ;
2237 ctspec
[1].rgb
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) ;
2239 ::CTabChanged( ctable
) ;
2241 ::PenPixPat(pixpat
);
2242 m_macForegroundPixMap
= pixpat
;
2244 UnlockPixels( gwpixmaphandle
) ;
2248 ::PenPat(GetQDGlobalsBlack(&blackColor
));
2251 short mode
= patCopy
;
2252 switch( m_logicalFunction
)
2255 if ( backgroundTransparent
)
2260 case wxINVERT
: // NOT dst
2261 if ( !backgroundTransparent
)
2263 ::PenPat(GetQDGlobalsBlack(&blackColor
));
2267 case wxXOR
: // src XOR dst
2270 case wxOR_REVERSE
: // src OR (NOT dst)
2273 case wxSRC_INVERT
: // (NOT src)
2280 case wxAND_REVERSE
:// src AND (NOT dst)
2281 case wxAND
: // src AND dst
2282 case wxAND_INVERT
: // (NOT src) AND dst
2283 case wxNO_OP
: // dst
2284 case wxNOR
: // (NOT src) AND (NOT dst)
2285 case wxEQUIV
: // (NOT src) XOR dst
2286 case wxOR_INVERT
: // (NOT src) OR dst
2287 case wxNAND
: // (NOT src) OR (NOT dst)
2288 case wxOR
: // src OR dst
2290 // case wxSRC_OR: // source _bitmap_ OR destination
2291 // case wxSRC_AND: // source _bitmap_ AND destination
2295 m_macBrushInstalled
= true ;
2296 m_macPenInstalled
= false ;
2297 m_macFontInstalled
= false ;
2300 // ---------------------------------------------------------------------------
2301 // coordinates transformations
2302 // ---------------------------------------------------------------------------
2305 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
2307 return ((wxDC
*)this)->XDEV2LOG(x
);
2310 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
2312 return ((wxDC
*)this)->YDEV2LOG(y
);
2315 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
2317 return ((wxDC
*)this)->XDEV2LOGREL(x
);
2320 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
2322 return ((wxDC
*)this)->YDEV2LOGREL(y
);
2325 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
2327 return ((wxDC
*)this)->XLOG2DEV(x
);
2330 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
2332 return ((wxDC
*)this)->YLOG2DEV(y
);
2335 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
2337 return ((wxDC
*)this)->XLOG2DEVREL(x
);
2340 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
2342 return ((wxDC
*)this)->YLOG2DEVREL(y
);