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
@@ -253,6 +253,11 @@ int wxGridColumnOperations::GetFirstLine(const wxGrid *grid, wxGridWindow *gridW
|
||||
// wxGridCellRenderer and wxGridCellEditor managing ref counting
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxGridCellWorker::wxGridCellWorker(const wxGridCellWorker& other)
|
||||
{
|
||||
SetClientDataContainer(other.GetClientDataContainer());
|
||||
}
|
||||
|
||||
void wxGridCellWorker::SetParameters(const wxString& WXUNUSED(params))
|
||||
{
|
||||
// nothing to do
|
||||
@@ -445,6 +450,8 @@ wxGridCellAttr *wxGridCellAttr::Clone() const
|
||||
m_editor->IncRef();
|
||||
}
|
||||
|
||||
attr->SetClientDataContainer(GetClientDataContainer());
|
||||
|
||||
if ( IsReadOnly() )
|
||||
attr->SetReadOnly();
|
||||
|
||||
@@ -485,6 +492,10 @@ void wxGridCellAttr::MergeWith(wxGridCellAttr *mergefrom)
|
||||
m_editor = mergefrom->m_editor;
|
||||
m_editor->IncRef();
|
||||
}
|
||||
if ( !HasClientDataContainer() && mergefrom->HasClientDataContainer() )
|
||||
{
|
||||
SetClientDataContainer(mergefrom->GetClientDataContainer());
|
||||
}
|
||||
if ( !HasReadWriteMode() && mergefrom->HasReadWriteMode() )
|
||||
SetReadOnly(mergefrom->IsReadOnly());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user