diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 579076688c..14065dd42e 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -1329,18 +1329,14 @@ void wxGridStringTable::Clear() bool wxGridStringTable::InsertRows( size_t pos, size_t numRows ) { - size_t curNumRows = m_data.GetCount(); - size_t curNumCols = ( curNumRows > 0 ? m_data[0].GetCount() : - ( GetView() ? GetView()->GetNumberCols() : 0 ) ); - - if ( pos >= curNumRows ) + if ( pos >= m_data.size() ) { return AppendRows( numRows ); } wxArrayString sa; - sa.Alloc( curNumCols ); - sa.Add( wxEmptyString, curNumCols ); + sa.Alloc( m_numCols ); + sa.Add( wxEmptyString, m_numCols ); m_data.Insert( sa, pos, numRows ); if ( GetView() ) @@ -1358,16 +1354,11 @@ bool wxGridStringTable::InsertRows( size_t pos, size_t numRows ) bool wxGridStringTable::AppendRows( size_t numRows ) { - size_t curNumRows = m_data.GetCount(); - size_t curNumCols = ( curNumRows > 0 - ? m_data[0].GetCount() - : ( GetView() ? GetView()->GetNumberCols() : 0 ) ); - wxArrayString sa; - if ( curNumCols > 0 ) + if ( m_numCols > 0 ) { - sa.Alloc( curNumCols ); - sa.Add( wxEmptyString, curNumCols ); + sa.Alloc( m_numCols ); + sa.Add( wxEmptyString, m_numCols ); } m_data.Add( sa, numRows ); @@ -1430,14 +1421,7 @@ bool wxGridStringTable::DeleteRows( size_t pos, size_t numRows ) bool wxGridStringTable::InsertCols( size_t pos, size_t numCols ) { - size_t row, col; - - size_t curNumRows = m_data.GetCount(); - size_t curNumCols = ( curNumRows > 0 - ? m_data[0].GetCount() - : ( GetView() ? GetView()->GetNumberCols() : 0 ) ); - - if ( pos >= curNumCols ) + if ( pos >= static_cast(m_numCols) ) { return AppendCols( numCols ); } @@ -1446,14 +1430,13 @@ bool wxGridStringTable::InsertCols( size_t pos, size_t numCols ) { m_colLabels.Insert( wxEmptyString, pos, numCols ); - size_t i; - for ( i = pos; i < pos + numCols; i++ ) + for ( size_t i = pos; i < pos + numCols; i++ ) m_colLabels[i] = wxGridTableBase::GetColLabelValue( i ); } - for ( row = 0; row < curNumRows; row++ ) + for ( size_t row = 0; row < m_data.size(); row++ ) { - for ( col = pos; col < pos + numCols; col++ ) + for ( size_t col = pos; col < pos + numCols; col++ ) { m_data[row].Insert( wxEmptyString, col ); } @@ -1476,11 +1459,7 @@ bool wxGridStringTable::InsertCols( size_t pos, size_t numCols ) bool wxGridStringTable::AppendCols( size_t numCols ) { - size_t row; - - size_t curNumRows = m_data.GetCount(); - - for ( row = 0; row < curNumRows; row++ ) + for ( size_t row = 0; row < m_data.size(); row++ ) { m_data[row].Add( wxEmptyString, numCols ); } @@ -1504,8 +1483,7 @@ bool wxGridStringTable::DeleteCols( size_t pos, size_t numCols ) size_t row; size_t curNumRows = m_data.GetCount(); - size_t curNumCols = ( curNumRows > 0 ? m_data[0].GetCount() : - ( GetView() ? GetView()->GetNumberCols() : 0 ) ); + size_t curNumCols = m_numCols; if ( pos >= curNumCols ) {