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:
Frode Roxrud Gill
2022-03-13 17:05:12 +01:00
committed by Vadim Zeitlin
parent 88e92a5f01
commit f646e8b11c
11 changed files with 387 additions and 152 deletions

View File

@@ -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.