Backport: Various fixes and improvements to get look-and-feel similar across
different platforms. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@45801 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
0.1.8-6
|
||||
-------
|
||||
|
||||
Various fixes and improvements to get look-and-feel similar across
|
||||
different platforms.
|
||||
|
||||
0.1.8-5
|
||||
-------
|
||||
|
||||
|
@@ -99,6 +99,7 @@ class Tools(wx.Panel):
|
||||
wx.wxEVT_COMMAND_BUTTON_CLICKED, g.frame.OnCreate)
|
||||
wx.EVT_KEY_DOWN(self, self.OnKeyDown)
|
||||
wx.EVT_KEY_UP(self, self.OnKeyUp)
|
||||
self.Bind(wx.EVT_LEFT_DOWN, self.OnClickBox)
|
||||
|
||||
self.drag = None
|
||||
|
||||
@@ -119,10 +120,11 @@ class Tools(wx.Panel):
|
||||
# Each group is inside box
|
||||
id = wx.NewId()
|
||||
box = wx.StaticBox(self, id, '[+] '+name, style=wx.WANTS_CHARS)
|
||||
box.SetForegroundColour(wx.Colour(64, 64, 64))
|
||||
# box.SetFont(g.smallerFont())
|
||||
box.show = True
|
||||
box.name = name
|
||||
box.gnum = len(self.groups)
|
||||
box.SetFont(g.smallerFont())
|
||||
box.Bind(wx.EVT_LEFT_DOWN, self.OnClickBox)
|
||||
boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
|
||||
boxSizer.Add((0, 4))
|
||||
@@ -135,7 +137,7 @@ class Tools(wx.Panel):
|
||||
# Enable/disable group
|
||||
def EnableGroup(self, gnum, enable = True):
|
||||
grp = self.groups[gnum]
|
||||
grp[0].Enable(enable)
|
||||
#grp[0].Enable(enable)
|
||||
for b in grp[1].values(): b.Enable(enable)
|
||||
|
||||
# Show/hide group
|
||||
@@ -156,12 +158,23 @@ class Tools(wx.Panel):
|
||||
grp[1][id].Enable(enable)
|
||||
|
||||
def OnClickBox(self, evt):
|
||||
if wx.Platform == '__WXMSW__':
|
||||
box = None
|
||||
for id,b in self.boxes.items():
|
||||
# Detect click on label
|
||||
if b.GetRect().Inside(evt.GetPosition()):
|
||||
box = b
|
||||
break
|
||||
if not box: return
|
||||
else:
|
||||
box = self.boxes[evt.GetId()]
|
||||
# Collapse/restore static box, change label
|
||||
self.ShowGroup(box.gnum, not box.show)
|
||||
if box.show: box.SetLabel('[+] ' + box.name)
|
||||
else: box.SetLabel('[-] ' + box.name)
|
||||
self.Layout()
|
||||
self.Refresh()
|
||||
#for b in self.boxes.items():
|
||||
|
||||
# DaD
|
||||
def OnLeftDownOnButton(self, evt):
|
||||
|
@@ -11,12 +11,6 @@ import traceback
|
||||
# Constant to define standart window name
|
||||
STD_NAME = '_XRCED_T_W'
|
||||
|
||||
COLOUR_COMMENT = 'Blue'
|
||||
COLOUR_REF = 'DarkGreen'
|
||||
COLOUR_HIDDEN = 'Grey'
|
||||
COLOUR_HL = 'Red'
|
||||
COLOUR_DT = 'DarkGreen'
|
||||
|
||||
# Icons
|
||||
import images
|
||||
|
||||
@@ -420,44 +414,7 @@ def SetMenu(m, list, shift=False):
|
||||
class HighLightBox:
|
||||
colour = None
|
||||
def __init__(self, pos, size):
|
||||
if not self.colour: colour = self.colour = wx.NamedColour(COLOUR_HL)
|
||||
else: colour = self.colour
|
||||
if size.width == -1: size.width = 1
|
||||
if size.height == -1: size.height = 1
|
||||
w = g.testWin.panel
|
||||
l1 = wx.Window(w, -1, pos, wx.Size(size.width, 2))
|
||||
l1.SetBackgroundColour(self.colour)
|
||||
l2 = wx.Window(w, -1, pos, wx.Size(2, size.height))
|
||||
l2.SetBackgroundColour(self.colour)
|
||||
l3 = wx.Window(w, -1, wx.Point(pos.x + size.width - 2, pos.y), wx.Size(2, size.height))
|
||||
l3.SetBackgroundColour(self.colour)
|
||||
l4 = wx.Window(w, -1, wx.Point(pos.x, pos.y + size.height - 2), wx.Size(size.width, 2))
|
||||
l4.SetBackgroundColour(self.colour)
|
||||
self.lines = [l1, l2, l3, l4]
|
||||
self.size = size
|
||||
g.testWin.highLight = self
|
||||
# Move highlight to a new position
|
||||
def Replace(self, pos, size):
|
||||
if size.width == -1: size.width = 1
|
||||
if size.height == -1: size.height = 1
|
||||
self.lines[0].SetDimensions(pos.x, pos.y, size.width, 2)
|
||||
self.lines[1].SetDimensions(pos.x, pos.y, 2, size.height)
|
||||
self.lines[2].SetDimensions(pos.x + size.width - 2, pos.y, 2, size.height)
|
||||
self.lines[3].SetDimensions(pos.x, pos.y + size.height - 2, size.width, 2)
|
||||
self.size = size
|
||||
# Remove it
|
||||
def Remove(self):
|
||||
map(wx.Window.Destroy, self.lines)
|
||||
g.testWin.highLight = None
|
||||
def Refresh(self):
|
||||
map(wx.Window.Refresh, self.lines)
|
||||
|
||||
# Same for drop target
|
||||
class HighLightDTBox(HighLightBox):
|
||||
colour = None
|
||||
def __init__(self, pos, size):
|
||||
if not self.colour: colour = self.colour = wx.NamedColour(COLOUR_DT)
|
||||
else: colour = self.colour
|
||||
colour = g.tree.COLOUR_HL
|
||||
if size.width == -1: size.width = 0
|
||||
if size.height == -1: size.height = 0
|
||||
w = g.testWin.panel
|
||||
@@ -470,28 +427,79 @@ class HighLightDTBox(HighLightBox):
|
||||
l4 = wx.Window(w, -1, wx.Point(pos.x, pos.y + size.height - 2), wx.Size(size.width, 2))
|
||||
l4.SetBackgroundColour(colour)
|
||||
self.lines = [l1, l2, l3, l4]
|
||||
if wx.Platform == '__WXMSW__':
|
||||
for l in self.lines:
|
||||
l.Bind(wx.EVT_PAINT, self.OnPaint)
|
||||
g.testWin.highLight = self
|
||||
self.size = size
|
||||
# Repainting is not always done for these windows on Windows
|
||||
def OnPaint(self, evt):
|
||||
w = evt.GetEventObject()
|
||||
dc = wx.PaintDC(w)
|
||||
w.ClearBackground()
|
||||
dc.Destroy()
|
||||
# Move highlight to a new position
|
||||
def Replace(self, pos, size):
|
||||
if size.width == -1: size.width = 0
|
||||
if size.height == -1: size.height = 0
|
||||
self.lines[0].SetDimensions(pos.x, pos.y, size.width, 2)
|
||||
self.lines[1].SetDimensions(pos.x, pos.y, 2, size.height)
|
||||
self.lines[2].SetDimensions(pos.x + size.width - 2, pos.y, 2, size.height)
|
||||
self.lines[3].SetDimensions(pos.x, pos.y + size.height - 2, size.width, 2)
|
||||
self.size = size
|
||||
def Remove(self):
|
||||
map(wx.Window.Destroy, self.lines)
|
||||
g.testWin.highLight = None
|
||||
def Refresh(self):
|
||||
map(wx.Window.Refresh, self.lines)
|
||||
|
||||
# Same for drop target
|
||||
class HighLightDTBox(HighLightBox):
|
||||
colour = None
|
||||
def __init__(self, pos, size):
|
||||
colour = g.tree.COLOUR_DT
|
||||
if size.width == -1: size.width = 0
|
||||
if size.height == -1: size.height = 0
|
||||
w = g.testWin.panel
|
||||
l1 = wx.Window(w, -1, pos, wx.Size(size.width, 2))
|
||||
l1.SetBackgroundColour(colour)
|
||||
l2 = wx.Window(w, -1, pos, wx.Size(2, size.height))
|
||||
l2.SetBackgroundColour(colour)
|
||||
l3 = wx.Window(w, -1, wx.Point(pos.x + size.width - 2, pos.y), wx.Size(2, size.height))
|
||||
l3.SetBackgroundColour(colour)
|
||||
l4 = wx.Window(w, -1, wx.Point(pos.x, pos.y + size.height - 2), wx.Size(size.width, 2))
|
||||
l4.SetBackgroundColour(colour)
|
||||
self.lines = [l1, l2, l3, l4]
|
||||
self.item = None
|
||||
self.size = size
|
||||
# Remove it
|
||||
def Remove(self):
|
||||
map(wx.Window.Destroy, self.lines)
|
||||
g.testWin.highLightDT = None
|
||||
|
||||
def updateHL(hl, hlClass, pos, size):
|
||||
# Need to recreate window if size did not change to force update
|
||||
if hl and hl.size == size:
|
||||
hl.Remove()
|
||||
hl = None
|
||||
if hl:
|
||||
hl.Replace(pos, size)
|
||||
hl.Refresh()
|
||||
else:
|
||||
hl = hlClass(pos, size)
|
||||
hl.Refresh()
|
||||
return hl
|
||||
|
||||
################################################################################
|
||||
|
||||
class XML_Tree(wx.TreeCtrl):
|
||||
def __init__(self, parent, id):
|
||||
# Item colour
|
||||
self.COLOUR_COMMENT = wx.Colour(0, 0, 255)
|
||||
self.COLOUR_REF = wx.Colour(0, 0, 128)
|
||||
self.COLOUR_HIDDEN = wx.Colour(128, 128, 128)
|
||||
self.COLOUR_HL = wx.Colour(255, 0, 0)
|
||||
self.COLOUR_DT = wx.Colour(0, 64, 0)
|
||||
|
||||
wx.TreeCtrl.__init__(self, parent, id,
|
||||
style = wx.TR_HAS_BUTTONS | wx.TR_MULTIPLE | wx.TR_EDIT_LABELS)
|
||||
self.SetBackgroundColour(wx.Colour(224, 248, 224))
|
||||
@@ -569,7 +577,6 @@ class XML_Tree(wx.TreeCtrl):
|
||||
|
||||
# Clear tree
|
||||
def Clear(self):
|
||||
self.selection = None
|
||||
self.UnselectAll()
|
||||
self.DeleteAllItems()
|
||||
# Add minimal structure
|
||||
@@ -590,7 +597,6 @@ class XML_Tree(wx.TreeCtrl):
|
||||
|
||||
# Clear old data and set new
|
||||
def SetData(self, dom):
|
||||
self.selection = None
|
||||
self.UnselectAll()
|
||||
self.DeleteAllItems()
|
||||
# Add minimal structure
|
||||
@@ -634,12 +640,12 @@ class XML_Tree(wx.TreeCtrl):
|
||||
data=wx.TreeItemData(xxx))
|
||||
# Different color for comments and references
|
||||
if xxx.className == 'comment':
|
||||
self.SetItemTextColour(item, COLOUR_COMMENT)
|
||||
self.SetItemTextColour(item, self.COLOUR_COMMENT)
|
||||
self.SetItemFont(item, self.fontComment)
|
||||
elif treeObj.ref:
|
||||
self.SetItemTextColour(item, COLOUR_REF)
|
||||
self.SetItemTextColour(item, self.COLOUR_REF)
|
||||
elif treeObj.hasStyle and treeObj.params.get('hidden', False):
|
||||
self.SetItemTextColour(item, COLOUR_HIDDEN)
|
||||
self.SetItemTextColour(item, self.COLOUR_HIDDEN)
|
||||
# Try to find children objects
|
||||
if treeObj.hasChildren:
|
||||
nodes = treeObj.node.childNodes[:]
|
||||
@@ -670,12 +676,12 @@ class XML_Tree(wx.TreeCtrl):
|
||||
treeObj = xxx.treeObject()
|
||||
# Different color for references and comments
|
||||
if xxx.className == 'comment':
|
||||
self.SetItemTextColour(newItem, COLOUR_COMMENT)
|
||||
self.SetItemTextColour(newItem, self.COLOUR_COMMENT)
|
||||
self.SetItemFont(newItem, self.fontComment)
|
||||
elif treeObj.ref:
|
||||
self.SetItemTextColour(newItem, COLOUR_REF)
|
||||
self.SetItemTextColour(newItem, self.COLOUR_REF)
|
||||
elif treeObj.hasStyle and treeObj.params.get('hidden', False):
|
||||
self.SetItemTextColour(newItem, COLOUR_HIDDEN)
|
||||
self.SetItemTextColour(newItem, self.COLOUR_HIDDEN)
|
||||
# Add children items
|
||||
if xxx.hasChildren:
|
||||
treeObj = xxx.treeObject()
|
||||
@@ -691,8 +697,6 @@ class XML_Tree(wx.TreeCtrl):
|
||||
parent = node.parentNode
|
||||
parent.removeChild(node)
|
||||
self.Delete(leaf)
|
||||
# Reset selection object
|
||||
self.selection = None
|
||||
return node
|
||||
|
||||
# Find position relative to the top-level window
|
||||
@@ -768,10 +772,27 @@ class XML_Tree(wx.TreeCtrl):
|
||||
def OnSelChanged(self, evt):
|
||||
if self.selectionChanging: return
|
||||
self.selectionChanging = True
|
||||
self.UnselectAll()
|
||||
self.SelectItem(evt.GetItem())
|
||||
wx.TreeCtrl.UnselectAll(self)
|
||||
self.ChangeSelection(evt.GetItem())
|
||||
wx.TreeCtrl.SelectItem(self, evt.GetItem())
|
||||
self.selectionChanging = False
|
||||
g.frame.SetStatusText('')
|
||||
evt.Skip()
|
||||
|
||||
# Override to use like single-selection tree
|
||||
def GetSelection(self):
|
||||
return self.selection
|
||||
|
||||
def SelectItem(self, item):
|
||||
self.UnselectAll()
|
||||
self.ChangeSelection(item)
|
||||
wx.TreeCtrl.SelectItem(self, item)
|
||||
|
||||
def UnselectAll(self):
|
||||
self.selection = None
|
||||
g.tools.UpdateUI()
|
||||
wx.TreeCtrl.UnselectAll(self)
|
||||
wx.Yield()
|
||||
|
||||
def ChangeSelection(self, item):
|
||||
# Apply changes
|
||||
@@ -791,11 +812,12 @@ class XML_Tree(wx.TreeCtrl):
|
||||
status = 'Changes were applied'
|
||||
if status: g.frame.SetStatusText(status)
|
||||
# Generate view
|
||||
self.selection = item
|
||||
if not self.selection.IsOk():
|
||||
if not item:
|
||||
self.selection = None
|
||||
return
|
||||
xxx = self.GetPyData(self.selection)
|
||||
else:
|
||||
self.selection = item
|
||||
xxx = self.GetPyData(item)
|
||||
# Update panel
|
||||
g.panel.SetData(xxx)
|
||||
# Update tools
|
||||
@@ -1076,7 +1098,9 @@ class XML_Tree(wx.TreeCtrl):
|
||||
def OnSizeTestWin(self, evt):
|
||||
# Update highlight after size change
|
||||
hl = g.testWin.highLight
|
||||
if hl: hl.Replace(self.FindNodePos(hl.item), hl.obj.GetSize())
|
||||
if hl:
|
||||
hl.Replace(self.FindNodePos(hl.item), hl.obj.GetSize())
|
||||
hl.Refresh()
|
||||
#self.HighLight(g.testWin.highLight.item)
|
||||
evt.Skip()
|
||||
|
||||
@@ -1125,15 +1149,6 @@ class XML_Tree(wx.TreeCtrl):
|
||||
return False
|
||||
return not (self.IsExpanded(item) and self.GetChildrenCount(item, False))
|
||||
|
||||
# Override to use like single-selection tree
|
||||
def GetSelection(self):
|
||||
return self.selection
|
||||
|
||||
def SelectItem(self, item):
|
||||
self.UnselectAll()
|
||||
self.ChangeSelection(item)
|
||||
wx.TreeCtrl.SelectItem(self, item)
|
||||
|
||||
# Pull-down
|
||||
def OnRightDown(self, evt):
|
||||
pullDownMenu = g.pullDownMenu
|
||||
@@ -1359,7 +1374,7 @@ class DropTarget(wx.PyDropTarget):
|
||||
if not hl or hl.item != parentItem:
|
||||
g.testWin.highLightDT = updateHL(hl, HighLightDTBox, pos, size)
|
||||
g.testWin.highLightDT.item = parentItem
|
||||
g.tree.SetItemTextColour(parentItem, COLOUR_DT)
|
||||
g.tree.SetItemTextColour(parentItem, g.tree.COLOUR_DT)
|
||||
g.tree.EnsureVisible(parentItem)
|
||||
g.frame.SetStatusText('Drop target: %s' % parent.treeName())
|
||||
else:
|
||||
|
@@ -878,7 +878,6 @@ class Frame(wx.Frame):
|
||||
self.modified = True
|
||||
self.SetStatusText(status)
|
||||
|
||||
|
||||
def OnCutDelete(self, evt):
|
||||
selected = tree.selection
|
||||
if not selected: return # key pressed event
|
||||
@@ -905,6 +904,7 @@ class Frame(wx.Frame):
|
||||
index = tree.ItemFullIndex(selected)
|
||||
xxx = tree.GetPyData(selected)
|
||||
parent = tree.GetPyData(tree.GetItemParent(selected)).treeObject()
|
||||
tree.UnselectAll()
|
||||
elem = tree.RemoveLeaf(selected)
|
||||
undoMan.RegisterUndo(UndoCutDelete(index, parent, elem))
|
||||
if evt.GetId() == wx.ID_CUT:
|
||||
@@ -922,10 +922,7 @@ class Frame(wx.Frame):
|
||||
else:
|
||||
wx.MessageBox("Unable to open the clipboard", "Error")
|
||||
tree.pendingHighLight = None
|
||||
tree.UnselectAll()
|
||||
tree.selection = None
|
||||
# Update tools
|
||||
g.tools.UpdateUI()
|
||||
panel.Clear()
|
||||
self.SetModified()
|
||||
self.SetStatusText(status)
|
||||
@@ -1400,7 +1397,7 @@ Homepage: http://xrced.sourceforge.net\
|
||||
panel.RemovePage(1)
|
||||
if not self.IsIconized():
|
||||
conf.x, conf.y = self.GetPosition()
|
||||
conf.width, conf.height = self.GetSize()
|
||||
conf.width, conf.height = self.GetClientSize()
|
||||
if conf.embedPanel:
|
||||
conf.sashPos = self.splitter.GetSashPosition()
|
||||
else:
|
||||
@@ -1766,6 +1763,7 @@ Please upgrade wxWidgets to %d.%d.%d or higher.''' % MinWxVersion)
|
||||
wx.FileSystem.AddHandler(wx.MemoryFSHandler())
|
||||
# Create main frame
|
||||
frame = Frame(pos, size)
|
||||
frame.SetClientSize(size)
|
||||
frame.Show(True)
|
||||
|
||||
# Load plugins
|
||||
|
Reference in New Issue
Block a user