- FontInfo fi ;
- ::GetFontInfo( &fi ) ;
-#if TARGET_CARBON
- if ( !useDrawThemeText )
-#endif
- yy += fi.ascent ;
- ::MoveTo( xx , yy );
- if ( m_backgroundMode == wxTRANSPARENT )
- {
- ::TextMode( srcOr) ;
- }
- else
- {
- ::TextMode( srcCopy ) ;
- }
- const char *text = NULL ;
- int length = 0 ;
- wxString macText ;
- if ( wxApp::s_macDefaultEncodingIsPC )
- {
- macText = wxMacMakeMacStringFromPC( strtext ) ;
- text = macText ;
- length = macText.Length() ;
- }
- else
- {
- text = strtext ;
- length = strtext.Length() ;
- }
- int laststop = 0 ;
- int i = 0 ;
- int line = 0 ;
- {
- while( i < length )
- {
- if( text[i] == 13 || text[i] == 10)
- {
-#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 } ;
- CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text + laststop , i - laststop , CFStringGetSystemEncoding(), false ) ;
- if ( m_backgroundMode != wxTRANSPARENT )
- {
- Point bounds={0,0} ;
- Rect background = frame ;
- SInt16 baseline ;
- ::GetThemeTextDimensions( mString,
- kThemeCurrentPortFont,
- kThemeStateActive,
- false,
- &bounds,
- &baseline );
- background.right = background.left + bounds.h ;
- background.bottom = background.top + bounds.v ;
- ::EraseRect( &background ) ;
- }
- ::DrawThemeTextBox( mString,
- kThemeCurrentPortFont,
- kThemeStateActive,
- false,
- &frame,
- teJustLeft,
- nil );
- CFRelease( mString ) ;
- line++ ;
- }
- else
-#endif
- {
- ::DrawText( text , laststop , i - laststop ) ;
- line++ ;
- ::MoveTo( xx , yy + line*(fi.descent + fi.ascent + fi.leading) );
- }
- laststop = i+1 ;
- }
- i++ ;
- }
-#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 } ;
- CFStringRef mString = CFStringCreateWithCString( NULL , text + laststop , kCFStringEncodingMacRoman ) ;
- if ( m_backgroundMode != wxTRANSPARENT )
- {
- Point bounds={0,0} ;
- Rect background = frame ;
- SInt16 baseline ;
- ::GetThemeTextDimensions( mString,
- kThemeCurrentPortFont,
- kThemeStateActive,
- false,
- &bounds,
- &baseline );
- background.right = background.left + bounds.h ;
- background.bottom = background.top + bounds.v ;
- ::EraseRect( &background ) ;
- }
- ::DrawThemeTextBox( mString,
- kThemeCurrentPortFont,
- kThemeStateActive,
- false,
- &frame,
- teJustLeft,
- nil );
- CFRelease( mString ) ;
- }
- else
-#endif
- {
- ::DrawText( text , laststop , i - laststop ) ;
- }
- }
- ::TextMode( srcOr ) ;
-}
-bool wxDC::CanGetTextExtent() const
-{
- wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
- return true ;
-}
-void wxDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *height,
- wxCoord *descent, wxCoord *externalLeading ,
- wxFont *theFont ) const
-{
- wxCHECK_RET(Ok(), wxT("Invalid DC"));
- wxMacPortSetter helper(this) ;
- wxFont formerFont = m_font ;
- if ( theFont )
- {
- // work around the constness
- *((wxFont*)(&m_font)) = *theFont ;
- }
- MacInstallFont() ;
- FontInfo fi ;
- ::GetFontInfo( &fi ) ;
-#if TARGET_CARBON
- bool useGetThemeText = ( GetThemeTextDimensions != (void*) kUnresolvedCFragSymbolAddress ) ;
- if ( ((wxFont*)&m_font)->GetNoAntiAliasing() )
- useGetThemeText = false ;
-#endif
- if ( height )
- *height = YDEV2LOGREL( fi.descent + fi.ascent ) ;
- if ( descent )
- *descent =YDEV2LOGREL( fi.descent );
- if ( externalLeading )
- *externalLeading = YDEV2LOGREL( fi.leading ) ;
- const char *text = NULL ;
- int length = 0 ;
- wxString macText ;
- if ( wxApp::s_macDefaultEncodingIsPC )
- {
- macText = wxMacMakeMacStringFromPC( string ) ;
- text = macText ;
- length = macText.Length() ;
- }
- else
- {
- text = string ;
- length = string.Length() ;
- }
- int laststop = 0 ;
- int i = 0 ;
- int curwidth = 0 ;
- if ( width )
- {
- *width = 0 ;
- while( i < length )
- {
- if( text[i] == 13 || text[i] == 10)
- {
- if ( height )
- *height += YDEV2LOGREL( fi.descent + fi.ascent + fi.leading ) ;
-#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++ ;
- }
-
-#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 ;
- }
-}
-wxCoord wxDC::GetCharWidth(void) const
-{
- wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
- wxMacPortSetter helper(this) ;
- MacInstallFont() ;
- int width = 0 ;
-#if TARGET_CARBON
- bool useGetThemeText = ( GetThemeTextDimensions != (void*) kUnresolvedCFragSymbolAddress ) ;
- if ( ((wxFont*)&m_font)->GetNoAntiAliasing() )
- useGetThemeText = false ;
-#endif
- char text[] = "H" ;
-#if TARGET_CARBON
- if ( useGetThemeText )
- {
- Point bounds={0,0} ;
- SInt16 baseline ;
- CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text , 1 , CFStringGetSystemEncoding(), false ) ;
- ::GetThemeTextDimensions( mString,
- kThemeCurrentPortFont,
- kThemeStateActive,
- false,
- &bounds,
- &baseline );
- CFRelease( mString ) ;
- width = bounds.h ;