+ wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(propertyWindow);
+ if (resource)
+ {
+ wxString value = property->GetValue().StringValue();
+
+ wxString strName = value.Before('=');
+ wxString strId = value.After('=');
+ int id = atoi(strId);
+
+ wxString oldSymbolName = wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().GetSymbolForId(resource->GetId());
+ int oldSymbolId = resource->GetId();
+
+ if (strName != "")
+ {
+ // If we change the id for an existing symbol, we need to:
+ // 1) Check if there are any other resources currently using the original id.
+ // If so, will need to change their id to the new id.
+ // 2) Remove the old symbol, add the new symbol.
+ // In this check, we don't have to do this, but we need to do it in SetProperty.
+
+ if (strName == oldSymbolName && id != oldSymbolId)
+ {
+ wxASSERT( (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName)) );
+
+ // It's OK to change just the id. But we'll need to change all matching ids in all resources,
+ // because ids are unique and changing one resource's id must change all identical ones.
+ wxResourceManager::GetCurrentResourceManager()->ChangeIds(oldSymbolId, id);
+
+ wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName);
+ wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName, id);
+ }
+
+ // If we change the name but not the id, we'll just need to remove and
+ // re-add the symbol/id pair.
+ if (strName != oldSymbolName && id == oldSymbolId)
+ {
+ wxASSERT( (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName)) );
+
+ wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName);
+
+ if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(strName))
+ {
+ wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName, id);
+ }
+ }
+
+ // What if we're changing both the name and the id?
+ // - if there's no symbol of that name, just remove the old, add the new (in SetProperty)
+ // - if there is a symbol of that name, if id matches, do nothing. If not, veto.
+
+ if (strName != oldSymbolName && id != oldSymbolId)
+ {
+ // Remove old symbol if it's not being used
+ if (!wxResourceManager::GetCurrentResourceManager()->IsSymbolUsed(resource, oldSymbolId) &&
+ !wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().IsStandardSymbol(oldSymbolName))
+ {
+ wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().RemoveSymbol(oldSymbolName);
+ }
+
+ if (!wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().SymbolExists(strName))
+ {
+ wxResourceManager::GetCurrentResourceManager()->GetSymbolTable().AddSymbol(strName, id);
+ }
+ }
+ resource->SetId(id);
+ }
+
+ return TRUE;
+ }
+ else
+ return FALSE;