[Commits] (alecf) fix the rest of bug 2579 - properly shrink overlapping calendar canvasitems so that they continue to be clickable..

commits at osafoundation.org commits at osafoundation.org
Wed Apr 13 13:52:57 PDT 2005


Commit by: alecf
Modified files:
chandler/parcels/osaf/framework/blocks/calendar/CalendarCanvas.py 1.61 1.62

Log message:
fix the rest of bug 2579 - properly shrink overlapping calendar canvasitems so that they continue to be clickable..

Bugzilla links:
http://bugzilla.osafoundation.org/show_bug.cgi?id=2579

ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/blocks/calendar/CalendarCanvas.py.diff?r1=text&tr1=1.61&r2=text&tr2=1.62

Index: chandler/parcels/osaf/framework/blocks/calendar/CalendarCanvas.py
diff -u chandler/parcels/osaf/framework/blocks/calendar/CalendarCanvas.py:1.61 chandler/parcels/osaf/framework/blocks/calendar/CalendarCanvas.py:1.62
--- chandler/parcels/osaf/framework/blocks/calendar/CalendarCanvas.py:1.61	Tue Apr 12 14:47:28 2005
+++ chandler/parcels/osaf/framework/blocks/calendar/CalendarCanvas.py	Wed Apr 13 13:52:56 2005
@@ -1,8 +1,8 @@
 """ Canvas for calendaring blocks
 """
 
-__version__ = "$Revision: 1.61 $"
-__date__ = "$Date: 2005/04/12 21:47:28 $"
+__version__ = "$Revision: 1.62 $"
+__date__ = "$Date: 2005/04/13 20:52:56 $"
 __copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
 __license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -27,6 +27,7 @@
     def __init__(self, *args, **keywords):
         super(CalendarCanvasItem, self).__init__(*args, **keywords)
         self._parentConflicts = []
+        self._childConflicts = []
         # the rating of conflicts - i.e. how far to indent this
         self._conflictDepth = 0
                 
@@ -114,6 +115,7 @@
         # we might want to keep track of the inverse conflict as well,
         # for conflict bars
         child._parentConflicts.append(self)
+        self._childConflicts.append(child)
         
     def FindFirstGapInSequence(self, seq):
         """
@@ -148,6 +150,14 @@
         # maximum indent level of all children + 1
         return self._conflictDepth
         
+    def GetMaxDepth(self):
+        maxparents = maxchildren = 0
+        if self._childConflicts:
+            maxchildren = max([child.GetIndentLevel() for child in self._childConflicts])
+        if self._parentConflicts:
+            maxparents = max([parent.GetIndentLevel() for parent in self._parentConflicts])
+        return max(self.GetIndentLevel(), maxchildren, maxparents)
+        
 
 class ColumnarCanvasItem(CalendarCanvasItem):
     resizeBufferSize = 5
@@ -165,9 +175,10 @@
     def UpdateDrawingRects(self):
         item = self.GetItem()
         indent = self.GetIndentLevel() * 5
+        width = self.GetMaxDepth() * 5
         self._boundsRects = list(self.GenerateBoundsRects(self._calendarCanvas,
                                                           item.startTime,
-                                                          item.endTime, indent))
+                                                          item.endTime, indent, width))
         self._bounds = self._boundsRects[0]
 
         r = self._boundsRects[-1]
@@ -229,7 +240,7 @@
         if hasattr(self, '_forceResizeMode'):
             del self._forceResizeMode
     
-    def GenerateBoundsRects(calendarCanvas, startTime, endTime, indent):
+    def GenerateBoundsRects(calendarCanvas, startTime, endTime, indent=0, width=0):
         """
         Generate a bounds rectangle for each day period. For example, an event
         that goes from noon monday to noon wednesday would have three bounds rectangles:
@@ -253,7 +264,7 @@
             
             rect = ColumnarCanvasItem.MakeRectForRange(calendarCanvas, boundsStartTime, boundsEndTime)
             rect.x += indent
-            rect.width -= indent
+            rect.width -= width
             try:
                 yield rect
             except ValueError:
@@ -1120,8 +1131,7 @@
             rects = \
                 ColumnarCanvasItem.GenerateBoundsRects(self,
                                                        self._bgSelectionStartTime,
-                                                       self._bgSelectionEndTime, 
-                                                       0)
+                                                       self._bgSelectionEndTime)
             for rect in rects:
                 dc.DrawRectangleRect(rect)
 



More information about the Commits mailing list