]> git.saurik.com Git - wxWidgets.git/blobdiff - contrib/utils/wxrcedit/editor.cpp
test undividable words
[wxWidgets.git] / contrib / utils / wxrcedit / editor.cpp
index 201c047d72d4520cebaaac73756414ebb5c2c92e..d24f9b932a41c1e3a808f3a5e0cb8a7358cf6dc2 100644 (file)
@@ -92,7 +92,7 @@ void wxXmlRcEditDocument::Upgrade()
         UpgradeNode(node);
     }
     node->DeleteProperty(wxT("version"));
-    node->AddProperty(wxT("version"), wxT(WX_XMLRES_CURRENT_VERSION_STRING));
+    node->AddProperty(wxT("version"), WX_XMLRES_CURRENT_VERSION_STRING);
 }
 
 
@@ -141,6 +141,7 @@ enum
     ID_COPY,
 
     ID_NEWDIALOG,
+       ID_NEWFRAME,
     ID_NEWPANEL,
     ID_NEWMENU,
     ID_NEWMENUBAR,
@@ -297,7 +298,7 @@ void EditorFrame::LoadFile(const wxString& filename)
     m_Resource = new wxXmlRcEditDocument;
     m_Modified = FALSE;
     
-    if (!m_Resource->Load(filename, wxXML_IO_AUTO, wxLocale::GetSystemEncodingName()))
+    if (!m_Resource->Load(filename,  wxLocale::GetSystemEncodingName()))
     {
         delete m_Resource;
         m_Resource = NULL;
@@ -341,7 +342,15 @@ void EditorFrame::NewFile()
     m_FileName = "";
     m_Resource = new wxXmlRcEditDocument;
     m_Resource->SetRoot(new wxXmlNode(wxXML_ELEMENT_NODE, _("resource")));
+       
+       m_Resource->SetFileEncoding("utf-8");
+#if !wxUSE_UNICODE
+    m_Resource->SetEncoding(wxLocale::GetSystemEncodingName());
+#endif
     
+       m_Resource->GetRoot()->AddProperty(_T("version"),
+                                       WX_XMLRES_CURRENT_VERSION_STRING);
+
     m_Modified = FALSE;
     RefreshTree();
     RefreshTitle();
@@ -366,6 +375,7 @@ void EditorFrame::RefreshTree()
     wxXmlNode *sel = m_SelectedNode;
     
     m_TreeCtrl->DeleteAllItems(); 
+
     wxTreeItemId root = m_TreeCtrl->AddRoot("Resource: " + wxFileNameFromPath(m_FileName), 5, 5);
 
     wxXmlNode *n = m_Resource->GetRoot()->GetChildren();  
@@ -482,20 +492,19 @@ void EditorFrame::OnTreeSel(wxTreeEvent& event)
     if (node)
         PropertiesFrame::Get()->ShowProps(node);
 
-    if (m_TreeCtrl->GetParent(event.GetItem()) == m_TreeCtrl->GetRootItem())
+    if (m_TreeCtrl->GetItemParent(event.GetItem()) == m_TreeCtrl->GetRootItem())
     {
         wxTreeItemId it = event.GetOldItem();
 
         if (it.IsOk() && m_TreeCtrl->GetRootItem() != it)
         {
-            while (m_TreeCtrl->GetParent(it) != m_TreeCtrl->GetRootItem())
-                it = m_TreeCtrl->GetParent(it);
+            while (m_TreeCtrl->GetItemParent(it) != m_TreeCtrl->GetRootItem())
+                it = m_TreeCtrl->GetItemParent(it);
             m_TreeCtrl->Collapse(it);
         }
         RecursivelyExpand(m_TreeCtrl, event.GetItem());
 
-        PreviewFrame::Get()->Preview(node,m_Resource->GetRoot()->GetPropVal(
-                                      wxT("version"), wxT("0.0.0.0")));
+        PreviewFrame::Get()->Preview(node,m_Resource);
     }
 }
 
@@ -509,8 +518,7 @@ void EditorFrame::OnToolbar(wxCommandEvent& event)
             {
             XmlTreeData* dt = (XmlTreeData*)m_TreeCtrl->GetItemData(m_TreeCtrl->GetSelection());;
             if (dt != NULL && dt->Node != NULL)
-                PreviewFrame::Get()->Preview(dt->Node,m_Resource->GetRoot()->GetPropVal(
-                                      wxT("version"), wxT("0.0.0.0")));
+                PreviewFrame::Get()->Preview(dt->Node, m_Resource);
             break;
             }
 
@@ -559,7 +567,7 @@ void EditorFrame::OnToolbar(wxCommandEvent& event)
 void EditorFrame::DeleteSelectedNode()
 {
     XmlTreeData *dt = (XmlTreeData*)
-            (m_TreeCtrl->GetItemData(m_TreeCtrl->GetParent(m_TreeCtrl->GetSelection())));
+            (m_TreeCtrl->GetItemData(m_TreeCtrl->GetItemParent(m_TreeCtrl->GetSelection())));
     wxXmlNode *n = (dt) ? dt->Node : NULL;
 
     m_SelectedNode->GetParent()->RemoveChild(m_SelectedNode);
@@ -575,7 +583,7 @@ void EditorFrame::OnNewNode(wxCommandEvent& event)
     {
         XmlTreeData *pardt = 
             (XmlTreeData*)(m_TreeCtrl->GetItemData(
-                m_TreeCtrl->GetParent(m_TreeCtrl->GetSelection())));
+                m_TreeCtrl->GetItemParent(m_TreeCtrl->GetSelection())));
 
         if (pardt && pardt->Node && pardt->Node != m_Resource->GetRoot())
         {
@@ -615,6 +623,7 @@ void EditorFrame::OnNewNode(wxCommandEvent& event)
         switch (event.GetId())
         {
             case ID_NEWDIALOG : name = _T("wxDialog"); break;
+                       case ID_NEWFRAME : name = _T("wxFrame"); break;
             case ID_NEWPANEL : name = _T("wxPanel"); break;
             case ID_NEWMENU : name = _T("wxMenu"); break;
             case ID_NEWMENUBAR : name = _T("wxMenuBar"); break;
@@ -639,6 +648,7 @@ void EditorFrame::OnRightClickTree(wxPoint pos)
     if (m_SelectedNode == NULL || m_SelectedNode == m_Resource->GetRoot())
     {
         popup->Append(ID_NEWDIALOG, _("New wxDialog"));
+               popup->Append(ID_NEWFRAME, _("New wxFrame"));
         popup->Append(ID_NEWPANEL, _("New wxPanel"));
         popup->Append(ID_NEWMENU, _("New wxMenu"));
         popup->Append(ID_NEWMENUBAR, _("New wxMenuBar"));
@@ -679,7 +689,7 @@ void EditorFrame::OnRightClickTree(wxPoint pos)
 
         XmlTreeData *pardt = 
             (XmlTreeData*)(m_TreeCtrl->GetItemData(
-                m_TreeCtrl->GetParent(m_TreeCtrl->GetSelection())));
+                m_TreeCtrl->GetItemParent(m_TreeCtrl->GetSelection())));
         if (pardt && pardt->Node && pardt->Node != m_Resource->GetRoot())
         {
             wxXmlNode *nd = pardt->Node;
@@ -744,7 +754,7 @@ void EditorFrame::OnClipboardAction(wxCommandEvent& event)
             {
             XmlTreeData *pardt = 
                 (XmlTreeData*)(m_TreeCtrl->GetItemData(
-                    m_TreeCtrl->GetParent(m_TreeCtrl->GetSelection())));
+                    m_TreeCtrl->GetItemParent(m_TreeCtrl->GetSelection())));
 
             if (pardt && pardt->Node && pardt->Node != m_Resource->GetRoot())
             {