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:
@@ -1686,7 +1686,7 @@ BigGridFrame::BigGridFrame(long sizeGrid)
|
||||
// must profile it...
|
||||
//m_table->SetAttrProvider(new MyGridCellAttrProvider);
|
||||
|
||||
m_grid->SetTable(m_table, true);
|
||||
m_grid->AssignTable(m_table);
|
||||
|
||||
#if defined __WXMOTIF__
|
||||
// MB: the grid isn't getting a sensible default size under wxMotif
|
||||
@@ -1977,7 +1977,7 @@ BugsGridFrame::BugsGridFrame()
|
||||
wxGrid *grid = new wxGrid(this, wxID_ANY);
|
||||
wxGridTableBase *table = new BugsGridTable();
|
||||
table->SetAttrProvider(new MyGridCellAttrProvider);
|
||||
grid->SetTable(table, true);
|
||||
grid->AssignTable(table);
|
||||
|
||||
wxGridCellAttr *attrRO = new wxGridCellAttr,
|
||||
*attrRangeEditor = new wxGridCellAttr,
|
||||
@@ -2338,7 +2338,7 @@ TabularGridFrame::TabularGridFrame()
|
||||
m_grid = new wxGrid(panel, wxID_ANY,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxBORDER_STATIC | wxWANTS_CHARS);
|
||||
m_grid->SetTable(m_table, true, wxGrid::wxGridSelectRows);
|
||||
m_grid->AssignTable(m_table, wxGrid::wxGridSelectRows);
|
||||
|
||||
m_grid->EnableDragColMove();
|
||||
m_grid->UseNativeColHeader();
|
||||
|
Reference in New Issue
Block a user