X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a9412f8f03171fdd3606a4ad3db9c9da8fe6bd7c..9556c0f1b3dec367bf2bdc3eef7b1d54668adcf7:/src/mac/carbon/dc.cpp?ds=sidebyside diff --git a/src/mac/carbon/dc.cpp b/src/mac/carbon/dc.cpp index 7b95aef88a..d906bac5a4 100644 --- a/src/mac/carbon/dc.cpp +++ b/src/mac/carbon/dc.cpp @@ -28,10 +28,10 @@ using namespace std ; #endif #include "wx/mac/private.h" -#include "ATSUnicode.h" -#include "TextCommon.h" -#include "TextEncodingConverter.h" -#include "FixMath.h" +#include +#include +#include +#include #if !USE_SHARED_LIBRARY IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject) #endif @@ -1476,6 +1476,7 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) int i = 0 ; int line = 0 ; { +#if 0 // we don't have to do all that here while( i < length ) { if( strtext[i] == 13 || strtext[i] == 10) @@ -1515,6 +1516,21 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) { wxCharBuffer text = linetext.mb_str(wxConvLocal) ; ::DrawText( text , 0 , strlen(text) ) ; + 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 ) ; + } line++ ; ::MoveTo( xx , yy + line*(fi.descent + fi.ascent + fi.leading) ); } @@ -1523,6 +1539,8 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) i++ ; } wxString linetext = strtext.Mid( laststop , i - laststop ) ; +#endif // 0 + wxString linetext = strtext ; #if TARGET_CARBON if ( useDrawThemeText ) { @@ -1556,6 +1574,14 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) #endif { wxCharBuffer text = linetext.mb_str(wxConvLocal) ; + if ( m_backgroundMode != wxTRANSPARENT ) + { + Rect frame = { yy - fi.ascent + line*(fi.descent + fi.ascent + fi.leading) ,xx , yy - fi.ascent + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 10000 } ; + short width = ::TextWidth( text , 0 , strlen(text) ) ; + frame.right = frame.left + width ; + + ::EraseRect( &frame ) ; + } ::DrawText( text , 0 , strlen(text) ) ; } } @@ -1602,6 +1628,7 @@ void wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *h if ( width ) { *width = 0 ; +#if 0 // apparently we don't have to do all that while( i < length ) { if( strtext[i] == 13 || strtext[i] == 10) @@ -1637,6 +1664,8 @@ void wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *h } wxString linetext = strtext.Mid( laststop , i - laststop ) ; +#endif // 0 + wxString linetext = strtext ; #if TARGET_CARBON if ( useGetThemeText ) { @@ -1668,6 +1697,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; i