+ else if (name == "y")
+ {
+ wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow);
+ int x, y;
+ m_propertyWindow->GetPosition(&x, &y);
+ int newY = (int)property->GetValue().IntegerValue();
+ int pixelY = newY;
+
+ // We need to convert to pixels if this is not a dialog or panel, but
+ // the parent resource specifies dialog units.
+ if (m_propertyWindow->GetParent() && m_propertyWindow->IsKindOf(CLASSINFO(wxControl)))
+ {
+ wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow->GetParent());
+ if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
+ {
+ wxPoint pt = m_propertyWindow->GetParent()->ConvertDialogToPixels(wxPoint(x, newY));
+ pixelY = pt.y;
+ }
+ }
+ else if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel)))
+ {
+ wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow);
+ if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
+ {
+ wxPoint pt = m_propertyWindow->ConvertDialogToPixels(wxPoint(x, newY));
+ pixelY = pt.y;
+ }
+ }
+
+ if (y != pixelY)
+ {
+ m_propertyWindow->Move(x, pixelY);
+ resource->SetSize(resource->GetX(), newY, resource->GetWidth(), resource->GetHeight());
+ }
+ return TRUE;
+ }
+ else if (name == "width")
+ {
+ wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow);
+ int width, height;
+ m_propertyWindow->GetSize(&width, &height);
+ int newWidth = (int)property->GetValue().IntegerValue();
+ int pixelWidth = newWidth;
+
+ // We need to convert to pixels if this is not a dialog or panel, but
+ // the parent resource specifies dialog units.
+ if (m_propertyWindow->GetParent() && m_propertyWindow->IsKindOf(CLASSINFO(wxControl)))
+ {
+ wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow->GetParent());
+ if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
+ {
+ wxSize sz = m_propertyWindow->GetParent()->ConvertDialogToPixels(wxSize(newWidth, height));
+ pixelWidth = sz.x;
+ }
+ }
+ else if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel)))
+ {
+ wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow);
+ if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
+ {
+ wxSize sz = m_propertyWindow->ConvertDialogToPixels(wxSize(newWidth, height));
+ pixelWidth = sz.x;
+ }
+ }
+
+ if (width != pixelWidth)
+ {
+ m_propertyWindow->SetSize(pixelWidth, height);
+ resource->SetSize(resource->GetX(), resource->GetY(), newWidth, resource->GetHeight());
+ }
+ return TRUE;
+ }
+ else if (name == "height")
+ {
+ wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow);
+ int width, height;
+ m_propertyWindow->GetSize(&width, &height);
+ int newHeight = (int)property->GetValue().IntegerValue();
+ int pixelHeight = newHeight;
+
+ // We need to convert to pixels if this is not a dialog or panel, but
+ // the parent resource specifies dialog units.
+ if (m_propertyWindow->GetParent() && m_propertyWindow->IsKindOf(CLASSINFO(wxControl)))
+ {
+ wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow->GetParent());
+ if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
+ {
+ wxSize sz = m_propertyWindow->GetParent()->ConvertDialogToPixels(wxSize(width, newHeight));
+ pixelHeight = sz.y;
+ }
+ }
+ else if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel)))
+ {
+ wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow);
+ if (resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
+ {
+ wxSize sz = m_propertyWindow->ConvertDialogToPixels(wxSize(width, newHeight));
+ pixelHeight = sz.y;
+ }
+ }
+
+ if (height != pixelHeight)
+ {
+ m_propertyWindow->SetSize(width, pixelHeight);
+ resource->SetSize(resource->GetX(), resource->GetY(), resource->GetWidth(), newHeight);
+ }
+ return TRUE;
+ }
+ else if (name == "id")
+ {
+ wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_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;
+ }
+ else if (name == "border")
+ {
+ long borderStyle = 0;
+ wxString val = property->GetValue().StringValue();
+
+ if (val == "wxSIMPLE_BORDER")
+ borderStyle = wxSIMPLE_BORDER;
+ else if (val == "wxRAISED_BORDER")
+ borderStyle = wxRAISED_BORDER;
+ else if (val == "wxSUNKEN_BORDER")
+ borderStyle = wxSUNKEN_BORDER;
+ else if (val == "wxDOUBLE_BORDER")
+ borderStyle = wxDOUBLE_BORDER;
+ else if (val == "wxSTATIC_BORDER")
+ borderStyle = wxSTATIC_BORDER;
+ else if (val == "wxNO_BORDER")
+ borderStyle = wxNO_BORDER;
+
+ SetWindowStyle(m_propertyWindow, wxSIMPLE_BORDER, FALSE);
+ SetWindowStyle(m_propertyWindow, wxRAISED_BORDER, FALSE);
+ SetWindowStyle(m_propertyWindow, wxSUNKEN_BORDER, FALSE);
+ SetWindowStyle(m_propertyWindow, wxDOUBLE_BORDER, FALSE);
+ SetWindowStyle(m_propertyWindow, wxSTATIC_BORDER, FALSE);
+ SetWindowStyle(m_propertyWindow, wxNO_BORDER, FALSE);
+
+ SetWindowStyle(m_propertyWindow, borderStyle, TRUE);
+
+ wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow);
+ resource->SetStyle(m_propertyWindow->GetWindowStyleFlag());
+ return TRUE;
+ }
+ else
+ return FALSE;