Further fixes to Dialog Editor; additions to .dsp files

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5390 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2000-01-14 17:55:49 +00:00
parent dfd6b52fdb
commit 8caa4ed10e
15 changed files with 205 additions and 81 deletions

View File

@@ -527,22 +527,48 @@ void wxResourceManager::AssociateResource(wxItemResource *resource, wxWindow *wi
m_resourceAssociations.Put((long)resource, win);
wxNode *node = resource->GetChildren().First();
while (node)
wxNode* node2 = win->GetChildren().First();
while (node && node2)
{
wxItemResource *child = (wxItemResource *)node->Data();
wxWindow* childWindow = (wxWindow*) node2->Data();
if (child->GetId() != childWindow->GetId())
{
wxString msg;
msg.Printf("AssociateResource: error when associating child window %ld with resource %ld", child->GetId(), childWindow->GetId());
wxMessageBox(msg, "Dialog Editor problem", wxOK);
}
else if (childWindow->GetName() != child->GetName())
{
wxString msg;
msg.Printf("AssociateResource: error when associating child window with resource %s", child->GetName() ? (const char*) child->GetName() : "(unnamed)");
wxMessageBox(msg, "Dialog Editor problem", wxOK);
}
else
{
AssociateResource(child, childWindow);
}
// New code to avoid the problem of duplicate ids and names. We simply
// traverse the child windows and child resources in parallel,
// checking for any mismatch.
#if 0
wxWindow *childWindow = (wxWindow *)m_resourceAssociations.Get((long)child);
if (!childWindow)
childWindow = win->FindWindow(child->GetName());
// childWindow = win->FindWindow(child->GetName());
childWindow = win->FindWindow(child->GetId());
if (childWindow)
AssociateResource(child, childWindow);
else
{
char buf[200];
sprintf(buf, "AssociateResource: cannot find child window %s", child->GetName() ? (const char*) child->GetName() : "(unnamed)");
wxMessageBox(buf, "Dialog Editor problem", wxOK);
wxString msg;
msg.Printf("AssociateResource: cannot find child window %s", child->GetName() ? (const char*) child->GetName() : "(unnamed)");
wxMessageBox(msg, "Dialog Editor problem", wxOK);
}
#endif
node = node->Next();
node2 = node2->Next();
}
}
@@ -1363,6 +1389,9 @@ void wxResourceManager::CopySize()
{
item->SetSize(-1, -1, firstW, firstH);
int fw = firstW;
int fh = firstH;
wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(item);
wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(item->GetParent());
@@ -1372,9 +1401,9 @@ void wxResourceManager::CopySize()
if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
{
wxSize sz = item->GetParent()->ConvertPixelsToDialog(wxSize(firstW, firstH));
firstW = sz.x; firstH = sz.y;
fw = sz.x; fh = sz.y;
}
resource->SetSize(resource->GetX(), resource->GetY(), firstW, firstH);
resource->SetSize(resource->GetX(), resource->GetY(), fw, fh);
}
}

View File

@@ -100,7 +100,8 @@ wxDialogEditorPropertyListFrame::~wxDialogEditorPropertyListFrame()
{
delete m_propSheet;
delete m_propInfo;
wxPropertyInfo::sm_propertyWindow = NULL;
if (wxPropertyInfo::sm_propertyWindow == this)
wxPropertyInfo::sm_propertyWindow = NULL;
}
/*
@@ -111,11 +112,31 @@ wxDialogEditorPropertyListFrame::~wxDialogEditorPropertyListFrame()
// might be.
bool wxPropertyInfo::Edit(wxWindow *WXUNUSED(parent), const wxString& title)
{
if (sm_propertyWindow)
{
if (sm_propertyWindow)
{
wxWindowPropertyInfo* thisProp = (wxWindowPropertyInfo*) this;
wxWindowPropertyInfo* oldProp = (wxWindowPropertyInfo*) (((wxDialogEditorPropertyListFrame *) sm_propertyWindow)->GetInfo());
if (oldProp->GetWindow() == thisProp->GetWindow())
{
sm_propertyWindow->Raise();
return TRUE;
}
}
else
{
int w, h, x, y;
sm_propertyWindow->GetSize(& w, & h);
sm_propertyWindow->GetPosition(& x, & y);
wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().width = w;
wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().height = h;
wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().x = x;
wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().y = y;
// Close the window, so we can create a new one for the different window
sm_propertyWindow->Destroy();
sm_propertyWindow = (wxDialogEditorPropertyListFrame *) NULL;
}
}
int width = wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().width;
int height = wxResourceManager::GetCurrentResourceManager()->GetPropertyWindowSize().height;
@@ -665,7 +686,9 @@ bool wxWindowPropertyInfo::InstantiateResource(wxItemResource *resource)
wxString str(m_propertyWindow->GetName());
resource->SetName(str);
#if 0
#if 0 // Why did we comment this out? Possibly because of rounding errors
// that will build up as the conversion is repeatedly done.
// so only do the conversion when a resize happens.
int x, y, w, h;
if (m_propertyWindow->IsKindOf(CLASSINFO(wxPanel)))
@@ -900,7 +923,37 @@ wxProperty *wxStaticTextPropertyInfo::GetProperty(wxString& name)
bool wxStaticTextPropertyInfo::SetProperty(wxString& name, wxProperty *property)
{
return wxItemPropertyInfo::SetProperty(name, property);
wxStaticText* itemWindow = (wxStaticText*) m_propertyWindow;
if (name == "label")
{
// Because setting a wxStaticText control's label may change the
// size, we must get the size and instantiate the resource immediately.
itemWindow->SetLabel(property->GetValue().StringValue());
int w, h;
wxItemResource *resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(itemWindow);
m_propertyWindow->GetSize(&w, &h);
// m_propertyWindow->GetPosition(&x, &y);
// We need to convert to dialog units if
// the parent resource specifies dialog units.
if (m_propertyWindow->GetParent())
{
wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_propertyWindow->GetParent());
if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
{
// wxPoint pt = m_propertyWindow->GetParent()->ConvertPixelsToDialog(wxPoint(x, y));
// x = pt.x; y = pt.y;
wxSize sz = m_propertyWindow->GetParent()->ConvertPixelsToDialog(wxSize(w, h));
w = sz.x; h = sz.y;
}
}
resource->SetSize(resource->GetX(), resource->GetY(), w, h);
return TRUE;
}
else
return wxItemPropertyInfo::SetProperty(name, property);
}
void wxStaticTextPropertyInfo::GetPropertyNames(wxStringList& names)

View File

@@ -29,6 +29,8 @@ public:
long style = wxDEFAULT_FRAME_STYLE, const wxString& name = "frame");
~wxDialogEditorPropertyListFrame();
wxPropertyInfo* GetInfo() const { return m_propInfo; }
private:
wxPropertySheet* m_propSheet;
wxPropertyValidatorRegistry m_registry;
@@ -99,6 +101,9 @@ class wxWindowPropertyInfo: public wxPropertyInfo
// Set the window style
void SetWindowStyle(wxWindow* win, long style, bool set);
wxWindow* GetWindow() const { return m_propertyWindow; }
wxItemResource* GetResource() const { return m_propertyResource; }
protected:
wxWindow* m_propertyWindow;
wxItemResource* m_propertyResource;