From: Robin Dunn Date: Tue, 20 Feb 2001 06:10:38 +0000 (+0000) Subject: Added a SetFont method that behaves like SetLabel does with respect to X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/486fd225d4942c852b913636bdc81d9a0a27f7d5?hp=2f10f4238afa739b528d4115a5f2e8a0e87f2bcb Added a SetFont method that behaves like SetLabel does with respect to wxST_NO_AUTORESIZE. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9387 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/msw/stattext.h b/include/wx/msw/stattext.h index fd0f63d801..ca5fd0c0e2 100644 --- a/include/wx/msw/stattext.h +++ b/include/wx/msw/stattext.h @@ -46,6 +46,7 @@ public: // accessors void SetLabel(const wxString& label); + bool SetFont( const wxFont &font ); // overriden base class virtuals virtual bool AcceptsFocus() const { return FALSE; } diff --git a/src/msw/stattext.cpp b/src/msw/stattext.cpp index 82b2a21745..c4a61fd113 100644 --- a/src/msw/stattext.cpp +++ b/src/msw/stattext.cpp @@ -86,7 +86,7 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id, SubclassWin(m_hWnd); - SetFont(parent->GetFont()); + wxControl::SetFont(parent->GetFont()); SetSize(x, y, width, height); return TRUE; @@ -148,6 +148,22 @@ void wxStaticText::SetLabel(const wxString& label) } } + +bool wxStaticText::SetFont(const wxFont& font) +{ + bool ret = wxControl::SetFont(font); + + // adjust the size of the window to fit to the label unless autoresizing is + // disabled + if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) ) + { + DoSetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH | wxSIZE_AUTO_HEIGHT); + } + + return ret; +} + + long wxStaticText::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) { // Ensure that static items get messages. Some controls don't like this