]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/stattext.cpp
allow compilation with wxUSE_CHOICEDLG set to 0
[wxWidgets.git] / src / mac / carbon / stattext.cpp
index 8437b9d5d131db89bc3a0c19537767aa0ac32532..e2bd22ed23209477b5493424df7809f5e04bff95 100644 (file)
@@ -66,8 +66,18 @@ wxSize wxStaticText::DoGetBestSize() const
     Point bounds ;
     SInt16 baseline ;
     wxMacCFStringHolder str(m_label ,  m_font.GetEncoding() ) ;
-    verify_noerr( GetThemeTextDimensions( str , m_font.MacGetThemeFontID() , kThemeStateActive , false , &bounds , &baseline ) ) ;
-
+    if ( m_font.MacGetThemeFontID() != kThemeCurrentPortFont )
+        verify_noerr( GetThemeTextDimensions( (m_label.Length() > 0 ? ((CFStringRef) str ) : CFSTR(" ") ) , m_font.MacGetThemeFontID() , kThemeStateActive , false , &bounds , &baseline ) ) ;
+    else
+    {
+        wxMacWindowStateSaver sv( this ) ;
+        ::TextFont( m_font.MacGetFontNum() ) ;
+        ::TextSize( (short)( m_font.MacGetFontSize()) ) ;
+        ::TextFace( m_font.MacGetFontStyle() ) ;        
+        verify_noerr( GetThemeTextDimensions( (m_label.Length() > 0 ? ((CFStringRef) str ) : CFSTR(" ") ) , kThemeCurrentPortFont , kThemeStateActive , false , &bounds , &baseline ) ) ;
+    }
+    if ( m_label.Length() == 0 )
+        bounds.h = 0 ;
     return wxSize(bounds.h, bounds.v);
 }
 
@@ -82,7 +92,10 @@ void wxStaticText::SetLabel(const wxString& st )
                &ref );
 
     if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) )
+    {
         SetSize( GetBestSize() ) ;
+        SetSizeHints(GetSize());
+    }
 
     Update() ;
 }
@@ -94,7 +107,10 @@ bool wxStaticText::SetFont(const wxFont& font)
        if ( ret )
        {
            if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) )
+            {
                SetSize( GetBestSize() );
+                SetSizeHints(GetSize());
+            }
        }
 
     return ret;