[Commits] (john) Generalized ShowHideSidebar to work with other blocks.

commits at osafoundation.org commits at osafoundation.org
Sat May 8 17:19:53 PDT 2004


Commit by: john
Modified files:
osaf/chandler/Chandler/parcels/OSAF/views/main/SideBar.py 1.6 1.7
osaf/chandler/Chandler/parcels/OSAF/views/main/parcel.xml 1.33 1.34
osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Events/parcel.xml 1.21 1.22
osaf/chandler/Chandler/parcels/OSAF/framework/blocks/ContainerBlocks.py 1.76 1.77
osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Block.py 1.23 1.24

Log message:
Generalized ShowHideSidebar to work with other blocks.
Eliminated Sidebar class, it's now unnecessary
Simplified wxSynchronizeFramework for SplitWindow


ViewCVS links:
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/parcels/OSAF/views/main/SideBar.py.diff?r1=text&tr1=1.6&r2=text&tr2=1.7
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/parcels/OSAF/views/main/parcel.xml.diff?r1=text&tr1=1.33&r2=text&tr2=1.34
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Events/parcel.xml.diff?r1=text&tr1=1.21&r2=text&tr2=1.22
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/parcels/OSAF/framework/blocks/ContainerBlocks.py.diff?r1=text&tr1=1.76&r2=text&tr2=1.77
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Block.py.diff?r1=text&tr1=1.23&r2=text&tr2=1.24

Index: osaf/chandler/Chandler/parcels/OSAF/framework/blocks/ContainerBlocks.py
diff -u osaf/chandler/Chandler/parcels/OSAF/framework/blocks/ContainerBlocks.py:1.76 osaf/chandler/Chandler/parcels/OSAF/framework/blocks/ContainerBlocks.py:1.77
--- osaf/chandler/Chandler/parcels/OSAF/framework/blocks/ContainerBlocks.py:1.76	Thu May  6 10:44:36 2004
+++ osaf/chandler/Chandler/parcels/OSAF/framework/blocks/ContainerBlocks.py	Sat May  8 17:19:19 2004
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.76 $"
-__date__ = "$Date: 2004/05/06 17:44:36 $"
+__version__ = "$Revision: 1.77 $"
+__date__ = "$Date: 2004/05/09 00:19:19 $"
 __copyright__ = "Copyright (c) 2003 Open Source Applications Foundation"
 __license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -172,64 +172,60 @@
         self.SetSize ((counterpart.size.width, counterpart.size.height))
 
         assert (len (counterpart.childrenBlocks) >= 1 and
-                len (counterpart.childrenBlocks) <= 2)
+                len (counterpart.childrenBlocks) <= 2), "We don't currently allow splitter windows with no contents"
 
         # Collect information about the splitter
         oldWindow1 = self.GetWindow1()
         oldWindow2 = self.GetWindow2()
+        
+        window1 = None
+        window2 = None
+
         children = iter (counterpart.childrenBlocks)
-        window1 = Globals.association[children.next().itsUUID]
-        try:
-            window2 = Globals.association[children.next().itsUUID]
-        except StopIteration:
-            window2 = None
-            isSplit = False
-        else:
-            isSplit = True
+        child1 = children.next()
+        if child1.open:
+            window1 = Globals.association[child1.itsUUID]
+
+        if len (counterpart.childrenBlocks) >= 2:
+            child2 = children.next()
+            if child2.open:
+                window2 = Globals.association[child2.itsUUID]
 
+        isSplit = bool (window1) and bool (window2)
+        
         # Update any differences between the block and wxCounterpart
         self.Freeze()
-        if isSplit:
-            if (counterpart.orientationEnum == "Horizontal"):
-                splitMode = wx.SPLIT_HORIZONTAL
-                distance = counterpart.size.width
-            else:
-                assert counterpart.orientationEnum == "Vertical"
-                splitMode = wx.SPLIT_VERTICAL
-                distance = counterpart.size.height
-            position = int (round (distance * counterpart.splitPercentage))
-
-            if self.IsSplit():
-                if self.GetSplitMode() != splitMode:
-                    self.SetSplitMode (splitMode)
-                if oldWindow1 != window1:
-                    result = self.ReplaceWindow (oldWindow1, window1)
-                    assert (result)
-                    oldWindow1.Destroy()
-                if oldWindow2 != window2:
-                    result = self.ReplaceWindow (oldWindow2, window2)
-                    assert (result)
-                    oldWindow2.Destroy()
+        if not self.IsSplit() and isSplit:
+            if counterpart.orientationEnum == "Horizontal":
+                position = counterpart.size.height * counterpart.splitPercentage
+                success = self.SplitHorizontally (window1, window2, position)
             else:
-                if splitMode == wx.SPLIT_HORIZONTAL:
-                    success = self.SplitHorizontally (window1, window2, position)
-                else:
-                    success = self.SplitVertically (window1, window2, position)
-                assert success
-                if oldWindow1 and (oldWindow1 != window1):
-                    oldWindow1.Destroy()
-
-        else:
-            if self.IsSplit():
-                self.UnSplit()
-                oldWindow2.Destroy()
-            if not oldWindow1:
+                position = counterpart.size.width * counterpart.splitPercentage
+                success = self.SplitVertically (window1, window2, position)
+            assert success
+            window1.Show()
+            window2.Show()
+        elif not oldWindow1 and not oldWindow2 and not isSplit:
+            if window1:
                 self.Initialize (window1)
             else:
-                if oldWindow1 != window1:
-                    result = self.ReplaceWindow (self.GetWindow1(), window1)
-                    assert (result)
-                    oldWindow1.Destroy()
+                self.Initialize (window2)
+        else:
+            if self.IsSplit() and not isSplit:
+                success = self.Unsplit()
+                assert success
+            if bool (oldWindow1) ^ bool (window1):
+                window1, window2 = window2, window1
+            if window1:
+                success = self.ReplaceWindow (oldWindow1, window1)
+                assert success
+                oldWindow1.Show(False)
+                window1.Show()
+            if window2:
+                success = self.ReplaceWindow (oldWindow2, window2)
+                assert success
+                oldWindow2.Show(False)
+                window2.Show()
         self.Thaw()
         
     def __del__(self):

Index: osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Events/parcel.xml
diff -u osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Events/parcel.xml:1.21 osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Events/parcel.xml:1.22
--- osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Events/parcel.xml:1.21	Wed May  5 13:34:45 2004
+++ osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Events/parcel.xml	Sat May  8 17:19:18 2004
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
 
-<!-- $Revision: 1.21 $ -->
-<!-- $Date: 2004/05/05 20:34:45 $ -->
+<!-- $Revision: 1.22 $ -->
+<!-- $Date: 2004/05/09 00:19:18 $ -->
 <!-- Copyright (c) 2003 Open Source Applications Foundation -->
 <!-- License: http://osafoundation.org/Chandler_0.1_license_terms.htm -->
 
@@ -25,7 +25,6 @@
     <blockEvents itemref="events:Copy"/>
     <blockEvents itemref="events:Paste"/>
     <blockEvents itemref="events:Preferences"/>
-    <blockEvents itemref="events:ViewSideBar"/>
     <blockEvents itemref="events:ViewNavigationBar"/>
     <blockEvents itemref="events:ViewBookmarksBar"/>
     <blockEvents itemref="events:ViewStatusBar"/>    
@@ -82,11 +81,6 @@
   <BlockEvent itemName="Preferences">
     <dispatchEnum>ActiveViewBubbleUp</dispatchEnum>
     <methodName>OnPreferencesEvent</methodName>
-  </BlockEvent>
-
-  <BlockEvent itemName="ViewSideBar">
-    <dispatchEnum>Broadcast</dispatchEnum>
-    <methodName>OnViewSideBarEvent</methodName>
   </BlockEvent>
 
   <BlockEvent itemName="ViewNavigationBar">

Index: osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Block.py
diff -u osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Block.py:1.23 osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Block.py:1.24
--- osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Block.py:1.23	Tue May  4 16:40:01 2004
+++ osaf/chandler/Chandler/parcels/OSAF/framework/blocks/Block.py	Sat May  8 17:19:19 2004
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.23 $"
-__date__ = "$Date: 2004/05/04 23:40:01 $"
+__version__ = "$Revision: 1.24 $"
+__date__ = "$Date: 2004/05/09 00:19:19 $"
 __copyright__ = "Copyright (c) 2003 Open Source Applications Foundation"
 __license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -100,6 +100,14 @@
             if hasattr(theWindow, "scheduleUpdate"):
                 theWindow.scheduleUpdate = True
 
+    def OnShowHide(self, notification):
+        self.open = not self.open
+        self.parentBlock.SynchronizeFramework()
+
+
+    def OnShowHideUpdateUI(self, notification):
+        notification.data['Check'] = self.open
+
 
     def SynchronizeFramework (self):
         """
@@ -111,7 +119,7 @@
         synchronizeFramework, changes to the wx counterpart cause these handlers to be
         called, and in this case we don't want to post a notification. So we wrap calls
         to synchronizeFramework and set a flag indicating that we're inside
-        synchronizeFramework so the handler's can tell when not to post selection
+        synchronizeFramework so the handlers can tell when not to post selection
         changed events. We use this flag in other similar situations, for example,
         during shutdown to ignore events caused by the framework tearing down wx
         counterparts.

Index: osaf/chandler/Chandler/parcels/OSAF/views/main/parcel.xml
diff -u osaf/chandler/Chandler/parcels/OSAF/views/main/parcel.xml:1.33 osaf/chandler/Chandler/parcels/OSAF/views/main/parcel.xml:1.34
--- osaf/chandler/Chandler/parcels/OSAF/views/main/parcel.xml:1.33	Thu May  6 10:47:17 2004
+++ osaf/chandler/Chandler/parcels/OSAF/views/main/parcel.xml	Sat May  8 17:19:14 2004
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
 
-<!-- $Revision: 1.33 $ -->
-<!-- $Date: 2004/05/06 17:47:17 $ -->
+<!-- $Revision: 1.34 $ -->
+<!-- $Date: 2004/05/09 00:19:14 $ -->
 <!-- Copyright (c) 2003 Open Source Applications Foundation -->
 <!-- License: http://osafoundation.org/Chandler_0.1_license_terms.htm -->
 
@@ -39,6 +39,12 @@
     Events
   -->
 
+  <BlockEvent itemName="ShowHideSidebar">
+    <dispatchEnum>SendToBlock</dispatchEnum>
+    <methodName>OnShowHide</methodName>
+    <dispatchToBlock itemref="doc:Sidebar"/>
+  </BlockEvent>
+
   <!--
     Menus
   -->
@@ -148,7 +154,7 @@
     <title>View Sidebar</title>
     <menuLocation>ViewMenu</menuLocation>
     <menuItemKind>Check</menuItemKind>
-    <event itemref="events:ViewSideBar"/>
+    <event itemref="doc:ShowHideSidebar"/>
   </MenuItem>
 
   <MenuItem itemName="ViewNavigationBarItem">
@@ -452,9 +458,7 @@
     <border>3.0, 3.0, 3.0, 3.0</border>
   </TabbedContainer>  
 
-  <Tree itemName="Sidebar"
-        itemClass="OSAF.views.main.SideBar.SideBar">
-
+  <Tree itemName="Sidebar">
     <!-- Attributes -->
     <elementDelegate>OSAF.views.main.SideBar.SideBarDelegate</elementDelegate>
     <selection itemref="doc:AboutChandler"/>
@@ -564,6 +568,9 @@
     <!-- Layout children -->
     <childrenBlocks itemref="doc:BookmarksContainer"/>
     
+    <!-- Block Events -->
+    <blockEvents itemref="doc:ShowHideSidebar"/>
+
     <!-- Attributes -->
     <orientationEnum>Vertical</orientationEnum>
 

Index: osaf/chandler/Chandler/parcels/OSAF/views/main/SideBar.py
diff -u osaf/chandler/Chandler/parcels/OSAF/views/main/SideBar.py:1.6 osaf/chandler/Chandler/parcels/OSAF/views/main/SideBar.py:1.7
--- osaf/chandler/Chandler/parcels/OSAF/views/main/SideBar.py:1.6	Thu Apr 15 15:55:47 2004
+++ osaf/chandler/Chandler/parcels/OSAF/views/main/SideBar.py	Sat May  8 17:19:14 2004
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.6 $"
-__date__ = "$Date: 2004/04/15 22:55:47 $"
+__version__ = "$Revision: 1.7 $"
+__date__ = "$Date: 2004/05/09 00:19:14 $"
 __copyright__ = "Copyright (c) 2003 Open Source Applications Foundation"
 __license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -7,30 +7,6 @@
 import OSAF.framework.blocks.ControlBlocks as ControlBlocks
 
         
-class SideBar(ControlBlocks.Tree):
-    def renderOneBlock(self, parent, parentWindow):
-        returnArguments = ControlBlocks.Tree.renderOneBlock(self, parent, parentWindow)
-        self.showOrHideSideBar(returnArguments[0])
-        return returnArguments
-    
-    def OnViewSideBarEvent(self, notification):
-        self.open = not self.open
-        self.showOrHideSideBar(Globals.association[self.itsUUID])
-
-    def showOrHideSideBar(self, sidebar):
-        if sidebar.IsShown() != self.open:
-            sidebar.Show(self.open)
-            parentWindow = Globals.association[self.parentBlock.itsUUID]
-            if self.open:
-                self.parentBlock.addToContainer(parentWindow, sidebar, None, None, None)
-            else:
-                self.parentBlock.removeFromContainer(parentWindow, sidebar, False)
-            self.parentBlock.handleChildren(parentWindow)
-            
-    def OnViewSideBarEventUpdateUI(self, notification):
-        notification.data['Check'] = self.open
-
-
 class SideBarDelegate:
     def ElementParent(self, element):
         return element.parent



More information about the Commits mailing list