implement CreateGrid() in terms of SetTable() instead of duplicating its code and confusing the issue

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55646 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-09-15 14:09:26 +00:00
parent ff72f628bb
commit 6b992f7df1

View File

@@ -4279,28 +4279,16 @@ void wxGrid::Create()
} }
bool wxGrid::CreateGrid( int numRows, int numCols, bool wxGrid::CreateGrid( int numRows, int numCols,
wxGrid::wxGridSelectionModes selmode ) wxGridSelectionModes selmode )
{ {
wxCHECK_MSG( !m_created, wxCHECK_MSG( !m_created,
false, false,
wxT("wxGrid::CreateGrid or wxGrid::SetTable called more than once") ); wxT("wxGrid::CreateGrid or wxGrid::SetTable called more than once") );
m_numRows = numRows; return SetTable(new wxGridStringTable(numRows, numCols), true, selmode);
m_numCols = numCols;
m_table = new wxGridStringTable( m_numRows, m_numCols );
m_table->SetView( this );
m_ownTable = true;
m_selection = new wxGridSelection( this, selmode );
CalcDimensions();
m_created = true;
return m_created;
} }
void wxGrid::SetSelectionMode(wxGrid::wxGridSelectionModes selmode) void wxGrid::SetSelectionMode(wxGridSelectionModes selmode)
{ {
wxCHECK_RET( m_created, wxCHECK_RET( m_created,
wxT("Called wxGrid::SetSelectionMode() before calling CreateGrid()") ); wxT("Called wxGrid::SetSelectionMode() before calling CreateGrid()") );
@@ -4310,14 +4298,16 @@ void wxGrid::SetSelectionMode(wxGrid::wxGridSelectionModes selmode)
wxGrid::wxGridSelectionModes wxGrid::GetSelectionMode() const wxGrid::wxGridSelectionModes wxGrid::GetSelectionMode() const
{ {
wxCHECK_MSG( m_created, wxGrid::wxGridSelectCells, wxCHECK_MSG( m_created, wxGridSelectCells,
wxT("Called wxGrid::GetSelectionMode() before calling CreateGrid()") ); wxT("Called wxGrid::GetSelectionMode() before calling CreateGrid()") );
return m_selection->GetSelectionMode(); return m_selection->GetSelectionMode();
} }
bool wxGrid::SetTable( wxGridTableBase *table, bool takeOwnership, bool
wxGrid::wxGridSelectionModes selmode ) wxGrid::SetTable(wxGridTableBase *table,
bool takeOwnership,
wxGrid::wxGridSelectionModes selmode )
{ {
bool checkSelection = false; bool checkSelection = false;
if ( m_created ) if ( m_created )