1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "dc.h"
16 #include "wx/wxprec.h"
20 #include "wx/mac/uma.h"
21 #include "wx/dcmemory.h"
22 #include "wx/dcprint.h"
23 #include "wx/region.h"
32 #include "wx/mac/private.h"
33 #include <ATSUnicode.h>
34 #include <TextCommon.h>
35 #include <TextEncodingConverter.h>
36 #if !USE_SHARED_LIBRARY
37 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxObject
)
40 //-----------------------------------------------------------------------------
42 //-----------------------------------------------------------------------------
44 const double RAD2DEG
= 180.0 / M_PI
;
45 const short kEmulatedMode
= -1 ;
46 const short kUnsupportedMode
= -2 ;
48 extern TECObjectRef s_TECNativeCToUnicode
;
50 // set to 0 if problems arise
51 #define wxMAC_EXPERIMENTAL_DC 1
53 wxMacPortSetter::wxMacPortSetter( const wxDC
* dc
) :
54 m_ph( (GrafPtr
) dc
->m_macPort
)
56 wxASSERT( dc
->Ok() ) ;
58 dc
->MacSetupPort(&m_ph
) ;
60 wxMacPortSetter::~wxMacPortSetter()
62 m_dc
->MacCleanupPort(&m_ph
) ;
65 #if wxMAC_EXPERIMENTAL_DC
66 class wxMacFastPortSetter
69 wxMacFastPortSetter( const wxDC
*dc
)
71 wxASSERT( dc
->Ok() ) ;
72 m_swapped
= QDSwapPort( (GrafPtr
) dc
->m_macPort
, &m_oldPort
) ;
73 m_clipRgn
= NewRgn() ;
74 GetClip( m_clipRgn
) ;
76 dc
->MacSetupPort( NULL
) ;
78 ~wxMacFastPortSetter()
80 // SetPort( (GrafPtr) m_dc->m_macPort ) ;
81 SetClip( m_clipRgn
) ;
83 SetPort( m_oldPort
) ;
84 m_dc
->MacCleanupPort( NULL
) ;
85 DisposeRgn( m_clipRgn
) ;
95 typedef wxMacPortSetter wxMacFastPortSetter
;
98 wxMacWindowClipper::wxMacWindowClipper( const wxWindow
* win
) :
99 wxMacPortSaver( (GrafPtr
) GetWindowPort((WindowRef
) win
->MacGetTopLevelWindowRef()) )
101 m_newPort
=(GrafPtr
) GetWindowPort((WindowRef
) win
->MacGetTopLevelWindowRef()) ;
102 m_formerClip
= NewRgn() ;
103 m_newClip
= NewRgn() ;
104 GetClip( m_formerClip
) ;
109 win
->MacWindowToRootWindow( &x
,&y
) ;
110 // get area including focus rect
111 CopyRgn( (RgnHandle
) ((wxWindow
*)win
)->MacGetVisibleRegion(true).GetWXHRGN() , m_newClip
) ;
112 if ( !EmptyRgn( m_newClip
) )
113 OffsetRgn( m_newClip
, x
, y
) ;
115 SetClip( m_newClip
) ;
119 wxMacWindowClipper::~wxMacWindowClipper()
121 SetPort( m_newPort
) ;
122 SetClip( m_formerClip
) ;
123 DisposeRgn( m_newClip
) ;
124 DisposeRgn( m_formerClip
) ;
127 wxMacWindowStateSaver::wxMacWindowStateSaver( const wxWindow
* win
) :
128 wxMacWindowClipper( win
)
130 // the port is already set at this point
131 m_newPort
=(GrafPtr
) GetWindowPort((WindowRef
) win
->MacGetTopLevelWindowRef()) ;
132 GetThemeDrawingState( &m_themeDrawingState
) ;
135 wxMacWindowStateSaver::~wxMacWindowStateSaver()
137 SetPort( m_newPort
) ;
138 SetThemeDrawingState( m_themeDrawingState
, true ) ;
141 //-----------------------------------------------------------------------------
143 //-----------------------------------------------------------------------------
144 static inline double dmin(double a
, double b
) { return a
< b
? a
: b
; }
145 static inline double dmax(double a
, double b
) { return a
> b
? a
: b
; }
146 static inline double DegToRad(double deg
) { return (deg
* M_PI
) / 180.0; }
148 //-----------------------------------------------------------------------------
150 //-----------------------------------------------------------------------------
151 // this function emulates all wx colour manipulations, used to verify the implementation
152 // by setting the mode in the blitting functions to kEmulatedMode
153 void wxMacCalculateColour( int logical_func
, const RGBColor
&srcColor
, RGBColor
&dstColor
) ;
155 void wxMacCalculateColour( int logical_func
, const RGBColor
&srcColor
, RGBColor
&dstColor
)
157 switch ( logical_func
)
159 case wxAND
: // src AND dst
160 dstColor
.red
= dstColor
.red
& srcColor
.red
;
161 dstColor
.green
= dstColor
.green
& srcColor
.green
;
162 dstColor
.blue
= dstColor
.blue
& srcColor
.blue
;
164 case wxAND_INVERT
: // (NOT src) AND dst
165 dstColor
.red
= dstColor
.red
& ~srcColor
.red
;
166 dstColor
.green
= dstColor
.green
& ~srcColor
.green
;
167 dstColor
.blue
= dstColor
.blue
& ~srcColor
.blue
;
169 case wxAND_REVERSE
:// src AND (NOT dst)
170 dstColor
.red
= ~dstColor
.red
& srcColor
.red
;
171 dstColor
.green
= ~dstColor
.green
& srcColor
.green
;
172 dstColor
.blue
= ~dstColor
.blue
& srcColor
.blue
;
180 dstColor
.red
= srcColor
.red
;
181 dstColor
.green
= srcColor
.green
;
182 dstColor
.blue
= srcColor
.blue
;
184 case wxEQUIV
: // (NOT src) XOR dst
185 dstColor
.red
= dstColor
.red
^ ~srcColor
.red
;
186 dstColor
.green
= dstColor
.green
^ ~srcColor
.green
;
187 dstColor
.blue
= dstColor
.blue
^ ~srcColor
.blue
;
189 case wxINVERT
: // NOT dst
190 dstColor
.red
= ~dstColor
.red
;
191 dstColor
.green
= ~dstColor
.green
;
192 dstColor
.blue
= ~dstColor
.blue
;
194 case wxNAND
: // (NOT src) OR (NOT dst)
195 dstColor
.red
= ~dstColor
.red
| ~srcColor
.red
;
196 dstColor
.green
= ~dstColor
.green
| ~srcColor
.green
;
197 dstColor
.blue
= ~dstColor
.blue
| ~srcColor
.blue
;
199 case wxNOR
: // (NOT src) AND (NOT dst)
200 dstColor
.red
= ~dstColor
.red
& ~srcColor
.red
;
201 dstColor
.green
= ~dstColor
.green
& ~srcColor
.green
;
202 dstColor
.blue
= ~dstColor
.blue
& ~srcColor
.blue
;
206 case wxOR
: // src OR dst
207 dstColor
.red
= dstColor
.red
| srcColor
.red
;
208 dstColor
.green
= dstColor
.green
| srcColor
.green
;
209 dstColor
.blue
= dstColor
.blue
| srcColor
.blue
;
211 case wxOR_INVERT
: // (NOT src) OR dst
212 dstColor
.red
= dstColor
.red
| ~srcColor
.red
;
213 dstColor
.green
= dstColor
.green
| ~srcColor
.green
;
214 dstColor
.blue
= dstColor
.blue
| ~srcColor
.blue
;
216 case wxOR_REVERSE
: // src OR (NOT dst)
217 dstColor
.red
= ~dstColor
.red
| srcColor
.red
;
218 dstColor
.green
= ~dstColor
.green
| srcColor
.green
;
219 dstColor
.blue
= ~dstColor
.blue
| srcColor
.blue
;
222 dstColor
.red
= 0xFFFF ;
223 dstColor
.green
= 0xFFFF ;
224 dstColor
.blue
= 0xFFFF ;
226 case wxSRC_INVERT
: // (NOT src)
227 dstColor
.red
= ~srcColor
.red
;
228 dstColor
.green
= ~srcColor
.green
;
229 dstColor
.blue
= ~srcColor
.blue
;
231 case wxXOR
: // src XOR dst
232 dstColor
.red
= dstColor
.red
^ srcColor
.red
;
233 dstColor
.green
= dstColor
.green
^ srcColor
.green
;
234 dstColor
.blue
= dstColor
.blue
^ srcColor
.blue
;
243 m_mm_to_pix_x
= mm2pt
;
244 m_mm_to_pix_y
= mm2pt
;
245 m_internalDeviceOriginX
= 0;
246 m_internalDeviceOriginY
= 0;
247 m_externalDeviceOriginX
= 0;
248 m_externalDeviceOriginY
= 0;
249 m_logicalScaleX
= 1.0;
250 m_logicalScaleY
= 1.0;
255 m_needComputeScaleX
= false;
256 m_needComputeScaleY
= false;
260 m_macFontInstalled
= false ;
261 m_macBrushInstalled
= false ;
262 m_macPenInstalled
= false ;
263 m_macLocalOrigin
.x
= m_macLocalOrigin
.y
= 0 ;
264 m_macBoundaryClipRgn
= NewRgn() ;
265 m_macCurrentClipRgn
= NewRgn() ;
266 SetRectRgn( (RgnHandle
) m_macBoundaryClipRgn
, -32000 , -32000 , 32000 , 32000 ) ;
267 SetRectRgn( (RgnHandle
) m_macCurrentClipRgn
, -32000 , -32000 , 32000 , 32000 ) ;
268 m_pen
= *wxBLACK_PEN
;
269 m_font
= *wxNORMAL_FONT
;
270 m_brush
= *wxWHITE_BRUSH
;
272 // needed to debug possible errors with two active drawing methods at the same time on
274 m_macCurrentPortStateHelper
= NULL
;
276 m_macATSUIStyle
= NULL
;
277 m_macAliasWasEnabled
= false;
278 m_macForegroundPixMap
= NULL
;
279 m_macBackgroundPixMap
= NULL
;
284 DisposeRgn( (RgnHandle
) m_macBoundaryClipRgn
) ;
285 DisposeRgn( (RgnHandle
) m_macCurrentClipRgn
) ;
288 void wxDC::MacSetupGraphicContext()
290 // no-op for QuickDraw
293 void wxDC::MacSetupPort(wxMacPortStateHelper
* help
) const
296 wxASSERT( m_macCurrentPortStateHelper
== NULL
) ;
297 m_macCurrentPortStateHelper
= help
;
299 SetClip( (RgnHandle
) m_macCurrentClipRgn
);
300 #if ! wxMAC_EXPERIMENTAL_DC
301 m_macFontInstalled
= false ;
302 m_macBrushInstalled
= false ;
303 m_macPenInstalled
= false ;
306 void wxDC::MacCleanupPort(wxMacPortStateHelper
* help
) const
309 wxASSERT( m_macCurrentPortStateHelper
== help
) ;
310 m_macCurrentPortStateHelper
= NULL
;
312 if( m_macATSUIStyle
)
314 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUIStyle
);
315 m_macATSUIStyle
= NULL
;
317 if ( m_macAliasWasEnabled
)
319 SetAntiAliasedTextEnabled(m_macFormerAliasState
, m_macFormerAliasSize
);
320 m_macAliasWasEnabled
= false ;
322 if ( m_macForegroundPixMap
)
325 ::PenPat(GetQDGlobalsBlack(&blackColor
));
326 DisposePixPat( (PixPatHandle
) m_macForegroundPixMap
) ;
327 m_macForegroundPixMap
= NULL
;
329 if ( m_macBackgroundPixMap
)
332 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
333 DisposePixPat( (PixPatHandle
) m_macBackgroundPixMap
) ;
334 m_macBackgroundPixMap
= NULL
;
338 void wxDC::DoDrawBitmap( const wxBitmap
&bmp
, wxCoord x
, wxCoord y
, bool useMask
)
340 wxCHECK_RET( Ok(), wxT("invalid window dc") );
341 wxCHECK_RET( bmp
.Ok(), wxT("invalid bitmap") );
342 wxMacFastPortSetter
helper(this) ;
343 wxCoord xx
= XLOG2DEVMAC(x
);
344 wxCoord yy
= YLOG2DEVMAC(y
);
345 wxCoord w
= bmp
.GetWidth();
346 wxCoord h
= bmp
.GetHeight();
347 wxCoord ww
= XLOG2DEVREL(w
);
348 wxCoord hh
= YLOG2DEVREL(h
);
349 // Set up drawing mode
350 short mode
= (m_logicalFunction
== wxCOPY
? srcCopy
:
351 //m_logicalFunction == wxCLEAR ? WHITENESS :
352 //m_logicalFunction == wxSET ? BLACKNESS :
353 m_logicalFunction
== wxINVERT
? hilite
:
354 //m_logicalFunction == wxAND ? MERGECOPY :
355 m_logicalFunction
== wxOR
? srcOr
:
356 m_logicalFunction
== wxSRC_INVERT
? notSrcCopy
:
357 m_logicalFunction
== wxXOR
? srcXor
:
358 m_logicalFunction
== wxOR_REVERSE
? notSrcOr
:
359 //m_logicalFunction == wxAND_REVERSE ? SRCERASE :
360 //m_logicalFunction == wxSRC_OR ? srcOr :
361 //m_logicalFunction == wxSRC_AND ? SRCAND :
363 if ( bmp
.GetBitmapType() == kMacBitmapTypePict
) {
364 Rect bitmaprect
= { 0 , 0 , hh
, ww
};
365 ::OffsetRect( &bitmaprect
, xx
, yy
) ;
366 ::DrawPicture( (PicHandle
) bmp
.GetPict(), &bitmaprect
) ;
368 else if ( bmp
.GetBitmapType() == kMacBitmapTypeGrafWorld
)
370 GWorldPtr bmapworld
= MAC_WXHBITMAP( bmp
.GetHBITMAP() );
371 PixMapHandle bmappixels
;
372 // Set foreground and background colours (for bitmaps depth = 1)
373 if(bmp
.GetDepth() == 1)
375 RGBColor fore
= MAC_WXCOLORREF(m_textForegroundColour
.GetPixel());
376 RGBColor back
= MAC_WXCOLORREF(m_textBackgroundColour
.GetPixel());
382 RGBColor white
= { 0xFFFF, 0xFFFF,0xFFFF} ;
383 RGBColor black
= { 0,0,0} ;
384 RGBForeColor( &black
) ;
385 RGBBackColor( &white
) ;
387 bmappixels
= GetGWorldPixMap( bmapworld
) ;
388 wxCHECK_RET(LockPixels(bmappixels
),
389 wxT("DoDrawBitmap: Unable to lock pixels"));
390 Rect source
= { 0, 0, h
, w
};
391 Rect dest
= { yy
, xx
, yy
+ hh
, xx
+ ww
};
392 if ( useMask
&& bmp
.GetMask() )
394 if( LockPixels(GetGWorldPixMap(MAC_WXHBITMAP(bmp
.GetMask()->GetMaskBitmap()))))
398 GetPortBitMapForCopyBits(bmapworld
),
399 GetPortBitMapForCopyBits(MAC_WXHBITMAP(bmp
.GetMask()->GetMaskBitmap())),
400 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ),
401 &source
, &source
, &dest
, mode
, NULL
403 UnlockPixels(GetGWorldPixMap(MAC_WXHBITMAP(bmp
.GetMask()->GetMaskBitmap())));
407 CopyBits( GetPortBitMapForCopyBits( bmapworld
),
408 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ),
409 &source
, &dest
, mode
, NULL
) ;
411 UnlockPixels( bmappixels
) ;
413 else if ( bmp
.GetBitmapType() == kMacBitmapTypeIcon
)
415 Rect bitmaprect
= { 0 , 0 , bmp
.GetHeight(), bmp
.GetWidth() } ;
416 OffsetRect( &bitmaprect
, xx
, yy
) ;
417 PlotCIconHandle( &bitmaprect
, atNone
, ttNone
, MAC_WXHICON(bmp
.GetHICON()) ) ;
419 m_macPenInstalled
= false ;
420 m_macBrushInstalled
= false ;
421 m_macFontInstalled
= false ;
424 void wxDC::DoDrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
)
426 wxCHECK_RET(Ok(), wxT("Invalid dc wxDC::DoDrawIcon"));
427 wxCHECK_RET(icon
.Ok(), wxT("Invalid icon wxDC::DoDrawIcon"));
428 DoDrawBitmap( icon
, x
, y
, icon
.GetMask() != NULL
) ;
431 void wxDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
433 wxCHECK_RET(Ok(), wxT("wxDC::DoSetClippingRegion Invalid DC"));
434 wxCoord xx
, yy
, ww
, hh
;
437 ww
= XLOG2DEVREL(width
);
438 hh
= YLOG2DEVREL(height
);
439 SetRectRgn( (RgnHandle
) m_macCurrentClipRgn
, xx
, yy
, xx
+ ww
, yy
+ hh
) ;
440 SectRgn( (RgnHandle
) m_macCurrentClipRgn
, (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
443 m_clipX1
= wxMax( m_clipX1
, xx
);
444 m_clipY1
= wxMax( m_clipY1
, yy
);
445 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
));
446 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
));
458 void wxDC::DoSetClippingRegionAsRegion( const wxRegion
®ion
)
460 wxCHECK_RET( Ok(), wxT("invalid window dc") ) ;
463 DestroyClippingRegion();
466 wxMacFastPortSetter
helper(this) ;
468 region
.GetBox( x
, y
, w
, h
);
469 wxCoord xx
, yy
, ww
, hh
;
474 // if we have a scaling that we cannot map onto native regions
475 // we must use the box
476 if ( ww
!= w
|| hh
!= h
)
478 wxDC::DoSetClippingRegion( x
, y
, w
, h
);
482 CopyRgn( (RgnHandle
) region
.GetWXHRGN() , (RgnHandle
) m_macCurrentClipRgn
) ;
483 if ( xx
!= x
|| yy
!= y
)
485 OffsetRgn( (RgnHandle
) m_macCurrentClipRgn
, xx
- x
, yy
- y
) ;
487 SectRgn( (RgnHandle
) m_macCurrentClipRgn
, (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
490 m_clipX1
= wxMax( m_clipX1
, xx
);
491 m_clipY1
= wxMax( m_clipY1
, yy
);
492 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
));
493 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
));
506 void wxDC::DestroyClippingRegion()
508 wxMacFastPortSetter
helper(this) ;
509 CopyRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
513 void wxDC::DoGetSizeMM( int* width
, int* height
) const
518 *width
= long( double(w
) / (m_scaleX
*m_mm_to_pix_x
) );
519 *height
= long( double(h
) / (m_scaleY
*m_mm_to_pix_y
) );
522 void wxDC::SetTextForeground( const wxColour
&col
)
524 wxCHECK_RET(Ok(), wxT("Invalid DC"));
525 m_textForegroundColour
= col
;
526 m_macFontInstalled
= false ;
529 void wxDC::SetTextBackground( const wxColour
&col
)
531 wxCHECK_RET(Ok(), wxT("Invalid DC"));
532 m_textBackgroundColour
= col
;
533 m_macFontInstalled
= false ;
536 void wxDC::SetMapMode( int mode
)
541 SetLogicalScale( twips2mm
*m_mm_to_pix_x
, twips2mm
*m_mm_to_pix_y
);
544 SetLogicalScale( pt2mm
*m_mm_to_pix_x
, pt2mm
*m_mm_to_pix_y
);
547 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
550 SetLogicalScale( m_mm_to_pix_x
/10.0, m_mm_to_pix_y
/10.0 );
554 SetLogicalScale( 1.0, 1.0 );
557 if (mode
!= wxMM_TEXT
)
559 m_needComputeScaleX
= true;
560 m_needComputeScaleY
= true;
564 void wxDC::SetUserScale( double x
, double y
)
566 // allow negative ? -> no
569 ComputeScaleAndOrigin();
572 void wxDC::SetLogicalScale( double x
, double y
)
577 ComputeScaleAndOrigin();
580 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
582 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
583 m_logicalOriginY
= y
* m_signY
;
584 ComputeScaleAndOrigin();
587 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
589 m_externalDeviceOriginX
= x
;
590 m_externalDeviceOriginY
= y
;
591 ComputeScaleAndOrigin();
594 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
596 m_signX
= (xLeftRight
? 1 : -1);
597 m_signY
= (yBottomUp
? -1 : 1);
598 ComputeScaleAndOrigin();
601 wxSize
wxDC::GetPPI() const
603 return wxSize(72, 72);
606 int wxDC::GetDepth() const
608 if ( IsPortColor( (CGrafPtr
) m_macPort
) )
610 return ( (**GetPortPixMap( (CGrafPtr
) m_macPort
)).pixelSize
) ;
615 void wxDC::ComputeScaleAndOrigin()
617 // CMB: copy scale to see if it changes
618 double origScaleX
= m_scaleX
;
619 double origScaleY
= m_scaleY
;
620 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
621 m_scaleY
= m_logicalScaleY
* m_userScaleY
;
622 m_deviceOriginX
= m_internalDeviceOriginX
+ m_externalDeviceOriginX
;
623 m_deviceOriginY
= m_internalDeviceOriginY
+ m_externalDeviceOriginY
;
624 // CMB: if scale has changed call SetPen to recalulate the line width
625 if (m_scaleX
!= origScaleX
|| m_scaleY
!= origScaleY
)
627 // this is a bit artificial, but we need to force wxDC to think
628 // the pen has changed
635 void wxDC::SetPalette( const wxPalette
& palette
)
639 void wxDC::SetBackgroundMode( int mode
)
641 m_backgroundMode
= mode
;
644 void wxDC::SetFont( const wxFont
&font
)
647 m_macFontInstalled
= false ;
650 void wxDC::SetPen( const wxPen
&pen
)
655 m_macPenInstalled
= false ;
658 void wxDC::SetBrush( const wxBrush
&brush
)
660 if (m_brush
== brush
)
663 m_macBrushInstalled
= false ;
666 void wxDC::SetBackground( const wxBrush
&brush
)
668 if (m_backgroundBrush
== brush
)
670 m_backgroundBrush
= brush
;
671 if (!m_backgroundBrush
.Ok())
673 m_macBrushInstalled
= false ;
676 void wxDC::SetLogicalFunction( int function
)
678 if (m_logicalFunction
== function
)
680 m_logicalFunction
= function
;
681 m_macFontInstalled
= false ;
682 m_macBrushInstalled
= false ;
683 m_macPenInstalled
= false ;
686 extern bool wxDoFloodFill(wxDC
*dc
, wxCoord x
, wxCoord y
,
687 const wxColour
& col
, int style
);
689 bool wxDC::DoFloodFill(wxCoord x
, wxCoord y
,
690 const wxColour
& col
, int style
)
692 return wxDoFloodFill(this, x
, y
, col
, style
);
695 bool wxDC::DoGetPixel( wxCoord x
, wxCoord y
, wxColour
*col
) const
697 wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel Invalid DC") );
698 wxMacFastPortSetter
helper(this) ;
700 GetCPixel( XLOG2DEVMAC(x
), YLOG2DEVMAC(y
), &colour
);
701 // Convert from Mac colour to wx
702 col
->Set( colour
.red
>> 8,
708 void wxDC::DoDrawLine( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
710 wxCHECK_RET(Ok(), wxT("Invalid DC"));
711 wxMacFastPortSetter
helper(this) ;
712 if (m_pen
.GetStyle() != wxTRANSPARENT
)
715 wxCoord offset
= ( (m_pen
.GetWidth() == 0 ? 1 :
716 m_pen
.GetWidth() ) * (wxCoord
)m_scaleX
- 1) / 2;
717 wxCoord xx1
= XLOG2DEVMAC(x1
) - offset
;
718 wxCoord yy1
= YLOG2DEVMAC(y1
) - offset
;
719 wxCoord xx2
= XLOG2DEVMAC(x2
) - offset
;
720 wxCoord yy2
= YLOG2DEVMAC(y2
) - offset
;
721 if ((m_pen
.GetCap() == wxCAP_ROUND
) &&
722 (m_pen
.GetWidth() <= 1))
724 // Implement LAST_NOT for MAC at least for
725 // orthogonal lines. RR.
746 void wxDC::DoCrossHair( wxCoord x
, wxCoord y
)
748 wxCHECK_RET( Ok(), wxT("wxDC::DoCrossHair Invalid window dc") );
749 wxMacFastPortSetter
helper(this) ;
750 if (m_pen
.GetStyle() != wxTRANSPARENT
)
755 wxCoord xx
= XLOG2DEVMAC(x
);
756 wxCoord yy
= YLOG2DEVMAC(y
);
758 ::MoveTo( XLOG2DEVMAC(0), yy
);
759 ::LineTo( XLOG2DEVMAC(w
), yy
);
760 ::MoveTo( xx
, YLOG2DEVMAC(0) );
761 ::LineTo( xx
, YLOG2DEVMAC(h
) );
762 CalcBoundingBox(x
, y
);
763 CalcBoundingBox(x
+w
, y
+h
);
768 * To draw arcs properly the angles need to be converted from the WX style:
769 * Angles start on the +ve X axis and go anti-clockwise (As you would draw on
770 * a normal axis on paper).
773 * Angles start on the +ve y axis and go clockwise.
776 static double wxConvertWXangleToMACangle(double angle
)
778 double newAngle
= 90 - angle
;
779 while ( newAngle
> 360 ) newAngle
-= 360 ;
780 while ( newAngle
< 0 ) newAngle
+= 360 ;
784 void wxDC::DoDrawArc( wxCoord x1
, wxCoord y1
,
785 wxCoord x2
, wxCoord y2
,
786 wxCoord xc
, wxCoord yc
)
788 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawArc Invalid DC"));
789 wxMacFastPortSetter
helper(this) ;
790 wxCoord xx1
= XLOG2DEVMAC(x1
);
791 wxCoord yy1
= YLOG2DEVMAC(y1
);
792 wxCoord xx2
= XLOG2DEVMAC(x2
);
793 wxCoord yy2
= YLOG2DEVMAC(y2
);
794 wxCoord xxc
= XLOG2DEVMAC(xc
);
795 wxCoord yyc
= YLOG2DEVMAC(yc
);
796 double dx
= xx1
- xxc
;
797 double dy
= yy1
- yyc
;
798 double radius
= sqrt((double)(dx
*dx
+dy
*dy
));
799 wxCoord rad
= (wxCoord
)radius
;
800 double radius1
, radius2
;
801 if (xx1
== xx2
&& yy1
== yy2
)
806 else if (radius
== 0.0)
808 radius1
= radius2
= 0.0;
812 radius1
= (xx1
- xxc
== 0) ?
813 (yy1
- yyc
< 0) ? 90.0 : -90.0 :
814 -atan2(double(yy1
-yyc
), double(xx1
-xxc
)) * RAD2DEG
;
815 radius2
= (xx2
- xxc
== 0) ?
816 (yy2
- yyc
< 0) ? 90.0 : -90.0 :
817 -atan2(double(yy2
-yyc
), double(xx2
-xxc
)) * RAD2DEG
;
819 wxCoord alpha2
= wxCoord(radius2
- radius1
);
820 wxCoord alpha1
= wxCoord(wxConvertWXangleToMACangle(radius1
));
821 while( alpha2
< 0 ) alpha2
+= 360 ;
823 Rect r
= { yyc
- rad
, xxc
- rad
, yyc
+ rad
, xxc
+ rad
};
824 if(m_brush
.GetStyle() != wxTRANSPARENT
) {
826 PaintArc(&r
, alpha1
, alpha2
);
828 if(m_pen
.GetStyle() != wxTRANSPARENT
) {
830 FrameArc(&r
, alpha1
, alpha2
);
834 void wxDC::DoDrawEllipticArc( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
835 double sa
, double ea
)
837 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawEllepticArc Invalid DC"));
838 wxMacFastPortSetter
helper(this) ;
840 double angle
= sa
- ea
; // Order important Mac in opposite direction to wx
841 // we have to make sure that the filling is always counter-clockwise
844 wxCoord xx
= XLOG2DEVMAC(x
);
845 wxCoord yy
= YLOG2DEVMAC(y
);
846 wxCoord ww
= m_signX
* XLOG2DEVREL(w
);
847 wxCoord hh
= m_signY
* YLOG2DEVREL(h
);
848 // handle -ve width and/or height
849 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
850 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
851 sa
= wxConvertWXangleToMACangle(sa
);
856 if(m_brush
.GetStyle() != wxTRANSPARENT
) {
858 PaintArc(&r
, (short)sa
, (short)angle
);
860 if(m_pen
.GetStyle() != wxTRANSPARENT
) {
862 FrameArc(&r
, (short)sa
, (short)angle
);
866 void wxDC::DoDrawPoint( wxCoord x
, wxCoord y
)
868 wxCHECK_RET(Ok(), wxT("Invalid DC"));
869 wxMacFastPortSetter
helper(this) ;
870 if (m_pen
.GetStyle() != wxTRANSPARENT
)
872 wxCoord xx1
= XLOG2DEVMAC(x
);
873 wxCoord yy1
= YLOG2DEVMAC(y
);
874 RGBColor pencolor
= MAC_WXCOLORREF( m_pen
.GetColour().GetPixel());
875 ::SetCPixel( xx1
,yy1
,&pencolor
) ;
876 CalcBoundingBox(x
, y
);
880 void wxDC::DoDrawLines(int n
, wxPoint points
[],
881 wxCoord xoffset
, wxCoord yoffset
)
883 wxCHECK_RET(Ok(), wxT("Invalid DC"));
884 wxMacFastPortSetter
helper(this) ;
885 if (m_pen
.GetStyle() == wxTRANSPARENT
)
888 wxCoord offset
= ( (m_pen
.GetWidth() == 0 ? 1 :
889 m_pen
.GetWidth() ) * (wxCoord
)m_scaleX
- 1) / 2 ;
890 wxCoord x1
, x2
, y1
, y2
;
891 x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
892 y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
893 ::MoveTo(x1
- offset
, y1
- offset
);
894 for (int i
= 0; i
< n
-1; i
++)
896 x2
= XLOG2DEVMAC(points
[i
+1].x
+ xoffset
);
897 y2
= YLOG2DEVMAC(points
[i
+1].y
+ yoffset
);
898 ::LineTo( x2
- offset
, y2
- offset
);
902 void wxDC::DoDrawPolygon(int n
, wxPoint points
[],
903 wxCoord xoffset
, wxCoord yoffset
,
906 wxCHECK_RET(Ok(), wxT("Invalid DC"));
907 wxMacFastPortSetter
helper(this) ;
908 wxCoord x1
, x2
, y1
, y2
;
909 if ( m_brush
.GetStyle() == wxTRANSPARENT
&& m_pen
.GetStyle() == wxTRANSPARENT
)
911 PolyHandle polygon
= OpenPoly();
912 x2
= x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
913 y2
= y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
915 for (int i
= 1; i
< n
; i
++)
917 x2
= XLOG2DEVMAC(points
[i
].x
+ xoffset
);
918 y2
= YLOG2DEVMAC(points
[i
].y
+ yoffset
);
921 // close the polyline if necessary
922 if ( x1
!= x2
|| y1
!= y2
)
927 if (m_brush
.GetStyle() != wxTRANSPARENT
)
930 ::PaintPoly( polygon
);
932 if (m_pen
.GetStyle() != wxTRANSPARENT
)
935 ::FramePoly( polygon
) ;
940 void wxDC::DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
942 wxCHECK_RET(Ok(), wxT("Invalid DC"));
943 wxMacFastPortSetter
helper(this) ;
944 wxCoord xx
= XLOG2DEVMAC(x
);
945 wxCoord yy
= YLOG2DEVMAC(y
);
946 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
947 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
948 // CMB: draw nothing if transformed w or h is 0
949 if (ww
== 0 || hh
== 0)
951 // CMB: handle -ve width and/or height
962 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
963 if (m_brush
.GetStyle() != wxTRANSPARENT
)
966 ::PaintRect( &rect
) ;
968 if (m_pen
.GetStyle() != wxTRANSPARENT
)
971 ::FrameRect( &rect
) ;
975 void wxDC::DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
976 wxCoord width
, wxCoord height
,
979 wxCHECK_RET(Ok(), wxT("Invalid DC"));
980 wxMacFastPortSetter
helper(this) ;
982 radius
= - radius
* ((width
< height
) ? width
: height
);
983 wxCoord xx
= XLOG2DEVMAC(x
);
984 wxCoord yy
= YLOG2DEVMAC(y
);
985 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
986 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
987 // CMB: draw nothing if transformed w or h is 0
988 if (ww
== 0 || hh
== 0)
990 // CMB: handle -ve width and/or height
1001 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
1002 if (m_brush
.GetStyle() != wxTRANSPARENT
)
1005 ::PaintRoundRect( &rect
, int(radius
* 2) , int(radius
* 2) ) ;
1007 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1010 ::FrameRoundRect( &rect
, int(radius
* 2) , int(radius
* 2) ) ;
1014 void wxDC::DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1016 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1017 wxMacFastPortSetter
helper(this) ;
1018 wxCoord xx
= XLOG2DEVMAC(x
);
1019 wxCoord yy
= YLOG2DEVMAC(y
);
1020 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1021 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1022 // CMB: draw nothing if transformed w or h is 0
1023 if (ww
== 0 || hh
== 0)
1025 // CMB: handle -ve width and/or height
1036 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
1037 if (m_brush
.GetStyle() != wxTRANSPARENT
)
1040 ::PaintOval( &rect
) ;
1042 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1045 ::FrameOval( &rect
) ;
1049 bool wxDC::CanDrawBitmap(void) const
1054 bool wxDC::DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1055 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
, int logical_func
, bool useMask
,
1056 wxCoord xsrcMask
, wxCoord ysrcMask
)
1058 wxCHECK_MSG(Ok(), false, wxT("wxDC::DoBlit Illegal dc"));
1059 wxCHECK_MSG(source
->Ok(), false, wxT("wxDC::DoBlit Illegal source DC"));
1060 if ( logical_func
== wxNO_OP
)
1062 if (xsrcMask
== -1 && ysrcMask
== -1)
1064 xsrcMask
= xsrc
; ysrcMask
= ysrc
;
1066 // correct the parameter in case this dc does not have a mask at all
1067 if ( useMask
&& !source
->m_macMask
)
1069 Rect srcrect
, dstrect
;
1070 srcrect
.top
= source
->YLOG2DEVMAC(ysrc
) ;
1071 srcrect
.left
= source
->XLOG2DEVMAC(xsrc
) ;
1072 srcrect
.right
= source
->XLOG2DEVMAC(xsrc
+ width
) ;
1073 srcrect
.bottom
= source
->YLOG2DEVMAC(ysrc
+ height
) ;
1074 dstrect
.top
= YLOG2DEVMAC(ydest
) ;
1075 dstrect
.left
= XLOG2DEVMAC(xdest
) ;
1076 dstrect
.bottom
= YLOG2DEVMAC(ydest
+ height
) ;
1077 dstrect
.right
= XLOG2DEVMAC(xdest
+ width
) ;
1078 short mode
= kUnsupportedMode
;
1079 bool invertDestinationFirst
= false ;
1080 switch ( logical_func
)
1082 case wxAND
: // src AND dst
1083 mode
= adMin
; // ok
1085 case wxAND_INVERT
: // (NOT src) AND dst
1086 mode
= notSrcOr
; // ok
1088 case wxAND_REVERSE
:// src AND (NOT dst)
1089 invertDestinationFirst
= true ;
1093 mode
= kEmulatedMode
;
1096 mode
= srcCopy
; // ok
1098 case wxEQUIV
: // (NOT src) XOR dst
1099 mode
= srcXor
; // ok
1101 case wxINVERT
: // NOT dst
1102 mode
= kEmulatedMode
; //or hilite ;
1104 case wxNAND
: // (NOT src) OR (NOT dst)
1105 invertDestinationFirst
= true ;
1108 case wxNOR
: // (NOT src) AND (NOT dst)
1109 invertDestinationFirst
= true ;
1112 case wxNO_OP
: // dst
1113 mode
= kEmulatedMode
; // this has already been handled upon entry
1115 case wxOR
: // src OR dst
1118 case wxOR_INVERT
: // (NOT src) OR dst
1121 case wxOR_REVERSE
: // src OR (NOT dst)
1122 invertDestinationFirst
= true ;
1126 mode
= kEmulatedMode
;
1128 case wxSRC_INVERT
: // (NOT src)
1129 mode
= notSrcCopy
; // ok
1131 case wxXOR
: // src XOR dst
1132 mode
= notSrcXor
; // ok
1137 if ( mode
== kUnsupportedMode
)
1139 wxFAIL_MSG(wxT("unsupported blitting mode" ));
1142 CGrafPtr sourcePort
= (CGrafPtr
) source
->m_macPort
;
1143 PixMapHandle bmappixels
= GetGWorldPixMap( sourcePort
) ;
1144 if ( LockPixels(bmappixels
) )
1146 wxMacFastPortSetter
helper(this) ;
1147 if ( source
->GetDepth() == 1 )
1149 RGBForeColor( &MAC_WXCOLORREF(m_textForegroundColour
.GetPixel()) ) ;
1150 RGBBackColor( &MAC_WXCOLORREF(m_textBackgroundColour
.GetPixel()) ) ;
1154 // the modes need this, otherwise we'll end up having really nice colors...
1155 RGBColor white
= { 0xFFFF, 0xFFFF,0xFFFF} ;
1156 RGBColor black
= { 0,0,0} ;
1157 RGBForeColor( &black
) ;
1158 RGBBackColor( &white
) ;
1160 if ( useMask
&& source
->m_macMask
)
1162 if ( mode
== srcCopy
)
1164 if ( LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) )
1166 CopyMask( GetPortBitMapForCopyBits( sourcePort
) ,
1167 GetPortBitMapForCopyBits( MAC_WXHBITMAP(source
->m_macMask
) ) ,
1168 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1169 &srcrect
, &srcrect
, &dstrect
) ;
1170 UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1175 RgnHandle clipRgn
= NewRgn() ;
1176 LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1177 BitMapToRegion( clipRgn
, (BitMap
*) *GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1178 UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1179 OffsetRgn( clipRgn
, -srcrect
.left
+ dstrect
.left
, -srcrect
.top
+ dstrect
.top
) ;
1180 if ( mode
== kEmulatedMode
)
1183 ::PenPat(GetQDGlobalsBlack(&pat
));
1184 if ( logical_func
== wxSET
)
1186 RGBColor col
= { 0xFFFF, 0xFFFF, 0xFFFF } ;
1187 ::RGBForeColor( &col
) ;
1188 ::PaintRgn( clipRgn
) ;
1190 else if ( logical_func
== wxCLEAR
)
1192 RGBColor col
= { 0x0000, 0x0000, 0x0000 } ;
1193 ::RGBForeColor( &col
) ;
1194 ::PaintRgn( clipRgn
) ;
1196 else if ( logical_func
== wxINVERT
)
1198 MacInvertRgn( clipRgn
) ;
1202 for ( int y
= 0 ; y
< srcrect
.right
- srcrect
.left
; ++y
)
1204 for ( int x
= 0 ; x
< srcrect
.bottom
- srcrect
.top
; ++x
)
1206 Point dstPoint
= { dstrect
.top
+ y
, dstrect
.left
+ x
} ;
1207 Point srcPoint
= { srcrect
.top
+ y
, srcrect
.left
+ x
} ;
1208 if ( PtInRgn( dstPoint
, clipRgn
) )
1212 SetPort( (GrafPtr
) sourcePort
) ;
1213 GetCPixel( srcPoint
.h
, srcPoint
.v
, &srcColor
) ;
1214 SetPort( (GrafPtr
) m_macPort
) ;
1215 GetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1216 wxMacCalculateColour( logical_func
, srcColor
, dstColor
) ;
1217 SetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1225 if ( invertDestinationFirst
)
1227 MacInvertRgn( clipRgn
) ;
1229 CopyBits( GetPortBitMapForCopyBits( sourcePort
) ,
1230 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1231 &srcrect
, &dstrect
, mode
, clipRgn
) ;
1233 DisposeRgn( clipRgn
) ;
1238 RgnHandle clipRgn
= NewRgn() ;
1239 SetRectRgn( clipRgn
, dstrect
.left
, dstrect
.top
, dstrect
.right
, dstrect
.bottom
) ;
1240 if ( mode
== kEmulatedMode
)
1243 ::PenPat(GetQDGlobalsBlack(&pat
));
1244 if ( logical_func
== wxSET
)
1246 RGBColor col
= { 0xFFFF, 0xFFFF, 0xFFFF } ;
1247 ::RGBForeColor( &col
) ;
1248 ::PaintRgn( clipRgn
) ;
1250 else if ( logical_func
== wxCLEAR
)
1252 RGBColor col
= { 0x0000, 0x0000, 0x0000 } ;
1253 ::RGBForeColor( &col
) ;
1254 ::PaintRgn( clipRgn
) ;
1256 else if ( logical_func
== wxINVERT
)
1258 MacInvertRgn( clipRgn
) ;
1262 for ( int y
= 0 ; y
< srcrect
.right
- srcrect
.left
; ++y
)
1264 for ( int x
= 0 ; x
< srcrect
.bottom
- srcrect
.top
; ++x
)
1266 Point dstPoint
= { dstrect
.top
+ y
, dstrect
.left
+ x
} ;
1267 Point srcPoint
= { srcrect
.top
+ y
, srcrect
.left
+ x
} ;
1271 SetPort( (GrafPtr
) sourcePort
) ;
1272 GetCPixel( srcPoint
.h
, srcPoint
.v
, &srcColor
) ;
1273 SetPort( (GrafPtr
) m_macPort
) ;
1274 GetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1275 wxMacCalculateColour( logical_func
, srcColor
, dstColor
) ;
1276 SetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1284 if ( invertDestinationFirst
)
1286 MacInvertRgn( clipRgn
) ;
1288 CopyBits( GetPortBitMapForCopyBits( sourcePort
) ,
1289 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1290 &srcrect
, &dstrect
, mode
, NULL
) ;
1292 DisposeRgn( clipRgn
) ;
1294 UnlockPixels( bmappixels
) ;
1296 m_macPenInstalled
= false ;
1297 m_macBrushInstalled
= false ;
1298 m_macFontInstalled
= false ;
1302 void wxDC::DoDrawRotatedText(const wxString
& str
, wxCoord x
, wxCoord y
,
1305 // TODO support text background color (only possible by hand, ATSUI does not support it)
1306 wxCHECK_RET( Ok(), wxT("wxDC::DoDrawRotatedText Invalid window dc") );
1308 if ( str
.Length() == 0 )
1311 wxMacFastPortSetter
helper(this) ;
1316 m_macFormerAliasState
= IsAntiAliasedTextEnabled(&m_macFormerAliasSize
);
1317 SetAntiAliasedTextEnabled(true, SInt16(m_scaleY
* m_font
.MacGetFontSize()));
1318 m_macAliasWasEnabled
= true ;
1320 OSStatus status
= noErr
;
1321 ATSUTextLayout atsuLayout
;
1322 UniCharCount chars
= str
.Length() ;
1323 UniChar
* ubuf
= NULL
;
1324 #if SIZEOF_WCHAR_T == 4
1325 wxMBConvUTF16BE converter
;
1327 size_t unicharlen
= converter
.WC2MB( NULL
, str
.wc_str() , 0 ) ;
1328 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1329 converter
.WC2MB( (char*) ubuf
, str
.wc_str(), unicharlen
+ 2 ) ;
1331 const wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1332 size_t unicharlen
= converter
.WC2MB( NULL
, wchar
.data() , 0 ) ;
1333 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1334 converter
.WC2MB( (char*) ubuf
, wchar
.data() , unicharlen
+ 2 ) ;
1336 chars
= unicharlen
/ 2 ;
1339 ubuf
= (UniChar
*) str
.wc_str() ;
1341 wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1342 chars
= wxWcslen( wchar
.data() ) ;
1343 ubuf
= (UniChar
*) wchar
.data() ;
1347 status
= ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr
) ubuf
, 0 , chars
, chars
, 1 ,
1348 &chars
, (ATSUStyle
*) &m_macATSUIStyle
, &atsuLayout
) ;
1350 wxASSERT_MSG( status
== noErr
, wxT("couldn't create the layout of the rotated text") );
1351 int iAngle
= int( angle
);
1352 int drawX
= XLOG2DEVMAC(x
) ;
1353 int drawY
= YLOG2DEVMAC(y
) ;
1355 ATSUTextMeasurement textBefore
;
1356 ATSUTextMeasurement textAfter
;
1357 ATSUTextMeasurement ascent
;
1358 ATSUTextMeasurement descent
;
1361 if ( abs(iAngle
) > 0 )
1363 Fixed atsuAngle
= IntToFixed( iAngle
) ;
1364 ATSUAttributeTag atsuTags
[] =
1366 kATSULineRotationTag
,
1368 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1372 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1376 status
= ::ATSUSetLayoutControls(atsuLayout
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
),
1377 atsuTags
, atsuSizes
, atsuValues
) ;
1379 status
= ::ATSUMeasureText( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1380 &textBefore
, &textAfter
, &ascent
, &descent
);
1382 drawX
+= (int)(sin(angle
/RAD2DEG
) * FixedToInt(ascent
));
1383 drawY
+= (int)(cos(angle
/RAD2DEG
) * FixedToInt(ascent
));
1384 status
= ::ATSUDrawText( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1385 IntToFixed(drawX
) , IntToFixed(drawY
) );
1386 wxASSERT_MSG( status
== noErr
, wxT("couldn't draw the rotated text") );
1388 status
= ::ATSUMeasureTextImage( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1389 IntToFixed(drawX
) , IntToFixed(drawY
) , &rect
);
1390 wxASSERT_MSG( status
== noErr
, wxT("couldn't measure the rotated text") );
1391 OffsetRect( &rect
, -m_macLocalOrigin
.x
, -m_macLocalOrigin
.y
) ;
1392 CalcBoundingBox(XDEV2LOG(rect
.left
), YDEV2LOG(rect
.top
) );
1393 CalcBoundingBox(XDEV2LOG(rect
.right
), YDEV2LOG(rect
.bottom
) );
1394 ::ATSUDisposeTextLayout(atsuLayout
);
1395 #if SIZEOF_WCHAR_T == 4
1400 void wxDC::DoDrawText(const wxString
& strtext
, wxCoord x
, wxCoord y
)
1402 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawText Invalid DC"));
1404 wxMacFastPortSetter
helper(this) ;
1405 long xx
= XLOG2DEVMAC(x
);
1406 long yy
= YLOG2DEVMAC(y
);
1408 bool useDrawThemeText
= ( DrawThemeTextBox
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1409 if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC
) ) || m_font
.GetNoAntiAliasing() )
1410 useDrawThemeText
= false ;
1415 ::GetFontInfo( &fi
) ;
1417 if ( !useDrawThemeText
)
1420 ::MoveTo( xx
, yy
);
1421 if ( m_backgroundMode
== wxTRANSPARENT
)
1423 ::TextMode( srcOr
) ;
1427 ::TextMode( srcCopy
) ;
1431 wxString linetext
= strtext
;
1433 if ( useDrawThemeText
)
1435 Rect frame
= { yy
+ line
*(fi
.descent
+ fi
.ascent
+ fi
.leading
) ,xx
, yy
+ (line
+1)*(fi
.descent
+ fi
.ascent
+ fi
.leading
) , xx
+ 10000 } ;
1436 wxMacCFStringHolder
mString( linetext
, m_font
.GetEncoding()) ;
1438 if ( m_backgroundMode
!= wxTRANSPARENT
)
1440 Point bounds
={0,0} ;
1441 Rect background
= frame
;
1443 ::GetThemeTextDimensions( mString
,
1444 m_font
.MacGetThemeFontID() ,
1449 background
.right
= background
.left
+ bounds
.h
;
1450 background
.bottom
= background
.top
+ bounds
.v
;
1451 ::EraseRect( &background
) ;
1453 ::DrawThemeTextBox( mString
,
1454 m_font
.MacGetThemeFontID() ,
1464 wxCharBuffer text
= linetext
.mb_str(wxConvLocal
) ;
1465 ::DrawText( text
, 0 , strlen(text
) ) ;
1468 ::TextMode( srcOr
) ;
1471 bool wxDC::CanGetTextExtent() const
1473 wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
1477 void wxDC::DoGetTextExtent( const wxString
&strtext
, wxCoord
*width
, wxCoord
*height
,
1478 wxCoord
*descent
, wxCoord
*externalLeading
,
1479 wxFont
*theFont
) const
1481 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1482 wxMacFastPortSetter
helper(this) ;
1483 wxFont formerFont
= m_font
;
1486 // work around the constness
1487 *((wxFont
*)(&m_font
)) = *theFont
;
1491 ::GetFontInfo( &fi
) ;
1493 bool useGetThemeText
= ( GetThemeTextDimensions
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1494 if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC
) ) || ((wxFont
*)&m_font
)->GetNoAntiAliasing() )
1495 useGetThemeText
= false ;
1498 *height
= YDEV2LOGREL( fi
.descent
+ fi
.ascent
) ;
1500 *descent
=YDEV2LOGREL( fi
.descent
);
1501 if ( externalLeading
)
1502 *externalLeading
= YDEV2LOGREL( fi
.leading
) ;
1508 wxString linetext
= strtext
;
1510 if ( useGetThemeText
)
1512 Point bounds
={0,0} ;
1514 wxMacCFStringHolder
mString( linetext
, m_font
.GetEncoding() ) ;
1515 ThemeFontID themeFont
= m_font
.MacGetThemeFontID() ;
1516 ::GetThemeTextDimensions( mString
,
1522 curwidth
= bounds
.h
;
1526 wxCharBuffer text
= linetext
.mb_str(wxConvLocal
) ;
1527 curwidth
= ::TextWidth( text
, 0 , strlen(text
) ) ;
1529 if ( curwidth
> *width
)
1530 *width
= XDEV2LOGREL( curwidth
) ;
1534 // work around the constness
1535 *((wxFont
*)(&m_font
)) = formerFont
;
1536 m_macFontInstalled
= false ;
1541 bool wxDC::DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
1543 wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
1546 widths
.Add(0, text
.Length());
1548 if (text
.Length() == 0)
1551 wxMacFastPortSetter
helper(this) ;
1554 bool useGetThemeText
= ( GetThemeTextDimensions
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1555 if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC
) ) || ((wxFont
*)&m_font
)->GetNoAntiAliasing() )
1556 useGetThemeText
= false ;
1558 if ( useGetThemeText
)
1560 // If anybody knows how to do this more efficiently yet still handle
1561 // the fractional glyph widths that may be present when using AA
1562 // fonts, please change it. Currently it is measuring from the
1563 // begining of the string for each succeding substring, which is much
1564 // slower than this should be.
1565 for (size_t i
=0; i
<text
.Length(); i
++)
1567 wxString
str(text
.Left(i
+1));
1568 Point bounds
= {0,0};
1570 wxMacCFStringHolder
mString(str
, m_font
.GetEncoding());
1571 ::GetThemeTextDimensions( mString
,
1572 m_font
.MacGetThemeFontID(),
1577 widths
[i
] = XDEV2LOGREL(bounds
.h
);
1583 wxCharBuffer buff
= text
.mb_str(wxConvLocal
);
1584 size_t len
= strlen(buff
);
1585 short* measurements
= new short[len
+1];
1586 MeasureText(len
, buff
.data(), measurements
);
1588 // Copy to widths, starting at measurements[1]
1589 // NOTE: this doesn't take into account any multi-byte characters
1590 // in buff, it probabkly should...
1591 for (size_t i
=0; i
<text
.Length(); i
++)
1592 widths
[i
] = XDEV2LOGREL(measurements
[i
+1]);
1594 delete [] measurements
;
1602 wxCoord
wxDC::GetCharWidth(void) const
1604 wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
1605 wxMacFastPortSetter
helper(this) ;
1609 bool useGetThemeText
= ( GetThemeTextDimensions
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1610 if ( UMAGetSystemVersion() < 0x1000 || ((wxFont
*)&m_font
)->GetNoAntiAliasing() )
1611 useGetThemeText
= false ;
1615 if ( useGetThemeText
)
1617 Point bounds
={0,0} ;
1619 CFStringRef mString
= CFStringCreateWithBytes( NULL
, (UInt8
*) text
, 1 , CFStringGetSystemEncoding(), false ) ;
1620 ::GetThemeTextDimensions( mString
,
1621 m_font
.MacGetThemeFontID(),
1626 CFRelease( mString
) ;
1632 width
= ::TextWidth( text
, 0 , 1 ) ;
1634 return YDEV2LOGREL(width
) ;
1637 wxCoord
wxDC::GetCharHeight(void) const
1639 wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
1640 wxMacFastPortSetter
helper(this) ;
1643 ::GetFontInfo( &fi
) ;
1644 return YDEV2LOGREL( fi
.descent
+ fi
.ascent
);
1647 void wxDC::Clear(void)
1649 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1650 wxMacFastPortSetter
helper(this) ;
1651 Rect rect
= { -31000 , -31000 , 31000 , 31000 } ;
1652 if ( m_backgroundBrush
.Ok() && m_backgroundBrush
.GetStyle() != wxTRANSPARENT
)
1655 MacSetupBackgroundForCurrentPort( m_backgroundBrush
) ;
1656 ::EraseRect( &rect
) ;
1660 void wxDC::MacInstallFont() const
1662 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1663 // if ( m_macFontInstalled )
1665 Pattern blackColor
;
1666 MacSetupBackgroundForCurrentPort(m_backgroundBrush
) ;
1667 if ( m_backgroundMode
!= wxTRANSPARENT
)
1669 Pattern whiteColor
;
1670 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
1673 wxASSERT( m_font
.Ok() ) ;
1676 ::TextFont( m_font
.MacGetFontNum() ) ;
1677 ::TextSize( (short)(m_scaleY
* m_font
.MacGetFontSize()) ) ;
1678 ::TextFace( m_font
.MacGetFontStyle() ) ;
1679 m_macFontInstalled
= true ;
1680 m_macBrushInstalled
= false ;
1681 m_macPenInstalled
= false ;
1682 RGBColor forecolor
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel());
1683 RGBColor backcolor
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel());
1684 ::RGBForeColor( &forecolor
);
1685 ::RGBBackColor( &backcolor
);
1687 short mode
= patCopy
;
1689 switch( m_logicalFunction
)
1694 case wxINVERT
: // NOT dst
1695 ::PenPat(GetQDGlobalsBlack(&blackColor
));
1698 case wxXOR
: // src XOR dst
1701 case wxOR_REVERSE
: // src OR (NOT dst)
1704 case wxSRC_INVERT
: // (NOT src)
1707 case wxAND
: // src AND dst
1712 case wxAND_REVERSE
:// src AND (NOT dst)
1713 case wxAND_INVERT
: // (NOT src) AND dst
1714 case wxNO_OP
: // dst
1715 case wxNOR
: // (NOT src) AND (NOT dst)
1716 case wxEQUIV
: // (NOT src) XOR dst
1717 case wxOR_INVERT
: // (NOT src) OR dst
1718 case wxNAND
: // (NOT src) OR (NOT dst)
1719 case wxOR
: // src OR dst
1721 // case wxSRC_OR: // source _bitmap_ OR destination
1722 // case wxSRC_AND: // source _bitmap_ AND destination
1726 OSStatus status
= noErr
;
1727 status
= ATSUCreateAndCopyStyle( (ATSUStyle
) m_font
.MacGetATSUStyle() , (ATSUStyle
*) &m_macATSUIStyle
) ;
1728 wxASSERT_MSG( status
== noErr
, wxT("couldn't set create ATSU style") ) ;
1730 Fixed atsuSize
= IntToFixed( int(m_scaleY
* m_font
.MacGetFontSize()) ) ;
1731 ATSUAttributeTag atsuTags
[] =
1735 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1739 Boolean kTrue
= true ;
1740 Boolean kFalse
= false ;
1742 ATSUVerticalCharacterType kHorizontal
= kATSUStronglyHorizontal
;
1743 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1747 status
= ::ATSUSetAttributes((ATSUStyle
)m_macATSUIStyle
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
) ,
1748 atsuTags
, atsuSizes
, atsuValues
);
1750 wxASSERT_MSG( status
== noErr
, wxT("couldn't Modify ATSU style") ) ;
1754 Pattern gPatterns
[] =
1756 { { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF } } ,
1757 { { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 } } ,
1758 { { 0x80 , 0x40 , 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , 0x01 } } ,
1759 { { 0x10 , 0x10 , 0x10 , 0xFF , 0x10 , 0x10 , 0x10 , 0x10 } } ,
1760 { { 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 } } ,
1761 { { 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 } } ,
1762 { { 0x81 , 0x42 , 0x24 , 0x18 , 0x18 , 0x24 , 0x42 , 0x81 } } ,
1764 { { 0xCC , 0x99 , 0x33 , 0x66 , 0xCC , 0x99 , 0x33 , 0x66 } } , // DOT
1765 { { 0xFE , 0xFD , 0xFB , 0xF7 , 0xEF , 0xDF , 0xBF , 0x7F } } , // LONG_DASH
1766 { { 0xEE , 0xDD , 0xBB , 0x77 , 0xEE , 0xDD , 0xBB , 0x77 } } , // SHORT_DASH
1767 { { 0xDE , 0xBD , 0x7B , 0xF6 , 0xED , 0xDB , 0xB7 , 0x6F } } , // DOT_DASH
1770 static void wxMacGetPattern(int penStyle
, Pattern
*pattern
)
1772 int index
= 0; // solid pattern by default
1776 case wxBDIAGONAL_HATCH
: index
= 1; break;
1777 case wxFDIAGONAL_HATCH
: index
= 2; break;
1778 case wxCROSS_HATCH
: index
= 3; break;
1779 case wxHORIZONTAL_HATCH
: index
= 4; break;
1780 case wxVERTICAL_HATCH
: index
= 5; break;
1781 case wxCROSSDIAG_HATCH
: index
= 6; break;
1783 case wxDOT
: index
= 7; break;
1784 case wxLONG_DASH
: index
= 8; break;
1785 case wxSHORT_DASH
: index
= 9; break;
1786 case wxDOT_DASH
: index
= 10; break;
1788 *pattern
= gPatterns
[index
];
1791 void wxDC::MacInstallPen() const
1793 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1794 //Pattern blackColor;
1795 // if ( m_macPenInstalled )
1797 RGBColor forecolor
= MAC_WXCOLORREF( m_pen
.GetColour().GetPixel());
1798 RGBColor backcolor
= MAC_WXCOLORREF( m_backgroundBrush
.GetColour().GetPixel());
1799 ::RGBForeColor( &forecolor
);
1800 ::RGBBackColor( &backcolor
);
1802 int penWidth
= (int) (m_pen
.GetWidth() * m_scaleX
) ; ;
1803 // null means only one pixel, at whatever resolution
1804 if ( penWidth
== 0 )
1806 ::PenSize(penWidth
, penWidth
);
1808 int penStyle
= m_pen
.GetStyle();
1810 if (penStyle
== wxUSER_DASH
)
1812 // FIXME: there should be exactly 8 items in the dash
1814 int number
= m_pen
.GetDashes(&dash
) ;
1816 for ( int i
= 0 ; i
< 8 ; ++i
)
1818 pat
.pat
[i
] = dash
[index
] ;
1819 if (index
< number
- 1)
1825 wxMacGetPattern(penStyle
, &pat
);
1829 short mode
= patCopy
;
1831 switch( m_logicalFunction
)
1833 case wxCOPY
: // only foreground color, leave background (thus not patCopy)
1836 case wxINVERT
: // NOT dst
1837 // ::PenPat(GetQDGlobalsBlack(&blackColor));
1840 case wxXOR
: // src XOR dst
1843 case wxOR_REVERSE
: // src OR (NOT dst)
1846 case wxSRC_INVERT
: // (NOT src)
1849 case wxAND
: // src AND dst
1854 case wxAND_REVERSE
:// src AND (NOT dst)
1855 case wxAND_INVERT
: // (NOT src) AND dst
1856 case wxNO_OP
: // dst
1857 case wxNOR
: // (NOT src) AND (NOT dst)
1858 case wxEQUIV
: // (NOT src) XOR dst
1859 case wxOR_INVERT
: // (NOT src) OR dst
1860 case wxNAND
: // (NOT src) OR (NOT dst)
1861 case wxOR
: // src OR dst
1863 // case wxSRC_OR: // source _bitmap_ OR destination
1864 // case wxSRC_AND: // source _bitmap_ AND destination
1868 m_macPenInstalled
= true ;
1869 m_macBrushInstalled
= false ;
1870 m_macFontInstalled
= false ;
1873 void wxDC::MacSetupBackgroundForCurrentPort(const wxBrush
& background
)
1875 Pattern whiteColor
;
1876 if ( background
.Ok() )
1878 switch( background
.MacGetBrushKind() )
1880 case kwxMacBrushTheme
:
1882 ::SetThemeBackground( background
.MacGetTheme() , wxDisplayDepth() , true ) ;
1885 case kwxMacBrushThemeBackground
:
1888 ThemeBackgroundKind bg
= background
.MacGetThemeBackground( &extent
) ;
1889 ::ApplyThemeBackground( bg
, &extent
,kThemeStateActive
, wxDisplayDepth() , true ) ;
1892 case kwxMacBrushColour
:
1894 ::RGBBackColor( &MAC_WXCOLORREF( background
.GetColour().GetPixel()) );
1895 int brushStyle
= background
.GetStyle();
1896 if (brushStyle
== wxSOLID
)
1897 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
1898 else if (background
.IsHatch())
1901 wxMacGetPattern(brushStyle
, &pat
);
1906 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
1914 void wxDC::MacInstallBrush() const
1916 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1917 Pattern blackColor
;
1918 // if ( m_macBrushInstalled )
1921 bool backgroundTransparent
= (GetBackgroundMode() == wxTRANSPARENT
) ;
1922 ::RGBForeColor( &MAC_WXCOLORREF( m_brush
.GetColour().GetPixel()) );
1923 ::RGBBackColor( &MAC_WXCOLORREF( m_backgroundBrush
.GetColour().GetPixel()) );
1924 int brushStyle
= m_brush
.GetStyle();
1925 if (brushStyle
== wxSOLID
)
1927 ::PenPat(GetQDGlobalsBlack(&blackColor
));
1929 else if (m_brush
.IsHatch())
1932 wxMacGetPattern(brushStyle
, &pat
);
1935 else if ( m_brush
.GetStyle() == wxSTIPPLE
|| m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
)
1937 // we force this in order to be compliant with wxMSW
1938 backgroundTransparent
= false ;
1939 // for these the text fore (and back for MASK_OPAQUE) colors are used
1940 wxBitmap
* bitmap
= m_brush
.GetStipple() ;
1941 int width
= bitmap
->GetWidth() ;
1942 int height
= bitmap
->GetHeight() ;
1943 GWorldPtr gw
= NULL
;
1944 if ( m_brush
.GetStyle() == wxSTIPPLE
)
1945 gw
= MAC_WXHBITMAP(bitmap
->GetHBITMAP()) ;
1947 gw
= MAC_WXHBITMAP(bitmap
->GetMask()->GetMaskBitmap()) ;
1948 PixMapHandle gwpixmaphandle
= GetGWorldPixMap( gw
) ;
1949 LockPixels( gwpixmaphandle
) ;
1950 bool isMonochrome
= !IsPortColor( gw
) ;
1951 if ( !isMonochrome
)
1953 if ( (**gwpixmaphandle
).pixelSize
== 1 )
1954 isMonochrome
= true ;
1956 if ( isMonochrome
&& width
== 8 && height
== 8 )
1958 ::RGBForeColor( &MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) );
1959 ::RGBForeColor( &MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) );
1960 BitMap
* gwbitmap
= (BitMap
*) *gwpixmaphandle
; // since the color depth is 1 it is a BitMap
1961 UInt8
*gwbits
= (UInt8
*) gwbitmap
->baseAddr
;
1962 int alignment
= gwbitmap
->rowBytes
& 0x7FFF ;
1964 for ( int i
= 0 ; i
< 8 ; ++i
)
1966 pat
.pat
[i
] = gwbits
[i
*alignment
+0] ;
1968 UnlockPixels( GetGWorldPixMap( gw
) ) ;
1973 // this will be the code to handle power of 2 patterns, we will have to arrive at a nice
1974 // caching scheme before putting this into production
1977 PixPatHandle pixpat
= NewPixPat() ;
1978 CopyPixMap(gwpixmaphandle
, (**pixpat
).patMap
);
1979 imageSize
= GetPixRowBytes((**pixpat
).patMap
) *
1980 ((**(**pixpat
).patMap
).bounds
.bottom
-
1981 (**(**pixpat
).patMap
).bounds
.top
);
1982 PtrToHand( (**gwpixmaphandle
).baseAddr
, &image
, imageSize
);
1983 (**pixpat
).patData
= image
;
1986 CTabHandle ctable
= ((**((**pixpat
).patMap
)).pmTable
) ;
1987 ColorSpecPtr ctspec
= (ColorSpecPtr
) &(**ctable
).ctTable
;
1988 if ( ctspec
[0].rgb
.red
== 0x0000 )
1990 ctspec
[1].rgb
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) ;
1991 ctspec
[0].rgb
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) ;
1995 ctspec
[0].rgb
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) ;
1996 ctspec
[1].rgb
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) ;
1998 ::CTabChanged( ctable
) ;
2000 ::PenPixPat(pixpat
);
2001 m_macForegroundPixMap
= pixpat
;
2003 UnlockPixels( gwpixmaphandle
) ;
2007 ::PenPat(GetQDGlobalsBlack(&blackColor
));
2009 short mode
= patCopy
;
2010 switch( m_logicalFunction
)
2013 if ( backgroundTransparent
)
2018 case wxINVERT
: // NOT dst
2019 if ( !backgroundTransparent
)
2021 ::PenPat(GetQDGlobalsBlack(&blackColor
));
2025 case wxXOR
: // src XOR dst
2028 case wxOR_REVERSE
: // src OR (NOT dst)
2031 case wxSRC_INVERT
: // (NOT src)
2034 case wxAND
: // src AND dst
2039 case wxAND_REVERSE
:// src AND (NOT dst)
2040 case wxAND_INVERT
: // (NOT src) AND dst
2041 case wxNO_OP
: // dst
2042 case wxNOR
: // (NOT src) AND (NOT dst)
2043 case wxEQUIV
: // (NOT src) XOR dst
2044 case wxOR_INVERT
: // (NOT src) OR dst
2045 case wxNAND
: // (NOT src) OR (NOT dst)
2046 case wxOR
: // src OR dst
2048 // case wxSRC_OR: // source _bitmap_ OR destination
2049 // case wxSRC_AND: // source _bitmap_ AND destination
2053 m_macBrushInstalled
= true ;
2054 m_macPenInstalled
= false ;
2055 m_macFontInstalled
= false ;
2058 // ---------------------------------------------------------------------------
2059 // coordinates transformations
2060 // ---------------------------------------------------------------------------
2062 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
2064 return ((wxDC
*)this)->XDEV2LOG(x
);
2067 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
2069 return ((wxDC
*)this)->YDEV2LOG(y
);
2072 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
2074 return ((wxDC
*)this)->XDEV2LOGREL(x
);
2077 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
2079 return ((wxDC
*)this)->YDEV2LOGREL(y
);
2082 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
2084 return ((wxDC
*)this)->XLOG2DEV(x
);
2087 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
2089 return ((wxDC
*)this)->YLOG2DEV(y
);
2092 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
2094 return ((wxDC
*)this)->XLOG2DEVREL(x
);
2097 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
2099 return ((wxDC
*)this)->YLOG2DEVREL(y
);