1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
16 #if !wxMAC_USE_CORE_GRAPHICS
18 #include "wx/mac/uma.h"
19 #include "wx/dcmemory.h"
20 #include "wx/dcprint.h"
21 #include "wx/region.h"
32 #include "wx/mac/private.h"
34 #include <ATSUnicode.h>
35 #include <TextCommon.h>
36 #include <TextEncodingConverter.h>
40 // set to 0 if problems arise
41 #define wxMAC_EXPERIMENTAL_DC 1
44 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxObject
)
46 //-----------------------------------------------------------------------------
48 //-----------------------------------------------------------------------------
50 const double RAD2DEG
= 180.0 / M_PI
;
51 const short kEmulatedMode
= -1 ;
52 const short kUnsupportedMode
= -2 ;
54 extern TECObjectRef s_TECNativeCToUnicode
;
57 wxMacPortSetter::wxMacPortSetter( const wxDC
* dc
) :
58 m_ph( (GrafPtr
) dc
->m_macPort
)
60 wxASSERT( dc
->Ok() ) ;
62 dc
->MacSetupPort(&m_ph
) ;
65 wxMacPortSetter::~wxMacPortSetter()
67 m_dc
->MacCleanupPort(&m_ph
) ;
70 #if wxMAC_EXPERIMENTAL_DC
71 class wxMacFastPortSetter
74 wxMacFastPortSetter( const wxDC
*dc
)
76 wxASSERT( dc
->Ok() ) ;
77 m_swapped
= QDSwapPort( (GrafPtr
) dc
->m_macPort
, &m_oldPort
) ;
78 m_clipRgn
= NewRgn() ;
79 GetClip( m_clipRgn
) ;
81 dc
->MacSetupPort( NULL
) ;
84 ~wxMacFastPortSetter()
86 // SetPort( (GrafPtr) m_dc->m_macPort ) ;
87 SetClip( m_clipRgn
) ;
89 SetPort( m_oldPort
) ;
90 m_dc
->MacCleanupPort( NULL
) ;
91 DisposeRgn( m_clipRgn
) ;
102 typedef wxMacPortSetter wxMacFastPortSetter
;
105 wxMacWindowClipper::wxMacWindowClipper( const wxWindow
* win
) :
106 wxMacPortSaver( (GrafPtr
) GetWindowPort((WindowRef
) win
->MacGetTopLevelWindowRef()) )
108 m_newPort
=(GrafPtr
) GetWindowPort((WindowRef
) win
->MacGetTopLevelWindowRef()) ;
109 m_formerClip
= NewRgn() ;
110 m_newClip
= NewRgn() ;
111 GetClip( m_formerClip
) ;
115 // guard against half constructed objects, this just leads to a empty clip
116 if ( win
->GetPeer() )
119 win
->MacWindowToRootWindow( &x
, &y
) ;
121 // get area including focus rect
122 CopyRgn( (RgnHandle
) ((wxWindow
*)win
)->MacGetVisibleRegion(true).GetWXHRGN() , m_newClip
) ;
123 if ( !EmptyRgn( m_newClip
) )
124 OffsetRgn( m_newClip
, x
, y
) ;
127 SetClip( m_newClip
) ;
131 wxMacWindowClipper::~wxMacWindowClipper()
133 SetPort( m_newPort
) ;
134 SetClip( m_formerClip
) ;
135 DisposeRgn( m_newClip
) ;
136 DisposeRgn( m_formerClip
) ;
139 wxMacWindowStateSaver::wxMacWindowStateSaver( const wxWindow
* win
) :
140 wxMacWindowClipper( win
)
142 // the port is already set at this point
143 m_newPort
= (GrafPtr
) GetWindowPort((WindowRef
) win
->MacGetTopLevelWindowRef()) ;
144 GetThemeDrawingState( &m_themeDrawingState
) ;
147 wxMacWindowStateSaver::~wxMacWindowStateSaver()
149 SetPort( m_newPort
) ;
150 SetThemeDrawingState( m_themeDrawingState
, true ) ;
153 //-----------------------------------------------------------------------------
155 //-----------------------------------------------------------------------------
156 static inline double dmin(double a
, double b
) { return a
< b
? a
: b
; }
157 static inline double dmax(double a
, double b
) { return a
> b
? a
: b
; }
158 static inline double DegToRad(double deg
) { return (deg
* M_PI
) / 180.0; }
160 //-----------------------------------------------------------------------------
162 //-----------------------------------------------------------------------------
163 // this function emulates all wx colour manipulations, used to verify the implementation
164 // by setting the mode in the blitting functions to kEmulatedMode
165 void wxMacCalculateColour( int logical_func
, const RGBColor
&srcColor
, RGBColor
&dstColor
) ;
167 void wxMacCalculateColour( int logical_func
, const RGBColor
&srcColor
, RGBColor
&dstColor
)
169 switch ( logical_func
)
171 case wxAND
: // src AND dst
172 dstColor
.red
= dstColor
.red
& srcColor
.red
;
173 dstColor
.green
= dstColor
.green
& srcColor
.green
;
174 dstColor
.blue
= dstColor
.blue
& srcColor
.blue
;
177 case wxAND_INVERT
: // (NOT src) AND dst
178 dstColor
.red
= dstColor
.red
& ~srcColor
.red
;
179 dstColor
.green
= dstColor
.green
& ~srcColor
.green
;
180 dstColor
.blue
= dstColor
.blue
& ~srcColor
.blue
;
183 case wxAND_REVERSE
:// src AND (NOT dst)
184 dstColor
.red
= ~dstColor
.red
& srcColor
.red
;
185 dstColor
.green
= ~dstColor
.green
& srcColor
.green
;
186 dstColor
.blue
= ~dstColor
.blue
& srcColor
.blue
;
196 dstColor
.red
= srcColor
.red
;
197 dstColor
.green
= srcColor
.green
;
198 dstColor
.blue
= srcColor
.blue
;
201 case wxEQUIV
: // (NOT src) XOR dst
202 dstColor
.red
= dstColor
.red
^ ~srcColor
.red
;
203 dstColor
.green
= dstColor
.green
^ ~srcColor
.green
;
204 dstColor
.blue
= dstColor
.blue
^ ~srcColor
.blue
;
207 case wxINVERT
: // NOT dst
208 dstColor
.red
= ~dstColor
.red
;
209 dstColor
.green
= ~dstColor
.green
;
210 dstColor
.blue
= ~dstColor
.blue
;
213 case wxNAND
: // (NOT src) OR (NOT dst)
214 dstColor
.red
= ~dstColor
.red
| ~srcColor
.red
;
215 dstColor
.green
= ~dstColor
.green
| ~srcColor
.green
;
216 dstColor
.blue
= ~dstColor
.blue
| ~srcColor
.blue
;
219 case wxNOR
: // (NOT src) AND (NOT dst)
220 dstColor
.red
= ~dstColor
.red
& ~srcColor
.red
;
221 dstColor
.green
= ~dstColor
.green
& ~srcColor
.green
;
222 dstColor
.blue
= ~dstColor
.blue
& ~srcColor
.blue
;
225 case wxOR
: // src OR dst
226 dstColor
.red
= dstColor
.red
| srcColor
.red
;
227 dstColor
.green
= dstColor
.green
| srcColor
.green
;
228 dstColor
.blue
= dstColor
.blue
| srcColor
.blue
;
231 case wxOR_INVERT
: // (NOT src) OR dst
232 dstColor
.red
= dstColor
.red
| ~srcColor
.red
;
233 dstColor
.green
= dstColor
.green
| ~srcColor
.green
;
234 dstColor
.blue
= dstColor
.blue
| ~srcColor
.blue
;
237 case wxOR_REVERSE
: // src OR (NOT dst)
238 dstColor
.red
= ~dstColor
.red
| srcColor
.red
;
239 dstColor
.green
= ~dstColor
.green
| srcColor
.green
;
240 dstColor
.blue
= ~dstColor
.blue
| srcColor
.blue
;
244 dstColor
.red
= 0xFFFF ;
245 dstColor
.green
= 0xFFFF ;
246 dstColor
.blue
= 0xFFFF ;
249 case wxSRC_INVERT
: // (NOT src)
250 dstColor
.red
= ~srcColor
.red
;
251 dstColor
.green
= ~srcColor
.green
;
252 dstColor
.blue
= ~srcColor
.blue
;
255 case wxXOR
: // src XOR dst
256 dstColor
.red
= dstColor
.red
^ srcColor
.red
;
257 dstColor
.green
= dstColor
.green
^ srcColor
.green
;
258 dstColor
.blue
= dstColor
.blue
^ srcColor
.blue
;
271 m_mm_to_pix_x
= mm2pt
;
272 m_mm_to_pix_y
= mm2pt
;
273 m_internalDeviceOriginX
= 0;
274 m_internalDeviceOriginY
= 0;
275 m_externalDeviceOriginX
= 0;
276 m_externalDeviceOriginY
= 0;
277 m_logicalScaleX
= 1.0;
278 m_logicalScaleY
= 1.0;
283 m_needComputeScaleX
= false;
284 m_needComputeScaleY
= false;
287 m_macFontInstalled
= false ;
288 m_macBrushInstalled
= false ;
289 m_macPenInstalled
= false ;
290 m_macLocalOrigin
.x
= m_macLocalOrigin
.y
= 0 ;
291 m_macBoundaryClipRgn
= NewRgn() ;
292 m_macCurrentClipRgn
= NewRgn() ;
293 SetRectRgn( (RgnHandle
) m_macBoundaryClipRgn
, -32000 , -32000 , 32000 , 32000 ) ;
294 SetRectRgn( (RgnHandle
) m_macCurrentClipRgn
, -32000 , -32000 , 32000 , 32000 ) ;
295 m_pen
= *wxBLACK_PEN
;
296 m_font
= *wxNORMAL_FONT
;
297 m_brush
= *wxWHITE_BRUSH
;
300 // needed to debug possible errors with two active drawing methods at the same time on
302 m_macCurrentPortStateHelper
= NULL
;
305 m_macATSUIStyle
= NULL
;
306 m_macAliasWasEnabled
= false;
307 m_macForegroundPixMap
= NULL
;
308 m_macBackgroundPixMap
= NULL
;
313 DisposeRgn( (RgnHandle
) m_macBoundaryClipRgn
) ;
314 DisposeRgn( (RgnHandle
) m_macCurrentClipRgn
) ;
317 void wxDC::MacSetupPort(wxMacPortStateHelper
* help
) const
320 wxASSERT( m_macCurrentPortStateHelper
== NULL
) ;
321 m_macCurrentPortStateHelper
= help
;
324 SetClip( (RgnHandle
) m_macCurrentClipRgn
);
326 #if ! wxMAC_EXPERIMENTAL_DC
327 m_macFontInstalled
= false ;
328 m_macBrushInstalled
= false ;
329 m_macPenInstalled
= false ;
333 void wxDC::MacCleanupPort(wxMacPortStateHelper
* help
) const
336 wxASSERT( m_macCurrentPortStateHelper
== help
) ;
337 m_macCurrentPortStateHelper
= NULL
;
340 if ( m_macATSUIStyle
)
342 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUIStyle
);
343 m_macATSUIStyle
= NULL
;
346 if ( m_macAliasWasEnabled
)
348 SetAntiAliasedTextEnabled(m_macFormerAliasState
, m_macFormerAliasSize
);
349 m_macAliasWasEnabled
= false ;
352 if ( m_macForegroundPixMap
)
355 ::PenPat(GetQDGlobalsBlack(&blackColor
));
356 DisposePixPat( (PixPatHandle
) m_macForegroundPixMap
) ;
357 m_macForegroundPixMap
= NULL
;
360 if ( m_macBackgroundPixMap
)
363 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
364 DisposePixPat( (PixPatHandle
) m_macBackgroundPixMap
) ;
365 m_macBackgroundPixMap
= NULL
;
369 void wxDC::DoDrawBitmap( const wxBitmap
&bmp
, wxCoord x
, wxCoord y
, bool useMask
)
371 wxCHECK_RET( Ok(), wxT("wxDC::DoDrawBitmap - invalid DC") );
372 wxCHECK_RET( bmp
.Ok(), wxT("wxDC::DoDrawBitmap - invalid bitmap") );
374 wxMacFastPortSetter
helper(this) ;
375 wxCoord xx
= XLOG2DEVMAC(x
);
376 wxCoord yy
= YLOG2DEVMAC(y
);
377 wxCoord w
= bmp
.GetWidth();
378 wxCoord h
= bmp
.GetHeight();
379 wxCoord ww
= XLOG2DEVREL(w
);
380 wxCoord hh
= YLOG2DEVREL(h
);
382 // Set up drawing mode
383 short mode
= (m_logicalFunction
== wxCOPY
? srcCopy
:
384 //m_logicalFunction == wxCLEAR ? WHITENESS :
385 //m_logicalFunction == wxSET ? BLACKNESS :
386 m_logicalFunction
== wxINVERT
? hilite
:
387 //m_logicalFunction == wxAND ? MERGECOPY :
388 m_logicalFunction
== wxOR
? srcOr
:
389 m_logicalFunction
== wxSRC_INVERT
? notSrcCopy
:
390 m_logicalFunction
== wxXOR
? srcXor
:
391 m_logicalFunction
== wxOR_REVERSE
? notSrcOr
:
392 //m_logicalFunction == wxAND_REVERSE ? SRCERASE :
393 //m_logicalFunction == wxSRC_OR ? srcOr :
394 //m_logicalFunction == wxSRC_AND ? SRCAND :
397 GWorldPtr maskworld
= NULL
;
398 GWorldPtr bmapworld
= MAC_WXHBITMAP( bmp
.GetHBITMAP((WXHBITMAP
*)&maskworld
) );
399 PixMapHandle bmappixels
;
401 // Set foreground and background colours (for bitmaps depth = 1)
402 if (bmp
.GetDepth() == 1)
404 RGBColor fore
= MAC_WXCOLORREF(m_textForegroundColour
.GetPixel());
405 RGBColor back
= MAC_WXCOLORREF(m_textBackgroundColour
.GetPixel());
411 RGBColor white
= { 0xFFFF, 0xFFFF, 0xFFFF } ;
412 RGBColor black
= { 0, 0, 0 } ;
413 RGBForeColor( &black
) ;
414 RGBBackColor( &white
) ;
416 bmappixels
= GetGWorldPixMap( bmapworld
) ;
418 wxCHECK_RET(LockPixels(bmappixels
),
419 wxT("wxDC::DoDrawBitmap - failed to lock pixels"));
421 Rect source
= { 0, 0, h
, w
};
422 Rect dest
= { yy
, xx
, yy
+ hh
, xx
+ ww
};
423 if ( useMask
&& maskworld
)
425 if ( LockPixels(GetGWorldPixMap(MAC_WXHBITMAP(maskworld
))))
429 GetPortBitMapForCopyBits(bmapworld
),
430 GetPortBitMapForCopyBits(MAC_WXHBITMAP(maskworld
)),
431 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ),
432 &source
, &source
, &dest
, mode
, NULL
434 UnlockPixels(GetGWorldPixMap(MAC_WXHBITMAP(maskworld
)));
439 CopyBits( GetPortBitMapForCopyBits( bmapworld
),
440 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ),
441 &source
, &dest
, mode
, NULL
) ;
443 UnlockPixels( bmappixels
) ;
445 m_macPenInstalled
= false ;
446 m_macBrushInstalled
= false ;
447 m_macFontInstalled
= false ;
450 void wxDC::DoDrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
)
452 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawIcon - invalid DC"));
453 wxCHECK_RET(icon
.Ok(), wxT("wxDC::DoDrawIcon - invalid icon"));
455 wxMacFastPortSetter
helper(this) ;
457 wxCoord xx
= XLOG2DEVMAC(x
);
458 wxCoord yy
= YLOG2DEVMAC(y
);
459 wxCoord w
= icon
.GetWidth();
460 wxCoord h
= icon
.GetHeight();
461 wxCoord ww
= XLOG2DEVREL(w
);
462 wxCoord hh
= YLOG2DEVREL(h
);
464 Rect r
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
465 PlotIconRef( &r
, kAlignNone
, kTransformNone
, kPlotIconRefNormalFlags
, MAC_WXHICON( icon
.GetHICON() ) ) ;
468 void wxDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
470 wxCHECK_RET(Ok(), wxT("wxDC::DoSetClippingRegion - invalid DC"));
472 wxCoord xx
, yy
, ww
, hh
;
475 ww
= XLOG2DEVREL(width
);
476 hh
= YLOG2DEVREL(height
);
478 SetRectRgn( (RgnHandle
) m_macCurrentClipRgn
, xx
, yy
, xx
+ ww
, yy
+ hh
) ;
479 SectRgn( (RgnHandle
) m_macCurrentClipRgn
, (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
482 m_clipX1
= wxMax( m_clipX1
, xx
);
483 m_clipY1
= wxMax( m_clipY1
, yy
);
484 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
) );
485 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
) );
497 void wxDC::DoSetClippingRegionAsRegion( const wxRegion
®ion
)
499 wxCHECK_RET(Ok(), wxT("wxDC::DoSetClippingRegionAsRegion - invalid DC"));
501 wxMacFastPortSetter
helper(this) ;
503 region
.GetBox( x
, y
, w
, h
);
504 wxCoord xx
, yy
, ww
, hh
;
510 // if we have a scaling that we cannot map onto native regions
511 // we must use the box
512 if ( ww
!= w
|| hh
!= h
)
514 wxDC::DoSetClippingRegion( x
, y
, w
, h
);
518 CopyRgn( (RgnHandle
) region
.GetWXHRGN() , (RgnHandle
) m_macCurrentClipRgn
) ;
519 if ( xx
!= x
|| yy
!= y
)
520 OffsetRgn( (RgnHandle
) m_macCurrentClipRgn
, xx
- x
, yy
- y
) ;
522 SectRgn( (RgnHandle
) m_macCurrentClipRgn
, (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
525 m_clipX1
= wxMax( m_clipX1
, xx
);
526 m_clipY1
= wxMax( m_clipY1
, yy
);
527 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
) );
528 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
) );
541 void wxDC::DestroyClippingRegion()
543 wxMacFastPortSetter
helper(this) ;
545 CopyRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
549 void wxDC::DoGetSizeMM( int* width
, int* height
) const
555 *width
= long( double(w
) / (m_scaleX
* m_mm_to_pix_x
) );
557 *height
= long( double(h
) / (m_scaleY
* m_mm_to_pix_y
) );
560 void wxDC::SetTextForeground( const wxColour
&col
)
562 wxCHECK_RET(Ok(), wxT("wxDC::SetTextForeground - invalid DC"));
564 m_textForegroundColour
= col
;
565 m_macFontInstalled
= false ;
568 void wxDC::SetTextBackground( const wxColour
&col
)
570 wxCHECK_RET(Ok(), wxT("wxDC::SetTextBackground - invalid DC"));
572 m_textBackgroundColour
= col
;
573 m_macFontInstalled
= false ;
576 void wxDC::SetMapMode( int mode
)
581 SetLogicalScale( twips2mm
* m_mm_to_pix_x
, twips2mm
* m_mm_to_pix_y
);
585 SetLogicalScale( pt2mm
* m_mm_to_pix_x
, pt2mm
* m_mm_to_pix_y
);
589 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
593 SetLogicalScale( m_mm_to_pix_x
/ 10.0, m_mm_to_pix_y
/ 10.0 );
598 SetLogicalScale( 1.0, 1.0 );
602 if (mode
!= wxMM_TEXT
)
604 m_needComputeScaleX
= true;
605 m_needComputeScaleY
= true;
609 void wxDC::SetUserScale( double x
, double y
)
611 // allow negative ? -> no
614 ComputeScaleAndOrigin();
617 void wxDC::SetLogicalScale( double x
, double y
)
622 ComputeScaleAndOrigin();
625 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
627 // is this still correct ?
628 m_logicalOriginX
= x
* m_signX
;
629 m_logicalOriginY
= y
* m_signY
;
630 ComputeScaleAndOrigin();
633 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
635 m_externalDeviceOriginX
= x
;
636 m_externalDeviceOriginY
= y
;
637 ComputeScaleAndOrigin();
640 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
642 m_signX
= (xLeftRight
? 1 : -1);
643 m_signY
= (yBottomUp
? -1 : 1);
644 ComputeScaleAndOrigin();
647 wxSize
wxDC::GetPPI() const
649 return wxSize(72, 72);
652 int wxDC::GetDepth() const
654 if ( IsPortColor( (CGrafPtr
) m_macPort
) )
655 return ( (**GetPortPixMap( (CGrafPtr
) m_macPort
)).pixelSize
) ;
660 void wxDC::ComputeScaleAndOrigin()
662 // CMB: copy scale to see if it changes
663 double origScaleX
= m_scaleX
;
664 double origScaleY
= m_scaleY
;
665 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
666 m_scaleY
= m_logicalScaleY
* m_userScaleY
;
667 m_deviceOriginX
= m_internalDeviceOriginX
+ m_externalDeviceOriginX
;
668 m_deviceOriginY
= m_internalDeviceOriginY
+ m_externalDeviceOriginY
;
670 // CMB: if scale has changed call SetPen to recalulate the line width
671 if (m_scaleX
!= origScaleX
|| m_scaleY
!= origScaleY
)
673 // this is a bit artificial, but we need to force wxDC to think
674 // the pen has changed
681 void wxDC::SetPalette( const wxPalette
& palette
)
685 void wxDC::SetBackgroundMode( int mode
)
687 m_backgroundMode
= mode
;
690 void wxDC::SetFont( const wxFont
&font
)
693 m_macFontInstalled
= false ;
696 void wxDC::SetPen( const wxPen
&pen
)
702 m_macPenInstalled
= false ;
705 void wxDC::SetBrush( const wxBrush
&brush
)
707 if (m_brush
== brush
)
711 m_macBrushInstalled
= false ;
714 void wxDC::SetBackground( const wxBrush
&brush
)
716 if (m_backgroundBrush
== brush
)
719 m_backgroundBrush
= brush
;
720 if (m_backgroundBrush
.Ok())
721 m_macBrushInstalled
= false ;
724 void wxDC::SetLogicalFunction( int function
)
726 if (m_logicalFunction
== function
)
729 m_logicalFunction
= function
;
730 m_macFontInstalled
= false ;
731 m_macBrushInstalled
= false ;
732 m_macPenInstalled
= false ;
735 extern bool wxDoFloodFill(wxDC
*dc
, wxCoord x
, wxCoord y
,
736 const wxColour
& col
, int style
);
738 bool wxDC::DoFloodFill(wxCoord x
, wxCoord y
,
739 const wxColour
& col
, int style
)
741 return wxDoFloodFill(this, x
, y
, col
, style
);
744 bool wxDC::DoGetPixel( wxCoord x
, wxCoord y
, wxColour
*col
) const
746 wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel - invalid DC") );
748 wxMacFastPortSetter
helper(this) ;
750 // NOTE: Get/SetCPixel are slow!
752 GetCPixel( XLOG2DEVMAC(x
), YLOG2DEVMAC(y
), &colour
);
754 // convert from Mac colour to wx
755 col
->Set( colour
.red
>> 8, colour
.green
>> 8, colour
.blue
>> 8);
760 void wxDC::DoDrawLine( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
762 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawLine - invalid DC"));
764 wxMacFastPortSetter
helper(this) ;
766 if (m_pen
.GetStyle() != wxTRANSPARENT
)
769 wxCoord offset
= ( (m_pen
.GetWidth() == 0 ? 1 :
770 m_pen
.GetWidth() ) * (wxCoord
)m_scaleX
- 1) / 2;
771 wxCoord xx1
= XLOG2DEVMAC(x1
) - offset
;
772 wxCoord yy1
= YLOG2DEVMAC(y1
) - offset
;
773 wxCoord xx2
= XLOG2DEVMAC(x2
) - offset
;
774 wxCoord yy2
= YLOG2DEVMAC(y2
) - offset
;
776 if ((m_pen
.GetCap() == wxCAP_ROUND
) &&
777 (m_pen
.GetWidth() <= 1))
779 // Implement LAST_NOT for MAC at least for
780 // orthogonal lines. RR.
803 void wxDC::DoCrossHair( wxCoord x
, wxCoord y
)
805 wxCHECK_RET(Ok(), wxT("wxDC::DoCrossHair - invalid DC"));
807 wxMacFastPortSetter
helper(this) ;
809 if (m_pen
.GetStyle() != wxTRANSPARENT
)
814 wxCoord xx
= XLOG2DEVMAC(x
);
815 wxCoord yy
= YLOG2DEVMAC(y
);
818 ::MoveTo( XLOG2DEVMAC(0), yy
);
819 ::LineTo( XLOG2DEVMAC(w
), yy
);
820 ::MoveTo( xx
, YLOG2DEVMAC(0) );
821 ::LineTo( xx
, YLOG2DEVMAC(h
) );
822 CalcBoundingBox(x
, y
);
823 CalcBoundingBox(x
+ w
, y
+ h
);
828 * To draw arcs properly the angles need to be converted from the WX style:
829 * Angles start on the +ve X axis and go anti-clockwise (As you would draw on
830 * a normal axis on paper).
833 * Angles start on the +ve y axis and go clockwise.
836 static double wxConvertWXangleToMACangle(double angle
)
838 double newAngle
= 90 - angle
;
840 while ( newAngle
> 360 )
842 while ( newAngle
< 0 )
848 void wxDC::DoDrawArc( wxCoord x1
, wxCoord y1
,
849 wxCoord x2
, wxCoord y2
,
850 wxCoord xc
, wxCoord yc
)
852 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawArc - invalid DC"));
854 wxMacFastPortSetter
helper(this) ;
856 wxCoord xx1
= XLOG2DEVMAC(x1
);
857 wxCoord yy1
= YLOG2DEVMAC(y1
);
858 wxCoord xx2
= XLOG2DEVMAC(x2
);
859 wxCoord yy2
= YLOG2DEVMAC(y2
);
860 wxCoord xxc
= XLOG2DEVMAC(xc
);
861 wxCoord yyc
= YLOG2DEVMAC(yc
);
863 double dx
= xx1
- xxc
;
864 double dy
= yy1
- yyc
;
865 double radius
= sqrt((double)(dx
* dx
+ dy
* dy
));
866 wxCoord rad
= (wxCoord
)radius
;
867 double radius1
, radius2
;
869 if (xx1
== xx2
&& yy1
== yy2
)
874 else if (radius
== 0.0)
876 radius1
= radius2
= 0.0;
880 radius1
= (xx1
- xxc
== 0) ?
881 (yy1
- yyc
< 0) ? 90.0 : -90.0 :
882 -atan2(double(yy1
- yyc
), double(xx1
- xxc
)) * RAD2DEG
;
883 radius2
= (xx2
- xxc
== 0) ?
884 (yy2
- yyc
< 0) ? 90.0 : -90.0 :
885 -atan2(double(yy2
- yyc
), double(xx2
- xxc
)) * RAD2DEG
;
888 wxCoord alpha2
= wxCoord(radius2
- radius1
);
889 wxCoord alpha1
= wxCoord(wxConvertWXangleToMACangle(radius1
));
893 Rect r
= { yyc
- rad
, xxc
- rad
, yyc
+ rad
, xxc
+ rad
};
895 if (m_brush
.GetStyle() != wxTRANSPARENT
)
898 PaintArc(&r
, alpha1
, alpha2
);
901 if (m_pen
.GetStyle() != wxTRANSPARENT
)
904 FrameArc(&r
, alpha1
, alpha2
);
908 void wxDC::DoDrawEllipticArc( wxCoord x
, wxCoord y
, wxCoord w
, wxCoord h
,
909 double sa
, double ea
)
911 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawEllepticArc - invalid DC"));
912 wxMacFastPortSetter
helper(this) ;
915 // Order important Mac in opposite direction to wx
916 // we have to make sure that the filling is always counter-clockwise
917 double angle
= sa
- ea
;
921 wxCoord xx
= XLOG2DEVMAC(x
);
922 wxCoord yy
= YLOG2DEVMAC(y
);
923 wxCoord ww
= m_signX
* XLOG2DEVREL(w
);
924 wxCoord hh
= m_signY
* YLOG2DEVREL(h
);
926 // handle -ve width and/or height
939 sa
= wxConvertWXangleToMACangle(sa
);
945 if (m_brush
.GetStyle() != wxTRANSPARENT
)
948 PaintArc(&r
, (short)sa
, (short)angle
);
951 if (m_pen
.GetStyle() != wxTRANSPARENT
)
954 FrameArc(&r
, (short)sa
, (short)angle
);
958 void wxDC::DoDrawPoint( wxCoord x
, wxCoord y
)
960 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawPoint - invalid DC"));
962 wxMacFastPortSetter
helper(this) ;
964 if (m_pen
.GetStyle() != wxTRANSPARENT
)
966 wxCoord xx1
= XLOG2DEVMAC(x
);
967 wxCoord yy1
= YLOG2DEVMAC(y
);
968 RGBColor pencolor
= MAC_WXCOLORREF( m_pen
.GetColour().GetPixel());
970 // NOTE: Get/SetCPixel are slow!
971 ::SetCPixel( xx1
, yy1
, &pencolor
) ;
972 CalcBoundingBox(x
, y
);
976 void wxDC::DoDrawLines(int n
, wxPoint points
[],
977 wxCoord xoffset
, wxCoord yoffset
)
979 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawLines - invalid DC"));
981 if (m_pen
.GetStyle() == wxTRANSPARENT
)
984 wxMacFastPortSetter
helper(this) ;
987 wxCoord offset
= ( (m_pen
.GetWidth() == 0 ? 1 :
988 m_pen
.GetWidth() ) * (wxCoord
)m_scaleX
- 1) / 2 ;
990 wxCoord x1
, x2
, y1
, y2
;
991 x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
992 y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
994 ::MoveTo( x1
- offset
, y1
- offset
);
995 for (int i
= 0; i
< n
-1; i
++)
997 x2
= XLOG2DEVMAC(points
[i
+ 1].x
+ xoffset
);
998 y2
= YLOG2DEVMAC(points
[i
+ 1].y
+ yoffset
);
999 ::LineTo( x2
- offset
, y2
- offset
);
1003 void wxDC::DoDrawPolygon(int n
, wxPoint points
[],
1004 wxCoord xoffset
, wxCoord yoffset
,
1007 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawPolygon - invalid DC"));
1009 if ( m_brush
.GetStyle() == wxTRANSPARENT
&& m_pen
.GetStyle() == wxTRANSPARENT
)
1012 wxMacFastPortSetter
helper(this) ;
1014 wxCoord x1
, x2
, y1
, y2
;
1015 PolyHandle polygon
= OpenPoly();
1016 x2
= x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
1017 y2
= y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
1020 for (int i
= 1; i
< n
; i
++)
1022 x2
= XLOG2DEVMAC(points
[i
].x
+ xoffset
);
1023 y2
= YLOG2DEVMAC(points
[i
].y
+ yoffset
);
1027 // close the polyline if necessary
1028 if ( x1
!= x2
|| y1
!= y2
)
1029 ::LineTo( x1
, y1
) ;
1032 if (m_brush
.GetStyle() != wxTRANSPARENT
)
1035 ::PaintPoly( polygon
);
1038 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1041 ::FramePoly( polygon
) ;
1044 KillPoly( polygon
);
1047 void wxDC::DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1049 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawRectangle - invalid DC"));
1051 wxMacFastPortSetter
helper(this) ;
1053 wxCoord xx
= XLOG2DEVMAC(x
);
1054 wxCoord yy
= YLOG2DEVMAC(y
);
1055 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1056 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1058 // CMB: draw nothing if transformed w or h is 0
1059 if (ww
== 0 || hh
== 0)
1062 // CMB: handle -ve width and/or height
1075 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
1077 if (m_brush
.GetStyle() != wxTRANSPARENT
)
1080 ::PaintRect( &rect
) ;
1083 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1086 ::FrameRect( &rect
) ;
1090 void wxDC::DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
1091 wxCoord width
, wxCoord height
,
1094 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawRoundedRectangle - invalid DC"));
1096 wxMacFastPortSetter
helper(this) ;
1098 radius
= - radius
* ((width
< height
) ? width
: height
);
1099 wxCoord xx
= XLOG2DEVMAC(x
);
1100 wxCoord yy
= YLOG2DEVMAC(y
);
1101 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1102 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1104 // CMB: draw nothing if transformed w or h is 0
1105 if (ww
== 0 || hh
== 0)
1108 // CMB: handle -ve width and/or height
1121 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
1123 if (m_brush
.GetStyle() != wxTRANSPARENT
)
1126 ::PaintRoundRect( &rect
, int(radius
* 2) , int(radius
* 2) ) ;
1129 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1132 ::FrameRoundRect( &rect
, int(radius
* 2) , int(radius
* 2) ) ;
1136 void wxDC::DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1138 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawEllipse - invalid DC"));
1140 wxMacFastPortSetter
helper(this) ;
1142 wxCoord xx
= XLOG2DEVMAC(x
);
1143 wxCoord yy
= YLOG2DEVMAC(y
);
1144 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1145 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1147 // CMB: draw nothing if transformed w or h is 0
1148 if (ww
== 0 || hh
== 0)
1151 // CMB: handle -ve width and/or height
1164 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
1166 if (m_brush
.GetStyle() != wxTRANSPARENT
)
1169 ::PaintOval( &rect
) ;
1172 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1175 ::FrameOval( &rect
) ;
1179 bool wxDC::CanDrawBitmap(void) const
1184 bool wxDC::DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1185 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
, int logical_func
, bool useMask
,
1186 wxCoord xsrcMask
, wxCoord ysrcMask
)
1188 wxCHECK_MSG(Ok(), false, wxT("wxDC::DoBlit - invalid DC"));
1189 wxCHECK_MSG(source
->Ok(), false, wxT("wxDC::DoBlit - invalid source DC"));
1191 if ( logical_func
== wxNO_OP
)
1194 if (xsrcMask
== -1 && ysrcMask
== -1)
1200 // correct the parameter in case this dc does not have a mask at all
1201 if ( useMask
&& !source
->m_macMask
)
1204 Rect srcrect
, dstrect
;
1205 srcrect
.top
= source
->YLOG2DEVMAC(ysrc
) ;
1206 srcrect
.left
= source
->XLOG2DEVMAC(xsrc
) ;
1207 srcrect
.right
= source
->XLOG2DEVMAC(xsrc
+ width
) ;
1208 srcrect
.bottom
= source
->YLOG2DEVMAC(ysrc
+ height
) ;
1209 dstrect
.top
= YLOG2DEVMAC(ydest
) ;
1210 dstrect
.left
= XLOG2DEVMAC(xdest
) ;
1211 dstrect
.bottom
= YLOG2DEVMAC(ydest
+ height
) ;
1212 dstrect
.right
= XLOG2DEVMAC(xdest
+ width
) ;
1213 short mode
= kUnsupportedMode
;
1214 bool invertDestinationFirst
= false ;
1216 switch ( logical_func
)
1218 case wxAND
: // src AND dst
1219 mode
= adMin
; // ok
1222 case wxAND_INVERT
: // (NOT src) AND dst
1223 mode
= notSrcOr
; // ok
1226 case wxAND_REVERSE
:// src AND (NOT dst)
1227 invertDestinationFirst
= true ;
1232 mode
= kEmulatedMode
;
1236 mode
= srcCopy
; // ok
1239 case wxEQUIV
: // (NOT src) XOR dst
1240 mode
= srcXor
; // ok
1243 case wxINVERT
: // NOT dst
1244 mode
= kEmulatedMode
; //or hilite ;
1247 case wxNAND
: // (NOT src) OR (NOT dst)
1248 invertDestinationFirst
= true ;
1252 case wxNOR
: // (NOT src) AND (NOT dst)
1253 invertDestinationFirst
= true ;
1257 case wxNO_OP
: // dst
1258 mode
= kEmulatedMode
; // this has already been handled upon entry
1261 case wxOR
: // src OR dst
1265 case wxOR_INVERT
: // (NOT src) OR dst
1269 case wxOR_REVERSE
: // src OR (NOT dst)
1270 invertDestinationFirst
= true ;
1275 mode
= kEmulatedMode
;
1278 case wxSRC_INVERT
: // (NOT src)
1279 mode
= notSrcCopy
; // ok
1282 case wxXOR
: // src XOR dst
1283 mode
= notSrcXor
; // ok
1290 if ( mode
== kUnsupportedMode
)
1292 wxFAIL_MSG(wxT("unsupported blitting mode" ));
1297 CGrafPtr sourcePort
= (CGrafPtr
) source
->m_macPort
;
1298 PixMapHandle bmappixels
= GetGWorldPixMap( sourcePort
) ;
1299 if ( LockPixels(bmappixels
) )
1301 wxMacFastPortSetter
helper(this) ;
1303 if ( source
->GetDepth() == 1 )
1305 RGBForeColor( &MAC_WXCOLORREF(m_textForegroundColour
.GetPixel()) ) ;
1306 RGBBackColor( &MAC_WXCOLORREF(m_textBackgroundColour
.GetPixel()) ) ;
1310 // the modes need this, otherwise we'll end up having really nice colors...
1311 RGBColor white
= { 0xFFFF, 0xFFFF, 0xFFFF } ;
1312 RGBColor black
= { 0, 0, 0 } ;
1314 RGBForeColor( &black
) ;
1315 RGBBackColor( &white
) ;
1318 if ( useMask
&& source
->m_macMask
)
1320 if ( mode
== srcCopy
)
1322 if ( LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) )
1324 CopyMask( GetPortBitMapForCopyBits( sourcePort
) ,
1325 GetPortBitMapForCopyBits( MAC_WXHBITMAP(source
->m_macMask
) ) ,
1326 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1327 &srcrect
, &srcrect
, &dstrect
) ;
1328 UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1333 RgnHandle clipRgn
= NewRgn() ;
1334 LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1335 BitMapToRegion( clipRgn
, (BitMap
*) *GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1336 UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1337 OffsetRgn( clipRgn
, -srcrect
.left
+ dstrect
.left
, -srcrect
.top
+ dstrect
.top
) ;
1339 if ( mode
== kEmulatedMode
)
1343 ::PenPat(GetQDGlobalsBlack(&pat
));
1344 if ( logical_func
== wxSET
)
1346 RGBColor col
= { 0xFFFF, 0xFFFF, 0xFFFF } ;
1347 ::RGBForeColor( &col
) ;
1348 ::PaintRgn( clipRgn
) ;
1350 else if ( logical_func
== wxCLEAR
)
1352 RGBColor col
= { 0x0000, 0x0000, 0x0000 } ;
1353 ::RGBForeColor( &col
) ;
1354 ::PaintRgn( clipRgn
) ;
1356 else if ( logical_func
== wxINVERT
)
1358 MacInvertRgn( clipRgn
) ;
1362 for ( int y
= 0 ; y
< srcrect
.right
- srcrect
.left
; ++y
)
1364 for ( int x
= 0 ; x
< srcrect
.bottom
- srcrect
.top
; ++x
)
1366 Point dstPoint
= { dstrect
.top
+ y
, dstrect
.left
+ x
} ;
1367 Point srcPoint
= { srcrect
.top
+ y
, srcrect
.left
+ x
} ;
1368 if ( PtInRgn( dstPoint
, clipRgn
) )
1370 RGBColor srcColor
, dstColor
;
1372 // NOTE: Get/SetCPixel are slow!
1373 SetPort( (GrafPtr
) sourcePort
) ;
1374 GetCPixel( srcPoint
.h
, srcPoint
.v
, &srcColor
) ;
1375 SetPort( (GrafPtr
) m_macPort
) ;
1376 GetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1377 wxMacCalculateColour( logical_func
, srcColor
, dstColor
) ;
1378 SetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1386 if ( invertDestinationFirst
)
1387 MacInvertRgn( clipRgn
) ;
1389 CopyBits( GetPortBitMapForCopyBits( sourcePort
) ,
1390 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1391 &srcrect
, &dstrect
, mode
, clipRgn
) ;
1394 DisposeRgn( clipRgn
) ;
1399 RgnHandle clipRgn
= NewRgn() ;
1400 SetRectRgn( clipRgn
, dstrect
.left
, dstrect
.top
, dstrect
.right
, dstrect
.bottom
) ;
1402 if ( mode
== kEmulatedMode
)
1406 ::PenPat(GetQDGlobalsBlack(&pat
));
1407 if ( logical_func
== wxSET
)
1409 RGBColor col
= { 0xFFFF, 0xFFFF, 0xFFFF } ;
1410 ::RGBForeColor( &col
) ;
1411 ::PaintRgn( clipRgn
) ;
1413 else if ( logical_func
== wxCLEAR
)
1415 RGBColor col
= { 0x0000, 0x0000, 0x0000 } ;
1417 ::RGBForeColor( &col
) ;
1418 ::PaintRgn( clipRgn
) ;
1420 else if ( logical_func
== wxINVERT
)
1422 MacInvertRgn( clipRgn
) ;
1426 for ( int y
= 0 ; y
< srcrect
.right
- srcrect
.left
; ++y
)
1428 for ( int x
= 0 ; x
< srcrect
.bottom
- srcrect
.top
; ++x
)
1430 Point dstPoint
= { dstrect
.top
+ y
, dstrect
.left
+ x
} ;
1431 Point srcPoint
= { srcrect
.top
+ y
, srcrect
.left
+ x
} ;
1433 RGBColor srcColor
, dstColor
;
1435 // NOTE: Get/SetCPixel are slow!
1436 SetPort( (GrafPtr
) sourcePort
) ;
1437 GetCPixel( srcPoint
.h
, srcPoint
.v
, &srcColor
) ;
1438 SetPort( (GrafPtr
) m_macPort
) ;
1439 GetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1440 wxMacCalculateColour( logical_func
, srcColor
, dstColor
) ;
1441 SetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1449 if ( invertDestinationFirst
)
1450 MacInvertRgn( clipRgn
) ;
1452 CopyBits( GetPortBitMapForCopyBits( sourcePort
) ,
1453 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1454 &srcrect
, &dstrect
, mode
, NULL
) ;
1457 DisposeRgn( clipRgn
) ;
1460 UnlockPixels( bmappixels
) ;
1463 m_macPenInstalled
= false ;
1464 m_macBrushInstalled
= false ;
1465 m_macFontInstalled
= false ;
1470 void wxDC::DoDrawRotatedText(const wxString
& str
, wxCoord x
, wxCoord y
,
1473 // TODO: support text background color (only possible by hand, ATSUI does not support it)
1474 wxCHECK_RET( Ok(), wxT("wxDC::DoDrawRotatedText - invalid DC") );
1476 if ( str
.Length() == 0 )
1479 wxMacFastPortSetter
helper(this) ;
1485 m_macFormerAliasState
= IsAntiAliasedTextEnabled(&m_macFormerAliasSize
);
1486 SetAntiAliasedTextEnabled(true, SInt16(m_scaleY
* m_font
.MacGetFontSize()));
1487 m_macAliasWasEnabled
= true ;
1491 OSStatus status
= noErr
;
1492 ATSUTextLayout atsuLayout
;
1493 UniCharCount chars
= str
.Length() ;
1494 UniChar
* ubuf
= NULL
;
1496 #if SIZEOF_WCHAR_T == 4
1497 wxMBConvUTF16 converter
;
1499 size_t unicharlen
= converter
.WC2MB( NULL
, str
.wc_str() , 0 ) ;
1500 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1501 converter
.WC2MB( (char*) ubuf
, str
.wc_str(), unicharlen
+ 2 ) ;
1503 const wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1504 size_t unicharlen
= converter
.WC2MB( NULL
, wchar
.data() , 0 ) ;
1505 ubuf
= (UniChar
*) malloc( unicharlen
+ 2 ) ;
1506 converter
.WC2MB( (char*) ubuf
, wchar
.data() , unicharlen
+ 2 ) ;
1508 chars
= unicharlen
/ 2 ;
1511 ubuf
= (UniChar
*) str
.wc_str() ;
1513 wxWCharBuffer wchar
= str
.wc_str( wxConvLocal
) ;
1514 chars
= wxWcslen( wchar
.data() ) ;
1515 ubuf
= (UniChar
*) wchar
.data() ;
1519 status
= ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr
) ubuf
, 0 , chars
, chars
, 1 ,
1520 &chars
, (ATSUStyle
*) &m_macATSUIStyle
, &atsuLayout
) ;
1522 wxASSERT_MSG( status
== noErr
, wxT("couldn't create the layout of the rotated text") );
1524 status
= ::ATSUSetTransientFontMatching( atsuLayout
, true ) ;
1525 wxASSERT_MSG( status
== noErr
, wxT("couldn't setup transient font matching") );
1527 int iAngle
= int( angle
);
1528 int drawX
= XLOG2DEVMAC(x
) ;
1529 int drawY
= YLOG2DEVMAC(y
) ;
1531 ATSUTextMeasurement textBefore
, textAfter
;
1532 ATSUTextMeasurement ascent
, descent
;
1534 if ( abs(iAngle
) > 0 )
1536 Fixed atsuAngle
= IntToFixed( iAngle
) ;
1538 ATSUAttributeTag atsuTags
[] =
1540 kATSULineRotationTag
,
1542 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1546 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1551 status
= ::ATSUSetLayoutControls(atsuLayout
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
),
1552 atsuTags
, atsuSizes
, atsuValues
) ;
1555 status
= ::ATSUMeasureText( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1556 &textBefore
, &textAfter
, &ascent
, &descent
);
1558 drawX
+= (int)(sin(angle
/ RAD2DEG
) * FixedToInt(ascent
));
1559 drawY
+= (int)(cos(angle
/ RAD2DEG
) * FixedToInt(ascent
));
1560 status
= ::ATSUDrawText( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1561 IntToFixed(drawX
) , IntToFixed(drawY
) );
1563 wxASSERT_MSG( status
== noErr
, wxT("couldn't draw the rotated text") );
1566 status
= ::ATSUMeasureTextImage( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1567 IntToFixed(drawX
) , IntToFixed(drawY
) , &rect
);
1568 wxASSERT_MSG( status
== noErr
, wxT("couldn't measure the rotated text") );
1570 OffsetRect( &rect
, -m_macLocalOrigin
.x
, -m_macLocalOrigin
.y
) ;
1571 CalcBoundingBox(XDEV2LOG(rect
.left
), YDEV2LOG(rect
.top
) );
1572 CalcBoundingBox(XDEV2LOG(rect
.right
), YDEV2LOG(rect
.bottom
) );
1573 ::ATSUDisposeTextLayout(atsuLayout
);
1575 #if SIZEOF_WCHAR_T == 4
1580 void wxDC::DoDrawText(const wxString
& strtext
, wxCoord x
, wxCoord y
)
1582 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawText - invalid DC"));
1584 wxMacFastPortSetter
helper(this) ;
1585 long xx
= XLOG2DEVMAC(x
);
1586 long yy
= YLOG2DEVMAC(y
);
1589 bool useDrawThemeText
= ( DrawThemeTextBox
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1590 if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC
) ) || m_font
.GetNoAntiAliasing() )
1591 useDrawThemeText
= false ;
1597 ::GetFontInfo( &fi
) ;
1600 if ( !useDrawThemeText
)
1606 ::TextMode( (m_backgroundMode
== wxTRANSPARENT
) ? srcOr
: srcCopy
) ;
1607 ::MoveTo( xx
, yy
);
1611 wxString linetext
= strtext
;
1614 if ( useDrawThemeText
)
1617 yy
+ line
*(fi
.descent
+ fi
.ascent
+ fi
.leading
), xx
,
1618 yy
+ (line
+1)*(fi
.descent
+ fi
.ascent
+ fi
.leading
) , xx
+ 10000 } ;
1619 wxMacCFStringHolder
mString( linetext
, m_font
.GetEncoding()) ;
1621 if ( m_backgroundMode
!= wxTRANSPARENT
)
1623 Point bounds
= {0, 0} ;
1624 Rect background
= frame
;
1626 ::GetThemeTextDimensions( mString
,
1627 m_font
.MacGetThemeFontID() ,
1632 background
.right
= background
.left
+ bounds
.h
;
1633 background
.bottom
= background
.top
+ bounds
.v
;
1634 ::EraseRect( &background
) ;
1637 ::DrawThemeTextBox( mString
,
1638 m_font
.MacGetThemeFontID() ,
1648 wxCharBuffer text
= linetext
.mb_str(wxConvLocal
) ;
1649 ::DrawText( text
, 0 , strlen(text
) ) ;
1653 ::TextMode( srcOr
) ;
1656 bool wxDC::CanGetTextExtent() const
1658 wxCHECK_MSG(Ok(), false, wxT("wxDC::CanGetTextExtent - invalid DC"));
1663 void wxDC::DoGetTextExtent( const wxString
&strtext
, wxCoord
*width
, wxCoord
*height
,
1664 wxCoord
*descent
, wxCoord
*externalLeading
,
1665 wxFont
*theFont
) const
1667 wxCHECK_RET(Ok(), wxT("wxDC::DoGetTextExtent - invalid DC"));
1669 wxMacFastPortSetter
helper(this) ;
1670 wxFont formerFont
= m_font
;
1673 // work around the constness
1674 *((wxFont
*)(&m_font
)) = *theFont
;
1679 ::GetFontInfo( &fi
) ;
1682 bool useGetThemeText
= ( GetThemeTextDimensions
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1683 if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC
) ) || ((wxFont
*)&m_font
)->GetNoAntiAliasing() )
1684 useGetThemeText
= false ;
1688 *height
= YDEV2LOGREL( fi
.descent
+ fi
.ascent
) ;
1690 *descent
=YDEV2LOGREL( fi
.descent
);
1691 if ( externalLeading
)
1692 *externalLeading
= YDEV2LOGREL( fi
.leading
) ;
1698 wxString linetext
= strtext
;
1700 if ( useGetThemeText
)
1702 Point bounds
= {0, 0} ;
1704 wxMacCFStringHolder
mString( linetext
, m_font
.GetEncoding() ) ;
1705 ThemeFontID themeFont
= m_font
.MacGetThemeFontID() ;
1706 ::GetThemeTextDimensions( mString
,
1712 curwidth
= bounds
.h
;
1716 wxCharBuffer text
= linetext
.mb_str(wxConvLocal
) ;
1717 curwidth
= ::TextWidth( text
, 0 , strlen(text
) ) ;
1720 if ( curwidth
> *width
)
1721 *width
= XDEV2LOGREL( curwidth
) ;
1726 // work around the constness
1727 *((wxFont
*)(&m_font
)) = formerFont
;
1728 m_macFontInstalled
= false ;
1732 bool wxDC::DoGetPartialTextExtents(const wxString
& text
, wxArrayInt
& widths
) const
1734 wxCHECK_MSG(Ok(), false, wxT("wxDC::DoGetPartialTextExtents - invalid DC"));
1737 widths
.Add(0, text
.Length());
1739 if (text
.Length() == 0)
1742 wxMacFastPortSetter
helper(this) ;
1746 bool useGetThemeText
= ( GetThemeTextDimensions
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1747 if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC
) ) || ((wxFont
*)&m_font
)->GetNoAntiAliasing() )
1748 useGetThemeText
= false ;
1750 if ( useGetThemeText
)
1752 // If anybody knows how to do this more efficiently yet still handle
1753 // the fractional glyph widths that may be present when using AA
1754 // fonts, please change it. Currently it is measuring from the
1755 // beginning of the string for each succeeding substring, which is much
1756 // slower than this should be.
1757 for (size_t i
=0; i
<text
.Length(); i
++)
1759 wxString
str(text
.Left(i
+ 1));
1760 Point bounds
= {0, 0};
1762 wxMacCFStringHolder
mString(str
, m_font
.GetEncoding());
1764 ::GetThemeTextDimensions( mString
,
1765 m_font
.MacGetThemeFontID(),
1770 widths
[i
] = XDEV2LOGREL(bounds
.h
);
1776 wxCharBuffer buff
= text
.mb_str(wxConvLocal
);
1777 size_t len
= strlen(buff
);
1778 short* measurements
= new short[len
+1];
1779 MeasureText(len
, buff
.data(), measurements
);
1781 // Copy to widths, starting at measurements[1]
1782 // NOTE: this doesn't take into account any multi-byte characters
1783 // in buff, it probably should...
1784 for (size_t i
=0; i
<text
.Length(); i
++)
1785 widths
[i
] = XDEV2LOGREL(measurements
[i
+ 1]);
1787 delete [] measurements
;
1793 wxCoord
wxDC::GetCharWidth(void) const
1795 wxCHECK_MSG(Ok(), 1, wxT("wxDC::GetCharWidth - invalid DC"));
1797 wxMacFastPortSetter
helper(this) ;
1799 const char text
[] = "g" ;
1804 bool useGetThemeText
= ( GetThemeTextDimensions
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1805 if ( UMAGetSystemVersion() < 0x1000 || ((wxFont
*)&m_font
)->GetNoAntiAliasing() )
1806 useGetThemeText
= false ;
1808 if ( useGetThemeText
)
1810 Point bounds
= {0, 0} ;
1812 CFStringRef mString
= CFStringCreateWithBytes( NULL
, (UInt8
*) text
, 1 , CFStringGetSystemEncoding(), false ) ;
1813 ::GetThemeTextDimensions( mString
,
1814 m_font
.MacGetThemeFontID(),
1819 CFRelease( mString
) ;
1825 width
= ::TextWidth( text
, 0 , 1 ) ;
1828 return YDEV2LOGREL(width
) ;
1831 wxCoord
wxDC::GetCharHeight(void) const
1833 wxCHECK_MSG(Ok(), 1, wxT("wxDC::GetCharHeight - invalid DC"));
1835 wxMacFastPortSetter
helper(this) ;
1838 ::GetFontInfo( &fi
) ;
1840 return YDEV2LOGREL( fi
.descent
+ fi
.ascent
);
1843 void wxDC::Clear(void)
1845 wxCHECK_RET(Ok(), wxT("wxDC::Clear - invalid DC"));
1847 wxMacFastPortSetter
helper(this) ;
1848 Rect rect
= { -31000 , -31000 , 31000 , 31000 } ;
1850 if ( m_backgroundBrush
.Ok() && m_backgroundBrush
.GetStyle() != wxTRANSPARENT
)
1853 MacSetupBackgroundForCurrentPort( m_backgroundBrush
) ;
1854 ::EraseRect( &rect
) ;
1858 void wxDC::MacInstallFont() const
1860 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1862 // if ( m_macFontInstalled )
1865 Pattern blackColor
;
1866 MacSetupBackgroundForCurrentPort(m_backgroundBrush
) ;
1867 if ( m_backgroundMode
!= wxTRANSPARENT
)
1869 Pattern whiteColor
;
1870 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
1873 wxASSERT( m_font
.Ok() ) ;
1875 ::TextFont( m_font
.MacGetFontNum() ) ;
1876 ::TextSize( (short)(m_scaleY
* m_font
.MacGetFontSize()) ) ;
1877 ::TextFace( m_font
.MacGetFontStyle() ) ;
1878 m_macFontInstalled
= true ;
1879 m_macBrushInstalled
= false ;
1880 m_macPenInstalled
= false ;
1881 RGBColor forecolor
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel());
1882 RGBColor backcolor
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel());
1883 ::RGBForeColor( &forecolor
);
1884 ::RGBBackColor( &backcolor
);
1887 short mode
= patCopy
;
1888 switch ( m_logicalFunction
)
1894 case wxINVERT
: // NOT dst
1895 ::PenPat(GetQDGlobalsBlack(&blackColor
));
1899 case wxXOR
: // src XOR dst
1903 case wxOR_REVERSE
: // src OR (NOT dst)
1907 case wxSRC_INVERT
: // (NOT src)
1911 case wxAND
: // src AND dst
1915 // TODO: unsupported
1917 case wxAND_REVERSE
:// src AND (NOT dst)
1918 case wxAND_INVERT
: // (NOT src) AND dst
1919 case wxNO_OP
: // dst
1920 case wxNOR
: // (NOT src) AND (NOT dst)
1921 case wxEQUIV
: // (NOT src) XOR dst
1922 case wxOR_INVERT
: // (NOT src) OR dst
1923 case wxNAND
: // (NOT src) OR (NOT dst)
1924 case wxOR
: // src OR dst
1926 // case wxSRC_OR: // source _bitmap_ OR destination
1927 // case wxSRC_AND: // source _bitmap_ AND destination
1935 OSStatus status
= noErr
;
1936 status
= ATSUCreateAndCopyStyle( (ATSUStyle
) m_font
.MacGetATSUStyle() , (ATSUStyle
*) &m_macATSUIStyle
) ;
1937 wxASSERT_MSG( status
== noErr
, wxT("couldn't set create ATSU style") ) ;
1939 Fixed atsuSize
= IntToFixed( int(m_scaleY
* m_font
.MacGetFontSize()) ) ;
1940 ATSUAttributeTag atsuTags
[] =
1944 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1948 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1953 status
= ::ATSUSetAttributes((ATSUStyle
)m_macATSUIStyle
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
) ,
1954 atsuTags
, atsuSizes
, atsuValues
);
1956 wxASSERT_MSG( status
== noErr
, wxT("couldn't modify ATSU style") ) ;
1959 Pattern gPatterns
[] =
1962 { { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF } } ,
1963 { { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 } } ,
1964 { { 0x80 , 0x40 , 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , 0x01 } } ,
1965 { { 0x10 , 0x10 , 0x10 , 0xFF , 0x10 , 0x10 , 0x10 , 0x10 } } ,
1966 { { 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 } } ,
1967 { { 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 } } ,
1968 { { 0x81 , 0x42 , 0x24 , 0x18 , 0x18 , 0x24 , 0x42 , 0x81 } } ,
1971 { { 0xCC , 0x99 , 0x33 , 0x66 , 0xCC , 0x99 , 0x33 , 0x66 } } , // DOT
1972 { { 0xFE , 0xFD , 0xFB , 0xF7 , 0xEF , 0xDF , 0xBF , 0x7F } } , // LONG_DASH
1973 { { 0xEE , 0xDD , 0xBB , 0x77 , 0xEE , 0xDD , 0xBB , 0x77 } } , // SHORT_DASH
1974 { { 0xDE , 0xBD , 0x7B , 0xF6 , 0xED , 0xDB , 0xB7 , 0x6F } } , // DOT_DASH
1977 static void wxMacGetPattern(int penStyle
, Pattern
*pattern
)
1979 int index
= 0; // solid pattern by default
1983 case wxBDIAGONAL_HATCH
: index
= 1; break;
1984 case wxFDIAGONAL_HATCH
: index
= 2; break;
1985 case wxCROSS_HATCH
: index
= 3; break;
1986 case wxHORIZONTAL_HATCH
: index
= 4; break;
1987 case wxVERTICAL_HATCH
: index
= 5; break;
1988 case wxCROSSDIAG_HATCH
: index
= 6; break;
1991 case wxDOT
: index
= 7; break;
1992 case wxLONG_DASH
: index
= 8; break;
1993 case wxSHORT_DASH
: index
= 9; break;
1994 case wxDOT_DASH
: index
= 10; break;
2000 *pattern
= gPatterns
[index
];
2003 void wxDC::MacInstallPen() const
2005 wxCHECK_RET(Ok(), wxT("wxDC::MacInstallPen - invalid DC"));
2007 //Pattern blackColor;
2008 // if ( m_macPenInstalled )
2011 RGBColor forecolor
= MAC_WXCOLORREF( m_pen
.GetColour().GetPixel());
2012 RGBColor backcolor
= MAC_WXCOLORREF( m_backgroundBrush
.GetColour().GetPixel());
2013 ::RGBForeColor( &forecolor
);
2014 ::RGBBackColor( &backcolor
);
2017 // null means only one pixel, at whatever resolution
2018 int penWidth
= (int) (m_pen
.GetWidth() * m_scaleX
) ;
2019 if ( penWidth
== 0 )
2021 ::PenSize(penWidth
, penWidth
);
2024 int penStyle
= m_pen
.GetStyle();
2025 if (penStyle
== wxUSER_DASH
)
2027 // FIXME: there should be exactly 8 items in the dash
2029 int number
= m_pen
.GetDashes(&dash
) ;
2031 for ( int i
= 0 ; i
< 8 ; ++i
)
2033 pat
.pat
[i
] = dash
[index
] ;
2034 if (index
< number
- 1)
2040 wxMacGetPattern(penStyle
, &pat
);
2045 short mode
= patCopy
;
2046 switch ( m_logicalFunction
)
2048 case wxCOPY
: // only foreground color, leave background (thus not patCopy)
2052 case wxINVERT
: // NOT dst
2053 // ::PenPat(GetQDGlobalsBlack(&blackColor));
2057 case wxXOR
: // src XOR dst
2061 case wxOR_REVERSE
: // src OR (NOT dst)
2065 case wxSRC_INVERT
: // (NOT src)
2069 case wxAND
: // src AND dst
2073 // TODO: unsupported
2075 case wxAND_REVERSE
:// src AND (NOT dst)
2076 case wxAND_INVERT
: // (NOT src) AND dst
2077 case wxNO_OP
: // dst
2078 case wxNOR
: // (NOT src) AND (NOT dst)
2079 case wxEQUIV
: // (NOT src) XOR dst
2080 case wxOR_INVERT
: // (NOT src) OR dst
2081 case wxNAND
: // (NOT src) OR (NOT dst)
2082 case wxOR
: // src OR dst
2084 // case wxSRC_OR: // source _bitmap_ OR destination
2085 // case wxSRC_AND: // source _bitmap_ AND destination
2093 m_macPenInstalled
= true ;
2094 m_macBrushInstalled
= false ;
2095 m_macFontInstalled
= false ;
2098 void wxDC::MacSetupBackgroundForCurrentPort(const wxBrush
& background
)
2100 Pattern whiteColor
;
2102 if ( background
.Ok() )
2104 switch ( background
.MacGetBrushKind() )
2106 case kwxMacBrushTheme
:
2107 ::SetThemeBackground( background
.MacGetTheme() , wxDisplayDepth() , true ) ;
2110 case kwxMacBrushThemeBackground
:
2113 ThemeBackgroundKind bg
= background
.MacGetThemeBackground( &extent
) ;
2114 ::ApplyThemeBackground( bg
, &extent
, kThemeStateActive
, wxDisplayDepth() , true ) ;
2118 case kwxMacBrushColour
:
2120 ::RGBBackColor( &MAC_WXCOLORREF( background
.GetColour().GetPixel()) );
2121 int brushStyle
= background
.GetStyle();
2122 if (brushStyle
== wxSOLID
)
2123 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
2124 else if (background
.IsHatch())
2127 wxMacGetPattern(brushStyle
, &pat
);
2132 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
2143 void wxDC::MacInstallBrush() const
2145 wxCHECK_RET(Ok(), wxT("Invalid DC"));
2147 // if ( m_macBrushInstalled )
2150 Pattern blackColor
;
2151 bool backgroundTransparent
= (GetBackgroundMode() == wxTRANSPARENT
) ;
2152 ::RGBForeColor( &MAC_WXCOLORREF( m_brush
.GetColour().GetPixel()) );
2153 ::RGBBackColor( &MAC_WXCOLORREF( m_backgroundBrush
.GetColour().GetPixel()) );
2155 int brushStyle
= m_brush
.GetStyle();
2156 if (brushStyle
== wxSOLID
)
2158 ::PenPat(GetQDGlobalsBlack(&blackColor
));
2160 else if (m_brush
.IsHatch())
2164 wxMacGetPattern(brushStyle
, &pat
);
2167 else if ( m_brush
.GetStyle() == wxSTIPPLE
|| m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
)
2169 // we force this in order to be compliant with wxMSW
2170 backgroundTransparent
= false ;
2172 // for these the text fore (and back for MASK_OPAQUE) colors are used
2173 wxBitmap
* bitmap
= m_brush
.GetStipple() ;
2174 int width
= bitmap
->GetWidth() ;
2175 int height
= bitmap
->GetHeight() ;
2176 GWorldPtr gw
= NULL
;
2178 if ( m_brush
.GetStyle() == wxSTIPPLE
)
2179 gw
= MAC_WXHBITMAP(bitmap
->GetHBITMAP(NULL
)) ;
2181 gw
= MAC_WXHBITMAP(bitmap
->GetMask()->GetHBITMAP()) ;
2183 PixMapHandle gwpixmaphandle
= GetGWorldPixMap( gw
) ;
2184 LockPixels( gwpixmaphandle
) ;
2185 bool isMonochrome
= !IsPortColor( gw
) ;
2186 if ( !isMonochrome
)
2188 if ( (**gwpixmaphandle
).pixelSize
== 1 )
2189 isMonochrome
= true ;
2192 if ( isMonochrome
&& width
== 8 && height
== 8 )
2194 ::RGBForeColor( &MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) );
2195 ::RGBForeColor( &MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) );
2196 BitMap
* gwbitmap
= (BitMap
*) *gwpixmaphandle
; // since the color depth is 1 it is a BitMap
2197 UInt8
*gwbits
= (UInt8
*) gwbitmap
->baseAddr
;
2198 int alignment
= gwbitmap
->rowBytes
& 0x7FFF ;
2201 for ( int i
= 0 ; i
< 8 ; ++i
)
2203 pat
.pat
[i
] = gwbits
[i
* alignment
+ 0] ;
2206 UnlockPixels( GetGWorldPixMap( gw
) ) ;
2211 // this will be the code to handle power of 2 patterns, we will have to arrive at a nice
2212 // caching scheme before putting this into production
2216 PixPatHandle pixpat
= NewPixPat() ;
2217 CopyPixMap(gwpixmaphandle
, (**pixpat
).patMap
);
2218 imageSize
= GetPixRowBytes((**pixpat
).patMap
) *
2219 ((**(**pixpat
).patMap
).bounds
.bottom
-
2220 (**(**pixpat
).patMap
).bounds
.top
);
2221 PtrToHand( (**gwpixmaphandle
).baseAddr
, &image
, imageSize
);
2222 (**pixpat
).patData
= image
;
2226 CTabHandle ctable
= ((**((**pixpat
).patMap
)).pmTable
) ;
2227 ColorSpecPtr ctspec
= (ColorSpecPtr
) &(**ctable
).ctTable
;
2228 if ( ctspec
[0].rgb
.red
== 0x0000 )
2230 ctspec
[1].rgb
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) ;
2231 ctspec
[0].rgb
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) ;
2235 ctspec
[0].rgb
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) ;
2236 ctspec
[1].rgb
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) ;
2238 ::CTabChanged( ctable
) ;
2241 ::PenPixPat(pixpat
);
2242 m_macForegroundPixMap
= pixpat
;
2245 UnlockPixels( gwpixmaphandle
) ;
2249 ::PenPat(GetQDGlobalsBlack(&blackColor
));
2252 short mode
= patCopy
;
2253 switch ( m_logicalFunction
)
2256 if ( backgroundTransparent
)
2262 case wxINVERT
: // NOT dst
2263 if ( !backgroundTransparent
)
2264 ::PenPat(GetQDGlobalsBlack(&blackColor
));
2268 case wxXOR
: // src XOR dst
2272 case wxOR_REVERSE
: // src OR (NOT dst)
2276 case wxSRC_INVERT
: // (NOT src)
2280 case wxAND
: // src AND dst
2284 // TODO: unsupported
2286 case wxAND_REVERSE
:// src AND (NOT dst)
2287 case wxAND_INVERT
: // (NOT src) AND dst
2288 case wxNO_OP
: // dst
2289 case wxNOR
: // (NOT src) AND (NOT dst)
2290 case wxEQUIV
: // (NOT src) XOR dst
2291 case wxOR_INVERT
: // (NOT src) OR dst
2292 case wxNAND
: // (NOT src) OR (NOT dst)
2293 case wxOR
: // src OR dst
2295 // case wxSRC_OR: // source _bitmap_ OR destination
2296 // case wxSRC_AND: // source _bitmap_ AND destination
2304 m_macBrushInstalled
= true ;
2305 m_macPenInstalled
= false ;
2306 m_macFontInstalled
= false ;
2309 // ---------------------------------------------------------------------------
2310 // coordinates transformations
2311 // ---------------------------------------------------------------------------
2313 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
2315 return ((wxDC
*)this)->XDEV2LOG(x
);
2318 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
2320 return ((wxDC
*)this)->YDEV2LOG(y
);
2323 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
2325 return ((wxDC
*)this)->XDEV2LOGREL(x
);
2328 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
2330 return ((wxDC
*)this)->YDEV2LOGREL(y
);
2333 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
2335 return ((wxDC
*)this)->XLOG2DEV(x
);
2338 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
2340 return ((wxDC
*)this)->YLOG2DEV(y
);
2343 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
2345 return ((wxDC
*)this)->XLOG2DEVREL(x
);
2348 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
2350 return ((wxDC
*)this)->YLOG2DEVREL(y
);
2353 #endif // !wxMAC_USE_CORE_GRAPHICS