]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/dialoged/src/reseditr.cpp
SetTitle() works even if menu was created without title initially (and setting
[wxWidgets.git] / utils / dialoged / src / reseditr.cpp
index 1aa9fea3eaa8586221813a7aa71e7a197f000404..507ced9872bf1409f7420b7bc94a1f50e2adc567 100644 (file)
 #include "wx/gauge.h"
 #include "wx/slider.h"
 #include "wx/textctrl.h"
+#include "wx/menu.h"
+#include "wx/toolbar.h"
 #endif
 
 #include "wx/scrolbar.h"
+#include "wx/config.h"
 
 #include <ctype.h>
 #include <stdlib.h>
 #include <math.h>
 #include <string.h>
 
-#if defined(__WINDOWS__) && !defined(__GNUWIN32__)
+#if defined(__WXMSW__) && !defined(__GNUWIN32__)
 #include <strstrea.h>
 #else
 #include <strstream.h>
 #endif
 
-#ifdef __WINDOWS__
+#ifdef __WXMSW__
 #include <windows.h>
 #endif
 
+#ifdef __WXMSW__
 #include "wx/help.h"
+#endif
 
 #include "reseditr.h"
 #include "winprop.h"
-#include "editrpal.h"
 #include "dlghndlr.h"
+#include "edtree.h"
+#include "edlist.h"
 
 static void ObjectMenuProc(wxMenu& menu, wxCommandEvent& event);
-void wxResourceEditWindow(wxWindow *win);
-wxWindowPropertyInfo *wxCreatePropertyInfoForWindow(wxWindow *win);
-wxResourceManager *wxResourceManager::currentResourceManager = NULL;
-
-// Bitmaps for toolbar
-wxBitmap *ToolbarLoadBitmap = NULL;
-wxBitmap *ToolbarSaveBitmap = NULL;
-wxBitmap *ToolbarNewBitmap = NULL;
-wxBitmap *ToolbarVertBitmap = NULL;
-wxBitmap *ToolbarAlignTBitmap = NULL;
-wxBitmap *ToolbarAlignBBitmap = NULL;
-wxBitmap *ToolbarHorizBitmap = NULL;
-wxBitmap *ToolbarAlignLBitmap = NULL;
-wxBitmap *ToolbarAlignRBitmap = NULL;
-wxBitmap *ToolbarCopySizeBitmap = NULL;
-wxBitmap *ToolbarToFrontBitmap = NULL;
-wxBitmap *ToolbarToBackBitmap = NULL;
-wxBitmap *ToolbarHelpBitmap = NULL;
-
-wxBitmap *wxWinBitmap = NULL;
-
-#ifdef __X__
-#include "bitmaps/load.xbm"
-#include "bitmaps/save.xbm"
-#include "bitmaps/new.xbm"
-#include "bitmaps/vert.xbm"
-#include "bitmaps/alignt.xbm"
-#include "bitmaps/alignb.xbm"
-#include "bitmaps/horiz.xbm"
-#include "bitmaps/alignl.xbm"
-#include "bitmaps/alignr.xbm"
-#include "bitmaps/copysize.xbm"
-#include "bitmaps/tofront.xbm"
-#include "bitmaps/toback.xbm"
-#include "bitmaps/help.xbm"
-#include "bitmaps/wxwin.xbm"
+wxResourceManager *wxResourceManager::sm_currentResourceManager = NULL;
+
+#ifdef __WXGTK__
+#include "bitmaps/load.xpm"
+#include "bitmaps/save.xpm"
+#include "bitmaps/new.xpm"
+#include "bitmaps/vert.xpm"
+#include "bitmaps/alignt.xpm"
+#include "bitmaps/alignb.xpm"
+#include "bitmaps/horiz.xpm"
+#include "bitmaps/alignl.xpm"
+#include "bitmaps/alignr.xpm"
+#include "bitmaps/copysize.xpm"
+#include "bitmaps/tofront.xpm"
+#include "bitmaps/toback.xpm"
+#include "bitmaps/help.xpm"
+#include "bitmaps/wxwin.xpm"
 #endif
 
 /*
  * Resource manager
  */
 
+wxResourceManager::wxResourceManager():
+  m_imageList(16, 16, TRUE)
+{
+  sm_currentResourceManager = this;
+  m_editorFrame = NULL;
+  m_editorPanel = NULL;
+  m_popupMenu = NULL;
+  m_editorResourceTree = NULL;
+  m_editorControlList = NULL;
+  m_nameCounter = 1;
+  m_symbolIdCounter = 99;
+  m_modified = FALSE;
+  m_currentFilename = "";
+  m_symbolFilename = "";
+  m_editorToolBar = NULL;
 
-wxResourceManager::wxResourceManager(void)
-{
-  currentResourceManager = this;
-  editorFrame = NULL;
-  editorPanel = NULL;
-  popupMenu = NULL;
-  editorResourceList = NULL;
-  editorPalette = NULL;
-  nameCounter = 1;
-  modified = FALSE;
-  currentFilename = "";
-  editMode = TRUE;
-  editorToolBar = NULL;
-  
   // Default window positions
-  resourceEditorWindowSize.width = 470;
-  resourceEditorWindowSize.height = 300;
+  m_resourceEditorWindowSize.width = 500;
+  m_resourceEditorWindowSize.height = 450;
 
-  resourceEditorWindowSize.x = 0;
-  resourceEditorWindowSize.y = 0;
-  
-  propertyWindowSize.width = 300;
-  propertyWindowSize.height = 300;
+  m_resourceEditorWindowSize.x = 0;
+  m_resourceEditorWindowSize.y = 0;
 
-  helpInstance = NULL;
+  m_propertyWindowSize.width = 300;
+  m_propertyWindowSize.height = 300;
+
+#ifdef __WXMSW__
+  m_helpController = NULL;
+#endif
+
+  m_bitmapImage = NULL;
+  m_rootDialogItem = 0;
 }
 
-wxResourceManager::~wxResourceManager(void)
+wxResourceManager::~wxResourceManager()
 {
-  currentResourceManager = NULL;
+  sm_currentResourceManager = NULL;
   SaveOptions();
 
-  helpInstance->Quit();
-  delete helpInstance;
-  helpInstance = NULL;
+#ifdef __WXMSW__
+  if (m_helpController)
+  {
+    m_helpController->Quit();
+    delete m_helpController;
+    m_helpController = NULL;
+  }
+#endif  
+  
+  delete m_bitmapImage;
+  delete m_popupMenu;
 }
 
-bool wxResourceManager::Initialize(void)
+bool wxResourceManager::Initialize()
 {
   // Set up the resource filename for each platform.
-#ifdef __WINDOWS__
+#ifdef __WXMSW__
   // dialoged.ini in the Windows directory
   char buf[256];
   GetWindowsDirectory(buf, 256);
   strcat(buf, "\\dialoged.ini");
-  optionsResourceFilename = buf;
-#elif defined(__X__)
-  char buf[500];
-  (void)wxGetHomeDir(buf);
-  strcat(buf, "/.hardyrc");
-  optionsResourceFilename = buf;
+  m_optionsResourceFilename = buf;
+#elif defined(__WXGTK__)
+  wxGetHomeDir( &m_optionsResourceFilename );
+  m_optionsResourceFilename += "/.dialogedrc";
 #else
 #error "Unsupported platform."
 #endif
 
   LoadOptions();
 
-  helpInstance = new wxHelpController;
-  helpInstance->Initialize("dialoged");
+#ifdef __WXMSW__
+  m_helpController = new wxHelpController;
+  m_helpController->Initialize("dialoged");
+#endif
 
-  InitializeTools();
-  popupMenu = new wxMenu("", (wxFunction)ObjectMenuProc);
-  popupMenu->Append(OBJECT_MENU_EDIT, "Edit properties");
-  popupMenu->Append(OBJECT_MENU_DELETE, "Delete object");
-  
-  if (!wxWinBitmap)
+  m_popupMenu = new wxMenu("", (wxFunction)ObjectMenuProc);
+  m_popupMenu->Append(OBJECT_MENU_EDIT, "Edit properties");
+  m_popupMenu->Append(OBJECT_MENU_DELETE, "Delete object");
+
+  if (!m_bitmapImage)
   {
-#ifdef __WINDOWS__
-    wxWinBitmap = new wxBitmap("WXWINBMP", wxBITMAP_TYPE_BMP_RESOURCE);
+#ifdef __WXMSW__
+    m_bitmapImage = new wxBitmap("WXWINBMP", wxBITMAP_TYPE_BMP_RESOURCE);
 #endif
-#ifdef __X__
-    wxWinBitmap = new wxBitmap(wxwin_bits, wxwin_width, wxwin_height);
+#ifdef __WXGTK__
+    m_bitmapImage = new wxBitmap( wxwin_xpm );
 #endif
   }
+
+  // Initialize the image list icons
+#ifdef __WXMSW__
+  wxIcon icon1("DIALOG_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16);
+  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);
+  m_imageList.Add(icon1);
+  m_imageList.Add(icon2);
+  m_imageList.Add(icon3);
+  m_imageList.Add(icon4);
+#endif
+
+  m_symbolTable.AddStandardSymbols();
+
   return TRUE;
 }
 
-bool wxResourceManager::LoadOptions(void)
-{
-  wxGetResource("DialogEd", "editorWindowX", &resourceEditorWindowSize.x, optionsResourceFilename.GetData());
-  wxGetResource("DialogEd", "editorWindowY", &resourceEditorWindowSize.y, optionsResourceFilename.GetData());
-  wxGetResource("DialogEd", "editorWindowWidth", &resourceEditorWindowSize.width, optionsResourceFilename.GetData());
-  wxGetResource("DialogEd", "editorWindowHeight", &resourceEditorWindowSize.height, optionsResourceFilename.GetData());
-  wxGetResource("DialogEd", "propertyWindowX", &propertyWindowSize.x, optionsResourceFilename.GetData());
-  wxGetResource("DialogEd", "propertyWindowY", &propertyWindowSize.y, optionsResourceFilename.GetData());
-  wxGetResource("DialogEd", "propertyWindowWidth", &propertyWindowSize.width, optionsResourceFilename.GetData());
-  wxGetResource("DialogEd", "propertyWindowHeight", &propertyWindowSize.height, optionsResourceFilename.GetData());
+bool wxResourceManager::LoadOptions()
+{
+  wxConfig config("DialogEd", "wxWindows");
+
+  config.Read("editorWindowX", &m_resourceEditorWindowSize.x);
+  config.Read("editorWindowY", &m_resourceEditorWindowSize.y);
+  config.Read("editorWindowWidth", &m_resourceEditorWindowSize.width);
+  config.Read("editorWindowHeight", &m_resourceEditorWindowSize.height);
+  config.Read("propertyWindowX", &m_propertyWindowSize.x);
+  config.Read("propertyWindowY", &m_propertyWindowSize.y);
+  config.Read("propertyWindowWidth", &m_propertyWindowSize.width);
+  config.Read("propertyWindowHeight", &m_propertyWindowSize.height);
+
+  /*
+  wxGetResource("DialogEd", "editorWindowX", &m_resourceEditorWindowSize.x, m_optionsResourceFilename.GetData());
+  wxGetResource("DialogEd", "editorWindowY", &m_resourceEditorWindowSize.y, m_optionsResourceFilename.GetData());
+  wxGetResource("DialogEd", "editorWindowWidth", &m_resourceEditorWindowSize.width, m_optionsResourceFilename.GetData());
+  wxGetResource("DialogEd", "editorWindowHeight", &m_resourceEditorWindowSize.height, m_optionsResourceFilename.GetData());
+  wxGetResource("DialogEd", "propertyWindowX", &m_propertyWindowSize.x, m_optionsResourceFilename.GetData());
+  wxGetResource("DialogEd", "propertyWindowY", &m_propertyWindowSize.y, m_optionsResourceFilename.GetData());
+  wxGetResource("DialogEd", "propertyWindowWidth", &m_propertyWindowSize.width, m_optionsResourceFilename.GetData());
+  wxGetResource("DialogEd", "propertyWindowHeight", &m_propertyWindowSize.height, m_optionsResourceFilename.GetData());
+  */
   return TRUE;
 }
 
-bool wxResourceManager::SaveOptions(void)
+bool wxResourceManager::SaveOptions()
 {
-  wxWriteResource("DialogEd", "editorWindowX", resourceEditorWindowSize.x, optionsResourceFilename.GetData());
-  wxWriteResource("DialogEd", "editorWindowY", resourceEditorWindowSize.y, optionsResourceFilename.GetData());
-  wxWriteResource("DialogEd", "editorWindowWidth", resourceEditorWindowSize.width, optionsResourceFilename.GetData());
-  wxWriteResource("DialogEd", "editorWindowHeight", resourceEditorWindowSize.height, optionsResourceFilename.GetData());
+  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);
+  /*
+  wxWriteResource("DialogEd", "editorWindowX", m_resourceEditorWindowSize.x, m_optionsResourceFilename.GetData());
+  wxWriteResource("DialogEd", "editorWindowY", m_resourceEditorWindowSize.y, m_optionsResourceFilename.GetData());
+  wxWriteResource("DialogEd", "editorWindowWidth", m_resourceEditorWindowSize.width, m_optionsResourceFilename.GetData());
+  wxWriteResource("DialogEd", "editorWindowHeight", m_resourceEditorWindowSize.height, m_optionsResourceFilename.GetData());
+
+  wxWriteResource("DialogEd", "propertyWindowX", m_propertyWindowSize.x, m_optionsResourceFilename.GetData());
+  wxWriteResource("DialogEd", "propertyWindowY", m_propertyWindowSize.y, m_optionsResourceFilename.GetData());
+  wxWriteResource("DialogEd", "propertyWindowWidth", m_propertyWindowSize.width, m_optionsResourceFilename.GetData());
+  wxWriteResource("DialogEd", "propertyWindowHeight", m_propertyWindowSize.height, m_optionsResourceFilename.GetData());
+  */
 
-  wxWriteResource("DialogEd", "propertyWindowX", propertyWindowSize.x, optionsResourceFilename.GetData());
-  wxWriteResource("DialogEd", "propertyWindowY", propertyWindowSize.y, optionsResourceFilename.GetData());
-  wxWriteResource("DialogEd", "propertyWindowWidth", propertyWindowSize.width, optionsResourceFilename.GetData());
-  wxWriteResource("DialogEd", "propertyWindowHeight", propertyWindowSize.height, optionsResourceFilename.GetData());
-  
   return TRUE;
 }
 
 // Show or hide the resource editor frame, which displays a list
 // of resources with ability to edit them.
-bool wxResourceManager::ShowResourceEditor(bool show, wxWindow *parent, const char *title)
+bool wxResourceManager::ShowResourceEditor(bool show, wxWindow *WXUNUSED(parent), const char *title)
 {
   if (show)
   {
-    if (editorFrame)
+    if (m_editorFrame)
     {
-      editorFrame->Iconize(FALSE);
-      editorFrame->Show(TRUE);
+      m_editorFrame->Iconize(FALSE);
+      m_editorFrame->Show(TRUE);
       return TRUE;
     }
-    editorFrame = OnCreateEditorFrame(title);
+    m_editorFrame = OnCreateEditorFrame(title);
     SetFrameTitle("");
-    wxMenuBar *menuBar = OnCreateEditorMenuBar(editorFrame);
-    editorFrame->SetMenuBar(menuBar);
-    editorPanel = OnCreateEditorPanel(editorFrame);
-    editorToolBar = (EditorToolBar *)OnCreateToolBar(editorFrame);
-    editorPalette = OnCreatePalette(editorFrame);
+    wxMenuBar *menuBar = OnCreateEditorMenuBar(m_editorFrame);
+    m_editorFrame->SetMenuBar(menuBar);
+
+    m_editorToolBar = (EditorToolBar *)OnCreateToolBar(m_editorFrame);
+    m_editorControlList = new wxResourceEditorControlList(m_editorFrame, IDC_LISTCTRL, wxPoint(0, 0), wxSize(-1, -1));
+    m_editorResourceTree = new wxResourceEditorProjectTree(m_editorFrame, IDC_TREECTRL, wxPoint(0, 0), wxSize(-1, -1),
+      wxTR_HAS_BUTTONS);
+    m_editorPanel = OnCreateEditorPanel(m_editorFrame);
+
+    m_editorResourceTree->SetImageList(& m_imageList);
 
     // Constraints for toolbar
     wxLayoutConstraints *c = new wxLayoutConstraints;
-    c->left.SameAs       (editorFrame, wxLeft, 0);
-    c->top.SameAs        (editorFrame, wxTop, 0);
-    c->right.SameAs      (editorFrame, wxRight, 0);
-    c->bottom.Unconstrained();    
+    c->left.SameAs       (m_editorFrame, wxLeft, 0);
+    c->top.SameAs        (m_editorFrame, wxTop, 0);
+    c->right.SameAs      (m_editorFrame, wxRight, 0);
+    c->bottom.Unconstrained();
     c->width.Unconstrained();
     c->height.Absolute(28);
-    editorToolBar->SetConstraints(c);
+    m_editorToolBar->SetConstraints(c);
 
-    // Constraints for palette
+    // Constraints for listbox
     c = new wxLayoutConstraints;
-    c->left.SameAs       (editorFrame, wxLeft, 0);
-    c->top.SameAs        (editorToolBar, wxBottom, 0);
-    c->right.SameAs      (editorFrame, wxRight, 0);
-    c->bottom.Unconstrained();    
+    c->left.SameAs       (m_editorFrame, wxLeft, 0);
+    c->top.SameAs        (m_editorToolBar, wxBottom, 0);
+    c->right.Absolute    (150);
+    c->bottom.SameAs     (m_editorControlList, wxTop, 0);
     c->width.Unconstrained();
-    c->height.Absolute(34);
-    editorPalette->SetConstraints(c);
+    c->height.Unconstrained();
+    m_editorResourceTree->SetConstraints(c);
 
     // Constraints for panel
     c = new wxLayoutConstraints;
-    c->left.SameAs       (editorFrame, wxLeft, 0);
-    c->top.SameAs        (editorPalette, wxBottom, 0);
-    c->right.SameAs      (editorFrame, wxRight, 0);
-    c->bottom.SameAs     (editorFrame, wxBottom, 0);    
+    c->left.SameAs       (m_editorResourceTree, wxRight, 0);
+    c->top.SameAs        (m_editorToolBar, wxBottom, 0);
+    c->right.SameAs      (m_editorFrame, wxRight, 0);
+    c->bottom.SameAs     (m_editorControlList, wxTop, 0);
     c->width.Unconstrained();
     c->height.Unconstrained();
-    editorPanel->SetConstraints(c);
+    m_editorPanel->SetConstraints(c);
 
-    editorFrame->SetAutoLayout(TRUE);
+    // Constraints for control list (bottom window)
+    c = new wxLayoutConstraints;
+    c->left.SameAs       (m_editorFrame, wxLeft, 0);
+    c->right.SameAs      (m_editorFrame, wxRight, 0);
+    c->bottom.SameAs     (m_editorFrame, wxBottom, 0);
+    c->width.Unconstrained();
+#ifdef __WXGTK__
+    c->height.Absolute(140);
+#else
+    c->height.Absolute(60);
+#endif
+
+    m_editorControlList->SetConstraints(c);
+
+    m_editorFrame->SetAutoLayout(TRUE);
 
     UpdateResourceList();
-    editorFrame->Show(TRUE);
+
+    m_editorFrame->Show(TRUE);
     return TRUE;
   }
   else
   {
-    wxFrame *fr = editorFrame;
-    if (editorFrame->OnClose())
+    wxFrame *fr = m_editorFrame;
+    if (m_editorFrame->OnClose())
     {
       fr->Show(FALSE);
       delete fr;
-      editorFrame = NULL;
-      editorPanel = NULL;
+      m_editorFrame = NULL;
+      m_editorPanel = NULL;
     }
   }
   return TRUE;
@@ -279,36 +339,37 @@ bool wxResourceManager::ShowResourceEditor(bool show, wxWindow *parent, const ch
 
 void wxResourceManager::SetFrameTitle(const wxString& filename)
 {
-  if (editorFrame)
+  if (m_editorFrame)
   {
     if (filename == wxString(""))
-      editorFrame->SetTitle("wxWindows Dialog Editor - untitled");
+      m_editorFrame->SetTitle("wxWindows Dialog Editor - untitled");
     else
     {
       wxString str("wxWindows Dialog Editor - ");
       wxString str2(wxFileNameFromPath(WXSTRINGCAST filename));
       str += str2;
-      editorFrame->SetTitle(str);
+      m_editorFrame->SetTitle(str);
     }
   }
 }
 
-bool wxResourceManager::Save(void)
+bool wxResourceManager::Save()
 {
-  if (currentFilename == wxString(""))
+  if (m_currentFilename == wxString(""))
     return SaveAs();
   else
-    return Save(currentFilename);
+    return Save(m_currentFilename);
 }
 
 bool wxResourceManager::Save(const wxString& filename)
 {
   // Ensure all visible windows are saved to their resources
-  currentFilename = filename;
-  SetFrameTitle(currentFilename);
+  m_currentFilename = filename;
+  SetFrameTitle(m_currentFilename);
   InstantiateAllResourcesFromWindows();
-  if (resourceTable.Save(filename))
+  if (m_resourceTable.Save(filename))
   {
+    m_symbolTable.WriteIncludeFile(m_symbolFilename);
     Modify(FALSE);
     return TRUE;
   }
@@ -316,20 +377,29 @@ bool wxResourceManager::Save(const wxString& filename)
     return FALSE;
 }
 
-bool wxResourceManager::SaveAs(void)
+bool wxResourceManager::SaveAs()
 {
-  wxString s(wxFileSelector("Save resource file", wxPathOnly(WXSTRINGCAST currentFilename), wxFileNameFromPath(WXSTRINGCAST currentFilename),
+  wxString s(wxFileSelector("Save resource file", wxPathOnly(WXSTRINGCAST m_currentFilename), wxFileNameFromPath(WXSTRINGCAST m_currentFilename),
     "wxr", "*.wxr", wxSAVE | wxOVERWRITE_PROMPT));
     
   if (s.IsNull() || s == "")
     return FALSE;
     
-  currentFilename = s;
-  Save(currentFilename);
+  m_currentFilename = s;
+  wxStripExtension(m_currentFilename);
+  m_currentFilename += ".wxr";
+
+  // Construct include filename from this file
+  m_symbolFilename = m_currentFilename;
+
+  wxStripExtension(m_symbolFilename);
+  m_symbolFilename += ".h";
+
+  Save(m_currentFilename);
   return TRUE;
 }
 
-bool wxResourceManager::SaveIfModified(void)
+bool wxResourceManager::SaveIfModified()
 {
   if (Modified())
     return Save();
@@ -346,6 +416,8 @@ bool wxResourceManager::New(bool loadFromFile, const wxString& filename)
   if (!Clear(TRUE, FALSE))
     return FALSE;
     
+  m_symbolTable.AddStandardSymbols();
+
   if (loadFromFile)
   {
     wxString str = filename;
@@ -358,28 +430,64 @@ bool wxResourceManager::New(bool loadFromFile, const wxString& filename)
         return FALSE;
     }
     
-    if (!resourceTable.ParseResourceFile(WXSTRINGCAST str))
+    if (!m_resourceTable.ParseResourceFile(WXSTRINGCAST str))
     {
       wxMessageBox("Could not read file.", "Resource file load error", wxOK | wxICON_EXCLAMATION);
       return FALSE;
     }
-    currentFilename = str;
-    
-    SetFrameTitle(currentFilename);
-    
+    m_currentFilename = str;
+
+    SetFrameTitle(m_currentFilename);
+
     UpdateResourceList();
+
+    // Construct include filename from this file
+    m_symbolFilename = m_currentFilename;
+
+    wxStripExtension(m_symbolFilename);
+    m_symbolFilename += ".h";
+
+    if (!m_symbolTable.ReadIncludeFile(m_symbolFilename))
+    {
+        wxString str("Could not find include file ");
+        str += m_symbolFilename;
+        str += ".\nDialog Editor maintains a header file containing id symbols to be used in the application.\n";
+        str += "The next time this .wxr file is saved, a header file will be saved also.";
+        wxMessageBox(str, "Dialog Editor Warning", wxOK );
+
+        m_symbolIdCounter = 99;
+    }
+    else
+    {
+        // Set the id counter to the last known id
+        m_symbolIdCounter = m_symbolTable.FindHighestId();
+    }
+
+    // Now check in case some (or all) resources don't have resource ids, or they
+    // don't match the .h file, or something of that nature.
+    bool altered = RepairResourceIds();
+    if (altered)
+    {
+        wxMessageBox("Some resources have had new identifiers associated with them, since they were missing.", 
+                    "Dialog Editor Warning", wxOK );
+        Modify(TRUE);
+    }
+    else
+        Modify(FALSE);
+
+    return TRUE;
   }
   else
   {
     SetFrameTitle("");
-    currentFilename = "";
+    m_currentFilename = "";
   }
   Modify(FALSE);
   
   return TRUE;
 }
 
-bool wxResourceManager::Clear(bool deleteWindows, bool force)
+bool wxResourceManager::Clear(bool WXUNUSED(deleteWindows), bool force)
 {
   if (!force && Modified())
   {
@@ -393,22 +501,24 @@ bool wxResourceManager::Clear(bool deleteWindows, bool force)
         Modify(FALSE);
   }
   
-  DisassociateWindows(deleteWindows);
+  ClearCurrentDialog();
+  DisassociateWindows();
 
-  resourceTable.ClearTable();
+  m_symbolTable.Clear();
+  m_resourceTable.ClearTable();
   UpdateResourceList();
 
   return TRUE;
 }
 
-bool wxResourceManager::DisassociateWindows(bool deleteWindows)
+bool wxResourceManager::DisassociateWindows()
 {
-  resourceTable.BeginFind();
+  m_resourceTable.BeginFind();
   wxNode *node;
-  while (node = resourceTable.Next())
+  while (node = m_resourceTable.Next())
   {
     wxItemResource *res = (wxItemResource *)node->Data();
-    DisassociateResource(res, deleteWindows);
+    DisassociateResource(res);
   }
   
   return TRUE;
@@ -416,14 +526,14 @@ bool wxResourceManager::DisassociateWindows(bool deleteWindows)
 
 void wxResourceManager::AssociateResource(wxItemResource *resource, wxWindow *win)
 {
-  if (!resourceAssociations.Get((long)resource))
-    resourceAssociations.Put((long)resource, win);
-    
+  if (!m_resourceAssociations.Get((long)resource))
+    m_resourceAssociations.Put((long)resource, win);
+
   wxNode *node = resource->GetChildren().First();
   while (node)
   {
     wxItemResource *child = (wxItemResource *)node->Data();
-    wxWindow *childWindow = (wxWindow *)resourceAssociations.Get((long)child);
+    wxWindow *childWindow = (wxWindow *)m_resourceAssociations.Get((long)child);
     if (!childWindow)
       childWindow = win->FindWindow(child->GetName());
     if (childWindow)
@@ -439,14 +549,13 @@ void wxResourceManager::AssociateResource(wxItemResource *resource, wxWindow *wi
   }
 }
 
-bool wxResourceManager::DisassociateResource(wxItemResource *resource, bool deleteWindow)
+bool wxResourceManager::DisassociateResource(wxItemResource *resource)
 {
   wxWindow *win = FindWindowForResource(resource);
   if (!win)
     return FALSE;
 
-  // Disassociate children of window without deleting windows
-  // since they'll be deleted by parent.
+  // Disassociate children of window
   if (win->GetChildren())
   {
     wxNode *node = win->GetChildren()->First();
@@ -454,47 +563,88 @@ bool wxResourceManager::DisassociateResource(wxItemResource *resource, bool dele
     {
       wxWindow *child = (wxWindow *)node->Data();
       if (child->IsKindOf(CLASSINFO(wxControl)))
-       DisassociateResource(child, FALSE);
+       DisassociateResource(child);
       node = node->Next();
     }
   }
   
-  if (deleteWindow)
-  {
-    if (win->IsKindOf(CLASSINFO(wxPanel)) && !win->IsKindOf(CLASSINFO(wxDialog)))
-      delete win->GetParent(); // Delete frame
-    else if ( win->IsKindOf(CLASSINFO(wxControl)) )
-       {
-         wxEvtHandler *childHandler = win->GetEventHandler();
-         if ( childHandler != win )
-         {
-               win->PopEventHandler();
-               delete childHandler;
-         }
-      delete win;
-       }
-       else
-         // Is this enough? What about event handler? TODO
-         delete win;
-  }
   RemoveSelection(win);
-  resourceAssociations.Delete((long)resource);
+  m_resourceAssociations.Delete((long)resource);
   return TRUE;
 }
 
-bool wxResourceManager::DisassociateResource(wxWindow *win, bool deleteWindow)
+bool wxResourceManager::DisassociateResource(wxWindow *win)
 {
   wxItemResource *res = FindResourceForWindow(win);
   if (res)
-    return DisassociateResource(res, deleteWindow);
-  return FALSE;
+    return DisassociateResource(res);
+  else
+    return FALSE;
+}
+
+// Saves the window info into the resource, and deletes the
+// handler. Doesn't actually disassociate the window from
+// the resources. Replaces OnClose.
+bool wxResourceManager::SaveInfoAndDeleteHandler(wxWindow* win)
+{
+    wxItemResource *res = FindResourceForWindow(win);
+
+    if (win->IsKindOf(CLASSINFO(wxPanel)))
+    {
+        wxResourceEditorDialogHandler* handler = (wxResourceEditorDialogHandler*) win->GetEventHandler();
+        win->PopEventHandler();
+
+        // Now reset all child event handlers
+        wxNode *node = win->GetChildren()->First();
+        while ( node )
+        {
+               wxWindow *child = (wxWindow *)node->Data();
+               wxEvtHandler *childHandler = child->GetEventHandler();
+               if ( child->IsKindOf(CLASSINFO(wxControl)) && childHandler != child )
+               {
+                       child->PopEventHandler(TRUE);
+               }
+               node = node->Next();
+        }
+        delete handler;
+    }
+    else
+    {
+        win->PopEventHandler(TRUE);
+    }
+  
+    // Save the information
+    InstantiateResourceFromWindow(res, win, TRUE);
+  
+//  DisassociateResource(win);
+
+    return TRUE;
+}
+
+// Destroys the window. If this is the 'current' panel, NULLs the
+// variable.
+bool wxResourceManager::DeleteWindow(wxWindow* win)
+{
+    bool clearDisplay = FALSE;
+    if (m_editorPanel->m_childWindow == win)
+    {
+        m_editorPanel->m_childWindow = NULL;
+        clearDisplay = TRUE;
+    }
+
+    win->Destroy();
+
+    if (clearDisplay)
+        m_editorPanel->Clear();
+
+    return TRUE;
 }
 
 wxItemResource *wxResourceManager::FindResourceForWindow(wxWindow *win)
 {
-  resourceAssociations.BeginFind();
+  m_resourceAssociations.BeginFind();
   wxNode *node;
-  while (node = resourceAssociations.Next())
+  while (node = m_resourceAssociations.Next())
   {
     wxWindow *w = (wxWindow *)node->Data();
     if (w == win)
@@ -507,7 +657,7 @@ wxItemResource *wxResourceManager::FindResourceForWindow(wxWindow *win)
 
 wxWindow *wxResourceManager::FindWindowForResource(wxItemResource *resource)
 {
-  return (wxWindow *)resourceAssociations.Get((long)resource);
+  return (wxWindow *)m_resourceAssociations.Get((long)resource);
 }
 
 
@@ -515,10 +665,10 @@ void wxResourceManager::MakeUniqueName(char *prefix, char *buf)
 {
   while (TRUE)
   {
-    sprintf(buf, "%s%d", prefix, nameCounter);
-    nameCounter ++;
-    
-    if (!resourceTable.FindResource(buf))
+    sprintf(buf, "%s%d", prefix, m_nameCounter);
+    m_nameCounter ++;
+
+    if (!m_resourceTable.FindResource(buf))
       return;
   }
 }
@@ -528,35 +678,26 @@ wxFrame *wxResourceManager::OnCreateEditorFrame(const char *title)
   int frameWidth = 420;
   int frameHeight = 300;
   
-  wxResourceEditorFrame *frame = new wxResourceEditorFrame(this, NULL, (char *)title,
-
-    resourceEditorWindowSize.x, resourceEditorWindowSize.y,
-    resourceEditorWindowSize.width, resourceEditorWindowSize.height,
-
-    wxDEFAULT_FRAME);
-
-  wxFrame::UseNativeStatusBar(FALSE);
+  wxResourceEditorFrame *frame = new wxResourceEditorFrame(this, NULL, title,
+    wxPoint(m_resourceEditorWindowSize.x, m_resourceEditorWindowSize.y),
+    wxSize(m_resourceEditorWindowSize.width, m_resourceEditorWindowSize.height),
+    wxDEFAULT_FRAME_STYLE);
 
-  frame->CreateStatusBar(2);
+  frame->CreateStatusBar(1);
 
-  wxFrame::UseNativeStatusBar(TRUE);
-
-  frame->SetStatusText(editMode ? "Edit mode" : "Test mode", 1);
   frame->SetAutoLayout(TRUE);
-#ifdef __WINDOWS__
-  wxIcon *icon = new wxIcon("DIALOGEDICON");
-  frame->SetIcon(icon);
+#ifdef __WXMSW__
+  frame->SetIcon(wxIcon("DIALOGEDICON"));
 #endif
   return frame;
 }
 
-wxMenuBar *wxResourceManager::OnCreateEditorMenuBar(wxFrame *parent)
+wxMenuBar *wxResourceManager::OnCreateEditorMenuBar(wxFrame *WXUNUSED(parent))
 {
   wxMenuBar *menuBar = new wxMenuBar;
 
   wxMenu *fileMenu = new wxMenu;
   fileMenu->Append(RESED_NEW_DIALOG, "New &dialog", "Create a new dialog");
-  fileMenu->Append(RESED_NEW_PANEL, "New &panel", "Create a new panel");
   fileMenu->AppendSeparator();
   fileMenu->Append(wxID_NEW, "&New project",           "Clear the current project");
   fileMenu->Append(wxID_OPEN, "&Open...",         "Load a resource file");
@@ -567,10 +708,9 @@ wxMenuBar *wxResourceManager::OnCreateEditorMenuBar(wxFrame *parent)
   fileMenu->Append(wxID_EXIT, "E&xit",            "Exit resource editor");
 
   wxMenu *editMenu = new wxMenu;
+  editMenu->Append(RESED_TEST, "&Test Dialog",  "Test dialog");
   editMenu->Append(RESED_RECREATE, "&Recreate",  "Recreate the selected resource(s)");
   editMenu->Append(RESED_DELETE, "&Delete",  "Delete the selected resource(s)");
-  editMenu->AppendSeparator();
-  editMenu->Append(RESED_TOGGLE_TEST_MODE, "&Toggle edit/test mode",  "Toggle edit/test mode");
 
   wxMenu *helpMenu = new wxMenu;
   helpMenu->Append(RESED_CONTENTS, "&Help topics",          "Invokes the on-line help");
@@ -584,72 +724,61 @@ wxMenuBar *wxResourceManager::OnCreateEditorMenuBar(wxFrame *parent)
   return menuBar;
 }
 
-wxPanel *wxResourceManager::OnCreateEditorPanel(wxFrame *parent)
+wxResourceEditorScrolledWindow *wxResourceManager::OnCreateEditorPanel(wxFrame *parent)
 {
-  wxResourceEditorPanel *panel = new wxResourceEditorPanel(parent);
-
-  editorResourceList = new wxListBox(panel, -1, wxPoint(0, 0), wxSize(-1, -1));
+  wxResourceEditorScrolledWindow *panel = new wxResourceEditorScrolledWindow(parent, wxDefaultPosition, wxDefaultSize,
+//    wxSUNKEN_BORDER|wxCLIP_CHILDREN);
+    wxSUNKEN_BORDER);
 
-  wxLayoutConstraints *c = new wxLayoutConstraints;
-  c->left.SameAs       (panel, wxLeft, 5);
-  c->top.SameAs        (panel, wxTop, 5);
-  c->right.SameAs      (panel, wxRight, 5);
-  c->bottom.SameAs     (panel, wxBottom, 5);
-  c->width.Unconstrained();
-  c->height.Unconstrained();
-  editorResourceList->SetConstraints(c);
+  panel->SetScrollbars(10, 10, 100, 100);
 
   return panel;
 }
 
-wxToolBarBase *wxResourceManager::OnCreateToolBar(wxFrame *parent)
+wxToolBar *wxResourceManager::OnCreateToolBar(wxFrame *parent)
 {
   // Load palette bitmaps
-#ifdef __WINDOWS__
-  ToolbarLoadBitmap = new wxBitmap("LOADTOOL");
-  ToolbarSaveBitmap = new wxBitmap("SAVETOOL");
-  ToolbarNewBitmap = new wxBitmap("NEWTOOL");
-  ToolbarVertBitmap = new wxBitmap("VERTTOOL");
-  ToolbarAlignTBitmap = new wxBitmap("ALIGNTTOOL");
-  ToolbarAlignBBitmap = new wxBitmap("ALIGNBTOOL");
-  ToolbarHorizBitmap = new wxBitmap("HORIZTOOL");
-  ToolbarAlignLBitmap = new wxBitmap("ALIGNLTOOL");
-  ToolbarAlignRBitmap = new wxBitmap("ALIGNRTOOL");
-  ToolbarCopySizeBitmap = new wxBitmap("COPYSIZETOOL");
-  ToolbarToBackBitmap = new wxBitmap("TOBACKTOOL");
-  ToolbarToFrontBitmap = new wxBitmap("TOFRONTTOOL");
-  ToolbarHelpBitmap = new wxBitmap("HELPTOOL");
+#ifdef __WXMSW__
+  wxBitmap ToolbarLoadBitmap("LOADTOOL");
+  wxBitmap ToolbarSaveBitmap("SAVETOOL");
+  wxBitmap ToolbarNewBitmap("NEWTOOL");
+  wxBitmap ToolbarVertBitmap("VERTTOOL");
+  wxBitmap ToolbarAlignTBitmap("ALIGNTTOOL");
+  wxBitmap ToolbarAlignBBitmap("ALIGNBTOOL");
+  wxBitmap ToolbarHorizBitmap("HORIZTOOL");
+  wxBitmap ToolbarAlignLBitmap("ALIGNLTOOL");
+  wxBitmap ToolbarAlignRBitmap("ALIGNRTOOL");
+  wxBitmap ToolbarCopySizeBitmap("COPYSIZETOOL");
+  wxBitmap ToolbarToBackBitmap("TOBACKTOOL");
+  wxBitmap ToolbarToFrontBitmap("TOFRONTTOOL");
+  wxBitmap ToolbarHelpBitmap("HELPTOOL");
 #endif
-#ifdef __X__
-  ToolbarLoadBitmap = new wxBitmap(load_bits, load_width, load_height);
-  ToolbarSaveBitmap = new wxBitmap(save_bits, save_width, save_height);
-  ToolbarNewBitmap = new wxBitmap(new_bits, save_width, save_height);
-  ToolbarVertBitmap = new wxBitmap(vert_bits, vert_width, vert_height);
-  ToolbarAlignTBitmap = new wxBitmap(alignt_bits, alignt_width, alignt_height);
-  ToolbarAlignBBitmap = new wxBitmap(alignb_bits, alignb_width, alignb_height);
-  ToolbarHorizBitmap = new wxBitmap(horiz_bits, horiz_width, horiz_height);
-  ToolbarAlignLBitmap = new wxBitmap(alignl_bits, alignl_width, alignl_height);
-  ToolbarAlignRBitmap = new wxBitmap(alignr_bits, alignr_width, alignr_height);
-  ToolbarCopySizeBitmap = new wxBitmap(copysize_bits, copysize_width, copysize_height);
-  ToolbarToBackBitmap = new wxBitmap(toback_bits, toback_width, toback_height);
-  ToolbarToFrontBitmap = new wxBitmap(tofront_bits, tofront_width, tofront_height);
-//  ToolbarCPPBitmap = new wxBitmap(cpp_bits, cpp_width, cpp_height);
-//  ToolbarTreeBitmap = new wxBitmap(tree_bits, tree_width, tree_height);
-  ToolbarHelpBitmap = new wxBitmap(help_bits, help_width, help_height);
+#ifdef __WXGTK__
+  wxBitmap ToolbarLoadBitmap( load_xpm );
+  wxBitmap ToolbarSaveBitmap( save_xpm);
+  wxBitmap ToolbarNewBitmap( new_xpm );
+  wxBitmap ToolbarVertBitmap( vert_xpm );
+  wxBitmap ToolbarAlignTBitmap( alignt_xpm );
+  wxBitmap ToolbarAlignBBitmap( alignb_xpm );
+  wxBitmap ToolbarHorizBitmap( horiz_xpm );
+  wxBitmap ToolbarAlignLBitmap( alignl_xpm );
+  wxBitmap ToolbarAlignRBitmap( alignr_xpm );
+  wxBitmap ToolbarCopySizeBitmap( copysize_xpm );
+  wxBitmap ToolbarToBackBitmap( toback_xpm );
+  wxBitmap ToolbarToFrontBitmap( tofront_xpm );
+  wxBitmap ToolbarHelpBitmap( help_xpm );
 #endif
 
   // Create the toolbar
-  EditorToolBar *toolbar = new EditorToolBar(parent, 0, 0, -1, -1, wxNO_BORDER,
-                                        wxVERTICAL, 1);
+  EditorToolBar *toolbar = new EditorToolBar(parent, wxPoint(0, 0), wxSize(-1, -1), wxNO_BORDER|wxTB_HORIZONTAL);
   toolbar->SetMargins(2, 2);
-//  toolbar->GetDC()->SetBackground(wxLIGHT_GREY_BRUSH);
 
-#ifdef __WINDOWS__
+#ifdef __WXMSW__
   int width = 24;
   int dx = 2;
   int gap = 6;
 #else
-  int width = ToolbarLoadBitmap->GetWidth();
+  int width = 24; // ToolbarLoadBitmap->GetWidth();  ???
   int dx = 2;
   int gap = 6;
 #endif
@@ -693,53 +822,65 @@ wxToolBarBase *wxResourceManager::OnCreateToolBar(wxFrame *parent)
   toolbar->AddTool(TOOLBAR_TO_BACK, ToolbarToBackBitmap, (wxBitmap *)NULL,
                    FALSE, (float)currentX, -1, NULL, "To back");
   currentX += width + dx + gap;
-/*
-  toolbar->AddTool(TOOLBAR_GEN_CPP, ToolbarCPPBitmap, (wxBitmap *)NULL,
-                   FALSE, (float)currentX, -1, NULL);
-  currentX += width + dx;
 
-  toolbar->AddTool(TOOLBAR_TREE, ToolbarTreeBitmap, (wxBitmap *)NULL,
-                   FALSE, (float)currentX, -1, NULL);
-  currentX += width + dx;
-*/
   toolbar->AddSeparator();
   toolbar->AddTool(TOOLBAR_HELP, ToolbarHelpBitmap, (wxBitmap *)NULL,
                    FALSE, (float)currentX, -1, NULL, "Help");
   currentX += width + dx;
   
-  toolbar->CreateTools();
+  toolbar->Realize();
 
   return toolbar;
-
-//  parent->OnSize(-1, -1);
 }
 
-void wxResourceManager::UpdateResourceList(void)
+void wxResourceManager::UpdateResourceList()
 {
-  editorResourceList->Clear();
-  resourceTable.BeginFind();
+  if (!m_editorResourceTree)
+      return;
+
+  m_editorResourceTree->SetInvalid(TRUE);
+  m_editorResourceTree->DeleteAllItems();
+
+  long id = m_editorResourceTree->InsertItem(0, "Dialogs"
+#ifdef __WXMSW__
+     , 1, 2
+#endif
+   );
+
+  m_resourceTable.BeginFind();
   wxNode *node;
-  while (node = resourceTable.Next())
+  while (node = m_resourceTable.Next())
   {
     wxItemResource *res = (wxItemResource *)node->Data();
     wxString resType(res->GetType());
-//    if (res->GetType() == wxTYPE_DIALOG_BOX || res->GetType() == wxTYPE_FRAME || res->GetType() == wxTYPE_BITMAP)
     if (resType == "wxDialog" || resType == "wxDialogBox" || resType == "wxPanel" || resType == "wxBitmap")
     {
-      AddItemsRecursively(0, res);
+      AddItemsRecursively(id, res);
     }
   }
+  m_editorResourceTree->ExpandItem(id, wxTREE_EXPAND_EXPAND);
+  m_editorResourceTree->SetInvalid(FALSE);
 }
 
-void wxResourceManager::AddItemsRecursively(int level, wxItemResource *resource)
+void wxResourceManager::AddItemsRecursively(long parent, wxItemResource *resource)
 {
-  int padWidth = level*4;
-  
   wxString theString("");
-  theString.Append(' ', padWidth);
-  theString += resource->GetName();
+  theString = resource->GetName();
+
+  int imageId = 0;
+  wxString resType(resource->GetType());
+  if (resType == "wxDialog" || resType == "wxDialogBox" || resType == "wxPanel")
+    imageId = 0;
+  else
+    imageId = 3;
   
-  editorResourceList->Append(theString.GetData(), (char *)resource);
+  long id = m_editorResourceTree->InsertItem(parent, theString
+#ifdef __WXMSW__
+     , imageId
+#endif
+   );
+
+  m_editorResourceTree->SetItemData(id, (long) resource);
 
   if (strcmp(resource->GetType(), "wxBitmap") != 0)
   {
@@ -747,18 +888,19 @@ void wxResourceManager::AddItemsRecursively(int level, wxItemResource *resource)
     while (node)
     {
       wxItemResource *res = (wxItemResource *)node->Data();
-      AddItemsRecursively(level+1, res);
+      AddItemsRecursively(id, res);
       node = node->Next();
     }
   }
+//  m_editorResourceTree->ExpandItem(id, wxTREE_EXPAND_EXPAND);
 }
 
-bool wxResourceManager::EditSelectedResource(void)
+bool wxResourceManager::EditSelectedResource()
 {
-  int sel = editorResourceList->GetSelection();
-  if (sel > -1)
+  int sel = m_editorResourceTree->GetSelection();
+  if (sel != 0)
   {
-    wxItemResource *res = (wxItemResource *)editorResourceList->wxListBox::GetClientData(sel);
+    wxItemResource *res = (wxItemResource *)m_editorResourceTree->GetItemData(sel);
     return Edit(res);
   }
   return FALSE;
@@ -766,132 +908,71 @@ bool wxResourceManager::EditSelectedResource(void)
 
 bool wxResourceManager::Edit(wxItemResource *res)
 {
+  ClearCurrentDialog();
+
   wxString resType(res->GetType());
-  if (resType == "wxDialog" || resType == "wxDialogBox")
-    {
-      wxDialog *dialog = (wxDialog *)FindWindowForResource(res);
-      if (dialog)
-        dialog->Show(TRUE);
-      else
-      {
-        dialog = new wxDialog;
-        wxResourceEditorDialogHandler *handler = new wxResourceEditorDialogHandler(dialog, res, dialog->GetEventHandler(),
-           this);
-        dialog->PushEventHandler(handler);
+  wxPanel *panel = (wxPanel *)FindWindowForResource(res);
 
-//        dialog->SetUserEditMode(TRUE);
-          
-        dialog->LoadFromResource(GetEditorFrame(), res->GetName(), &resourceTable);
-               handler->AddChildHandlers(); // Add event handlers for all controls
-        dialog->SetModal(FALSE);
-        AssociateResource(res, dialog);
-        dialog->Show(TRUE);
-      }
-    }
-  else if (resType == "wxPanel")
-    {
-      wxPanel *panel = (wxPanel *)FindWindowForResource(res);
-      if (panel)
-        panel->GetParent()->Show(TRUE);
-      else
-      {
-        DialogEditorPanelFrame *frame = new DialogEditorPanelFrame(GetEditorFrame(), res->GetName(), 10, 10, 400, 300, wxDEFAULT_FRAME_STYLE, res->GetName());
+  if (panel)
+  {
+    wxMessageBox("Should not find panel in wxResourceManager::Edit");
+    return FALSE;
+  }
+  else
+  {
+//        long style = res->GetStyle();
+//        res->SetStyle(style|wxRAISED_BORDER);
         panel = new wxPanel;
         wxResourceEditorDialogHandler *handler = new wxResourceEditorDialogHandler(panel, res, panel->GetEventHandler(),
            this);
+
+        panel->LoadFromResource(m_editorPanel, res->GetName(), &m_resourceTable);
+
         panel->PushEventHandler(handler);
-//        panel->SetUserEditMode(TRUE);
-          
-        panel->LoadFromResource(frame, res->GetName(), &resourceTable);
+
+//        res->SetStyle(style);
                handler->AddChildHandlers(); // Add event handlers for all controls
         AssociateResource(res, panel);
-        frame->SetClientSize(res->GetWidth(), res->GetHeight());
-        frame->Show(TRUE);
-      }
-    }
+
+        m_editorPanel->m_childWindow = panel;
+        panel->Move(m_editorPanel->GetMarginX(), m_editorPanel->GetMarginY());
+        panel->Show(TRUE);
+        panel->Refresh();
+
+        wxClientDC dc(m_editorPanel);
+        m_editorPanel->DrawTitle(dc);
+  }
   return FALSE;
 }
 
-bool wxResourceManager::CreateNewDialog(void)
+bool wxResourceManager::CreateNewPanel()
 {
+  ClearCurrentDialog();
+
   char buf[256];
   MakeUniqueName("dialog", buf);
   
   wxItemResource *resource = new wxItemResource;
-//  resource->SetType(wxTYPE_DIALOG_BOX);
   resource->SetType("wxDialog");
   resource->SetName(buf);
   resource->SetTitle(buf);
-  resourceTable.AddResource(resource);
-
-#ifdef __MOTIF__
-  wxDialog *dialog = new wxDialog(GetEditorFrame(), -1, buf, wxPoint(10, 10), wxSize(400, 300), wxDEFAULT_DIALOG_STYLE, buf);
-/*
-  dialog->SetBackgroundColour(*wxLIGHT_GREY);
-  dialog->GetDC()->SetBackground(wxLIGHT_GREY_BRUSH);
-  dialog->SetButtonColour(*wxBLACK);
-  dialog->SetLabelColour(*wxBLACK);
-*/
-#else
-  wxDialog *dialog = new wxDialog(GetEditorFrame(), -1, buf, wxPoint(10, 10), wxSize(400, 300), wxDEFAULT_DIALOG_STYLE, buf);
-#endif
-  
-  resource->SetValue1(FALSE); // Modeless to start with
-  resource->SetStyle(dialog->GetWindowStyleFlag());
-
-  // For editing in situ we will need to use the hash table to ensure
-  // we don't dereference invalid pointers.
-//  resourceWindowTable.Put((long)resource, dialog);
-
-  wxResourceEditorDialogHandler *handler = new wxResourceEditorDialogHandler(dialog, resource, dialog->GetEventHandler(),
-   this);
 
-  dialog->PushEventHandler(handler);
-  
-  dialog->Centre(wxBOTH);
-//  dialog->SetUserEditMode(TRUE);
-  dialog->Show(TRUE);
-
-  SetEditMode(TRUE, FALSE);
+  wxString newIdName;
+  int id = GenerateWindowId("ID_DIALOG", newIdName);
+  resource->SetId(id);
 
-  AssociateResource(resource, dialog);
-//  SetCurrentResource(resource);
-//  SetCurrentResourceWindow(dialog);
-  UpdateResourceList();
-  
-  Modify(TRUE);
-  
-  return TRUE;
-}
+  // This is now guaranteed to be unique, so just add to symbol table
+  m_symbolTable.AddSymbol(newIdName, id);
 
-bool wxResourceManager::CreateNewPanel(void)
-{
-  char buf[256];
-  MakeUniqueName("panel", buf);
-  
-  wxItemResource *resource = new wxItemResource;
-//  resource->SetType(wxTYPE_PANEL);
-  resource->SetType("wxPanel");
-  resource->SetName(buf);
-  resource->SetTitle(buf);
-  resourceTable.AddResource(resource);
-  
-  DialogEditorPanelFrame *frame = new DialogEditorPanelFrame(GetEditorFrame(), buf, 10, 10, 400, 300, wxDEFAULT_FRAME_STYLE, buf);
+  m_resourceTable.AddResource(resource);
 
-#ifdef __MOTIF__
-  wxPanel *panel = new wxPanel(frame, -1, wxPoint(0, 0), wxSize(400, 300), 0, buf);
-/*
-  panel->SetBackgroundColour(*wxLIGHT_GREY);
-  panel->GetDC()->SetBackground(wxLIGHT_GREY_BRUSH);
-  panel->SetButtonColour(*wxBLACK);
-  panel->SetLabelColour(*wxBLACK);
-*/
+  wxPanel *panel = new wxPanel(m_editorPanel, -1,
+     wxPoint(m_editorPanel->GetMarginX(), m_editorPanel->GetMarginY()),
+     wxSize(400, 300), wxRAISED_BORDER|wxDEFAULT_DIALOG_STYLE, buf);
+  m_editorPanel->m_childWindow = panel;
 
-#else
-  wxPanel *panel = new wxPanel(frame, -1, wxPoint(0, 0), wxSize(400, 300), 0, buf);
-#endif
-  
   resource->SetStyle(panel->GetWindowStyleFlag());
+  resource->SetSize(10, 10, 400, 300);
 
   // For editing in situ we will need to use the hash table to ensure
   // we don't dereference invalid pointers.
@@ -901,19 +982,17 @@ bool wxResourceManager::CreateNewPanel(void)
    this);
   panel->PushEventHandler(handler);
   
-  panel->Centre(wxBOTH);
-//  panel->SetUserEditMode(TRUE);
-  frame->Show(TRUE);
-
-  SetEditMode(TRUE, FALSE);
-
   AssociateResource(resource, panel);
-//  SetCurrentResource(resource);
-//  SetCurrentResourceWindow(panel);
   UpdateResourceList();
   
   Modify(TRUE);
-  
+  m_editorPanel->m_childWindow->Refresh();
+
+//  panel->Refresh();
+
+  wxClientDC dc(m_editorPanel);
+  m_editorPanel->DrawTitle(dc);
+
   return TRUE;
 }
 
@@ -929,53 +1008,62 @@ bool wxResourceManager::CreatePanelItem(wxItemResource *panelResource, wxPanel *
   wxControl *newItem = NULL;
   res->SetSize(x, y, -1, -1);
   res->SetType(iType);
+
+  wxString prefix;
   
   wxString itemType(iType);
 
   if (itemType == "wxButton")
     {
+      prefix = "ID_BUTTON";
       MakeUniqueName("button", buf);
       res->SetName(buf);
       if (isBitmap)
-        newItem = new wxBitmapButton(panel, -1, wxWinBitmap, wxPoint(x, y), wxSize(-1, -1), 0, wxDefaultValidator, buf);
+        newItem = new wxBitmapButton(panel, -1, m_bitmapImage, wxPoint(x, y), wxSize(-1, -1), 0, wxDefaultValidator, buf);
       else
         newItem = new wxButton(panel, -1, "Button", wxPoint(x, y), wxSize(-1, -1), 0, wxDefaultValidator, buf);
     }
   if (itemType == "wxBitmapButton")
     {
+      prefix = "ID_BITMAPBUTTON";
       MakeUniqueName("button", buf);
       res->SetName(buf);
-      newItem = new wxBitmapButton(panel, -1, wxWinBitmap, wxPoint(x, y), wxSize(-1, -1), 0, wxDefaultValidator, buf);
+      newItem = new wxBitmapButton(panel, -1, m_bitmapImage, wxPoint(x, y), wxSize(-1, -1), 0, wxDefaultValidator, buf);
     }
   else if (itemType == "wxMessage" || itemType == "wxStaticText")
     {
-      MakeUniqueName("message", buf);
+      prefix = "ID_STATIC";
+      MakeUniqueName("statictext", buf);
       res->SetName(buf);
       if (isBitmap)
-        newItem = new wxStaticBitmap(panel, -1, wxWinBitmap, 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, "Message", wxPoint(x, y), wxSize(-1, -1), 0, buf);
+        newItem = new wxStaticText(panel, -1, "Static", wxPoint(x, y), wxSize(-1, -1), 0, buf);
     }
   else if (itemType == "wxStaticBitmap")
     {
-      MakeUniqueName("message", buf);
+      prefix = "ID_STATICBITMAP";
+      MakeUniqueName("static", buf);
       res->SetName(buf);
-      newItem = new wxStaticBitmap(panel, -1, wxWinBitmap, 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")
     {
+      prefix = "ID_CHECKBOX";
       MakeUniqueName("checkbox", buf);
       res->SetName(buf);
       newItem = new wxCheckBox(panel, -1, "Checkbox", wxPoint(x, y), wxSize(-1, -1), 0, wxDefaultValidator, buf);
     }
   else if (itemType == "wxListBox")
     {
+      prefix = "ID_LISTBOX";
       MakeUniqueName("listbox", buf);
       res->SetName(buf);
       newItem = new wxListBox(panel, -1, wxPoint(x, y), wxSize(-1, -1), 0, NULL, 0, wxDefaultValidator, buf);
     }
   else if (itemType == "wxRadioBox")
     {
+      prefix = "ID_RADIOBOX";
       MakeUniqueName("radiobox", buf);
       res->SetName(buf);
       wxString names[] = { "One", "Two" };
@@ -983,46 +1071,69 @@ bool wxResourceManager::CreatePanelItem(wxItemResource *panelResource, wxPanel *
             wxHORIZONTAL, wxDefaultValidator, buf);
       res->SetStringValues(new wxStringList("One", "Two", NULL));
     }
+  else if (itemType == "wxRadioButton")
+    {
+      prefix = "ID_RADIOBUTTON";
+      MakeUniqueName("radiobutton", buf);
+      res->SetName(buf);
+      wxString names[] = { "One", "Two" };
+      newItem = new wxRadioButton(panel, -1, "Radiobutton", wxPoint(x, y), wxSize(-1, -1),
+            0, wxDefaultValidator, buf);
+    }
   else if (itemType == "wxChoice")
     {
+      prefix = "ID_CHOICE";
       MakeUniqueName("choice", buf);
       res->SetName(buf);
       newItem = new wxChoice(panel, -1, wxPoint(x, y), wxSize(-1, -1), 0, NULL, 0, wxDefaultValidator, buf);
     }
+  else if (itemType == "wxComboBox")
+    {
+      prefix = "ID_COMBOBOX";
+      MakeUniqueName("combobox", buf);
+      res->SetName(buf);
+      newItem = new wxComboBox(panel, -1, "", wxPoint(x, y), wxSize(-1, -1), 0, NULL, wxCB_DROPDOWN, wxDefaultValidator, buf);
+    }
   else if (itemType == "wxGroupBox" || itemType == "wxStaticBox")
     {
-      MakeUniqueName("group", buf);
+      prefix = "ID_STATICBOX";
+      MakeUniqueName("staticbox", buf);
       res->SetName(buf);
-      newItem = new wxStaticBox(panel, -1, "Groupbox", wxPoint(x, y), wxSize(200, 200), 0, buf);
+      newItem = new wxStaticBox(panel, -1, "Static", wxPoint(x, y), wxSize(200, 200), 0, buf);
     }
   else if (itemType == "wxGauge")
     {
+      prefix = "ID_GAUGE";
       MakeUniqueName("gauge", buf);
       res->SetName(buf);
       newItem = new wxGauge(panel, -1, 10, wxPoint(x, y), wxSize(80, 30), wxHORIZONTAL, wxDefaultValidator, buf);
     }
   else if (itemType == "wxSlider")
     {
+      prefix = "ID_SLIDER";
       MakeUniqueName("slider", buf);
       res->SetName(buf);
       newItem = new wxSlider(panel, -1, 1, 1, 10, wxPoint(x, y), wxSize(120, -1), wxHORIZONTAL, wxDefaultValidator, buf);
     }
-  else if (itemType == "wxText" || itemType == "wxTextCtrl")
+  else if (itemType == "wxText" || itemType == "wxTextCtrl (single-line)")
     {
-      MakeUniqueName("text", buf);
+      prefix = "ID_TEXTCTRL";
+      MakeUniqueName("textctrl", buf);
       res->SetName(buf);
+      res->SetType("wxTextCtrl");
       newItem = new wxTextCtrl(panel, -1, "", wxPoint(x, y), wxSize(120, -1), 0, wxDefaultValidator, buf);
     }
-/*
-  else if (itemType == "wxMultiText")
+  else if (itemType == "wxMultiText" || itemType == "wxTextCtrl (multi-line)")
     {
-      MakeUniqueName("multitext", buf);
+      prefix = "ID_TEXTCTRL";
+      MakeUniqueName("textctrl", buf);
       res->SetName(buf);
-      newItem = new wxMultiText(panel, (wxFunction)NULL, "Multitext", "", x, y, -1, -1, 0, wxDefaultValidator, buf);
+      res->SetType("wxTextCtrl");
+      newItem = new wxTextCtrl(panel, -1, "", wxPoint(x, y), wxSize(120, 100), wxTE_MULTILINE, wxDefaultValidator, buf);
     }
-*/
   else if (itemType == "wxScrollBar")
     {
+      prefix = "ID_SCROLLBAR";
       MakeUniqueName("scrollbar", buf);
       res->SetName(buf);
       newItem = new wxScrollBar(panel, -1, wxPoint(x, y), wxSize(140, -1), wxHORIZONTAL, wxDefaultValidator, buf);
@@ -1030,6 +1141,13 @@ bool wxResourceManager::CreatePanelItem(wxItemResource *panelResource, wxPanel *
   if (!newItem)
     return FALSE;
 
+  wxString newIdName;
+  int id = GenerateWindowId(prefix, newIdName);
+  res->SetId(id);
+
+  // This is now guaranteed to be unique, so just add to symbol table
+  m_symbolTable.AddSymbol(newIdName, id);
+
   newItem->PushEventHandler(new wxResourceEditorControlHandler(newItem, newItem));
 
   res->SetStyle(newItem->GetWindowStyleFlag());
@@ -1041,13 +1159,52 @@ bool wxResourceManager::CreatePanelItem(wxItemResource *panelResource, wxPanel *
   return TRUE;
 }
 
+void wxResourceManager::ClearCurrentDialog()
+{
+  if (m_editorPanel->m_childWindow)
+  {
+    SaveInfoAndDeleteHandler(m_editorPanel->m_childWindow);
+    DisassociateResource(m_editorPanel->m_childWindow);
+    DeleteWindow(m_editorPanel->m_childWindow);
+    m_editorPanel->m_childWindow = NULL;
+    m_editorPanel->Clear();
+  }
+}
+
+bool wxResourceManager::TestCurrentDialog(wxWindow* parent)
+{
+  if (m_editorPanel->m_childWindow)
+  {
+    wxItemResource* item = FindResourceForWindow(m_editorPanel->m_childWindow);
+    if (!item)
+        return FALSE;
+
+    // Make sure the resources are up-to-date w.r.t. the window
+    InstantiateResourceFromWindow(item, m_editorPanel->m_childWindow, TRUE);
+
+    wxDialog* dialog = new wxDialog;
+    long oldStyle = item->GetStyle();
+    bool success = FALSE;
+//    item->SetStyle(wxDEFAULT_DIALOG_STYLE);
+    if (dialog->LoadFromResource(parent, item->GetName(), & m_resourceTable))
+    {
+        dialog->Centre();
+        dialog->ShowModal();
+        success = TRUE;
+    }
+//    item->SetStyle(oldStyle);
+    return success;
+  }
+  return FALSE;
+}
+
 // Find the first dialog or panel for which
 // there is a selected panel item.
-wxWindow *wxResourceManager::FindParentOfSelection(void)
+wxWindow *wxResourceManager::FindParentOfSelection()
 {
-  resourceTable.BeginFind();
+  m_resourceTable.BeginFind();
   wxNode *node;
-  while (node = resourceTable.Next())
+  while (node = m_resourceTable.Next())
   {
     wxItemResource *res = (wxItemResource *)node->Data();
     wxWindow *win = FindWindowForResource(res);
@@ -1150,7 +1307,7 @@ void wxResourceManager::AlignItems(int flag)
 }
 
 // Copy the first image's size to subsequent images
-void wxResourceManager::CopySize(void)
+void wxResourceManager::CopySize()
 {
   wxWindow *win = FindParentOfSelection();
   if (!win)
@@ -1217,22 +1374,22 @@ void wxResourceManager::ToBackOrFront(bool toBack)
 
 void wxResourceManager::AddSelection(wxWindow *win)
 {
-  if (!selections.Member(win))
-    selections.Append(win);
+  if (!m_selections.Member(win))
+    m_selections.Append(win);
 }
 
 void wxResourceManager::RemoveSelection(wxWindow *win)
 {
-  selections.DeleteObject(win);
+  m_selections.DeleteObject(win);
 }
 
 // Need to search through resource table removing this from
 // any resource which has this as a parent.
 bool wxResourceManager::RemoveResourceFromParent(wxItemResource *res)
 {
-  resourceTable.BeginFind();
+  m_resourceTable.BeginFind();
   wxNode *node;
-  while (node = resourceTable.Next())
+  while (node = m_resourceTable.Next())
   {
     wxItemResource *thisRes = (wxItemResource *)node->Data();
     if (thisRes->GetChildren().Member(res))
@@ -1264,18 +1421,24 @@ bool wxResourceManager::DeleteResource(wxItemResource *res)
   // associate bitmap resource if not being used.
   wxString resType(res->GetType());
   
-  if ((resType == "wxMessage" || resType == "wxButton") && res->GetValue4())
+  if ((resType == "wxMessage" || resType == "wxStaticBitmap" || resType == "wxButton" || resType == "wxBitmapButton") && res->GetValue4())
   {
     PossiblyDeleteBitmapResource(res->GetValue4());
   }
 
-  resourceTable.Delete(res->GetName());
+  // Remove symbol from table if appropriate
+  if (!IsSymbolUsed(res, res->GetId()))
+  {
+    m_symbolTable.RemoveSymbol(res->GetId());
+  }
+
+  m_resourceTable.Delete(res->GetName());
   delete res;
   Modify(TRUE);
   return TRUE;
 }
 
-bool wxResourceManager::DeleteResource(wxWindow *win, bool deleteWindow)
+bool wxResourceManager::DeleteResource(wxWindow *win)
 {
   if (win->IsKindOf(CLASSINFO(wxControl)))
   {
@@ -1287,19 +1450,18 @@ bool wxResourceManager::DeleteResource(wxWindow *win, bool deleteWindow)
     {
       RemoveSelection(item);
       childHandler->SelectItem(FALSE);
+#ifndef __WXGTK__
       item->GetParent()->Refresh();
+#endif
     }
   }
   
   wxItemResource *res = FindResourceForWindow(win);
   
-  DisassociateResource(res, deleteWindow);
+  DisassociateResource(res);
   DeleteResource(res);
   UpdateResourceList();
 
-  // What about associated event handler? Must clean up! BUGBUG
-//  if (win && deleteWindow)
-//    delete win;
   return TRUE;
 }
 
@@ -1327,7 +1489,7 @@ char *wxResourceManager::AddBitmapResource(char *filename)
     child->SetSize(0,0,0,0);
     resource->GetChildren().Append(child);
 
-    resourceTable.AddResource(resource);
+    m_resourceTable.AddResource(resource);
 
     UpdateResourceList();
   }
@@ -1342,7 +1504,7 @@ void wxResourceManager::PossiblyDeleteBitmapResource(char *resourceName)
 {
   if (!IsBitmapResourceUsed(resourceName))
   {
-    wxItemResource *res = resourceTable.FindResource(resourceName);
+    wxItemResource *res = m_resourceTable.FindResource(resourceName);
     DeleteResource(res);
     UpdateResourceList();
   }
@@ -1350,9 +1512,9 @@ void wxResourceManager::PossiblyDeleteBitmapResource(char *resourceName)
 
 bool wxResourceManager::IsBitmapResourceUsed(char *resourceName)
 {
-  resourceTable.BeginFind();
+  m_resourceTable.BeginFind();
   wxNode *node;
-  while (node = resourceTable.Next())
+  while (node = m_resourceTable.Next())
   {
     wxItemResource *res = (wxItemResource *)node->Data();
     wxString resType(res->GetType());
@@ -1380,7 +1542,7 @@ char *wxResourceManager::FindBitmapFilenameForResource(wxItemResource *resource)
 {
   if (!resource || !resource->GetValue4())
     return NULL;
-  wxItemResource *bitmapResource = resourceTable.FindResource(resource->GetValue4());
+  wxItemResource *bitmapResource = m_resourceTable.FindResource(resource->GetValue4());
   if (!bitmapResource)
     return NULL;
 
@@ -1400,9 +1562,9 @@ char *wxResourceManager::FindBitmapFilenameForResource(wxItemResource *resource)
 
 wxItemResource *wxResourceManager::FindBitmapResourceByFilename(char *filename)
 {
-  resourceTable.BeginFind();
+  m_resourceTable.BeginFind();
   wxNode *node;
-  while (node = resourceTable.Next())
+  while (node = m_resourceTable.Next())
   {
     wxItemResource *res = (wxItemResource *)node->Data();
     wxString resType(res->GetType());
@@ -1421,95 +1583,216 @@ wxItemResource *wxResourceManager::FindBitmapResourceByFilename(char *filename)
   return NULL;
 }
 
- // 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)
+// Is this window identifier symbol in use?
+// Let's assume that we can't have 2 names for the same integer id.
+// Therefore we can tell by the integer id whether the symbol is
+// in use.
+bool wxResourceManager::IsSymbolUsed(wxItemResource* thisResource, wxWindowID id)
 {
-  wxItemResource *resource = FindResourceForWindow(win);
-
-  // Put the current window properties into the wxItemResource object
-  
-  wxWindowPropertyInfo *newInfo = NULL;
-  if (!info)
+  m_resourceTable.BeginFind();
+  wxNode *node;
+  while (node = m_resourceTable.Next())
   {
-    newInfo = wxCreatePropertyInfoForWindow(win);
-    info = newInfo;
-  }
-
-  info->InstantiateResource(resource);
+    wxItemResource *res = (wxItemResource *)node->Data();
 
-  wxWindow *newWin = NULL;
-  wxWindow *parent = win->GetParent();
-  
-  if (win->IsKindOf(CLASSINFO(wxPanel)))
-  {
-    bool isDialog = win->IsKindOf(CLASSINFO(wxDialog));
-    wxWindow *parent = win->GetParent();
-    
-    win->GetEventHandler()->OnClose();
-    
-    if (!isDialog && parent)
+    wxString resType(res->GetType());
+    if (resType == "wxDialog" || resType == "wxDialogBox" || resType == "wxPanel")
     {
-      // Delete frame parent of panel if this is not a dialog box
-      parent->Close(TRUE);
-    }
+      if ((res != thisResource) && (res->GetId() == id))
+          return TRUE;
 
-    Edit(resource);
-    newWin = FindWindowForResource(resource);
-  }
-  else
-  {
-    DisassociateResource(resource, FALSE);
-    delete win;
-    newWin = resourceTable.CreateItem((wxPanel *)parent, resource);
-    AssociateResource(resource, newWin);
-    UpdateResourceList();
+      wxNode *node1 = res->GetChildren().First();
+      while (node1)
+      {
+        wxItemResource *child = (wxItemResource *)node1->Data();
+        if ((child != thisResource) && (child->GetId() == id))
+          return TRUE;
+        node1 = node1->Next();
+      }
+    }
   }
-
-  if (info)
-    info->SetPropertyWindow(newWin);
-    
-  if (newInfo)
-    delete newInfo;
-  
-  return newWin;
+  return FALSE;
 }
 
-// Delete resource highlighted in the listbox
-bool wxResourceManager::DeleteSelection(bool deleteWindow)
+// Is this window identifier compatible with the given name? (i.e.
+// does it already exist under a different name)
+bool wxResourceManager::IsIdentifierOK(const wxString& name, wxWindowID id)
 {
-  int sel = editorResourceList->GetSelection();
-  if (sel > -1)
-  {
-    wxItemResource *res = (wxItemResource *)editorResourceList->wxListBox::GetClientData(sel);
-    wxWindow *win = FindWindowForResource(res);
-/*
-    if (res == currentResource)
+    if (m_symbolTable.SymbolExists(name))
     {
-      currentResource = NULL;
-      currentResourceWindow = NULL;
+        int foundId = m_symbolTable.GetIdForSymbol(name);
+        if (foundId != id)
+            return FALSE;
     }
-*/
+    return TRUE;
+}
 
-    DisassociateResource(res, deleteWindow);
-    DeleteResource(res);
+// Change all integer ids that match oldId, to newId.
+// This is necessary if an id is changed for one resource - all resources
+// must be changed.
+void wxResourceManager::ChangeIds(int oldId, int newId)
+{
+  m_resourceTable.BeginFind();
+  wxNode *node;
+  while (node = m_resourceTable.Next())
+  {
+    wxItemResource *res = (wxItemResource *)node->Data();
+
+    wxString resType(res->GetType());
+    if (resType == "wxDialog" || resType == "wxDialogBox" || resType == "wxPanel")
+    {
+      if (res->GetId() == oldId)
+          res->SetId(newId);
+
+      wxNode *node1 = res->GetChildren().First();
+      while (node1)
+      {
+        wxItemResource *child = (wxItemResource *)node1->Data();
+        if (child->GetId() == oldId)
+            child->SetId(newId);
+
+        node1 = node1->Next();
+      }
+    }
+  }
+}
+
+// If any resource ids were missing (or their symbol was missing),
+// repair them i.e. give them new ids. Returns TRUE if any resource
+// needed repairing.
+bool wxResourceManager::RepairResourceIds()
+{
+  bool repaired = FALSE;
+
+  m_resourceTable.BeginFind();
+  wxNode *node;
+  while (node = m_resourceTable.Next())
+  {
+    wxItemResource *res = (wxItemResource *)node->Data();
+    wxString resType(res->GetType());
+    if (resType == "wxDialog" || resType == "wxDialogBox" || resType == "wxPanel")
+    {
+
+      if ( (res->GetId() == 0) || ((res->GetId() > 0) && !m_symbolTable.IdExists(res->GetId())) )
+      {
+          wxString newSymbolName;
+          int newId = GenerateWindowId("ID_DIALOG", newSymbolName) ;
+
+          if (res->GetId() == 0)
+          {
+              res->SetId(newId);
+              m_symbolTable.AddSymbol(newSymbolName, newId);
+          }
+          else
+          {
+              m_symbolTable.AddSymbol(newSymbolName, res->GetId());
+          }
+
+          repaired = TRUE;
+      }
+
+      wxNode *node1 = res->GetChildren().First();
+      while (node1)
+      {
+        wxItemResource *child = (wxItemResource *)node1->Data();
+
+        if ( (child->GetId() == 0) || ((child->GetId() > 0) && !m_symbolTable.IdExists(child->GetId())) )
+        {
+            wxString newSymbolName;
+            int newId = GenerateWindowId("ID_CONTROL", newSymbolName) ;
+
+            if (child->GetId() == 0)
+            {
+                child->SetId(newId);
+                m_symbolTable.AddSymbol(newSymbolName, newId);
+            }
+            else
+            {
+                m_symbolTable.AddSymbol(newSymbolName, child->GetId());
+            }
+
+            repaired = TRUE;
+        }
+
+        node1 = node1->Next();
+      }
+    }
+  }
+  return repaired;
+}
+
+
+ // 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)
+{
+  wxItemResource *resource = FindResourceForWindow(win);
+
+  // Put the current window properties into the wxItemResource object
+  
+  wxWindowPropertyInfo *newInfo = NULL;
+  if (!info)
+  {
+    newInfo = CreatePropertyInfoForWindow(win);
+    info = newInfo;
+  }
+
+  info->InstantiateResource(resource);
+
+  wxWindow *newWin = NULL;
+  wxWindow *parent = win->GetParent();
+  
+  if (win->IsKindOf(CLASSINFO(wxPanel)))
+  {
+    Edit(resource);
+    newWin = FindWindowForResource(resource);
+  }
+  else
+  {
+    DisassociateResource(resource);
+    if (win->GetEventHandler() != win)
+        win->PopEventHandler(TRUE);
+
+    DeleteWindow(win);
+    newWin = m_resourceTable.CreateItem((wxPanel *)parent, resource);
+    newWin->PushEventHandler(new wxResourceEditorControlHandler((wxControl*) newWin, (wxControl*) newWin));
+    AssociateResource(resource, newWin);
     UpdateResourceList();
+  }
 
-/*
-    // What about associated event handler? Must clean up! BUGBUG
-    if (win && deleteWindow)
-      delete win;
-*/
+  if (info)
+    info->SetPropertyWindow(newWin);
+    
+  if (newInfo)
+    delete newInfo;
+  
+  return newWin;
+}
 
-    Modify(TRUE);
+// Delete resource highlighted in the listbox
+bool wxResourceManager::DeleteSelection()
+{
+  int sel = m_editorResourceTree->GetSelection();
+  if (sel != 0)
+  {
+    wxItemResource *res = (wxItemResource *)m_editorResourceTree->GetItemData(sel);
+    wxWindow *win = FindWindowForResource(res);
+    if (win)
+    {
+        DeleteResource(win);
+        DeleteWindow(win);
+        UpdateResourceList();
+        Modify(TRUE);
+    }
+    return TRUE;
   }
 
   return FALSE;
 }
 
 // Delete resource highlighted in the listbox
-bool wxResourceManager::RecreateSelection(void)
+bool wxResourceManager::RecreateSelection()
 {
   wxNode *node = GetSelections().First();
   while (node)
@@ -1533,74 +1816,13 @@ bool wxResourceManager::EditDialog(wxDialog *dialog, wxWindow *parent)
   return FALSE;
 }
 
-void wxResourceManager::SetEditMode(bool flag, bool changeCurrentResource)
-{
-  editMode = flag;
-  if (editorFrame)
-    editorFrame->SetStatusText(editMode ? "Edit mode" : "Test mode", 1);
-
-  // Switch mode for each dialog in the resource list
-  resourceTable.BeginFind();
-  wxNode *node = resourceTable.Next();
-  while (node)
-  {
-    wxItemResource *resource = (wxItemResource *)node->Data();
-    wxWindow *currentResourceWindow = FindWindowForResource(resource);
-  
-    if (changeCurrentResource && currentResourceWindow && (currentResourceWindow->IsKindOf(CLASSINFO(wxPanel))))
-    {
-      wxPanel *panel = (wxPanel *)currentResourceWindow;
-      if (editMode)
-      {
-        // If we have already installed our own handler, don't bother editing.
-        // This test will need to be changed eventually because for in-situ editing,
-        // the user might have installed a different one anyway.
-        wxEvtHandler *handler = panel->GetEventHandler();
-           handler->SetEvtHandlerEnabled(TRUE);
-        // Enable all children
-        wxNode *node = panel->GetChildren()->First();
-        while (node)
-        {
-          wxControl *item = (wxControl *)node->Data();
-                 if ( item->IsKindOf(CLASSINFO(wxControl)) )
-                 {
-               wxEvtHandler *childHandler = item->GetEventHandler();
-                       childHandler->SetEvtHandlerEnabled(TRUE);
-                 }
-          node = node->Next();
-        }
-      }
-      else
-      {
-        wxEvtHandler *handler = panel->GetEventHandler();
-               handler->SetEvtHandlerEnabled(FALSE);
-        // Deselect all items on the dialog and refresh.
-        wxNode *node = panel->GetChildren()->First();
-        while (node)
-        {
-          wxControl *item = (wxControl *)node->Data();
-          if (item->IsKindOf(CLASSINFO(wxControl)))
-             {
-                    wxResourceEditorControlHandler *childHandler = (wxResourceEditorControlHandler *)item->GetEventHandler();
-                    childHandler->SetEvtHandlerEnabled(FALSE);
-             childHandler->SelectItem(FALSE);
-                 }
-          node = node->Next();
-        }
-        panel->Refresh();
-      }
-    }
-    node = resourceTable.Next();
-  }
-}
-
 // Ensures that all currently shown windows are saved to resources,
 // e.g. just before writing to a .wxr file.
-bool wxResourceManager::InstantiateAllResourcesFromWindows(void)
+bool wxResourceManager::InstantiateAllResourcesFromWindows()
 {
-  resourceTable.BeginFind();
+  m_resourceTable.BeginFind();
   wxNode *node;
-  while (node = resourceTable.Next())
+  while (node = m_resourceTable.Next())
   {
     wxItemResource *res = (wxItemResource *)node->Data();
     wxString resType(res->GetType());
@@ -1623,7 +1845,7 @@ bool wxResourceManager::InstantiateAllResourcesFromWindows(void)
 
 bool wxResourceManager::InstantiateResourceFromWindow(wxItemResource *resource, wxWindow *window, bool recurse)
 {
-  wxWindowPropertyInfo *info = wxCreatePropertyInfoForWindow(window);
+  wxWindowPropertyInfo *info = CreatePropertyInfoForWindow(window);
   info->SetResource(resource);
   info->InstantiateResource(resource);
   delete info;
@@ -1651,114 +1873,227 @@ bool wxResourceManager::InstantiateResourceFromWindow(wxItemResource *resource,
   return TRUE;
 }
 
+// Create a window information object for the give window
+wxWindowPropertyInfo *wxResourceManager::CreatePropertyInfoForWindow(wxWindow *win)
+{
+  wxWindowPropertyInfo *info = NULL;
+  if (win->IsKindOf(CLASSINFO(wxScrollBar)))
+        {
+          info = new wxScrollBarPropertyInfo(win);
+        }
+  else if (win->IsKindOf(CLASSINFO(wxStaticBox)))
+        {
+          info = new wxGroupBoxPropertyInfo(win);
+        }
+  else if (win->IsKindOf(CLASSINFO(wxCheckBox)))
+        {
+          info = new wxCheckBoxPropertyInfo(win);
+        }
+  else if (win->IsKindOf(CLASSINFO(wxSlider)))
+        {
+          info = new wxSliderPropertyInfo(win);
+        }
+  else if (win->IsKindOf(CLASSINFO(wxGauge)))
+        {
+          info = new wxGaugePropertyInfo(win);
+        }
+  else if (win->IsKindOf(CLASSINFO(wxListBox)))
+        {
+          info = new wxListBoxPropertyInfo(win);
+        }
+  else if (win->IsKindOf(CLASSINFO(wxRadioBox)))
+        {
+          info = new wxRadioBoxPropertyInfo(win);
+        }
+  else if (win->IsKindOf(CLASSINFO(wxRadioButton)))
+        {
+          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)))
+        {
+          info = new wxButtonPropertyInfo(win);
+        }
+  else if (win->IsKindOf(CLASSINFO(wxBitmapButton)))
+        {
+          info = new wxBitmapButtonPropertyInfo(win);
+        }
+  else if (win->IsKindOf(CLASSINFO(wxStaticText)))
+        {
+          info = new wxStaticTextPropertyInfo(win);
+        }
+  else if (win->IsKindOf(CLASSINFO(wxStaticBitmap)))
+        {
+          info = new wxStaticBitmapPropertyInfo(win);
+        }
+  else if (win->IsKindOf(CLASSINFO(wxTextCtrl)))
+        {
+          info = new wxTextPropertyInfo(win);
+        }
+  else if (win->IsKindOf(CLASSINFO(wxPanel)))
+        {
+          info = new wxPanelPropertyInfo(win);
+        }
+  else
+        {
+          info = new wxWindowPropertyInfo(win);
+        }
+  return info;
+}
+
+// Edit the given window
+void wxResourceManager::EditWindow(wxWindow *win)
+{
+  wxWindowPropertyInfo *info = CreatePropertyInfoForWindow(win);
+  if (info)
+  {
+    info->SetResource(FindResourceForWindow(win));
+    wxString str("Editing ");
+    str += win->GetClassInfo()->GetClassName();
+    str += ": ";
+    if (win->GetName() != "")
+        str += win->GetName();
+    else
+        str += "properties";
+    info->Edit(NULL, str);
+  }
+}
+
+// Generate a window id and a first stab at a name
+int wxResourceManager::GenerateWindowId(const wxString& prefix, wxString& idName)
+{
+    m_symbolIdCounter ++;
+    while (m_symbolTable.IdExists(m_symbolIdCounter))
+        m_symbolIdCounter ++;
+
+    int nameId = m_symbolIdCounter;
+
+    wxString str;
+    str.Printf("%d", nameId);
+    idName = prefix + str;
+
+    while (m_symbolTable.SymbolExists(idName))
+    {
+        nameId ++;
+        str.Printf("%d", nameId);
+        idName = prefix + str;
+    }
+
+    return m_symbolIdCounter;
+}
+
 
 /*
  * Resource editor frame
  */
-wxResourceEditorFrame::wxResourceEditorFrame(wxResourceManager *resMan, wxFrame *parent, char *title,
-    int x, int y, int width, int height, long style, char *name):
-  wxFrame(parent, -1, title, wxPoint(x, y), wxSize(width, height), style, name)
+
+IMPLEMENT_CLASS(wxResourceEditorFrame, wxFrame)
+
+BEGIN_EVENT_TABLE(wxResourceEditorFrame, wxFrame)
+    EVT_MENU(wxID_NEW, wxResourceEditorFrame::OnNew)
+    EVT_MENU(RESED_NEW_DIALOG, wxResourceEditorFrame::OnNewDialog)
+    EVT_MENU(wxID_OPEN, wxResourceEditorFrame::OnOpen)
+    EVT_MENU(RESED_CLEAR, wxResourceEditorFrame::OnClear)
+    EVT_MENU(wxID_SAVE, wxResourceEditorFrame::OnSave)
+    EVT_MENU(wxID_SAVEAS, wxResourceEditorFrame::OnSaveAs)
+    EVT_MENU(wxID_EXIT, wxResourceEditorFrame::OnExit)
+    EVT_MENU(wxID_ABOUT, wxResourceEditorFrame::OnAbout)
+    EVT_MENU(RESED_CONTENTS, wxResourceEditorFrame::OnContents)
+    EVT_MENU(RESED_DELETE, wxResourceEditorFrame::OnDeleteSelection)
+    EVT_MENU(RESED_RECREATE, wxResourceEditorFrame::OnRecreateSelection)
+    EVT_MENU(RESED_TEST, wxResourceEditorFrame::OnTest)
+END_EVENT_TABLE()
+
+wxResourceEditorFrame::wxResourceEditorFrame(wxResourceManager *resMan, wxFrame *parent, const wxString& title,
+    const wxPoint& pos, const wxSize& size, long style, const wxString& name):
+  wxFrame(parent, -1, title, pos, size, style, name)
 {
   manager = resMan;
 }
 
-wxResourceEditorFrame::~wxResourceEditorFrame(void)
+wxResourceEditorFrame::~wxResourceEditorFrame()
 {
 }
 
-void wxResourceEditorFrame::OldOnMenuCommand(int cmd)
+void wxResourceEditorFrame::OnNew(wxCommandEvent& WXUNUSED(event))
 {
-  switch (cmd)
-  {
-    case wxID_NEW:
-    {
       manager->New(FALSE);
-      break;
-    }
-    case RESED_NEW_DIALOG:
-    {
-      manager->CreateNewDialog();
-      break;
-    }
-    case RESED_NEW_PANEL:
-    {
+}
+
+void wxResourceEditorFrame::OnNewDialog(wxCommandEvent& WXUNUSED(event))
+{
       manager->CreateNewPanel();
-      break;
-    }
-    case wxID_OPEN:
-    {
+}
+
+void wxResourceEditorFrame::OnOpen(wxCommandEvent& WXUNUSED(event))
+{
       manager->New(TRUE);
-      break;
-    }
-    case RESED_CLEAR:
-    {
+}
+
+void wxResourceEditorFrame::OnClear(wxCommandEvent& WXUNUSED(event))
+{
       manager->Clear(TRUE, FALSE);
-      break;
-    }
-    case wxID_SAVE:
-    {
+}
+
+void wxResourceEditorFrame::OnSave(wxCommandEvent& WXUNUSED(event))
+{
       manager->Save();
-      break;
-    }
-    case wxID_SAVEAS:
-    {
+}
+
+void wxResourceEditorFrame::OnSaveAs(wxCommandEvent& WXUNUSED(event))
+{
       manager->SaveAs();
-      break;
-    }
-    case wxID_EXIT:
-    {
+}
+
+void wxResourceEditorFrame::OnExit(wxCommandEvent& WXUNUSED(event))
+{
          manager->Clear(TRUE, FALSE) ;
       this->Close();
-      break;
-    }
-    case wxID_ABOUT:
-    {
+}
+
+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);
-      (void)wxMessageBox(buf, "About Dialog Editor", wxOK|wxCENTRE);
-      break;
-    }
-    case RESED_CONTENTS:
-    {
+      wxMessageBox(buf, "About Dialog Editor", wxOK|wxCENTRE);
+}
+
+void wxResourceEditorFrame::OnTest(wxCommandEvent& WXUNUSED(event))
+{
+    manager->TestCurrentDialog(this);
+}
+
+void wxResourceEditorFrame::OnContents(wxCommandEvent& WXUNUSED(event))
+{
+#ifdef __WXMSW__
       wxBeginBusyCursor();
-      manager->GetHelpInstance()->LoadFile();
-      manager->GetHelpInstance()->DisplayContents();
+      manager->GetHelpController()->LoadFile();
+      manager->GetHelpController()->DisplayContents();
       wxEndBusyCursor();
-      break;
-    }
-    case RESED_DELETE:
-    {
+#endif
+}
+
+void wxResourceEditorFrame::OnDeleteSelection(wxCommandEvent& WXUNUSED(event))
+{
       manager->DeleteSelection();
-      break;
-    }
-    case RESED_RECREATE:
-    {
+}
+
+void wxResourceEditorFrame::OnRecreateSelection(wxCommandEvent& WXUNUSED(event))
+{
       manager->RecreateSelection();
-      break;
-    }
-    case RESED_TOGGLE_TEST_MODE:
-    {
-      manager->SetEditMode(!manager->GetEditMode());
-      break;
-    }
-    default:
-      break;
-  }
 }
 
-bool wxResourceEditorFrame::OnClose(void)
+bool wxResourceEditorFrame::OnClose()
 {
   if (manager->Modified())
   {
-/*
-    int ans = wxMessageBox("Save modified resource file?", "Dialog Editor", wxYES_NO | wxCANCEL);
-    if (ans == wxCANCEL)
-      return FALSE;
-    if (ans == wxYES)
-      if (!manager->SaveIfModified())
-        return FALSE;
-*/
   if (!manager->Clear(TRUE, FALSE))
      return FALSE;
   }
@@ -1767,45 +2102,83 @@ bool wxResourceEditorFrame::OnClose(void)
   {
     int w, h;
     GetSize(&w, &h);
-    manager->resourceEditorWindowSize.width = w;
-    manager->resourceEditorWindowSize.height = h;
+    manager->m_resourceEditorWindowSize.width = w;
+    manager->m_resourceEditorWindowSize.height = h;
 
     int x, y;
     GetPosition(&x, &y);
 
-    manager->resourceEditorWindowSize.x = x;
-    manager->resourceEditorWindowSize.y = y;
+    manager->m_resourceEditorWindowSize.x = x;
+    manager->m_resourceEditorWindowSize.y = y;
   }
   manager->SetEditorFrame(NULL);
   manager->SetEditorToolBar(NULL);
-  manager->SetEditorPalette(NULL);
 
   return TRUE;
 }
 
 /*
- * Resource editor panel
+ * Resource editor window that contains the dialog/panel being edited
  */
-wxResourceEditorPanel::wxResourceEditorPanel(wxWindow *parent, int x, int y, int width, int height,
-    long style, char *name):
-  wxPanel(parent, -1, wxPoint(x, y), wxSize(width, height), style, name)
+
+BEGIN_EVENT_TABLE(wxResourceEditorScrolledWindow, wxScrolledWindow)
+    EVT_SCROLL(wxResourceEditorScrolledWindow::OnScroll)
+    EVT_PAINT(wxResourceEditorScrolledWindow::OnPaint)
+END_EVENT_TABLE()
+
+wxResourceEditorScrolledWindow::wxResourceEditorScrolledWindow(wxWindow *parent, const wxPoint& pos, const wxSize& size,
+    long style):
+  wxScrolledWindow(parent, -1, pos, size, style)
 {
+    m_marginX = 10;
+    m_marginY = 40;
+    m_childWindow = NULL;
 }
 
-wxResourceEditorPanel::~wxResourceEditorPanel(void)
+wxResourceEditorScrolledWindow::~wxResourceEditorScrolledWindow()
 {
 }
 
-void wxResourceEditorPanel::OnDefaultAction(wxControl *item)
+void wxResourceEditorScrolledWindow::OnScroll(wxScrollEvent& event)
 {
-  wxResourceEditorFrame *frame = (wxResourceEditorFrame *)GetParent();
-  wxResourceManager *manager = frame->manager;
+    wxScrolledWindow::OnScroll(event);
 
-  if (item == manager->GetEditorResourceList())
-  {
-    manager->EditSelectedResource();
-  }
+    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))
+{
+    wxPaintDC dc(this);
+
+    DrawTitle(dc);
+}
+
+void wxResourceEditorScrolledWindow::DrawTitle(wxDC& dc)
+{
+    if (m_childWindow)
+    {
+        wxItemResource* res = wxResourceManager::GetCurrentResourceManager()->FindResourceForWindow(m_childWindow);
+        if (res)
+        {
+            wxString str(res->GetTitle());
+            int x, y;
+            ViewStart(& x, & y);
+
+            wxFont font(10, wxSWISS, wxNORMAL, wxBOLD);
+            dc.SetFont(font);
+            dc.SetBackgroundMode(wxTRANSPARENT);
+            dc.SetTextForeground(wxColour(0, 0, 0));
+
+            long w, h;
+            dc.GetTextExtent(str, & w, & h);
+
+            dc.DrawText(str, m_marginX + (- x * 10), m_marginY + (- y * 10) - h - 5);
+        }
+    }
 }
 
 // Popup menu callback
@@ -1819,12 +2192,14 @@ void ObjectMenuProc(wxMenu& menu, wxCommandEvent& event)
   {
     case OBJECT_MENU_EDIT:
     {
-      wxResourceEditWindow(data);
+      wxResourceManager::GetCurrentResourceManager()->EditWindow(data);
       break;
     }
     case OBJECT_MENU_DELETE:
     {
-      wxResourceManager::currentResourceManager->DeleteResource(data);
+      wxResourceManager::GetCurrentResourceManager()->SaveInfoAndDeleteHandler(data);
+      wxResourceManager::GetCurrentResourceManager()->DeleteResource(data);
+      wxResourceManager::GetCurrentResourceManager()->DeleteWindow(data);
       break;
     }
     default:
@@ -1832,126 +2207,34 @@ void ObjectMenuProc(wxMenu& menu, wxCommandEvent& event)
   }
 }
 
-wxWindowPropertyInfo *wxCreatePropertyInfoForWindow(wxWindow *win)
-{
-  wxWindowPropertyInfo *info = NULL;
-  if (win->IsKindOf(CLASSINFO(wxScrollBar)))
-        {
-          info = new wxScrollBarPropertyInfo(win);
-        }
-  else if (win->IsKindOf(CLASSINFO(wxStaticBox)))
-        {
-          info = new wxGroupBoxPropertyInfo(win);
-        }
-  else if (win->IsKindOf(CLASSINFO(wxCheckBox)))
-        {
-          info = new wxCheckBoxPropertyInfo(win);
-        }
-  else if (win->IsKindOf(CLASSINFO(wxSlider)))
-        {
-          info = new wxSliderPropertyInfo(win);
-        }
-  else if (win->IsKindOf(CLASSINFO(wxGauge)))
-        {
-          info = new wxGaugePropertyInfo(win);
-        }
-  else if (win->IsKindOf(CLASSINFO(wxListBox)))
-        {
-          info = new wxListBoxPropertyInfo(win);
-        }
-  else if (win->IsKindOf(CLASSINFO(wxRadioBox)))
-        {
-          info = new wxRadioBoxPropertyInfo(win);
-        }
-  else if (win->IsKindOf(CLASSINFO(wxChoice)))
-        {
-          info = new wxChoicePropertyInfo(win);
-        }
-  else if (win->IsKindOf(CLASSINFO(wxButton)))
-        {
-          info = new wxButtonPropertyInfo(win);
-/*
-          if (((wxButton *)win)->IsBitmap())
-            ((wxButtonPropertyInfo *)info)->isBitmapButton = TRUE;
-*/
-        }
-  else if (win->IsKindOf(CLASSINFO(wxStaticText)))
-        {
-          info = new wxStaticTextPropertyInfo(win);
-/*
-          if (((wxMessage *)win)->IsBitmap())
-            ((wxMessagePropertyInfo *)info)->isBitmapMessage = TRUE;
-*/
-        }
-  else if (win->IsKindOf(CLASSINFO(wxTextCtrl)))
-        {
-          info = new wxTextPropertyInfo(win);
-        }
-  else if (win->IsKindOf(CLASSINFO(wxDialog)))
-        {
-          info = new wxDialogPropertyInfo(win);
-        }
-  else if (win->IsKindOf(CLASSINFO(wxPanel)))
-        {
-          info = new wxPanelPropertyInfo(win);
-        }
-  else
-        {
-          info = new wxWindowPropertyInfo(win);
-        }
-  return info;
-}
-
-// Popup menu callback
-void wxResourceEditWindow(wxWindow *win)
-{
-  wxWindowPropertyInfo *info = wxCreatePropertyInfoForWindow(win);
-  if (info)
-  {
-    info->SetResource(wxResourceManager::currentResourceManager->FindResourceForWindow(win));
-    wxString str("Editing ");
-    str += win->GetClassInfo()->GetClassName();
-    str += ": ";
-    if (win->GetName() != "")
-        str += win->GetName();
-    else
-        str += "properties";
-    info->Edit(NULL, WXSTRINGCAST str);
-    delete info;
-  }
-}
-
 /*
  * Main toolbar
  *
  */
 
-#if defined(__WINDOWS__) && defined(__WIN95__)
-BEGIN_EVENT_TABLE(EditorToolBar, wxToolBar95)
-#elif defined(__WINDOWS__)
-BEGIN_EVENT_TABLE(EditorToolBar, wxToolBarMSW)
+#ifdef __WXGTK__   // I don't dare to delete it...
+BEGIN_EVENT_TABLE(EditorToolBar, wxToolBar)
+END_EVENT_TABLE()
+
 #else
-BEGIN_EVENT_TABLE(EditorToolBar, wxToolBarSimple)
-#endif
+
+BEGIN_EVENT_TABLE(EditorToolBar, wxToolBar)
        EVT_PAINT(EditorToolBar::OnPaint)
 END_EVENT_TABLE()
 
-EditorToolBar::EditorToolBar(wxFrame *frame, int x, int y, int w, int h,
-            long style, int direction, int RowsOrColumns):
-#if defined(__WINDOWS__) && defined(__WIN95__)
-  wxToolBar95(frame, -1, wxPoint(x, y), wxSize(w, h), style, direction, RowsOrColumns)
-#elif defined(__WINDOWS__)
-  wxToolBarMSW(frame, -1, wxPoint(x, y), wxSize(w, h), style, direction, RowsOrColumns)
-#else
-  wxToolBarSimple(frame, -1, wxPoint(x, y), wxSize(w, h), style, direction, RowsOrColumns)
 #endif
+
+EditorToolBar::EditorToolBar(wxFrame *frame, const wxPoint& pos, const wxSize& size,
+            long style):
+  wxToolBar(frame, -1, pos, size, style)
 {
 }
 
 bool EditorToolBar::OnLeftClick(int toolIndex, bool toggled)
 {
-  wxResourceManager *manager = wxResourceManager::currentResourceManager;
-  
+  wxResourceManager *manager = wxResourceManager::GetCurrentResourceManager();
+
   switch (toolIndex)
   {
     case TOOLBAR_LOAD_FILE:
@@ -1961,7 +2244,7 @@ bool EditorToolBar::OnLeftClick(int toolIndex, bool toggled)
     }
     case TOOLBAR_NEW:
     {
-      manager->New(FALSE);
+      manager->CreateNewPanel();
       break;
     }
     case TOOLBAR_SAVE_FILE:
@@ -1971,10 +2254,12 @@ bool EditorToolBar::OnLeftClick(int toolIndex, bool toggled)
     }
     case TOOLBAR_HELP:
     {
+#ifdef __WXMSW__
       wxBeginBusyCursor();
-      manager->GetHelpInstance()->LoadFile();
-      manager->GetHelpInstance()->DisplayContents();
+      manager->GetHelpController()->LoadFile();
+      manager->GetHelpController()->DisplayContents();
       wxEndBusyCursor();
+#endif
       break;
     }
     case TOOLBAR_FORMAT_HORIZ:
@@ -2084,31 +2369,3 @@ void EditorToolBar::OnMouseEnter(int toolIndex)
   else frame->SetStatusText("");
 }
 
-void EditorToolBar::OnPaint(wxPaintEvent& event)
-{
-#if defined(__WINDOWS__) && defined(__WIN95__)
-  wxToolBar95::OnPaint(event);
-#elif defined(__WINDOWS__)
-  wxToolBarMSW::OnPaint(event);
-#else
-  wxToolBarSimple::OnPaint(event);
-#endif
-
-  wxPaintDC dc(this);
-  int w, h;
-  GetSize(&w, &h);
-  dc.SetPen(wxBLACK_PEN);
-  dc.SetBrush(wxTRANSPARENT_BRUSH);
-  dc.DrawLine(0, h-1, w, h-1);
-}
-
-/*
- * Frame for editing a panel in
- */
-bool DialogEditorPanelFrame::OnClose(void)
-{
-  wxWindow *child = (wxWindow *)GetChildren()->First()->Data();
-  wxEvtHandler *handler = child->GetEventHandler();
-  return handler->OnClose();
-}