+
+ int h = wxMax( 0, height );
+ int diff = h - m_rowHeights[row];
+
+ m_rowHeights[row] = h;
+ int i;
+ for ( i = row; i < m_numRows; i++ )
+ {
+ m_rowBottoms[i] += diff;
+ }
+ if ( !GetBatchCount() )
+ CalcDimensions();
+}
+
+void wxGrid::SetDefaultColSize( int width, bool resizeExistingCols )
+{
+ m_defaultColWidth = wxMax( width, WXGRID_MIN_COL_WIDTH );
+
+ if ( resizeExistingCols )
+ {
+ InitColWidths();
+ if ( !GetBatchCount() )
+ CalcDimensions();
+ }
+}
+
+void wxGrid::SetColSize( int col, int width )
+{
+ wxCHECK_RET( col >= 0 && col < m_numCols, _T("invalid column index") );
+
+ // should we check that it's bigger than GetColMinimalWidth(col) here?
+
+ if ( m_colWidths.IsEmpty() )
+ {
+ // need to really create the array
+ InitColWidths();
+ }
+
+ int w = wxMax( 0, width );
+ int diff = w - m_colWidths[col];
+ m_colWidths[col] = w;
+
+ int i;
+ for ( i = col; i < m_numCols; i++ )
+ {
+ m_colRights[i] += diff;
+ }
+ if ( !GetBatchCount() )
+ CalcDimensions();
+}
+
+
+void wxGrid::SetColMinimalWidth( int col, int width )
+{
+ m_colMinWidths.Put(col, width);
+}
+
+void wxGrid::SetRowMinimalHeight( int row, int width )
+{
+ m_rowMinHeights.Put(row, width);
+}
+
+int wxGrid::GetColMinimalWidth(int col) const
+{
+ long value = m_colMinWidths.Get(col);
+ return value != wxNOT_FOUND ? (int)value : WXGRID_MIN_COL_WIDTH;
+}
+
+int wxGrid::GetRowMinimalHeight(int row) const
+{
+ long value = m_rowMinHeights.Get(row);
+ return value != wxNOT_FOUND ? (int)value : WXGRID_MIN_ROW_HEIGHT;
+}
+
+// ----------------------------------------------------------------------------
+// auto sizing
+// ----------------------------------------------------------------------------
+
+void wxGrid::AutoSizeColOrRow( int colOrRow, bool setAsMin, bool column )
+{
+ wxClientDC dc(m_gridWin);
+
+ // init both of them to avoid compiler warnings, even if weo nly need one
+ int row = -1,
+ col = -1;
+ if ( column )
+ col = colOrRow;
+ else
+ row = colOrRow;
+
+ wxCoord extent, extentMax = 0;
+ int max = column ? m_numRows : m_numCols;
+ for ( int rowOrCol = 0; rowOrCol < max; rowOrCol++ )
+ {
+ if ( column )
+ row = rowOrCol;
+ else
+ col = rowOrCol;
+
+ wxGridCellAttr* attr = GetCellAttr(row, col);
+ wxGridCellRenderer* renderer = attr->GetRenderer(this, row, col);
+ if ( renderer )
+ {
+ wxSize size = renderer->GetBestSize(*this, *attr, dc, row, col);
+ extent = column ? size.x : size.y;
+ if ( extent > extentMax )
+ {
+ extentMax = extent;
+ }
+
+ renderer->DecRef();
+ }
+
+ attr->DecRef();
+ }
+
+ // now also compare with the column label extent
+ wxCoord w, h;
+ dc.SetFont( GetLabelFont() );
+
+ if ( column )
+ dc.GetTextExtent( GetColLabelValue(col), &w, &h );
+ else
+ dc.GetTextExtent( GetRowLabelValue(row), &w, &h );
+
+ extent = column ? w : h;
+ if ( extent > extentMax )
+ {
+ extentMax = extent;
+ }
+
+ if ( !extentMax )
+ {
+ // empty column - give default extent (notice that if extentMax is less
+ // than default extent but != 0, it's ok)
+ extentMax = column ? m_defaultColWidth : m_defaultRowHeight;
+ }
+ else
+ {
+ if ( column )
+ {
+ // leave some space around text
+ extentMax += 10;
+ }
+ else
+ {
+ extentMax += 6;
+ }
+ }
+
+ if ( column ){
+ SetColSize(col, extentMax);
+ if ( !GetBatchCount() )
+ {
+ int cw, ch, dummy;
+ m_gridWin->GetClientSize( &cw, &ch );
+ wxRect rect ( CellToRect( 0, col ) );
+ rect.y = 0;
+ CalcScrolledPosition(rect.x, 0, &rect.x, &dummy);
+ rect.width = cw - rect.x;
+ rect.height = m_colLabelHeight;
+ m_colLabelWin->Refresh( TRUE, &rect );
+ }
+ }
+ else{
+ SetRowSize(row, extentMax);
+ if ( !GetBatchCount() )
+ {
+ int cw, ch, dummy;
+ m_gridWin->GetClientSize( &cw, &ch );
+ wxRect rect ( CellToRect( row, 0 ) );
+ rect.x = 0;
+ CalcScrolledPosition(0, rect.y, &dummy, &rect.y);
+ rect.width = m_rowLabelWidth;
+ rect.height = ch - rect.y;
+ m_rowLabelWin->Refresh( TRUE, &rect );
+ }
+ }
+ if ( setAsMin )