Add a simple wxGrid::AssignTable() wrapper for SetTable()
In many case SetTable() is called with its takeOwnership parameter set to true, as shown by the grid sample in which all 3 of the calls to SetTable() set it to true, but calling it in this case is awkward, as bare "true" in the caller is unreadable and almost invariably requires an explanatory comment. Improve the API by adding AssignTable(), which is the same to SetTable() as the existing AssignImageList() to SetImageLabel(), which always takes ownership of the table pointer.
This commit is contained in:
@@ -2601,6 +2601,14 @@ wxGrid::SetTable(wxGridTableBase *table,
|
||||
return m_created;
|
||||
}
|
||||
|
||||
void wxGrid::AssignTable(wxGridTableBase *table, wxGridSelectionModes selmode)
|
||||
{
|
||||
wxCHECK_RET( table, wxS("Table pointer must be valid") );
|
||||
wxCHECK_RET( !m_created, wxS("wxGrid already has a table") );
|
||||
|
||||
SetTable(table, true /* take ownership */, selmode);
|
||||
}
|
||||
|
||||
void wxGrid::Init()
|
||||
{
|
||||
m_created = false;
|
||||
|
Reference in New Issue
Block a user