X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/99030bdf57b8d590066092d2f466626f9bdef172..29e4a1901a9d0cd738af42f4207ae185eaf3b96e:/src/mac/carbon/dc.cpp diff --git a/src/mac/carbon/dc.cpp b/src/mac/carbon/dc.cpp index 2acff5c48a..364c45fcf1 100644 --- a/src/mac/carbon/dc.cpp +++ b/src/mac/carbon/dc.cpp @@ -1464,6 +1464,7 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) long yy = YLOG2DEVMAC(y); #if TARGET_CARBON bool useDrawThemeText = ( DrawThemeTextBox != (void*) kUnresolvedCFragSymbolAddress ) ; + useDrawThemeText = false ; #endif MacInstallFont() ; if ( 0 ) @@ -1525,7 +1526,7 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) ::DrawThemeTextBox( mString, kThemeCurrentPortFont, kThemeStateActive, - true, + false, &frame, teJustLeft, nil ); @@ -1551,7 +1552,7 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) ::DrawThemeTextBox( mString, kThemeCurrentPortFont, kThemeStateActive, - true, + false, &frame, teJustLeft, nil ); @@ -1584,22 +1585,18 @@ void wxDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *he if ( theFont ) { - wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; - - if ( font ) - { - ::TextFont( font->m_macFontNum ) ; - ::TextSize( YLOG2DEVREL( font->m_macFontSize) ) ; - ::TextFace( font->m_macFontStyle ) ; - } - } - else - { - MacInstallFont() ; + // work around the constness + *((wxFont*)(&m_font)) = *theFont ; } + MacInstallFont() ; + FontInfo fi ; ::GetFontInfo( &fi ) ; +#if TARGET_CARBON + bool useGetThemeText = ( GetThemeTextDimensions != (void*) kUnresolvedCFragSymbolAddress ) ; + useGetThemeText = false ; +#endif if ( height ) *height = YDEV2LOGREL( fi.descent + fi.ascent ) ; @@ -1636,21 +1633,61 @@ void wxDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *he { if ( height ) *height += YDEV2LOGREL( fi.descent + fi.ascent + fi.leading ) ; - curwidth = ::TextWidth( text , laststop , i - laststop ) ; +#if TARGET_CARBON + if ( useGetThemeText ) + { + Point bounds={0,0} ; + SInt16 baseline ; + CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text + laststop , i - laststop , CFStringGetSystemEncoding(), false ) ; + ::GetThemeTextDimensions( mString, + kThemeCurrentPortFont, + kThemeStateActive, + false, + &bounds, + &baseline ); + CFRelease( mString ) ; + curwidth = bounds.h ; + } + else +#endif + { + curwidth = ::TextWidth( text , laststop , i - laststop ) ; + } if ( curwidth > *width ) *width = XDEV2LOGREL( curwidth ) ; laststop = i+1 ; } i++ ; } - - curwidth = ::TextWidth( text , laststop , i - laststop ) ; + +#if TARGET_CARBON + if ( useGetThemeText ) + { + Point bounds={0,0} ; + SInt16 baseline ; + CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text + laststop , i - laststop , CFStringGetSystemEncoding(), false ) ; + ::GetThemeTextDimensions( mString, + kThemeCurrentPortFont, + kThemeStateActive, + false, + &bounds, + &baseline ); + CFRelease( mString ) ; + curwidth = bounds.h ; + } + else +#endif + { + curwidth = ::TextWidth( text , laststop , i - laststop ) ; + } if ( curwidth > *width ) *width = XDEV2LOGREL( curwidth ) ; } if ( theFont ) { + // work around the constness + *((wxFont*)(&m_font)) = formerFont ; m_macFontInstalled = false ; } }