git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@45702 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2007-04-27 22:15:09 +00:00
parent d698728cea
commit 3bd8d81d3e
3 changed files with 39 additions and 11 deletions

View File

@@ -165,11 +165,12 @@ class Tools(wx.Panel):
do = MyDataObject() do = MyDataObject()
do.SetData(str(evt.GetId())) do.SetData(str(evt.GetId()))
bm = evt.GetEventObject().GetBitmapLabel() bm = evt.GetEventObject().GetBitmapLabel()
if wx.Platform != '__WXMAC__': # wxGTK requires wxIcon cursor, wxWIN and wxMAC require wxCursor
if wx.Platform == '__WXGTK__':
icon = wx.EmptyIcon() icon = wx.EmptyIcon()
icon.CopyFromBitmap(bm) icon.CopyFromBitmap(bm)
dragSource = wx.DropSource(self, icon) dragSource = wx.DropSource(self, icon)
else: # on Mac DragSource requires cursor (but does not work anyway) else:
curs = wx.CursorFromImage(wx.ImageFromBitmap(bm)) curs = wx.CursorFromImage(wx.ImageFromBitmap(bm))
dragSource = wx.DropSource(self, curs) dragSource = wx.DropSource(self, curs)
dragSource.SetData(do) dragSource.SetData(do)

View File

@@ -15,7 +15,7 @@ COLOUR_COMMENT = 'Blue'
COLOUR_REF = 'DarkGreen' COLOUR_REF = 'DarkGreen'
COLOUR_HIDDEN = 'Grey' COLOUR_HIDDEN = 'Grey'
COLOUR_HL = 'Red' COLOUR_HL = 'Red'
COLOUR_DT = 'Green' COLOUR_DT = 'DarkGreen'
# Icons # Icons
import images import images
@@ -1121,6 +1121,7 @@ class XML_Tree(wx.TreeCtrl):
# Override to use like single-selection tree # Override to use like single-selection tree
def GetSelection(self): def GetSelection(self):
return self.selection return self.selection
def SelectItem(self, item): def SelectItem(self, item):
self.UnselectAll() self.UnselectAll()
self.ChangeSelection(item) self.ChangeSelection(item)
@@ -1341,10 +1342,13 @@ class DropTarget(wx.PyDropTarget):
if d != wx.DragNone: if d != wx.DragNone:
obj,parent,parentItem,item = other obj,parent,parentItem,item = other
pos, size = g.tree.FindNodePos(parentItem, obj), obj.GetSize() pos, size = g.tree.FindNodePos(parentItem, obj), obj.GetSize()
# Change tree item colour
hl = g.testWin.highLightDT hl = g.testWin.highLightDT
if hl and hl.item and hl.item != parentItem: # Set color of highlighted item back to normal
g.tree.SetItemTextColour(hl.item, g.tree.itemColour) if hl and hl.item:
if hl.item != parentItem:
g.tree.SetItemTextColour(hl.item, g.tree.itemColour)
# Highlight future parent
g.tree.itemColour = g.tree.GetItemTextColour(parentItem) # save current
g.testWin.highLightDT = updateHL(hl, HighLightDTBox, pos, size) g.testWin.highLightDT = updateHL(hl, HighLightDTBox, pos, size)
g.testWin.highLightDT.item = parentItem g.testWin.highLightDT.item = parentItem
g.tree.SetItemTextColour(parentItem, COLOUR_DT) g.tree.SetItemTextColour(parentItem, COLOUR_DT)
@@ -1361,6 +1365,7 @@ class DropTarget(wx.PyDropTarget):
def RemoveHL(self): def RemoveHL(self):
hl = g.testWin.highLightDT hl = g.testWin.highLightDT
if hl: if hl:
if hl.item: g.tree.SetItemTextColour(hl.item, g.tree.itemColour) if hl.item:
g.tree.SetItemTextColour(hl.item, g.tree.itemColour)
hl.Remove() hl.Remove()

View File

@@ -46,8 +46,6 @@ sys_path = sys.path
# 1 adds CMD command to Help menu # 1 adds CMD command to Help menu
debug = 0 debug = 0
import xxx
g.helpText = """\ g.helpText = """\
<HTML><H2>Welcome to XRC<font color="blue">ed</font></H2><H3><font color="green">DON'T PANIC :)</font></H3> <HTML><H2>Welcome to XRC<font color="blue">ed</font></H2><H3><font color="green">DON'T PANIC :)</font></H3>
Read this note before clicking on anything!<P> Read this note before clicking on anything!<P>
@@ -688,12 +686,18 @@ class Frame(wx.Frame):
index = tree.ItemIndex(selected) index = tree.ItemIndex(selected)
if index == 0: return # No previous sibling found if index == 0: return # No previous sibling found
# Remove highlight, update testWin
if g.testWin and g.testWin.highLight:
g.testWin.highLight.Remove()
tree.needUpdate = True
# Undo info # Undo info
self.lastOp = 'MOVEUP' self.lastOp = 'MOVEUP'
status = 'Moved before previous sibling' status = 'Moved before previous sibling'
# Prepare undo data # Prepare undo data
panel.Apply() panel.Apply()
tree.UnselectAll()
parent = tree.GetItemParent(selected) parent = tree.GetItemParent(selected)
elem = tree.RemoveLeaf(selected) elem = tree.RemoveLeaf(selected)
@@ -718,12 +722,18 @@ class Frame(wx.Frame):
next = tree.GetNextSibling(selected) next = tree.GetNextSibling(selected)
if not next: return if not next: return
# Remove highlight, update testWin
if g.testWin and g.testWin.highLight:
g.testWin.highLight.Remove()
tree.needUpdate = True
# Undo info # Undo info
self.lastOp = 'MOVEDOWN' self.lastOp = 'MOVEDOWN'
status = 'Moved after next sibling' status = 'Moved after next sibling'
# Prepare undo data # Prepare undo data
panel.Apply() panel.Apply()
tree.UnselectAll()
parent = tree.GetItemParent(selected) parent = tree.GetItemParent(selected)
elem = tree.RemoveLeaf(selected) elem = tree.RemoveLeaf(selected)
@@ -752,6 +762,11 @@ class Frame(wx.Frame):
# Check compatibility # Check compatibility
if not self.ItemsAreCompatible(tree.GetPyData(pparent).treeObject(), tree.GetPyData(selected).treeObject()): return if not self.ItemsAreCompatible(tree.GetPyData(pparent).treeObject(), tree.GetPyData(selected).treeObject()): return
# Remove highlight, update testWin
if g.testWin and g.testWin.highLight:
g.testWin.highLight.Remove()
tree.needUpdate = True
# Undo info # Undo info
self.lastOp = 'MOVELEFT' self.lastOp = 'MOVELEFT'
status = 'Made next sibling of parent' status = 'Made next sibling of parent'
@@ -791,6 +806,7 @@ class Frame(wx.Frame):
selected = tree.InsertNode(pparent, tree.GetPyData(pparent).treeObject(), elem, nextItem) selected = tree.InsertNode(pparent, tree.GetPyData(pparent).treeObject(), elem, nextItem)
newIndex = tree.ItemIndex(selected) newIndex = tree.ItemIndex(selected)
tree.oldItem = None
tree.SelectItem(selected) tree.SelectItem(selected)
undoMan.RegisterUndo(UndoMove(oldParent, oldIndex, pparent, newIndex)) undoMan.RegisterUndo(UndoMove(oldParent, oldIndex, pparent, newIndex))
@@ -813,6 +829,11 @@ class Frame(wx.Frame):
# Check compatibility # Check compatibility
if not self.ItemsAreCompatible(parent, tree.GetPyData(selected).treeObject()): return if not self.ItemsAreCompatible(parent, tree.GetPyData(selected).treeObject()): return
# Remove highlight, update testWin
if g.testWin and g.testWin.highLight:
g.testWin.highLight.Remove()
tree.needUpdate = True
# Undo info # Undo info
self.lastOp = 'MOVERIGHT' self.lastOp = 'MOVERIGHT'
status = 'Made last child of previous sibling' status = 'Made last child of previous sibling'
@@ -849,10 +870,11 @@ class Frame(wx.Frame):
selected = tree.InsertNode(newParent, tree.GetPyData(newParent).treeObject(), elem, wx.TreeItemId()) selected = tree.InsertNode(newParent, tree.GetPyData(newParent).treeObject(), elem, wx.TreeItemId())
newIndex = tree.ItemIndex(selected) newIndex = tree.ItemIndex(selected)
tree.oldItem = None
tree.SelectItem(selected) tree.SelectItem(selected)
undoMan.RegisterUndo(UndoMove(oldParent, oldIndex, newParent, newIndex)) undoMan.RegisterUndo(UndoMove(oldParent, oldIndex, newParent, newIndex))
self.modified = True self.modified = True
self.SetStatusText(status) self.SetStatusText(status)
@@ -1336,7 +1358,7 @@ Homepage: http://xrced.sourceforge.net\
tree.HighLight(tree.pendingHighLight) tree.HighLight(tree.pendingHighLight)
except: except:
# Remove highlight if any problem # Remove highlight if any problem
if g.testWin.highLight: if g.testWin and g.testWin.highLight:
g.testWin.highLight.Remove() g.testWin.highLight.Remove()
tree.pendingHighLight = None tree.pendingHighLight = None
raise raise