1 /////////////////////////////////////////////////////////////////////////////
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "dc.h"
18 #include "wx/mac/uma.h"
19 #include "wx/dcmemory.h"
20 #include "wx/region.h"
30 #include "wx/mac/private.h"
31 #include "ATSUnicode.h"
32 #include "TextCommon.h"
33 #include "TextEncodingConverter.h"
35 #if !USE_SHARED_LIBRARY
36 IMPLEMENT_ABSTRACT_CLASS(wxDC
, wxObject
)
39 //-----------------------------------------------------------------------------
41 //-----------------------------------------------------------------------------
43 #define mm2inches 0.0393700787402
44 #define inches2mm 25.4
45 #define mm2twips 56.6929133859
46 #define twips2mm 0.0176388888889
47 #define mm2pt 2.83464566929
48 #define pt2mm 0.352777777778
50 const double M_PI
= 3.14159265358979 ;
52 const double RAD2DEG
= 180.0 / M_PI
;
53 const short kEmulatedMode
= -1 ;
54 const short kUnsupportedMode
= -2 ;
56 wxMacPortSetter::wxMacPortSetter( const wxDC
* dc
) :
57 m_ph( (GrafPtr
) dc
->m_macPort
)
59 wxASSERT( dc
->Ok() ) ;
61 dc
->MacSetupPort(&m_ph
) ;
64 wxMacPortSetter::~wxMacPortSetter()
66 m_dc
->MacCleanupPort(&m_ph
) ;
69 //-----------------------------------------------------------------------------
71 //-----------------------------------------------------------------------------
73 static inline double dmin(double a
, double b
) { return a
< b
? a
: b
; }
74 static inline double dmax(double a
, double b
) { return a
> b
? a
: b
; }
75 static inline double DegToRad(double deg
) { return (deg
* M_PI
) / 180.0; }
77 //-----------------------------------------------------------------------------
79 //-----------------------------------------------------------------------------
81 // this function emulates all wx colour manipulations, used to verify the implementation
82 // by setting the mode in the blitting functions to kEmulatedMode
84 void wxMacCalculateColour( int logical_func
, const RGBColor
&srcColor
, RGBColor
&dstColor
) ;
85 void wxMacCalculateColour( int logical_func
, const RGBColor
&srcColor
, RGBColor
&dstColor
)
87 switch ( logical_func
)
89 case wxAND
: // src AND dst
90 dstColor
.red
= dstColor
.red
& srcColor
.red
;
91 dstColor
.green
= dstColor
.green
& srcColor
.green
;
92 dstColor
.blue
= dstColor
.blue
& srcColor
.blue
;
94 case wxAND_INVERT
: // (NOT src) AND dst
95 dstColor
.red
= dstColor
.red
& ~srcColor
.red
;
96 dstColor
.green
= dstColor
.green
& ~srcColor
.green
;
97 dstColor
.blue
= dstColor
.blue
& ~srcColor
.blue
;
99 case wxAND_REVERSE
:// src AND (NOT dst)
100 dstColor
.red
= ~dstColor
.red
& srcColor
.red
;
101 dstColor
.green
= ~dstColor
.green
& srcColor
.green
;
102 dstColor
.blue
= ~dstColor
.blue
& srcColor
.blue
;
110 dstColor
.red
= srcColor
.red
;
111 dstColor
.green
= srcColor
.green
;
112 dstColor
.blue
= srcColor
.blue
;
114 case wxEQUIV
: // (NOT src) XOR dst
115 dstColor
.red
= dstColor
.red
^ ~srcColor
.red
;
116 dstColor
.green
= dstColor
.green
^ ~srcColor
.green
;
117 dstColor
.blue
= dstColor
.blue
^ ~srcColor
.blue
;
119 case wxINVERT
: // NOT dst
120 dstColor
.red
= ~dstColor
.red
;
121 dstColor
.green
= ~dstColor
.green
;
122 dstColor
.blue
= ~dstColor
.blue
;
124 case wxNAND
: // (NOT src) OR (NOT dst)
125 dstColor
.red
= ~dstColor
.red
| ~srcColor
.red
;
126 dstColor
.green
= ~dstColor
.green
| ~srcColor
.green
;
127 dstColor
.blue
= ~dstColor
.blue
| ~srcColor
.blue
;
129 case wxNOR
: // (NOT src) AND (NOT dst)
130 dstColor
.red
= ~dstColor
.red
& ~srcColor
.red
;
131 dstColor
.green
= ~dstColor
.green
& ~srcColor
.green
;
132 dstColor
.blue
= ~dstColor
.blue
& ~srcColor
.blue
;
136 case wxOR
: // src OR dst
137 dstColor
.red
= dstColor
.red
| srcColor
.red
;
138 dstColor
.green
= dstColor
.green
| srcColor
.green
;
139 dstColor
.blue
= dstColor
.blue
| srcColor
.blue
;
141 case wxOR_INVERT
: // (NOT src) OR dst
142 dstColor
.red
= dstColor
.red
| ~srcColor
.red
;
143 dstColor
.green
= dstColor
.green
| ~srcColor
.green
;
144 dstColor
.blue
= dstColor
.blue
| ~srcColor
.blue
;
146 case wxOR_REVERSE
: // src OR (NOT dst)
147 dstColor
.red
= ~dstColor
.red
| srcColor
.red
;
148 dstColor
.green
= ~dstColor
.green
| srcColor
.green
;
149 dstColor
.blue
= ~dstColor
.blue
| srcColor
.blue
;
152 dstColor
.red
= 0xFFFF ;
153 dstColor
.green
= 0xFFFF ;
154 dstColor
.blue
= 0xFFFF ;
156 case wxSRC_INVERT
: // (NOT src)
157 dstColor
.red
= ~srcColor
.red
;
158 dstColor
.green
= ~srcColor
.green
;
159 dstColor
.blue
= ~srcColor
.blue
;
161 case wxXOR
: // src XOR dst
162 dstColor
.red
= dstColor
.red
^ srcColor
.red
;
163 dstColor
.green
= dstColor
.green
^ srcColor
.green
;
164 dstColor
.blue
= dstColor
.blue
^ srcColor
.blue
;
175 m_mm_to_pix_x
= mm2pt
;
176 m_mm_to_pix_y
= mm2pt
;
178 m_internalDeviceOriginX
= 0;
179 m_internalDeviceOriginY
= 0;
180 m_externalDeviceOriginX
= 0;
181 m_externalDeviceOriginY
= 0;
183 m_logicalScaleX
= 1.0;
184 m_logicalScaleY
= 1.0;
190 m_needComputeScaleX
= FALSE
;
191 m_needComputeScaleY
= FALSE
;
197 m_macFontInstalled
= false ;
198 m_macBrushInstalled
= false ;
199 m_macPenInstalled
= false ;
201 m_macLocalOrigin
.x
= m_macLocalOrigin
.y
= 0 ;
202 m_macBoundaryClipRgn
= NewRgn() ;
203 m_macCurrentClipRgn
= NewRgn() ;
205 SetRectRgn( (RgnHandle
) m_macBoundaryClipRgn
, -32000 , -32000 , 32000 , 32000 ) ;
206 SetRectRgn( (RgnHandle
) m_macCurrentClipRgn
, -32000 , -32000 , 32000 , 32000 ) ;
208 m_pen
= *wxBLACK_PEN
;
209 m_font
= *wxNORMAL_FONT
;
210 m_brush
= *wxWHITE_BRUSH
;
211 m_macCurrentPortStateHelper
= NULL
;
212 m_macATSUIStyle
= NULL
;
213 m_macAliasWasEnabled
= false;
214 m_macForegroundPixMap
= NULL
;
215 m_macBackgroundPixMap
= NULL
;
220 DisposeRgn( (RgnHandle
) m_macBoundaryClipRgn
) ;
221 DisposeRgn( (RgnHandle
) m_macCurrentClipRgn
) ;
223 void wxDC::MacSetupPort(wxMacPortStateHelper
* help
) const
225 wxASSERT( m_macCurrentPortStateHelper
== NULL
) ;
226 m_macCurrentPortStateHelper
= help
;
227 SetClip( (RgnHandle
) m_macCurrentClipRgn
);
229 m_macFontInstalled
= false ;
230 m_macBrushInstalled
= false ;
231 m_macPenInstalled
= false ;
234 void wxDC::MacCleanupPort(wxMacPortStateHelper
* help
) const
236 wxASSERT( m_macCurrentPortStateHelper
== help
) ;
237 m_macCurrentPortStateHelper
= NULL
;
238 if( m_macATSUIStyle
)
240 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUIStyle
);
241 m_macATSUIStyle
= NULL
;
243 if ( m_macAliasWasEnabled
)
245 SetAntiAliasedTextEnabled(m_macFormerAliasState
, m_macFormerAliasSize
);
246 m_macAliasWasEnabled
= false ;
248 if ( m_macForegroundPixMap
)
251 ::PenPat(GetQDGlobalsBlack(&blackColor
));
252 DisposePixPat( (PixPatHandle
) m_macForegroundPixMap
) ;
253 m_macForegroundPixMap
= NULL
;
255 if ( m_macBackgroundPixMap
)
258 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
259 DisposePixPat( (PixPatHandle
) m_macBackgroundPixMap
) ;
260 m_macBackgroundPixMap
= NULL
;
264 void wxDC::DoDrawBitmap( const wxBitmap
&bmp
, wxCoord x
, wxCoord y
, bool useMask
)
266 wxCHECK_RET( Ok(), wxT("invalid window dc") );
268 wxCHECK_RET( bmp
.Ok(), wxT("invalid bitmap") );
270 wxMacPortSetter
helper(this) ;
272 wxCoord xx
= XLOG2DEVMAC(x
);
273 wxCoord yy
= YLOG2DEVMAC(y
);
274 wxCoord w
= bmp
.GetWidth();
275 wxCoord h
= bmp
.GetHeight();
276 wxCoord ww
= XLOG2DEVREL(w
);
277 wxCoord hh
= YLOG2DEVREL(h
);
279 // Set up drawing mode
280 short mode
= (m_logicalFunction
== wxCOPY
? srcCopy
:
281 //m_logicalFunction == wxCLEAR ? WHITENESS :
282 //m_logicalFunction == wxSET ? BLACKNESS :
283 m_logicalFunction
== wxINVERT
? hilite
:
284 //m_logicalFunction == wxAND ? MERGECOPY :
285 m_logicalFunction
== wxOR
? srcOr
:
286 m_logicalFunction
== wxSRC_INVERT
? notSrcCopy
:
287 m_logicalFunction
== wxXOR
? srcXor
:
288 m_logicalFunction
== wxOR_REVERSE
? notSrcOr
:
289 //m_logicalFunction == wxAND_REVERSE ? SRCERASE :
290 //m_logicalFunction == wxSRC_OR ? srcOr :
291 //m_logicalFunction == wxSRC_AND ? SRCAND :
294 if ( bmp
.GetBitmapType() == kMacBitmapTypePict
) {
295 Rect bitmaprect
= { 0 , 0 , hh
, ww
};
296 ::OffsetRect( &bitmaprect
, xx
, yy
) ;
297 ::DrawPicture( (PicHandle
) bmp
.GetPict(), &bitmaprect
) ;
299 else if ( bmp
.GetBitmapType() == kMacBitmapTypeGrafWorld
)
301 GWorldPtr bmapworld
= MAC_WXHBITMAP( bmp
.GetHBITMAP() );
302 PixMapHandle bmappixels
;
304 // Set foreground and background colours (for bitmaps depth = 1)
305 if(bmp
.GetDepth() == 1)
307 RGBColor fore
= MAC_WXCOLORREF(m_textForegroundColour
.GetPixel());
308 RGBColor back
= MAC_WXCOLORREF(m_textBackgroundColour
.GetPixel());
314 RGBColor white
= { 0xFFFF, 0xFFFF,0xFFFF} ;
315 RGBColor black
= { 0,0,0} ;
316 RGBForeColor( &black
) ;
317 RGBBackColor( &white
) ;
320 bmappixels
= GetGWorldPixMap( bmapworld
) ;
322 wxCHECK_RET(LockPixels(bmappixels
),
323 wxT("DoDrawBitmap: Unable to lock pixels"));
325 Rect source
= { 0, 0, h
, w
};
326 Rect dest
= { yy
, xx
, yy
+ hh
, xx
+ ww
};
328 if ( useMask
&& bmp
.GetMask() )
330 if( LockPixels(GetGWorldPixMap(MAC_WXHBITMAP(bmp
.GetMask()->GetMaskBitmap()))))
334 GetPortBitMapForCopyBits(bmapworld
),
335 GetPortBitMapForCopyBits(MAC_WXHBITMAP(bmp
.GetMask()->GetMaskBitmap())),
336 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ),
337 &source
, &source
, &dest
, mode
, NULL
339 UnlockPixels(GetGWorldPixMap(MAC_WXHBITMAP(bmp
.GetMask()->GetMaskBitmap())));
343 CopyBits( GetPortBitMapForCopyBits( bmapworld
),
344 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ),
345 &source
, &dest
, mode
, NULL
) ;
347 UnlockPixels( bmappixels
) ;
349 else if ( bmp
.GetBitmapType() == kMacBitmapTypeIcon
)
351 Rect bitmaprect
= { 0 , 0 , bmp
.GetHeight(), bmp
.GetWidth() } ;
352 OffsetRect( &bitmaprect
, xx
, yy
) ;
353 PlotCIconHandle( &bitmaprect
, atNone
, ttNone
, MAC_WXHICON(bmp
.GetHICON()) ) ;
355 m_macPenInstalled
= false ;
356 m_macBrushInstalled
= false ;
357 m_macFontInstalled
= false ;
361 void wxDC::DoDrawIcon( const wxIcon
&icon
, wxCoord x
, wxCoord y
)
363 wxCHECK_RET(Ok(), wxT("Invalid dc wxDC::DoDrawIcon"));
365 wxCHECK_RET(icon
.Ok(), wxT("Invalid icon wxDC::DoDrawIcon"));
367 DoDrawBitmap( icon
, x
, y
, icon
.GetMask() != NULL
) ;
369 void wxDC::DoSetClippingRegion( wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
371 wxCHECK_RET(Ok(), wxT("wxDC::DoSetClippingRegion Invalid DC"));
372 wxCoord xx
, yy
, ww
, hh
;
376 ww
= XLOG2DEVREL(width
);
377 hh
= YLOG2DEVREL(height
);
379 SetRectRgn( (RgnHandle
) m_macCurrentClipRgn
, xx
, yy
, xx
+ ww
, yy
+ hh
) ;
380 SectRgn( (RgnHandle
) m_macCurrentClipRgn
, (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
384 m_clipX1
= wxMax( m_clipX1
, xx
);
385 m_clipY1
= wxMax( m_clipY1
, yy
);
386 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
));
387 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
));
399 void wxDC::DoSetClippingRegionAsRegion( const wxRegion
®ion
)
401 wxCHECK_RET( Ok(), wxT("invalid window dc") ) ;
403 wxMacPortSetter
helper(this) ;
406 DestroyClippingRegion();
411 region
.GetBox( x
, y
, w
, h
);
412 wxCoord xx
, yy
, ww
, hh
;
419 // if we have a scaling that we cannot map onto native regions
420 // we must use the box
422 if ( ww
!= w
|| hh
!= h
)
424 wxDC::DoSetClippingRegion( x
, y
, w
, h
);
428 CopyRgn( (RgnHandle
) region
.GetWXHRGN() , (RgnHandle
) m_macCurrentClipRgn
) ;
429 if ( xx
!= x
|| yy
!= y
)
431 OffsetRgn( (RgnHandle
) m_macCurrentClipRgn
, xx
- x
, yy
- y
) ;
433 SectRgn( (RgnHandle
) m_macCurrentClipRgn
, (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
436 m_clipX1
= wxMax( m_clipX1
, xx
);
437 m_clipY1
= wxMax( m_clipY1
, yy
);
438 m_clipX2
= wxMin( m_clipX2
, (xx
+ ww
));
439 m_clipY2
= wxMin( m_clipY2
, (yy
+ hh
));
453 void wxDC::DestroyClippingRegion()
455 wxMacPortSetter
helper(this) ;
456 CopyRgn( (RgnHandle
) m_macBoundaryClipRgn
, (RgnHandle
) m_macCurrentClipRgn
) ;
459 void wxDC::DoGetSize( int* width
, int* height
) const
461 *width
= m_maxX
-m_minX
;
462 *height
= m_maxY
-m_minY
;
464 void wxDC::DoGetSizeMM( int* width
, int* height
) const
469 *width
= long( double(w
) / (m_scaleX
*m_mm_to_pix_x
) );
470 *height
= long( double(h
) / (m_scaleY
*m_mm_to_pix_y
) );
472 void wxDC::SetTextForeground( const wxColour
&col
)
474 wxCHECK_RET(Ok(), wxT("Invalid DC"));
475 m_textForegroundColour
= col
;
476 m_macFontInstalled
= false ;
478 void wxDC::SetTextBackground( const wxColour
&col
)
480 wxCHECK_RET(Ok(), wxT("Invalid DC"));
481 m_textBackgroundColour
= col
;
482 m_macFontInstalled
= false ;
484 void wxDC::SetMapMode( int mode
)
489 SetLogicalScale( twips2mm
*m_mm_to_pix_x
, twips2mm
*m_mm_to_pix_y
);
492 SetLogicalScale( pt2mm
*m_mm_to_pix_x
, pt2mm
*m_mm_to_pix_y
);
495 SetLogicalScale( m_mm_to_pix_x
, m_mm_to_pix_y
);
498 SetLogicalScale( m_mm_to_pix_x
/10.0, m_mm_to_pix_y
/10.0 );
502 SetLogicalScale( 1.0, 1.0 );
505 if (mode
!= wxMM_TEXT
)
507 m_needComputeScaleX
= TRUE
;
508 m_needComputeScaleY
= TRUE
;
511 void wxDC::SetUserScale( double x
, double y
)
513 // allow negative ? -> no
516 ComputeScaleAndOrigin();
518 void wxDC::SetLogicalScale( double x
, double y
)
523 ComputeScaleAndOrigin();
525 void wxDC::SetLogicalOrigin( wxCoord x
, wxCoord y
)
527 m_logicalOriginX
= x
* m_signX
; // is this still correct ?
528 m_logicalOriginY
= y
* m_signY
;
529 ComputeScaleAndOrigin();
531 void wxDC::SetDeviceOrigin( wxCoord x
, wxCoord y
)
533 m_externalDeviceOriginX
= x
;
534 m_externalDeviceOriginY
= y
;
535 ComputeScaleAndOrigin();
539 void wxDC::SetInternalDeviceOrigin( long x
, long y
)
541 m_internalDeviceOriginX
= x
;
542 m_internalDeviceOriginY
= y
;
543 ComputeScaleAndOrigin();
545 void wxDC::GetInternalDeviceOrigin( long *x
, long *y
)
547 if (x
) *x
= m_internalDeviceOriginX
;
548 if (y
) *y
= m_internalDeviceOriginY
;
551 void wxDC::SetAxisOrientation( bool xLeftRight
, bool yBottomUp
)
553 m_signX
= (xLeftRight
? 1 : -1);
554 m_signY
= (yBottomUp
? -1 : 1);
555 ComputeScaleAndOrigin();
558 wxSize
wxDC::GetPPI() const
560 return wxSize(72, 72);
563 int wxDC::GetDepth() const
565 if ( IsPortColor( (CGrafPtr
) m_macPort
) )
567 return ( (**GetPortPixMap( (CGrafPtr
) m_macPort
)).pixelSize
) ;
572 void wxDC::ComputeScaleAndOrigin()
574 // CMB: copy scale to see if it changes
575 double origScaleX
= m_scaleX
;
576 double origScaleY
= m_scaleY
;
578 m_scaleX
= m_logicalScaleX
* m_userScaleX
;
579 m_scaleY
= m_logicalScaleY
* m_userScaleY
;
581 m_deviceOriginX
= m_internalDeviceOriginX
+ m_externalDeviceOriginX
;
582 m_deviceOriginY
= m_internalDeviceOriginY
+ m_externalDeviceOriginY
;
584 // CMB: if scale has changed call SetPen to recalulate the line width
585 if (m_scaleX
!= origScaleX
|| m_scaleY
!= origScaleY
)
587 // this is a bit artificial, but we need to force wxDC to think
588 // the pen has changed
589 wxPen
* pen
= & GetPen();
595 void wxDC::SetPalette( const wxPalette
& palette
)
599 void wxDC::SetBackgroundMode( int mode
)
601 m_backgroundMode
= mode
;
604 void wxDC::SetFont( const wxFont
&font
)
607 m_macFontInstalled
= false ;
610 void wxDC::SetPen( const wxPen
&pen
)
617 m_macPenInstalled
= false ;
620 void wxDC::SetBrush( const wxBrush
&brush
)
622 if (m_brush
== brush
)
626 m_macBrushInstalled
= false ;
629 void wxDC::SetBackground( const wxBrush
&brush
)
631 if (m_backgroundBrush
== brush
)
634 m_backgroundBrush
= brush
;
636 if (!m_backgroundBrush
.Ok())
638 m_macBrushInstalled
= false ;
641 void wxDC::SetLogicalFunction( int function
)
643 if (m_logicalFunction
== function
)
646 m_logicalFunction
= function
;
647 m_macFontInstalled
= false ;
648 m_macBrushInstalled
= false ;
649 m_macPenInstalled
= false ;
652 extern bool wxDoFloodFill(wxDC
*dc
, wxCoord x
, wxCoord y
,
653 const wxColour
& col
, int style
);
655 bool wxDC::DoFloodFill(wxCoord x
, wxCoord y
,
656 const wxColour
& col
, int style
)
658 return wxDoFloodFill(this, x
, y
, col
, style
);
661 bool wxDC::DoGetPixel( wxCoord x
, wxCoord y
, wxColour
*col
) const
663 wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel Invalid DC") );
664 wxMacPortSetter
helper(this) ;
668 GetCPixel( XLOG2DEVMAC(x
), YLOG2DEVMAC(y
), &colour
);
670 // Convert from Mac colour to wx
671 col
->Set( colour
.red
>> 8,
678 void wxDC::DoDrawLine( wxCoord x1
, wxCoord y1
, wxCoord x2
, wxCoord y2
)
680 wxCHECK_RET(Ok(), wxT("Invalid DC"));
682 wxMacPortSetter
helper(this) ;
684 if (m_pen
.GetStyle() != wxTRANSPARENT
)
687 wxCoord offset
= ( (m_pen
.GetWidth() == 0 ? 1 :
688 m_pen
.GetWidth() ) * (wxCoord
)m_scaleX
- 1) / 2;
690 wxCoord xx1
= XLOG2DEVMAC(x1
) - offset
;
691 wxCoord yy1
= YLOG2DEVMAC(y1
) - offset
;
692 wxCoord xx2
= XLOG2DEVMAC(x2
) - offset
;
693 wxCoord yy2
= YLOG2DEVMAC(y2
) - offset
;
695 if ((m_pen
.GetCap() == wxCAP_ROUND
) &&
696 (m_pen
.GetWidth() <= 1))
698 // Implement LAST_NOT for MAC at least for
699 // orthogonal lines. RR.
721 void wxDC::DoCrossHair( wxCoord x
, wxCoord y
)
723 wxCHECK_RET( Ok(), wxT("wxDC::DoCrossHair Invalid window dc") );
725 if (m_pen
.GetStyle() != wxTRANSPARENT
)
730 wxCoord xx
= XLOG2DEVMAC(x
);
731 wxCoord yy
= YLOG2DEVMAC(y
);
734 ::MoveTo( XLOG2DEVMAC(0), yy
);
735 ::LineTo( XLOG2DEVMAC(w
), yy
);
736 ::MoveTo( xx
, YLOG2DEVMAC(0) );
737 ::LineTo( xx
, YLOG2DEVMAC(h
) );
739 CalcBoundingBox(x
, y
);
740 CalcBoundingBox(x
+w
, y
+h
);
746 * To draw arcs properly the angles need to be converted from the WX style:
747 * Angles start on the +ve X axis and go anti-clockwise (As you would draw on
748 * a normal axis on paper).
751 * Angles start on the +ve y axis and go clockwise.
752 * To achive this I work out which quadrant the angle lies in then map this to
753 * the equivalent quadrant on the Mac. (Sin and Cos values reveal which
754 * quadrant you are in).
756 static double wxConvertWXangleToMACangle(double angle
)
760 sin_a
= sin(angle
/ RAD2DEG
);
761 cos_a
= cos(angle
/ RAD2DEG
);
763 if( (sin_a
>= 0.0) && (cos_a
>= 0.0) ) {
764 angle
= acos(sin_a
) * RAD2DEG
;
766 else if( (sin_a
>= 0.0) && (cos_a
<= 0.0) ) {
768 angle
= acos(sin_a
) * RAD2DEG
+ 180;
770 else if( (sin_a
<= 0.0) && (cos_a
>= 0.0) ) {
771 angle
= acos(sin_a
) * RAD2DEG
+ 180;
773 else if( (sin_a
< 0.0) && (cos_a
< 0.0) ) {
775 angle
= acos(sin_a
) * RAD2DEG
+ 180;
780 void wxDC::DoDrawArc( wxCoord x1
, wxCoord y1
,
781 wxCoord x2
, wxCoord y2
,
782 wxCoord xc
, wxCoord yc
)
784 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawArc Invalid DC"));
786 wxCoord xx1
= XLOG2DEVMAC(x1
);
787 wxCoord yy1
= YLOG2DEVMAC(y1
);
788 wxCoord xx2
= XLOG2DEVMAC(x2
);
789 wxCoord yy2
= YLOG2DEVMAC(y2
);
790 wxCoord xxc
= XLOG2DEVMAC(xc
);
791 wxCoord yyc
= YLOG2DEVMAC(yc
);
792 double dx
= xx1
- xxc
;
793 double dy
= yy1
- yyc
;
794 double radius
= sqrt((double)(dx
*dx
+dy
*dy
));
795 wxCoord rad
= (wxCoord
)radius
;
796 double radius1
, radius2
;
798 if (xx1
== xx2
&& yy1
== yy2
)
803 else if (radius
== 0.0)
805 radius1
= radius2
= 0.0;
809 radius1
= (xx1
- xxc
== 0) ?
810 (yy1
- yyc
< 0) ? 90.0 : -90.0 :
811 -atan2(double(yy1
-yyc
), double(xx1
-xxc
)) * RAD2DEG
;
812 radius2
= (xx2
- xxc
== 0) ?
813 (yy2
- yyc
< 0) ? 90.0 : -90.0 :
814 -atan2(double(yy2
-yyc
), double(xx2
-xxc
)) * RAD2DEG
;
816 wxCoord alpha2
= wxCoord(radius2
- radius1
);
817 wxCoord alpha1
= wxCoord(wxConvertWXangleToMACangle(radius1
));
818 if( (xx1
> xx2
) || (yy1
> yy2
) ) {
822 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"));
840 double angle
= sa
- ea
; // Order important Mac in opposite direction to wx
842 wxCoord xx
= XLOG2DEVMAC(x
);
843 wxCoord yy
= YLOG2DEVMAC(y
);
844 wxCoord ww
= m_signX
* XLOG2DEVREL(w
);
845 wxCoord hh
= m_signY
* YLOG2DEVREL(h
);
847 // handle -ve width and/or height
848 if (ww
< 0) { ww
= -ww
; xx
= xx
- ww
; }
849 if (hh
< 0) { hh
= -hh
; yy
= yy
- hh
; }
851 sa
= wxConvertWXangleToMACangle(sa
);
858 if(m_brush
.GetStyle() != wxTRANSPARENT
) {
860 PaintArc(&r
, (short)sa
, (short)angle
);
862 if(m_pen
.GetStyle() != wxTRANSPARENT
) {
864 FrameArc(&r
, (short)sa
, (short)angle
);
868 void wxDC::DoDrawPoint( wxCoord x
, wxCoord y
)
870 wxCHECK_RET(Ok(), wxT("Invalid DC"));
872 wxMacPortSetter
helper(this) ;
874 if (m_pen
.GetStyle() != wxTRANSPARENT
)
876 wxCoord xx1
= XLOG2DEVMAC(x
);
877 wxCoord yy1
= YLOG2DEVMAC(y
);
878 RGBColor pencolor
= MAC_WXCOLORREF( m_pen
.GetColour().GetPixel());
879 ::SetCPixel( xx1
,yy1
,&pencolor
) ;
880 CalcBoundingBox(x
, y
);
884 void wxDC::DoDrawLines(int n
, wxPoint points
[],
885 wxCoord xoffset
, wxCoord yoffset
)
887 wxCHECK_RET(Ok(), wxT("Invalid DC"));
888 wxMacPortSetter
helper(this) ;
890 if (m_pen
.GetStyle() == wxTRANSPARENT
)
895 wxCoord offset
= ( (m_pen
.GetWidth() == 0 ? 1 :
896 m_pen
.GetWidth() ) * (wxCoord
)m_scaleX
- 1) / 2 ;
898 wxCoord x1
, x2
, y1
, y2
;
899 x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
900 y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
901 ::MoveTo(x1
- offset
, y1
- offset
);
903 for (int i
= 0; i
< n
-1; i
++)
905 x2
= XLOG2DEVMAC(points
[i
+1].x
+ xoffset
);
906 y2
= YLOG2DEVMAC(points
[i
+1].y
+ yoffset
);
907 ::LineTo( x2
- offset
, y2
- offset
);
911 void wxDC::DoDrawPolygon(int n
, wxPoint points
[],
912 wxCoord xoffset
, wxCoord yoffset
,
915 wxCHECK_RET(Ok(), wxT("Invalid DC"));
916 wxMacPortSetter
helper(this) ;
918 wxCoord x1
, x2
, y1
, y2
;
920 if ( m_brush
.GetStyle() == wxTRANSPARENT
&& m_pen
.GetStyle() == wxTRANSPARENT
)
923 PolyHandle polygon
= OpenPoly();
925 x1
= XLOG2DEVMAC(points
[0].x
+ xoffset
);
926 y1
= YLOG2DEVMAC(points
[0].y
+ yoffset
);
929 for (int i
= 1; i
< n
; i
++)
931 x2
= XLOG2DEVMAC(points
[i
].x
+ xoffset
);
932 y2
= YLOG2DEVMAC(points
[i
].y
+ yoffset
);
936 // close the polyline if necessary
937 if ( x1
!= x2
|| y1
!= y2
)
944 if (m_brush
.GetStyle() != wxTRANSPARENT
)
948 ::PaintPoly( polygon
);
952 if (m_pen
.GetStyle() != wxTRANSPARENT
)
956 ::FramePoly( polygon
) ;
962 void wxDC::DoDrawRectangle(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
964 wxCHECK_RET(Ok(), wxT("Invalid DC"));
965 wxMacPortSetter
helper(this) ;
967 wxCoord xx
= XLOG2DEVMAC(x
);
968 wxCoord yy
= YLOG2DEVMAC(y
);
969 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
970 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
972 // CMB: draw nothing if transformed w or h is 0
973 if (ww
== 0 || hh
== 0)
976 // CMB: handle -ve width and/or height
989 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
991 if (m_brush
.GetStyle() != wxTRANSPARENT
)
994 ::PaintRect( &rect
) ;
997 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1000 ::FrameRect( &rect
) ;
1004 void wxDC::DoDrawRoundedRectangle(wxCoord x
, wxCoord y
,
1005 wxCoord width
, wxCoord height
,
1008 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1009 wxMacPortSetter
helper(this) ;
1012 radius
= - radius
* ((width
< height
) ? width
: height
);
1014 wxCoord xx
= XLOG2DEVMAC(x
);
1015 wxCoord yy
= YLOG2DEVMAC(y
);
1016 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1017 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1019 // CMB: draw nothing if transformed w or h is 0
1020 if (ww
== 0 || hh
== 0)
1023 // CMB: handle -ve width and/or height
1036 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
1038 if (m_brush
.GetStyle() != wxTRANSPARENT
)
1041 ::PaintRoundRect( &rect
, int(radius
* 2) , int(radius
* 2) ) ;
1044 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1047 ::FrameRoundRect( &rect
, int(radius
* 2) , int(radius
* 2) ) ;
1051 void wxDC::DoDrawEllipse(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
)
1053 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1054 wxMacPortSetter
helper(this) ;
1056 wxCoord xx
= XLOG2DEVMAC(x
);
1057 wxCoord yy
= YLOG2DEVMAC(y
);
1058 wxCoord ww
= m_signX
* XLOG2DEVREL(width
);
1059 wxCoord hh
= m_signY
* YLOG2DEVREL(height
);
1061 // CMB: draw nothing if transformed w or h is 0
1062 if (ww
== 0 || hh
== 0)
1065 // CMB: handle -ve width and/or height
1078 Rect rect
= { yy
, xx
, yy
+ hh
, xx
+ ww
} ;
1080 if (m_brush
.GetStyle() != wxTRANSPARENT
)
1083 ::PaintOval( &rect
) ;
1086 if (m_pen
.GetStyle() != wxTRANSPARENT
)
1089 ::FrameOval( &rect
) ;
1095 bool wxDC::CanDrawBitmap(void) const
1101 bool wxDC::DoBlit(wxCoord xdest
, wxCoord ydest
, wxCoord width
, wxCoord height
,
1102 wxDC
*source
, wxCoord xsrc
, wxCoord ysrc
, int logical_func
, bool useMask
,
1103 wxCoord xsrcMask
, wxCoord ysrcMask
)
1105 wxCHECK_MSG(Ok(), false, wxT("wxDC::DoBlit Illegal dc"));
1106 wxCHECK_MSG(source
->Ok(), false, wxT("wxDC::DoBlit Illegal source DC"));
1108 if ( logical_func
== wxNO_OP
)
1111 if (xsrcMask
== -1 && ysrcMask
== -1)
1113 xsrcMask
= xsrc
; ysrcMask
= ysrc
;
1116 // correct the parameter in case this dc does not have a mask at all
1118 if ( useMask
&& !source
->m_macMask
)
1121 Rect srcrect
, dstrect
;
1122 srcrect
.top
= source
->YLOG2DEVMAC(ysrc
) ;
1123 srcrect
.left
= source
->XLOG2DEVMAC(xsrc
) ;
1124 srcrect
.right
= source
->XLOG2DEVMAC(xsrc
+ width
) ;
1125 srcrect
.bottom
= source
->YLOG2DEVMAC(ysrc
+ height
) ;
1126 dstrect
.top
= YLOG2DEVMAC(ydest
) ;
1127 dstrect
.left
= XLOG2DEVMAC(xdest
) ;
1128 dstrect
.bottom
= YLOG2DEVMAC(ydest
+ height
) ;
1129 dstrect
.right
= XLOG2DEVMAC(xdest
+ width
) ;
1131 short mode
= kUnsupportedMode
;
1132 bool invertDestinationFirst
= false ;
1133 switch ( logical_func
)
1135 case wxAND
: // src AND dst
1136 mode
= srcOr
; // ok
1138 case wxAND_INVERT
: // (NOT src) AND dst
1139 mode
= notSrcOr
; // ok
1141 case wxAND_REVERSE
:// src AND (NOT dst)
1142 invertDestinationFirst
= true ;
1146 mode
= kEmulatedMode
;
1149 mode
= srcCopy
; // ok
1151 case wxEQUIV
: // (NOT src) XOR dst
1152 mode
= srcXor
; // ok
1154 case wxINVERT
: // NOT dst
1155 mode
= kEmulatedMode
; //or hilite ;
1157 case wxNAND
: // (NOT src) OR (NOT dst)
1158 invertDestinationFirst
= true ;
1161 case wxNOR
: // (NOT src) AND (NOT dst)
1162 invertDestinationFirst
= true ;
1165 case wxNO_OP
: // dst
1166 mode
= kEmulatedMode
; // this has already been handled upon entry
1168 case wxOR
: // src OR dst
1171 case wxOR_INVERT
: // (NOT src) OR dst
1174 case wxOR_REVERSE
: // src OR (NOT dst)
1175 invertDestinationFirst
= true ;
1179 mode
= kEmulatedMode
;
1181 case wxSRC_INVERT
: // (NOT src)
1182 mode
= notSrcCopy
; // ok
1184 case wxXOR
: // src XOR dst
1185 mode
= notSrcXor
; // ok
1193 if ( mode
== kUnsupportedMode
)
1195 wxFAIL_MSG("unsupported blitting mode" );
1199 CGrafPtr sourcePort
= (CGrafPtr
) source
->m_macPort
;
1200 PixMapHandle bmappixels
= GetGWorldPixMap( sourcePort
) ;
1201 if ( LockPixels(bmappixels
) )
1203 wxMacPortSetter
helper(this) ;
1205 if ( source
->GetDepth() == 1 )
1207 RGBForeColor( &MAC_WXCOLORREF(m_textForegroundColour
.GetPixel()) ) ;
1208 RGBBackColor( &MAC_WXCOLORREF(m_textBackgroundColour
.GetPixel()) ) ;
1212 // the modes need this, otherwise we'll end up having really nice colors...
1213 RGBColor white
= { 0xFFFF, 0xFFFF,0xFFFF} ;
1214 RGBColor black
= { 0,0,0} ;
1215 RGBForeColor( &black
) ;
1216 RGBBackColor( &white
) ;
1219 if ( useMask
&& source
->m_macMask
)
1221 if ( mode
== srcCopy
)
1223 if ( LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) )
1225 CopyMask( GetPortBitMapForCopyBits( sourcePort
) ,
1226 GetPortBitMapForCopyBits( MAC_WXHBITMAP(source
->m_macMask
) ) ,
1227 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1228 &srcrect
, &srcrect
, &dstrect
) ;
1229 UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1234 RgnHandle clipRgn
= NewRgn() ;
1235 LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1236 BitMapToRegion( clipRgn
, (BitMap
*) *GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1237 UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source
->m_macMask
) ) ) ;
1238 OffsetRgn( clipRgn
, -srcrect
.left
+ dstrect
.left
, -srcrect
.top
+ dstrect
.top
) ;
1239 if ( mode
== kEmulatedMode
)
1242 ::PenPat(GetQDGlobalsBlack(&pat
));
1243 if ( logical_func
== wxSET
)
1245 RGBColor col
= { 0xFFFF, 0xFFFF, 0xFFFF } ;
1246 ::RGBForeColor( &col
) ;
1247 ::PaintRgn( clipRgn
) ;
1249 else if ( logical_func
== wxCLEAR
)
1251 RGBColor col
= { 0x0000, 0x0000, 0x0000 } ;
1252 ::RGBForeColor( &col
) ;
1253 ::PaintRgn( clipRgn
) ;
1255 else if ( logical_func
== wxINVERT
)
1257 MacInvertRgn( clipRgn
) ;
1261 for ( int y
= 0 ; y
< srcrect
.right
- srcrect
.left
; ++y
)
1263 for ( int x
= 0 ; x
< srcrect
.bottom
- srcrect
.top
; ++x
)
1265 Point dstPoint
= { dstrect
.top
+ y
, dstrect
.left
+ x
} ;
1266 Point srcPoint
= { srcrect
.top
+ y
, srcrect
.left
+ x
} ;
1267 if ( PtInRgn( dstPoint
, clipRgn
) )
1272 SetPort( (GrafPtr
) sourcePort
) ;
1273 GetCPixel( srcPoint
.h
, srcPoint
.v
, &srcColor
) ;
1274 SetPort( (GrafPtr
) m_macPort
) ;
1275 GetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1277 wxMacCalculateColour( logical_func
, srcColor
, dstColor
) ;
1278 SetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1286 if ( invertDestinationFirst
)
1288 MacInvertRgn( clipRgn
) ;
1290 CopyBits( GetPortBitMapForCopyBits( sourcePort
) ,
1291 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1292 &srcrect
, &dstrect
, mode
, clipRgn
) ;
1294 DisposeRgn( clipRgn
) ;
1299 RgnHandle clipRgn
= NewRgn() ;
1300 SetRectRgn( clipRgn
, dstrect
.left
, dstrect
.top
, dstrect
.right
, dstrect
.bottom
) ;
1301 if ( mode
== kEmulatedMode
)
1304 ::PenPat(GetQDGlobalsBlack(&pat
));
1305 if ( logical_func
== wxSET
)
1307 RGBColor col
= { 0xFFFF, 0xFFFF, 0xFFFF } ;
1308 ::RGBForeColor( &col
) ;
1309 ::PaintRgn( clipRgn
) ;
1311 else if ( logical_func
== wxCLEAR
)
1313 RGBColor col
= { 0x0000, 0x0000, 0x0000 } ;
1314 ::RGBForeColor( &col
) ;
1315 ::PaintRgn( clipRgn
) ;
1317 else if ( logical_func
== wxINVERT
)
1319 MacInvertRgn( clipRgn
) ;
1323 for ( int y
= 0 ; y
< srcrect
.right
- srcrect
.left
; ++y
)
1325 for ( int x
= 0 ; x
< srcrect
.bottom
- srcrect
.top
; ++x
)
1327 Point dstPoint
= { dstrect
.top
+ y
, dstrect
.left
+ x
} ;
1328 Point srcPoint
= { srcrect
.top
+ y
, srcrect
.left
+ x
} ;
1334 SetPort( (GrafPtr
) sourcePort
) ;
1335 GetCPixel( srcPoint
.h
, srcPoint
.v
, &srcColor
) ;
1336 SetPort( (GrafPtr
) m_macPort
) ;
1337 GetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1339 wxMacCalculateColour( logical_func
, srcColor
, dstColor
) ;
1340 SetCPixel( dstPoint
.h
, dstPoint
.v
, &dstColor
) ;
1349 if ( invertDestinationFirst
)
1351 MacInvertRgn( clipRgn
) ;
1353 CopyBits( GetPortBitMapForCopyBits( sourcePort
) ,
1354 GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort
) ) ,
1355 &srcrect
, &dstrect
, mode
, NULL
) ;
1357 DisposeRgn( clipRgn
) ;
1359 UnlockPixels( bmappixels
) ;
1362 m_macPenInstalled
= false ;
1363 m_macBrushInstalled
= false ;
1364 m_macFontInstalled
= false ;
1369 inline Fixed
IntToFixed( int inInt
)
1371 return (((SInt32
) inInt
) << 16);
1375 void wxDC::DoDrawRotatedText(const wxString
& str
, wxCoord x
, wxCoord y
,
1378 wxCHECK_RET( Ok(), wxT("wxDC::DoDrawRotatedText Invalid window dc") );
1382 DrawText(str
, x
, y
);
1386 if ( str
.Length() == 0 )
1389 wxMacPortSetter
helper(this) ;
1393 if ( wxApp::s_macDefaultEncodingIsPC
)
1395 text
= wxMacMakeMacStringFromPC( str
) ;
1402 wxFontRefData
* font
= (wxFontRefData
*) m_font
.GetRefData() ;
1405 m_macFormerAliasState
= IsAntiAliasedTextEnabled(&m_macFormerAliasSize
);
1406 SetAntiAliasedTextEnabled(true, m_scaleY
* font
->m_macFontSize
);
1407 m_macAliasWasEnabled
= true ;
1410 OSStatus status
= noErr
;
1413 status
= TECCreateConverter(&ec
, kTextEncodingMacRoman
, kTextEncodingUnicodeDefault
);
1414 wxASSERT_MSG( status
== noErr
, "couldn't start converter" ) ;
1416 ByteCount byteOutLen
;
1417 ByteCount byteInLen
= text
.Length() ;
1418 ByteCount byteBufferLen
= byteInLen
*2 ;
1419 char* buf
= new char[byteBufferLen
] ;
1421 status
= TECConvertText(ec
, (ConstTextPtr
)text
.c_str() , byteInLen
, &byteInLen
,
1422 (TextPtr
)buf
, byteBufferLen
, &byteOutLen
);
1424 wxASSERT_MSG( status
== noErr
, "couldn't convert text" ) ;
1425 status
= TECDisposeConverter(ec
);
1426 wxASSERT_MSG( status
== noErr
, "couldn't dispose converter" ) ;
1428 ATSUTextLayout atsuLayout
;
1429 UniCharCount chars
= byteOutLen
/ 2 ;
1430 status
= ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr
) buf
, 0 , byteOutLen
/ 2 , byteOutLen
/ 2 , 1 ,
1431 &chars
, (ATSUStyle
*) &m_macATSUIStyle
, &atsuLayout
) ;
1432 wxASSERT_MSG( status
== noErr
, "couldn't create the layout of the rotated text" );
1434 if ( abs(angle
) > 0 )
1436 Fixed atsuAngle
= IntToFixed( angle
) ;
1437 ByteCount angleSize
= sizeof(Fixed
) ;
1438 ATSUAttributeTag rotationTag
= kATSULineRotationTag
;
1439 ATSUAttributeValuePtr angleValue
= &atsuAngle
;
1440 status
= ::ATSUSetLayoutControls(atsuLayout
, 1 , &rotationTag
, &angleSize
, &angleValue
) ;
1443 status
= ::ATSUDrawText( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1444 IntToFixed(XLOG2DEVMAC(x
) ) , IntToFixed(YLOG2DEVMAC(y
) ) );
1445 wxASSERT_MSG( status
== noErr
, "couldn't draw the rotated text" );
1447 status
= ::ATSUMeasureTextImage( atsuLayout
, kATSUFromTextBeginning
, kATSUToTextEnd
,
1448 IntToFixed(XLOG2DEVMAC(x
) ) , IntToFixed(YLOG2DEVMAC(y
) ) , &rect
);
1449 wxASSERT_MSG( status
== noErr
, "couldn't measure the rotated text" );
1451 OffsetRect( &rect
, -m_macLocalOrigin
.x
, -m_macLocalOrigin
.y
) ;
1452 CalcBoundingBox(XDEV2LOG(rect
.left
), YDEV2LOG(rect
.top
) );
1453 CalcBoundingBox(XDEV2LOG(rect
.right
), YDEV2LOG(rect
.bottom
) );
1454 ::ATSUDisposeTextLayout(atsuLayout
);
1458 void wxDC::DoDrawText(const wxString
& strtext
, wxCoord x
, wxCoord y
)
1460 wxCHECK_RET(Ok(), wxT("wxDC::DoDrawText Invalid DC"));
1461 wxMacPortSetter
helper(this) ;
1463 long xx
= XLOG2DEVMAC(x
);
1464 long yy
= YLOG2DEVMAC(y
);
1466 bool useDrawThemeText
= ( DrawThemeTextBox
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1471 m_macFormerAliasState
= IsAntiAliasedTextEnabled(&m_macFormerAliasSize
);
1472 SetAntiAliasedTextEnabled(true, 8);
1473 m_macAliasWasEnabled
= true ;
1477 ::GetFontInfo( &fi
) ;
1480 if ( !useDrawThemeText
)
1484 ::MoveTo( xx
, yy
);
1485 if ( m_backgroundMode
== wxTRANSPARENT
)
1487 ::TextMode( srcOr
) ;
1491 ::TextMode( srcCopy
) ;
1494 const char *text
= NULL
;
1498 if ( wxApp::s_macDefaultEncodingIsPC
)
1500 macText
= wxMacMakeMacStringFromPC( strtext
) ;
1502 length
= macText
.Length() ;
1507 length
= strtext
.Length() ;
1518 if( text
[i
] == 13 || text
[i
] == 10)
1521 if ( useDrawThemeText
)
1523 Rect frame
= { yy
+ line
*(fi
.descent
+ fi
.ascent
+ fi
.leading
) ,xx
, yy
+ (line
+1)*(fi
.descent
+ fi
.ascent
+ fi
.leading
) , xx
+ 1000 } ;
1524 CFStringRef mString
= CFStringCreateWithBytes( NULL
, (UInt8
*) text
+ laststop
, i
- laststop
, CFStringGetSystemEncoding(), false ) ;
1525 ::DrawThemeTextBox( mString
,
1526 kThemeCurrentPortFont
,
1532 CFRelease( mString
) ;
1538 ::DrawText( text
, laststop
, i
- laststop
) ;
1540 ::MoveTo( xx
, yy
+ line
*(fi
.descent
+ fi
.ascent
+ fi
.leading
) );
1547 if ( useDrawThemeText
)
1549 Rect frame
= { yy
+ line
*(fi
.descent
+ fi
.ascent
+ fi
.leading
) ,xx
, yy
+ (line
+1)*(fi
.descent
+ fi
.ascent
+ fi
.leading
) , xx
+ 1000 } ;
1550 CFStringRef mString
= CFStringCreateWithCString( NULL
, text
+ laststop
, kCFStringEncodingMacRoman
) ;
1551 ::DrawThemeTextBox( mString
,
1552 kThemeCurrentPortFont
,
1558 CFRelease( mString
) ;
1563 ::DrawText( text
, laststop
, i
- laststop
) ;
1566 ::TextMode( srcOr
) ;
1569 bool wxDC::CanGetTextExtent() const
1571 wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
1576 void wxDC::DoGetTextExtent( const wxString
&string
, wxCoord
*width
, wxCoord
*height
,
1577 wxCoord
*descent
, wxCoord
*externalLeading
,
1578 wxFont
*theFont
) const
1580 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1581 wxMacPortSetter
helper(this) ;
1583 wxFont formerFont
= m_font
;
1587 // work around the constness
1588 *((wxFont
*)(&m_font
)) = *theFont
;
1594 ::GetFontInfo( &fi
) ;
1596 bool useGetThemeText
= ( GetThemeTextDimensions
!= (void*) kUnresolvedCFragSymbolAddress
) ;
1600 *height
= YDEV2LOGREL( fi
.descent
+ fi
.ascent
) ;
1602 *descent
=YDEV2LOGREL( fi
.descent
);
1603 if ( externalLeading
)
1604 *externalLeading
= YDEV2LOGREL( fi
.leading
) ;
1606 const char *text
= NULL
;
1609 if ( wxApp::s_macDefaultEncodingIsPC
)
1611 macText
= wxMacMakeMacStringFromPC( string
) ;
1613 length
= macText
.Length() ;
1618 length
= string
.Length() ;
1630 if( text
[i
] == 13 || text
[i
] == 10)
1633 *height
+= YDEV2LOGREL( fi
.descent
+ fi
.ascent
+ fi
.leading
) ;
1635 if ( useGetThemeText
)
1637 Point bounds
={0,0} ;
1638 CFStringRef mString
= CFStringCreateWithBytes( NULL
, (UInt8
*) text
+ laststop
, i
- laststop
, CFStringGetSystemEncoding(), false ) ;
1639 ::GetThemeTextDimensions( mString
,
1640 kThemeCurrentPortFont
,
1645 CFRelease( mString
) ;
1646 curwidth
= bounds
.h
;
1651 curwidth
= ::TextWidth( text
, laststop
, i
- laststop
) ;
1653 if ( curwidth
> *width
)
1654 *width
= XDEV2LOGREL( curwidth
) ;
1661 if ( useGetThemeText
)
1663 Point bounds
={0,0} ;
1664 CFStringRef mString
= CFStringCreateWithBytes( NULL
, (UInt8
*) text
+ laststop
, i
- laststop
, CFStringGetSystemEncoding(), false ) ;
1665 ::GetThemeTextDimensions( mString
,
1666 kThemeCurrentPortFont
,
1671 CFRelease( mString
) ;
1672 curwidth
= bounds
.h
;
1677 curwidth
= ::TextWidth( text
, laststop
, i
- laststop
) ;
1679 if ( curwidth
> *width
)
1680 *width
= XDEV2LOGREL( curwidth
) ;
1685 // work around the constness
1686 *((wxFont
*)(&m_font
)) = formerFont
;
1687 m_macFontInstalled
= false ;
1691 wxCoord
wxDC::GetCharWidth(void) const
1693 wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
1695 wxMacPortSetter
helper(this) ;
1699 int width
= ::TextWidth( "n" , 0 , 1 ) ;
1701 return YDEV2LOGREL(width
) ;
1704 wxCoord
wxDC::GetCharHeight(void) const
1706 wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
1708 wxMacPortSetter
helper(this) ;
1713 ::GetFontInfo( &fi
) ;
1715 return YDEV2LOGREL( fi
.descent
+ fi
.ascent
);
1718 void wxDC::Clear(void)
1720 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1721 wxMacPortSetter
helper(this) ;
1722 Rect rect
= { -31000 , -31000 , 31000 , 31000 } ;
1724 if (m_backgroundBrush
.GetStyle() != wxTRANSPARENT
)
1727 //MacInstallBrush() ;
1728 MacSetupBackgroundForCurrentPort( m_backgroundBrush
) ;
1729 ::EraseRect( &rect
) ;
1733 void wxDC::MacInstallFont() const
1735 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1736 // if ( m_macFontInstalled )
1738 Pattern blackColor
;
1740 MacSetupBackgroundForCurrentPort(m_backgroundBrush
) ;
1742 wxFontRefData
* font
= (wxFontRefData
*) m_font
.GetRefData() ;
1746 ::TextFont( font
->m_macFontNum
) ;
1747 ::TextSize( short(m_scaleY
* font
->m_macFontSize
) ) ;
1748 ::TextFace( font
->m_macFontStyle
) ;
1750 m_macFontInstalled
= true ;
1751 m_macBrushInstalled
= false ;
1752 m_macPenInstalled
= false ;
1754 RGBColor forecolor
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel());
1755 RGBColor backcolor
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel());
1756 ::RGBForeColor( &forecolor
);
1757 ::RGBBackColor( &backcolor
);
1761 FontFamilyID fontId
;
1765 GetThemeFont(kThemeSmallSystemFont
, GetApplicationScript() , fontName
, &fontSize
, &fontStyle
) ;
1766 GetFNum( fontName
, &fontId
);
1768 ::TextFont( fontId
) ;
1769 ::TextSize( short(m_scaleY
* fontSize
) ) ;
1770 ::TextFace( fontStyle
) ;
1772 // todo reset after spacing changes - or store the current spacing somewhere
1774 m_macFontInstalled
= true ;
1775 m_macBrushInstalled
= false ;
1776 m_macPenInstalled
= false ;
1778 RGBColor forecolor
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel());
1779 RGBColor backcolor
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel());
1780 ::RGBForeColor( &forecolor
);
1781 ::RGBBackColor( &backcolor
);
1784 short mode
= patCopy
;
1788 switch( m_logicalFunction
)
1793 case wxINVERT
: // NOT dst
1794 ::PenPat(GetQDGlobalsBlack(&blackColor
));
1797 case wxXOR
: // src XOR dst
1800 case wxOR_REVERSE
: // src OR (NOT dst)
1803 case wxSRC_INVERT
: // (NOT src)
1810 case wxAND_REVERSE
:// src AND (NOT dst)
1811 case wxAND
: // src AND dst
1812 case wxAND_INVERT
: // (NOT src) AND dst
1813 case wxNO_OP
: // dst
1814 case wxNOR
: // (NOT src) AND (NOT dst)
1815 case wxEQUIV
: // (NOT src) XOR dst
1816 case wxOR_INVERT
: // (NOT src) OR dst
1817 case wxNAND
: // (NOT src) OR (NOT dst)
1818 case wxOR
: // src OR dst
1820 // case wxSRC_OR: // source _bitmap_ OR destination
1821 // case wxSRC_AND: // source _bitmap_ AND destination
1826 OSStatus status
= noErr
;
1828 Fixed atsuSize
= IntToFixed(m_scaleY
* font
->m_macFontSize
) ;
1830 Style qdStyle
= font
->m_macFontStyle
;
1831 ATSUFontID atsuFont
= font
->m_macATSUFontID
;
1833 status
= ::ATSUCreateStyle(&(ATSUStyle
)m_macATSUIStyle
) ;
1834 wxASSERT_MSG( status
== noErr
, "couldn't create ATSU style" ) ;
1836 ATSUAttributeTag atsuTags
[] =
1841 kATSUBaselineClassTag
,
1842 kATSUVerticalCharacterTag
,
1844 kATSUQDBoldfaceTag
,
1846 kATSUQDUnderlineTag
,
1847 kATSUQDCondensedTag
,
1848 kATSUQDExtendedTag
,
1852 ByteCount atsuSizes
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1854 sizeof( ATSUFontID
) ,
1856 // sizeof( RGBColor ) ,
1857 sizeof( BslnBaselineClass
) ,
1858 sizeof( ATSUVerticalCharacterType
),
1868 Boolean kTrue
= true ;
1869 Boolean kFalse
= false ;
1870 BslnBaselineClass kBaselineDefault
= kBSLNHangingBaseline
;
1872 ATSUVerticalCharacterType kHorizontal
= kATSUStronglyHorizontal
;
1874 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
)/sizeof(ATSUAttributeTag
)] =
1878 // &MAC_WXCOLORREF( m_textForegroundColour.GetPixel() ) ,
1882 (qdStyle
& bold
) ? &kTrue
: &kFalse
,
1883 (qdStyle
& italic
) ? &kTrue
: &kFalse
,
1884 (qdStyle
& underline
) ? &kTrue
: &kFalse
,
1885 (qdStyle
& condense
) ? &kTrue
: &kFalse
,
1886 (qdStyle
& extend
) ? &kTrue
: &kFalse
,
1889 status
= ::ATSUSetAttributes((ATSUStyle
)m_macATSUIStyle
, sizeof(atsuTags
)/sizeof(ATSUAttributeTag
),
1890 atsuTags
, atsuSizes
, atsuValues
);
1891 wxASSERT_MSG( status
== noErr
, "couldn't set create ATSU style" ) ;
1895 Pattern gHatchPatterns
[] =
1897 { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF } ,
1898 { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 } ,
1899 { 0x80 , 0x40 , 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , 0x01 } ,
1900 { 0x10 , 0x10 , 0x10 , 0xFF , 0x10 , 0x10 , 0x10 , 0x10 } ,
1901 { 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 } ,
1902 { 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 } ,
1903 { 0x81 , 0x42 , 0x24 , 0x18 , 0x18 , 0x24 , 0x42 , 0x81 } ,
1906 static void wxMacGetHatchPattern(int hatchStyle
, Pattern
*pattern
)
1912 case wxBDIAGONAL_HATCH
:
1915 case wxFDIAGONAL_HATCH
:
1921 case wxHORIZONTAL_HATCH
:
1924 case wxVERTICAL_HATCH
:
1927 case wxCROSSDIAG_HATCH
:
1931 theIndex
= 1; // solid pattern
1934 *pattern
= gHatchPatterns
[theIndex
-1] ;
1937 void wxDC::MacInstallPen() const
1939 wxCHECK_RET(Ok(), wxT("Invalid DC"));
1943 // if ( m_macPenInstalled )
1946 RGBColor forecolor
= MAC_WXCOLORREF( m_pen
.GetColour().GetPixel());
1947 RGBColor backcolor
= MAC_WXCOLORREF( m_backgroundBrush
.GetColour().GetPixel());
1948 ::RGBForeColor( &forecolor
);
1949 ::RGBBackColor( &backcolor
);
1952 int penWidth
= m_pen
.GetWidth() * (int) m_scaleX
;
1954 // null means only one pixel, at whatever resolution
1955 if ( penWidth
== 0 )
1957 ::PenSize(penWidth
, penWidth
);
1959 int penStyle
= m_pen
.GetStyle();
1961 if (penStyle
== wxSOLID
)
1963 ::PenPat(GetQDGlobalsBlack(&blackColor
));
1965 else if (IS_HATCH(penStyle
))
1968 wxMacGetHatchPattern(penStyle
, &pat
);
1973 Pattern pat
= *GetQDGlobalsBlack(&blackColor
) ;
1977 for ( int i
= 0 ; i
< 8 ; ++i
)
1983 for ( int i
= 0 ; i
< 8 ; ++i
)
1989 for ( int i
= 0 ; i
< 8 ; ++i
)
1995 for ( int i
= 0 ; i
< 8 ; ++i
)
2003 int number
= m_pen
.GetDashes(&dash
) ;
2004 // right now we don't allocate larger pixmaps
2005 for ( int i
= 0 ; i
< 8 ; ++i
)
2007 pat
.pat
[i
] = dash
[0] ;
2015 short mode
= patCopy
;
2019 switch( m_logicalFunction
)
2021 case wxCOPY
: // only foreground color, leave background (thus not patCopy)
2024 case wxINVERT
: // NOT dst
2025 // ::PenPat(GetQDGlobalsBlack(&blackColor));
2028 case wxXOR
: // src XOR dst
2031 case wxOR_REVERSE
: // src OR (NOT dst)
2034 case wxSRC_INVERT
: // (NOT src)
2041 case wxAND_REVERSE
:// src AND (NOT dst)
2042 case wxAND
: // src AND dst
2043 case wxAND_INVERT
: // (NOT src) AND dst
2044 case wxNO_OP
: // dst
2045 case wxNOR
: // (NOT src) AND (NOT dst)
2046 case wxEQUIV
: // (NOT src) XOR dst
2047 case wxOR_INVERT
: // (NOT src) OR dst
2048 case wxNAND
: // (NOT src) OR (NOT dst)
2049 case wxOR
: // src OR dst
2051 // case wxSRC_OR: // source _bitmap_ OR destination
2052 // case wxSRC_AND: // source _bitmap_ AND destination
2056 m_macPenInstalled
= true ;
2057 m_macBrushInstalled
= false ;
2058 m_macFontInstalled
= false ;
2061 void wxDC::MacSetupBackgroundForCurrentPort(const wxBrush
& background
)
2063 Pattern whiteColor
;
2064 switch( background
.MacGetBrushKind() )
2066 case kwxMacBrushTheme
:
2068 ::SetThemeBackground( background
.GetMacTheme() , wxDisplayDepth() , true ) ;
2071 case kwxMacBrushThemeBackground
:
2074 ThemeBackgroundKind bg
= background
.GetMacThemeBackground( &extent
) ;
2075 ::ApplyThemeBackground( bg
, &extent
,kThemeStateActive
, wxDisplayDepth() , true ) ;
2078 case kwxMacBrushColour
:
2080 ::RGBBackColor( &MAC_WXCOLORREF( background
.GetColour().GetPixel()) );
2081 int brushStyle
= background
.GetStyle();
2082 if (brushStyle
== wxSOLID
)
2083 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
2084 else if (IS_HATCH(brushStyle
))
2087 wxMacGetHatchPattern(brushStyle
, &pat
);
2092 ::BackPat(GetQDGlobalsWhite(&whiteColor
));
2099 void wxDC::MacInstallBrush() const
2101 wxCHECK_RET(Ok(), wxT("Invalid DC"));
2103 Pattern blackColor
;
2104 // if ( m_macBrushInstalled )
2109 bool backgroundTransparent
= (GetBackgroundMode() == wxTRANSPARENT
) ;
2111 ::RGBForeColor( &MAC_WXCOLORREF( m_brush
.GetColour().GetPixel()) );
2112 ::RGBBackColor( &MAC_WXCOLORREF( m_backgroundBrush
.GetColour().GetPixel()) );
2114 int brushStyle
= m_brush
.GetStyle();
2115 if (brushStyle
== wxSOLID
)
2117 ::PenPat(GetQDGlobalsBlack(&blackColor
));
2119 else if (IS_HATCH(brushStyle
))
2122 wxMacGetHatchPattern(brushStyle
, &pat
);
2125 else if ( m_brush
.GetStyle() == wxSTIPPLE
|| m_brush
.GetStyle() == wxSTIPPLE_MASK_OPAQUE
)
2127 // we force this in order to be compliant with wxMSW
2128 backgroundTransparent
= false ;
2129 // for these the text fore (and back for MASK_OPAQUE) colors are used
2130 wxBitmap
* bitmap
= m_brush
.GetStipple() ;
2131 int width
= bitmap
->GetWidth() ;
2132 int height
= bitmap
->GetHeight() ;
2133 GWorldPtr gw
= NULL
;
2135 if ( m_brush
.GetStyle() == wxSTIPPLE
)
2136 gw
= MAC_WXHBITMAP(bitmap
->GetHBITMAP()) ;
2138 gw
= MAC_WXHBITMAP(bitmap
->GetMask()->GetMaskBitmap()) ;
2140 PixMapHandle gwpixmaphandle
= GetGWorldPixMap( gw
) ;
2141 LockPixels( gwpixmaphandle
) ;
2143 bool isMonochrome
= !IsPortColor( gw
) ;
2145 if ( !isMonochrome
)
2147 if ( (**gwpixmaphandle
).pixelSize
== 1 )
2148 isMonochrome
= true ;
2151 if ( isMonochrome
&& width
== 8 && height
== 8 )
2153 ::RGBForeColor( &MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) );
2154 ::RGBForeColor( &MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) );
2155 BitMap
* gwbitmap
= (BitMap
*) *gwpixmaphandle
; // since the color depth is 1 it is a BitMap
2156 UInt8
*gwbits
= (UInt8
*) gwbitmap
->baseAddr
;
2157 int alignment
= gwbitmap
->rowBytes
& 0x7FFF ;
2159 for ( int i
= 0 ; i
< 8 ; ++i
)
2161 pat
.pat
[i
] = gwbits
[i
*alignment
+0] ;
2163 UnlockPixels( GetGWorldPixMap( gw
) ) ;
2168 // this will be the code to handle power of 2 patterns, we will have to arrive at a nice
2169 // caching scheme before putting this into production
2172 PixPatHandle pixpat
= NewPixPat() ;
2174 CopyPixMap(gwpixmaphandle
, (**pixpat
).patMap
);
2175 imageSize
= GetPixRowBytes((**pixpat
).patMap
) *
2176 ((**(**pixpat
).patMap
).bounds
.bottom
-
2177 (**(**pixpat
).patMap
).bounds
.top
);
2179 PtrToHand( (**gwpixmaphandle
).baseAddr
, &image
, imageSize
);
2180 (**pixpat
).patData
= image
;
2183 CTabHandle ctable
= ((**((**pixpat
).patMap
)).pmTable
) ;
2184 ColorSpecPtr ctspec
= (ColorSpecPtr
) &(**ctable
).ctTable
;
2185 if ( ctspec
[0].rgb
.red
== 0x0000 )
2187 ctspec
[1].rgb
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) ;
2188 ctspec
[0].rgb
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) ;
2192 ctspec
[0].rgb
= MAC_WXCOLORREF( m_textBackgroundColour
.GetPixel()) ;
2193 ctspec
[1].rgb
= MAC_WXCOLORREF( m_textForegroundColour
.GetPixel()) ;
2195 ::CTabChanged( ctable
) ;
2197 ::PenPixPat(pixpat
);
2198 m_macForegroundPixMap
= pixpat
;
2200 UnlockPixels( gwpixmaphandle
) ;
2204 ::PenPat(GetQDGlobalsBlack(&blackColor
));
2207 short mode
= patCopy
;
2208 switch( m_logicalFunction
)
2211 if ( backgroundTransparent
)
2216 case wxINVERT
: // NOT dst
2217 if ( !backgroundTransparent
)
2219 ::PenPat(GetQDGlobalsBlack(&blackColor
));
2223 case wxXOR
: // src XOR dst
2226 case wxOR_REVERSE
: // src OR (NOT dst)
2229 case wxSRC_INVERT
: // (NOT src)
2236 case wxAND_REVERSE
:// src AND (NOT dst)
2237 case wxAND
: // src AND dst
2238 case wxAND_INVERT
: // (NOT src) AND dst
2239 case wxNO_OP
: // dst
2240 case wxNOR
: // (NOT src) AND (NOT dst)
2241 case wxEQUIV
: // (NOT src) XOR dst
2242 case wxOR_INVERT
: // (NOT src) OR dst
2243 case wxNAND
: // (NOT src) OR (NOT dst)
2244 case wxOR
: // src OR dst
2246 // case wxSRC_OR: // source _bitmap_ OR destination
2247 // case wxSRC_AND: // source _bitmap_ AND destination
2251 m_macBrushInstalled
= true ;
2252 m_macPenInstalled
= false ;
2253 m_macFontInstalled
= false ;
2256 // ---------------------------------------------------------------------------
2257 // coordinates transformations
2258 // ---------------------------------------------------------------------------
2261 wxCoord
wxDCBase::DeviceToLogicalX(wxCoord x
) const
2263 return ((wxDC
*)this)->XDEV2LOG(x
);
2266 wxCoord
wxDCBase::DeviceToLogicalY(wxCoord y
) const
2268 return ((wxDC
*)this)->YDEV2LOG(y
);
2271 wxCoord
wxDCBase::DeviceToLogicalXRel(wxCoord x
) const
2273 return ((wxDC
*)this)->XDEV2LOGREL(x
);
2276 wxCoord
wxDCBase::DeviceToLogicalYRel(wxCoord y
) const
2278 return ((wxDC
*)this)->YDEV2LOGREL(y
);
2281 wxCoord
wxDCBase::LogicalToDeviceX(wxCoord x
) const
2283 return ((wxDC
*)this)->XLOG2DEV(x
);
2286 wxCoord
wxDCBase::LogicalToDeviceY(wxCoord y
) const
2288 return ((wxDC
*)this)->YLOG2DEV(y
);
2291 wxCoord
wxDCBase::LogicalToDeviceXRel(wxCoord x
) const
2293 return ((wxDC
*)this)->XLOG2DEVREL(x
);
2296 wxCoord
wxDCBase::LogicalToDeviceYRel(wxCoord y
) const
2298 return ((wxDC
*)this)->YLOG2DEVREL(y
);