[Commits] (jed) Added ability to manually set layout selectors.

commits at osafoundation.org commits at osafoundation.org
Thu Aug 19 16:09:44 PDT 2004


Commit by: jed
Modified files:
chandler/parcels/osaf/framework/blocks/ContainerBlocks.py 1.125 1.126

Log message:
Added ability to manually set layout selectors.

ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/blocks/ContainerBlocks.py.diff?r1=text&tr1=1.125&r2=text&tr2=1.126

Index: chandler/parcels/osaf/framework/blocks/ContainerBlocks.py
diff -u chandler/parcels/osaf/framework/blocks/ContainerBlocks.py:1.125 chandler/parcels/osaf/framework/blocks/ContainerBlocks.py:1.126
--- chandler/parcels/osaf/framework/blocks/ContainerBlocks.py:1.125	Thu Aug 19 11:06:24 2004
+++ chandler/parcels/osaf/framework/blocks/ContainerBlocks.py	Thu Aug 19 16:09:43 2004
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.125 $"
-__date__ = "$Date: 2004/08/19 18:06:24 $"
+__version__ = "$Revision: 1.126 $"
+__date__ = "$Date: 2004/08/19 23:09:43 $"
 __copyright__ = "Copyright (c) 2003 Open Source Applications Foundation"
 __license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -79,6 +79,20 @@
                       wxRectangularChild.CalculateWXBorder(choice))
             self.Layout()    
 
+    def setSelectedChoice(self, selectedIndex):
+        index = 0
+        for childBlock in self.blockItem.childrenBlocks:
+            if isinstance(childBlock, Toolbar):
+                for toolbarItem in childBlock.widget.toolItemList:
+                    toolbarItemId = toolbarItem.widget.GetId()
+                    if index == selectedIndex:
+                        if not childBlock.widget.GetToolState(toolbarItemId):                                
+                            childBlock.widget.ToggleTool(toolbarItemId, True)                            
+                    else:
+                        if childBlock.widget.GetToolState(toolbarItemId):
+                            childBlock.widget.ToggleTool(toolbarItemId, False)
+                    index += 1
+                                        
     def _getSelectedChoice(self):
         index = 0
         for childBlock in self.blockItem.childrenBlocks:
@@ -91,6 +105,16 @@
         # This is a bug in wxWidgets that should be fixed.
         return 0
             
+    def getIdPos(self, id):
+        index = 0
+        for childBlock in self.blockItem.childrenBlocks:
+            if isinstance(childBlock, Toolbar):
+                for toolbarItem in childBlock.widget.toolItemList:
+                    if id == toolbarItem.widget.GetId():
+                        return index
+                    index += 1
+        return -1
+    
 
 class ChoiceContainer(BoxContainer):
     def instantiateWidget (self):
@@ -108,26 +132,20 @@
 
         return widget
 
+    def changeSelection(self, selectionIndex):
+        self.widget.setSelectedChoice(selectionIndex)
+        self.synchronizeWidget()
+
     def onSelectionChanged(self, notification):
         # @@@ On the Mac, radio buttons do not work as radio
         # buttons, but rather they behave as individual toggle
         # buttons.  As a workaround, we deselect the other 
         # radio buttons.
         if '__WXMAC__' in wx.PlatformInfo:
-            for childBlock in self.childrenBlocks:
-                if isinstance(childBlock, Toolbar):
-                    for toolbarItem in childBlock.widget.toolItemList:
-                        if toolbarItem != notification.data['sender']:
-                            if childBlock.widget.GetToolState(toolbarItem.widget.GetId()):
-                                childBlock.widget.ToggleTool(toolbarItem.widget.GetId(), False)
-                        else:
-                            if not childBlock.widget.GetToolState(toolbarItem.widget.GetId()):                                
-                                childBlock.widget.ToggleTool(toolbarItem.widget.GetId(), True)                            
-        try:
-            self.widget.wxSynchronizeWidget()    
-        except AttributeError:
-            pass
-
+            itemId = notification.data['sender'].widget.GetId()
+            pos = self.widget.getIdPost(itemId)
+            self.widget.SetSelectedChoice(pos)
+        self.synchronizeWidget()
 
 class EmbeddedContainer(RectangularChild):
     def instantiateWidget (self):



More information about the Commits mailing list