+ TreeNode *pNode = GetNode(event);
+ bool bExpanding = event.GetKeyCode() == wxTREE_EXPAND_EXPAND;
+
+ // expansion might take some time
+ wxSetCursor(*wxHOURGLASS_CURSOR);
+ wxLogStatus(wxT("Working..."));
+ wxYield(); // to give the status line a chance to refresh itself
+ m_restoreStatus = true; // some time later...
+
+ if ( pNode->IsKey() )
+ {
+ if ( bExpanding )
+ {
+ // expanding: add subkeys/values
+ if ( !pNode->OnExpand() )
+ return;
+ }
+ else
+ {
+ // collapsing: clean up
+ pNode->OnCollapse();
+ }
+ }
+}
+
+void RegTreeCtrl::OnBeginEdit(wxTreeEvent& event)
+{
+ TreeNode *pNode = GetNode(event);
+ if ( pNode->IsRoot() || pNode->Parent()->IsRoot() )
+ {
+ wxLogStatus(_T("This registry key can't be renamed."));
+
+ event.Veto();
+ }
+ else
+ {
+ m_nameOld = pNode->m_strName;
+ }
+}
+
+void RegTreeCtrl::OnEndEdit(wxTreeEvent& event)
+{
+ bool ok;
+
+ wxString name = event.GetLabel();
+
+ 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();
+ }