]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/dc.cpp
only fowarding events if there is a focus window
[wxWidgets.git] / src / mac / carbon / dc.cpp
index 2acff5c48accb7dd97ef76ce1a93c374178ff7c4..364c45fcf105dd6edc3f61dd797a38dfdb77d370 100644 (file)
@@ -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 ;
        }
 }