different platforms.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45799
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
+0.1.8-6
+-------
+
+Various fixes and improvements to get look-and-feel similar across
+different platforms.
+
wx.wxEVT_COMMAND_BUTTON_CLICKED, g.frame.OnCreate)
wx.EVT_KEY_DOWN(self, self.OnKeyDown)
wx.EVT_KEY_UP(self, self.OnKeyUp)
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)
# Each group is inside box
id = wx.NewId()
box = wx.StaticBox(self, id, '[+] '+name, style=wx.WANTS_CHARS)
# 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.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))
box.Bind(wx.EVT_LEFT_DOWN, self.OnClickBox)
boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
boxSizer.Add((0, 4))
# Enable/disable group
def EnableGroup(self, gnum, enable = True):
grp = self.groups[gnum]
# Enable/disable group
def EnableGroup(self, gnum, enable = True):
grp = self.groups[gnum]
for b in grp[1].values(): b.Enable(enable)
# Show/hide group
for b in grp[1].values(): b.Enable(enable)
# Show/hide group
grp[1][id].Enable(enable)
def OnClickBox(self, evt):
grp[1][id].Enable(enable)
def OnClickBox(self, evt):
- box = self.boxes[evt.GetId()]
+ 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()
# 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):
# DaD
def OnLeftDownOnButton(self, evt):
# Constant to define standart window name
STD_NAME = '_XRCED_T_W'
# 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'
-
class HighLightBox:
colour = None
def __init__(self, pos, size):
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
+ colour = g.tree.COLOUR_HL
+ 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))
w = g.testWin.panel
l1 = wx.Window(w, -1, pos, wx.Size(size.width, 2))
- l1.SetBackgroundColour(self.colour)
+ l1.SetBackgroundColour(colour)
l2 = wx.Window(w, -1, pos, wx.Size(2, size.height))
l2 = wx.Window(w, -1, pos, wx.Size(2, size.height))
- l2.SetBackgroundColour(self.colour)
+ l2.SetBackgroundColour(colour)
l3 = wx.Window(w, -1, wx.Point(pos.x + size.width - 2, pos.y), wx.Size(2, size.height))
l3 = wx.Window(w, -1, wx.Point(pos.x + size.width - 2, pos.y), wx.Size(2, size.height))
- l3.SetBackgroundColour(self.colour)
+ l3.SetBackgroundColour(colour)
l4 = wx.Window(w, -1, wx.Point(pos.x, pos.y + size.height - 2), wx.Size(size.width, 2))
l4 = wx.Window(w, -1, wx.Point(pos.x, pos.y + size.height - 2), wx.Size(size.width, 2))
- l4.SetBackgroundColour(self.colour)
+ l4.SetBackgroundColour(colour)
self.lines = [l1, l2, l3, l4]
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
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):
# 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
+ 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
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 Remove(self):
map(wx.Window.Destroy, self.lines)
g.testWin.highLight = None
class HighLightDTBox(HighLightBox):
colour = None
def __init__(self, pos, size):
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_DT
if size.width == -1: size.width = 0
if size.height == -1: size.height = 0
w = g.testWin.panel
if size.width == -1: size.width = 0
if size.height == -1: size.height = 0
w = g.testWin.panel
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]
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]
# Remove it
def Remove(self):
map(wx.Window.Destroy, self.lines)
g.testWin.highLightDT = None
def updateHL(hl, hlClass, pos, 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)
if hl and hl.size == size:
hl.Remove()
hl = None
if hl:
hl.Replace(pos, size)
else:
hl = hlClass(pos, size)
else:
hl = hlClass(pos, size)
return hl
################################################################################
class XML_Tree(wx.TreeCtrl):
def __init__(self, parent, id):
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))
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))
# Clear tree
def Clear(self):
# Clear tree
def Clear(self):
self.UnselectAll()
self.DeleteAllItems()
# Add minimal structure
self.UnselectAll()
self.DeleteAllItems()
# Add minimal structure
# Clear old data and set new
def SetData(self, dom):
# Clear old data and set new
def SetData(self, dom):
self.UnselectAll()
self.DeleteAllItems()
# Add minimal structure
self.UnselectAll()
self.DeleteAllItems()
# Add minimal structure
data=wx.TreeItemData(xxx))
# Different color for comments and references
if xxx.className == 'comment':
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.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):
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[:]
# Try to find children objects
if treeObj.hasChildren:
nodes = treeObj.node.childNodes[:]
treeObj = xxx.treeObject()
# Different color for references and comments
if xxx.className == 'comment':
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.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):
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()
# Add children items
if xxx.hasChildren:
treeObj = xxx.treeObject()
parent = node.parentNode
parent.removeChild(node)
self.Delete(leaf)
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
return node
# Find position relative to the top-level window
def OnSelChanged(self, evt):
if self.selectionChanging: return
self.selectionChanging = True
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('')
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
def ChangeSelection(self, item):
# Apply changes
status = 'Changes were applied'
if status: g.frame.SetStatusText(status)
# Generate view
status = 'Changes were applied'
if status: g.frame.SetStatusText(status)
# Generate view
- self.selection = item
- if not self.selection.IsOk():
self.selection = None
return
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
# Update panel
g.panel.SetData(xxx)
# Update tools
def OnSizeTestWin(self, evt):
# Update highlight after size change
hl = g.testWin.highLight
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()
#self.HighLight(g.testWin.highLight.item)
evt.Skip()
return False
return not (self.IsExpanded(item) and self.GetChildrenCount(item, False))
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
# Pull-down
def OnRightDown(self, evt):
pullDownMenu = g.pullDownMenu
if not hl or hl.item != parentItem:
g.testWin.highLightDT = updateHL(hl, HighLightDTBox, pos, size)
g.testWin.highLightDT.item = parentItem
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:
g.tree.EnsureVisible(parentItem)
g.frame.SetStatusText('Drop target: %s' % parent.treeName())
else:
self.modified = True
self.SetStatusText(status)
self.modified = True
self.SetStatusText(status)
def OnCutDelete(self, evt):
selected = tree.selection
if not selected: return # key pressed event
def OnCutDelete(self, evt):
selected = tree.selection
if not selected: return # key pressed event
index = tree.ItemFullIndex(selected)
xxx = tree.GetPyData(selected)
parent = tree.GetPyData(tree.GetItemParent(selected)).treeObject()
index = tree.ItemFullIndex(selected)
xxx = tree.GetPyData(selected)
parent = tree.GetPyData(tree.GetItemParent(selected)).treeObject()
elem = tree.RemoveLeaf(selected)
undoMan.RegisterUndo(UndoCutDelete(index, parent, elem))
if evt.GetId() == wx.ID_CUT:
elem = tree.RemoveLeaf(selected)
undoMan.RegisterUndo(UndoCutDelete(index, parent, elem))
if evt.GetId() == wx.ID_CUT:
else:
wx.MessageBox("Unable to open the clipboard", "Error")
tree.pendingHighLight = None
else:
wx.MessageBox("Unable to open the clipboard", "Error")
tree.pendingHighLight = None
- tree.UnselectAll()
- tree.selection = None
panel.Clear()
self.SetModified()
self.SetStatusText(status)
panel.Clear()
self.SetModified()
self.SetStatusText(status)
panel.RemovePage(1)
if not self.IsIconized():
conf.x, conf.y = self.GetPosition()
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:
if conf.embedPanel:
conf.sashPos = self.splitter.GetSashPosition()
else:
wx.FileSystem.AddHandler(wx.MemoryFSHandler())
# Create main frame
frame = Frame(pos, size)
wx.FileSystem.AddHandler(wx.MemoryFSHandler())
# Create main frame
frame = Frame(pos, size)
+ frame.SetClientSize(size)
frame.Show(True)
# Load plugins
frame.Show(True)
# Load plugins