Allow cloning client data stored in wxGrid attributes etc
Add wxSharedClientDataContainer class storing ref-counted client data and use it instead of plain wxClientDataContainer in wxGridCellAttr, wxGridCellEditor and wxGridCellRenderer classes. This allows to keep the same client data associated with many grid cells without having to make many copies of it.
This commit is contained in:
committed by
Vadim Zeitlin
parent
88e92a5f01
commit
f646e8b11c
@@ -1729,6 +1729,21 @@ TEST_CASE_METHOD(GridTestCase, "Grid::CellAttribute", "[attr][cell][grid]")
|
||||
CHECK_ATTR_COUNT( 0 );
|
||||
}
|
||||
|
||||
SECTION("Cloning")
|
||||
{
|
||||
CHECK_ATTR_COUNT( 0 );
|
||||
|
||||
m_grid->GetOrCreateCellAttrPtr(0, 0)
|
||||
->SetClientObject(new wxStringClientData("test"));
|
||||
CHECK_ATTR_COUNT( 1 );
|
||||
|
||||
m_grid->SetAttr(0, 1, m_grid->GetOrCreateCellAttrPtr(0, 0)->Clone());
|
||||
CHECK_ATTR_COUNT( 2 );
|
||||
|
||||
wxClientData* const
|
||||
data = m_grid->GetOrCreateCellAttrPtr(0, 1)->GetClientObject();
|
||||
CHECK( static_cast<wxStringClientData*>(data)->GetData() == "test" );
|
||||
}
|
||||
|
||||
// Fill the grid with attributes for next sections.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user