// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
+#ifdef __GNUG__
+#pragma implementation "stattext.h"
+#endif
+
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#include "wx/os2/private.h"
#include <stdio.h>
-#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
-#endif
bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
const wxString& label,
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();
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.
if (nMsg == WM_NCHITTEST)
return (long)HTCLIENT;
*/
- return wxWindow::OS2WindowProc(hwnd, nMsg, wParam, lParam);
+ return wxWindow::OS2WindowProc(nMsg, wParam, lParam);
}