public:
void SetAttr(wxGridCellAttr *attr, int row, int col);
wxGridCellAttr *GetAttr(int row, int col) const;
+ void UpdateAttrRows( size_t pos, int numRows );
+ void UpdateAttrCols( size_t pos, int numCols );
private:
// searches for the attr for given cell, returns wxNOT_FOUND if not found
void SetAttr(wxGridCellAttr *attr, int rowOrCol);
wxGridCellAttr *GetAttr(int rowOrCol) const;
+ void UpdateAttrRowsOrCols( size_t pos, int numRowsOrCols );
private:
wxArrayInt m_rowsOrCols;
return attr;
}
+void wxGridCellAttrData::UpdateAttrRows( size_t pos, int numRows )
+{
+ size_t count = m_attrs.GetCount();
+ 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--;
+ }
+ }
+ }
+ }
+}
+
+void wxGridCellAttrData::UpdateAttrCols( size_t pos, int numCols )
+{
+ size_t count = m_attrs.GetCount();
+ 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--;
+ }
+ }
+ }
+ }
+}
+
int wxGridCellAttrData::FindIndex(int row, int col) const
{
size_t count = m_attrs.GetCount();
}
}
+void wxGridRowOrColAttrData::UpdateAttrRowsOrCols( size_t pos, int numRowsOrCols )
+{
+ size_t count = m_attrs.GetCount();
+ 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--;
+ }
+ }
+ }
+ }
+}
+
// ----------------------------------------------------------------------------
// wxGridCellAttrProvider
// ----------------------------------------------------------------------------
m_data->m_colAttrs.SetAttr(attr, col);
}
+void wxGridCellAttrProvider::UpdateAttrRows( size_t pos, int numRows )
+{
+ if ( m_data )
+ {
+ m_data->m_cellAttrs.UpdateAttrRows( pos, numRows );
+
+ m_data->m_rowAttrs.UpdateAttrRowsOrCols( pos, numRows );
+ }
+}
+
+void wxGridCellAttrProvider::UpdateAttrCols( size_t pos, int numCols )
+{
+ if ( m_data )
+ {
+ m_data->m_cellAttrs.UpdateAttrCols( pos, numCols );
+
+ m_data->m_colAttrs.UpdateAttrRowsOrCols( pos, numCols );
+ }
+}
+
// ----------------------------------------------------------------------------
// wxGridTableBase
// ----------------------------------------------------------------------------
}
}
+void wxGridTableBase::UpdateAttrRows( size_t pos, int numRows )
+{
+ if ( m_attrProvider )
+ {
+ m_attrProvider->UpdateAttrRows( pos, numRows );
+ }
+}
+
+void wxGridTableBase::UpdateAttrCols( size_t pos, int numCols )
+{
+ if ( m_attrProvider )
+ {
+ m_attrProvider->UpdateAttrCols( pos, numCols );
+ }
+}
+
bool wxGridTableBase::InsertRows( size_t pos, size_t numRows )
{
wxFAIL_MSG( wxT("Called grid table class function InsertRows\n"
{
m_data.Insert( sa, row );
}
-
+ UpdateAttrRows( pos, numRows );
if ( GetView() )
{
wxGridTableMessage msg( this,
m_data.Remove( pos );
}
}
-
+ UpdateAttrRows( pos, -numRows );
if ( GetView() )
{
wxGridTableMessage msg( this,
m_data[row].Insert( wxEmptyString, col );
}
}
-
+ UpdateAttrCols( pos, numCols );
if ( GetView() )
{
wxGridTableMessage msg( this,
}
}
}
-
+ UpdateAttrCols( pos, -numCols );
if ( GetView() )
{
wxGridTableMessage msg( this,