Title: [commits] (grant) [15956] [APP] Minor sidebar cleanup
Revision
15956
Author
grant
Date
2007-11-29 08:30:48 -0800 (Thu, 29 Nov 2007)

Log Message

[APP] Minor sidebar cleanup
- Remove some duplicate code
- Enable correct font size
- Fix broken Demo() (missing arg to SidebarPresentation()).

Modified Paths

Diff

Modified: branches/rearchitecture/Chandler-App/ocap/chandler/sidebar.py (15955 => 15956)

--- branches/rearchitecture/Chandler-App/ocap/chandler/sidebar.py	2007-11-29 16:13:58 UTC (rev 15955)
+++ branches/rearchitecture/Chandler-App/ocap/chandler/sidebar.py	2007-11-29 16:30:48 UTC (rev 15956)
@@ -2,6 +2,7 @@
 import wx.grid as grid
 import ocap.wxui.table as table
 import ocap.wxui.drawing as drawing
+import ocap.wxui.styles as styles
 import ocap.chandler.interaction as interaction
 import peak.events.trellis as trellis
 from ocap.wxui.image import get_raw_image
@@ -11,8 +12,8 @@
     def Draw(self, grid, attr, dc, rect, row, col, isSelected):
         drawing.SetTextColorsAndFont(grid, attr, dc, isSelected)
 
-        dc.SetBackgroundMode (wx.SOLID)
-        dc.SetPen (wx.TRANSPARENT_PEN)
+        dc.SetBackgroundMode(wx.SOLID)
+        dc.SetPen(wx.TRANSPARENT_PEN)
 
         dc.DrawRectangleRect(rect)
 
@@ -46,7 +47,7 @@
 
         if image is not None:
             image = wx.BitmapFromImage(image)
-            imageRect = SidebarPresentation.GetRectFromOffsets(rect, [0,21,19])
+            imageRect = table.GetRectFromOffsets(rect, [0,21,19])
             dc.DrawBitmap(image, imageRect.GetLeft(), imageRect.GetTop(), True)
         
     def Clone():
@@ -72,32 +73,12 @@
             ),
         )
         sidebarGrid = table.Table(parent, sidebar, size=parent.Size)
+        sidebarGrid.SetDefaultCellFont(styles.getFont(styles.CharacterStyle(fontSize=12)))
         sidebarGrid.RegisterDataType("SidebarIcon", SidebarIconRenderer(), None)
                                   
         super(SidebarPresentation, self).__init__(parent, sidebar, columns, table=sidebarGrid, filter=filter)
         sidebarGrid.ScaleWidthToFit(True)
     
-    @staticmethod
-    def GetRectFromOffsets(rect, offsets):
-        def GetEdge(rect, offset):
-            if offset >= 0:
-                edge = rect.GetLeft()
-            else:
-                edge = rect.GetRight()
-            return edge + offset
-
-        top = rect.GetTop()
-        height = offsets[2]
-        if height == 0:
-            height = rect.GetHeight()
-        else:
-            top = top + (rect.GetHeight() - height) / 2.0
-        left = GetEdge(rect, offsets[0])
-        return wx.Rect(left,
-                        top,
-                        GetEdge(rect, offsets[1]) - left,
-                        height)
-
     @trellis.optional
     @trellis.rule
     def printStuff(self):
@@ -188,7 +169,7 @@
     frame = wx.Frame(None, title="Sidebar Mockup")
     frame.Size = wx.Size(220, frame.Size.height)
     frame.CenterOnParent()
-    sidebar = SidebarPresentation(frame, iApp.sidebar)
+    sidebar = SidebarPresentation(frame, iApp.sidebar, filter=None)
     frame.Show()
 
     # Make sidebarPresentation and interactionApp variables




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

Reply via email to