X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/670f9935630beb2123a5ca62894ae92a3f0efa4f..b724bafee0cbbb5c587d11e82a18c8ea5b060f26:/src/mac/carbon/dc.cpp?ds=inline diff --git a/src/mac/carbon/dc.cpp b/src/mac/carbon/dc.cpp index 1d07f86074..79195c147d 100644 --- a/src/mac/carbon/dc.cpp +++ b/src/mac/carbon/dc.cpp @@ -18,13 +18,13 @@ #ifndef WX_PRECOMP #include "wx/log.h" #include "wx/app.h" + #include "wx/dcmemory.h" + #include "wx/dcprint.h" + #include "wx/region.h" + #include "wx/image.h" #endif #include "wx/mac/uma.h" -#include "wx/dcmemory.h" -#include "wx/dcprint.h" -#include "wx/region.h" -#include "wx/image.h" #ifdef __MSL__ #if __MSL__ >= 0x6000 @@ -55,9 +55,6 @@ const double RAD2DEG = 180.0 / M_PI; const short kEmulatedMode = -1 ; const short kUnsupportedMode = -2 ; -extern TECObjectRef s_TECNativeCToUnicode ; - - wxMacPortSetter::wxMacPortSetter( const wxDC* dc ) : m_ph( (GrafPtr) dc->m_macPort ) { @@ -154,13 +151,6 @@ wxMacWindowStateSaver::~wxMacWindowStateSaver() SetThemeDrawingState( m_themeDrawingState , true ) ; } -//----------------------------------------------------------------------------- -// Local functions -//----------------------------------------------------------------------------- -static inline double dmin(double a, double b) { return a < b ? a : b; } -static inline double dmax(double a, double b) { return a > b ? a : b; } -static inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; } - //----------------------------------------------------------------------------- // wxDC //----------------------------------------------------------------------------- @@ -272,26 +262,11 @@ wxDC::wxDC() { m_ok = false; m_colour = true; - m_mm_to_pix_x = mm2pt; - m_mm_to_pix_y = mm2pt; - m_internalDeviceOriginX = 0; - m_internalDeviceOriginY = 0; - m_externalDeviceOriginX = 0; - m_externalDeviceOriginY = 0; - m_logicalScaleX = 1.0; - m_logicalScaleY = 1.0; - m_userScaleX = 1.0; - m_userScaleY = 1.0; - m_scaleX = 1.0; - m_scaleY = 1.0; - m_needComputeScaleX = false; - m_needComputeScaleY = false; m_macPort = NULL ; m_macMask = NULL ; m_macFontInstalled = false ; m_macBrushInstalled = false ; m_macPenInstalled = false ; - m_macLocalOrigin.x = m_macLocalOrigin.y = 0 ; m_macBoundaryClipRgn = NewRgn() ; m_macCurrentClipRgn = NewRgn() ; SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , -32000 , -32000 , 32000 , 32000 ) ; @@ -577,77 +552,6 @@ void wxDC::SetTextBackground( const wxColour &col ) m_macFontInstalled = false ; } -void wxDC::SetMapMode( int mode ) -{ - switch (mode) - { - case wxMM_TWIPS: - SetLogicalScale( twips2mm * m_mm_to_pix_x, twips2mm * m_mm_to_pix_y ); - break; - - case wxMM_POINTS: - SetLogicalScale( pt2mm * m_mm_to_pix_x, pt2mm * m_mm_to_pix_y ); - break; - - case wxMM_METRIC: - SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y ); - break; - - case wxMM_LOMETRIC: - SetLogicalScale( m_mm_to_pix_x / 10.0, m_mm_to_pix_y / 10.0 ); - break; - - default: - case wxMM_TEXT: - SetLogicalScale( 1.0, 1.0 ); - break; - } - - if (mode != wxMM_TEXT) - { - m_needComputeScaleX = true; - m_needComputeScaleY = true; - } -} - -void wxDC::SetUserScale( double x, double y ) -{ - // allow negative ? -> no - m_userScaleX = x; - m_userScaleY = y; - ComputeScaleAndOrigin(); -} - -void wxDC::SetLogicalScale( double x, double y ) -{ - // allow negative ? - m_logicalScaleX = x; - m_logicalScaleY = y; - ComputeScaleAndOrigin(); -} - -void wxDC::SetLogicalOrigin( wxCoord x, wxCoord y ) -{ - // is this still correct ? - m_logicalOriginX = x * m_signX; - m_logicalOriginY = y * m_signY; - ComputeScaleAndOrigin(); -} - -void wxDC::SetDeviceOrigin( wxCoord x, wxCoord y ) -{ - m_externalDeviceOriginX = x; - m_externalDeviceOriginY = y; - ComputeScaleAndOrigin(); -} - -void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) -{ - m_signX = (xLeftRight ? 1 : -1); - m_signY = (yBottomUp ? -1 : 1); - ComputeScaleAndOrigin(); -} - wxSize wxDC::GetPPI() const { return wxSize(72, 72); @@ -661,27 +565,6 @@ int wxDC::GetDepth() const return 1 ; } -void wxDC::ComputeScaleAndOrigin() -{ - // CMB: copy scale to see if it changes - double origScaleX = m_scaleX; - double origScaleY = m_scaleY; - m_scaleX = m_logicalScaleX * m_userScaleX; - m_scaleY = m_logicalScaleY * m_userScaleY; - m_deviceOriginX = m_internalDeviceOriginX + m_externalDeviceOriginX; - m_deviceOriginY = m_internalDeviceOriginY + m_externalDeviceOriginY; - - // CMB: if scale has changed call SetPen to recalulate the line width - if (m_scaleX != origScaleX || m_scaleY != origScaleY) - { - // this is a bit artificial, but we need to force wxDC to think - // the pen has changed - wxPen pen(GetPen()); - m_pen = wxNullPen; - SetPen(pen); - } -} - void wxDC::SetPalette( const wxPalette& palette ) { } @@ -756,7 +639,7 @@ bool wxDC::DoGetPixel( wxCoord x, wxCoord y, wxColour *col ) const GetCPixel( XLOG2DEVMAC(x), YLOG2DEVMAC(y), &colour ); // convert from Mac colour to wx - col->Set( colour.red >> 8, colour.green >> 8, colour.blue >> 8); + *col = colour; return true ; } @@ -1185,12 +1068,26 @@ bool wxDC::CanDrawBitmap(void) const return true ; } -bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, +bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord dstWidth, wxCoord dstHeight, wxDC *source, wxCoord xsrc, wxCoord ysrc, int logical_func , bool useMask, wxCoord xsrcMask, wxCoord ysrcMask ) { - wxCHECK_MSG(Ok(), false, wxT("wxDC::DoBlit - invalid DC")); - wxCHECK_MSG(source->Ok(), false, wxT("wxDC::DoBlit - invalid source DC")); + return DoStretchBlit( xdest, ydest, dstWidth, dstHeight, + source, xsrc, ysrc, dstWidth, dstHeight, + logical_func, useMask, + xsrcMask, ysrcMask ); +} + +bool wxDC::DoStretchBlit(wxCoord xdest, wxCoord ydest, + wxCoord dstWidth, wxCoord dstHeight, + wxDC *source, + wxCoord xsrc, wxCoord ysrc, + wxCoord srcWidth, wxCoord srcHeight, + int logical_func, bool useMask, + wxCoord xsrcMask, wxCoord ysrcMask) +{ + wxCHECK_MSG(Ok(), false, wxT("wxDC::DoStretchBlit - invalid DC")); + wxCHECK_MSG(source->Ok(), false, wxT("wxDC::DoStretchBlit - invalid source DC")); if ( logical_func == wxNO_OP ) return true ; @@ -1208,12 +1105,12 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, Rect srcrect , dstrect ; srcrect.top = source->YLOG2DEVMAC(ysrc) ; srcrect.left = source->XLOG2DEVMAC(xsrc) ; - srcrect.right = source->XLOG2DEVMAC(xsrc + width ) ; - srcrect.bottom = source->YLOG2DEVMAC(ysrc + height) ; + srcrect.right = source->XLOG2DEVMAC(xsrc + srcWidth ) ; + srcrect.bottom = source->YLOG2DEVMAC(ysrc + srcHeight) ; dstrect.top = YLOG2DEVMAC(ydest) ; dstrect.left = XLOG2DEVMAC(xdest) ; - dstrect.bottom = YLOG2DEVMAC(ydest + height ) ; - dstrect.right = XLOG2DEVMAC(xdest + width ) ; + dstrect.bottom = YLOG2DEVMAC(ydest + dstHeight ) ; + dstrect.right = XLOG2DEVMAC(xdest + dstWidth ) ; short mode = kUnsupportedMode ; bool invertDestinationFirst = false ; @@ -1474,7 +1371,6 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, double angle) { - // TODO: support text background color (only possible by hand, ATSUI does not support it) wxCHECK_RET( Ok(), wxT("wxDC::DoDrawRotatedText - invalid DC") ); if ( str.empty() ) @@ -1483,44 +1379,13 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, wxMacFastPortSetter helper(this) ; MacInstallFont() ; -#if 0 - if ( 0 ) - { - m_macFormerAliasState = IsAntiAliasedTextEnabled(&m_macFormerAliasSize); - SetAntiAliasedTextEnabled(true, SInt16(m_scaleY * m_font.MacGetFontSize())); - m_macAliasWasEnabled = true ; - } -#endif - OSStatus status = noErr ; ATSUTextLayout atsuLayout ; - UniCharCount chars = str.length() ; - UniChar* ubuf = NULL ; - -#if SIZEOF_WCHAR_T == 4 - wxMBConvUTF16 converter ; -#if wxUSE_UNICODE - size_t unicharlen = converter.WC2MB( NULL , str.wc_str() , 0 ) ; - ubuf = (UniChar*) malloc( unicharlen + 2 ) ; - converter.WC2MB( (char*) ubuf , str.wc_str(), unicharlen + 2 ) ; -#else - const wxWCharBuffer wchar = str.wc_str( wxConvLocal ) ; - size_t unicharlen = converter.WC2MB( NULL , wchar.data() , 0 ) ; - ubuf = (UniChar*) malloc( unicharlen + 2 ) ; - converter.WC2MB( (char*) ubuf , wchar.data() , unicharlen + 2 ) ; -#endif - chars = unicharlen / 2 ; -#else -#if wxUSE_UNICODE - ubuf = (UniChar*) str.wc_str() ; -#else - wxWCharBuffer wchar = str.wc_str( wxConvLocal ) ; - chars = wxWcslen( wchar.data() ) ; - ubuf = (UniChar*) wchar.data() ; -#endif -#endif - status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) ubuf , 0 , chars , chars , 1 , + wxMacUniCharBuffer unibuf( str ) ; + UniCharCount chars = unibuf.GetChars() ; + + status = ::ATSUCreateTextLayoutWithTextPtr( unibuf.GetBuffer() , 0 , chars , chars , 1 , &chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ; wxASSERT_MSG( status == noErr , wxT("couldn't create the layout of the rotated text") ); @@ -1535,29 +1400,66 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, ATSUTextMeasurement textBefore, textAfter ; ATSUTextMeasurement ascent, descent ; - if ( abs(iAngle) > 0 ) + ATSLineLayoutOptions layoutOptions = kATSLineNoLayoutOptions ; + + if (m_font.GetNoAntiAliasing()) { - Fixed atsuAngle = IntToFixed( iAngle ) ; + layoutOptions |= kATSLineNoAntiAliasing ; + } - ATSUAttributeTag atsuTags[] = - { - kATSULineRotationTag , - } ; - ByteCount atsuSizes[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = - { - sizeof( Fixed ) , - } ; - ATSUAttributeValuePtr atsuValues[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = - { - &atsuAngle , - } ; + Fixed atsuAngle = IntToFixed( iAngle ) ; + + ATSUAttributeTag atsuTags[] = + { + kATSULineLayoutOptionsTag , + kATSULineRotationTag , + } ; - status = ::ATSUSetLayoutControls(atsuLayout , sizeof(atsuTags)/sizeof(ATSUAttributeTag), + ByteCount atsuSizes[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = + { + sizeof( ATSLineLayoutOptions ) , + sizeof( Fixed ) , + } ; + + ATSUAttributeValuePtr atsuValues[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = + { + &layoutOptions , + &atsuAngle , + } ; + + status = ::ATSUSetLayoutControls(atsuLayout , sizeof(atsuTags)/sizeof(ATSUAttributeTag) - ( abs(iAngle) > 0.001 ? 0 : 1), atsuTags, atsuSizes, atsuValues ) ; - } status = ::ATSUMeasureText( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd, &textBefore , &textAfter, &ascent , &descent ); + wxASSERT_MSG( status == noErr , wxT("couldn't measure the rotated text") ); + + if ( m_backgroundMode == wxSOLID ) + { + // background painting must be done by hand, cannot be done by ATSUI + wxCoord x2 , y2 ; + PolyHandle polygon = OpenPoly(); + + ::MoveTo(drawX, drawY); + + x2 = (int) (drawX + sin(angle / RAD2DEG) * FixedToInt(ascent + descent)) ; + y2 = (int) (drawY + cos(angle / RAD2DEG) * FixedToInt(ascent + descent)) ; + ::LineTo(x2, y2); + + x2 = (int) (drawX + sin(angle / RAD2DEG) * FixedToInt(ascent + descent ) + cos(angle / RAD2DEG) * FixedToInt(textAfter)) ; + y2 = (int) (drawY + cos(angle / RAD2DEG) * FixedToInt(ascent + descent) - sin(angle / RAD2DEG) * FixedToInt(textAfter)) ; + ::LineTo(x2, y2); + + x2 = (int) (drawX + cos(angle / RAD2DEG) * FixedToInt(textAfter)) ; + y2 = (int) (drawY - sin(angle / RAD2DEG) * FixedToInt(textAfter)) ; + ::LineTo(x2, y2); + + ::LineTo( drawX, drawY) ; + ClosePoly(); + + ::ErasePoly( polygon ); + KillPoly( polygon ); + } drawX += (int)(sin(angle / RAD2DEG) * FixedToInt(ascent)); drawY += (int)(cos(angle / RAD2DEG) * FixedToInt(ascent)); @@ -1571,90 +1473,15 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, IntToFixed(drawX) , IntToFixed(drawY) , &rect ); wxASSERT_MSG( status == noErr , wxT("couldn't measure the rotated text") ); - OffsetRect( &rect , -m_macLocalOrigin.x , -m_macLocalOrigin.y ) ; + OffsetRect( &rect , -m_deviceLocalOriginX , -m_deviceLocalOriginY ) ; CalcBoundingBox(XDEV2LOG(rect.left), YDEV2LOG(rect.top) ); CalcBoundingBox(XDEV2LOG(rect.right), YDEV2LOG(rect.bottom) ); ::ATSUDisposeTextLayout(atsuLayout); - -#if SIZEOF_WCHAR_T == 4 - free( ubuf ) ; -#endif } void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) { - wxCHECK_RET(Ok(), wxT("wxDC::DoDrawText - invalid DC")); - - wxMacFastPortSetter helper(this) ; - long xx = XLOG2DEVMAC(x); - long yy = YLOG2DEVMAC(y); - -#if TARGET_CARBON - bool useDrawThemeText = ( DrawThemeTextBox != (void*) kUnresolvedCFragSymbolAddress ) ; - if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC ) ) || m_font.GetNoAntiAliasing() ) - useDrawThemeText = false ; -#endif - - MacInstallFont() ; - - FontInfo fi ; - ::GetFontInfo( &fi ) ; - -#if TARGET_CARBON - if ( !useDrawThemeText ) - yy += fi.ascent ; -#else - yy += fi.ascent ; -#endif - - ::TextMode( (m_backgroundMode == wxTRANSPARENT) ? srcOr : srcCopy ) ; - ::MoveTo( xx , yy ); - - int line = 0 ; - { - wxString linetext = strtext ; - -#if TARGET_CARBON - if ( useDrawThemeText ) - { - Rect frame = { - yy + line*(fi.descent + fi.ascent + fi.leading), xx , - yy + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 10000 } ; - wxMacCFStringHolder mString( linetext , m_font.GetEncoding()) ; - - if ( m_backgroundMode != wxTRANSPARENT ) - { - Point bounds = {0, 0} ; - Rect background = frame ; - SInt16 baseline ; - ::GetThemeTextDimensions( mString, - m_font.MacGetThemeFontID() , - kThemeStateActive, - false, - &bounds, - &baseline ); - background.right = background.left + bounds.h ; - background.bottom = background.top + bounds.v ; - ::EraseRect( &background ) ; - } - - ::DrawThemeTextBox( mString, - m_font.MacGetThemeFontID() , - kThemeStateActive, - false, - &frame, - teJustLeft, - NULL ); - } - else -#endif - { - wxCharBuffer text = linetext.mb_str(wxConvLocal) ; - ::DrawText( text , 0 , strlen(text) ) ; - } - } - - ::TextMode( srcOr ) ; + DoDrawRotatedText( strtext , x , y , 0) ; } bool wxDC::CanGetTextExtent() const @@ -1664,9 +1491,10 @@ bool wxDC::CanGetTextExtent() const return true ; } -void wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *height, + +void wxDC::DoGetTextExtent( const wxString &str, wxCoord *width, wxCoord *height, wxCoord *descent, wxCoord *externalLeading , - wxFont *theFont ) const + const wxFont *theFont ) const { wxCHECK_RET(Ok(), wxT("wxDC::DoGetTextExtent - invalid DC")); @@ -1679,51 +1507,63 @@ void wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *he } MacInstallFont() ; - FontInfo fi ; - ::GetFontInfo( &fi ) ; -#if TARGET_CARBON - bool useGetThemeText = ( GetThemeTextDimensions != (void*) kUnresolvedCFragSymbolAddress ) ; - if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC ) ) || ((wxFont*)&m_font)->GetNoAntiAliasing() ) - useGetThemeText = false ; -#endif + OSStatus status = noErr ; + ATSUTextLayout atsuLayout ; + + wxMacUniCharBuffer unibuf( str ) ; + UniCharCount chars = unibuf.GetChars() ; + + status = ::ATSUCreateTextLayoutWithTextPtr( unibuf.GetBuffer() , 0 , chars , chars , 1 , + &chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ; + + wxASSERT_MSG( status == noErr , wxT("couldn't create the layout of the text") ); + + status = ::ATSUSetTransientFontMatching( atsuLayout , true ) ; + wxASSERT_MSG( status == noErr , wxT("couldn't setup transient font matching") ); + + ATSLineLayoutOptions layoutOptions = kATSLineNoLayoutOptions ; + + if (m_font.GetNoAntiAliasing()) + { + layoutOptions |= kATSLineNoAntiAliasing ; + } + + ATSUAttributeTag atsuTags[] = + { + kATSULineLayoutOptionsTag , + } ; + + ByteCount atsuSizes[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = + { + sizeof( ATSLineLayoutOptions ) , + } ; + + ATSUAttributeValuePtr atsuValues[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = + { + &layoutOptions , + } ; + + status = ::ATSUSetLayoutControls(atsuLayout , sizeof(atsuTags)/sizeof(ATSUAttributeTag) , + atsuTags, atsuSizes, atsuValues ) ; + + ATSUTextMeasurement textBefore, textAfter ; + ATSUTextMeasurement textAscent, textDescent ; + + status = ::ATSUGetUnjustifiedBounds( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd, + &textBefore , &textAfter, &textAscent , &textDescent ); if ( height ) - *height = YDEV2LOGREL( fi.descent + fi.ascent ) ; + *height = YDEV2LOGREL( FixedToInt(textAscent + textDescent) ) ; if ( descent ) - *descent =YDEV2LOGREL( fi.descent ); + *descent =YDEV2LOGREL( FixedToInt(textDescent) ); if ( externalLeading ) - *externalLeading = YDEV2LOGREL( fi.leading ) ; - - int curwidth = 0 ; + *externalLeading = 0 ; if ( width ) - { - *width = 0 ; - wxString linetext = strtext ; + *width = XDEV2LOGREL( FixedToInt(textAfter - textBefore) ) ; - if ( useGetThemeText ) - { - Point bounds = {0, 0} ; - SInt16 baseline ; - wxMacCFStringHolder mString( linetext , m_font.GetEncoding() ) ; - ThemeFontID themeFont = m_font.MacGetThemeFontID() ; - ::GetThemeTextDimensions( mString, - themeFont , - kThemeStateActive, - false, - &bounds, - &baseline ); - curwidth = bounds.h ; - } - else - { - wxCharBuffer text = linetext.mb_str(wxConvLocal) ; - curwidth = ::TextWidth( text , 0 , strlen(text) ) ; - } + ::ATSUDisposeTextLayout(atsuLayout); - if ( curwidth > *width ) - *width = XDEV2LOGREL( curwidth ) ; - } if ( theFont ) { @@ -1746,102 +1586,77 @@ bool wxDC::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) con wxMacFastPortSetter helper(this) ; MacInstallFont() ; -#if TARGET_CARBON - bool useGetThemeText = ( GetThemeTextDimensions != (void*) kUnresolvedCFragSymbolAddress ) ; - if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC ) ) || ((wxFont*)&m_font)->GetNoAntiAliasing() ) - useGetThemeText = false ; + OSStatus status = noErr ; + ATSUTextLayout atsuLayout ; + + wxMacUniCharBuffer unibuf( text ) ; + UniCharCount chars = unibuf.GetChars() ; + + status = ::ATSUCreateTextLayoutWithTextPtr( unibuf.GetBuffer() , 0 , chars , chars , 1 , + &chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ; + + wxASSERT_MSG( status == noErr , wxT("couldn't create the layout of the text") ); + + status = ::ATSUSetTransientFontMatching( atsuLayout , true ) ; + wxASSERT_MSG( status == noErr , wxT("couldn't setup transient font matching") ); - if ( useGetThemeText ) + ATSLineLayoutOptions layoutOptions = kATSLineNoLayoutOptions ; + + if (m_font.GetNoAntiAliasing()) { - // If anybody knows how to do this more efficiently yet still handle - // the fractional glyph widths that may be present when using AA - // fonts, please change it. Currently it is measuring from the - // beginning of the string for each succeeding substring, which is much - // slower than this should be. - for (size_t i=0; iGetNoAntiAliasing() ) - useGetThemeText = false ; - - if ( useGetThemeText ) - { - Point bounds = {0, 0} ; - SInt16 baseline ; - CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text , 1 , CFStringGetSystemEncoding(), false ) ; - ::GetThemeTextDimensions( mString, - m_font.MacGetThemeFontID(), - kThemeStateActive, - false, - &bounds, - &baseline ); - CFRelease( mString ) ; - width = bounds.h ; - } - else -#endif - { - width = ::TextWidth( text , 0 , 1 ) ; - } - - return YDEV2LOGREL(width) ; + wxCoord width = 0 ; + DoGetTextExtent( wxT("g"), &width , NULL , NULL , NULL , NULL ) ; + return width ; } wxCoord wxDC::GetCharHeight(void) const { - wxCHECK_MSG(Ok(), 1, wxT("wxDC::GetCharHeight - invalid DC")); - - wxMacFastPortSetter helper(this) ; - MacInstallFont() ; - FontInfo fi ; - ::GetFontInfo( &fi ) ; - - return YDEV2LOGREL( fi.descent + fi.ascent ); + wxCoord height ; + DoGetTextExtent( wxT("g") , NULL , &height , NULL , NULL , NULL ) ; + return height ; } void wxDC::Clear(void) @@ -2328,44 +2143,44 @@ void wxDC::MacInstallBrush() const // coordinates transformations // --------------------------------------------------------------------------- -wxCoord wxDCBase::DeviceToLogicalX(wxCoord x) const +wxCoord wxDC::DeviceToLogicalX(wxCoord x) const { - return ((wxDC *)this)->XDEV2LOG(x); + return XDEV2LOG(x); } -wxCoord wxDCBase::DeviceToLogicalY(wxCoord y) const +wxCoord wxDC::DeviceToLogicalY(wxCoord y) const { - return ((wxDC *)this)->YDEV2LOG(y); + return YDEV2LOG(y); } -wxCoord wxDCBase::DeviceToLogicalXRel(wxCoord x) const +wxCoord wxDC::DeviceToLogicalXRel(wxCoord x) const { - return ((wxDC *)this)->XDEV2LOGREL(x); + return XDEV2LOGREL(x); } -wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const +wxCoord wxDC::DeviceToLogicalYRel(wxCoord y) const { - return ((wxDC *)this)->YDEV2LOGREL(y); + return YDEV2LOGREL(y); } -wxCoord wxDCBase::LogicalToDeviceX(wxCoord x) const +wxCoord wxDC::LogicalToDeviceX(wxCoord x) const { - return ((wxDC *)this)->XLOG2DEV(x); + return XLOG2DEV(x); } -wxCoord wxDCBase::LogicalToDeviceY(wxCoord y) const +wxCoord wxDC::LogicalToDeviceY(wxCoord y) const { - return ((wxDC *)this)->YLOG2DEV(y); + return YLOG2DEV(y); } -wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const +wxCoord wxDC::LogicalToDeviceXRel(wxCoord x) const { - return ((wxDC *)this)->XLOG2DEVREL(x); + return XLOG2DEVREL(x); } -wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const +wxCoord wxDC::LogicalToDeviceYRel(wxCoord y) const { - return ((wxDC *)this)->YLOG2DEVREL(y); + return YLOG2DEVREL(y); } #endif // !wxMAC_USE_CORE_GRAPHICS