- wxSize sizeFit(GetScrollX(size.x) * GetScrollLineX(),
- GetScrollY(size.y) * GetScrollLineY());
-
- // distribute the extra space between the columns/rows to avoid having
- // extra white space
- wxCoord diff = sizeFit.x - size.x;
- if ( diff && m_numCols )
- {
- // try to resize the columns uniformly
- wxCoord diffPerCol = diff / m_numCols;
- if ( diffPerCol )
- {
- for ( int col = 0; col < m_numCols; col++ )
- {
- SetColSize(col, GetColWidth(col) + diffPerCol);
- }
- }
-
- // add remaining amount to the last columns
- diff -= diffPerCol * m_numCols;
- if ( diff )
- {
- for ( int col = m_numCols - 1; col >= m_numCols - diff; col-- )
- {
- SetColSize(col, GetColWidth(col) + 1);
- }
- }
- }
-
- // same for rows
- diff = sizeFit.y - size.y;
- if ( diff && m_numRows )
- {
- // try to resize the columns uniformly
- wxCoord diffPerRow = diff / m_numRows;
- if ( diffPerRow )
- {
- for ( int row = 0; row < m_numRows; row++ )
- {
- SetRowSize(row, GetRowHeight(row) + diffPerRow);
- }
- }
-
- // add remaining amount to the last rows
- diff -= diffPerRow * m_numRows;
- if ( diff )
- {
- for ( int row = m_numRows - 1; row >= m_numRows - diff; row-- )
- {
- SetRowSize(row, GetRowHeight(row) + 1);
- }
- }
- }