+ TreeNode *pNode = GetNode(event);
+ if ( pNode->IsKey() )
+ {
+ wxRegKey& key = pNode->Key();
+ ok = key.Rename(name);
+ }
+ else
+ {
+ pNode = pNode->Parent();
+ wxRegKey& key = pNode->Key();
+
+ ok = key.RenameValue(m_nameOld, name);
+ }
+
+ if ( !ok )
+ {
+ wxLogError(_T("Failed to rename '%s' to '%s'."),
+ m_nameOld.c_str(), name.c_str());
+ }
+#if 0 // MSW tree ctrl doesn't like this at all, it hangs
+ else
+ {
+ pNode->Refresh();
+ }
+#endif // 0
+}
+
+void RegTreeCtrl::OnBeginDrag(wxTreeEvent& event)
+{
+ m_copyOnDrop = event.GetEventType() == wxEVT_COMMAND_TREE_BEGIN_DRAG;
+
+ TreeNode *pNode = GetNode(event);
+ if ( pNode->IsRoot() || pNode->Parent()->IsRoot() )
+ {
+ wxLogStatus(wxT("This registry key can't be %s."),
+ m_copyOnDrop ? wxT("copied") : wxT("moved"));
+ }
+ else
+ {
+ wxLogStatus(wxT("%s item %s..."),
+ m_copyOnDrop ? wxT("Copying") : wxT("Moving"),
+ pNode->FullName());
+
+ m_draggedItem = pNode;
+
+ event.Allow();
+ }
+}
+
+void RegTreeCtrl::OnEndDrag(wxTreeEvent& event)
+{
+ wxCHECK_RET( m_draggedItem, wxT("end drag without begin drag?") );
+
+ // clear the pointer anyhow
+ TreeNode *src = m_draggedItem;
+ m_draggedItem = NULL;
+
+ // where are we going to drop it?
+ TreeNode *dst = GetNode(event);
+ if ( dst && !dst->IsKey() )
+ {
+ // we need a parent key
+ dst = dst->Parent();
+ }
+
+ if ( !dst || dst->IsRoot() )
+ {
+ wxLogError(wxT("Can't create a key here."));