]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/dialoged/src/reseditr.cpp
Misc small changes
[wxWidgets.git] / utils / dialoged / src / reseditr.cpp
index fd82bb74aa89c4d6197d0fc82373eb88e727e6da..1e831519df4f4b08b76741f3f14b497802901bc5 100644 (file)
 #include <math.h>
 #include <string.h>
 
-#if wxUSE_IOSTREAMH
-#if defined(__WXMSW__) && !defined(__GNUWIN32__)
-#include <strstrea.h>
-#else
-#include <strstream.h>
-#endif
-#else
-#include <strstream>
-#endif
-
-#ifdef __WXMSW__
-#include <windows.h>
-#endif
-
 #ifdef __WXMSW__
 #include "wx/help.h"
 #endif
 #include "edtree.h"
 #include "edlist.h"
 
-static void ObjectMenuProc(wxMenu& menu, wxCommandEvent& event);
 wxResourceManager *wxResourceManager::sm_currentResourceManager = NULL;
 
-#ifdef __WXGTK__
+#if defined(__WXGTK__) || defined(__WXMOTIF__)
 #include "bitmaps/load.xpm"
 #include "bitmaps/save.xpm"
 #include "bitmaps/new.xpm"
@@ -86,6 +71,11 @@ wxResourceManager *wxResourceManager::sm_currentResourceManager = NULL;
 #include "bitmaps/toback.xpm"
 #include "bitmaps/help.xpm"
 #include "bitmaps/wxwin.xpm"
+
+#include "bitmaps/dialog.xpm"
+#include "bitmaps/folder1.xpm"
+#include "bitmaps/folder2.xpm"
+#include "bitmaps/buttonsm.xpm"
 #endif
 
 /*
@@ -147,13 +137,14 @@ wxResourceManager::~wxResourceManager()
 bool wxResourceManager::Initialize()
 {
   // Set up the resource filename for each platform.
+  // TODO: This shold be replaced by wxConfig usage.
 #ifdef __WXMSW__
   // dialoged.ini in the Windows directory
-  char buf[256];
-  GetWindowsDirectory(buf, 256);
-  strcat(buf, "\\dialoged.ini");
-  m_optionsResourceFilename = buf;
-#elif defined(__WXGTK__)
+  wxString windowsDir = wxGetOSDirectory();
+  windowsDir += "\\dialoged.ini" ;
+
+  m_optionsResourceFilename = windowsDir;
+#elif defined(__WXGTK__) || defined(__WXMOTIF__)
   wxGetHomeDir( &m_optionsResourceFilename );
   m_optionsResourceFilename += "/.dialogedrc";
 #else
@@ -167,7 +158,7 @@ bool wxResourceManager::Initialize()
   m_helpController->Initialize("dialoged");
 #endif
 
-  m_popupMenu = new wxMenu("", (wxFunction)ObjectMenuProc);
+  m_popupMenu = new wxMenu;
   m_popupMenu->Append(OBJECT_MENU_EDIT, "Edit properties");
   m_popupMenu->Append(OBJECT_MENU_DELETE, "Delete object");
 
@@ -176,7 +167,7 @@ bool wxResourceManager::Initialize()
 #ifdef __WXMSW__
     m_bitmapImage = new wxBitmap("WXWINBMP", wxBITMAP_TYPE_BMP_RESOURCE);
 #endif
-#ifdef __WXGTK__
+#if defined(__WXGTK__) || defined(__WXMOTIF__)
     m_bitmapImage = new wxBitmap( wxwin_xpm );
 #endif
   }
@@ -187,11 +178,16 @@ bool wxResourceManager::Initialize()
   wxIcon icon2("FOLDER1_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16);
   wxIcon icon3("FOLDER2_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16);
   wxIcon icon4("BUTTONSM_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16);
+#else
+  wxIcon icon1( dialog_xpm );    
+  wxIcon icon2( folder1_xpm );    
+  wxIcon icon3( folder2_xpm );    
+  wxIcon icon4( buttonsm_xpm );    
+#endif
   m_imageList.Add(icon1);
   m_imageList.Add(icon2);
   m_imageList.Add(icon3);
   m_imageList.Add(icon4);
-#endif
 
   m_symbolTable.AddStandardSymbols();
 
@@ -228,14 +224,14 @@ bool wxResourceManager::SaveOptions()
 {
   wxConfig config("DialogEd", "wxWindows");
 
-  config.Write("editorWindowX", m_resourceEditorWindowSize.x);
-  config.Write("editorWindowY", m_resourceEditorWindowSize.y);
-  config.Write("editorWindowWidth", m_resourceEditorWindowSize.width);
-  config.Write("editorWindowHeight", m_resourceEditorWindowSize.height);
-  config.Write("propertyWindowX", m_propertyWindowSize.x);
-  config.Write("propertyWindowY", m_propertyWindowSize.y);
-  config.Write("propertyWindowWidth", m_propertyWindowSize.width);
-  config.Write("propertyWindowHeight", m_propertyWindowSize.height);
+  config.Write("editorWindowX", (long) m_resourceEditorWindowSize.x);
+  config.Write("editorWindowY", (long) m_resourceEditorWindowSize.y);
+  config.Write("editorWindowWidth", (long) m_resourceEditorWindowSize.width);
+  config.Write("editorWindowHeight", (long) m_resourceEditorWindowSize.height);
+  config.Write("propertyWindowX", (long) m_propertyWindowSize.x);
+  config.Write("propertyWindowY", (long) m_propertyWindowSize.y);
+  config.Write("propertyWindowWidth", (long) m_propertyWindowSize.width);
+  config.Write("propertyWindowHeight", (long) m_propertyWindowSize.height);
   /*
   wxWriteResource("DialogEd", "editorWindowX", m_resourceEditorWindowSize.x, m_optionsResourceFilename.GetData());
   wxWriteResource("DialogEd", "editorWindowY", m_resourceEditorWindowSize.y, m_optionsResourceFilename.GetData());
@@ -312,8 +308,8 @@ bool wxResourceManager::ShowResourceEditor(bool show, wxWindow *WXUNUSED(parent)
     c->right.SameAs      (m_editorFrame, wxRight, 0);
     c->bottom.SameAs     (m_editorFrame, wxBottom, 0);
     c->width.Unconstrained();
-#ifdef __WXGTK__
-    c->height.Absolute(140);
+#if defined(__WXGTK__) || defined(__WXMOTIF__)
+    c->height.Absolute(120);
 #else
     c->height.Absolute(60);
 #endif
@@ -329,11 +325,8 @@ bool wxResourceManager::ShowResourceEditor(bool show, wxWindow *WXUNUSED(parent)
   }
   else
   {
-    wxFrame *fr = m_editorFrame;
-    if (m_editorFrame->OnClose())
+    if (m_editorFrame->Close())
     {
-      fr->Show(FALSE);
-      delete fr;
       m_editorFrame = NULL;
       m_editorPanel = NULL;
     }
@@ -384,7 +377,7 @@ bool wxResourceManager::Save(const wxString& filename)
 bool wxResourceManager::SaveAs()
 {
   wxString s(wxFileSelector("Save resource file", wxPathOnly(WXSTRINGCAST m_currentFilename), wxFileNameFromPath(WXSTRINGCAST m_currentFilename),
-    "wxr", "*.wxr", wxSAVE | wxOVERWRITE_PROMPT));
+    "wxr", "*.wxr", wxSAVE | wxOVERWRITE_PROMPT, wxTheApp->GetTopWindow()));
     
   if (s.IsNull() || s == "")
     return FALSE;
@@ -427,14 +420,14 @@ bool wxResourceManager::New(bool loadFromFile, const wxString& filename)
     wxString str = filename;
     if (str == wxString(""))
     {
-      wxString f(wxFileSelector("Open resource file", NULL, NULL, "wxr", "*.wxr", 0, NULL));
+      wxString f(wxFileSelector("Open resource file", NULL, NULL, "wxr", "*.wxr", 0, wxTheApp->GetTopWindow()));
       if (!f.IsNull() && f != "")
         str = f;
       else
         return FALSE;
     }
     
-    if (!m_resourceTable.ParseResourceFile(WXSTRINGCAST str))
+    if (!m_resourceTable.ParseResourceFile(str))
     {
       wxMessageBox("Could not read file.", "Resource file load error", wxOK | wxICON_EXCLAMATION);
       return FALSE;
@@ -493,6 +486,8 @@ bool wxResourceManager::New(bool loadFromFile, const wxString& filename)
 
 bool wxResourceManager::Clear(bool WXUNUSED(deleteWindows), bool force)
 {
+  wxPropertyInfo::CloseWindow();
+
   if (!force && Modified())
   {
     int ans = wxMessageBox("Save modified resource file?", "Dialog Editor", wxYES_NO | wxCANCEL);
@@ -534,22 +529,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();
   }
 }
 
@@ -560,18 +581,15 @@ bool wxResourceManager::DisassociateResource(wxItemResource *resource)
     return FALSE;
 
   // Disassociate children of window
-  if (win->GetChildren())
+  wxNode *node = win->GetChildren().First();
+  while (node)
   {
-    wxNode *node = win->GetChildren()->First();
-    while (node)
-    {
-      wxWindow *child = (wxWindow *)node->Data();
-      if (child->IsKindOf(CLASSINFO(wxControl)))
-       DisassociateResource(child);
-      node = node->Next();
-    }
+    wxWindow *child = (wxWindow *)node->Data();
+    if (child->IsKindOf(CLASSINFO(wxControl)))
+           DisassociateResource(child);
+    node = node->Next();
   }
-  
+
   RemoveSelection(win);
   m_resourceAssociations.Delete((long)resource);
   return TRUE;
@@ -599,7 +617,7 @@ bool wxResourceManager::SaveInfoAndDeleteHandler(wxWindow* win)
         win->PopEventHandler();
 
         // Now reset all child event handlers
-        wxNode *node = win->GetChildren()->First();
+        wxNode *node = win->GetChildren().First();
         while ( node )
         {
                wxWindow *child = (wxWindow *)node->Data();
@@ -653,7 +671,7 @@ wxItemResource *wxResourceManager::FindResourceForWindow(wxWindow *win)
     wxWindow *w = (wxWindow *)node->Data();
     if (w == win)
     {
-      return (wxItemResource *)node->key.integer;
+      return (wxItemResource *)node->GetKeyInteger();
     }
   }
   return NULL;
@@ -734,7 +752,11 @@ wxResourceEditorScrolledWindow *wxResourceManager::OnCreateEditorPanel(wxFrame *
 {
   wxResourceEditorScrolledWindow *panel = new wxResourceEditorScrolledWindow(parent, wxDefaultPosition, wxDefaultSize,
 //    wxSUNKEN_BORDER|wxCLIP_CHILDREN);
+#ifdef __WXMOTIF__
+    wxBORDER);
+#else
     wxSUNKEN_BORDER);
+#endif
 
   panel->SetScrollbars(10, 10, 100, 100);
 
@@ -759,7 +781,7 @@ wxToolBar *wxResourceManager::OnCreateToolBar(wxFrame *parent)
   wxBitmap ToolbarToFrontBitmap("TOFRONTTOOL");
   wxBitmap ToolbarHelpBitmap("HELPTOOL");
 #endif
-#ifdef __WXGTK__
+#if defined(__WXGTK__) || defined(__WXMOTIF__)
   wxBitmap ToolbarLoadBitmap( load_xpm );
   wxBitmap ToolbarSaveBitmap( save_xpm);
   wxBitmap ToolbarNewBitmap( new_xpm );
@@ -790,48 +812,48 @@ wxToolBar *wxResourceManager::OnCreateToolBar(wxFrame *parent)
 #endif
   int currentX = gap;
   toolbar->AddSeparator();
-  toolbar->AddTool(TOOLBAR_NEW, ToolbarNewBitmap, (wxBitmap *)NULL,
-                   FALSE, (float)currentX, -1, NULL, "New dialog");
+  toolbar->AddTool(TOOLBAR_NEW, ToolbarNewBitmap, wxNullBitmap,
+                   FALSE, currentX, -1, NULL, "New dialog");
   currentX += width + dx;
-  toolbar->AddTool(TOOLBAR_LOAD_FILE, ToolbarLoadBitmap, (wxBitmap *)NULL,
-                   FALSE, (float)currentX, -1, NULL, "Load");
+  toolbar->AddTool(TOOLBAR_LOAD_FILE, ToolbarLoadBitmap, wxNullBitmap,
+                   FALSE, currentX, -1, NULL, "Load");
   currentX += width + dx;
-  toolbar->AddTool(TOOLBAR_SAVE_FILE, ToolbarSaveBitmap, (wxBitmap *)NULL,
-                   FALSE, (float)currentX, -1, NULL, "Save");
+  toolbar->AddTool(TOOLBAR_SAVE_FILE, ToolbarSaveBitmap, wxNullBitmap,
+                   FALSE, currentX, -1, NULL, "Save");
   currentX += width + dx + gap;
   toolbar->AddSeparator();
-  toolbar->AddTool(TOOLBAR_FORMAT_HORIZ, ToolbarVertBitmap, (wxBitmap *)NULL,
-                   FALSE, (float)currentX, -1, NULL, "Horizontal align");
+  toolbar->AddTool(TOOLBAR_FORMAT_HORIZ, ToolbarVertBitmap, wxNullBitmap,
+                   FALSE, currentX, -1, NULL, "Horizontal align");
   currentX += width + dx;
-  toolbar->AddTool(TOOLBAR_FORMAT_VERT_TOP_ALIGN, ToolbarAlignTBitmap, (wxBitmap *)NULL,
-                   FALSE, (float)currentX, -1, NULL, "Top align");
+  toolbar->AddTool(TOOLBAR_FORMAT_VERT_TOP_ALIGN, ToolbarAlignTBitmap, wxNullBitmap,
+                   FALSE, currentX, -1, NULL, "Top align");
   currentX += width + dx;
-  toolbar->AddTool(TOOLBAR_FORMAT_VERT_BOT_ALIGN, ToolbarAlignBBitmap, (wxBitmap *)NULL,
-                   FALSE, (float)currentX, -1, NULL, "Bottom align");
+  toolbar->AddTool(TOOLBAR_FORMAT_VERT_BOT_ALIGN, ToolbarAlignBBitmap, wxNullBitmap,
+                   FALSE, currentX, -1, NULL, "Bottom align");
   currentX += width + dx;
-  toolbar->AddTool(TOOLBAR_FORMAT_VERT, ToolbarHorizBitmap, (wxBitmap *)NULL,
-                   FALSE, (float)currentX, -1, NULL, "Vertical align");
+  toolbar->AddTool(TOOLBAR_FORMAT_VERT, ToolbarHorizBitmap, wxNullBitmap,
+                   FALSE, currentX, -1, NULL, "Vertical align");
   currentX += width + dx;
-  toolbar->AddTool(TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN, ToolbarAlignLBitmap, (wxBitmap *)NULL,
-                   FALSE, (float)currentX, -1, NULL, "Left align");
+  toolbar->AddTool(TOOLBAR_FORMAT_HORIZ_LEFT_ALIGN, ToolbarAlignLBitmap, wxNullBitmap,
+                   FALSE, currentX, -1, NULL, "Left align");
   currentX += width + dx;
-  toolbar->AddTool(TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN, ToolbarAlignRBitmap, (wxBitmap *)NULL,
-                   FALSE, (float)currentX, -1, NULL, "Right align");
+  toolbar->AddTool(TOOLBAR_FORMAT_HORIZ_RIGHT_ALIGN, ToolbarAlignRBitmap, wxNullBitmap,
+                   FALSE, currentX, -1, NULL, "Right align");
   currentX += width + dx;
-  toolbar->AddTool(TOOLBAR_COPY_SIZE, ToolbarCopySizeBitmap, (wxBitmap *)NULL,
-                   FALSE, (float)currentX, -1, NULL, "Copy size");
+  toolbar->AddTool(TOOLBAR_COPY_SIZE, ToolbarCopySizeBitmap, wxNullBitmap,
+                   FALSE, currentX, -1, NULL, "Copy size");
   currentX += width + dx + gap;
   toolbar->AddSeparator();
-  toolbar->AddTool(TOOLBAR_TO_FRONT, ToolbarToFrontBitmap, (wxBitmap *)NULL,
-                   FALSE, (float)currentX, -1, NULL, "To front");
+  toolbar->AddTool(TOOLBAR_TO_FRONT, ToolbarToFrontBitmap, wxNullBitmap,
+                   FALSE, currentX, -1, NULL, "To front");
   currentX += width + dx;
-  toolbar->AddTool(TOOLBAR_TO_BACK, ToolbarToBackBitmap, (wxBitmap *)NULL,
-                   FALSE, (float)currentX, -1, NULL, "To back");
+  toolbar->AddTool(TOOLBAR_TO_BACK, ToolbarToBackBitmap, wxNullBitmap,
+                   FALSE, currentX, -1, NULL, "To back");
   currentX += width + dx + gap;
 
   toolbar->AddSeparator();
-  toolbar->AddTool(TOOLBAR_HELP, ToolbarHelpBitmap, (wxBitmap *)NULL,
-                   FALSE, (float)currentX, -1, NULL, "Help");
+  toolbar->AddTool(TOOLBAR_HELP, ToolbarHelpBitmap, wxNullBitmap,
+                   FALSE, currentX, -1, NULL, "Help");
   currentX += width + dx;
   
   toolbar->Realize();
@@ -876,11 +898,7 @@ void wxResourceManager::AddItemsRecursively(long parent, wxItemResource *resourc
   else
     imageId = 3;
   
-  long id = m_editorResourceTree->InsertItem(parent, theString
-#ifdef __WXMSW__
-     , imageId
-#endif
-   );
+  long id = m_editorResourceTree->AppendItem(parent, theString, imageId );
 
   m_editorResourceTree->SetItemData(id, new wxResourceTreeData(resource));
 
@@ -911,6 +929,8 @@ bool wxResourceManager::EditSelectedResource()
 
 bool wxResourceManager::Edit(wxItemResource *res)
 {
+  wxPropertyInfo::CloseWindow();
+
   ClearCurrentDialog();
 
   wxString resType(res->GetType());
@@ -950,6 +970,8 @@ bool wxResourceManager::Edit(wxItemResource *res)
 
 bool wxResourceManager::CreateNewPanel()
 {
+  wxPropertyInfo::CloseWindow();
+
   ClearCurrentDialog();
 
   char buf[256];
@@ -1020,7 +1042,7 @@ bool wxResourceManager::CreatePanelItem(wxItemResource *panelResource, wxPanel *
 
   if ((panelResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) != 0)
   {
-    wxPoint pt = panel->ConvertPixelsToDialog(pt);
+    wxPoint pt = panel->ConvertPixelsToDialog(wxPoint(x, y));
     res->SetSize(pt.x, pt.y, -1, -1);
   }
   else res->SetSize(x, y, -1, -1);
@@ -1037,7 +1059,7 @@ bool wxResourceManager::CreatePanelItem(wxItemResource *panelResource, wxPanel *
       MakeUniqueName("button", buf);
       res->SetName(buf);
       if (isBitmap)
-        newItem = new wxBitmapButton(panel, -1, m_bitmapImage, wxPoint(x, y), wxSize(-1, -1), 0, wxDefaultValidator, buf);
+        newItem = new wxBitmapButton(panel, -1, * m_bitmapImage, wxPoint(x, y), wxSize(-1, -1), wxBU_AUTODRAW, wxDefaultValidator, buf);
       else
         newItem = new wxButton(panel, -1, "Button", wxPoint(x, y), wxSize(-1, -1), 0, wxDefaultValidator, buf);
     }
@@ -1046,7 +1068,7 @@ bool wxResourceManager::CreatePanelItem(wxItemResource *panelResource, wxPanel *
       prefix = "ID_BITMAPBUTTON";
       MakeUniqueName("button", buf);
       res->SetName(buf);
-      newItem = new wxBitmapButton(panel, -1, m_bitmapImage, wxPoint(x, y), wxSize(-1, -1), 0, wxDefaultValidator, buf);
+      newItem = new wxBitmapButton(panel, -1, * m_bitmapImage, wxPoint(x, y), wxSize(-1, -1), wxBU_AUTODRAW, wxDefaultValidator, buf);
     }
   else if (itemType == "wxMessage" || itemType == "wxStaticText")
     {
@@ -1054,7 +1076,7 @@ bool wxResourceManager::CreatePanelItem(wxItemResource *panelResource, wxPanel *
       MakeUniqueName("statictext", buf);
       res->SetName(buf);
       if (isBitmap)
-        newItem = new wxStaticBitmap(panel, -1, m_bitmapImage, wxPoint(x, y), wxSize(0, 0), 0, buf);
+        newItem = new wxStaticBitmap(panel, -1, m_bitmapImage, wxPoint(x, y), wxSize(0, 0), 0, buf);
       else
         newItem = new wxStaticText(panel, -1, "Static", wxPoint(x, y), wxSize(-1, -1), 0, buf);
     }
@@ -1063,7 +1085,7 @@ bool wxResourceManager::CreatePanelItem(wxItemResource *panelResource, wxPanel *
       prefix = "ID_STATICBITMAP";
       MakeUniqueName("static", buf);
       res->SetName(buf);
-      newItem = new wxStaticBitmap(panel, -1, m_bitmapImage, wxPoint(x, y), wxSize(-1, -1), 0, buf);
+      newItem = new wxStaticBitmap(panel, -1, m_bitmapImage, wxPoint(x, y), wxSize(-1, -1), 0, buf);
     }
   else if (itemType == "wxCheckBox")
     {
@@ -1159,6 +1181,16 @@ bool wxResourceManager::CreatePanelItem(wxItemResource *panelResource, wxPanel *
   if (!newItem)
     return FALSE;
 
+  int actualW, actualH;
+  newItem->GetSize(&actualW, &actualH);
+  wxSize actualSize(actualW, actualH);
+
+  if ((panelResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) != 0)
+  {
+    actualSize = panel->ConvertPixelsToDialog(actualSize);
+  }
+  res->SetSize(res->GetX(), res->GetY(), actualSize.x, actualSize.y);
+
   wxString newIdName;
   int id = GenerateWindowId(prefix, newIdName);
   res->SetId(id);
@@ -1225,7 +1257,7 @@ wxWindow *wxResourceManager::FindParentOfSelection()
     wxWindow *win = FindWindowForResource(res);
     if (win)
     {
-      wxNode *node1 = win->GetChildren()->First();
+      wxNode *node1 = win->GetChildren().First();
       while (node1)
       {
         wxControl *item = (wxControl *)node1->Data();
@@ -1315,7 +1347,22 @@ void wxResourceManager::AlignItems(int flag)
           break;
       }
 
+      wxItemResource* resource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(item);
+      wxItemResource* parentResource = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(item->GetParent());
+
       item->SetSize(newX, newY, w, h);
+
+         // Also update the associated resource
+         // We need to convert to dialog units if this is not a dialog or panel, but
+         // the parent resource specifies dialog units.
+         if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
+      {
+        wxPoint pt = item->GetParent()->ConvertPixelsToDialog(wxPoint(newX, newY));
+        newX = pt.x; newY = pt.y;
+        wxSize sz = item->GetParent()->ConvertPixelsToDialog(wxSize(w, h));
+        w = sz.x; h = sz.y;
+      }
+      resource->SetSize(newX, newY, w, h);
     }
   }
   win->Refresh();
@@ -1345,7 +1392,26 @@ void wxResourceManager::CopySize()
   {
     wxControl *item = (wxControl *)node->Data();
     if (item->GetParent() == win)
+       {
       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());
+
+         // Also update the associated resource
+         // We need to convert to dialog units if this is not a dialog or panel, but
+         // the parent resource specifies dialog units.
+         if (parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS)
+      {
+        wxSize sz = item->GetParent()->ConvertPixelsToDialog(wxSize(firstW, firstH));
+        fw = sz.x; fh = sz.y;
+      }
+      resource->SetSize(resource->GetX(), resource->GetY(), fw, fh);
+
+       }
   }
   win->Refresh();
 }
@@ -1364,18 +1430,18 @@ void wxResourceManager::ToBackOrFront(bool toBack)
     wxItemResource *itemResource = FindResourceForWindow(item);
     if (item->GetParent() == win)
     {
-      win->GetChildren()->DeleteObject(item);
+      win->GetChildren().DeleteObject(item);
       if (winResource)
         winResource->GetChildren().DeleteObject(itemResource);
       if (toBack)
       {
-        win->GetChildren()->Insert(item);
+        win->GetChildren().Insert(item);
         if (winResource)
           winResource->GetChildren().Insert(itemResource);
       }
       else
       {
-        win->GetChildren()->Append(item);
+        win->GetChildren().Append(item);
         if (winResource)
           winResource->GetChildren().Append(itemResource);
       }
@@ -1396,6 +1462,25 @@ void wxResourceManager::RemoveSelection(wxWindow *win)
   m_selections.DeleteObject(win);
 }
 
+void wxResourceManager::DeselectItemIfNecessary(wxWindow *win)
+{
+    if (win->IsKindOf(CLASSINFO(wxControl)) && (win->GetEventHandler() != win))
+    {
+        // Deselect and refresh window in case we leave selection
+        // handles behind
+        wxControl *item = (wxControl *)win;
+        wxResourceEditorControlHandler *childHandler = (wxResourceEditorControlHandler *)item->GetEventHandler();
+        if (childHandler->IsSelected())
+        {
+            wxResourceManager::GetCurrentResourceManager()->RemoveSelection(item);
+            childHandler->SelectItem(FALSE);
+#ifndef __WXGTK__
+            item->GetParent()->Refresh();
+#endif
+        }
+    } 
+}
+
 // Need to search through resource table removing this from
 // any resource which has this as a parent.
 bool wxResourceManager::RemoveResourceFromParent(wxItemResource *res)
@@ -1455,21 +1540,7 @@ bool wxResourceManager::DeleteResource(wxItemResource *res)
 
 bool wxResourceManager::DeleteResource(wxWindow *win)
 {
-  if (win->IsKindOf(CLASSINFO(wxControl)))
-  {
-    // Deselect and refresh window in case we leave selection
-    // handles behind
-    wxControl *item = (wxControl *)win;
-    wxResourceEditorControlHandler *childHandler = (wxResourceEditorControlHandler *)item->GetEventHandler();
-    if (childHandler->IsSelected())
-    {
-      RemoveSelection(item);
-      childHandler->SelectItem(FALSE);
-#ifndef __WXGTK__
-      item->GetParent()->Refresh();
-#endif
-    }
-  }
+  DeselectItemIfNecessary(win);
   
   wxItemResource *res = FindResourceForWindow(win);
   
@@ -1570,7 +1641,7 @@ wxString wxResourceManager::FindBitmapFilenameForResource(wxItemResource *resour
     wxItemResource *child = (wxItemResource *)node->Data();
     return child->GetName();
     
-    node = node->Next();
+    //node = node->Next();
   }
   return wxEmptyString;
 }
@@ -1740,7 +1811,7 @@ bool wxResourceManager::RepairResourceIds()
  // Deletes 'win' and creates a new window from the resource that
  // was associated with it. E.g. if you can't change properties on the
  // fly, you'll need to delete the window and create it again.
-wxWindow *wxResourceManager::RecreateWindowFromResource(wxWindow *win, wxWindowPropertyInfo *info)
+wxWindow *wxResourceManager::RecreateWindowFromResource(wxWindow *win, wxWindowPropertyInfo *info, bool instantiateFirst)
 {
   wxItemResource *resource = FindResourceForWindow(win);
 
@@ -1753,13 +1824,15 @@ wxWindow *wxResourceManager::RecreateWindowFromResource(wxWindow *win, wxWindowP
     info = newInfo;
   }
 
-  info->InstantiateResource(resource);
+  // May not always want to copy values back from the resource
+  if (instantiateFirst)
+    info->InstantiateResource(resource);
 
   wxWindow *newWin = NULL;
   wxWindow *parent = win->GetParent();
   wxItemResource* parentResource = NULL;
   if (parent)
-    FindResourceForWindow(parent);
+    parentResource = FindResourceForWindow(parent);
   
   if (win->IsKindOf(CLASSINFO(wxPanel)))
   {
@@ -1928,30 +2001,30 @@ wxWindowPropertyInfo *wxResourceManager::CreatePropertyInfoForWindow(wxWindow *w
         {
           info = new wxRadioButtonPropertyInfo(win);
         }
-  else if (win->IsKindOf(CLASSINFO(wxChoice)))
-        {
-          info = new wxChoicePropertyInfo(win);
-        }
   else if (win->IsKindOf(CLASSINFO(wxComboBox)))
         {
           info = new wxComboBoxPropertyInfo(win);
         }
-  else if (win->IsKindOf(CLASSINFO(wxButton)))
+  else if (win->IsKindOf(CLASSINFO(wxChoice)))
         {
-          info = new wxButtonPropertyInfo(win);
+          info = new wxChoicePropertyInfo(win);
         }
   else if (win->IsKindOf(CLASSINFO(wxBitmapButton)))
         {
           info = new wxBitmapButtonPropertyInfo(win);
         }
-  else if (win->IsKindOf(CLASSINFO(wxStaticText)))
+  else if (win->IsKindOf(CLASSINFO(wxButton)))
         {
-          info = new wxStaticTextPropertyInfo(win);
+          info = new wxButtonPropertyInfo(win);
         }
   else if (win->IsKindOf(CLASSINFO(wxStaticBitmap)))
         {
           info = new wxStaticBitmapPropertyInfo(win);
         }
+  else if (win->IsKindOf(CLASSINFO(wxStaticText)))
+        {
+          info = new wxStaticTextPropertyInfo(win);
+        }
   else if (win->IsKindOf(CLASSINFO(wxTextCtrl)))
         {
           info = new wxTextPropertyInfo(win);
@@ -2028,6 +2101,7 @@ BEGIN_EVENT_TABLE(wxResourceEditorFrame, wxFrame)
     EVT_MENU(RESED_DELETE, wxResourceEditorFrame::OnDeleteSelection)
     EVT_MENU(RESED_RECREATE, wxResourceEditorFrame::OnRecreateSelection)
     EVT_MENU(RESED_TEST, wxResourceEditorFrame::OnTest)
+    EVT_CLOSE(wxResourceEditorFrame::OnCloseWindow)
 END_EVENT_TABLE()
 
 wxResourceEditorFrame::wxResourceEditorFrame(wxResourceManager *resMan, wxFrame *parent, const wxString& title,
@@ -2073,14 +2147,14 @@ void wxResourceEditorFrame::OnSaveAs(wxCommandEvent& WXUNUSED(event))
 
 void wxResourceEditorFrame::OnExit(wxCommandEvent& WXUNUSED(event))
 {
-         manager->Clear(TRUE, FALSE) ;
-      this->Close();
+      manager->Clear(TRUE, FALSE) ;
+      this->Destroy();
 }
 
 void wxResourceEditorFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
 {
       char buf[300];
-      sprintf(buf, "wxWindows Dialog Editor %.1f\nAuthor: Julian Smart J.Smart@ed.ac.uk\nJulian Smart (c) 1996", wxDIALOG_EDITOR_VERSION);
+      sprintf(buf, "wxWindows Dialog Editor %.1f\nAuthor: Julian Smart <julian.smart@ukonline.co.uk>\nJulian Smart (c) 1996-1999", wxDIALOG_EDITOR_VERSION);
       wxMessageBox(buf, "About Dialog Editor", wxOK|wxCENTRE);
 }
 
@@ -2109,15 +2183,19 @@ void wxResourceEditorFrame::OnRecreateSelection(wxCommandEvent& WXUNUSED(event))
       manager->RecreateSelection();
 }
 
-bool wxResourceEditorFrame::OnClose()
+void wxResourceEditorFrame::OnCloseWindow(wxCloseEvent& event)
 {
+  wxPropertyInfo::CloseWindow();
   if (manager->Modified())
   {
-  if (!manager->Clear(TRUE, FALSE))
-     return FALSE;
+     if (!manager->Clear(TRUE, FALSE))
+     {
+       event.Veto();
+       return;
+    }
   }
     
-  if (!Iconized())
+  if (!IsIconized())
   {
     int w, h;
     GetSize(&w, &h);
@@ -2133,7 +2211,7 @@ bool wxResourceEditorFrame::OnClose()
   manager->SetEditorFrame(NULL);
   manager->SetEditorToolBar(NULL);
 
-  return TRUE;
+  this->Destroy();
 }
 
 /*
@@ -2141,7 +2219,6 @@ bool wxResourceEditorFrame::OnClose()
  */
 
 BEGIN_EVENT_TABLE(wxResourceEditorScrolledWindow, wxScrolledWindow)
-    EVT_SCROLL(wxResourceEditorScrolledWindow::OnScroll)
     EVT_PAINT(wxResourceEditorScrolledWindow::OnPaint)
 END_EVENT_TABLE()
 
@@ -2152,21 +2229,12 @@ wxResourceEditorScrolledWindow::wxResourceEditorScrolledWindow(wxWindow *parent,
     m_marginX = 10;
     m_marginY = 40;
     m_childWindow = NULL;
-}
 
-wxResourceEditorScrolledWindow::~wxResourceEditorScrolledWindow()
-{
+    SetBackgroundColour(* wxWHITE);
 }
 
-void wxResourceEditorScrolledWindow::OnScroll(wxScrollEvent& event)
+wxResourceEditorScrolledWindow::~wxResourceEditorScrolledWindow()
 {
-    wxScrolledWindow::OnScroll(event);
-
-    int x, y;
-    ViewStart(& x, & y);
-
-    if (m_childWindow)
-        m_childWindow->Move(m_marginX + (- x * 10), m_marginY + (- y * 10));
 }
 
 void wxResourceEditorScrolledWindow::OnPaint(wxPaintEvent& WXUNUSED(event))
@@ -2201,9 +2269,9 @@ void wxResourceEditorScrolledWindow::DrawTitle(wxDC& dc)
 }
 
 // Popup menu callback
-void ObjectMenuProc(wxMenumenu, wxCommandEvent& event)
+void ObjectMenuProc(wxMenu *menu, wxCommandEvent& event)
 {
-  wxWindow *data = (wxWindow *)menu.GetClientData();
+  wxWindow *data = (wxWindow *)menu->GetClientData();
   if (!data)
     return;
 
@@ -2216,6 +2284,8 @@ void ObjectMenuProc(wxMenu& menu, wxCommandEvent& event)
     }
     case OBJECT_MENU_DELETE:
     {
+      wxResourceManager::GetCurrentResourceManager()->DeselectItemIfNecessary(data);
+
       wxResourceManager::GetCurrentResourceManager()->SaveInfoAndDeleteHandler(data);
       wxResourceManager::GetCurrentResourceManager()->DeleteResource(data);
       wxResourceManager::GetCurrentResourceManager()->DeleteWindow(data);
@@ -2231,19 +2301,10 @@ void ObjectMenuProc(wxMenu& menu, wxCommandEvent& event)
  *
  */
 
-#ifdef __WXGTK__   // I don't dare to delete it...
 BEGIN_EVENT_TABLE(EditorToolBar, wxToolBar)
+//     EVT_PAINT(EditorToolBar::OnPaint)
 END_EVENT_TABLE()
 
-#else
-
-BEGIN_EVENT_TABLE(EditorToolBar, wxToolBar)
-       EVT_PAINT(EditorToolBar::OnPaint)
-END_EVENT_TABLE()
-
-#endif
-
 EditorToolBar::EditorToolBar(wxFrame *frame, const wxPoint& pos, const wxSize& size,
             long style):
   wxToolBar(frame, -1, pos, size, style)