]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/stattext.cpp
VTK wrapper of vtkRenderWindow for wxPython. Tested on MSW so far.
[wxWidgets.git] / src / msw / stattext.cpp
index b0b6fd21f84f6d8666497ce189072f38db5ce6b7..38d249d3cbb6fce29f2dc94581aa42dc2fb9e3a7 100644 (file)
@@ -99,15 +99,28 @@ wxSize wxStaticText::DoGetBestSize()
     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();