]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/wx/py/filling.py
Factory some of wxFilterClassFactory into a base class.
[wxWidgets.git] / wxPython / wx / py / filling.py
index 0a4b701465ecdcb98d85a8610fd6363dc79d0c1f..28714bd6a54bb10c3f4bcb01b547f5413fd89076 100644 (file)
@@ -16,11 +16,6 @@ import sys
 import types
 from version import VERSION
 
-try:
-    True
-except NameError:
-    True = 1==1
-    False = 1==0
 
 COMMONTYPES = [getattr(types, t) for t in dir(types) \
                if not t.startswith('_') \
@@ -66,10 +61,10 @@ class FillingTree(wx.TreeCtrl):
         rootData = wx.TreeItemData(rootObject)
         self.item = self.root = self.AddRoot(rootLabel, -1, -1, rootData)
         self.SetItemHasChildren(self.root, self.objHasChildren(rootObject))
-        wx.EVT_TREE_ITEM_EXPANDING(self, self.GetId(), self.OnItemExpanding)
-        wx.EVT_TREE_ITEM_COLLAPSED(self, self.GetId(), self.OnItemCollapsed)
-        wx.EVT_TREE_SEL_CHANGED(self, self.GetId(), self.OnSelChanged)
-        wx.EVT_TREE_ITEM_ACTIVATED(self, self.GetId(), self.OnItemActivated)
+        self.Bind(wx.EVT_TREE_ITEM_EXPANDING, self.OnItemExpanding, id=self.GetId())
+        self.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.OnItemCollapsed, id=self.GetId())
+        self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged, id=self.GetId())
+        self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnItemActivated, id=self.GetId())
         if not static:
             dispatcher.connect(receiver=self.push, signal='Interpreter.push')
 
@@ -164,6 +159,8 @@ class FillingTree(wx.TreeCtrl):
 
     def display(self):
         item = self.item
+        if not item:
+            return
         if self.IsExpanded(item):
             self.addChildren(item)
         self.setText('')
@@ -282,24 +279,49 @@ class Filling(wx.SplitterWindow):
     revision = __revision__
 
     def __init__(self, parent, id=-1, pos=wx.DefaultPosition,
-                 size=wx.DefaultSize, style=wx.SP_3D,
+                 size=wx.DefaultSize, style=wx.SP_3D|wx.SP_LIVE_UPDATE,
                  name='Filling Window', rootObject=None,
                  rootLabel=None, rootIsNamespace=False, static=False):
         """Create a Filling instance."""
         wx.SplitterWindow.__init__(self, parent, id, pos, size, style, name)
+
         self.tree = FillingTree(parent=self, rootObject=rootObject,
                                 rootLabel=rootLabel,
                                 rootIsNamespace=rootIsNamespace,
                                 static=static)
         self.text = FillingText(parent=self, static=static)
-        self.SplitVertically(self.tree, self.text, 130)
+        
+        wx.FutureCall(1, self.SplitVertically, self.tree, self.text, 200)
+        
         self.SetMinimumPaneSize(1)
+
         # Override the filling so that descriptions go to FillingText.
         self.tree.setText = self.text.SetText
+
         # Display the root item.
-##        self.tree.SelectItem(self.tree.root)
+        self.tree.SelectItem(self.tree.root)
         self.tree.display()
 
+        self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, self.OnChanged)
+
+    def OnChanged(self, event):
+        #this is important: do not evaluate this event=> otherwise, splitterwindow behaves strange
+        #event.Skip()
+        pass
+
+
+    def LoadSettings(self, config):
+        pos = config.ReadInt('Sash/FillingPos', 200)
+        wx.FutureCall(250, self.SetSashPosition, pos)
+        zoom = config.ReadInt('View/Zoom/Filling', -99)
+        if zoom != -99:
+            self.text.SetZoom(zoom)
+
+    def SaveSettings(self, config):
+        config.WriteInt('Sash/FillingPos', self.GetSashPosition())
+        config.WriteInt('View/Zoom/Filling', self.text.GetZoom())
+
+
 
 class FillingFrame(wx.Frame):
     """Frame containing the namespace tree component."""