]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/dc.cpp
The UseAntiAliasing is off by default on wxMac. Add a menu item to
[wxWidgets.git] / src / mac / carbon / dc.cpp
index 126dea09aa7a4b1382c23c84f76c152e0c0a583a..bfd36c8421f7a034fa538bf5c30d6db69a139f44 100644 (file)
@@ -1485,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 } ;
                 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} ;
                     if ( m_backgroundMode != wxTRANSPARENT )
                     {
                         Point bounds={0,0} ;
@@ -1527,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 } ;
         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 )
             {
 
             if ( m_backgroundMode != wxTRANSPARENT )
             {
@@ -1614,7 +1614,7 @@ void  wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *h
                 {
                     Point bounds={0,0} ;
                     SInt16 baseline ;
                 {
                     Point bounds={0,0} ;
                     SInt16 baseline ;
-                    wxMacCFStringHolder mString( linetext ) ;
+                    wxMacCFStringHolder mString( linetext , m_font.GetEncoding() ) ;
                     ::GetThemeTextDimensions( mString,
                         kThemeCurrentPortFont,
                         kThemeStateActive,
                     ::GetThemeTextDimensions( mString,
                         kThemeCurrentPortFont,
                         kThemeStateActive,
@@ -1642,7 +1642,7 @@ void  wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *h
         {
             Point bounds={0,0} ;
             SInt16 baseline ;
         {
             Point bounds={0,0} ;
             SInt16 baseline ;
-            wxMacCFStringHolder mString( linetext ) ;
+            wxMacCFStringHolder mString( linetext , m_font.GetEncoding() ) ;
             ::GetThemeTextDimensions( mString,
                 kThemeCurrentPortFont,
                 kThemeStateActive,
             ::GetThemeTextDimensions( mString,
                 kThemeCurrentPortFont,
                 kThemeStateActive,
@@ -1668,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; i<text.Length(); i++)
+        {
+            wxString str(text.Left(i+1));
+            Point bounds = {0,0};
+            SInt16 baseline ;
+            wxMacCFStringHolder mString(str, m_font.GetEncoding());
+            ::GetThemeTextDimensions( mString,
+                                      kThemeCurrentPortFont,
+                                      kThemeStateActive,
+                                      false,
+                                      &bounds,
+                                      &baseline );
+            widths[i] = XDEV2LOGREL(bounds.h);
+        }
+    }
+    else        
+#endif
+    {
+        wxCharBuffer buff = text.mb_str(wxConvLocal);
+        size_t len = strlen(buff);
+        short* measurements = new short[len+1];
+        MeasureText(len, buff.data(), measurements);
+
+        // Copy to widths, starting at measurements[1]
+        // NOTE: this doesn't take into account any multi-byte characters
+        // in buff, it probabkly should...
+        for (size_t i=0; i<text.Length(); i++)
+            widths[i] = XDEV2LOGREL(measurements[i+1]);
+
+        delete [] measurements;        
+    }
+
+    return true;
+}
+
+
+
 wxCoord   wxDC::GetCharWidth(void) const
 {
     wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
 wxCoord   wxDC::GetCharWidth(void) const
 {
     wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
@@ -1679,7 +1741,7 @@ wxCoord   wxDC::GetCharWidth(void) const
     if ( UMAGetSystemVersion() < 0x1000 || ((wxFont*)&m_font)->GetNoAntiAliasing() )
         useGetThemeText = false ;
 #endif
     if ( UMAGetSystemVersion() < 0x1000 || ((wxFont*)&m_font)->GetNoAntiAliasing() )
         useGetThemeText = false ;
 #endif
-    char text[] = "H" ;
+    char text[] = "g" ;
 #if TARGET_CARBON
     if ( useGetThemeText )
     {
 #if TARGET_CARBON
     if ( useGetThemeText )
     {