X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f048e32fcd5260f33fbebdafbe1a0deeda175419..d21d2e5adf7a5acf3b496a9c4e87eab220bd75d8:/src/msw/stattext.cpp?ds=sidebyside diff --git a/src/msw/stattext.cpp b/src/msw/stattext.cpp index 4ab6b6c42d..a83000876e 100644 --- a/src/msw/stattext.cpp +++ b/src/msw/stattext.cpp @@ -20,6 +20,8 @@ #pragma hdrstop #endif +#if wxUSE_STATTEXT + #ifndef WX_PRECOMP #include "wx/event.h" #include "wx/app.h" @@ -30,9 +32,7 @@ #include "wx/msw/private.h" #include -#if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl) -#endif bool wxStaticText::Create(wxWindow *parent, wxWindowID id, const wxString& label, @@ -59,7 +59,10 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id, m_windowStyle = style; - long msStyle = WS_CHILD|WS_VISIBLE; + long msStyle = WS_CHILD | WS_VISIBLE; + + if ( m_windowStyle & wxCLIP_SIBLINGS ) + msStyle |= WS_CLIPSIBLINGS; if (m_windowStyle & wxALIGN_CENTRE) msStyle |= SS_CENTER; else if (m_windowStyle & wxALIGN_RIGHT) @@ -88,7 +91,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; @@ -142,14 +145,32 @@ void wxStaticText::SetLabel(const wxString& label) { SetWindowText(GetHwnd(), label); + // 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); + + Refresh(); + } +} + + +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 @@ -160,4 +181,4 @@ long wxStaticText::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) return wxWindow::MSWWindowProc(nMsg, wParam, lParam); } - +#endif // wxUSE_STATTEXT