editing comments by editing tree label

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44770 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Roman Rolinsky
2007-03-11 23:37:08 +00:00
parent 9812391356
commit fe295b0d3e
5 changed files with 40 additions and 8 deletions

View File

@@ -309,6 +309,8 @@ class PropPage(ParamPage):
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),
@@ -317,6 +319,7 @@ class PropPage(ParamPage):
topSizer.Add(sizer, 1, wx.ALL | wx.EXPAND, 3)
self.SetSizer(topSizer)
topSizer.Fit(self)
def SetValues(self, xxx):
self.xxx = xxx
self.origChecks = []
@@ -343,6 +346,13 @@ class PropPage(ParamPage):
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
@@ -369,6 +379,7 @@ class StylePage(ParamPage):
self.SetAutoLayout(True)
self.SetSizer(topSizer)
topSizer.Fit(self)
# Set data for a cahced page
def SetValues(self, xxx):
self.xxx = xxx

View File

@@ -450,12 +450,12 @@ class ParamMultilineText(PPanel):
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)
@@ -486,7 +486,8 @@ class ParamEncoding(ParamText):
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):

View File

@@ -435,10 +435,12 @@ class HighLightBox:
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
@@ -449,6 +451,8 @@ class XML_Tree(wx.TreeCtrl):
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
@@ -609,6 +613,7 @@ class XML_Tree(wx.TreeCtrl):
# 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):
@@ -1203,3 +1208,17 @@ class XML_Tree(wx.TreeCtrl):
# 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()

View File

@@ -1123,6 +1123,8 @@ Homepage: http://xrced.sourceforge.net\
else:
tree.pendingHighLight = None
tree.SetFocus()
if not xxx.isElement:
tree.EditLabel(newItem)
self.SetModified()
# Replace one object with another

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" ?>
<resource>
<!-- The beginning is here -->
<object class="wxDialog" name="DIALOG_TEXT">
<title>Text Dialog</title>
<centered>1</centered>