]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/wx/tools/XRCed/tree.py
add many new macros to facilitate using wx from projects using bakefile presets;...
[wxWidgets.git] / wxPython / wx / tools / XRCed / tree.py
index 26e8b91a8a9a0fb6a5e3439a76c016462ab81b6d..3c5ddf95fbc4a718402d1e1469eba2cf31fb92d9 100644 (file)
@@ -563,6 +563,8 @@ class XML_Tree(wx.TreeCtrl):
         # Different color for references
         if treeObj.ref:
             self.SetItemTextColour(item, 'DarkGreen')
+        elif treeObj.hasStyle and treeObj.params.get('hidden', False):
+            self.SetItemTextColour(item, 'Grey')
         # Try to find children objects
         if treeObj.hasChildren:
             nodes = treeObj.element.childNodes[:]
@@ -610,6 +612,7 @@ class XML_Tree(wx.TreeCtrl):
         # Reset selection object
         self.selection = None
         return node
+    
     # Find position relative to the top-level window
     def FindNodePos(self, item, obj=None):
         # Root at (0,0)
@@ -629,17 +632,18 @@ class XML_Tree(wx.TreeCtrl):
                         if g.testWin.highLight:
                             g.testWin.highLight.Remove()
                     break
-        # Find first ancestor which is a wxWindow (not a sizer)
+        # For sizers and notebooks we must select the first window-like parent
         winParent = itemParent
         while self.GetPyData(winParent).isSizer:
             winParent = self.GetItemParent(winParent)
         # Notebook children are layed out in a little strange way
-        if self.GetPyData(itemParent).treeObject().__class__ == xxxNotebook:
-            parentPos = wx.Point(0,0)
-        else:
-            parentPos = self.FindNodePos(winParent)
-        # Position (-1,-1) is really (0,0)
+        # wxGTK places NB panels relative to the NB parent
+        if wx.Platform == '__WXGTK__':
+            if self.GetPyData(itemParent).treeObject().__class__ == xxxNotebook:
+                winParent = self.GetItemParent(winParent)
+        parentPos = self.FindNodePos(winParent)
         pos = obj.GetPosition()
+        # Position (-1,-1) is really (0,0)
         if pos == (-1,-1): pos = (0,0)
         return parentPos + pos
 
@@ -698,7 +702,6 @@ class XML_Tree(wx.TreeCtrl):
             # If some data was modified, apply changes
             if g.panel.IsModified():
                 self.Apply(xxx, oldItem)
-                #if conf.autoRefresh:
                 if g.testWin:
                     if g.testWin.highLight:
                         g.testWin.highLight.Remove()
@@ -723,7 +726,8 @@ class XML_Tree(wx.TreeCtrl):
         if item == g.testWin.item: return False
         while item != self.root:
             item = self.GetItemParent(item)
-            if item == g.testWin.item: return True
+            if item == g.testWin.item:
+                return True
         return False
 
     # Highlight selected item
@@ -739,7 +743,9 @@ class XML_Tree(wx.TreeCtrl):
             return
         # Get window/sizer object
         obj = self.FindNodeObject(item)
-        if not obj:
+        xxx = self.GetPyData(item).treeObject()
+        # Remove existing HL if item not found or is hidden
+        if not obj or xxx.hasStyle and xxx.params.get('hidden', False):
             if g.testWin.highLight: g.testWin.highLight.Remove()
             return
         pos = self.FindNodePos(item, obj)
@@ -769,6 +775,7 @@ class XML_Tree(wx.TreeCtrl):
             return
         # Show item in bold
         if g.testWin:     # Reset old
+            self.UnselectAll()
             self.SetItemBold(g.testWin.item, False)
         try:
             wx.BeginBusyCursor()
@@ -953,9 +960,11 @@ class XML_Tree(wx.TreeCtrl):
                 testWin.toolBar = res.LoadToolBar(testWin, STD_NAME)
                 testWin.SetToolBar(testWin.toolBar)
                 testWin.Show(True)
+            # Catch some events, set highlight
             if testWin:
                 testWin.item = item
                 wx.EVT_CLOSE(testWin, self.OnCloseTestWin)
+                wx.EVT_SIZE(testWin, self.OnSizeTestWin)
                 testWin.highLight = None
                 if highLight and not self.pendingHighLight:
                     self.HighLight(highLight)
@@ -981,6 +990,11 @@ class XML_Tree(wx.TreeCtrl):
     def OnCloseTestWin(self, evt):
         self.CloseTestWindow()
 
+    def OnSizeTestWin(self, evt):
+        if g.testWin.highLight:
+            self.HighLight(g.testWin.highLight.item)
+        evt.Skip()
+
     # Return index in parent, for real window children
     def WindowIndex(self, item):
         n = 0                           # index of sibling
@@ -1116,7 +1130,7 @@ class XML_Tree(wx.TreeCtrl):
                         (ID_NEW.PANEL, 'Panel', 'Create panel'),
                         (ID_NEW.DIALOG, 'Dialog', 'Create dialog'),
                         (ID_NEW.FRAME, 'Frame', 'Create frame')], shift=True)
-                elif xxx.isSizer:
+                elif xxx.isSizer and self.ItemHasChildren(item):
                     SetMenu(m, pullDownMenu.sizers, shift=True)
                 else:
                     SetMenu(m, pullDownMenu.controls, shift=True)
@@ -1143,6 +1157,12 @@ class XML_Tree(wx.TreeCtrl):
         self.PopupMenu(menu, evt.GetPosition())
         menu.Destroy()
 
+    # Redefine to force the update of font dimentions on wxGTK
+    if wx.Platform == '__WXGTK__':
+        def SetItemBold(self, item, state=True):
+            wx.TreeCtrl.SetItemBold(self, item, state)
+            self.SetIndent(self.GetIndent())
+
     # Apply changes
     def Apply(self, xxx, item):
         g.panel.Apply()