X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/105b0fcae75a2291cc24fc9b42f615d34825dbd3..b635e17fef75d05881f5b5db85ec5f21d1cb3750:/src/mac/carbon/dc.cpp diff --git a/src/mac/carbon/dc.cpp b/src/mac/carbon/dc.cpp index 35717bd3fe..bfd36c8421 100644 --- a/src/mac/carbon/dc.cpp +++ b/src/mac/carbon/dc.cpp @@ -1371,11 +1371,10 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, wxMacFastPortSetter helper(this) ; MacInstallFont() ; - wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; if ( 0 ) { m_macFormerAliasState = IsAntiAliasedTextEnabled(&m_macFormerAliasSize); - SetAntiAliasedTextEnabled(true, SInt16(m_scaleY * font->m_macFontSize)); + SetAntiAliasedTextEnabled(true, SInt16(m_scaleY * m_font.GetMacFontSize())); m_macAliasWasEnabled = true ; } OSStatus status = noErr ; @@ -1486,7 +1485,7 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) 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 ) ; + wxMacCFStringHolder mString( linetext , m_font.GetEncoding() ) ; if ( m_backgroundMode != wxTRANSPARENT ) { Point bounds={0,0} ; @@ -1528,7 +1527,7 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) 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 ) ; + wxMacCFStringHolder mString( linetext , m_font.GetEncoding()) ; if ( m_backgroundMode != wxTRANSPARENT ) { @@ -1615,7 +1614,7 @@ void wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *h { Point bounds={0,0} ; SInt16 baseline ; - wxMacCFStringHolder mString( linetext ) ; + wxMacCFStringHolder mString( linetext , m_font.GetEncoding() ) ; ::GetThemeTextDimensions( mString, kThemeCurrentPortFont, kThemeStateActive, @@ -1643,7 +1642,7 @@ void wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *h { Point bounds={0,0} ; SInt16 baseline ; - wxMacCFStringHolder mString( linetext ) ; + wxMacCFStringHolder mString( linetext , m_font.GetEncoding() ) ; ::GetThemeTextDimensions( mString, kThemeCurrentPortFont, kThemeStateActive, @@ -1669,6 +1668,68 @@ void wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *h } } + +bool wxDC::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const +{ + wxCHECK_MSG(Ok(), false, wxT("Invalid DC")); + + widths.Empty(); + widths.Add(0, text.Length()); + + if (text.Length() == 0) + return false; + + wxMacFastPortSetter helper(this) ; + MacInstallFont() ; +#if TARGET_CARBON + bool useGetThemeText = ( GetThemeTextDimensions != (void*) kUnresolvedCFragSymbolAddress ) ; + if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC ) ) || ((wxFont*)&m_font)->GetNoAntiAliasing() ) + useGetThemeText = false ; + + if ( useGetThemeText ) + { + // 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 + // begining of the string for each succeding substring, which is much + // slower than this should be. + for (size_t i=0; iGetNoAntiAliasing() ) useGetThemeText = false ; #endif - char text[] = "H" ; + char text[] = "g" ; #if TARGET_CARBON if ( useGetThemeText ) { @@ -1735,12 +1796,11 @@ void wxDC::MacInstallFont() const // return ; Pattern blackColor ; MacSetupBackgroundForCurrentPort(m_backgroundBrush) ; - wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; - if ( font ) + if ( m_font.Ok() ) { - ::TextFont( font->m_macFontNum ) ; - ::TextSize( short(m_scaleY * font->m_macFontSize) ) ; - ::TextFace( font->m_macFontStyle ) ; + ::TextFont( m_font.GetMacFontNum() ) ; + ::TextSize( (short)(m_scaleY * m_font.GetMacFontSize()) ) ; + ::TextFace( m_font.GetMacFontStyle() ) ; m_macFontInstalled = true ; m_macBrushInstalled = false ; m_macPenInstalled = false ; @@ -1809,9 +1869,9 @@ void wxDC::MacInstallFont() const } ::PenMode( mode ) ; OSStatus status = noErr ; - Fixed atsuSize = IntToFixed( int(m_scaleY * font->m_macFontSize) ) ; - Style qdStyle = font->m_macFontStyle ; - ATSUFontID atsuFont = font->m_macATSUFontID ; + Fixed atsuSize = IntToFixed( int(m_scaleY * m_font.GetMacFontSize()) ) ; + Style qdStyle = m_font.GetMacFontStyle() ; + ATSUFontID atsuFont = m_font.GetMacATSUFontID() ; status = ::ATSUCreateStyle((ATSUStyle *)&m_macATSUIStyle) ; wxASSERT_MSG( status == noErr , wxT("couldn't create ATSU style") ) ; ATSUAttributeTag atsuTags[] = @@ -1864,18 +1924,18 @@ void wxDC::MacInstallFont() const Pattern gPatterns[] = { // hatch patterns - { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF } , - { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 } , - { 0x80 , 0x40 , 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , 0x01 } , - { 0x10 , 0x10 , 0x10 , 0xFF , 0x10 , 0x10 , 0x10 , 0x10 } , - { 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 } , - { 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 } , - { 0x81 , 0x42 , 0x24 , 0x18 , 0x18 , 0x24 , 0x42 , 0x81 } , + { { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF } } , + { { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 } } , + { { 0x80 , 0x40 , 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , 0x01 } } , + { { 0x10 , 0x10 , 0x10 , 0xFF , 0x10 , 0x10 , 0x10 , 0x10 } } , + { { 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 } } , + { { 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 } } , + { { 0x81 , 0x42 , 0x24 , 0x18 , 0x18 , 0x24 , 0x42 , 0x81 } } , // dash patterns - { 0xCC , 0x99 , 0x33 , 0x66 , 0xCC , 0x99 , 0x33 , 0x66 } , // DOT - { 0xFE , 0xFD , 0xFB , 0xF7 , 0xEF , 0xDF , 0xBF , 0x7F } , // LONG_DASH - { 0xEE , 0xDD , 0xBB , 0x77 , 0xEE , 0xDD , 0xBB , 0x77 } , // SHORT_DASH - { 0xDE , 0xBD , 0x7B , 0xF6 , 0xED , 0xDB , 0xB7 , 0x6F } , // DOT_DASH + { { 0xCC , 0x99 , 0x33 , 0x66 , 0xCC , 0x99 , 0x33 , 0x66 } } , // DOT + { { 0xFE , 0xFD , 0xFB , 0xF7 , 0xEF , 0xDF , 0xBF , 0x7F } } , // LONG_DASH + { { 0xEE , 0xDD , 0xBB , 0x77 , 0xEE , 0xDD , 0xBB , 0x77 } } , // SHORT_DASH + { { 0xDE , 0xBD , 0x7B , 0xF6 , 0xED , 0xDB , 0xB7 , 0x6F } } , // DOT_DASH } ; static void wxMacGetPattern(int penStyle, Pattern *pattern) @@ -1902,7 +1962,7 @@ static void wxMacGetPattern(int penStyle, Pattern *pattern) void wxDC::MacInstallPen() const { wxCHECK_RET(Ok(), wxT("Invalid DC")); - Pattern blackColor; + //Pattern blackColor; // if ( m_macPenInstalled ) // return ; RGBColor forecolor = MAC_WXCOLORREF( m_pen.GetColour().GetPixel());