X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/dbeddfb93d3479d03d8ec4c0121dfbe3bbcc422b..55410bb4f67febe1ca20654f078ea4fb9a6223ae:/src/osx/cocoa/stattext.mm diff --git a/src/osx/cocoa/stattext.mm b/src/osx/cocoa/stattext.mm index a30082c990..efb6e56343 100644 --- a/src/osx/cocoa/stattext.mm +++ b/src/osx/cocoa/stattext.mm @@ -23,62 +23,41 @@ #include "wx/settings.h" #endif // WX_PRECOMP -#include "wx/notebook.h" -#include "wx/tabctrl.h" - #include "wx/osx/private.h" #include wxSize wxStaticText::DoGetBestSize() const { - Point bounds; -#if wxOSX_USE_CARBON - 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 ); - if ( !EmptyRect( &bestsize ) ) +Point bounds; + +#if wxOSX_USE_ATSU_TEXT + OSStatus err = noErr; + wxCFStringRef str( m_label, GetFont().GetEncoding() ); + + SInt16 baseline; + if ( m_font.MacGetThemeFontID() != kThemeCurrentPortFont ) { - bounds.h = bestsize.right - bestsize.left ; - bounds.v = bestsize.bottom - bestsize.top ; + err = GetThemeTextDimensions( + (!m_label.empty() ? (CFStringRef)str : CFSTR(" ")), + m_font.MacGetThemeFontID(), kThemeStateActive, false, &bounds, &baseline ); + verify_noerr( err ); } else #endif { -#if wxOSX_USE_CARBON - ControlFontStyleRec controlFont; - OSStatus err = m_peer->GetData( kControlEntireControl, kControlFontStyleTag, &controlFont ); - verify_noerr( err ); + wxClientDC dc(const_cast(this)); + wxCoord width, height ; + dc.GetTextExtent( m_label , &width, &height); + // Some labels seem to have their last characters + // stripped out. Adding 4 pixels seems to be enough to fix this. + bounds.h = width+4; + bounds.v = height; + } - wxCFStringRef str( m_label, GetFont().GetEncoding() ); + if ( m_label.empty() ) + bounds.h = 0; -#if wxOSX_USE_ATSU_TEXT - SInt16 baseline; - if ( m_font.MacGetThemeFontID() != kThemeCurrentPortFont ) - { - err = GetThemeTextDimensions( - (!m_label.empty() ? (CFStringRef)str : CFSTR(" ")), - m_font.MacGetThemeFontID(), kThemeStateActive, false, &bounds, &baseline ); - verify_noerr( err ); - } - else -#endif -#endif - { - wxClientDC dc(const_cast(this)); - wxCoord width, height ; - dc.GetTextExtent( m_label , &width, &height); - bounds.h = width; - bounds.v = height; - } - - if ( m_label.empty() ) - bounds.h = 0; - } bounds.h += MacGetLeftBorderSize() + MacGetRightBorderSize(); bounds.v += MacGetTopBorderSize() + MacGetBottomBorderSize(); @@ -92,27 +71,23 @@ wxSize wxStaticText::DoGetBestSize() const to allow correct dynamic ellipsizing of the label */ -wxWidgetImplType* wxWidgetImpl::CreateStaticText( wxWindowMac* wxpeer, - wxWindowMac* parent, - wxWindowID id, +wxWidgetImplType* wxWidgetImpl::CreateStaticText( wxWindowMac* wxpeer, + wxWindowMac* parent, + wxWindowID id, const wxString& label, - const wxPoint& pos, + const wxPoint& pos, const wxSize& size, - long style, - long extraStyle) + long style, + long extraStyle) { - NSView* sv = (wxpeer->GetParent()->GetHandle() ); - NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ; wxNSTextField* v = [[wxNSTextField alloc] initWithFrame:r]; - [sv addSubview:v]; [v setBezeled:NO]; [v setEditable:NO]; [v setDrawsBackground:NO]; - + wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v ); - [v setImplementation:c]; return c; /* Rect bounds = wxMacGetBoundsForControl( wxpeer, pos, size );