]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/wx/tools/XRCed/panel.py
wxMSW fixes for tree control
[wxWidgets.git] / wxPython / wx / tools / XRCed / panel.py
index 1ace9f7596dc08da74b25b73364b8d273c027b5a..407888f52c19b92dd29b3566f6ea80f8b0d211e3 100644 (file)
@@ -37,18 +37,26 @@ class Panel(wxNotebook):
         self.AddPage(self.page1, 'Properties')
         # Second page
         self.page2 = wxScrolledWindow(self, -1)
+        self.page2.Hide()
         sizer = wxBoxSizer()
         sizer.Add(wxBoxSizer())         # dummy sizer
         self.page2.SetAutoLayout(True)
         self.page2.SetSizer(sizer)
+        # Cache for already used panels
+        self.pageCache = {}             # cached property panels
+        self.stylePageCache = {}        # cached style panels
 
     # Delete child windows and recreate page sizer
     def ResetPage(self, page):
         topSizer = page.GetSizer()
         sizer = topSizer.GetChildren()[0].GetSizer()
         for w in page.GetChildren():
-            w.Destroy()
-            
+            sizer.Detach(w)
+            if isinstance(w, ParamPage):
+                if w.IsShown():
+                    w.Hide()
+            else:
+                w.Destroy()
         topSizer.Remove(sizer)
         # Create new windows
         sizer = wxBoxSizer(wxVERTICAL)
@@ -64,7 +72,7 @@ class Panel(wxNotebook):
         # First page
         # Remove current objects and sizer
         sizer = self.ResetPage(self.page1)
-        if not xxx or (not xxx.allParams and not xxx.hasName):
+        if not xxx or (not xxx.allParams and not xxx.hasName and not xxx.hasChild):
             if g.tree.selection:
                 sizer.Add(wxStaticText(self.page1, -1, 'This item has no properties.'))
             else:                       # nothing selected
@@ -81,13 +89,27 @@ class Panel(wxNotebook):
             g.currentXXX = xxx.treeObject()
             # Normal or SizerItem page
             isGBSizerItem = isinstance(xxx.parent, xxxGridBagSizer)
-            page = PropPage(self.page1, xxx.panelName(), xxx)
+            cacheID = (xxx.__class__, isGBSizerItem)            
+            try:
+                page = self.pageCache[cacheID]
+                page.box.SetLabel(xxx.panelName())
+                page.Show()
+            except KeyError:
+                page = PropPage(self.page1, xxx.panelName(), xxx)
+                self.pageCache[cacheID] = page
             page.SetValues(xxx)
             self.pages.append(page)
             sizer.Add(page, 1, wxEXPAND)
             if xxx.hasChild:
                 # Special label for child objects - they may have different GUI
-                page = PropPage(self.page1, xxx.child.panelName(), xxx.child)
+                cacheID = (xxx.child.__class__, xxx.__class__)
+                try:
+                    page = self.pageCache[cacheID]
+                    page.box.SetLabel(xxx.child.panelName())
+                    page.Show()
+                except KeyError:
+                    page = PropPage(self.page1, xxx.child.panelName(), xxx.child)
+                    self.pageCache[cacheID] = page
                 page.SetValues(xxx.child)
                 self.pages.append(page)
                 sizer.Add(page, 0, wxEXPAND | wxTOP, 5)
@@ -101,7 +123,12 @@ class Panel(wxNotebook):
             xxx = xxx.treeObject()
             # Simplest case: set data if class is the same
             sizer = self.ResetPage(self.page2)
-            page = StylePage(self.page2, xxx.className + ' style', xxx)
+            try:
+                page = self.stylePageCache[xxx.__class__]
+                page.Show()
+            except KeyError:
+                page = StylePage(self.page2, xxx.className + ' style', xxx)
+                self.stylePageCache[xxx.__class__] = page
             page.SetValues(xxx)
             self.pages.append(page)
             sizer.Add(page, 0, wxEXPAND)
@@ -109,6 +136,8 @@ class Panel(wxNotebook):
             if not self.GetPageCount() == 2:
                 self.AddPage(self.page2, 'Style')
             self.page2.Layout()
+            if 'wxGTK' in wx.PlatformInfo:
+                self.page2.Show(True)
             size = self.page2.GetSizer().GetMinSize()
             self.page2.SetScrollbars(1, 1, size.width, size.height, 0, 0, True)
         else:
@@ -118,17 +147,21 @@ class Panel(wxNotebook):
                 self.page1.Refresh()
                 self.RemovePage(1)
         self.modified = False
+        
     def Clear(self):
         self.SetData(None)
         self.modified = False
+        
     # If some parameter has changed
     def IsModified(self):
         return self.modified
+    
     def SetModified(self, value):
         # Register undo object when modifying first time
         if not self.modified and value:
            g.undoMan.RegisterUndo(UndoEdit())
         self.modified = value
+        
     def Apply(self):
         for p in self.pages: p.Apply()
 
@@ -138,8 +171,6 @@ class Panel(wxNotebook):
 class ParamPage(wxPanel):
     def __init__(self, parent, xxx):
         wxPanel.__init__(self, parent, -1)
-        self.SetBackgroundColour(parent.GetBackgroundColour())
-        self.SetForegroundColour(parent.GetForegroundColour())
         self.xxx = xxx
         # Register event handlers
         for id in paramIDs.values():
@@ -168,7 +199,10 @@ class ParamPage(wxPanel):
                 xxx.params[param] = xxxParam(elem)
             # Find place to put new element: first present element after param
             found = False
-            paramStyles = xxx.allParams + xxx.styles
+            if xxx.hasStyle: 
+                paramStyles = xxx.allParams + xxx.styles
+            else:
+                paramStyles = xxx.allParams 
             for p in paramStyles[paramStyles.index(param) + 1:]:
                 # Content params don't have same type
                 if xxx.params.has_key(p) and p != 'content':