]> git.saurik.com Git - wxWidgets.git/commitdiff
Include the size of any window borders (size vs. clientsize
authorRobin Dunn <robin@alldunn.com>
Thu, 3 Feb 2005 22:11:43 +0000 (22:11 +0000)
committerRobin Dunn <robin@alldunn.com>
Thu, 3 Feb 2005 22:11:43 +0000 (22:11 +0000)
differences) in the window's bestsize

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31730 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
src/common/wincmn.cpp

index 4b721d0da3494e401287f86ff62a0983ff926483..758ab40742efb88ddbd5d99a66c85103eedbed86 100644 (file)
@@ -39,6 +39,11 @@ All:
 - wxGetPowerType() and wxGetBatteryState() addition
 - wxSystemSettings::GetSystem*() members deprecated and replaced with
   wxSystemSettings::Get*()
 - wxGetPowerType() and wxGetBatteryState() addition
 - wxSystemSettings::GetSystem*() members deprecated and replaced with
   wxSystemSettings::Get*()
+- wxWindowBase::DoGetBestSize now includes the difference (if any) between 
+  the client size and total size of the window.  Code that sets the 
+  client size using the best size, or that added extra space to sizers
+  to compensate for this bug may need to be changed.
+
 
 All (GUI):
 
 
 All (GUI):
 
index 1f67899546ffc2df4768835eba2ee53d97db375e..29a9fa84023cd682bf16da4f830b0d9ff5e609a7 100644 (file)
@@ -508,7 +508,7 @@ void wxWindowBase::Fit()
 {
     if ( GetChildren().GetCount() > 0 )
     {
 {
     if ( GetChildren().GetCount() > 0 )
     {
-        SetClientSize(GetBestSize());
+        SetSize(GetBestSize());
     }
     //else: do nothing if we have no children
 }
     }
     //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
 {
 // return the size best suited for the current window
 wxSize wxWindowBase::DoGetBestSize() const
 {
+    wxSize best;
+    
     if ( m_windowSizer )
     {
     if ( m_windowSizer )
     {
-        return m_windowSizer->GetMinSize();
+        best = m_windowSizer->GetMinSize();
     }
 #if wxUSE_CONSTRAINTS
     else if ( m_constraints )
     }
 #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 :-(
         }
 
             //       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()
     }
 #endif // wxUSE_CONSTRAINTS
     else if ( !GetChildren().empty()
@@ -643,17 +645,25 @@ wxSize wxWindowBase::DoGetBestSize() const
         maxX += 7;
         maxY += 14;
 
         maxX += 7;
         maxY += 14;
 
-        return wxSize(maxX, maxY);
+        best = wxSize(maxX, maxY);
     }
     else // ! has children
     {
     }
     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();
     }
         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;
 }
 
 
 }