revision 7
Using system clipboard for Copy/Paste git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36129 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
0.1.6-7
|
||||||
|
-------
|
||||||
|
|
||||||
|
Using system clipboard for Copy/Paste.
|
||||||
|
|
||||||
0.1.6-6
|
0.1.6-6
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
@@ -15,7 +15,7 @@ import sys
|
|||||||
# Global constants
|
# Global constants
|
||||||
|
|
||||||
progname = 'XRCed'
|
progname = 'XRCed'
|
||||||
version = '0.1.6-6'
|
version = '0.1.6-7'
|
||||||
# Can be changed to set other default encoding different
|
# Can be changed to set other default encoding different
|
||||||
#defaultEncoding = ''
|
#defaultEncoding = ''
|
||||||
# you comment above and can uncomment this:
|
# you comment above and can uncomment this:
|
||||||
|
@@ -21,7 +21,7 @@ Options:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from globals import *
|
from globals import *
|
||||||
import os, sys, getopt, re, traceback, tempfile, shutil
|
import os, sys, getopt, re, traceback, tempfile, shutil, cPickle
|
||||||
|
|
||||||
# Local modules
|
# Local modules
|
||||||
from tree import * # imports xxx which imports params
|
from tree import * # imports xxx which imports params
|
||||||
@@ -306,7 +306,6 @@ class Frame(wxFrame):
|
|||||||
self.SetSizer(sizer)
|
self.SetSizer(sizer)
|
||||||
|
|
||||||
# Initialize
|
# Initialize
|
||||||
self.clipboard = None
|
|
||||||
self.Clear()
|
self.Clear()
|
||||||
|
|
||||||
# Other events
|
# Other events
|
||||||
@@ -414,7 +413,11 @@ class Frame(wxFrame):
|
|||||||
selected = tree.selection
|
selected = tree.selection
|
||||||
if not selected: return # key pressed event
|
if not selected: return # key pressed event
|
||||||
xxx = tree.GetPyData(selected)
|
xxx = tree.GetPyData(selected)
|
||||||
self.clipboard = xxx.element.cloneNode(True)
|
wx.TheClipboard.Open()
|
||||||
|
data = wx.CustomDataObject('XRCED')
|
||||||
|
data.SetData(cPickle.dumps(xxx.element))
|
||||||
|
wx.TheClipboard.SetData(data)
|
||||||
|
wx.TheClipboard.Close()
|
||||||
self.SetStatusText('Copied')
|
self.SetStatusText('Copied')
|
||||||
|
|
||||||
def OnPaste(self, evt):
|
def OnPaste(self, evt):
|
||||||
@@ -443,8 +446,16 @@ class Frame(wxFrame):
|
|||||||
parentLeaf = selected
|
parentLeaf = selected
|
||||||
parent = tree.GetPyData(parentLeaf).treeObject()
|
parent = tree.GetPyData(parentLeaf).treeObject()
|
||||||
|
|
||||||
# Create a copy of clipboard element
|
# Create a copy of clipboard pickled element
|
||||||
elem = self.clipboard.cloneNode(True)
|
wx.TheClipboard.Open()
|
||||||
|
data = wx.CustomDataObject('XRCED')
|
||||||
|
if not wx.TheClipboard.IsSupported(data.GetFormat()):
|
||||||
|
wx.TheClipboard.Close()
|
||||||
|
wx.LogError('unsupported clipboard format')
|
||||||
|
return
|
||||||
|
wx.TheClipboard.GetData(data)
|
||||||
|
wx.TheClipboard.Close()
|
||||||
|
elem = cPickle.loads(data.GetData())
|
||||||
# Tempopary xxx object to test things
|
# Tempopary xxx object to test things
|
||||||
xxx = MakeXXXFromDOM(parent, elem)
|
xxx = MakeXXXFromDOM(parent, elem)
|
||||||
|
|
||||||
@@ -553,8 +564,11 @@ class Frame(wxFrame):
|
|||||||
elem = tree.RemoveLeaf(selected)
|
elem = tree.RemoveLeaf(selected)
|
||||||
undoMan.RegisterUndo(UndoCutDelete(index, parent, elem))
|
undoMan.RegisterUndo(UndoCutDelete(index, parent, elem))
|
||||||
if evt.GetId() == wxID_CUT:
|
if evt.GetId() == wxID_CUT:
|
||||||
if self.clipboard: self.clipboard.unlink()
|
wx.TheClipboard.Open()
|
||||||
self.clipboard = elem.cloneNode(True)
|
data = wx.CustomDataObject('XRCED')
|
||||||
|
data.SetData(cPickle.dumps(elem))
|
||||||
|
wx.TheClipboard.SetData(data)
|
||||||
|
wx.TheClipboard.Close()
|
||||||
tree.pendingHighLight = None
|
tree.pendingHighLight = None
|
||||||
tree.UnselectAll()
|
tree.UnselectAll()
|
||||||
tree.selection = None
|
tree.selection = None
|
||||||
@@ -935,7 +949,7 @@ Homepage: http://xrced.sourceforge.net\
|
|||||||
elif evt.GetId() == wxID_SAVE:
|
elif evt.GetId() == wxID_SAVE:
|
||||||
evt.Enable(self.modified)
|
evt.Enable(self.modified)
|
||||||
elif evt.GetId() in [wxID_PASTE, self.ID_TOOL_PASTE]:
|
elif evt.GetId() in [wxID_PASTE, self.ID_TOOL_PASTE]:
|
||||||
evt.Enable((self.clipboard and tree.selection) != None)
|
evt.Enable(tree.selection is not None)
|
||||||
elif evt.GetId() == self.ID_TEST:
|
elif evt.GetId() == self.ID_TEST:
|
||||||
evt.Enable(tree.selection is not None and tree.selection != tree.root)
|
evt.Enable(tree.selection is not None and tree.selection != tree.root)
|
||||||
elif evt.GetId() in [self.ID_LOCATE, self.ID_TOOL_LOCATE]:
|
elif evt.GetId() in [self.ID_LOCATE, self.ID_TOOL_LOCATE]:
|
||||||
@@ -995,9 +1009,6 @@ Homepage: http://xrced.sourceforge.net\
|
|||||||
|
|
||||||
def Clear(self):
|
def Clear(self):
|
||||||
self.dataFile = ''
|
self.dataFile = ''
|
||||||
if self.clipboard:
|
|
||||||
self.clipboard.unlink()
|
|
||||||
self.clipboard = None
|
|
||||||
undoMan.Clear()
|
undoMan.Clear()
|
||||||
self.SetModified(False)
|
self.SetModified(False)
|
||||||
tree.Clear()
|
tree.Clear()
|
||||||
|
Reference in New Issue
Block a user