Title: [commits] (jeffrey) [16050] [APP] Add a deeper level of overlap for one cluster, which
Revision
16050
Author
jeffrey
Date
2007-12-05 14:10:55 -0800 (Wed, 05 Dec 2007)

Log Message

[APP] Add a deeper level of overlap for one cluster, which
surfaced the fact that integer arithmetic happens to work at
max_depth 2, but not at higher levels, so make max_depth a float.
- Also, bind selection between all-day and timed canvas

Modified Paths

Diff

Modified: branches/rearchitecture/Chandler-Platform/ocap/wxui/calendar_canvas.py (16049 => 16050)

--- branches/rearchitecture/Chandler-Platform/ocap/wxui/calendar_canvas.py	2007-12-05 21:43:50 UTC (rev 16049)
+++ branches/rearchitecture/Chandler-Platform/ocap/wxui/calendar_canvas.py	2007-12-05 22:10:55 UTC (rev 16050)
@@ -233,7 +233,7 @@
         self.Bind(wx.EVT_SIZE,  self.OnSize)
         self.Bind(wx.EVT_ERASE_BACKGROUND, lambda x: None)
         self.Bind(wx.EVT_LEFT_DOWN, self.OnClick)
-        self.Bind(EVT_SELECT_ITEMS, self.SelectItems)
+        self.Bind(EVT_SELECT_ITEMS, self.OnSelectItems)
 
         self.events = {}
         self.selected_ids = []
@@ -357,6 +357,7 @@
         rect = wx.Rect2D(x, y, width, BASE_HOUR_HEIGHT*hours)
 
         if max_depth > 1:
+            max_depth = float(max_depth)
             if self.range_mode == 'day':
                 rect.Inset(depth*width/max_depth, 0, 0, 0)
                 rect.width = width/max_depth
@@ -565,19 +566,22 @@
     def end(self):
         return self.start + self.duration
 
-    def SelectItems(self, evt):
-        local = set(id for id in  evt.selected_ids if id in self.events)
-        old   = set(id for id in self.selected_ids if id in self.events)
-        self.selected_ids = evt.selected_ids
+    def OnSelectItems(self, evt):
+        self.UpdateSelection(evt.selected_ids)
+
+    def UpdateSelection(self, selected_ids):
+        new_local = set(id for id in selected_ids      if id in self.events)
+        old_local = set(id for id in self.selected_ids if id in self.events)
+        self.selected_ids = selected_ids
         
-        if local != old:
-            local_selected_events = set(self.events[id] for id in local)
-            if local:
+        if new_local != old_local:
+            selected_events = set(self.events[id] for id in new_local)
+            if new_local:
                 for interval in self.intervals:
-                    if local_selected_events.intersection(interval.event_list):
+                    if selected_events.intersection(interval.event_list):
                         for cluster in interval.clusters:
                             for event in cluster.event_list:
-                                if event.id in local:
+                                if event.id in new_local:
                                     cluster.front_event = event
                                     break
             self.Refresh(False)
@@ -737,6 +741,9 @@
         self.calendar = Calendar(parent=splitter, time_formatter=None)
         self.allday = AllDayCalendar(parent=splitter, time_formatter=None)
 
+        self.calendar.Bind(EVT_SELECT_ITEMS, self.OnSelectItems)
+        self.allday.Bind(EVT_SELECT_ITEMS, self.OnSelectItems)
+
         splitter.SplitHorizontally(self.allday, self.calendar)
         splitter.SetMinimumPaneSize(20)
         splitter.SashPosition = 20
@@ -889,6 +896,14 @@
 
         self.weekColumnHeader.Thaw()
 
+    def OnSelectItems(self, evt):
+        self.UpdateSelection(evt.selected_ids)
+        wx.PostEvent(self, evt)
+        
+    def UpdateSelection(self, selected_ids):
+        self.calendar.UpdateSelection(selected_ids)
+        self.allday.UpdateSelection(selected_ids)
+
     def OnSize(self, event):
         self.ResizeColumnHeader()
         event.Skip()
@@ -1046,6 +1061,12 @@
     calendar.ChangeEvent(id="foo3", title=lorem,
                          start=datetime(2007,11,27,16), 
                          duration=timedelta(hours=3))
+    calendar.ChangeEvent(id="foo3.1", title=lorem,
+                         start=datetime(2007,11,27,16,30), 
+                         duration=timedelta(hours=3))
+    calendar.ChangeEvent(id="foo3.2", title=lorem,
+                         start=datetime(2007,11,27,17), 
+                         duration=timedelta(hours=3))
     calendar.ChangeEvent(id="foo4", title=lorem,
                          start=datetime(2007,11,27,18), 
                          duration=timedelta(hours=3))




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

Reply via email to