+
+
+
+void EditorFrame::OnClipboardAction(wxCommandEvent& event)
+{
+ switch (event.GetId())
+ {
+ case ID_COPY:
+ case ID_CUT:
+ delete m_Clipboard;
+ m_Clipboard = new wxXmlNode(*m_SelectedNode);
+ GetMenuBar()->Enable(ID_PASTE_SYBLING, TRUE);
+ GetMenuBar()->Enable(ID_PASTE_CHILD, TRUE);
+ if (event.GetId() == ID_CUT) DeleteSelectedNode();
+ break;
+
+ case ID_PASTE_SYBLING:
+ {
+ XmlTreeData *pardt =
+ (XmlTreeData*)(m_TreeCtrl->GetItemData(
+ m_TreeCtrl->GetParent(m_TreeCtrl->GetSelection())));
+
+ if (pardt && pardt->Node && pardt->Node != m_Resource->GetRoot())
+ {
+ wxXmlNode *nd = pardt->Node;
+
+ wxXmlNode *realnode = FindHandler(nd)->GetRealNode(nd);
+ NodeHandler *hnd = FindHandler(realnode);
+ wxXmlNode *node = new wxXmlNode(*m_Clipboard);
+ hnd->InsertNode(realnode, node, m_SelectedNode);
+ wxTreeItemId root = m_TreeCtrl->GetSelection();
+ SelectNode(node, &root);
+ }
+ }
+ break;
+
+ case ID_PASTE_CHILD:
+ wxXmlNode *realnode = FindHandler(m_SelectedNode)->GetRealNode(m_SelectedNode);
+ NodeHandler *hnd = FindHandler(realnode);
+ wxXmlNode *node = new wxXmlNode(*m_Clipboard);
+ hnd->InsertNode(realnode, node);
+ wxTreeItemId root = m_TreeCtrl->GetSelection();
+ SelectNode(node, &root);
+ break;
+ }
+}
+