X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/77ffb5937e89927b621128789401db8921fe580f..4792d19265f446a15e669ef1cfda20b2dd36d414:/src/mac/carbon/stattext.cpp diff --git a/src/mac/carbon/stattext.cpp b/src/mac/carbon/stattext.cpp index 4e5ced0d6d..3c67c64a9a 100644 --- a/src/mac/carbon/stattext.cpp +++ b/src/mac/carbon/stattext.cpp @@ -6,12 +6,12 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWidgets licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation "stattext.h" -#endif +#include "wx/wxprec.h" + +#if wxUSE_STATTEXT #include "wx/app.h" #include "wx/stattext.h" @@ -24,9 +24,7 @@ #include -#if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl) -#endif #include "wx/mac/uma.h" @@ -49,8 +47,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,8 +59,7 @@ 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 ; @@ -78,6 +76,9 @@ wxSize wxStaticText::DoGetBestSize() const } if ( m_label.Length() == 0 ) bounds.h = 0 ; + + bounds.h += MacGetLeftBorderSize() + MacGetRightBorderSize() ; + bounds.v += MacGetTopBorderSize() + MacGetBottomBorderSize() ; return wxSize(bounds.h, bounds.v); } @@ -88,16 +89,16 @@ 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() ) ; - SetSizeHints(GetSize()); } - - Update() ; + Refresh() ; + // we shouldn't need forced updates + // Update() ; } bool wxStaticText::SetFont(const wxFont& font) @@ -107,11 +108,14 @@ bool wxStaticText::SetFont(const wxFont& font) if ( ret ) { if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) ) - { - SetSize( GetBestSize() ); - SetSizeHints(GetSize()); - } + { + InvalidateBestSize(); + SetSize( GetBestSize() ); + } } return ret; } + +#endif //if wxUSE_STATTEXT +