From d1c0b4f97ee996b8dd8b3290fa64196ca9761393 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 16 Feb 2000 19:15:13 +0000 Subject: [PATCH] deTABified git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6085 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/generic/grid.h | 3 + src/generic/grid.cpp | 153 +++++++++++++++++++------------------- 2 files changed, 81 insertions(+), 75 deletions(-) diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index 836f125827..7d5e8f02d0 100644 --- a/include/wx/generic/grid.h +++ b/include/wx/generic/grid.h @@ -311,6 +311,9 @@ public: virtual void SetAttr(wxGridCellAttr *attr, int row, int col); virtual void SetRowAttr(wxGridCellAttr *attr, int row); virtual void SetColAttr(wxGridCellAttr *attr, int col); + + // these functions must be called whenever some rows/cols are deleted + // because the internal data must be updated then void UpdateAttrRows( size_t pos, int numRows ); void UpdateAttrCols( size_t pos, int numCols ); diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index edc925b87e..2b687e5ac1 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -637,29 +637,29 @@ void wxGridCellAttrData::UpdateAttrRows( size_t pos, int numRows ) for ( size_t n = 0; n < count; n++ ) { wxGridCellCoords& coords = m_attrs[n].coords; - wxCoord row = coords.GetRow(); - if ((size_t)row >= pos) - { - if (numRows > 0) - { - // If rows inserted, include row counter where necessary - coords.SetRow(row + numRows); - } - else if (numRows < 0) - { - // If rows deleted ... - if ((size_t)row >= pos - numRows) - { - // ...either decrement row counter (if row still exists)... - coords.SetRow(row + numRows); - } - else - { - // ...or remove the attribute - m_attrs.RemoveAt((size_t)n); - n--; count--; - } - } + wxCoord row = coords.GetRow(); + if ((size_t)row >= pos) + { + if (numRows > 0) + { + // If rows inserted, include row counter where necessary + coords.SetRow(row + numRows); + } + else if (numRows < 0) + { + // If rows deleted ... + if ((size_t)row >= pos - numRows) + { + // ...either decrement row counter (if row still exists)... + coords.SetRow(row + numRows); + } + else + { + // ...or remove the attribute + m_attrs.RemoveAt((size_t)n); + n--; count--; + } + } } } } @@ -670,29 +670,29 @@ void wxGridCellAttrData::UpdateAttrCols( size_t pos, int numCols ) for ( size_t n = 0; n < count; n++ ) { wxGridCellCoords& coords = m_attrs[n].coords; - wxCoord col = coords.GetCol(); - if ( (size_t)col >= pos ) - { - if ( numCols > 0 ) - { - // If rows inserted, include row counter where necessary - coords.SetCol(col + numCols); - } - else if (numCols < 0) - { - // If rows deleted ... - if ((size_t)col >= pos - numCols) - { - // ...either decrement row counter (if row still exists)... - coords.SetCol(col + numCols); - } - else - { - // ...or remove the attribute - m_attrs.RemoveAt((size_t)n); - n--; count--; - } - } + wxCoord col = coords.GetCol(); + if ( (size_t)col >= pos ) + { + if ( numCols > 0 ) + { + // If rows inserted, include row counter where necessary + coords.SetCol(col + numCols); + } + else if (numCols < 0) + { + // If rows deleted ... + if ((size_t)col >= pos - numCols) + { + // ...either decrement row counter (if row still exists)... + coords.SetCol(col + numCols); + } + else + { + // ...or remove the attribute + m_attrs.RemoveAt((size_t)n); + n--; count--; + } + } } } } @@ -771,25 +771,25 @@ void wxGridRowOrColAttrData::UpdateAttrRowsOrCols( size_t pos, int numRowsOrCols for ( size_t n = 0; n < count; n++ ) { int & rowOrCol = m_rowsOrCols[n]; - if ( (size_t)rowOrCol >= pos ) - { - if ( numRowsOrCols > 0 ) - { - // If rows inserted, include row counter where necessary - rowOrCol += numRowsOrCols; - } - else if ( numRowsOrCols < 0) - { - // If rows deleted, either decrement row counter (if row still exists) - if ((size_t)rowOrCol >= pos - numRowsOrCols) - rowOrCol += numRowsOrCols; - else - { - m_rowsOrCols.RemoveAt((size_t)n); - m_attrs.RemoveAt((size_t)n); - n--; count--; - } - } + if ( (size_t)rowOrCol >= pos ) + { + if ( numRowsOrCols > 0 ) + { + // If rows inserted, include row counter where necessary + rowOrCol += numRowsOrCols; + } + else if ( numRowsOrCols < 0) + { + // If rows deleted, either decrement row counter (if row still exists) + if ((size_t)rowOrCol >= pos - numRowsOrCols) + rowOrCol += numRowsOrCols; + else + { + m_rowsOrCols.RemoveAt((size_t)n); + m_attrs.RemoveAt((size_t)n); + n--; count--; + } + } } } } @@ -869,7 +869,7 @@ void wxGridCellAttrProvider::UpdateAttrRows( size_t pos, int numRows ) { m_data->m_cellAttrs.UpdateAttrRows( pos, numRows ); - m_data->m_rowAttrs.UpdateAttrRowsOrCols( pos, numRows ); + m_data->m_rowAttrs.UpdateAttrRowsOrCols( pos, numRows ); } } @@ -879,7 +879,7 @@ void wxGridCellAttrProvider::UpdateAttrCols( size_t pos, int numCols ) { m_data->m_cellAttrs.UpdateAttrCols( pos, numCols ); - m_data->m_colAttrs.UpdateAttrRowsOrCols( pos, numCols ); + m_data->m_colAttrs.UpdateAttrRowsOrCols( pos, numCols ); } } @@ -2832,10 +2832,10 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event ) wxClientDC dc( m_gridWin ); PrepareDC( dc ); - y = wxMax( y, - m_rowBottoms[m_dragRowOrCol] - - m_rowHeights[m_dragRowOrCol] + - WXGRID_MIN_ROW_HEIGHT ); + y = wxMax( y, + m_rowBottoms[m_dragRowOrCol] - + m_rowHeights[m_dragRowOrCol] + + WXGRID_MIN_ROW_HEIGHT ); dc.SetLogicalFunction(wxINVERT); if ( m_dragLastPos >= 0 ) { @@ -2852,9 +2852,9 @@ void wxGrid::ProcessGridCellMouseEvent( wxMouseEvent& event ) wxClientDC dc( m_gridWin ); PrepareDC( dc ); - x = wxMax( x, - m_colRights[m_dragRowOrCol] - - m_colWidths[m_dragRowOrCol] + WXGRID_MIN_COL_WIDTH ); + x = wxMax( x, + m_colRights[m_dragRowOrCol] - + m_colWidths[m_dragRowOrCol] + WXGRID_MIN_COL_WIDTH ); dc.SetLogicalFunction(wxINVERT); if ( m_dragLastPos >= 0 ) { @@ -3700,7 +3700,10 @@ void wxGrid::SetCurrentCell( const wxGridCellCoords& coords ) // Clear the old current cell highlight wxRect r = BlockToDeviceRect(m_currentCellCoords, m_currentCellCoords); - m_currentCellCoords = coords; // Otherwise refresh redraws the highlight! + + // Otherwise refresh redraws the highlight! + m_currentCellCoords = coords; + m_gridWin->Refresh( FALSE, &r ); }