X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6e7a89af32d371a2f90832f6e20d3da3ea1ce062..71a09c3579dd5cb4cd8fa7fdc143561cbff74e12:/src/osx/carbon/stattext.cpp?ds=sidebyside diff --git a/src/osx/carbon/stattext.cpp b/src/osx/carbon/stattext.cpp index 03eb2a00ad..8b0c9714c4 100644 --- a/src/osx/carbon/stattext.cpp +++ b/src/osx/carbon/stattext.cpp @@ -4,7 +4,6 @@ // Author: Stefan Csomor // Modified by: // Created: 04/01/98 -// RCS-ID: $Id$ // Copyright: (c) Stefan Csomor // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -48,10 +47,11 @@ wxSize wxStaticText::DoGetBestSize() const Rect bestsize = { 0 , 0 , 0 , 0 } ; // try the built-in best size if available - Boolean former = m_peer->GetData( kControlStaticTextIsMultilineTag); - m_peer->SetData( kControlStaticTextIsMultilineTag, (Boolean)0 ); - m_peer->GetBestRect( &bestsize ) ; - m_peer->SetData( kControlStaticTextIsMultilineTag, former ); + Boolean former = GetPeer()->GetData( kControlStaticTextIsMultilineTag); + GetPeer()->SetData( kControlStaticTextIsMultilineTag, (Boolean)0 ); + GetPeer()->GetBestRect( &bestsize ) ; + GetPeer()->SetData( kControlStaticTextIsMultilineTag, former ); + if ( !EmptyRect( &bestsize ) ) { bounds.h = bestsize.right - bestsize.left ; @@ -62,17 +62,24 @@ wxSize wxStaticText::DoGetBestSize() const { #if wxOSX_USE_CARBON ControlFontStyleRec controlFont; - OSStatus err = m_peer->GetData( kControlEntireControl, kControlFontStyleTag, &controlFont ); + OSStatus err = GetPeer()->GetData( kControlEntireControl, kControlFontStyleTag, &controlFont ); verify_noerr( err ); - wxCFStringRef str( m_label, GetFont().GetEncoding() ); - #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( - (!m_label.empty() ? (CFStringRef)str : CFSTR(" ")), + (CFStringRef)str, m_font.MacGetThemeFontID(), kThemeStateActive, false, &bounds, &baseline ); verify_noerr( err ); } @@ -103,12 +110,12 @@ wxSize wxStaticText::DoGetBestSize() const wxWidgetImplType* wxWidgetImpl::CreateStaticText( wxWindowMac* wxpeer, wxWindowMac* parent, - wxWindowID id, - const wxString& label, + wxWindowID WXUNUSED(id), + const wxString& WXUNUSED(label), const wxPoint& pos, const wxSize& size, long style, - long extraStyle) + long WXUNUSED(extraStyle)) { Rect bounds = wxMacGetBoundsForControl( wxpeer, pos, size );