Title: [commits] (grant) [15967] Initial (hacky) bridge for the "app" area toolbar items, really for demo
Revision
15967
Author
grant
Date
2007-11-29 11:37:09 -0800 (Thu, 29 Nov 2007)

Log Message

Initial (hacky) bridge for the "app" area toolbar items, really for demo
purposes only.

Modified Paths

Diff

Modified: branches/rearchitecture/Chandler-Debugging/ocap/debugging/py_crust.py (15966 => 15967)

--- branches/rearchitecture/Chandler-Debugging/ocap/debugging/py_crust.py	2007-11-29 19:33:42 UTC (rev 15966)
+++ branches/rearchitecture/Chandler-Debugging/ocap/debugging/py_crust.py	2007-11-29 19:37:09 UTC (rev 15967)
@@ -121,6 +121,47 @@
         # WTH? Expanding with zero proportion is needed to get the top line
         other.Add(self, 0, flag=wx.EXPAND)
 
+
+class ToolbarBridge(trellis.Component):
+    trellis.values(
+        widget = None,
+        cell = None,
+    )
+    #trellis.rules(
+    #    setup = lambda self: self.widget.Bind(wx.EVT_KILL_FOCUS, self.write),
+    #    read = lambda self: self.widget.SetValue(unicode(self.cell)),
+    #)
+    #def write(self, event):
+    #    self.cell = float(self.widget.GetValue())
+    def addAppTool(self, label, imageName, cellValue):
+        from ocap.wxui.image import get_raw_image
+    
+        toolId = wx.NewId()
+        tool = self.widget.AddRadioTool(toolId,
+                    wx.BitmapFromImage(get_raw_image(imageName)),
+                    clientData=cellValue)
+        tool.SetLabel(label)
+        # Eek, without the next two lines, wx doesn't draw
+        # the labels on the unselected tools. Probably we are
+        # not calling tb.Realize() at the right time [grant].
+        self.widget.ToggleTool(toolId, True)
+        self.widget.ToggleTool(toolId, False)
+        self.widget.Bind(wx.EVT_TOOL, self.OnToolEvent, id=toolId)
+        
+    def OnToolEvent(self, event):
+        for tool in self.widget.ToolBarTools:
+            if tool.GetId() == event.GetId():
+                self.cell = tool.ClientData
+        event.Skip()
+
+    @trellis.rule
+    def selectTool(self):
+        value = self.cell
+        for tool in self.widget.ToolBarTools:
+            if tool.ClientData == value:
+                self.widget.ToggleTool(tool.GetId(), True)
+
+
 class PreviewAndMinicalendarSizer(Boxer, trellis.Component):
     widgets = trellis.value(trellis.List())
     
@@ -179,8 +220,16 @@
     )
     tb.SetToolBitmapSize((32,32))
     tb.SetToolSeparation(20)
-    from ocap.wxui.image import get_raw_image
-    tb.AddLabelTool(wx.NewId(), "All", wx.BitmapFromImage(get_raw_image('ApplicationBarAll.png')))
+
+    ia = interaction.Application()
+
+    tbBridge = ToolbarBridge(widget=tb, cell=trellis.Cells(ia)['filter'])
+    tbBridge.addAppTool("All", 'ApplicationBarAll.png', None)
+    tbBridge.addAppTool("Mail", 'ApplicationBarMail.png', 'mail')
+    tbBridge.addAppTool("Tasks", 'ApplicationBarTask.png', 'tasks')
+    tbBridge.addAppTool("Calendar", 'ApplicationBarEvent.png', 'calendar')
+
+    
     splitterStyle = wx.SP_LIVE_UPDATE | wx.NO_BORDER | wx.SP_3DSASH
     main_splitter = ChangeTrackingSplitter(frame, style=splitterStyle)
     child_splitter = BottomTrackingSplitter(main_splitter, style=splitterStyle)
@@ -188,7 +237,9 @@
     main_splitter.SetMinimumPaneSize(50)
     child_splitter.SetMinimumPaneSize(1) 
 
-    ia = interaction.Application()
+    tb.Realize()
+
+
     sb = sidebar.SidebarPresentation(child_splitter, ia.sidebar,
                                      filter=trellis.Cells(ia)['filter'])
 




_______________________________________________
Commits mailing list
[email protected]
http://lists.osafoundation.org/mailman/listinfo/commits

Reply via email to