]> git.saurik.com Git - wxWidgets.git/commitdiff
reworked the editor
authorVáclav Slavík <vslavik@fastmail.fm>
Sat, 4 Nov 2000 23:34:33 +0000 (23:34 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Sat, 4 Nov 2000 23:34:33 +0000 (23:34 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8687 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

26 files changed:
contrib/utils/wxrcedit/Makefile.in
contrib/utils/wxrcedit/edapp.cpp
contrib/utils/wxrcedit/editor.cpp
contrib/utils/wxrcedit/editor.h
contrib/utils/wxrcedit/makefile.b32
contrib/utils/wxrcedit/makefile.g95
contrib/utils/wxrcedit/makefile.vc
contrib/utils/wxrcedit/makefile.wat
contrib/utils/wxrcedit/nodehnd.cpp
contrib/utils/wxrcedit/nodehnd.h
contrib/utils/wxrcedit/nodesdb.cpp [new file with mode: 0644]
contrib/utils/wxrcedit/nodesdb.h [new file with mode: 0644]
contrib/utils/wxrcedit/pe_adv.cpp [new file with mode: 0644]
contrib/utils/wxrcedit/pe_adv.h [new file with mode: 0644]
contrib/utils/wxrcedit/pe_basic.cpp [new file with mode: 0644]
contrib/utils/wxrcedit/pe_basic.h [new file with mode: 0644]
contrib/utils/wxrcedit/propedit.cpp [new file with mode: 0644]
contrib/utils/wxrcedit/propedit.h [new file with mode: 0644]
contrib/utils/wxrcedit/propframe.cpp [new file with mode: 0644]
contrib/utils/wxrcedit/propframe.h [new file with mode: 0644]
contrib/utils/wxrcedit/prophnd.cpp [deleted file]
contrib/utils/wxrcedit/prophnd.h [deleted file]
contrib/utils/wxrcedit/splittree.cpp [new file with mode: 0644]
contrib/utils/wxrcedit/splittree.h [new file with mode: 0644]
contrib/utils/wxrcedit/xmlhelpr.cpp
contrib/utils/wxrcedit/xmlhelpr.h

index d369563d09f2af30c7b5555fcd1ddcd6bfbf53f6..64a7eba674e1b06d5836ac2d1e29abe280b92e2b 100644 (file)
@@ -6,7 +6,8 @@ program_dir = contrib/utils/wxrcedit
 
 PROGRAM=wxrcedit
 
-OBJECTS=edapp.o editor.o nodehnd.o prophnd.o xmlhelpr.o preview.o
+OBJECTS=edapp.o editor.o nodehnd.o xmlhelpr.o preview.o nodesdb.o \
+        pe_basic.o pe_adv.o propedit.o propframe.o splittree.o
 
 DATADIRS = df
 DATAFILES = df/break.df df/control.df df/menu_item.df df/notebookpage.df \
index 2ad0a59b05e04ecab02272d8d60d02ad30a2bceb..3adb61a1c7bf95c69924256d3623189d4855cbde 100644 (file)
@@ -30,7 +30,8 @@
 #include "wx/wx.h"
 
 #include "editor.h"
-
+#include "preview.h"
+#include "propframe.h"
 
 
 // -- Application
@@ -51,6 +52,8 @@ bool MyApp::OnInit()
     wxFrame *frame = new EditorFrame(NULL, arg);
     SetTopWindow(frame);
     frame->Show(TRUE);
+    PreviewFrame::Get()->Show(TRUE);
+    PropertiesFrame::Get()->Show(TRUE);
     return TRUE;
 }
 
index c48887b89d2b0874e8b5e9b670957da2d4b2ddc2..c340043ff1a7420950ee2e8f009d6fcd0f695df7 100644 (file)
@@ -32,6 +32,7 @@
 #include "nodehnd.h"
 #include "xmlhelpr.h"
 #include "preview.h"
+#include "propframe.h"
 
 
 
@@ -73,11 +74,6 @@ enum
     ID_DELETE_NODE,
     ID_EXIT,
     ID_TREE,    
-    ID_XMLIDEDIT,
-    ID_XMLIDPICK,
-    ID_EDITCODE,
-    ID_PROPSLIST,
-    ID_CLEARPROP,
     
     ID_CUT,
     ID_PASTE_SYBLING,
@@ -89,8 +85,8 @@ enum
     ID_NEWMENU,
     ID_NEWMENUBAR,
     ID_NEWTOOLBAR,   
-    ID_NEWNODE = wxID_HIGHEST + 1000,
-    ID_NEWSYBNODE = ID_NEWNODE + 2000
+    ID_NEWNODE = wxID_HIGHEST + 10000, // safely out of XMLID range :)
+    ID_NEWSYBNODE = ID_NEWNODE + 20000
 };
 
 
@@ -102,11 +98,6 @@ BEGIN_EVENT_TABLE(EditorFrame, wxFrame)
     EVT_TOOL_RANGE(ID_PREVIEW, ID_EXIT, EditorFrame::OnToolbar)
     EVT_MENU_RANGE(ID_NEWDIALOG, ID_NEWSYBNODE + 1000, EditorFrame::OnNewNode)
     EVT_MENU_RANGE(ID_CUT, ID_COPY, EditorFrame::OnClipboardAction)
-    EVT_TEXT(ID_XMLIDEDIT, EditorFrame::OnXMLIDEdit)
-    EVT_BUTTON(ID_XMLIDPICK, EditorFrame::OnXMLIDPick)
-    EVT_BUTTON(ID_EDITCODE, EditorFrame::OnEditCode)
-    EVT_BUTTON(ID_CLEARPROP, EditorFrame::OnClearProp)
-    EVT_LIST_ITEM_SELECTED(ID_PROPSLIST, EditorFrame::OnPropSel)
 END_EVENT_TABLE()
 
 
@@ -123,9 +114,6 @@ END_EVENT_TABLE()
 #include "bitmaps/panel.xpm"
 #include "bitmaps/gsizer.xpm"
 #include "bitmaps/resicon.xpm"
-
-#include "bitmaps/unused.xpm"
-#include "bitmaps/used.xpm"
 #endif
 
 
@@ -147,7 +135,6 @@ EditorFrame::EditorFrame(wxFrame *parent, const wxString& filename)
     m_SelectedNode = NULL;
     m_Resource = NULL;
     m_FileName = wxEmptyString;
-    m_SelectedProp = -1;
 
     wxMenu *menuFile = new wxMenu;
     menuFile->Append(ID_NEW, "&New");
@@ -172,21 +159,6 @@ EditorFrame::EditorFrame(wxFrame *parent, const wxString& filename)
     menuBar->Append(menuFile, "&File");
     menuBar->Append(menuEdit, "&Edit");
     SetMenuBar(menuBar);
-
-    // handlers:
-    m_Handlers.DeleteContents(TRUE);
-    RegisterHandlers(".");
-    RegisterHandlers("./df");
-    // if modifying, don't forget to modify other places --
-    // search for wxINSTALL_PREFIX in nodehnd.cpp
-#ifdef __UNIX__
-    RegisterHandlers(wxGetHomeDir() + "/.wxrcedit");
-    #ifdef wxINSTALL_PREFIX
-    RegisterHandlers(wxINSTALL_PREFIX "/share/wx/wxrcedit");
-    #endif
-#endif
-    // must stay last:
-    m_Handlers.Append(new NodeHandlerUnknown(this));
   
     // Create toolbar:
     wxToolBar *toolBar = CreateToolBar(wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT);
@@ -205,80 +177,20 @@ EditorFrame::EditorFrame(wxFrame *parent, const wxString& filename)
                        FALSE, -1, -1, (wxObject *) NULL,
                        _("Preview"));   
     toolBar -> Realize();
-    
-    // Create layout:    
-    wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
-    wxPanel *p = new wxPanel(this);
-    sizer->Add(p, 1, wxEXPAND);
-    wxSizer *sizer2 = new wxBoxSizer(wxVERTICAL);
-
-    m_Splitter = new wxSplitterWindow(p);
-    sizer2->Add(m_Splitter, 1, wxEXPAND);
-    
-
-    // Create tree control:
-    m_TreeCtrl = new EditorTreeCtrl(m_Splitter, ID_TREE, this);
-    m_ImgList = new wxImageList(16, 16);
-    m_ImgList->Add(wxICON(control));
-    m_ImgList->Add(wxICON(panel));
-    m_ImgList->Add(wxICON(vsizer));
-    m_ImgList->Add(wxICON(hsizer));
-    m_ImgList->Add(wxICON(gsizer));
-    m_ImgList->Add(wxICON(resicon));
-
-    m_TreeCtrl->SetImageList(m_ImgList);
-    
-    // Create properties panel:
-    m_Splitter2 = new wxSplitterWindow(m_Splitter);
-    m_PropsPanel = new wxPanel(m_Splitter2, -1, wxDefaultPosition,
-                           wxDefaultSize, wxTAB_TRAVERSAL);
 
-    wxSizer *sizer3 = new wxBoxSizer(wxVERTICAL);
+    wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
     
-    wxSizer *sz = new wxBoxSizer(wxHORIZONTAL);
-
-    sizer3->Add(new wxButton(m_PropsPanel, ID_EDITCODE, "Edit XML code"), 
-            0, wxALL | wxEXPAND, 2);
-    sz->Add(new wxStaticText(m_PropsPanel, -1, _("XMLID name:")),
-            0, wxLEFT | wxALIGN_CENTER_VERTICAL, 2);
-    m_XMLIDCtrl = new wxTextCtrl(m_PropsPanel, ID_XMLIDEDIT, "");
-    sz->Add(m_XMLIDCtrl, 1, wxLEFT|wxRIGHT, 2);
-    sz->Add(new wxButton(m_PropsPanel, ID_XMLIDPICK, "...", wxDefaultPosition, wxSize(16,-1)), 
-            0, wxRIGHT, 2);  
-    sizer3->Add(sz, 0, wxTOP|wxEXPAND, 2); 
-    
-    m_PropsList = new wxListCtrl(m_PropsPanel, ID_PROPSLIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL); 
-
-    m_ImgListProp = new wxImageList(16, 16);
-    m_ImgListProp->Add(wxICON(unused));
-    m_ImgListProp->Add(wxICON(used));
-    m_PropsList->SetImageList(m_ImgListProp, wxIMAGE_LIST_SMALL);
-
-    m_PropsList->InsertColumn(0, _("Property"));
-    m_PropsList->InsertColumn(1, _("Value"));
-    m_PropsList->SetColumnWidth(0, cfg->Read("editor_col0", wxLIST_AUTOSIZE_USEHEADER));
-    m_PropsList->SetColumnWidth(1, cfg->Read("editor_col1", wxLIST_AUTOSIZE_USEHEADER));
-
-    sizer3->Add(m_PropsList, 1, wxALL | wxEXPAND, 2);
-       
-    m_PropsPanel->SetAutoLayout(TRUE);
-    m_PropsPanel->SetSizer(sizer3);
-    m_PropsPanel->Layout();
-
-    m_PropsEditPanel = new wxScrolledWindow(m_Splitter2, -1, wxDefaultPosition,
-                           wxDefaultSize, wxTAB_TRAVERSAL);
-
-    m_Splitter->SplitVertically(m_TreeCtrl, m_Splitter2);
-    m_Splitter->SetSashPosition(cfg->Read("editor_sash", 140));
-
-    m_Splitter2->SplitHorizontally(m_PropsPanel, m_PropsEditPanel);
-    m_Splitter2->SetSashPosition(cfg->Read("editor_sash2", 100));
-                                      
-    p->SetAutoLayout(TRUE);
-    p->SetSizer(sizer2);
-
-
+    // Create tree control:
+    m_TreeCtrl = new EditorTreeCtrl(this, ID_TREE, this);
+    wxImageList *imgList = new wxImageList(16, 16);
+    imgList->Add(wxICON(control));
+    imgList->Add(wxICON(panel));
+    imgList->Add(wxICON(vsizer));
+    imgList->Add(wxICON(hsizer));
+    imgList->Add(wxICON(gsizer));
+    imgList->Add(wxICON(resicon));
+    m_TreeCtrl->AssignImageList(imgList);
+    sizer->Add(m_TreeCtrl, 1, wxEXPAND);
 
     SetAutoLayout(TRUE);
     SetSizer(sizer);
@@ -295,62 +207,20 @@ EditorFrame::EditorFrame(wxFrame *parent, const wxString& filename)
 EditorFrame::~EditorFrame()
 {
     PreviewFrame::Get()->Close();
+    PropertiesFrame::Get()->Close();
 
     wxConfigBase *cfg = wxConfigBase::Get();
     
-    cfg->Write("editor_x", (long)GetPosition().x);
-    cfg->Write("editor_y", (long)GetPosition().y);
-    cfg->Write("editor_w", (long)GetSize().x);
-    cfg->Write("editor_h", (long)GetSize().y);
-    cfg->Write("editor_sash", (long)m_Splitter->GetSashPosition());
-    cfg->Write("editor_sash2", (long)m_Splitter2->GetSashPosition());
-    cfg->Write("editor_col0", (long)m_PropsList->GetColumnWidth(0));
-    cfg->Write("editor_col1", (long)m_PropsList->GetColumnWidth(1));
-
-    delete m_ImgList;
-    delete m_ImgListProp;
-    RefreshProps(NULL);
-    
+    cfg->Write(_T("editor_x"), (long)GetPosition().x);
+    cfg->Write(_T("editor_y"), (long)GetPosition().y);
+    cfg->Write(_T("editor_w"), (long)GetSize().x);
+    cfg->Write(_T("editor_h"), (long)GetSize().y);
+
     delete m_Clipboard;
 }
 
 
 
-NodeHandler *EditorFrame::FindHandler(wxXmlNode *node)
-{
-    wxNode *n = m_Handlers.GetFirst();
-    while (n)
-    {
-        NodeHandler *h = (NodeHandler*) n->GetData();
-        if (h->CanHandle(node))
-            return h;
-        n = n->GetNext();
-    }
-    return NULL;
-}
-
-
-
-void EditorFrame::RegisterHandlers(const wxString& dirname)
-{
-    if (!wxDirExists(dirname)) return;
-    
-    wxDir dir(dirname);
-    wxString filename;
-    bool cont;
-    NodeHandler *hnd;
-    
-    cont = dir.GetFirst(&filename, "*.df");
-    while (cont)
-    {
-        hnd = NodeHandler::CreateFromFile(filename, this);
-        if (hnd) m_Handlers.Append(hnd);
-        cont = dir.GetNext(&filename);
-    }
-    
-}
-
-
 
 void EditorFrame::LoadFile(const wxString& filename)
 {
@@ -421,56 +291,6 @@ void EditorFrame::RefreshTree()
 }
 
 
-void EditorFrame::RefreshProps(wxXmlNode *node)
-{
-    m_SelectedProp = -1;
-    
-    for (int i = 0; i < m_PropsList->GetItemCount(); i++)
-        delete (wxObject*)(m_PropsList->GetItemData(i));   
-    
-    m_PropsList->DeleteAllItems();
-
-    if (node == NULL) return;
-    
-    m_XMLIDCtrl->SetValue(FindHandler(node)->GetRealNode(node)->
-                            GetPropVal("name", "-1"));
-    CreatePropsList(m_PropsList, node);
-
-    RefreshPropsEdit();
-}
-
-
-
-void EditorFrame::RefreshPropsEdit()
-{
-    m_PropsEditPanel->DestroyChildren();
-    m_PropsEditPanel->SetSizer(NULL);
-    
-    if (!m_SelectedNode || m_SelectedProp == -1 ||
-        m_PropsList->GetItemData(m_SelectedProp) == 0) return;
-    
-    wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
-    
-    sizer->Add(new wxButton(m_PropsEditPanel, ID_CLEARPROP, _("Clear")),
-               0, wxALL, 5);
-        
-    sizer->Add(
-                FindHandler(m_SelectedNode)->CreatePropEditPanel(m_PropsEditPanel, m_PropsList, m_SelectedProp),
-                1,  wxEXPAND, 0);
-    
-    m_PropsEditPanel->SetAutoLayout(TRUE);
-    m_PropsEditPanel->SetSizer(sizer);
-    m_PropsEditPanel->Layout();
-
-    wxSize winsz = m_PropsEditPanel->GetSize();
-    sizer->SetMinSize(winsz.x, winsz.y);
-    
-    wxSize minsz = sizer->GetMinSize();
-
-    m_PropsEditPanel->SetScrollbars(8, 8, 1/*minsz.x/8*/, minsz.y/8);
-}
-
-
 
 bool EditorFrame::SelectNode(wxXmlNode *node, wxTreeItemId *root)
 {
@@ -513,16 +333,7 @@ wxTreeItemId EditorFrame::CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId pare
         return invalid;
     }
 
-    return FindHandler(node)->CreateTreeNode(treectrl, parent, node);
-}
-
-
-
-void EditorFrame::CreatePropsList(wxListCtrl *treectrl, wxXmlNode *node)
-{
-    if (!node) return;
-
-    FindHandler(node)->CreatePropsList(treectrl, node);
+    return NodeHandler::Find(node)->CreateTreeNode(treectrl, parent, node);
 }
 
 
@@ -536,165 +347,54 @@ void EditorFrame::NotifyChanged(int change_type)
     {
         wxTreeItemId sel = m_TreeCtrl->GetSelection();
         m_TreeCtrl->SetItemText(sel, 
-             FindHandler(m_SelectedNode)->GetTreeString(m_SelectedNode));
+             NodeHandler::Find(m_SelectedNode)->GetTreeString(m_SelectedNode));
     }
 
     if (change_type & CHANGED_TREE_SELECTED_ICON)
     {
         wxTreeItemId sel = m_TreeCtrl->GetSelection();
-        int icon = FindHandler(m_SelectedNode)->GetTreeIcon(m_SelectedNode);
+        int icon = NodeHandler::Find(m_SelectedNode)->GetTreeIcon(m_SelectedNode);
         m_TreeCtrl->SetItemImage(sel, icon);
     }
-
-    if (change_type & CHANGED_PROPS_PANEL)
-        RefreshProps(m_SelectedNode);
 }
 
 
 
-void EditorFrame::OnTreeSel(wxTreeEvent& event)
+static void RecursivelyExpand(wxTreeCtrl *t, wxTreeItemId item)
 {
-    XmlTreeData *dt = (XmlTreeData*)(m_TreeCtrl->GetItemData(event.GetItem()));
-    wxXmlNode *node = (dt) ? dt->Node : NULL;
-        
-    m_SelectedNode = node;
-    RefreshProps(node);
-}
-
-
-
-void EditorFrame::OnXMLIDEdit(wxCommandEvent& event)
-{
-    if (!m_SelectedNode) return;
-    wxXmlNode *node = FindHandler(m_SelectedNode)->GetRealNode(m_SelectedNode);
-
-    node->DeleteProperty("name");
-    wxString s = m_XMLIDCtrl->GetValue();
-    if (!(s == "-1")) node->AddProperty("name", s);
-    NotifyChanged(CHANGED_TREE_SELECTED);
-}
-
-
-
-void EditorFrame::OnXMLIDPick(wxCommandEvent& event)
-{
-    if (!m_SelectedNode) return;
-    wxXmlNode *node = FindHandler(m_SelectedNode)->GetRealNode(m_SelectedNode);
-
-    wxString choices[] = {wxString("-1")
-    #define stdID(id) , wxString(#id)
-    stdID(wxID_OK) stdID(wxID_CANCEL)
-    stdID(wxID_YES) stdID(wxID_NO)
-    stdID(wxID_APPLY) stdID(wxID_HELP) 
-    stdID(wxID_HELP_CONTEXT)
-
-    stdID(wxID_OPEN) stdID(wxID_CLOSE) stdID(wxID_NEW)
-    stdID(wxID_SAVE) stdID(wxID_SAVEAS) stdID(wxID_REVERT)
-    stdID(wxID_EXIT) stdID(wxID_UNDO) stdID(wxID_REDO)
-    stdID(wxID_PRINT) stdID(wxID_PRINT_SETUP)
-    stdID(wxID_PREVIEW) stdID(wxID_ABOUT) stdID(wxID_HELP_CONTENTS)
-    stdID(wxID_HELP_COMMANDS) stdID(wxID_HELP_PROCEDURES)
-    stdID(wxID_CUT) stdID(wxID_COPY) stdID(wxID_PASTE)
-    stdID(wxID_CLEAR) stdID(wxID_FIND) stdID(wxID_DUPLICATE)
-    stdID(wxID_SELECTALL) 
-    stdID(wxID_STATIC) stdID(wxID_FORWARD) stdID(wxID_BACKWARD)
-    stdID(wxID_DEFAULT) stdID(wxID_MORE) stdID(wxID_SETUP)
-    stdID(wxID_RESET) 
-    #undef stdID
-    };
-
-    wxString s = 
-      wxGetSingleChoice(_("Choose from predefined IDs:"), _("XMLID"), 
-                        38/*sizeof choices*/, choices);
-    if (!s) return;
-
-    m_XMLIDCtrl->SetValue(s);
-    node->DeleteProperty("name");
-    if (!(s == "-1")) node->AddProperty("name", s);
-    NotifyChanged(CHANGED_TREE_SELECTED);
+    t->Expand(item);
+    long cookie;
+    wxTreeItemId id = t->GetFirstChild(item, cookie);
+    while (id.IsOk())
+    {
+        RecursivelyExpand(t, id);
+        id = t->GetNextChild(item, cookie);
+    }
 }
 
-
-
-void EditorFrame::OnEditCode(wxCommandEvent& event)
+void EditorFrame::OnTreeSel(wxTreeEvent& event)
 {
-    if (!m_SelectedNode) return;
-
-    wxBusyCursor bcur;
-    wxDialog dlg(this, -1, _("XML code editor"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
-    wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
-    wxTextCtrl *tc = new wxTextCtrl(&dlg, -1, "", wxDefaultPosition,
-                         wxDefaultSize, wxTE_MULTILINE);
-    sizer->Add(tc, 1, wxEXPAND | wxALL, 10);
-
-    wxSizer *sz2 = new wxBoxSizer(wxHORIZONTAL);
-
-    sz2->Add(new wxButton(&dlg, wxID_OK, _("Save")), 0);
-    sz2->Add(new wxButton(&dlg, wxID_CANCEL, _("Cancel")), 0, wxLEFT, 10);
-
-    sizer->Add(sz2, 0, wxALIGN_RIGHT | wxRIGHT|wxBOTTOM, 10);
-
-    dlg.SetAutoLayout(TRUE);
-    dlg.SetSizer(sizer);
-
-    wxConfigBase *cfg = wxConfigBase::Get();
-    
-    dlg.SetSize(wxRect(wxPoint(cfg->Read("xmleditor_x", -1), cfg->Read("xmleditor_y", -1)),
-            wxSize(cfg->Read("xmleditor_w", 400), cfg->Read("xmleditor_h", 400))));
-
-    wxString tempfile;
-    wxGetTempFileName("xmleditor", tempfile);
+    XmlTreeData *dt = (XmlTreeData*)(m_TreeCtrl->GetItemData(event.GetItem()));
+    wxXmlNode *node = (dt) ? dt->Node : NULL;      
+            
+    m_SelectedNode = node;
+    if (node)
+        PropertiesFrame::Get()->ShowProps(node);
 
+    if (m_TreeCtrl->GetParent(event.GetItem()) == m_TreeCtrl->GetRootItem())
     {
-        wxXmlDocument doc;
-        doc.SetRoot(new wxXmlNode(*m_SelectedNode));
-        doc.Save(tempfile, wxXML_IO_LIBXML);
-    }
-    tc->LoadFile(tempfile);
+        wxTreeItemId it = event.GetOldItem();
 
-    if (dlg.ShowModal() == wxID_OK)
-    {
-        tc->SaveFile(tempfile);
-        wxXmlDocument doc;
-        if (doc.Load(tempfile))
+        if (it.IsOk() && m_TreeCtrl->GetRootItem() != it)
         {
-            (*m_SelectedNode) = *doc.GetRoot();
-            NotifyChanged(CHANGED_TREE);
-            //FIXME-instead, regenerate only children
+            while (m_TreeCtrl->GetParent(it) != m_TreeCtrl->GetRootItem())
+                it = m_TreeCtrl->GetParent(it);
+            m_TreeCtrl->Collapse(it);
         }
-        else wxLogError(_("Illegal XML file, canceled."));
-    }
-    wxRemoveFile(tempfile);
+        RecursivelyExpand(m_TreeCtrl, event.GetItem());
 
-    cfg->Write("xmleditor_x", (long)dlg.GetPosition().x);
-    cfg->Write("xmleditor_y", (long)dlg.GetPosition().y);
-    cfg->Write("xmleditor_w", (long)dlg.GetSize().x);
-    cfg->Write("xmleditor_h", (long)dlg.GetSize().y);
-}
-
-
-
-void EditorFrame::OnClearProp(wxCommandEvent& event)
-{
-    m_PropsList->SetItemImage(m_SelectedProp, 0, 0);
-    m_PropsList->SetItem(m_SelectedProp, 1, "");
-    
-    PropsListInfo *pli = (PropsListInfo*)m_PropsList->GetItemData(m_SelectedProp);
-    
-    wxXmlNode *nd = XmlFindNode(pli->m_Node, pli->m_PropInfo->Name);
-    
-    if (nd == NULL) return;
-    nd->GetParent()->RemoveChild(nd);
-    delete nd;
-    RefreshPropsEdit();
-}
-
-
-
-void EditorFrame::OnPropSel(wxListEvent& event)
-{
-    m_SelectedProp = event.GetIndex();
-    RefreshPropsEdit();
+        PreviewFrame::Get()->Preview(node);
+    }
 }
 
 
@@ -721,7 +421,7 @@ void EditorFrame::OnToolbar(wxCommandEvent& event)
 
         case ID_OPEN :
             {
-            wxString name = wxFileSelector("Open XML resource", "", "", "", "XML resources|*.xml", wxOPEN | wxFILE_MUST_EXIST);
+            wxString name = wxFileSelector(_("Open XML resource"), _T(""), _T(""), _T(""), _("XML resources (*.xrc)|*.xrc"), wxOPEN | wxFILE_MUST_EXIST);
             if (!name.IsEmpty())
                 LoadFile(name);
             break;
@@ -733,7 +433,7 @@ void EditorFrame::OnToolbar(wxCommandEvent& event)
 
         case ID_SAVEAS :
             {
-            wxString name = wxFileSelector("Save as", "", m_FileName, "", "XML resources|*.xml", wxSAVE | wxOVERWRITE_PROMPT);
+            wxString name = wxFileSelector(_("Save as"), _T(""), m_FileName, _T(""), _("XML resources (*.xrc)|*.xrc"), wxSAVE | wxOVERWRITE_PROMPT);
             if (!name.IsEmpty())
                 SaveFile((m_FileName = name));
             break;
@@ -774,8 +474,8 @@ void EditorFrame::OnNewNode(wxCommandEvent& event)
         {
             wxXmlNode *nd = pardt->Node;
 
-            wxXmlNode *realnode = FindHandler(nd)->GetRealNode(nd);
-            NodeHandler *hnd = FindHandler(realnode);
+            wxXmlNode *realnode = NodeHandler::Find(nd)->GetRealNode(nd);
+            NodeHandler *hnd = NodeHandler::Find(realnode);
             wxString name = hnd->GetChildTypes()[event.GetId()-ID_NEWSYBNODE];
 
             wxXmlNode *node = new wxXmlNode(wxXML_ELEMENT_NODE, _T("object"));
@@ -790,8 +490,8 @@ void EditorFrame::OnNewNode(wxCommandEvent& event)
 
     else if (event.GetId() >= ID_NEWNODE)
     {
-        wxXmlNode *realnode = FindHandler(m_SelectedNode)->GetRealNode(m_SelectedNode);
-        NodeHandler *hnd = FindHandler(realnode);
+        wxXmlNode *realnode = NodeHandler::Find(m_SelectedNode)->GetRealNode(m_SelectedNode);
+        NodeHandler *hnd = NodeHandler::Find(realnode);
         wxString name = hnd->GetChildTypes()[event.GetId()-ID_NEWNODE];
 
         wxXmlNode *node = new wxXmlNode(wxXML_ELEMENT_NODE, _T("object"));
@@ -843,7 +543,7 @@ void EditorFrame::OnRightClickTree(wxPoint pos)
         bool has_children;
         {
             wxArrayString& arr = 
-                FindHandler(FindHandler(m_SelectedNode)->GetRealNode(m_SelectedNode))->
+                NodeHandler::Find(NodeHandler::Find(m_SelectedNode)->GetRealNode(m_SelectedNode))->
                     GetChildTypes();
 
             has_children = !arr.IsEmpty();
@@ -877,7 +577,7 @@ void EditorFrame::OnRightClickTree(wxPoint pos)
         {
             wxXmlNode *nd = pardt->Node;
             wxArrayString& arr = 
-                FindHandler(FindHandler(nd)->GetRealNode(nd))->
+                NodeHandler::Find(NodeHandler::Find(nd)->GetRealNode(nd))->
                     GetChildTypes();
 
             if (!arr.IsEmpty())
@@ -943,8 +643,8 @@ void EditorFrame::OnClipboardAction(wxCommandEvent& event)
             {
                 wxXmlNode *nd = pardt->Node;
 
-                wxXmlNode *realnode = FindHandler(nd)->GetRealNode(nd);
-                NodeHandler *hnd = FindHandler(realnode);
+                wxXmlNode *realnode = NodeHandler::Find(nd)->GetRealNode(nd);
+                NodeHandler *hnd = NodeHandler::Find(realnode);
                 wxXmlNode *node = new wxXmlNode(*m_Clipboard);
                 hnd->InsertNode(realnode, node, m_SelectedNode);
                 wxTreeItemId root = m_TreeCtrl->GetSelection();
@@ -954,8 +654,8 @@ void EditorFrame::OnClipboardAction(wxCommandEvent& event)
             break;
             
         case ID_PASTE_CHILD:
-            wxXmlNode *realnode = FindHandler(m_SelectedNode)->GetRealNode(m_SelectedNode);
-            NodeHandler *hnd = FindHandler(realnode);
+            wxXmlNode *realnode = NodeHandler::Find(m_SelectedNode)->GetRealNode(m_SelectedNode);
+            NodeHandler *hnd = NodeHandler::Find(realnode);
             wxXmlNode *node = new wxXmlNode(*m_Clipboard);
             hnd->InsertNode(realnode, node);
             wxTreeItemId root = m_TreeCtrl->GetSelection();
index 442e95f1b92d849ad3c25b1ffd8edc978c87dbf7..bb1d365c79d6e7bebf5eacbf17c60011d392d093 100644 (file)
@@ -61,35 +61,19 @@ class EditorFrame : public wxFrame
         wxString GetFileName() { return m_FileName; }
         
         void RefreshTree();
-        void RefreshProps(wxXmlNode *node);
-        void RefreshPropsEdit();
         bool SelectNode(wxXmlNode *node, wxTreeItemId *root = NULL);
         
         wxTreeItemId CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId parent, wxXmlNode *node);
-        void CreatePropsList(wxListCtrl *listctrl, wxXmlNode *node);
   
         void NotifyChanged(int change_type);
         
-        void RegisterHandlers(const wxString& dir);
-        
-        NodeHandler *FindHandler(wxXmlNode *node);
-        
         static EditorFrame *Get() { return ms_Instance; }
         
     private:
         static EditorFrame *ms_Instance;
     
         wxTreeCtrl *m_TreeCtrl;
-        wxTextCtrl *m_XMLIDCtrl;
-        wxImageList *m_ImgList, *m_ImgListProp;
-        wxPanel *m_PropsPanel;
-        wxScrolledWindow *m_PropsEditPanel;
-        wxSplitterWindow *m_Splitter, *m_Splitter2;
-        wxListCtrl *m_PropsList;
-        int m_SelectedProp;
         
-        wxList m_Handlers;
-
         wxXmlNode *m_SelectedNode;
         
         wxXmlNode *m_Clipboard;
@@ -101,11 +85,6 @@ class EditorFrame : public wxFrame
         void OnTreeSel(wxTreeEvent& event);
         void OnToolbar(wxCommandEvent& event);
         void OnNew(wxCommandEvent& event);
-        void OnXMLIDEdit(wxCommandEvent& event);
-        void OnXMLIDPick(wxCommandEvent& event);
-        void OnEditCode(wxCommandEvent& event);
-        void OnClearProp(wxCommandEvent& event);
-        void OnPropSel(wxListEvent& event);
         void OnNewNode(wxCommandEvent& event);
         void OnRightClickTree(wxPoint pos);
         void OnClipboardAction(wxCommandEvent& event);
index 928e48e53a9d78b14c184b82ef9bbbe56d93a6ad..590503233cb0ca9415847feec936826997493c46 100644 (file)
@@ -11,7 +11,8 @@ WXDIR = $(WXWIN)
 
 TARGET=wxrcedit
 EXTRALIBS=$(WXDIR)\lib\wxxml.lib
-OBJECTS=edapp.obj editor.obj nodehnd.obj prophnd.obj xmlhelpr.obj
+OBJECTS=edapp.obj editor.obj nodehnd.obj xmlhelpr.obj preview.obj nodesdb.obj \
+        pe_basic.obj pe_adv.obj propedit.obj propframe.obj splittree.obj
 
 !include $(WXDIR)\src\makeprog.b32
 
index aa9b29e9414d420aa939f0bacee9a4d99b54d8be..ca38c49f930c474f29e74f86fc2d10d16a39ab2c 100644 (file)
@@ -11,6 +11,7 @@ WXDIR = ../../..
 
 TARGET=wxrcedit
 EXTRALIBS=-lwxxml
-OBJECTS = edapp.o editor.o nodehnd.o prophnd.o xmlhelpr.o
+OBJECTS=edapp.o editor.o nodehnd.o xmlhelpr.o preview.o nodesdb.o \
+        pe_basic.o pe_adv.o propedit.o propframe.o splittree.o
 include $(WXDIR)/src/makeprog.g95
 
index 6afdf3440ee3537706658165def5f6783edca825..69a54242d20064f1b57117d13956704163a0597f 100644 (file)
@@ -23,7 +23,8 @@ EXTRALIBS=$(WXDIR)\lib\wxxmld.lib
 EXTRALIBS=$(WXDIR)\lib\wxxml.lib
 !endif
 
-OBJECTS=edapp.obj editor.obj nodehnd.obj prophnd.obj xmlhelpr.obj
+OBJECTS=edapp.obj editor.obj nodehnd.obj xmlhelpr.obj preview.obj nodesdb.obj \
+        pe_basic.obj pe_adv.obj propedit.obj propframe.obj splittree.obj
 
 !include $(WXDIR)\src\makeprog.vc
 
index 79575603c75d03599709a0632306bfd23994c9d0..12c5cc1a293689ad3059d4780a1c33cb46ca549c 100644 (file)
@@ -7,7 +7,7 @@ WXDIR = $(%WXWIN)
 
 PROGRAM = wxrcedit
 EXTRALIBS = $(WXDIR)\lib\wxxml.lib
-OBJECTS = edapp.obj editor.obj nodehnd.obj prophnd.obj xmlhelpr.obj
+OBJECTS=edapp.obj editor.obj nodehnd.obj xmlhelpr.obj preview.obj nodesdb.obj pe_basic.obj pe_adv.obj propedit.obj propframe.obj splittree.obj
 
 !include $(WXDIR)\src\makeprog.wat
 
index e584c498bce86ee3d49919e3a910e7f049404c62..e8a9abc39bb8a1f1563176aaed6bbb13ef1ab505 100644 (file)
 #include "editor.h"
 #include "treedt.h"
 #include "xmlhelpr.h"
+#include "nodesdb.h"
 
 
-WX_DEFINE_OBJARRAY(NodeInfoArray);
 
+wxList NodeHandler::ms_Handlers;
+bool NodeHandler::ms_HandlersLoaded = FALSE;
 
 
-void NodeInfo::Read(const wxString& filename)
+NodeHandler *NodeHandler::Find(wxXmlNode *node)
 {
-    HandlerType tp = HANDLER_NONE;
-    wxString nd, cht;
-    bool ab = FALSE;
-    long icn = -1;
-
-    Node.Empty();
-
-    wxPathList list;
-    // if modifying, don't forget to modify it in all places --
-    // search for wxINSTALL_PREFIX in editor.cpp
-    list.Add(".");
-    list.Add("./df");
-#ifdef __UNIX__ 
-    list.Add(wxGetHomeDir() + "/.wxrcedit");
-    #ifdef wxINSTALL_PREFIX
-    list.Add(wxINSTALL_PREFIX "/share/wx/wxrcedit");
-    #endif
-#endif
-    
-    wxString path = list.FindValidPath(filename);
-    if (path.IsEmpty()) return;
-    
-    wxTextFile tf;
-    tf.Open(path);
-    
-    if (!tf.IsOpened()) return;
-
-    for (size_t i = 0; i < tf.GetLineCount(); i++)
+    if (!ms_HandlersLoaded)
     {
-        if (tf[i].IsEmpty() || tf[i][0] == '#') continue;
-        wxStringTokenizer tkn(tf[i], ' ');
-        wxString s = tkn.GetNextToken();
-        if (s == "node")
-            nd = tkn.GetNextToken();
-        else if (s == "childtype")
-            cht = tkn.GetNextToken();
-        else if (s == "icon")
-            tkn.GetNextToken().ToLong(&icn);
-        else if (s == "derived")
-        {
-            if (tkn.GetNextToken() == "from")
-            {
-                s = tkn.GetNextToken();
-                DerivedFrom.Add(s);
-                Read(s + ".df");
-            }
-        }
-        else if (s == "abstract")
-            ab = true;
-        else if (s == "type")
-        {
-            s = tkn.GetNextToken();
-            if (s == "sizer") tp = HANDLER_SIZER;
-            else if (s == "sizeritem") tp = HANDLER_SIZERITEM;
-            else if (s == "panel") tp = HANDLER_PANEL;
-            else if (s == "notebook") tp = HANDLER_NOTEBOOK;
-            else if (s == "notebookpage") tp = HANDLER_NOTEBOOKPAGE;
-            else /*if (s == "normal")*/ tp = HANDLER_NORMAL;
-        }
-        else if (s == "var")
+        ms_HandlersLoaded = TRUE;
+        ms_Handlers.DeleteContents(TRUE);
+        
+        NodeInfoArray& arr = NodesDb::Get()->GetNodesInfo();
+        NodeHandler *hnd;
+        for (size_t i = 0; i < arr.GetCount(); i++)
         {
-            PropertyInfo pi;
-            pi.Name = tkn.GetNextToken();
-            tkn.GetNextToken();
-            wxString typ = tkn.GetNextToken();
-            if (tkn.HasMoreTokens()) pi.MoreInfo = tkn.GetNextToken();
-            /* ADD NEW PROPERTY TYPES HERE 
-               (search for other occurences of this comment in _all_ files) */
-            if (typ == "color") pi.Type = PROP_COLOR;
-            else if (typ == "flags") pi.Type = PROP_FLAGS;
-            else if (typ == "bool") pi.Type = PROP_BOOL;
-            else if (typ == "integer") pi.Type = PROP_INTEGER;
-            else if (typ == "coord") pi.Type = PROP_COORD;
-            else if (typ == "dimension") pi.Type = PROP_DIMENSION;
-            else if (typ == "not_implemented") pi.Type = PROP_NOT_IMPLEMENTED;
-            else /*if (typ == "text")*/ pi.Type = PROP_TEXT;
-            
-            bool fnd = FALSE;
-            for (size_t j = 0; j < Props.GetCount(); j++)
-            {
-                if (Props[j].Name == pi.Name)
-                {
-                    if (Props[j].Type == pi.Type && pi.Type == PROP_FLAGS)
-                        Props[j].MoreInfo << ',' << pi.MoreInfo;
-                    else
-                        Props[j] = pi;
-                    fnd = TRUE;
-                }
-            }
-            
-            if (!fnd) Props.Add(pi);
+            if (arr[i].NodeClass.IsEmpty() || arr[i].Abstract) continue;
+
+                 if (arr[i].Type == _T("panel"))
+                hnd = new NodeHandlerPanel(&(arr[i]));
+            else if (arr[i].Type == _T("sizer"))
+                hnd = new NodeHandlerSizer(&(arr[i]));
+            else if (arr[i].Type == _T("sizeritem"))
+                hnd = new NodeHandlerSizerItem(&(arr[i]));
+            else if (arr[i].Type == _T("notebook"))
+                hnd = new NodeHandlerNotebook(&(arr[i]));
+            else if (arr[i].Type == _T("notebookpage"))
+                hnd = new NodeHandlerNotebookPage(&(arr[i]));
+            else
+                hnd = new NodeHandler(&(arr[i]));
+            if (hnd) ms_Handlers.Append(hnd);
         }
+        ms_Handlers.Append(new NodeHandlerUnknown);        
     }
-    
-    if (!nd.IsEmpty()) Node = nd;
-    if (!cht.IsEmpty()) ChildType = cht;
-    if (tp != HANDLER_NONE) Type = tp;
-    if (icn != -1) Icon = icn;
-    Abstract = ab;
-}
-
-
 
-NodeHandler *NodeHandler::CreateFromFile(const wxString& filename, EditorFrame *frame)
-{
-    NodeHandler *hnd = NULL;
-
-    if (s_AllNodes == NULL) s_AllNodes = new NodeInfoArray;
-       
-    NodeInfo *ni = new NodeInfo; 
-    ni->Type = HANDLER_NONE;
-    ni->Icon = 0;
-    ni->Read(filename);
-    
-    // maybe we already parsed it?
-    for (size_t i = 0; i < s_AllNodes->GetCount(); i++)
-        if ((*s_AllNodes)[i].Node == ni->Node) return NULL;
-    
-    s_AllNodes->Add(*ni); // add a copy
-    
-    if (ni->Type == HANDLER_NONE || ni->Node.IsEmpty() || ni->Abstract) 
-        return NULL;
-    
-    switch (ni->Type)
+    wxNode *n = ms_Handlers.GetFirst();
+    while (n)
     {
-        case HANDLER_PANEL:
-            hnd = new NodeHandlerPanel(frame, ni);
-            break;
-        case HANDLER_SIZER:
-            hnd = new NodeHandlerSizer(frame, ni);
-            break;
-        case HANDLER_SIZERITEM:
-            hnd = new NodeHandlerSizerItem(frame, ni);
-            break;
-        case HANDLER_NOTEBOOK:
-            hnd = new NodeHandlerNotebook(frame, ni);
-            break;
-        case HANDLER_NOTEBOOKPAGE:
-            hnd = new NodeHandlerNotebookPage(frame, ni);
-            break;
-        default:
-            hnd = new NodeHandler(frame, ni);
-            break;
+        NodeHandler *h = (NodeHandler*) n->GetData();
+        if (h->CanHandle(node))
+            return h;
+        n = n->GetNext();
     }
-    
-    return hnd;
+    return NULL;
 }
 
 
 
 
-
-
-PropertyHandler* NodeHandler::s_PropHandlers[PROP_TYPES_CNT] = {NULL};
-int NodeHandler::s_RefCnt = 0;
-NodeInfoArray* NodeHandler::s_AllNodes = NULL;
-
-
-NodeHandler::NodeHandler(EditorFrame *frame, NodeInfo *ni) : 
+NodeHandler::NodeHandler(NodeInfo *ni) : 
         m_NodeInfo(ni)
 {
-    if (s_RefCnt++ == 0) CreatePropHandlers();
 }
 
 
-void NodeHandler::CreatePropHandlers()
+NodeHandler::~NodeHandler()
 {
-    /* ADD NEW PROPERTY TYPES HERE 
-       (search for other occurences of this comment in _all_ files) */
-    s_PropHandlers[PROP_TEXT] = new TextPropertyHandler;
-    s_PropHandlers[PROP_FLAGS] = new FlagsPropertyHandler;
-    s_PropHandlers[PROP_COLOR] = new TextPropertyHandler;
-    s_PropHandlers[PROP_BOOL] = new BoolPropertyHandler;
-    s_PropHandlers[PROP_INTEGER] = new TextPropertyHandler;
-    s_PropHandlers[PROP_COORD] = new CoordPropertyHandler;
-    s_PropHandlers[PROP_DIMENSION] = new DimensionPropertyHandler;
-    s_PropHandlers[PROP_NOT_IMPLEMENTED] = new NotImplPropertyHandler;
 }
 
 
-NodeHandler::~NodeHandler()
+
+bool NodeHandler::CanHandle(wxXmlNode *node)
 {
-    if (--s_RefCnt == 0)
-    {
-        for (int i = 0; i < PROP_TYPES_CNT; i++)
-            delete s_PropHandlers[i];
-        delete s_AllNodes; s_AllNodes = NULL;
-    }
-    delete m_NodeInfo;
+    return (m_NodeInfo->NodeClass == XmlGetClass(node));
 }
 
 
 
-bool NodeHandler::CanHandle(wxXmlNode *node)
+
+PropertyInfoArray& NodeHandler::GetPropsList(wxXmlNode *node)
 {
-    return (m_NodeInfo->Node == XmlGetClass(node));
+    return m_NodeInfo->Props;
 }
 
 
@@ -262,46 +133,23 @@ wxString NodeHandler::GetTreeString(wxXmlNode *node)
 
 
 
-void NodeHandler::CreatePropsList(wxListCtrl *listctrl, wxXmlNode *node)
-{
-    int index;
-    
-    for (size_t i = 0; i < m_NodeInfo->Props.GetCount(); i++)
-    {
-        PropertyInfo *p = &(m_NodeInfo->Props[i]);
-        index = s_PropHandlers[p->Type]->CreateListItem(listctrl, node, p);
-        listctrl->SetItemData(index, (long)new PropsListInfo(
-                                     index, s_PropHandlers[p->Type], node, 
-                                     p, listctrl));
-    }
-}
-
-
-
-wxPanel *NodeHandler::CreatePropEditPanel(wxWindow *parent, wxListCtrl *listctrl, int index)
-{
-    PropsListInfo *pli = (PropsListInfo*)listctrl->GetItemData(index);
-    
-    return pli->m_Handler->CreateEditPanel(parent, pli);
-}
-
-
 
 wxArrayString& NodeHandler::GetChildTypes()
 {
     if (m_ChildTypes.IsEmpty())
     {
         wxString basetype = m_NodeInfo->ChildType;
+        NodeInfoArray& arr = NodesDb::Get()->GetNodesInfo();
         
-        for (size_t i = 0; i < s_AllNodes->GetCount(); i++)
+        for (size_t i = 0; i < arr.GetCount(); i++)
         {
-            NodeInfo &ni = (*s_AllNodes)[i];
+            NodeInfo &ni = arr[i];
             
-            if (ni.Node == basetype && !ni.Abstract) 
-                m_ChildTypes.Add(ni.Node);
+            if (ni.NodeClass == basetype && !ni.Abstract) 
+                m_ChildTypes.Add(ni.NodeClass);
             
             if (ni.DerivedFrom.Index(basetype) != wxNOT_FOUND && !ni.Abstract)
-                m_ChildTypes.Add(ni.Node);
+                m_ChildTypes.Add(ni.NodeClass);
         }
         m_ChildTypes.Sort();
     }
@@ -336,10 +184,10 @@ wxTreeItemId NodeHandlerPanel::CreateTreeNode(wxTreeCtrl *treectrl,
     {
         if (n->GetType() == wxXML_ELEMENT_NODE &&
             n->GetName() == _T("object"))
-            EditorFrame::Get()->CreateTreeNode(treectrl, root, n);
+            Find(n)->CreateTreeNode(treectrl, root, n);
         n = n->GetNext();
     }
-    treectrl->Expand(root);
+    //treectrl->Expand(root);
     return root;
 }
 
@@ -402,22 +250,27 @@ wxTreeItemId NodeHandlerSizerItem::CreateTreeNode(wxTreeCtrl *treectrl,
 {
     wxTreeItemId root;
 
-    root = EditorFrame::Get()->CreateTreeNode(treectrl, parent, GetRealNode(node));
+    root = Find(GetRealNode(node))->CreateTreeNode(treectrl, parent, GetRealNode(node));
     ((XmlTreeData*)treectrl->GetItemData(root))->Node = node;
 
-    treectrl->Expand(root);
+    //treectrl->Expand(root);
     return root;
 }
 
 
 
-void NodeHandlerSizerItem::CreatePropsList(wxListCtrl *listctrl, wxXmlNode *node)
+PropertyInfoArray& NodeHandlerSizerItem::GetPropsList(wxXmlNode *node)
 {
-    NodeHandler::CreatePropsList(listctrl, node);
-    int item = listctrl->GetItemCount();
-    listctrl->InsertItem(item, "------");
-    listctrl->SetItemImage(item, 0, 0);
-    EditorFrame::Get()->CreatePropsList(listctrl, GetRealNode(node));
+    m_dummy = NodeHandler::GetPropsList(node);
+    wxXmlNode *nd = GetRealNode(node);
+    m_dummy.Add(PropertyInfo(wxEmptyString, wxEmptyString, wxEmptyString));
+    size_t pos = m_dummy.GetCount();
+    WX_APPEND_ARRAY(m_dummy, 
+                    Find(nd)->GetPropsList(nd));
+    for (size_t i = pos; i < m_dummy.GetCount(); i++)
+        m_dummy[i].Name = _T("object/") + m_dummy[i].Name;
+    
+    return m_dummy;
 }
 
 
@@ -425,7 +278,7 @@ void NodeHandlerSizerItem::CreatePropsList(wxListCtrl *listctrl, wxXmlNode *node
 wxString NodeHandlerSizerItem::GetTreeString(wxXmlNode *node)
 {
     wxXmlNode *n = GetRealNode(node);
-    return EditorFrame::Get()->FindHandler(n)->GetTreeString(n);
+    return Find(n)->GetTreeString(n);
 }
 
 
@@ -433,7 +286,7 @@ wxString NodeHandlerSizerItem::GetTreeString(wxXmlNode *node)
 int NodeHandlerSizerItem::GetTreeIcon(wxXmlNode *node)
 {
     wxXmlNode *n = GetRealNode(node);
-    return EditorFrame::Get()->FindHandler(n)->GetTreeIcon(n);
+    return Find(n)->GetTreeIcon(n);
 }
 
 
index 8001b5fece3b1c0f5859468a6188cde05779cd9f..25280b3ca1d7b7dbb6674ad57c52e8d94587f991 100644 (file)
@@ -23,37 +23,7 @@ class EditorFrame;
 
 #include "wx/treectrl.h"
 #include "wx/xml/xml.h"
-#include "prophnd.h"
-
-
-
-enum HandlerType
-{
-    HANDLER_NONE = 0,
-    HANDLER_PANEL = 1,
-    HANDLER_NORMAL,
-    HANDLER_SIZER,
-    HANDLER_SIZERITEM,
-    HANDLER_NOTEBOOK,
-    HANDLER_NOTEBOOKPAGE
-};
-
-
-class NodeInfo
-{
-    public:
-        wxString Node;
-        HandlerType Type;   
-        PropertyInfoArray Props;
-        wxArrayString DerivedFrom;
-        bool Abstract;
-        wxString ChildType;
-        int Icon;
-    
-        void Read(const wxString& filename);
-};
-
-WX_DECLARE_OBJARRAY(NodeInfo, NodeInfoArray);
+#include "nodesdb.h"
 
 
 
@@ -61,38 +31,35 @@ WX_DECLARE_OBJARRAY(NodeInfo, NodeInfoArray);
 class NodeHandler : public wxObject
 {
     public:
-        static NodeHandler *CreateFromFile(const wxString& filename, EditorFrame *frame);
+        static NodeHandler *Find(wxXmlNode *node);
     
-        NodeHandler(EditorFrame *frame, NodeInfo *ni);
+        NodeHandler(NodeInfo *ni);
         virtual ~NodeHandler();
         
         virtual bool CanHandle(wxXmlNode *node);
         virtual wxTreeItemId CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId parent,
                                     wxXmlNode *node);
-        virtual void CreatePropsList(wxListCtrl *listctrl, wxXmlNode *node);
+        virtual PropertyInfoArray& GetPropsList(wxXmlNode *node);
         virtual int GetTreeIcon(wxXmlNode * WXUNUSED(node)) {return m_NodeInfo->Icon;}
         virtual wxString GetTreeString(wxXmlNode *node);
-        wxPanel *CreatePropEditPanel(wxWindow *parent, wxListCtrl *listctrl, int index);
         wxArrayString& GetChildTypes();
         virtual void InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before = NULL);
         virtual wxXmlNode *GetRealNode(wxXmlNode *node) { return node; }
         
     protected:
+
         NodeInfo *m_NodeInfo;
         wxArrayString m_ChildTypes;
-
-        static PropertyHandler* s_PropHandlers[PROP_TYPES_CNT];
-        static int s_RefCnt;       
-        static NodeInfoArray* s_AllNodes;
         
-        void CreatePropHandlers();
+        static wxList ms_Handlers;
+        static bool ms_HandlersLoaded;
 };
 
 // wxPanel handler
 class NodeHandlerPanel : public NodeHandler
 {
     public:
-        NodeHandlerPanel(EditorFrame *frame, NodeInfo *ni) : NodeHandler(frame, ni) {}
+        NodeHandlerPanel(NodeInfo *ni) : NodeHandler(ni) {}
         
         virtual wxTreeItemId CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId parent,
                                     wxXmlNode *node);
@@ -104,7 +71,7 @@ class NodeHandlerPanel : public NodeHandler
 class NodeHandlerSizer : public NodeHandlerPanel
 {
     public:
-        NodeHandlerSizer(EditorFrame *frame, NodeInfo *ni) : NodeHandlerPanel(frame, ni) {}
+        NodeHandlerSizer(NodeInfo *ni) : NodeHandlerPanel(ni) {}
         
         virtual void InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before = NULL);
         virtual int GetTreeIcon(wxXmlNode *node);
@@ -115,14 +82,17 @@ class NodeHandlerSizer : public NodeHandlerPanel
 class NodeHandlerSizerItem : public NodeHandler
 {
     public:
-        NodeHandlerSizerItem(EditorFrame *frame, NodeInfo *ni) : NodeHandler(frame, ni) {}
+        NodeHandlerSizerItem(NodeInfo *ni) : NodeHandler(ni) {}
 
         virtual wxTreeItemId CreateTreeNode(wxTreeCtrl *treectrl, wxTreeItemId parent,
                                     wxXmlNode *node);
-        virtual void CreatePropsList(wxListCtrl *listctrl, wxXmlNode *node);
+        virtual PropertyInfoArray& GetPropsList(wxXmlNode *node);
         virtual wxString GetTreeString(wxXmlNode *node);
         virtual int GetTreeIcon(wxXmlNode *node);
         virtual wxXmlNode *GetRealNode(wxXmlNode *node);
+
+    private:
+        PropertyInfoArray m_dummy;
 };
 
 
@@ -131,7 +101,7 @@ class NodeHandlerSizerItem : public NodeHandler
 class NodeHandlerNotebook : public NodeHandlerPanel
 {
     public:
-        NodeHandlerNotebook(EditorFrame *frame, NodeInfo *ni) : NodeHandlerPanel(frame, ni) {}
+        NodeHandlerNotebook(NodeInfo *ni) : NodeHandlerPanel(ni) {}
         
         virtual void InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before = NULL);
 };
@@ -141,8 +111,8 @@ class NodeHandlerNotebook : public NodeHandlerPanel
 class NodeHandlerNotebookPage : public NodeHandlerSizerItem
 {
     public:
-        NodeHandlerNotebookPage(EditorFrame *frame, NodeInfo *ni) : 
-                                        NodeHandlerSizerItem(frame, ni) {}
+        NodeHandlerNotebookPage(NodeInfo *ni) : 
+                                        NodeHandlerSizerItem(ni) {}
 };
 
 
@@ -151,7 +121,7 @@ class NodeHandlerNotebookPage : public NodeHandlerSizerItem
 class NodeHandlerUnknown : public NodeHandler
 {
     public:
-        NodeHandlerUnknown(EditorFrame *frame) : NodeHandler(frame, new NodeInfo) {}
+        NodeHandlerUnknown() : NodeHandler(new NodeInfo) {}
         
         virtual bool CanHandle(wxXmlNode *node) { return TRUE; }
 };
diff --git a/contrib/utils/wxrcedit/nodesdb.cpp b/contrib/utils/wxrcedit/nodesdb.cpp
new file mode 100644 (file)
index 0000000..f36e6ed
--- /dev/null
@@ -0,0 +1,190 @@
+/////////////////////////////////////////////////////////////////////////////
+// Author:      Vaclav Slavik
+// Created:     2000/05/05
+// RCS-ID:      $Id$
+// Copyright:   (c) 2000 Vaclav Slavik
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+    #pragma implementation "nodesdb.h"
+#endif
+
+// For compilers that support precompilation, includes _T("wx/wx.h").
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+    #pragma hdrstop
+#endif
+
+#include "wx/wx.h"
+#include "wx/textfile.h"
+#include "wx/tokenzr.h"
+#include "wx/dir.h"
+#include "nodesdb.h"
+#include "wx/arrimpl.cpp"
+
+WX_DEFINE_OBJARRAY(NodeInfoArray);
+WX_DEFINE_OBJARRAY(PropertyInfoArray);
+
+
+
+
+void NodeInfo::Read(const wxString& filename, wxPathList& list)
+{
+    wxString tp;
+    wxString nd, cht;
+    bool ab = FALSE;
+    long icn = -1;
+
+    NodeClass.Empty();
+
+    wxString path = list.FindValidPath(filename);
+    if (path.IsEmpty()) return;
+    
+    wxTextFile tf;
+    tf.Open(path);
+    
+    if (!tf.IsOpened()) return;
+
+    for (size_t i = 0; i < tf.GetLineCount(); i++)
+    {
+        if (tf[i].IsEmpty() || tf[i][0] == _T('#')) continue;
+        wxStringTokenizer tkn(tf[i], _T(' '));
+        wxString s = tkn.GetNextToken();
+        if (s == _T("node"))
+            nd = tkn.GetNextToken();
+        else if (s == _T("childtype"))
+            cht = tkn.GetNextToken();
+        else if (s == _T("icon"))
+            tkn.GetNextToken().ToLong(&icn);
+        else if (s == _T("derived"))
+        {
+            if (tkn.GetNextToken() == _T("from"))
+            {
+                s = tkn.GetNextToken();
+                DerivedFrom.Add(s);
+                Read(s + _T(".df"), list);
+            }
+        }
+        else if (s == _T("abstract"))
+            ab = true;
+        else if (s == _T("type"))
+        {
+            tp = tkn.GetNextToken();
+        }
+        else if (s == _T("var"))
+        {
+            PropertyInfo pi;
+            pi.Name = tkn.GetNextToken();
+            tkn.GetNextToken();
+            pi.Type = tkn.GetNextToken();
+            if (tkn.HasMoreTokens()) pi.MoreInfo = tkn.GetNextToken();
+            
+            bool fnd = FALSE;
+            for (size_t j = 0; j < Props.GetCount(); j++)
+            {
+                if (Props[j].Name == pi.Name)
+                {
+                    if (Props[j].Type == pi.Type && pi.Type == _T("flags"))
+                        Props[j].MoreInfo << _T(',') << pi.MoreInfo;
+                    else
+                        Props[j] = pi;
+                    fnd = TRUE;
+                }
+            }
+            
+            if (!fnd) Props.Add(pi);
+        }
+    }
+    
+    if (!nd.IsEmpty()) NodeClass = nd;
+    if (!cht.IsEmpty()) ChildType = cht;
+    if (!!tp) Type = tp;
+    if (icn != -1) Icon = icn;
+    Abstract = ab;
+}
+
+
+
+
+
+
+
+
+
+NodesDb* NodesDb::ms_Instance = NULL;
+
+NodesDb *NodesDb::Get()
+{
+    if (ms_Instance == NULL) 
+    {
+        (void)new NodesDb;
+    }
+    return ms_Instance;
+}
+
+
+NodesDb::NodesDb()
+{
+    ms_Instance = this;
+
+    m_Paths.Add(_T("."));
+    m_Paths.Add(_T("./df"));
+#ifdef __UNIX__ 
+    m_Paths.Add(wxGetHomeDir() + _T("/.wxrcedit"));
+    #ifdef wxINSTALL_PREFIX
+    m_Paths.Add(wxINSTALL_PREFIX _T("/share/wx/wxrcedit"));
+    #endif
+#endif
+
+    Load();
+}
+
+
+
+void NodesDb::Load()
+{
+    for (size_t i = 0; i < m_Paths.GetCount(); i++)
+        LoadDir(m_Paths[i]);
+}
+
+
+
+void NodesDb::LoadDir(const wxString& path)
+{
+    if (!wxDirExists(path)) return;
+    
+    wxDir dir(path);
+    wxString filename;
+    bool cont;
+
+    cont = dir.GetFirst(&filename, "*.df");
+    while (cont)
+    {
+        LoadFile(filename);
+        cont = dir.GetNext(&filename);
+    }
+}
+
+
+
+void NodesDb::LoadFile(const wxString& file)
+{
+    NodeInfo *ni = new NodeInfo; 
+    ni->Type = wxEmptyString;
+    ni->Icon = 0;
+    wxPathList paths;
+    size_t i;
+    
+    for (i = 0; i < m_Paths.GetCount(); i++)
+        paths.Add(m_Paths[i]);
+    
+    ni->Read(file, paths);
+    
+    // maybe we already parsed it?
+    for (i = 0; i < m_Infos.GetCount(); i++)
+        if (m_Infos[i].NodeClass == ni->NodeClass) return;
+    
+    m_Infos.Add(ni);
+}
diff --git a/contrib/utils/wxrcedit/nodesdb.h b/contrib/utils/wxrcedit/nodesdb.h
new file mode 100644 (file)
index 0000000..ff629f0
--- /dev/null
@@ -0,0 +1,84 @@
+/////////////////////////////////////////////////////////////////////////////
+// Purpose:     XML resources editor
+// Author:      Vaclav Slavik
+// Created:     2000/05/05
+// RCS-ID:      $Id$
+// Copyright:   (c) 2000 Vaclav Slavik
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+    #pragma interface "nodesdb.h"
+#endif
+
+#ifndef _NODESDB_H_
+#define _NODESDB_H_
+
+#include "wx/dynarray.h"
+
+class WXDLLEXPORT wxXmlNode;
+class WXDLLEXPORT wxString;
+class WXDLLEXPORT wxPathList;
+
+
+class PropertyInfo
+{
+    public:
+        PropertyInfo() {}
+        PropertyInfo(const wxString& atype, const wxString& aname, const wxString& amoreinfo)
+          : Type(atype), Name(aname), MoreInfo(amoreinfo) {}
+       
+        PropertyInfo& operator=(const PropertyInfo& p)
+        {
+            Type = p.Type; Name = p.Name; MoreInfo = p.MoreInfo;
+            return *this;
+        }
+       
+        wxString Type;
+        wxString Name;
+        wxString MoreInfo;
+};
+
+WX_DECLARE_OBJARRAY(PropertyInfo, PropertyInfoArray);
+
+
+class NodeInfo
+{
+    public:
+        wxString NodeClass;
+        wxString Type;   
+        PropertyInfoArray Props;
+        wxArrayString DerivedFrom;
+        bool Abstract;
+        wxString ChildType;
+        int Icon;
+    
+        void Read(const wxString& filename, wxPathList& list);
+};
+
+WX_DECLARE_OBJARRAY(NodeInfo, NodeInfoArray);
+
+
+
+class NodesDb
+{
+    public:
+        NodesDb();
+    
+        void Load();
+        void LoadDir(const wxString& path);
+        void LoadFile(const wxString& file);
+        
+        NodeInfoArray& GetNodesInfo() { return m_Infos; }
+    
+        static NodesDb *Get();
+    
+    private:
+        static NodesDb *ms_Instance;
+        NodeInfoArray m_Infos;
+        wxArrayString m_Paths;
+};
+
+
+
+#endif 
diff --git a/contrib/utils/wxrcedit/pe_adv.cpp b/contrib/utils/wxrcedit/pe_adv.cpp
new file mode 100644 (file)
index 0000000..14ca986
--- /dev/null
@@ -0,0 +1,102 @@
+/////////////////////////////////////////////////////////////////////////////
+// Author:      Vaclav Slavik
+// Created:     2000/05/05
+// RCS-ID:      $Id$
+// Copyright:   (c) 2000 Vaclav Slavik
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+    #pragma implementation "pe_adv.h"
+#endif
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+    #pragma hdrstop
+#endif
+
+#include "wx/wx.h"
+#include "wx/xml/xml.h"
+#include "wx/tokenzr.h"
+#include "pe_basic.h"
+#include "pe_adv.h"
+#include "xmlhelpr.h"
+#include "editor.h"
+#include "preview.h"
+#include "wx/colordlg.h"
+
+
+
+wxWindow* PropEditCtrlFont::CreateEditCtrl()
+{
+    PropEditCtrlTxt::CreateEditCtrl();
+    m_TextCtrl->Enable(FALSE);
+    return m_TextCtrl;
+}
+
+
+
+wxTreeItemId PropEditCtrlFont::CreateTreeEntry(wxTreeItemId parent, const PropertyInfo& pinfo)
+{
+    wxTreeItemId ti = PropEditCtrlTxt::CreateTreeEntry(parent, pinfo);
+    return ti;
+}
+
+
+
+
+BEGIN_EVENT_TABLE(PropEditCtrlChoice, PropEditCtrl)
+    EVT_CHOICE(-1, PropEditCtrlChoice::OnChoice)
+END_EVENT_TABLE()
+
+wxWindow* PropEditCtrlChoice::CreateEditCtrl()
+{
+    m_Choice = new wxChoice(this, -1);
+    m_Choice->Append(_T("false"));
+    m_Choice->Append(_T("true"));
+    return m_Choice;
+}
+
+
+        
+void PropEditCtrlChoice::ReadValue()
+{
+}
+
+
+
+void PropEditCtrlChoice::WriteValue()
+{
+}
+
+
+
+void PropEditCtrlChoice::OnChoice(wxCommandEvent& event)
+{
+}
+
+
+
+void PropEditCtrlColor::OnDetails()
+{
+    wxColour clr;
+    wxString txt = m_TextCtrl->GetValue();
+    long unsigned tmp;
+    
+    if (txt.Length() == 7 && txt[0] == _T('#') &&
+        wxSscanf(txt.c_str(), _T("#%lX"), &tmp) == 1)
+        clr = wxColour((tmp & 0xFF0000) >> 16, 
+                       (tmp & 0x00FF00) >> 8, 
+                       (tmp & 0x0000FF));
+    clr = wxGetColourFromUser(NULL, clr);
+    if (clr.Ok())
+    {
+        txt.Printf(_T("#%02X%02X%02X"), clr.Red(), clr.Green(), clr.Blue());
+        m_TextCtrl->SetValue(txt);
+        WriteValue();
+    }
+}
+
+
diff --git a/contrib/utils/wxrcedit/pe_adv.h b/contrib/utils/wxrcedit/pe_adv.h
new file mode 100644 (file)
index 0000000..6de3b1b
--- /dev/null
@@ -0,0 +1,68 @@
+/////////////////////////////////////////////////////////////////////////////
+// Purpose:     XML resources editor
+// Author:      Vaclav Slavik
+// Created:     2000/05/05
+// RCS-ID:      $Id$
+// Copyright:   (c) 2000 Vaclav Slavik
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+    #pragma interface "pe_adv.h"
+#endif
+
+#ifndef _PE_ADV_H_
+#define _PE_ADV_H_
+
+#include "propedit.h"
+#include "pe_basic.h"
+
+class WXDLLEXPORT wxChoice;
+
+
+class PropEditCtrlFont : public PropEditCtrlTxt
+{
+    public:
+        PropEditCtrlFont(PropertiesFrame *propFrame)
+           : PropEditCtrlTxt(propFrame) {}
+                
+        virtual wxWindow* CreateEditCtrl();
+        virtual wxTreeItemId CreateTreeEntry(wxTreeItemId parent, const PropertyInfo& pinfo);
+};
+
+
+
+class PropEditCtrlChoice : public PropEditCtrl
+{
+    public:
+        PropEditCtrlChoice(PropertiesFrame *propFrame)
+           : PropEditCtrl(propFrame) {}
+                
+        virtual wxWindow* CreateEditCtrl();
+        
+        virtual void ReadValue();
+        virtual void WriteValue();
+    
+    protected:
+        wxChoice *m_Choice;
+
+        DECLARE_EVENT_TABLE()
+        void OnChoice(wxCommandEvent& event);
+};
+
+
+class PropEditCtrlColor : public PropEditCtrlTxt
+{
+    public:
+        PropEditCtrlColor(PropertiesFrame *propFrame)
+            : PropEditCtrlTxt(propFrame) {}
+
+        virtual bool HasDetails() { return TRUE; }
+        virtual void OnDetails();
+};
+
+
+
+
+
+#endif
diff --git a/contrib/utils/wxrcedit/pe_basic.cpp b/contrib/utils/wxrcedit/pe_basic.cpp
new file mode 100644 (file)
index 0000000..7bef53d
--- /dev/null
@@ -0,0 +1,431 @@
+/////////////////////////////////////////////////////////////////////////////
+// Author:      Vaclav Slavik
+// Created:     2000/05/05
+// RCS-ID:      $Id$
+// Copyright:   (c) 2000 Vaclav Slavik
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+    #pragma implementation "pe_basic.h"
+#endif
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+    #pragma hdrstop
+#endif
+
+#include "wx/wx.h"
+#include "wx/xml/xml.h"
+#include "wx/tokenzr.h"
+#include "pe_basic.h"
+#include "xmlhelpr.h"
+#include "editor.h"
+#include "preview.h"
+
+
+BEGIN_EVENT_TABLE(PropEditCtrlTxt, PropEditCtrl)
+    EVT_TEXT(-1, PropEditCtrlTxt::OnText)
+END_EVENT_TABLE()
+
+
+wxWindow *PropEditCtrlTxt::CreateEditCtrl()
+{
+    return (m_TextCtrl = new wxTextCtrl(this, -1));
+}
+
+
+
+void PropEditCtrlTxt::OnText(wxCommandEvent& event)
+{
+    if (CanSave()) WriteValue();
+}
+
+
+
+void PropEditCtrlTxt::ReadValue()
+{
+    m_TextCtrl->SetValue(XmlReadValue(GetNode(), m_PropInfo->Name));
+}
+
+
+
+void PropEditCtrlTxt::WriteValue()
+{
+    wxString newv = m_TextCtrl->GetValue();
+    XmlWriteValue(GetNode(), m_PropInfo->Name, newv);
+    m_TreeCtrl->SetItemBold(m_TreeItem, TRUE);
+}
+
+
+
+wxWindow *PropEditCtrlInt::CreateEditCtrl()
+{
+    PropEditCtrlTxt::CreateEditCtrl();
+    m_TextCtrl->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
+    return m_TextCtrl;
+}
+
+
+
+
+
+
+
+BEGIN_EVENT_TABLE(PropEditCtrlBool, PropEditCtrl)
+    EVT_CHOICE(-1, PropEditCtrlBool::OnChoice)
+END_EVENT_TABLE()
+
+wxWindow *PropEditCtrlBool::CreateEditCtrl()
+{
+    m_Choice = new wxChoice(this, -1);
+    m_Choice->Append(_T("false"));
+    m_Choice->Append(_T("true"));
+    return m_Choice;
+}
+
+
+
+void PropEditCtrlBool::ReadValue()
+{
+    int sel;
+    if (XmlReadValue(GetNode(), m_PropInfo->Name) == _T("0")) sel = 0;
+    else sel = 1;
+    m_Choice->SetSelection(sel);
+}
+
+
+
+void PropEditCtrlBool::WriteValue()
+{
+    wxString newv = m_Choice->GetSelection() == 0 ? _T("0") : _T("1");
+
+    XmlWriteValue(GetNode(), m_PropInfo->Name, newv);
+    m_TreeCtrl->SetItemBold(m_TreeItem, TRUE);
+}
+
+
+
+wxString PropEditCtrlBool::GetValueAsText(wxTreeItemId ti)
+{
+    PropertyInfo& pir = ((PETreeData*)m_TreeCtrl->GetItemData(ti))->PropInfo;
+    wxString x = XmlReadValue(GetNode(), pir.Name);
+    if (x == _T("1")) x = _T("true");
+    else if (x == _T("0")) x = _T("false");
+    return x;
+}
+
+
+
+void PropEditCtrlBool::OnChoice(wxCommandEvent& event)
+{
+    if (CanSave()) WriteValue();
+}
+
+
+
+
+// --------------------------- PropEditCtrlCoord -----------------------
+
+class PropEditCtrlCoordXY : public PropEditCtrlInt
+{
+    public:
+        PropEditCtrlCoordXY(PropertiesFrame *propFrame, int which)
+           : PropEditCtrlInt(propFrame), m_which(which) {}
+        
+        virtual void ReadValue()
+        {
+            wxString s = XmlReadValue(GetNode(), m_PropInfo->Name);
+            if (s.IsEmpty())
+            {
+                m_c[0] = m_c[1] = _T("-1");
+            }
+            else
+            {
+                wxStringTokenizer tkn(s.BeforeFirst(_T('d')), _T(","));
+                m_c[0] = tkn.GetNextToken();
+                m_c[1] = tkn.GetNextToken();
+            }
+            m_TextCtrl->SetValue(m_c[m_which]);
+        }
+        
+        virtual void WriteValue()
+        {
+            m_c[m_which] = m_TextCtrl->GetValue();
+            if (m_c[0].IsEmpty()) m_c[0] = _T("-1");
+            if (m_c[1].IsEmpty()) m_c[1] = _T("-1");
+            wxString s;
+            s << m_c[0] << _T(',') << m_c[1];
+            if (m_dlg) s << _T('d');
+            XmlWriteValue(GetNode(), m_PropInfo->Name, s);
+            m_TreeCtrl->SetItemBold(m_TreeCtrl->GetParent(m_TreeItem), TRUE);
+        }
+        
+        virtual wxString GetValueAsText(wxTreeItemId ti)
+        {
+            PropertyInfo *pi = &(((PETreeData*)m_TreeCtrl->GetItemData(ti))->PropInfo);
+            wxString s = XmlReadValue(GetNode(), pi->Name);
+            if (s.IsEmpty())
+            {
+                m_c[0] = m_c[1] = _T("-1");
+            }
+            else
+            {
+                wxStringTokenizer tkn(s.BeforeFirst(_T('d')), _T(","));
+                m_c[0] = tkn.GetNextToken();
+                m_c[1] = tkn.GetNextToken();
+            }
+            return m_c[m_which];
+        }
+        
+        virtual wxString GetPropName(const PropertyInfo& pinfo)
+        {
+            if (m_which == 0) return _T("x"); else return _T("y");
+        }
+
+        virtual bool HasClearButton() { return FALSE; }
+        virtual bool IsPresent(const PropertyInfo& pinfo) { return FALSE; } 
+
+    
+    protected:
+        wxString m_c[2];
+        bool m_dlg;
+        int m_which;
+};
+
+
+class PropEditCtrlCoordDlg : public PropEditCtrlBool
+{
+    public:
+        PropEditCtrlCoordDlg(PropertiesFrame *propFrame)
+           : PropEditCtrlBool(propFrame) {}
+        
+        virtual void ReadValue()
+        {
+            wxString s = XmlReadValue(GetNode(), m_PropInfo->Name);
+            if (s.IsEmpty()) m_Choice->SetSelection(0);
+            else if (s[s.Length()-1] == _T('d'))
+                m_Choice->SetSelection(1);
+            else
+                m_Choice->SetSelection(0);
+        }
+        
+        virtual void WriteValue()
+        {
+            wxString s = XmlReadValue(GetNode(), m_PropInfo->Name).BeforeFirst(_T('d'));
+            if (m_Choice->GetSelection() == 1) s << _T('d');
+            XmlWriteValue(GetNode(), m_PropInfo->Name, s);
+            m_TreeCtrl->SetItemBold(m_TreeCtrl->GetParent(m_TreeItem), TRUE);
+        }
+        
+        virtual wxString GetValueAsText(wxTreeItemId ti)
+        {
+            PropertyInfo *pi = &(((PETreeData*)m_TreeCtrl->GetItemData(ti))->PropInfo);
+            wxString s = XmlReadValue(GetNode(), pi->Name);
+            if (s.IsEmpty() || s[s.Length()-1] != _T('d'))
+                return _("false");
+            else
+                return _("true");
+        }
+        
+        virtual wxString GetPropName(const PropertyInfo& pinfo)
+        {
+            return _T("dlg");
+        }
+
+        virtual bool HasClearButton() { return FALSE; }
+        virtual bool IsPresent(const PropertyInfo& pinfo) { return FALSE; } 
+};
+
+
+
+
+PropEditCtrlCoord::PropEditCtrlCoord(PropertiesFrame *propFrame)
+           : PropEditCtrlTxt(propFrame)
+{
+    m_CtrlX = new PropEditCtrlCoordXY(propFrame, 0);
+    m_CtrlY = new PropEditCtrlCoordXY(propFrame, 1);
+    m_CtrlDlg = new PropEditCtrlCoordDlg(propFrame);
+}
+
+PropEditCtrlCoord::~PropEditCtrlCoord()
+{
+    delete m_CtrlX;
+    delete m_CtrlY;
+    delete m_CtrlDlg;
+}
+
+
+
+wxTreeItemId PropEditCtrlCoord::CreateTreeEntry(wxTreeItemId parent, const PropertyInfo& pinfo)
+{
+    wxTreeItemId id = PropEditCtrlTxt::CreateTreeEntry(parent, pinfo);
+    m_CtrlX->CreateTreeEntry(id, PropertyInfo(_T("text"), pinfo.Name, _T("")));
+    m_CtrlY->CreateTreeEntry(id, PropertyInfo(_T("text"), pinfo.Name, _T("")));
+    m_CtrlDlg->CreateTreeEntry(id, PropertyInfo(_T("bool"), pinfo.Name, _T("")));
+    return id;
+}
+
+
+
+
+
+
+// --------------------------- PropEditCtrlDim -----------------------
+
+class PropEditCtrlDimX : public PropEditCtrlInt
+{
+    public:
+        PropEditCtrlDimX(PropertiesFrame *propFrame)
+           : PropEditCtrlInt(propFrame){}
+        
+        virtual void ReadValue()
+        {
+            wxString s = XmlReadValue(GetNode(), m_PropInfo->Name);
+            m_c = s.BeforeFirst(_T('d'));
+            m_TextCtrl->SetValue(m_c);
+        }
+        
+        virtual void WriteValue()
+        {
+            wxString s = XmlReadValue(GetNode(), m_PropInfo->Name);
+            bool dlg = !s.IsEmpty() && s[s.Length()-1] == _T('d');
+            m_c = m_TextCtrl->GetValue();
+            s = m_c;
+            if (dlg) s << _T('d');
+            XmlWriteValue(GetNode(), m_PropInfo->Name, s);
+            m_TreeCtrl->SetItemBold(m_TreeCtrl->GetParent(m_TreeItem), TRUE);
+        }
+        
+        virtual wxString GetValueAsText(wxTreeItemId ti)
+        {
+            PropertyInfo *pi = &(((PETreeData*)m_TreeCtrl->GetItemData(ti))->PropInfo);
+            return XmlReadValue(GetNode(), pi->Name).BeforeFirst(_T('d'));
+        }
+        
+        virtual wxString GetPropName(const PropertyInfo& pinfo)
+        {
+            return _T("val");
+        }
+
+        virtual bool HasClearButton() { return FALSE; }
+        virtual bool IsPresent(const PropertyInfo& pinfo) { return FALSE; } 
+
+    
+    protected:
+        wxString m_c;
+};
+
+
+
+PropEditCtrlDim::PropEditCtrlDim(PropertiesFrame *propFrame)
+           : PropEditCtrlTxt(propFrame)
+{
+    m_CtrlX = new PropEditCtrlDimX(propFrame);
+    m_CtrlDlg = new PropEditCtrlCoordDlg(propFrame);
+}
+
+PropEditCtrlDim::~PropEditCtrlDim()
+{
+    delete m_CtrlX;
+    delete m_CtrlDlg;
+}
+
+
+
+wxTreeItemId PropEditCtrlDim::CreateTreeEntry(wxTreeItemId parent, const PropertyInfo& pinfo)
+{
+    wxTreeItemId id = PropEditCtrlTxt::CreateTreeEntry(parent, pinfo);
+    m_CtrlX->CreateTreeEntry(id, PropertyInfo(_T("text"), pinfo.Name, _T("")));
+    m_CtrlDlg->CreateTreeEntry(id, PropertyInfo(_T("bool"), pinfo.Name, _T("")));
+    return id;
+}
+
+
+
+
+// --------------------- PropEditCtrlXMLID -----------------------------
+
+
+void PropEditCtrlXMLID::ReadValue()
+{
+    m_TextCtrl->SetValue(GetNode()->GetPropVal(_T("name"), wxEmptyString));
+}
+
+
+
+void PropEditCtrlXMLID::WriteValue()
+{
+    wxString s =m_TextCtrl->GetValue();
+    if (s.IsEmpty()) s = _T("-1");
+
+    GetNode()->DeleteProperty(_T("name"));
+    GetNode()->AddProperty(_T("name"), s);
+
+    m_TreeCtrl->SetItemBold(m_TreeItem, TRUE);
+    EditorFrame::Get()->NotifyChanged(CHANGED_TREE_SELECTED);
+}
+
+
+
+void PropEditCtrlXMLID::Clear()
+{
+    EndEdit();
+    GetNode()->DeleteProperty(_T("name"));
+    m_TreeCtrl->SetItemBold(m_TreeItem, FALSE);
+    EditorFrame::Get()->NotifyChanged(CHANGED_TREE_SELECTED);
+}
+
+
+
+void PropEditCtrlXMLID::OnDetails()
+{
+    wxString choices[] = {wxString(_T("-1"))
+      #define stdID(id) , wxString(#id)
+      stdID(wxID_OK) stdID(wxID_CANCEL)
+      stdID(wxID_YES) stdID(wxID_NO)
+      stdID(wxID_APPLY) stdID(wxID_HELP) 
+      stdID(wxID_HELP_CONTEXT)
+
+      stdID(wxID_OPEN) stdID(wxID_CLOSE) stdID(wxID_NEW)
+      stdID(wxID_SAVE) stdID(wxID_SAVEAS) stdID(wxID_REVERT)
+      stdID(wxID_EXIT) stdID(wxID_UNDO) stdID(wxID_REDO)
+      stdID(wxID_PRINT) stdID(wxID_PRINT_SETUP)
+      stdID(wxID_PREVIEW) stdID(wxID_ABOUT) stdID(wxID_HELP_CONTENTS)
+      stdID(wxID_HELP_COMMANDS) stdID(wxID_HELP_PROCEDURES)
+      stdID(wxID_CUT) stdID(wxID_COPY) stdID(wxID_PASTE)
+      stdID(wxID_CLEAR) stdID(wxID_FIND) stdID(wxID_DUPLICATE)
+      stdID(wxID_SELECTALL) 
+      stdID(wxID_STATIC) stdID(wxID_FORWARD) stdID(wxID_BACKWARD)
+      stdID(wxID_DEFAULT) stdID(wxID_MORE) stdID(wxID_SETUP)
+      stdID(wxID_RESET) 
+      #undef stdID
+      };
+
+    wxString s = 
+        wxGetSingleChoice(_("Choose from predefined IDs:"), _("XMLID"), 
+                          38/*sizeof choices*/, choices);
+    if (!s) return;
+    m_TextCtrl->SetValue(s);
+    WriteValue();
+}
+
+
+
+wxString PropEditCtrlXMLID::GetValueAsText(wxTreeItemId ti)
+{
+    return GetNode()->GetPropVal(_T("name"), wxEmptyString);
+}
+
+
+
+bool PropEditCtrlXMLID::IsPresent(const PropertyInfo& pinfo)
+{
+    return GetNode()->HasProp(_T("name"));
+}
+
+
+
+
diff --git a/contrib/utils/wxrcedit/pe_basic.h b/contrib/utils/wxrcedit/pe_basic.h
new file mode 100644 (file)
index 0000000..f646125
--- /dev/null
@@ -0,0 +1,139 @@
+/////////////////////////////////////////////////////////////////////////////
+// Purpose:     XML resources editor
+// Author:      Vaclav Slavik
+// Created:     2000/05/05
+// RCS-ID:      $Id$
+// Copyright:   (c) 2000 Vaclav Slavik
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+    #pragma interface "pe_basic.h"
+#endif
+
+#ifndef _PE_BASIC_H_
+#define _PE_BASIC_H_
+
+#include "propedit.h"
+
+class WXDLLEXPORT wxChoice;
+
+
+
+class PropEditCtrlNull : public PropEditCtrl
+{
+    public:
+        PropEditCtrlNull(PropertiesFrame *propFrame)
+           : PropEditCtrl(propFrame) {}
+                
+        virtual void BeginEdit(const wxRect& rect, wxTreeItemId ti) {}
+        virtual void EndEdit() {}
+                
+        virtual wxWindow* CreateEditCtrl() {return NULL;}
+        
+        virtual void ReadValue() {}
+        virtual void WriteValue() {}
+};
+
+
+
+class PropEditCtrlTxt : public PropEditCtrl
+{
+    public:
+        PropEditCtrlTxt(PropertiesFrame *propFrame)
+           : PropEditCtrl(propFrame) {}
+                
+        virtual wxWindow* CreateEditCtrl();
+        
+        virtual void ReadValue();
+        virtual void WriteValue();
+        
+    protected:
+        wxTextCtrl *m_TextCtrl;
+
+    private:
+        DECLARE_EVENT_TABLE()
+        void OnText(wxCommandEvent& event);
+};
+
+
+
+class PropEditCtrlInt : public PropEditCtrlTxt
+{
+    public:
+        PropEditCtrlInt(PropertiesFrame *propFrame)
+           : PropEditCtrlTxt(propFrame) {}
+                
+        virtual wxWindow* CreateEditCtrl();
+};
+
+
+
+class PropEditCtrlBool : public PropEditCtrl
+{
+    public:
+        PropEditCtrlBool(PropertiesFrame *propFrame)
+           : PropEditCtrl(propFrame) {}
+                
+        virtual wxWindow* CreateEditCtrl();
+        
+        virtual void ReadValue();
+        virtual void WriteValue();
+        virtual wxString GetValueAsText(wxTreeItemId ti);
+    
+    protected:
+        wxChoice *m_Choice;
+
+        DECLARE_EVENT_TABLE()
+        void OnChoice(wxCommandEvent& event);
+};
+
+
+class PropEditCtrlCoord : public PropEditCtrlTxt
+{
+    public:
+        PropEditCtrlCoord(PropertiesFrame *propFrame);
+        ~PropEditCtrlCoord();
+    
+        virtual wxTreeItemId CreateTreeEntry(wxTreeItemId parent, const PropertyInfo& pinfo);
+        
+    private:
+        PropEditCtrl *m_CtrlX, *m_CtrlY, *m_CtrlDlg;
+};
+
+
+class PropEditCtrlDim : public PropEditCtrlTxt
+{
+    public:
+        PropEditCtrlDim(PropertiesFrame *propFrame);
+        ~PropEditCtrlDim();
+    
+        virtual wxTreeItemId CreateTreeEntry(wxTreeItemId parent, const PropertyInfo& pinfo);
+        
+    private:
+        PropEditCtrl *m_CtrlX, *m_CtrlDlg;
+};
+
+
+
+class PropEditCtrlXMLID : public PropEditCtrlTxt
+{
+    public:
+        PropEditCtrlXMLID(PropertiesFrame *propFrame)
+           : PropEditCtrlTxt(propFrame) {}
+                
+        virtual void ReadValue();
+        virtual void WriteValue();
+        virtual void Clear();
+        virtual bool HasDetails() { return TRUE; }
+        virtual void OnDetails();
+        virtual wxString GetValueAsText(wxTreeItemId ti);
+        virtual bool IsPresent(const PropertyInfo& pinfo);
+};
+
+
+
+
+
+
+#endif
diff --git a/contrib/utils/wxrcedit/propedit.cpp b/contrib/utils/wxrcedit/propedit.cpp
new file mode 100644 (file)
index 0000000..2a3e03f
--- /dev/null
@@ -0,0 +1,125 @@
+/////////////////////////////////////////////////////////////////////////////
+// Author:      Vaclav Slavik
+// Created:     2000/05/05
+// RCS-ID:      $Id$
+// Copyright:   (c) 2000 Vaclav Slavik
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+    #pragma implementation "propedit.h"
+#endif
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+    #pragma hdrstop
+#endif
+
+#include "wx/wx.h"
+#include "wx/xml/xml.h"
+#include "propframe.h"
+#include "propedit.h"
+#include "xmlhelpr.h"
+
+enum
+{
+    ID_CLEAR = wxID_HIGHEST + 1,
+    ID_DETAILS
+};
+
+
+
+BEGIN_EVENT_TABLE(PropEditCtrl, wxPanel)
+    EVT_BUTTON(ID_CLEAR, PropEditCtrl::OnButtonClear)
+    EVT_BUTTON(ID_DETAILS, PropEditCtrl::OnButtonDetails)
+END_EVENT_TABLE()
+
+void PropEditCtrl::OnButtonDetails(wxCommandEvent& event)
+{
+    OnDetails();
+}
+
+void PropEditCtrl::OnButtonClear(wxCommandEvent& event)
+{
+    Clear();
+}
+
+
+void PropEditCtrl::BeginEdit(const wxRect& rect, wxTreeItemId ti)
+{
+    m_CanSave = FALSE;
+    if (!m_Created)
+    {
+        wxSizer *sz = new wxBoxSizer(wxHORIZONTAL);
+        m_TheCtrl = CreateEditCtrl();
+        sz->Add(m_TheCtrl, 1);
+        if (HasDetails())
+            sz->Add(new wxButton(this, ID_DETAILS, _T("..."), wxDefaultPosition,
+                    wxSize(16,-1)));
+        if (HasClearButton())
+            sz->Add(new wxButton(this, ID_CLEAR, _T("X"), wxDefaultPosition,
+                    wxSize(16,-1)));
+        SetAutoLayout(TRUE);
+        SetSizer(sz);
+        m_Created = TRUE;
+    }
+
+    m_TheCtrl->SetFocus();
+
+    m_PropInfo = &(((PETreeData*)m_TreeCtrl->GetItemData(ti))->PropInfo);
+    m_TreeItem = ti;
+
+    SetSize(rect.x, rect.y, rect.width, rect.height);
+    Show(TRUE);
+    ReadValue();
+    m_CanSave = TRUE;
+}
+
+
+
+void PropEditCtrl::EndEdit()
+{
+    Show(FALSE);
+}
+
+
+
+wxTreeItemId PropEditCtrl::CreateTreeEntry(wxTreeItemId parent, const PropertyInfo& pinfo)
+{
+    wxTreeItemId t = m_TreeCtrl->AppendItem(parent, GetPropName(pinfo));
+    m_TreeCtrl->SetItemData(t, new PETreeData(this, pinfo));
+    if (IsPresent(pinfo))
+        m_TreeCtrl->SetItemBold(t, TRUE);
+    return t;
+}
+
+bool PropEditCtrl::IsPresent(const PropertyInfo& pinfo)
+{
+    return XmlFindNode(GetNode(), pinfo.Name) != NULL;
+}
+
+
+
+void PropEditCtrl::Clear()
+{
+    EndEdit();
+
+    wxXmlNode *n = XmlFindNode(GetNode(), m_PropInfo->Name);
+    if (n)
+    {
+        n->GetParent()->RemoveChild(n);
+        delete n;
+        m_TreeCtrl->SetItemBold(m_TreeItem, FALSE);
+    }
+}
+
+
+
+wxString PropEditCtrl::GetValueAsText(wxTreeItemId ti)
+{
+    PropertyInfo& pir = ((PETreeData*)m_TreeCtrl->GetItemData(ti))->PropInfo;
+    return XmlReadValue(GetNode(), pir.Name);
+}
+
diff --git a/contrib/utils/wxrcedit/propedit.h b/contrib/utils/wxrcedit/propedit.h
new file mode 100644 (file)
index 0000000..b743716
--- /dev/null
@@ -0,0 +1,87 @@
+/////////////////////////////////////////////////////////////////////////////
+// Purpose:     XML resources editor
+// Author:      Vaclav Slavik
+// Created:     2000/05/05
+// RCS-ID:      $Id$
+// Copyright:   (c) 2000 Vaclav Slavik
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+    #pragma interface "propedit.h"
+#endif
+
+#ifndef _PROPEDIT_H_
+#define _PROPEDIT_H_
+
+#include "wx/panel.h"
+#include "wx/treectrl.h"
+#include "nodesdb.h"
+#include "propframe.h"
+
+class WXDLLEXPORT wxXmlNode;
+class WXDLLEXPORT wxTreeCtrl;
+class WXDLLEXPORT wxTextCtrl;
+
+
+
+class PropEditCtrl : public wxPanel
+{
+    public:
+        PropEditCtrl(PropertiesFrame *propFrame)
+           : wxPanel(propFrame->m_valueWindow, -1),
+             m_PropFrame(propFrame), m_Created(FALSE), m_TreeCtrl(propFrame->m_tree) 
+             {Show(FALSE);}
+                
+        virtual void BeginEdit(const wxRect& rect, wxTreeItemId ti);
+        virtual void EndEdit();
+        
+        virtual wxTreeItemId CreateTreeEntry(wxTreeItemId parent, const PropertyInfo& pinfo);
+        virtual wxWindow* CreateEditCtrl() = 0;
+        
+        virtual bool IsPresent(const PropertyInfo& pinfo);
+        
+        virtual void Clear();
+        virtual void ReadValue() = 0;
+        virtual void WriteValue() = 0;
+        virtual wxString GetValueAsText(wxTreeItemId ti);
+        virtual wxString GetPropName(const PropertyInfo& pinfo)
+                { return pinfo.Name.AfterLast(_T('/')); }
+        
+        virtual bool HasDetails() { return FALSE; }
+        virtual void OnDetails() {}
+        virtual bool HasClearButton() { return TRUE; }
+        
+        void OnButtonDetails(wxCommandEvent& event);
+        void OnButtonClear(wxCommandEvent& event);
+    
+    protected:
+        wxXmlNode *GetNode() { return m_PropFrame->m_Node; }
+        bool CanSave() { return m_CanSave; }
+    
+        PropertiesFrame *m_PropFrame;
+        bool m_Created;
+        wxTreeCtrl *m_TreeCtrl;
+        wxTreeItemId m_TreeItem;
+        wxWindow *m_TheCtrl;
+        PropertyInfo *m_PropInfo;
+        
+        bool m_CanSave;
+        
+        DECLARE_EVENT_TABLE()
+};
+
+
+
+class PETreeData : public wxTreeItemData
+{
+    public:
+        PETreeData(PropEditCtrl *p, const PropertyInfo& pi) : 
+                wxTreeItemData(),
+                EditCtrl(p), PropInfo(pi) {}
+        PropEditCtrl *EditCtrl;
+        PropertyInfo PropInfo;
+};
+
+
+#endif
diff --git a/contrib/utils/wxrcedit/propframe.cpp b/contrib/utils/wxrcedit/propframe.cpp
new file mode 100644 (file)
index 0000000..cb82a0d
--- /dev/null
@@ -0,0 +1,293 @@
+/////////////////////////////////////////////////////////////////////////////
+// Author:      Vaclav Slavik
+// Created:     2000/05/05
+// RCS-ID:      $Id$
+// Copyright:   (c) 2000 Vaclav Slavik
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+    #pragma implementation "propframe.h"
+#endif
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+    #pragma hdrstop
+#endif
+
+#include "wx/wx.h"
+#include "wx/xml/xml.h"
+#include "wx/config.h"
+#include "splittree.h"
+#include "xmlhelpr.h"
+#include "propframe.h"
+#include "nodehnd.h"
+#include "propedit.h"
+#include "pe_basic.h"
+#include "pe_adv.h"
+
+// ------------- support classes --------
+
+
+class PropsTree: public wxRemotelyScrolledTreeCtrl
+{
+    public:
+        PropsTree(wxWindow* parent, wxWindowID id, const wxPoint& pt = wxDefaultPosition,
+            const wxSize& sz = wxDefaultSize, long style = wxTR_HAS_BUTTONS)
+            : wxRemotelyScrolledTreeCtrl(parent, id, pt, sz, style),
+              m_EditCtrl(NULL) {}
+
+           void OnPaint(wxPaintEvent& event)
+        {
+               wxPaintDC dc(this);
+
+               wxTreeCtrl::OnPaint(event);
+
+            // Reset the device origin since it may have been set
+            dc.SetDeviceOrigin(0, 0);
+
+               wxPen pen(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DLIGHT), 1, wxSOLID);
+               dc.SetPen(pen);
+            
+               dc.SetBrush(* wxTRANSPARENT_BRUSH);
+
+            wxSize clientSize = GetClientSize();
+               wxRect itemRect;
+               int cy=0;
+               wxTreeItemId h, lastH;
+               for(h=GetFirstVisibleItem();h;h=GetNextVisible(h))
+               {
+                       if (h.IsOk() && GetBoundingRect(h, itemRect))
+                       {
+                               cy = itemRect.GetTop();
+                               dc.DrawLine(0, cy, clientSize.x, cy);
+                               lastH = h;
+                       }
+               }
+               if (lastH.IsOk() && GetBoundingRect(lastH, itemRect))
+               {
+                       cy = itemRect.GetBottom();
+                       dc.DrawLine(0, cy, clientSize.x, cy);
+               }
+        }
+        
+        void OnSelChange(wxTreeEvent& event)
+        {
+            if (m_EditCtrl != NULL)
+            {
+                m_EditCtrl->EndEdit();
+                m_EditCtrl = NULL;
+            }
+        
+            wxTreeItemId item = event.GetItem();
+            PETreeData *dt = (PETreeData*)GetItemData(item);
+            if (dt != NULL)
+            {
+                wxRect bounding;
+                GetBoundingRect(item, bounding);
+                bounding.SetX(0);
+                bounding.SetWidth(GetCompanionWindow()->GetSize().x); 
+                dt->EditCtrl->BeginEdit(bounding, item);
+                m_EditCtrl = dt->EditCtrl;
+            }
+        }
+
+        void ClearProps()
+        {
+            DeleteAllItems();
+            AddRoot(_("Properties"));
+            if (m_EditCtrl)
+            {
+                m_EditCtrl->EndEdit();
+                m_EditCtrl = NULL;
+            }
+        }
+        
+        PropEditCtrl *m_EditCtrl;
+        
+        DECLARE_EVENT_TABLE()
+};
+
+BEGIN_EVENT_TABLE(PropsTree, wxRemotelyScrolledTreeCtrl)
+       EVT_PAINT(PropsTree::OnPaint)
+    EVT_TREE_SEL_CHANGED(-1, PropsTree::OnSelChange)
+END_EVENT_TABLE()
+
+
+class PropsValueWindow: public wxTreeCompanionWindow
+{
+    public:
+        PropsValueWindow(wxWindow* parent, wxWindowID id = -1,
+          const wxPoint& pos = wxDefaultPosition,
+          const wxSize& sz = wxDefaultSize,
+          long style = 0)
+           : wxTreeCompanionWindow(parent, id, pos, sz, style) {}
+           
+        virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect)
+        {
+               if (m_treeCtrl)
+               {
+                PETreeData *data = (PETreeData*)m_treeCtrl->GetItemData(id);
+                       wxString text;
+                if (data != NULL) text = data->EditCtrl->GetValueAsText(id);
+                dc.SetBrush(wxBrush(GetBackgroundColour(), wxSOLID));
+                dc.DrawRectangle(rect);
+                       dc.SetTextForeground(* wxBLACK);
+                       dc.SetBackgroundMode(wxTRANSPARENT);
+
+                       int textW, textH;
+                       dc.GetTextExtent(text, & textW, & textH);
+
+                       int x = 5;
+                       int y = rect.GetY() + wxMax(0, (rect.GetHeight() - textH) / 2);
+
+                       dc.DrawText(text, x, y);
+               }
+        }
+        
+        void OnClick(wxMouseEvent& event)
+        {
+            int flags;
+            wxTreeItemId item = GetTreeCtrl()->HitTest(wxPoint(1, event.GetY()), flags);
+            if (item.IsOk())
+            {
+                GetTreeCtrl()->ScrollTo(item);
+                GetTreeCtrl()->SelectItem(item);
+            }
+        }
+        
+        DECLARE_EVENT_TABLE()
+};
+
+BEGIN_EVENT_TABLE(PropsValueWindow, wxTreeCompanionWindow)
+       EVT_LEFT_DOWN(PropsValueWindow::OnClick)
+END_EVENT_TABLE()
+
+
+
+// ------------- properties frame --------
+
+
+
+PropertiesFrame* PropertiesFrame::ms_Instance = NULL;
+
+PropertiesFrame *PropertiesFrame::Get()
+{
+    if (ms_Instance == NULL) 
+    {
+        (void)new PropertiesFrame;
+        ms_Instance->Show(TRUE);
+    }
+    return ms_Instance;
+}
+
+PropertiesFrame::PropertiesFrame()
+    : wxFrame(NULL, -1, _("Properties"))
+{
+    ms_Instance = this;
+    m_Node = NULL;
+
+    m_scrolledWindow = new wxSplitterScrolledWindow(this, -1, wxDefaultPosition,
+               wxDefaultSize, wxNO_BORDER | wxCLIP_CHILDREN | wxVSCROLL);
+    m_splitter = new wxThinSplitterWindow(m_scrolledWindow, -1, wxDefaultPosition,
+               wxDefaultSize, wxSP_3DBORDER | wxCLIP_CHILDREN /* | wxSP_LIVE_UPDATE */);
+       m_splitter->SetSashSize(2);
+    m_tree = new PropsTree(m_splitter, -1, wxDefaultPosition,
+               wxDefaultSize, wxTR_HAS_BUTTONS | wxTR_NO_LINES | wxNO_BORDER );
+    m_tree->SetIndent(2);
+
+    m_valueWindow = new PropsValueWindow(m_splitter, -1, wxDefaultPosition,
+               wxDefaultSize, wxNO_BORDER);
+    m_valueWindow->SetBackgroundColour(m_tree->GetBackgroundColour());
+    m_splitter->SplitVertically(m_tree, m_valueWindow, wxConfig::Get()->Read(_T("propertiesframe_sash"), 100));
+       //m_splitter->AdjustScrollbars();
+       m_scrolledWindow->SetTargetWindow(m_tree);
+
+       m_scrolledWindow->EnableScrolling(FALSE, FALSE);
+
+       // Let the two controls know about each other
+       m_valueWindow->SetTreeCtrl(m_tree);
+       m_tree->SetCompanionWindow(m_valueWindow);
+
+    wxConfigBase *cfg = wxConfigBase::Get();
+    SetSize(wxRect(wxPoint(cfg->Read(_T("propertiesframe_x"), -1), cfg->Read(_T("propertiesframe_y"), -1)),
+            wxSize(cfg->Read(_T("propertiesframe_w"), 200), cfg->Read(_T("propertiesframe_h"), 200))));
+            
+
+    m_EditCtrls.DeleteContents(TRUE);
+    m_EditCtrls.Put(_T("bool"), new PropEditCtrlBool(this));
+    m_EditCtrls.Put(_T("coord"), new PropEditCtrlCoord(this));
+    m_EditCtrls.Put(_T("color"), new PropEditCtrlColor(this));
+    m_EditCtrls.Put(_T("dimension"), new PropEditCtrlDim(this));
+    m_EditCtrls.Put(_T("flags"), new PropEditCtrlTxt(this));
+    m_EditCtrls.Put(_T("integer"), new PropEditCtrlInt(this));
+    m_EditCtrls.Put(_T("not_implemented"), new PropEditCtrlNull(this));
+    m_EditCtrls.Put(_T("text"), new PropEditCtrlTxt(this));
+    m_EditCtrls.Put(_T("xmlid"), new PropEditCtrlXMLID(this));
+    m_EditCtrls.Put(_T("font"), new PropEditCtrlFont(this));
+    m_EditCtrls.Put(_T("choice"), new PropEditCtrlChoice(this));
+    m_EditCtrls.Put(_T(""), new PropEditCtrlNull(this));
+            
+    ClearProps();
+}
+
+
+
+PropertiesFrame::~PropertiesFrame()
+{
+    wxConfigBase *cfg = wxConfigBase::Get();  
+    cfg->Write(_T("propertiesframe_x"), (long)GetPosition().x);
+    cfg->Write(_T("propertiesframe_y"), (long)GetPosition().y);
+    cfg->Write(_T("propertiesframe_w"), (long)GetSize().x);
+    cfg->Write(_T("propertiesframe_h"), (long)GetSize().y);
+    cfg->Write(_T("propertiesframe_sash"), (long)m_splitter->GetSashPosition());
+    
+    ms_Instance = NULL;
+}
+
+
+        
+void PropertiesFrame::ShowProps(wxXmlNode *node)
+{
+   m_Node = node;
+   
+   ClearProps();
+   AddSingleProp(PropertyInfo(_T("xmlid"), _T("XMLID"), wxEmptyString));
+   AddProps(NodeHandler::Find(node)->GetPropsList(node));
+   
+   m_tree->Expand(m_tree->GetRootItem());
+   m_valueWindow->Refresh();
+}
+
+
+
+void PropertiesFrame::ClearProps()
+{
+    ((PropsTree*)m_tree)->ClearProps();
+}
+
+
+
+void PropertiesFrame::AddProps(PropertyInfoArray& plist)
+{
+    for (size_t i = 0; i < plist.GetCount(); i++)
+    {
+        AddSingleProp(plist[i]);
+    }
+}
+
+
+
+void PropertiesFrame::AddSingleProp(const PropertyInfo& pinfo)
+{
+    PropEditCtrl *pec = (PropEditCtrl*)m_EditCtrls.Get(pinfo.Type);
+    wxTreeItemId tid = m_tree->GetRootItem();
+    
+    if (pec == NULL)
+        wxLogError(_("Unknown property type '%s'!"), pinfo.Type.c_str());
+    else
+        pec->CreateTreeEntry(tid, pinfo);
+}
+
diff --git a/contrib/utils/wxrcedit/propframe.h b/contrib/utils/wxrcedit/propframe.h
new file mode 100644 (file)
index 0000000..6a95958
--- /dev/null
@@ -0,0 +1,55 @@
+/////////////////////////////////////////////////////////////////////////////
+// Purpose:     XML resources editor
+// Author:      Vaclav Slavik
+// Created:     2000/05/05
+// RCS-ID:      $Id$
+// Copyright:   (c) 2000 Vaclav Slavik
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+    #pragma interface "propframe.h"
+#endif
+
+#ifndef _PROPFRAME_H_
+#define _PROPFRAME_H_
+
+#include "splittree.h"
+
+class WXDLLEXPORT wxXmlNode;
+class PropEditCtrl;
+#include "wx/hash.h"
+#include "wx/frame.h"
+#include "nodesdb.h"
+
+class PropertiesFrame : public wxFrame
+{
+    public:
+        PropertiesFrame();
+        ~PropertiesFrame();
+        
+        void ShowProps(wxXmlNode *node);
+        
+        void ClearProps();
+        void AddProps(PropertyInfoArray& plist);
+        void AddSingleProp(const PropertyInfo& pinfo);
+      
+        static PropertiesFrame *Get();
+           
+    private:
+
+        static PropertiesFrame *ms_Instance;
+        wxXmlNode *m_Node;
+
+        wxRemotelyScrolledTreeCtrl *m_tree;
+        wxThinSplitterWindow *m_splitter;
+           wxSplitterScrolledWindow *m_scrolledWindow;
+        wxTreeCompanionWindow *m_valueWindow;
+        
+        wxHashTable m_EditCtrls;
+        
+        friend class PropEditCtrl;
+};
+
+
+#endif
diff --git a/contrib/utils/wxrcedit/prophnd.cpp b/contrib/utils/wxrcedit/prophnd.cpp
deleted file mode 100644 (file)
index e202886..0000000
+++ /dev/null
@@ -1,407 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////
-// Author:      Vaclav Slavik
-// Created:     2000/05/05
-// RCS-ID:      $Id$
-// Copyright:   (c) 2000 Vaclav Slavik
-// Licence:     wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifdef __GNUG__
-    #pragma implementation "prophnd.h"
-#endif
-
-// For compilers that support precompilation, includes "wx/wx.h".
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
-    #pragma hdrstop
-#endif
-
-#include "prophnd.h"
-#include "wx/xml/xml.h"
-#include "wx/wx.h"
-#include "wx/arrimpl.cpp"
-#include "wx/valtext.h"
-#include "wx/tokenzr.h"
-#include "wx/checklst.h"
-#include "wx/listctrl.h"
-#include "xmlhelpr.h"
-#include "editor.h"
-
-
-WX_DEFINE_OBJARRAY(PropertyInfoArray);
-
-
-enum
-{
-    ID_EDITCTRL = wxID_HIGHEST + 1000,
-    ID_XEDIT,
-    ID_YEDIT,
-    ID_USEDLG,
-    ID_BOOLVAL,
-    ID_CHECKLIST
-};
-
-
-
-class PropertyPanel : public wxPanel
-{
-    public:
-        PropertyPanel(wxWindow *parent, PropertyHandler *hnd, PropsListInfo *pli) 
-                    : wxPanel(parent, -1), m_Handler(hnd), m_PLI(pli) {}
-        
-        void Update(const wxString& value)
-        {
-            XmlWriteValue(m_PLI->m_Node, m_PLI->m_PropInfo->Name, value);
-            m_PLI->m_ListCtrl->SetItemImage(m_PLI->m_Index, 1, 1);
-            m_PLI->m_ListCtrl->SetItem(m_PLI->m_Index, 1, 
-                   m_Handler->GetBriefValue(m_PLI->m_Node, m_PLI->m_PropInfo));
-        }
-    
-    protected:
-        PropertyHandler *m_Handler;
-        PropsListInfo *m_PLI;
-};
-
-
-
-
-
-int PropertyHandler::CreateListItem(wxListCtrl *listctrl, wxXmlNode *node, PropertyInfo *pi)
-{
-    wxString name, value;
-    int iconnum;
-    
-    if (XmlFindNode(node, pi->Name) == NULL) iconnum = 0; else iconnum = 1;
-    name = pi->Name;
-    value = GetBriefValue(node, pi);
-
-    long pos = listctrl->GetItemCount();
-    listctrl->InsertItem(pos, name, iconnum);
-    listctrl->SetItem(pos, 1, value);
-    return pos;
-}
-
-
-
-wxString PropertyHandler::GetBriefValue(wxXmlNode *node, PropertyInfo *pi)
-{
-    return XmlReadValue(node, pi->Name);
-}
-
-
-
-
-
-
-class TextPropPanel : public PropertyPanel
-{
-    public:
-        TextPropPanel(wxWindow *parent, PropertyHandler *hnd, PropsListInfo *pli) : PropertyPanel(parent, hnd, pli)
-        {
-            wxSizer *sz = new wxBoxSizer(wxVERTICAL);
-            wxTextCtrl *tc;
-    
-            sz->Add(new wxStaticText(this, -1, _("Value:")), 0, wxLEFT, 5);
-            sz->Add(tc = new wxTextCtrl(this, ID_EDITCTRL, XmlReadValue(pli->m_Node, pli->m_PropInfo->Name)), 0, wxALL|wxEXPAND, 5);
-            tc->SetFocus();
-    
-            SetAutoLayout(TRUE);
-            SetSizer(sz);
-            Layout();
-        }
-        
-        void OnEdit(wxCommandEvent &event)
-        {
-            Update(((wxTextCtrl*)event.GetEventObject())->GetValue());
-        }
-        
-        DECLARE_EVENT_TABLE()
-};
-
-BEGIN_EVENT_TABLE(TextPropPanel, PropertyPanel)
-    EVT_TEXT(ID_EDITCTRL, TextPropPanel::OnEdit)
-END_EVENT_TABLE()
-
-
-wxPanel *TextPropertyHandler::CreateEditPanel(wxWindow *parent, PropsListInfo *pli)
-{
-    return new TextPropPanel(parent, this, pli);
-}
-
-
-
-
-
-
-
-
-
-
-
-class CoordPropPanel : public PropertyPanel
-{
-    public:
-        CoordPropPanel(wxWindow *parent, PropertyHandler *hnd, PropsListInfo *pli) : PropertyPanel(parent, hnd, pli)
-        {    
-            wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
-            wxSizer *sz = new wxBoxSizer(wxHORIZONTAL);
-            m_ed1 = m_ed2 = NULL; m_chb = NULL;
-    
-            sz->Add(new wxStaticText(this, -1, _("X:")), 0, wxLEFT|wxRIGHT|wxALIGN_CENTER, 5);
-            sz->Add(m_ed1 = new wxTextCtrl(this, ID_XEDIT, "",
-                                 wxDefaultPosition, wxDefaultSize, 0,
-                                 wxTextValidator(wxFILTER_NUMERIC)),
-                    1, wxRIGHT, 5);
-            m_ed1->SetFocus();
-
-            sz->Add(new wxStaticText(this, -1, _("Y:")), 0, wxLEFT|wxRIGHT|wxALIGN_CENTER, 5);
-            sz->Add(m_ed2 = new wxTextCtrl(this, ID_YEDIT, "",
-                                 wxDefaultPosition, wxDefaultSize, 0,
-                                 wxTextValidator(wxFILTER_NUMERIC)),
-                    1, wxRIGHT, 5);
-            sizer->Add(sz, 0, wxEXPAND|wxTOP, 5);
-    
-            sizer->Add(m_chb = new wxCheckBox(this, ID_USEDLG, _("Use dialog units")), 0, wxLEFT|wxTOP, 5);
-    
-            SetAutoLayout(TRUE);
-            SetSizer(sizer);
-            Layout();
-            
-            wxString val = XmlReadValue(pli->m_Node, pli->m_PropInfo->Name);
-            m_chb->SetValue(val.Len()==0 || val[val.Len()-1] == 'd');
-            m_ed1->SetValue(val.BeforeFirst(','));
-            m_ed2->SetValue(val.AfterFirst(',').BeforeFirst('d'));
-        }
-        
-        void OnEdit(wxCommandEvent &event)
-        {
-            wxString val, v1, v2;
-            
-            if (m_ed1 == NULL || m_ed2 == NULL || m_chb == NULL) return;
-            
-            v1 = m_ed1->GetValue();
-            v2 = m_ed2->GetValue();
-            if (v1.IsEmpty() || v2.IsEmpty()) return;
-            val = v1 + "," + v2;
-            if (m_chb->GetValue()) val << 'd';
-            Update(val);
-        }
-        
-        wxTextCtrl *m_ed1, *m_ed2;
-        wxCheckBox *m_chb;
-        
-        DECLARE_EVENT_TABLE()
-};
-
-BEGIN_EVENT_TABLE(CoordPropPanel, PropertyPanel)
-    EVT_TEXT(ID_XEDIT, CoordPropPanel::OnEdit)
-    EVT_TEXT(ID_YEDIT, CoordPropPanel::OnEdit)
-    EVT_CHECKBOX(ID_USEDLG, CoordPropPanel::OnEdit)
-END_EVENT_TABLE()
-
-wxPanel *CoordPropertyHandler::CreateEditPanel(wxWindow *parent, PropsListInfo *pli)
-{
-    return new CoordPropPanel(parent, this, pli);
-}
-
-
-
-
-
-
-
-class DimensionPropPanel : public PropertyPanel
-{
-    public:
-        DimensionPropPanel(wxWindow *parent, PropertyHandler *hnd, PropsListInfo *pli) : PropertyPanel(parent, hnd, pli)
-        {    
-            wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
-            m_ed1 = NULL; m_chb = NULL;
-    
-            sizer->Add(new wxStaticText(this, -1, _("Value:")), 0, wxLEFT, 5);
-            sizer->Add(m_ed1 = new wxTextCtrl(this, ID_XEDIT, "",
-                                 wxDefaultPosition, wxDefaultSize, 0,
-                                 wxTextValidator(wxFILTER_NUMERIC)),
-                    0, wxEXPAND, 5);
-            m_ed1->SetFocus();
-    
-            sizer->Add(m_chb = new wxCheckBox(this, ID_USEDLG, _("Use dialog units")), 0, wxLEFT|wxTOP, 5);
-    
-            SetAutoLayout(TRUE);
-            SetSizer(sizer);
-            Layout();
-            
-            wxString val = XmlReadValue(pli->m_Node, pli->m_PropInfo->Name);
-            m_chb->SetValue(val.Len()>0 && val[val.Len()-1] == 'd');
-            m_ed1->SetValue(val.BeforeFirst('d'));
-        }
-        
-        void OnEdit(wxCommandEvent &event)
-        {
-            wxString val;
-            
-            if (m_ed1 == NULL || m_chb == NULL) return;
-            
-            val = m_ed1->GetValue();
-            if (val.IsEmpty()) return;
-            if (m_chb->GetValue()) val << 'd';
-            Update(val);
-        }
-        
-        wxTextCtrl *m_ed1;
-        wxCheckBox *m_chb;
-        
-        DECLARE_EVENT_TABLE()
-};
-
-BEGIN_EVENT_TABLE(DimensionPropPanel, PropertyPanel)
-    EVT_TEXT(ID_XEDIT, DimensionPropPanel::OnEdit)
-    EVT_TEXT(ID_YEDIT, DimensionPropPanel::OnEdit)
-    EVT_CHECKBOX(ID_USEDLG, DimensionPropPanel::OnEdit)
-END_EVENT_TABLE()
-
-wxPanel *DimensionPropertyHandler::CreateEditPanel(wxWindow *parent, PropsListInfo *pli)
-{
-    return new DimensionPropPanel(parent, this, pli);
-}
-
-
-
-
-
-
-
-class BoolPropPanel : public PropertyPanel
-{
-    public:
-        BoolPropPanel(wxWindow *parent, PropertyHandler *hnd, PropsListInfo *pli) : PropertyPanel(parent, hnd, pli)
-        {    
-            m_chb = NULL;
-            wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
-            sizer->Add(m_chb = new wxCheckBox(this, ID_BOOLVAL, _("On/Yes/True")), 0, wxLEFT|wxTOP, 5);
-            SetAutoLayout(TRUE);
-            SetSizer(sizer);
-            Layout();
-            m_chb->SetValue(XmlReadValue(pli->m_Node, pli->m_PropInfo->Name) == "1");
-        }
-        
-        void OnEdit(wxCommandEvent &event)
-        {
-            if (m_chb == NULL) return;
-            if (m_chb->GetValue()) Update("1");
-            else Update("0");
-        }
-        
-        wxCheckBox *m_chb;
-        
-        DECLARE_EVENT_TABLE()
-};
-
-BEGIN_EVENT_TABLE(BoolPropPanel, PropertyPanel)
-    EVT_CHECKBOX(ID_BOOLVAL, BoolPropPanel::OnEdit)
-END_EVENT_TABLE()
-
-wxPanel *BoolPropertyHandler::CreateEditPanel(wxWindow *parent, PropsListInfo *pli)
-{
-    return new BoolPropPanel(parent, this, pli);
-}
-
-wxString BoolPropertyHandler::GetBriefValue(wxXmlNode *node, PropertyInfo *pi)
-{
-    wxString v = XmlReadValue(node, pi->Name);
-    if (v.IsEmpty()) return wxEmptyString;
-    else if (v == "1") return "true";
-    else return "false";
-}
-
-
-
-
-
-
-
-
-class FlagsPropPanel : public PropertyPanel
-{
-    public:
-        FlagsPropPanel(wxWindow *parent, PropertyHandler *hnd, PropsListInfo *pli) : PropertyPanel(parent, hnd, pli)
-        {    
-            m_chl = NULL;
-            wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
-            sizer->Add(m_chl = new wxCheckListBox(this, ID_CHECKLIST), 1, wxEXPAND|wxALL, 5);
-            SetAutoLayout(TRUE);
-            SetSizer(sizer);
-            Layout();
-            
-            {
-                wxStringTokenizer tkn(pli->m_PropInfo->MoreInfo, ",");
-                wxString s;
-                while (tkn.HasMoreTokens())
-                {
-                    s = tkn.GetNextToken();
-                    m_chl->Append(s);
-                    m_flags.Add(s);
-                }
-            }
-
-            {
-                wxStringTokenizer tkn(XmlReadValue(pli->m_Node, pli->m_PropInfo->Name), "| ");
-                int index;
-                while (tkn.HasMoreTokens())
-                {
-                    index = m_flags.Index(tkn.GetNextToken());
-                    if (index != wxNOT_FOUND)
-                        m_chl->Check(index);
-                }
-            }
-        }
-        
-        void OnEdit(wxCommandEvent &event)
-        {
-            wxString s;
-            bool first = TRUE;
-            
-            for (size_t i = 0; i < m_flags.GetCount(); i++)
-            {
-                if (m_chl->IsChecked(i))
-                {
-                    if (!first) s << '|';
-                    s << m_flags[i];
-                    first = FALSE;
-                }
-            }
-            Update(s);
-            if (m_PLI->m_PropInfo->Name == "orient") 
-                // FIXME - dirty hack related to sizers
-                EditorFrame::Get()->NotifyChanged(CHANGED_TREE_SELECTED_ICON);
-        }
-        
-        wxCheckListBox *m_chl;
-        wxArrayString m_flags;
-        
-        DECLARE_EVENT_TABLE()
-};
-
-BEGIN_EVENT_TABLE(FlagsPropPanel, PropertyPanel)
-    EVT_CHECKLISTBOX(ID_CHECKLIST, FlagsPropPanel::OnEdit)
-END_EVENT_TABLE()
-
-wxPanel *FlagsPropertyHandler::CreateEditPanel(wxWindow *parent, PropsListInfo *pli)
-{
-    return new FlagsPropPanel(parent, this, pli);
-}
-
-
-
-
-wxPanel *NotImplPropertyHandler::CreateEditPanel(wxWindow *parent, PropsListInfo *pli)
-{
-    wxPanel *p = new wxPanel(parent);
-    wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
-    sizer->Add(new wxStaticText(p, -1, _("Sorry, this is not supported.\nYou have to edit XML code directly.")), 1, wxEXPAND|wxALL, 5);
-    p->SetAutoLayout(TRUE);
-    p->SetSizer(sizer);
-    p->Layout();
-    return p;
-}
diff --git a/contrib/utils/wxrcedit/prophnd.h b/contrib/utils/wxrcedit/prophnd.h
deleted file mode 100644 (file)
index a130110..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////
-// Purpose:     XML resources editor
-// Author:      Vaclav Slavik
-// Created:     2000/05/05
-// RCS-ID:      $Id$
-// Copyright:   (c) 2000 Vaclav Slavik
-// Licence:     wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifdef __GNUG__
-    #pragma interface "prophnd.h"
-#endif
-
-#ifndef _PROPHND_H_
-#define _PROPHND_H_
-
-
-class WXDLLEXPORT wxXmlNode;
-class WXDLLEXPORT wxList;
-class WXDLLEXPORT wxListCtrl;
-class WXDLLEXPORT wxPanel;
-class WXDLLEXPORT wxWindow;
-
-#include "wx/xml/xml.h"
-#include "wx/dynarray.h"
-
-/* ADD NEW PROPERTY TYPES HERE 
-   (search for other occurences of this comment in _all_ files) */
-enum PropertyType
-{
-    PROP_TEXT = 0,
-    PROP_FLAGS = 1,
-    PROP_COLOR = 2,
-    PROP_BOOL = 3,
-    PROP_INTEGER = 4,
-    PROP_COORD = 5,
-    PROP_DIMENSION = 6,
-    PROP_NOT_IMPLEMENTED = 7,
-};
-#define PROP_TYPES_CNT  8
-
-class PropertyInfo
-{
-    public:
-        PropertyType Type;
-        wxString Name;
-        wxString MoreInfo;
-};
-
-WX_DECLARE_OBJARRAY(PropertyInfo, PropertyInfoArray);
-
-
-class PropertyHandler;
-
-class PropsListInfo : public wxObject
-{
-    public:
-        PropsListInfo(int index, PropertyHandler *hnd, wxXmlNode *node, 
-                      PropertyInfo *pi, wxListCtrl *listctrl) :
-                         m_Index(index), m_Handler(hnd), m_Node(node), 
-                        m_PropInfo(pi), m_ListCtrl(listctrl) {}
-        virtual ~PropsListInfo() {}
-        
-        int m_Index;
-        PropertyHandler *m_Handler;
-        wxXmlNode *m_Node;
-        PropertyInfo *m_PropInfo;
-        wxListCtrl *m_ListCtrl;
-};
-
-
-
-
-class PropertyHandler
-{
-    public:
-        PropertyHandler() {}
-        
-        int CreateListItem(wxListCtrl *listctrl, wxXmlNode *node, PropertyInfo *pi);
-        
-        virtual wxString GetBriefValue(wxXmlNode *node, PropertyInfo *pi);
-        virtual wxPanel *CreateEditPanel(wxWindow *parent, PropsListInfo *pli) = 0;
-};
-
-
-
-class TextPropertyHandler : public PropertyHandler
-{
-    public:
-        TextPropertyHandler() {}
-        virtual wxPanel *CreateEditPanel(wxWindow *parent, PropsListInfo *pli);
-};
-
-
-class CoordPropertyHandler : public PropertyHandler
-{
-    public:
-        CoordPropertyHandler() {}
-        virtual wxPanel *CreateEditPanel(wxWindow *parent, PropsListInfo *pli);
-};
-
-
-class DimensionPropertyHandler : public PropertyHandler
-{
-    public:
-        DimensionPropertyHandler() {}
-        virtual wxPanel *CreateEditPanel(wxWindow *parent, PropsListInfo *pli);
-};
-
-
-class BoolPropertyHandler : public PropertyHandler
-{
-    public:
-        BoolPropertyHandler() {}
-        virtual wxString GetBriefValue(wxXmlNode *node, PropertyInfo *pi);
-        virtual wxPanel *CreateEditPanel(wxWindow *parent, PropsListInfo *pli);
-};
-
-
-class FlagsPropertyHandler : public PropertyHandler
-{
-    public:
-        FlagsPropertyHandler() {}
-        virtual wxPanel *CreateEditPanel(wxWindow *parent, PropsListInfo *pli);
-};
-
-
-
-class NotImplPropertyHandler : public PropertyHandler
-{
-    public:
-        NotImplPropertyHandler() {}
-        virtual wxPanel *CreateEditPanel(wxWindow *parent, PropsListInfo *pli);
-};
-
-
-#endif 
diff --git a/contrib/utils/wxrcedit/splittree.cpp b/contrib/utils/wxrcedit/splittree.cpp
new file mode 100644 (file)
index 0000000..c5499bb
--- /dev/null
@@ -0,0 +1,634 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        splittree.cpp
+// Purpose:     Classes to achieve a remotely-scrolled tree in a splitter
+//              window that can be scrolled by a scrolled window higher in the
+//              hierarchy
+// Author:      Julian Smart
+// Modified by:
+// Created:     8/7/2000
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+#ifdef __GNUG__
+    #pragma implementation "splittree.h"
+#endif
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+    #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers (this file is usually all you
+// need because it includes almost all "standard" wxWindows headers)
+#ifndef WX_PRECOMP
+    #include "wx/wx.h"
+#endif
+
+#include "wx/generic/treectlg.h"
+
+#include "splittree.h"
+
+/*
+ * wxRemotelyScrolledTreeCtrl
+ */
+
+#if USE_GENERIC_TREECTRL
+IMPLEMENT_CLASS(wxRemotelyScrolledTreeCtrl, wxGenericTreeCtrl)
+#else
+IMPLEMENT_CLASS(wxRemotelyScrolledTreeCtrl, wxTreeCtrl)
+#endif
+
+#if USE_GENERIC_TREECTRL
+BEGIN_EVENT_TABLE(wxRemotelyScrolledTreeCtrl, wxGenericTreeCtrl)
+#else
+BEGIN_EVENT_TABLE(wxRemotelyScrolledTreeCtrl, wxTreeCtrl)
+#endif
+       EVT_SIZE(wxRemotelyScrolledTreeCtrl::OnSize)
+       EVT_TREE_ITEM_EXPANDED(-1, wxRemotelyScrolledTreeCtrl::OnExpand)
+       EVT_TREE_ITEM_COLLAPSED(-1, wxRemotelyScrolledTreeCtrl::OnExpand)
+       EVT_SCROLLWIN(wxRemotelyScrolledTreeCtrl::OnScroll)
+END_EVENT_TABLE()
+
+wxRemotelyScrolledTreeCtrl::wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pt,
+        const wxSize& sz, long style):
+        wxTreeCtrl(parent, id, pt, sz, style)
+{
+       m_companionWindow = NULL;
+}
+
+wxRemotelyScrolledTreeCtrl::~wxRemotelyScrolledTreeCtrl()
+{
+}
+
+void wxRemotelyScrolledTreeCtrl::HideVScrollbar()
+{
+#ifdef __WXMSW__
+    if (!IsKindOf(CLASSINFO(wxGenericTreeCtrl)))
+    {
+        ::ShowScrollBar((HWND) GetHWND(), SB_VERT, FALSE);
+    }
+    else
+#endif
+    {
+        // Implicit in overriding SetScrollbars
+    }
+}
+
+// Number of pixels per user unit (0 or -1 for no scrollbar)
+// Length of virtual canvas in user units
+// Length of page in user units
+void wxRemotelyScrolledTreeCtrl::SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
+                             int noUnitsX, int noUnitsY,
+                             int xPos, int yPos,
+                             bool noRefresh)
+{
+    if (IsKindOf(CLASSINFO(wxGenericTreeCtrl)))
+    {
+        wxGenericTreeCtrl* win = (wxGenericTreeCtrl*) this;
+        win->wxGenericTreeCtrl::SetScrollbars(pixelsPerUnitX, 0, noUnitsX, 0, xPos, 0, noRefresh);
+
+           wxScrolledWindow* scrolledWindow = GetScrolledWindow();
+           if (scrolledWindow)
+           {
+            scrolledWindow->SetScrollbars(0, pixelsPerUnitY, 0, noUnitsY, 0, yPos, noRefresh);
+        }
+    }
+}
+
+// In case we're using the generic tree control.
+int wxRemotelyScrolledTreeCtrl::GetScrollPos(int orient) const
+{
+    wxScrolledWindow* scrolledWindow = GetScrolledWindow();
+
+    if (IsKindOf(CLASSINFO(wxGenericTreeCtrl)))
+    {
+        wxGenericTreeCtrl* win = (wxGenericTreeCtrl*) this;
+
+        if (orient == wxHORIZONTAL)
+            return win->wxGenericTreeCtrl::GetScrollPos(orient);
+        else
+        {
+            return scrolledWindow->GetScrollPos(orient);
+        }
+    }
+    return 0;
+}
+
+
+// In case we're using the generic tree control.
+// Get the view start
+void wxRemotelyScrolledTreeCtrl::GetViewStart(int *x, int *y) const
+{
+    wxScrolledWindow* scrolledWindow = GetScrolledWindow();
+
+    if (IsKindOf(CLASSINFO(wxGenericTreeCtrl)))
+    {
+
+        wxGenericTreeCtrl* win = (wxGenericTreeCtrl*) this;
+        int x1, y1, x2, y2;
+        win->wxGenericTreeCtrl::GetViewStart(& x1, & y1);
+        * x = x1; * y = y1;
+        if (!scrolledWindow)
+            return;
+
+        scrolledWindow->GetViewStart(& x2, & y2);
+        * y = y2;
+    }
+       else
+       {
+               // x is wrong since the horizontal scrollbar is controlled by the
+               // tree control, but we probably don't need it.
+        scrolledWindow->GetViewStart(x, y);
+       }
+}
+
+// In case we're using the generic tree control.
+void wxRemotelyScrolledTreeCtrl::PrepareDC(wxDC& dc)
+{
+    if (IsKindOf(CLASSINFO(wxGenericTreeCtrl)))
+    {
+           wxScrolledWindow* scrolledWindow = GetScrolledWindow();
+
+        wxGenericTreeCtrl* win = (wxGenericTreeCtrl*) this;
+
+        int startX, startY;
+        GetViewStart(& startX, & startY);
+
+        int xppu1, yppu1, xppu2, yppu2;
+        win->wxGenericTreeCtrl::GetScrollPixelsPerUnit(& xppu1, & yppu1);
+        scrolledWindow->GetScrollPixelsPerUnit(& xppu2, & yppu2);
+
+        dc.SetDeviceOrigin( -startX * xppu1, -startY * yppu2 );
+        dc.SetUserScale( win->GetScaleX(), win->GetScaleY() );
+    }
+}
+
+// Scroll to the given line (in scroll units where each unit is
+// the height of an item)
+void wxRemotelyScrolledTreeCtrl::ScrollToLine(int posHoriz, int posVert)
+{
+#ifdef __WXMSW__
+    if (!IsKindOf(CLASSINFO(wxGenericTreeCtrl)))
+    {
+           UINT sbCode = SB_THUMBPOSITION;
+           HWND vertScrollBar = 0;
+           MSWDefWindowProc((WXUINT) WM_VSCROLL, MAKELONG(sbCode, posVert), (WXHWND) vertScrollBar);
+    }
+    else
+#endif
+    {
+        wxGenericTreeCtrl* win = (wxGenericTreeCtrl*) this;
+               win->Refresh();
+               /* Doesn't work yet because scrolling is ignored by Scroll
+        int xppu, yppu;
+           wxScrolledWindow* scrolledWindow = GetScrolledWindow();
+           if (scrolledWindow)
+           {
+                       scrolledWindow->GetScrollPixelsPerUnit(& xppu, & yppu);
+                       win->Scroll(-1, posVert*yppu);
+               }
+               */
+    }
+}
+
+void wxRemotelyScrolledTreeCtrl::OnSize(wxSizeEvent& event)
+{
+       HideVScrollbar();
+       AdjustRemoteScrollbars();
+       event.Skip();
+}
+
+void wxRemotelyScrolledTreeCtrl::OnExpand(wxTreeEvent& event)
+{
+       AdjustRemoteScrollbars();
+       event.Skip();
+
+    // If we don't have this, we get some bits of lines still remaining
+    if (event.GetEventType() == wxEVT_COMMAND_TREE_ITEM_COLLAPSED)
+        Refresh();
+
+       // Pass on the event
+       if (m_companionWindow)
+               m_companionWindow->GetEventHandler()->ProcessEvent(event);
+}
+
+// Adjust the containing wxScrolledWindow's scrollbars appropriately
+void wxRemotelyScrolledTreeCtrl::AdjustRemoteScrollbars()
+{
+    if (IsKindOf(CLASSINFO(wxGenericTreeCtrl)))
+       {
+               // This is for the generic tree control.
+               // It calls SetScrollbars which has been overridden
+               // to adjust the parent scrolled window vertical
+               // scrollbar.
+               ((wxGenericTreeCtrl*) this)->AdjustMyScrollbars();
+        return;
+       }
+       else
+       {
+               // This is for the wxMSW tree control
+               wxScrolledWindow* scrolledWindow = GetScrolledWindow();
+               if (scrolledWindow)
+               {
+                       wxRect itemRect;
+                       if (GetBoundingRect(GetRootItem(), itemRect))
+                       {
+                               int itemHeight = itemRect.GetHeight();
+                               
+                               int w, h;
+                               GetClientSize(&w, &h);
+                               
+                               wxRect rect(0, 0, 0, 0);
+                               CalcTreeSize(rect);
+                               int treeViewHeight = rect.GetHeight()/itemHeight;
+                               
+                               int scrollPixelsPerLine = itemHeight;
+                               int scrollPos = - (itemRect.y / itemHeight);
+                               
+                               scrolledWindow->SetScrollbars(0, scrollPixelsPerLine, 0, treeViewHeight, 0, scrollPos);
+                               
+                               // Ensure that when a scrollbar becomes hidden or visible,
+                               // the contained window sizes are right.
+                               // Problem: this is called too early (?)
+                               wxSizeEvent event(scrolledWindow->GetSize(), scrolledWindow->GetId());
+                               scrolledWindow->GetEventHandler()->ProcessEvent(event);
+                       }
+               }
+       }
+}
+
+
+// Calculate the area that contains both rectangles
+static wxRect CombineRectangles(const wxRect& rect1, const wxRect& rect2)
+{
+    wxRect rect;
+
+    int right1 = rect1.GetRight();
+    int bottom1 = rect1.GetBottom();
+    int right2 = rect2.GetRight();
+    int bottom2 = rect2.GetBottom();
+    
+    wxPoint topLeft = wxPoint(wxMin(rect1.x, rect2.x), wxMin(rect1.y, rect2.y));
+    wxPoint bottomRight = wxPoint(wxMax(right1, right2), wxMax(bottom1, bottom2));
+    
+    rect.x = topLeft.x; rect.y = topLeft.y;
+    rect.SetRight(bottomRight.x);
+    rect.SetBottom(bottomRight.y);
+
+    return rect;
+}
+
+
+// Calculate the tree overall size so we can set the scrollbar
+// correctly
+void wxRemotelyScrolledTreeCtrl::CalcTreeSize(wxRect& rect)
+{
+       CalcTreeSize(GetRootItem(), rect);
+}
+
+void wxRemotelyScrolledTreeCtrl::CalcTreeSize(const wxTreeItemId& id, wxRect& rect)
+{
+       // TODO: implement GetFirst/NextVisibleItem
+       // for wxGenericTreeCtrl, plus GetBoundingRect.
+
+       // More efficient implementation would be to find the last item (but how?)
+       // Q: is the bounding rect relative to the top of the virtual tree workspace
+       // or the top of the window? How would we convert?
+       wxRect itemSize;
+       if (GetBoundingRect(id, itemSize))
+       {
+               rect = CombineRectangles(rect, itemSize);
+       }
+
+       long cookie;
+       wxTreeItemId childId = GetFirstChild(id, cookie);
+       while (childId != 0)
+       {
+               CalcTreeSize(childId, rect);
+               childId = GetNextChild(childId, cookie);
+       }
+}
+
+// Find the scrolled window that contains this control
+wxScrolledWindow* wxRemotelyScrolledTreeCtrl::GetScrolledWindow() const
+{
+       wxWindow* parent = wxWindow::GetParent();
+       while (parent)
+       {
+               if (parent->IsKindOf(CLASSINFO(wxScrolledWindow)))
+                       return (wxScrolledWindow*) parent;
+               parent = parent->GetParent();
+       }
+       return NULL;
+}
+
+void wxRemotelyScrolledTreeCtrl::OnScroll(wxScrollWinEvent& event)
+{
+    int orient = event.GetOrientation();
+    if (orient == wxHORIZONTAL)
+    {
+        event.Skip();
+        return;
+    }
+    wxScrolledWindow* scrollWin = GetScrolledWindow();
+    if (!scrollWin)
+        return;
+
+    int x, y;
+    scrollWin->GetViewStart(& x, & y);
+
+    ScrollToLine(-1, y);
+}
+
+/*
+ * wxTreeCompanionWindow
+ *
+ * A window displaying values associated with tree control items.
+ */
+
+IMPLEMENT_CLASS(wxTreeCompanionWindow, wxWindow)
+
+BEGIN_EVENT_TABLE(wxTreeCompanionWindow, wxWindow)
+       EVT_PAINT(wxTreeCompanionWindow::OnPaint)
+       EVT_SCROLLWIN(wxTreeCompanionWindow::OnScroll)
+       EVT_TREE_ITEM_EXPANDED(-1, wxTreeCompanionWindow::OnExpand)
+       EVT_TREE_ITEM_COLLAPSED(-1, wxTreeCompanionWindow::OnExpand)
+END_EVENT_TABLE()
+
+wxTreeCompanionWindow::wxTreeCompanionWindow(wxWindow* parent, wxWindowID id,
+      const wxPoint& pos,
+      const wxSize& sz,
+      long style):
+       wxWindow(parent, id, pos, sz, style)
+{
+       m_treeCtrl = NULL;
+}
+
+void wxTreeCompanionWindow::DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect)
+{
+       // TEST CODE
+#if 1
+       if (m_treeCtrl)
+       {
+               wxString text = m_treeCtrl->GetItemText(id);
+               dc.SetTextForeground(* wxBLACK);
+               dc.SetBackgroundMode(wxTRANSPARENT);
+
+               int textW, textH;
+               dc.GetTextExtent(text, & textW, & textH);
+
+               int x = 5;
+               int y = rect.GetY() + wxMax(0, (rect.GetHeight() - textH) / 2);
+
+               dc.DrawText(text, x, y);
+       }
+#endif
+}
+
+void wxTreeCompanionWindow::OnPaint(wxPaintEvent& event)
+{
+       wxPaintDC dc(this);
+
+    if (!m_treeCtrl)
+        return;
+
+        wxPen pen(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DLIGHT), 1, wxSOLID);
+       dc.SetPen(pen);
+       dc.SetBrush(* wxTRANSPARENT_BRUSH);
+       wxFont font(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
+       dc.SetFont(font);
+
+    wxSize clientSize = GetClientSize();
+       wxRect itemRect;
+       int cy=0;
+       wxTreeItemId h, lastH;
+       for(h=m_treeCtrl->GetFirstVisibleItem();h;h=m_treeCtrl->GetNextVisible(h))
+       {
+               if (m_treeCtrl->GetBoundingRect(h, itemRect))
+               {
+                       cy = itemRect.GetTop();
+                       wxRect drawItemRect(0, cy, clientSize.x, itemRect.GetHeight());
+
+                       lastH = h;
+
+                       // Draw the actual item
+                       DrawItem(dc, h, drawItemRect);
+                       dc.DrawLine(0, cy, clientSize.x, cy);
+               }
+       }
+       if (lastH.IsOk() && m_treeCtrl->GetBoundingRect(lastH, itemRect))
+       {
+               cy = itemRect.GetBottom();
+               dc.DrawLine(0, cy, clientSize.x, cy);
+       }
+}
+
+void wxTreeCompanionWindow::OnScroll(wxScrollWinEvent& event)
+{
+    int orient = event.GetOrientation();
+    if (orient == wxHORIZONTAL)
+    {
+        event.Skip();
+        return;
+    }
+    if (!m_treeCtrl)
+        return;
+
+       // TODO: scroll the window physically instead of just refreshing.
+       Refresh(TRUE);
+}
+
+void wxTreeCompanionWindow::OnExpand(wxTreeEvent& event)
+{
+       // TODO: something more optimized than simply refresh the whole
+       // window when the tree is expanded/collapsed. Tricky.
+       Refresh();
+}
+
+/*
+ * wxThinSplitterWindow
+ */
+
+IMPLEMENT_CLASS(wxThinSplitterWindow, wxSplitterWindow)
+
+BEGIN_EVENT_TABLE(wxThinSplitterWindow, wxSplitterWindow)
+       EVT_SIZE(wxThinSplitterWindow::OnSize)
+END_EVENT_TABLE()
+
+wxThinSplitterWindow::wxThinSplitterWindow(wxWindow* parent, wxWindowID id,
+      const wxPoint& pos,
+      const wxSize& sz,
+      long style):
+      wxSplitterWindow(parent, id, pos, sz, style)
+{
+}
+
+void wxThinSplitterWindow::SizeWindows()
+{
+       // The client size may have changed inbetween
+       // the sizing of the first window and the sizing of
+       // the second. So repeat SizeWindows.
+    wxSplitterWindow::SizeWindows();
+    wxSplitterWindow::SizeWindows();
+}
+
+// Tests for x, y over sash
+bool wxThinSplitterWindow::SashHitTest(int x, int y, int tolerance)
+{
+       return wxSplitterWindow::SashHitTest(x, y, 4);
+}
+
+void wxThinSplitterWindow::DrawSash(wxDC& dc)
+{
+    if ( m_sashPosition == 0 || !m_windowTwo)
+        return;
+    if (GetWindowStyle() & wxSP_NOSASH)
+        return;
+
+    int w, h;
+    GetClientSize(&w, &h);
+
+       if ( m_splitMode == wxSPLIT_VERTICAL )
+       {
+               dc.SetPen(* m_facePen);
+               dc.SetBrush(* m_faceBrush);
+               int h1 = h-1;
+               int y1 = 0;
+               if ( (GetWindowStyleFlag() & wxSP_BORDER) != wxSP_BORDER && (GetWindowStyleFlag() & wxSP_3DBORDER) != wxSP_3DBORDER )
+                       h1 += 1; // Not sure why this is necessary...
+               if ( (GetWindowStyleFlag() & wxSP_3DBORDER) == wxSP_3DBORDER)
+               {
+                       y1 = 2; h1 -= 3;
+               }
+               dc.DrawRectangle(m_sashPosition, y1, m_sashSize, h1);
+       }
+       else
+       {
+               dc.SetPen(* m_facePen);
+               dc.SetBrush(* m_faceBrush);
+               int w1 = w-1;
+               int x1 = 0;
+               if ( (GetWindowStyleFlag() & wxSP_BORDER) != wxSP_BORDER && (GetWindowStyleFlag() & wxSP_3DBORDER) != wxSP_3DBORDER )
+                       w1 ++;
+               if ( (GetWindowStyleFlag() & wxSP_3DBORDER) == wxSP_3DBORDER)
+               {
+                       x1 = 2; w1 -= 3;
+               }
+               dc.DrawRectangle(x1, m_sashPosition, w1, m_sashSize);
+       }
+       
+    dc.SetPen(wxNullPen);
+    dc.SetBrush(wxNullBrush);
+}
+
+void wxThinSplitterWindow::OnSize(wxSizeEvent& event)
+{
+       wxSplitterWindow::OnSize(event);
+}
+
+/*
+ * wxSplitterScrolledWindow
+ */
+
+IMPLEMENT_CLASS(wxSplitterScrolledWindow, wxScrolledWindow)
+
+BEGIN_EVENT_TABLE(wxSplitterScrolledWindow, wxScrolledWindow)
+       EVT_SCROLLWIN(wxSplitterScrolledWindow::OnScroll)
+       EVT_SIZE(wxSplitterScrolledWindow::OnSize)
+END_EVENT_TABLE()
+
+wxSplitterScrolledWindow::wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id,
+      const wxPoint& pos,
+      const wxSize& sz,
+      long style):
+      wxScrolledWindow(parent, id, pos, sz, style)
+{
+}
+
+void wxSplitterScrolledWindow::OnSize(wxSizeEvent& event)
+{
+       wxSize sz = GetClientSize();
+       if (GetChildren().First())
+       {
+               ((wxWindow*) GetChildren().First()->Data())->SetSize(0, 0, sz.x, sz.y);
+       }
+}
+
+void wxSplitterScrolledWindow::OnScroll(wxScrollWinEvent& event)
+{
+    // Ensure that events being propagated back up the window hierarchy
+    // don't cause an infinite loop
+    static bool inOnScroll = FALSE;
+    if (inOnScroll)
+        return;
+    inOnScroll = TRUE;
+
+    int orient = event.GetOrientation();
+
+    int nScrollInc = CalcScrollInc(event);
+    if (nScrollInc == 0)
+    {
+        inOnScroll = FALSE;
+        return;
+    }
+
+    if (orient == wxHORIZONTAL)
+    {
+        inOnScroll = FALSE;
+        event.Skip();
+        return;
+#if 0
+        int newPos = m_xScrollPosition + nScrollInc;
+        SetScrollPos(wxHORIZONTAL, newPos, TRUE );
+#endif
+    }
+    else
+    {
+        int newPos = m_yScrollPosition + nScrollInc;
+        SetScrollPos(wxVERTICAL, newPos, TRUE );
+    }
+
+    if (orient == wxHORIZONTAL)
+    {
+        m_xScrollPosition += nScrollInc;
+    }
+    else
+    {
+        m_yScrollPosition += nScrollInc;
+    }
+
+    // Find targets in splitter window and send the event to them
+    wxNode* node = GetChildren().First();
+    while (node)
+    {
+        wxWindow* child = (wxWindow*) node->Data();
+        if (child->IsKindOf(CLASSINFO(wxSplitterWindow)))
+        {
+            wxSplitterWindow* splitter = (wxSplitterWindow*) child;
+            if (splitter->GetWindow1())
+                splitter->GetWindow1()->ProcessEvent(event);
+            if (splitter->GetWindow2())
+                splitter->GetWindow2()->ProcessEvent(event);
+            break;
+        }
+        node = node->Next();
+    }
+
+#ifdef __WXMAC__
+    m_targetWindow->MacUpdateImmediately() ;
+#endif
+
+    inOnScroll = FALSE;
+}
+
diff --git a/contrib/utils/wxrcedit/splittree.h b/contrib/utils/wxrcedit/splittree.h
new file mode 100644 (file)
index 0000000..4be4386
--- /dev/null
@@ -0,0 +1,227 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        splittree.h
+// Purpose:     Classes to achieve a remotely-scrolled tree in a splitter
+//              window that can be scrolled by a scrolled window higher in the
+//              hierarchy
+// Author:      Julian Smart
+// Modified by:
+// Created:     8/7/2000
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_SPLITTREE_H_
+#define _WX_SPLITTREE_H_
+
+#ifdef __GNUG__
+       #pragma interface "splittree.h"
+#endif
+
+// Set this to 1 to use generic tree control (doesn't yet work properly)
+#define USE_GENERIC_TREECTRL 0
+
+#include "wx/wx.h"
+#include "wx/treectrl.h"
+#include "wx/splitter.h"
+#include "wx/scrolwin.h"
+
+#if USE_GENERIC_TREECTRL
+#include "wx/generic/treectlg.h"
+#ifndef wxTreeCtrl
+#define wxTreeCtrl wxGenericTreeCtrl
+#define sm_classwxTreeCtrl sm_classwxGenericTreeCtrl
+#endif
+#endif
+
+class wxRemotelyScrolledTreeCtrl;
+class wxThinSplitterWindow;
+class wxSplitterScrolledWindow;
+
+/*
+ * wxRemotelyScrolledTreeCtrl
+ *
+ * This tree control disables its vertical scrollbar and catches scroll
+ * events passed by a scrolled window higher in the hierarchy.
+ * It also updates the scrolled window vertical scrollbar as appropriate.
+ */
+
+class wxRemotelyScrolledTreeCtrl: public wxTreeCtrl
+{
+       DECLARE_CLASS(wxRemotelyScrolledTreeCtrl)
+public:
+    wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pt = wxDefaultPosition,
+        const wxSize& sz = wxDefaultSize, long style = wxTR_HAS_BUTTONS);
+       ~wxRemotelyScrolledTreeCtrl();
+
+//// Events
+       void OnSize(wxSizeEvent& event);
+       void OnExpand(wxTreeEvent& event);
+    void OnScroll(wxScrollWinEvent& event);
+
+//// Overrides
+    // Override this in case we're using the generic tree control.
+    // Calls to this should disable the vertical scrollbar.
+
+    // Number of pixels per user unit (0 or -1 for no scrollbar)
+    // Length of virtual canvas in user units
+    // Length of page in user units
+    virtual void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
+                             int noUnitsX, int noUnitsY,
+                             int xPos = 0, int yPos = 0,
+                             bool noRefresh = FALSE );
+
+    // In case we're using the generic tree control.
+    // Get the view start
+    virtual void GetViewStart(int *x, int *y) const;
+
+    // In case we're using the generic tree control.
+    virtual void PrepareDC(wxDC& dc);
+
+    // In case we're using the generic tree control.
+    virtual int GetScrollPos(int orient) const;
+
+//// Helpers
+       void HideVScrollbar();
+
+       // Calculate the tree overall size so we can set the scrollbar
+       // correctly
+       void CalcTreeSize(wxRect& rect);
+       void CalcTreeSize(const wxTreeItemId& id, wxRect& rect);
+
+       // Adjust the containing wxScrolledWindow's scrollbars appropriately
+       void AdjustRemoteScrollbars();
+
+       // Find the scrolled window that contains this control
+       wxScrolledWindow* GetScrolledWindow() const;
+
+    // Scroll to the given line (in scroll units where each unit is
+    // the height of an item)
+    void ScrollToLine(int posHoriz, int posVert);
+
+//// Accessors
+
+       // The companion window is one which will get notified when certain
+       // events happen such as node expansion
+       void SetCompanionWindow(wxWindow* companion) { m_companionWindow = companion; }
+       wxWindow* GetCompanionWindow() const { return m_companionWindow; }
+
+
+    DECLARE_EVENT_TABLE()
+protected:
+       wxWindow*       m_companionWindow;
+};
+
+/*
+ * wxTreeCompanionWindow
+ *
+ * A window displaying values associated with tree control items.
+ */
+
+class wxTreeCompanionWindow: public wxWindow
+{
+public:
+    DECLARE_CLASS(wxTreeCompanionWindow)
+
+    wxTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
+      const wxPoint& pos = wxDefaultPosition,
+      const wxSize& sz = wxDefaultSize,
+      long style = 0);
+
+//// Overrides
+       virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect);
+
+//// Events
+       void OnPaint(wxPaintEvent& event);    
+    void OnScroll(wxScrollWinEvent& event);
+       void OnExpand(wxTreeEvent& event);
+
+//// Operations
+
+//// Accessors
+       wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const { return m_treeCtrl; };
+       void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl) { m_treeCtrl = treeCtrl; }
+
+//// Data members
+protected:
+       wxRemotelyScrolledTreeCtrl*     m_treeCtrl;
+
+    DECLARE_EVENT_TABLE()
+};
+
+
+/*
+ * wxThinSplitterWindow
+ *
+ * Implements a splitter with a less obvious sash
+ * than the usual one.
+ */
+
+class wxThinSplitterWindow: public wxSplitterWindow
+{
+public:
+    DECLARE_DYNAMIC_CLASS(wxThinSplitterWindow)
+
+    wxThinSplitterWindow(wxWindow* parent, wxWindowID id = -1,
+      const wxPoint& pos = wxDefaultPosition,
+      const wxSize& sz = wxDefaultSize,
+      long style = wxSP_3D | wxCLIP_CHILDREN);
+
+//// Overrides
+
+    void SizeWindows();
+    // Tests for x, y over sash. Overriding this allows us to increase
+    // the tolerance.
+    bool SashHitTest(int x, int y, int tolerance = 2);
+       void DrawSash(wxDC& dc);
+
+//// Events
+    
+    void OnSize(wxSizeEvent& event);
+
+//// Operations
+
+//// Accessors
+
+//// Data members
+protected:
+    DECLARE_EVENT_TABLE()
+};
+
+/*
+ * wxSplitterScrolledWindow
+ *
+ * This scrolled window is aware of the fact that one of its
+ * children is a splitter window. It passes on its scroll events
+ * (after some processing) to both splitter children for them
+ * scroll appropriately.
+ */
+
+class wxSplitterScrolledWindow: public wxScrolledWindow
+{
+public:
+    DECLARE_DYNAMIC_CLASS(wxSplitterScrolledWindow)
+
+    wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = -1,
+      const wxPoint& pos = wxDefaultPosition,
+      const wxSize& sz = wxDefaultSize,
+      long style = 0);
+
+//// Overrides
+
+//// Events
+    
+    void OnScroll(wxScrollWinEvent& event);
+    void OnSize(wxSizeEvent& event);
+
+//// Operations
+
+//// Accessors
+
+//// Data members
+public:
+    DECLARE_EVENT_TABLE()
+};
+
+#endif
+        // _SPLITTREE_H_
index c920dad77cda6482ecd8207ff9ed68162433e438..c5a56f854e3da328dc18f390b8b23c69e513ddad 100644 (file)
 
 #include "wx/xml/xml.h"
 #include "wx/wx.h"
+#include "wx/tokenzr.h"
 #include "xmlhelpr.h"
 
 
 
-wxXmlNode *XmlFindNode(wxXmlNode *parent, const wxString& param)
+wxXmlNode *XmlFindNodeSimple(wxXmlNode *parent, const wxString& param)
 {
+    if (param.IsEmpty()) return parent;
+
     wxXmlNode *n = parent->GetChildren();
     
     while (n)
@@ -37,14 +40,33 @@ wxXmlNode *XmlFindNode(wxXmlNode *parent, const wxString& param)
 }
 
 
+
+wxXmlNode *XmlFindNode(wxXmlNode *parent, const wxString& path)
+{
+    wxXmlNode *n = parent;
+    wxStringTokenizer tkn(path, _T("/"));
+    while (tkn.HasMoreTokens())
+    {
+        n = XmlFindNodeSimple(n, tkn.GetNextToken());
+        if (n == NULL) break;
+    }
+    return n;
+}
+
+
+
 void XmlWriteValue(wxXmlNode *parent, const wxString& name, const wxString& value)
 {
     wxXmlNode *n = XmlFindNode(parent, name);
     if (n == NULL) 
     {
-        n = new wxXmlNode(wxXML_ELEMENT_NODE, name);
-        parent->AddChild(n);
-        n->AddChild(new wxXmlNode(wxXML_TEXT_NODE, ""));
+        wxString pname = name.BeforeLast(_T('/'));
+        if (pname.IsEmpty()) pname = name;
+        wxXmlNode *p = XmlFindNode(parent, pname);
+        if (p == NULL) p = parent;
+        n = new wxXmlNode(wxXML_ELEMENT_NODE, name.AfterLast(_T('/')));
+        p->AddChild(n);
+        n->AddChild(new wxXmlNode(wxXML_TEXT_NODE, wxEmptyString));
     }
     
     n = n->GetChildren();
index e2f673543d3600abe502ecf004564cb95820a520..893a4b61ed289923c95d0903729c440848ac1bd6 100644 (file)
 
 void XmlWriteValue(wxXmlNode *parent, const wxString& name, const wxString& value);
 wxString XmlReadValue(wxXmlNode *parent, const wxString& name);
+
+// Finds a subnode of parent named <name>
+// (may be recursive, e.g. "name1/name2" means
+// <parent><name1><name2>value</name2></name1></parent>
 wxXmlNode *XmlFindNode(wxXmlNode *parent, const wxString& name);
+wxXmlNode *XmlFindNodeSimple(wxXmlNode *parent, const wxString& path);
+
 wxString XmlGetClass(wxXmlNode *parent);
 void XmlSetClass(wxXmlNode *parent, const wxString& classname);