// 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"
#include <stdio.h>
-#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
-#endif
#include "wx/mac/uma.h"
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
wxMacCFStringHolder str(m_label,m_font.GetEncoding() ) ;
- m_peer = new wxMacControl() ;
+ m_peer = new wxMacControl(this) ;
verify_noerr(CreateStaticTextControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, str ,
- NULL , *m_peer ) ) ;
+ NULL , m_peer->GetControlRefAddr() ) ) ;
MacPostControlCreate(pos,size) ;
wxSize wxStaticText::DoGetBestSize() const
{
ControlFontStyleRec controlFont ;
- Size outSize ;
- verify_noerr( GetControlData( *m_peer , kControlEntireControl , kControlFontStyleTag , sizeof(controlFont) , &controlFont , &outSize ) ) ;
+ verify_noerr( m_peer->GetData<ControlFontStyleRec>(kControlEntireControl , kControlFontStyleTag , &controlFont ) ) ;
Point bounds ;
SInt16 baseline ;
}
if ( m_label.Length() == 0 )
bounds.h = 0 ;
+
+ bounds.h += MacGetLeftBorderSize() + MacGetRightBorderSize() ;
+ bounds.v += MacGetTopBorderSize() + MacGetBottomBorderSize() ;
return wxSize(bounds.h, bounds.v);
}
wxMacCFStringHolder str(m_label,m_font.GetEncoding() ) ;
CFStringRef ref = str ;
- SetControlData( *m_peer, kControlEntireControl , kControlStaticTextCFStringTag, sizeof( CFStringRef ),
- &ref );
+ verify_noerr( m_peer->SetData<CFStringRef>(kControlEntireControl , kControlStaticTextCFStringTag, ref ) ) ;
- if (GetAdjustMinSizeFlag())
- SetBestSize(wxDefaultSize);
+ if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) )
+ {
+ InvalidateBestSize();
+ SetSize( GetBestSize() ) ;
+ }
+ Refresh() ;
+ // we shouldn't need forced updates
+ // Update() ;
+}
- Update() ;
+bool wxStaticText::SetFont(const wxFont& font)
+{
+ bool ret = wxControl::SetFont(font);
+
+ if ( ret )
+ {
+ if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) )
+ {
+ InvalidateBestSize();
+ SetSize( GetBestSize() );
+ }
+ }
+
+ return ret;
}
+#endif //if wxUSE_STATTEXT
+