]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/gbsizer.cpp
same as r57054 in 2.8
[wxWidgets.git] / src / common / gbsizer.cpp
index 55a7226fc655c7b5e4cbbacb01cce76dac077d10..eb23a2e37218d34bcca785b688a1dc0e96c3445f 100644 (file)
@@ -228,6 +228,18 @@ wxSizerItem* wxGridBagSizer::Add( wxGBSizerItem *item )
     if ( item->GetWindow() )
         item->GetWindow()->SetContainingSizer( this );
 
     if ( item->GetWindow() )
         item->GetWindow()->SetContainingSizer( this );
 
+    // extend the number of rows/columns of the underlying wxFlexGridSizer if
+    // necessary
+    int row, col;
+    item->GetEndPos(row, col);
+    row++;
+    col++;
+
+    if ( row > GetRows() )
+        SetRows(row);
+    if ( col > GetCols() )
+        SetCols(col);
+
     return item;
 }
 
     return item;
 }
 
@@ -580,7 +592,7 @@ void wxGridBagSizer::AdjustForOverflow()
         {
             wxGBPosition pos(row,col);
             wxGBSizerItem* item = FindItemAtPosition(pos);
         {
             wxGBPosition pos(row,col);
             wxGBSizerItem* item = FindItemAtPosition(pos);
-            if ( !item )
+            if ( !item || !item->IsShown() )
                 continue;
 
             int endrow, endcol;
                 continue;
 
             int endrow, endcol;
@@ -590,7 +602,7 @@ void wxGridBagSizer::AdjustForOverflow()
             // just look at the whole item height
             if ( item->GetPos() == pos && endrow == row )
             {
             // just look at the whole item height
             if ( item->GetPos() == pos && endrow == row )
             {
-                int itemHeight = item->GetSize().GetHeight();
+                int itemHeight = item->CalcMin().GetHeight();
                 rowExtra = wxMin(rowExtra, rowHeight - itemHeight);
                 continue;
             }
                 rowExtra = wxMin(rowExtra, rowHeight - itemHeight);
                 continue;
             }
@@ -599,7 +611,7 @@ void wxGridBagSizer::AdjustForOverflow()
             if ( endrow == row )
             {
                 // first deduct the portions of the item that are on prior rows
             if ( endrow == row )
             {
                 // first deduct the portions of the item that are on prior rows
-                int itemHeight = item->GetSize().GetHeight();
+                int itemHeight = item->CalcMin().GetHeight();
                 for (int r=item->GetPos().GetRow(); r<row; r++)
                     itemHeight -= (m_rowHeights[r] + GetHGap());
 
                 for (int r=item->GetPos().GetRow(); r<row; r++)
                     itemHeight -= (m_rowHeights[r] + GetHGap());
 
@@ -623,7 +635,7 @@ void wxGridBagSizer::AdjustForOverflow()
         {
             wxGBPosition pos(row,col);
             wxGBSizerItem* item = FindItemAtPosition(pos);
         {
             wxGBPosition pos(row,col);
             wxGBSizerItem* item = FindItemAtPosition(pos);
-            if ( !item )
+            if ( !item || !item->IsShown() )
                 continue;
 
             int endrow, endcol;
                 continue;
 
             int endrow, endcol;
@@ -631,14 +643,14 @@ void wxGridBagSizer::AdjustForOverflow()
             
             if ( item->GetPos() == pos && endcol == col )
             {
             
             if ( item->GetPos() == pos && endcol == col )
             {
-                int itemWidth = item->GetSize().GetWidth();
+                int itemWidth = item->CalcMin().GetWidth();
                 colExtra = wxMin(colExtra, colWidth - itemWidth);
                 continue;
             }
 
             if ( endcol == col )
             {
                 colExtra = wxMin(colExtra, colWidth - itemWidth);
                 continue;
             }
 
             if ( endcol == col )
             {
-                int itemWidth = item->GetSize().GetWidth();
+                int itemWidth = item->CalcMin().GetWidth();
                 for (int c=item->GetPos().GetCol(); c<col; c++)
                     itemWidth -= (m_colWidths[c] + GetVGap());
 
                 for (int c=item->GetPos().GetCol(); c<col; c++)
                     itemWidth -= (m_colWidths[c] + GetVGap());