]> git.saurik.com Git - wxWidgets.git/commitdiff
Fixed bug in FlexGridSizer mods that prevented them from ever shrinking.
authorRon Lee <ron@debian.org>
Mon, 27 Jan 2003 09:02:58 +0000 (09:02 +0000)
committerRon Lee <ron@debian.org>
Mon, 27 Jan 2003 09:02:58 +0000 (09:02 +0000)
Reverted the earlier SetScrollbars patch and fixed a bug in GetVirtualSize
that was hopefully the real cause of all the preceding woe.

Added a comment and a kludge for a most unusual bug manifesting in the
scrollsub sample.  If it is resized quickly size events appear to get lost
and the scrollbar is set incorrectly.  Adding an extra call to
AdjustScrollbars masks the problem, though its clearly superfluous since
the FitInside above already calls it.  This seems to be a brand new problem
(on both Gtk and msw) as of some time prior to this patch and it should be
looked into further.

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

src/common/sizer.cpp
src/common/wincmn.cpp
src/generic/scrlwing.cpp
src/gtk/scrolwin.cpp
src/gtk1/scrolwin.cpp

index a0ee65773c2cb0c7c69578e2a1e10544d6d08cb2..dfe492531dff16e4ab2c88c23de567970ab1bab4 100644 (file)
@@ -1114,16 +1114,29 @@ void wxFlexGridSizer::RecalcSizes()
 
 wxSize wxFlexGridSizer::CalcMin()
 {
-    int nrows, ncols;
+    int     nrows,
+            ncols;
+    size_t  i, s;
+
     if ( !CalcRowsCols(nrows, ncols) )
         return wxSize(10, 10);
 
+    // We have to clear the old sizes out if any item has wxADJUST_MINSIZE
+    // set on it.  Its probably quicker to just always do it than test for
+    // that though.  At least do it before resizing the arrays, SetCount will
+    // initialise new elements to zero.
+    for( s = m_rowHeights.GetCount(), i = 0; i < s; ++i )
+        m_rowHeights[ i ] = 0;
+
+    for( s = m_colWidths.GetCount(), i = 0; i < s; ++i )
+        m_colWidths[ i ] = 0;
+
     m_rowHeights.SetCount(nrows);
     m_colWidths.SetCount(ncols);
 
-    int                      i = 0;
     wxSizerItemList::Node   *node = m_children.GetFirst();
 
+    i = 0;
     while (node)
     {
         wxSizerItem    *item = node->GetData();
index aa805541dab4eed34953bd7f7e5afa5a6d20c4d7..65d02ccc85920b0fa2d07eaaa038a1215fa64dc8 100644 (file)
@@ -634,12 +634,8 @@ wxSize wxWindowBase::DoGetVirtualSize() const
 {
     wxSize  s( GetClientSize() );
 
-    if( m_virtualSize.GetWidth() != -1 )
-        s.SetWidth( m_virtualSize.GetWidth() );
-    if( m_virtualSize.GetHeight() != -1 )
-        s.SetHeight( m_virtualSize.GetHeight() );
-
-    return s;
+    return wxSize( wxMax( m_virtualSize.GetWidth(), s.GetWidth() ),
+                   wxMax( m_virtualSize.GetHeight(), s.GetHeight() ) );
 }
 
 // ----------------------------------------------------------------------------
index f516a8552dcb6536b470c19d139aef5987bb8554..944ff42b1e111fbbf961a29ded0ec07d410b9f8e 100644 (file)
@@ -344,23 +344,18 @@ void wxScrollHelper::SetScrollbars(int pixelsPerUnitX,
     m_xScrollPosition = xPos;
     m_yScrollPosition = yPos;
 
+    int w = noUnitsX * pixelsPerUnitX;
+    int h = noUnitsY * pixelsPerUnitY;
+
     // For better backward compatibility we set persisting limits
     // here not just the size.  It makes SetScrollbars 'sticky'
     // emulating the old non-autoscroll behaviour.
 
-    wxSize sz = m_targetWindow->GetClientSize();
-#if 1
-    int x = wxMax(noUnitsX * pixelsPerUnitX, sz.x);
-    int y = wxMax(noUnitsY * pixelsPerUnitY, sz.y);
-#else
-    int x = noUnitsX * pixelsPerUnitX;
-    int y = noUnitsY * pixelsPerUnitY;
-#endif    
-    m_targetWindow->SetVirtualSizeHints( x, y );
+    m_targetWindow->SetVirtualSizeHints( w, h );
 
     // The above should arguably be deprecated, this however we still need.
 
-    m_targetWindow->SetVirtualSize( x, y );
+    m_targetWindow->SetVirtualSize( w, h );
 
     if (do_refresh && !noRefresh)
         m_targetWindow->Refresh(TRUE, GetRect());
@@ -891,16 +886,19 @@ void wxScrollHelper::DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) co
 // Default OnSize resets scrollbars, if any
 void wxScrollHelper::HandleOnSize(wxSizeEvent& WXUNUSED(event))
 {
-    if( m_win->GetAutoLayout() )
+    if( m_win->GetAutoLayout() || m_targetWindow->GetAutoLayout() )
     {
         if ( m_targetWindow != m_win )
             m_targetWindow->FitInside();
 
         m_win->FitInside();
 
-#if wxUSE_CONSTRAINTS
-        m_win->Layout();
-#endif
+        // FIXME:  Something is really weird here...  This should be
+        // called by FitInside above (and apparently is), yet the
+        // scrollsub sample will get the scrollbar wrong if resized
+        // quickly.  This masks the bug, but is surely not the right
+        // answer at all.
+        AdjustScrollbars();
     }
     else
         AdjustScrollbars();
index ff1c2da0a007c76f80cab808290b49d593ef5b36..9a792a679e2fb89d106b26b8f73502b3e41dc66f 100644 (file)
@@ -833,12 +833,19 @@ bool wxScrolledWindow::Layout()
 // Default OnSize resets scrollbars, if any
 void wxScrolledWindow::OnSize(wxSizeEvent& WXUNUSED(event))
 {
-    if( GetAutoLayout() )
+    if( GetAutoLayout() || m_targetWindow->GetAutoLayout() )
     {
         if( m_targetWindow != this )
             m_targetWindow->FitInside();
 
         FitInside();
+
+        // FIXME:  Something is really weird here...  This should be
+        // called by FitInside above (and apparently is), yet the
+        // scrollsub sample will get the scrollbar wrong if resized
+        // quickly.  This masks the bug, but is surely not the right
+        // answer at all.
+        AdjustScrollbars();
     }
     else
     {
index ff1c2da0a007c76f80cab808290b49d593ef5b36..9a792a679e2fb89d106b26b8f73502b3e41dc66f 100644 (file)
@@ -833,12 +833,19 @@ bool wxScrolledWindow::Layout()
 // Default OnSize resets scrollbars, if any
 void wxScrolledWindow::OnSize(wxSizeEvent& WXUNUSED(event))
 {
-    if( GetAutoLayout() )
+    if( GetAutoLayout() || m_targetWindow->GetAutoLayout() )
     {
         if( m_targetWindow != this )
             m_targetWindow->FitInside();
 
         FitInside();
+
+        // FIXME:  Something is really weird here...  This should be
+        // called by FitInside above (and apparently is), yet the
+        // scrollsub sample will get the scrollbar wrong if resized
+        // quickly.  This masks the bug, but is surely not the right
+        // answer at all.
+        AdjustScrollbars();
     }
     else
     {