]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/stattext.cpp
MSW Caret is now destroyed and recreated when resized.
[wxWidgets.git] / src / os2 / stattext.cpp
index 91b15ada8fb3ded7fe3846394a205497ca59b142..6642dccd8eae0410ed23ff60fd69798dedda8e0d 100644 (file)
@@ -22,9 +22,7 @@
 #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,
@@ -60,20 +58,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();