X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d90895ac118ad4546eed7ee4c358a3fe644a1ad7..5d33ed2c6bc3065bf9dc77742da6c924b9e00fa5:/src/os2/stattext.cpp diff --git a/src/os2/stattext.cpp b/src/os2/stattext.cpp index 91b15ada8f..bf3141e961 100644 --- a/src/os2/stattext.cpp +++ b/src/os2/stattext.cpp @@ -9,6 +9,10 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// +#ifdef __GNUG__ +#pragma implementation "stattext.h" +#endif + // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -22,9 +26,7 @@ #include "wx/os2/private.h" #include -#if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl) -#endif bool wxStaticText::Create(wxWindow *parent, wxWindowID id, const wxString& label, @@ -60,20 +62,33 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id, return FALSE; } -wxSize wxStaticText::DoGetBestSize() +wxSize wxStaticText::DoGetBestSize() const { wxString text(wxGetWindowText(GetHWND())); int widthTextMax = 0, widthLine, - heightTextTotal = 0, heightLine; + heightTextTotal = 0, heightLineDefault = 0, heightLine = 0; wxString curLine; for ( const wxChar *pc = text; ; pc++ ) { if ( *pc == wxT('\n') || *pc == wxT('\0') ) { - GetTextExtent(curLine, &widthLine, &heightLine); - if ( widthLine > widthTextMax ) - widthTextMax = widthLine; - heightTextTotal += heightLine; + if ( !curLine ) { + // we can't use GetTextExtent - it will return 0 for both width + // and height and an empty line should count in height + // calculation + if ( !heightLineDefault ) + heightLineDefault = heightLine; + if ( !heightLineDefault ) + GetTextExtent(_T("W"), NULL, &heightLineDefault); + + heightTextTotal += heightLineDefault; + } + else { + GetTextExtent(curLine, &widthLine, &heightLine); + if ( widthLine > widthTextMax ) + widthTextMax = widthLine; + heightTextTotal += heightLine; + } if ( *pc == wxT('\n') ) { curLine.Empty();