]> git.saurik.com Git - wxWidgets.git/commitdiff
editing comments by editing tree label
authorRoman Rolinsky <rolinsky@femagsoft.com>
Sun, 11 Mar 2007 23:37:08 +0000 (23:37 +0000)
committerRoman Rolinsky <rolinsky@femagsoft.com>
Sun, 11 Mar 2007 23:37:08 +0000 (23:37 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44770 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

wxPython/wx/tools/XRCed/panel.py
wxPython/wx/tools/XRCed/params.py
wxPython/wx/tools/XRCed/tree.py
wxPython/wx/tools/XRCed/xrced.py
wxPython/wx/tools/XRCed/xrced.xrc

index 08600bc3844494c454c85b46b53b85396be2058f..43fe83d6ad7d11f4bd79f93899e2751c831a39b3 100644 (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
index 3a05721ca01c22f0409ddd5762a74ae2e2fb838f..53027dddec9e325c02fc86e8ba8a14d410339a2a 100644 (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):
index abc0a8e4520827ecc98ebe5bf4c1832b61f51bae..ec093e40553e7e86eafa87243fca43a3e17c462d 100644 (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()
index 11d29e87637d347f498760efa4e260c654a8d672..046bb763f4c8c94afe9ce5a7185d037955aecc8c 100644 (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
index 59c625a1c22337c3610aef7d226b12ff401e3938..16ba037d9411bf9f8e317f1925b0777bab15f6ee 100644 (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>
       </object>
     </object>
   </object>
-</resource>
+</resource>
\ No newline at end of file