From fe295b0d3e61c2b32079d886f5109fe825d14eb8 Mon Sep 17 00:00:00 2001 From: Roman Rolinsky Date: Sun, 11 Mar 2007 23:37:08 +0000 Subject: [PATCH] editing comments by editing tree label git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44770 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/wx/tools/XRCed/panel.py | 11 +++++++++++ wxPython/wx/tools/XRCed/params.py | 7 ++++--- wxPython/wx/tools/XRCed/tree.py | 25 ++++++++++++++++++++++--- wxPython/wx/tools/XRCed/xrced.py | 2 ++ wxPython/wx/tools/XRCed/xrced.xrc | 3 +-- 5 files changed, 40 insertions(+), 8 deletions(-) diff --git a/wxPython/wx/tools/XRCed/panel.py b/wxPython/wx/tools/XRCed/panel.py index 08600bc384..43fe83d6ad 100644 --- a/wxPython/wx/tools/XRCed/panel.py +++ b/wxPython/wx/tools/XRCed/panel.py @@ -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 diff --git a/wxPython/wx/tools/XRCed/params.py b/wxPython/wx/tools/XRCed/params.py index 3a05721ca0..53027dddec 100644 --- a/wxPython/wx/tools/XRCed/params.py +++ b/wxPython/wx/tools/XRCed/params.py @@ -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): diff --git a/wxPython/wx/tools/XRCed/tree.py b/wxPython/wx/tools/XRCed/tree.py index abc0a8e452..ec093e4055 100644 --- a/wxPython/wx/tools/XRCed/tree.py +++ b/wxPython/wx/tools/XRCed/tree.py @@ -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() diff --git a/wxPython/wx/tools/XRCed/xrced.py b/wxPython/wx/tools/XRCed/xrced.py index 11d29e8763..046bb763f4 100644 --- a/wxPython/wx/tools/XRCed/xrced.py +++ b/wxPython/wx/tools/XRCed/xrced.py @@ -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 diff --git a/wxPython/wx/tools/XRCed/xrced.xrc b/wxPython/wx/tools/XRCed/xrced.xrc index 59c625a1c2..16ba037d94 100644 --- a/wxPython/wx/tools/XRCed/xrced.xrc +++ b/wxPython/wx/tools/XRCed/xrced.xrc @@ -1,6 +1,5 @@ - Text Dialog 1 @@ -620,4 +619,4 @@ - + \ No newline at end of file -- 2.45.2