X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d90895ac118ad4546eed7ee4c358a3fe644a1ad7..012286eb3b9e05c15c1f7732c141b61d3ebb2524:/src/os2/stattext.cpp?ds=sidebyside diff --git a/src/os2/stattext.cpp b/src/os2/stattext.cpp index 91b15ada8f..00c3e2e32d 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(); @@ -123,7 +138,7 @@ WXHBRUSH wxStaticText::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, return (WXHBRUSH)0; } -MRESULT wxStaticText::OS2WindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) +MRESULT wxStaticText::OS2WindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) { // Ensure that static items get messages. Some controls don't like this // message to be intercepted (e.g. RichEdit), hence the tests. @@ -132,6 +147,6 @@ MRESULT wxStaticText::OS2WindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXL if (nMsg == WM_NCHITTEST) return (long)HTCLIENT; */ - return wxWindow::OS2WindowProc(hwnd, nMsg, wParam, lParam); + return wxWindow::OS2WindowProc(nMsg, wParam, lParam); }