Improve resetting table via SetTable (extended version of patch #1636377).
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44284 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -4357,24 +4357,33 @@ wxGrid::wxGridSelectionModes wxGrid::GetSelectionMode() const
|
|||||||
bool wxGrid::SetTable( wxGridTableBase *table, bool takeOwnership,
|
bool wxGrid::SetTable( wxGridTableBase *table, bool takeOwnership,
|
||||||
wxGrid::wxGridSelectionModes selmode )
|
wxGrid::wxGridSelectionModes selmode )
|
||||||
{
|
{
|
||||||
|
bool checkSelection = false;
|
||||||
if ( m_created )
|
if ( m_created )
|
||||||
{
|
{
|
||||||
// stop all processing
|
// stop all processing
|
||||||
m_created = false;
|
m_created = false;
|
||||||
|
|
||||||
if (m_ownTable)
|
if (m_table)
|
||||||
{
|
{
|
||||||
wxGridTableBase *t = m_table;
|
m_table->SetView(0);
|
||||||
|
if( m_ownTable )
|
||||||
|
delete m_table;
|
||||||
m_table = NULL;
|
m_table = NULL;
|
||||||
delete t;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete m_selection;
|
delete m_selection;
|
||||||
|
|
||||||
m_table = NULL;
|
|
||||||
m_selection = NULL;
|
m_selection = NULL;
|
||||||
|
|
||||||
|
m_ownTable = false;
|
||||||
m_numRows = 0;
|
m_numRows = 0;
|
||||||
m_numCols = 0;
|
m_numCols = 0;
|
||||||
|
checkSelection = true;
|
||||||
|
|
||||||
|
// kill row and column size arrays
|
||||||
|
m_colWidths.Empty();
|
||||||
|
m_colRights.Empty();
|
||||||
|
m_rowHeights.Empty();
|
||||||
|
m_rowBottoms.Empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (table)
|
if (table)
|
||||||
@@ -4386,7 +4395,28 @@ bool wxGrid::SetTable( wxGridTableBase *table, bool takeOwnership,
|
|||||||
m_table->SetView( this );
|
m_table->SetView( this );
|
||||||
m_ownTable = takeOwnership;
|
m_ownTable = takeOwnership;
|
||||||
m_selection = new wxGridSelection( this, selmode );
|
m_selection = new wxGridSelection( this, selmode );
|
||||||
|
if (checkSelection)
|
||||||
|
{
|
||||||
|
// If the newly set table is smaller than the
|
||||||
|
// original one current cell and selection regions
|
||||||
|
// might be invalid,
|
||||||
|
m_selectingKeyboard = wxGridNoCellCoords;
|
||||||
|
m_currentCellCoords =
|
||||||
|
wxGridCellCoords(wxMin(m_numRows, m_currentCellCoords.GetRow()),
|
||||||
|
wxMin(m_numCols, m_currentCellCoords.GetCol()));
|
||||||
|
if (m_selectingTopLeft.GetRow() >= m_numRows ||
|
||||||
|
m_selectingTopLeft.GetCol() >= m_numCols)
|
||||||
|
{
|
||||||
|
m_selectingTopLeft = wxGridNoCellCoords;
|
||||||
|
m_selectingBottomRight = wxGridNoCellCoords;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_selectingBottomRight =
|
||||||
|
wxGridCellCoords(wxMin(m_numRows,
|
||||||
|
m_selectingBottomRight.GetRow()),
|
||||||
|
wxMin(m_numCols,
|
||||||
|
m_selectingBottomRight.GetCol()));
|
||||||
|
}
|
||||||
CalcDimensions();
|
CalcDimensions();
|
||||||
|
|
||||||
m_created = true;
|
m_created = true;
|
||||||
|
Reference in New Issue
Block a user