control.Enable(present)
# Comment has only one parameter
if isinstance(xxx, xxxComment):
+ # Bind char event to check Enter key
+ control.text.Bind(wx.EVT_CHAR, self.OnEnter)
sizer.Add(control, 0, wx.ALIGN_CENTER_VERTICAL | wx.GROW)
else:
sizer.AddMany([ (label, 0, wx.ALIGN_CENTER_VERTICAL),
topSizer.Add(sizer, 1, wx.ALL | wx.EXPAND, 3)
self.SetSizer(topSizer)
topSizer.Fit(self)
+
def SetValues(self, xxx):
self.xxx = xxx
self.origChecks = []
self.origChecks.append((param, False))
self.origControls.append((param, '', False))
+ # This is called only for comment now
+ def OnEnter(self, evt):
+ if evt.GetKeyCode() == 13:
+ g.tree.Apply(self.xxx, g.tree.selection)
+ else:
+ evt.Skip()
+
################################################################################
# Style notebook page
self.SetAutoLayout(True)
self.SetSizer(topSizer)
topSizer.Fit(self)
+
# Set data for a cahced page
def SetValues(self, xxx):
self.xxx = xxx
dlg.Destroy()
class ParamText(PPanel):
- def __init__(self, parent, name, textWidth=-1):
+ def __init__(self, parent, name, textWidth=-1, style=0):
PPanel.__init__(self, parent, name)
self.ID_TEXT_CTRL = wx.NewId()
# We use sizer even here to have the same size of text control
sizer = wx.BoxSizer()
- self.text = wx.TextCtrl(self, self.ID_TEXT_CTRL, size=wx.Size(textWidth,-1))
+ self.text = wx.TextCtrl(self, self.ID_TEXT_CTRL, size=wx.Size(textWidth,-1), style=style)
if textWidth == -1: option = 1
else: option = 0
sizer.Add(self.text, option, wx.ALIGN_CENTER_VERTICAL | wx.TOP | wx.BOTTOM, 2)
class ParamComment(ParamText):
def __init__(self, parent, name):
- ParamText.__init__(self, parent, name, 330 + buttonSize[0])
+ ParamText.__init__(self, parent, name, 330 + buttonSize[0],
+ style=wx.TE_PROCESS_ENTER)
class ContentDialog(wx.Dialog):
def __init__(self, parent, value):
class XML_Tree(wx.TreeCtrl):
def __init__(self, parent, id):
- wx.TreeCtrl.__init__(self, parent, id, style = wx.TR_HAS_BUTTONS | wx.TR_MULTIPLE)
+ 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))
- self.fontComment = wx.Font(g.sysFont().GetPointSize(), wx.DEFAULT,
- wx.FONTSTYLE_ITALIC, wx.NORMAL)
+ self.fontComment = wx.FFont(self.GetFont().GetPointSize(),
+ self.GetFont().GetFamily(),
+ wx.FONTFLAG_ITALIC)
# Register events
wx.EVT_TREE_SEL_CHANGED(self, self.GetId(), self.OnSelChanged)
# One works on Linux, another on Windows
wx.EVT_RIGHT_DOWN(self, self.OnRightDown)
wx.EVT_TREE_ITEM_EXPANDED(self, self.GetId(), self.OnItemExpandedCollapsed)
wx.EVT_TREE_ITEM_COLLAPSED(self, self.GetId(), self.OnItemExpandedCollapsed)
+ self.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, self.OnBeginLabelEdit)
+ self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnEndLabelEdit)
self.selection = None
self.selectionChanging = False
# Different color for references and comments
if xxx.className == 'comment':
self.SetItemTextColour(newItem, 'Blue')
+ self.SetItemFont(newItem, self.fontComment)
elif treeObj.ref:
self.SetItemTextColour(newItem, 'DarkGreen')
elif treeObj.hasStyle and treeObj.params.get('hidden', False):
# Set global modified state
g.frame.SetModified()
+ def OnBeginLabelEdit(self, evt):
+ xxx = self.GetPyData(evt.GetItem())
+ if xxx.isElement:
+ evt.Veto()
+ else:
+ evt.Skip()
+
+ def OnEndLabelEdit(self, evt):
+ xxx = self.GetPyData(evt.GetItem())
+ node = xxx.node
+ if not xxx.isElement:
+ node.data = evt.GetLabel()
+ g.panel.SetData(xxx)
+ evt.Skip()
else:
tree.pendingHighLight = None
tree.SetFocus()
+ if not xxx.isElement:
+ tree.EditLabel(newItem)
self.SetModified()
# Replace one object with another
<?xml version="1.0" ?>
<resource>
- <!-- The beginning is here -->
<object class="wxDialog" name="DIALOG_TEXT">
<title>Text Dialog</title>
<centered>1</centered>
</object>
</object>
</object>
-</resource>
+</resource>
\ No newline at end of file