]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/wincmn.cpp
Ignorant WinCE fixes for compile breakage
[wxWidgets.git] / src / common / wincmn.cpp
index 1f67899546ffc2df4768835eba2ee53d97db375e..bf4d550a202f7ec5251169741c715a4dabf0d468 100644 (file)
@@ -508,7 +508,7 @@ void wxWindowBase::Fit()
 {
     if ( GetChildren().GetCount() > 0 )
     {
-        SetClientSize(GetBestSize());
+        SetSize(GetBestSize());
     }
     //else: do nothing if we have no children
 }
@@ -553,9 +553,11 @@ void wxWindowBase::InvalidateBestSize()
 // return the size best suited for the current window
 wxSize wxWindowBase::DoGetBestSize() const
 {
+    wxSize best;
+
     if ( m_windowSizer )
     {
-        return m_windowSizer->GetMinSize();
+        best = m_windowSizer->GetMinSize();
     }
 #if wxUSE_CONSTRAINTS
     else if ( m_constraints )
@@ -591,7 +593,7 @@ wxSize wxWindowBase::DoGetBestSize() const
             //       will never return a size bigger than the current one :-(
         }
 
-        return wxSize(maxX, maxY);
+        best = wxSize(maxX, maxY);
     }
 #endif // wxUSE_CONSTRAINTS
     else if ( !GetChildren().empty()
@@ -643,17 +645,25 @@ wxSize wxWindowBase::DoGetBestSize() const
         maxX += 7;
         maxY += 14;
 
-        return wxSize(maxX, maxY);
+        best = wxSize(maxX, maxY);
     }
     else // ! has children
     {
-        // for a generic window there is no natural best size - just use either the
-        // minimum size if there is one, or the current size
+        // For a generic window there is no natural best size - just use
+        // either the minimum size if there is one, or the current size.
+        // These are returned as-is, unadjusted by the client size difference.
         if ( GetMinSize().IsFullySpecified() )
             return GetMinSize();
         else
             return GetSize();
     }
+
+    // Add any difference between size and client size
+    wxSize diff = GetSize() - GetClientSize();
+    best.x += wxMax(0, diff.x);
+    best.y += wxMax(0, diff.y);
+
+    return best;
 }
 
 
@@ -689,7 +699,7 @@ void wxWindowBase::SetBestFittingSize(const wxSize& size)
 // by default the origin is not shifted
 wxPoint wxWindowBase::GetClientAreaOrigin() const
 {
-    return wxPoint(0, 0);
+    return wxPoint();
 }
 
 // set the min/max size of the window
@@ -779,10 +789,10 @@ void wxWindowBase::DoSetVirtualSize( int x, int y )
 
 wxSize wxWindowBase::DoGetVirtualSize() const
 {
-    wxSize  s( GetClientSize() );
+    if (m_virtualSize == wxDefaultSize)
+        return GetClientSize();
 
-    return wxSize( wxMax( m_virtualSize.GetWidth(), s.GetWidth() ),
-                   wxMax( m_virtualSize.GetHeight(), s.GetHeight() ) );
+    return m_virtualSize;
 }
 
 // ----------------------------------------------------------------------------