]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/carbon/stattext.cpp
use translatable strings as format template for menu lines
[wxWidgets.git] / src / osx / carbon / stattext.cpp
index bced016eb75c47bd65a7a38cfe64e7e26ae00641..67be74dbb49c563c75aa99df0f851fcd86580569 100644 (file)
@@ -23,9 +23,6 @@
     #include "wx/settings.h"
 #endif // WX_PRECOMP
 
     #include "wx/settings.h"
 #endif // WX_PRECOMP
 
-#include "wx/notebook.h"
-#include "wx/tabctrl.h"
-
 #include "wx/osx/private.h"
 
 #include <stdio.h>
 #include "wx/osx/private.h"
 
 #include <stdio.h>
@@ -51,10 +48,11 @@ wxSize wxStaticText::DoGetBestSize() const
     Rect bestsize = { 0 , 0 , 0 , 0 } ;
 
     // try the built-in best size if available
     Rect bestsize = { 0 , 0 , 0 , 0 } ;
 
     // try the built-in best size if available
-    Boolean former = m_peer->GetData<Boolean>( kControlStaticTextIsMultilineTag);
-    m_peer->SetData( kControlStaticTextIsMultilineTag, (Boolean)0 );
-    m_peer->GetBestRect( &bestsize ) ;
-    m_peer->SetData( kControlStaticTextIsMultilineTag, former );
+    Boolean former = GetPeer()->GetData<Boolean>( kControlStaticTextIsMultilineTag);
+    GetPeer()->SetData( kControlStaticTextIsMultilineTag, (Boolean)0 );
+    GetPeer()->GetBestRect( &bestsize ) ;
+    GetPeer()->SetData( kControlStaticTextIsMultilineTag, former );
+    
     if ( !EmptyRect( &bestsize ) )
     {
         bounds.h = bestsize.right - bestsize.left ;
     if ( !EmptyRect( &bestsize ) )
     {
         bounds.h = bestsize.right - bestsize.left ;
@@ -65,17 +63,24 @@ wxSize wxStaticText::DoGetBestSize() const
     {
 #if wxOSX_USE_CARBON
         ControlFontStyleRec controlFont;
     {
 #if wxOSX_USE_CARBON
         ControlFontStyleRec controlFont;
-        OSStatus err = m_peer->GetData<ControlFontStyleRec>( kControlEntireControl, kControlFontStyleTag, &controlFont );
+        OSStatus err = GetPeer()->GetData<ControlFontStyleRec>( kControlEntireControl, kControlFontStyleTag, &controlFont );
         verify_noerr( err );
 
         verify_noerr( err );
 
-        wxCFStringRef str( m_label,  GetFont().GetEncoding() );
-
 #if wxOSX_USE_ATSU_TEXT
         SInt16 baseline;
         if ( m_font.MacGetThemeFontID() != kThemeCurrentPortFont )
         {
 #if wxOSX_USE_ATSU_TEXT
         SInt16 baseline;
         if ( m_font.MacGetThemeFontID() != kThemeCurrentPortFont )
         {
+            // GetThemeTextDimensions will cache strings and the documentation
+            // says not to use the NoCopy string creation calls.
+            // This also means that we can't use CFSTR without
+            // -fno-constant-cfstrings if the library might be unloaded,
+            // as GetThemeTextDimensions may cache a pointer to our
+            // unloaded segment.
+            wxCFStringRef str( !m_label.empty() ? m_label : wxString(" "),
+                              GetFont().GetEncoding() );
+
             err = GetThemeTextDimensions(
             err = GetThemeTextDimensions(
-                (!m_label.empty() ? (CFStringRef)str : CFSTR(" ")),
+                (CFStringRef)str,
                 m_font.MacGetThemeFontID(), kThemeStateActive, false, &bounds, &baseline );
             verify_noerr( err );
         }
                 m_font.MacGetThemeFontID(), kThemeStateActive, false, &bounds, &baseline );
             verify_noerr( err );
         }
@@ -104,14 +109,14 @@ wxSize wxStaticText::DoGetBestSize() const
           to allow correct dynamic ellipsizing of the label
 */
 
           to allow correct dynamic ellipsizing of the label
 */
 
-wxWidgetImplType* wxWidgetImpl::CreateStaticText( wxWindowMac* wxpeer, 
-                                    wxWindowMac* parent, 
-                                    wxWindowID id, 
-                                    const wxString& label,
-                                    const wxPoint& pos, 
+wxWidgetImplType* wxWidgetImpl::CreateStaticText( wxWindowMac* wxpeer,
+                                    wxWindowMac* parent,
+                                    wxWindowID WXUNUSED(id),
+                                    const wxString& WXUNUSED(label),
+                                    const wxPoint& pos,
                                     const wxSize& size,
                                     const wxSize& size,
-                                    long style, 
-                                    long extraStyle) 
+                                    long style,
+                                    long WXUNUSED(extraStyle))
 {
     Rect bounds = wxMacGetBoundsForControl( wxpeer, pos, size );
 
 {
     Rect bounds = wxMacGetBoundsForControl( wxpeer, pos, size );