X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b1d7de5ae0c53162b57ac20cfed04264f0f27b30..0aeeec99d50c626067a438ed2a67e2019e4c84e3:/src/mac/carbon/stattext.cpp diff --git a/src/mac/carbon/stattext.cpp b/src/mac/carbon/stattext.cpp index c6a6dd4e1a..6f22db270c 100644 --- a/src/mac/carbon/stattext.cpp +++ b/src/mac/carbon/stattext.cpp @@ -9,10 +9,14 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "stattext.h" #endif +#include "wx/wxprec.h" + +#if wxUSE_STATTEXT + #include "wx/app.h" #include "wx/stattext.h" #include "wx/notebook.h" @@ -49,8 +53,9 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id, Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; wxMacCFStringHolder str(m_label,m_font.GetEncoding() ) ; + m_peer = new wxMacControl(this) ; verify_noerr(CreateStaticTextControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, str , - NULL , (ControlRef*)&m_macControl ) ) ; + NULL , m_peer->GetControlRefAddr() ) ) ; MacPostControlCreate(pos,size) ; @@ -60,15 +65,26 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id, wxSize wxStaticText::DoGetBestSize() const { ControlFontStyleRec controlFont ; - Size outSize ; - verify_noerr( GetControlData( (ControlRef) m_macControl , kControlEntireControl , kControlFontStyleTag , sizeof(controlFont) , &controlFont , &outSize ) ) ; + verify_noerr( m_peer->GetData(kControlEntireControl , kControlFontStyleTag , &controlFont ) ) ; Point bounds ; SInt16 baseline ; wxMacCFStringHolder str(m_label , m_font.GetEncoding() ) ; - verify_noerr( GetThemeTextDimensions( (m_label.Length() > 0 ? ((CFStringRef) str ) : CFSTR(" ") ) , 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 ; + + bounds.h += MacGetLeftBorderSize() + MacGetRightBorderSize() ; + bounds.v += MacGetTopBorderSize() + MacGetBottomBorderSize() ; return wxSize(bounds.h, bounds.v); } @@ -79,12 +95,14 @@ void wxStaticText::SetLabel(const wxString& st ) wxMacCFStringHolder str(m_label,m_font.GetEncoding() ) ; CFStringRef ref = str ; - SetControlData( (ControlRef) m_macControl, kControlEntireControl , kControlStaticTextCFStringTag, sizeof( CFStringRef ), - &ref ); + verify_noerr( m_peer->SetData(kControlEntireControl , kControlStaticTextCFStringTag, ref ) ) ; if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) ) + { + InvalidateBestSize(); SetSize( GetBestSize() ) ; - + } + Refresh() ; Update() ; } @@ -95,8 +113,14 @@ bool wxStaticText::SetFont(const wxFont& font) if ( ret ) { if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) ) - SetSize( GetBestSize() ); + { + InvalidateBestSize(); + SetSize( GetBestSize() ); + } } return ret; } + +#endif //if wxUSE_STATTEXT +