Fix for potential layout glitches in wxGridBagSizer when items span cells but
some other item affects the size of one of spanned rows/cols. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@52986 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -286,6 +286,9 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxGBPosition FindEmptyCell();
|
wxGBPosition FindEmptyCell();
|
||||||
|
#if wxABI_VERSION >= 20808
|
||||||
|
void AdjustForOverflow();
|
||||||
|
#endif
|
||||||
|
|
||||||
wxSize m_emptyCellSize;
|
wxSize m_emptyCellSize;
|
||||||
|
|
||||||
|
@@ -476,6 +476,7 @@ wxSize wxGridBagSizer::CalcMin()
|
|||||||
node = node->GetNext();
|
node = node->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AdjustForOverflow();
|
||||||
AdjustForFlexDirection();
|
AdjustForFlexDirection();
|
||||||
|
|
||||||
// Now traverse the heights and widths arrays calcing the totals, including gaps
|
// Now traverse the heights and widths arrays calcing the totals, including gaps
|
||||||
@@ -561,6 +562,98 @@ void wxGridBagSizer::RecalcSizes()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Sometimes CalcMin can result in some rows or cols having too much space in
|
||||||
|
// them because as it traverses the items it makes some assumptions when
|
||||||
|
// items span to other cells. But those assumptions can become invalid later
|
||||||
|
// on when other items are fitted into the same rows or columns that the
|
||||||
|
// spanning item occupies. This method tries to find those situations and
|
||||||
|
// fixes them.
|
||||||
|
void wxGridBagSizer::AdjustForOverflow()
|
||||||
|
{
|
||||||
|
int row, col;
|
||||||
|
|
||||||
|
for (row=0; row<m_rowHeights.GetCount(); row++)
|
||||||
|
{
|
||||||
|
int rowExtra=INT_MAX;
|
||||||
|
int rowHeight = m_rowHeights[row];
|
||||||
|
for (col=0; col<m_colWidths.GetCount(); col++)
|
||||||
|
{
|
||||||
|
wxGBPosition pos(row,col);
|
||||||
|
wxGBSizerItem* item = FindItemAtPosition(pos);
|
||||||
|
if ( !item )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
int endrow, endcol;
|
||||||
|
item->GetEndPos(endrow, endcol);
|
||||||
|
|
||||||
|
// If the item starts in this position and doesn't span rows, then
|
||||||
|
// just look at the whole item height
|
||||||
|
if ( item->GetPos() == pos && endrow == row )
|
||||||
|
{
|
||||||
|
int itemHeight = item->GetSize().GetHeight();
|
||||||
|
rowExtra = wxMin(rowExtra, rowHeight - itemHeight);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, only look at spanning items if they end on this row
|
||||||
|
if ( endrow == row )
|
||||||
|
{
|
||||||
|
// first deduct the portions of the item that are on prior rows
|
||||||
|
int itemHeight = item->GetSize().GetHeight();
|
||||||
|
for (int r=item->GetPos().GetRow(); r<row; r++)
|
||||||
|
itemHeight -= (m_rowHeights[r] + GetHGap());
|
||||||
|
|
||||||
|
if ( itemHeight < 0 )
|
||||||
|
itemHeight = 0;
|
||||||
|
|
||||||
|
// and check how much is left
|
||||||
|
rowExtra = wxMin(rowExtra, rowHeight - itemHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( rowExtra && rowExtra != INT_MAX )
|
||||||
|
m_rowHeights[row] -= rowExtra;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now do the same thing for columns
|
||||||
|
for (col=0; col<m_colWidths.GetCount(); col++)
|
||||||
|
{
|
||||||
|
int colExtra=INT_MAX;
|
||||||
|
int colWidth = m_colWidths[col];
|
||||||
|
for (row=0; row<m_rowHeights.GetCount(); row++)
|
||||||
|
{
|
||||||
|
wxGBPosition pos(row,col);
|
||||||
|
wxGBSizerItem* item = FindItemAtPosition(pos);
|
||||||
|
if ( !item )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
int endrow, endcol;
|
||||||
|
item->GetEndPos(endrow, endcol);
|
||||||
|
|
||||||
|
if ( item->GetPos() == pos && endcol == col )
|
||||||
|
{
|
||||||
|
int itemWidth = item->GetSize().GetWidth();
|
||||||
|
colExtra = wxMin(colExtra, colWidth - itemWidth);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( endcol == col )
|
||||||
|
{
|
||||||
|
int itemWidth = item->GetSize().GetWidth();
|
||||||
|
for (int c=item->GetPos().GetCol(); c<col; c++)
|
||||||
|
itemWidth -= (m_colWidths[c] + GetVGap());
|
||||||
|
|
||||||
|
if ( itemWidth < 0 )
|
||||||
|
itemWidth = 0;
|
||||||
|
|
||||||
|
colExtra = wxMin(colExtra, colWidth - itemWidth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( colExtra && colExtra != INT_MAX )
|
||||||
|
m_colWidths[col] -= colExtra;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
*wxApp*MacHideApp*;
|
*wxApp*MacHideApp*;
|
||||||
*TimeZone*Make*;
|
*TimeZone*Make*;
|
||||||
*wxBitmapButton*OnFocusChange*;
|
*wxBitmapButton*OnFocusChange*;
|
||||||
|
*wxGridBagSizer*AdjustForOverflow*;
|
||||||
*wxRemotelyScrolledTreeCtrl*DoCalcScrolledPosition*;
|
*wxRemotelyScrolledTreeCtrl*DoCalcScrolledPosition*;
|
||||||
*wxRemotelyScrolledTreeCtrl*SetScrollbar*;
|
*wxRemotelyScrolledTreeCtrl*SetScrollbar*;
|
||||||
*wxRichTextCtrl*GetTextCursor*;
|
*wxRichTextCtrl*GetTextCursor*;
|
||||||
|
Reference in New Issue
Block a user