- Revision
- 16003
- Author
- jeffrey
- Date
- 2007-11-30 18:41:03 -0800 (Fri, 30 Nov 2007)
Log Message
[APP] Rename wxui.calendar -> wxui.calendar_canvas
- Add a presentation bridge between calendar_canvas and the trellis
- Fix a bug in minicalendar (date_in_range was off by one month)
- Add a presentation bridge between calendar_canvas and the trellis
- Fix a bug in minicalendar (date_in_range was off by one month)
Modified Paths
- branches/rearchitecture/Chandler-App/ocap/chandler/interaction.py
- branches/rearchitecture/Chandler-App/ocap/chandler/minicalendar.py
Added Paths
Diff
Added: branches/rearchitecture/Chandler-App/ocap/chandler/calendar_main.py (16002 => 16003)
--- branches/rearchitecture/Chandler-App/ocap/chandler/calendar_main.py 2007-12-01 02:36:33 UTC (rev 16002) +++ branches/rearchitecture/Chandler-App/ocap/chandler/calendar_main.py 2007-12-01 02:41:03 UTC (rev 16003) @@ -0,0 +1,82 @@ +import wx +import ocap.wxui.calendar_canvas as calendar_canvas +import peak.events.trellis as trellis +from datetime import datetime, time + +class CalendarPresentation(trellis.Component): + id=0 + trellis.values( + widget = None, + many_days = None, + range_start = None, + range_mode = 'week', + ) + + def __init__(self, parent=None, **kw): + trellis.Component.__init__(self, **kw) + if self.widget is None and parent is not None: + self.widget = calendar_canvas.CalendarPanel(parent, name='calendar') + + @trellis.observer + def listen(self): + if self.widget is not None: + self.widget.Bind(calendar_canvas.EVT_SET_RANGE, + self.set_range) + self.widget.Bind(calendar_canvas.EVT_SET_RANGE_MODE, + self.set_range_mode) + + @trellis.observer + def watch_days(self): + if None not in (self.widget, self.many_days): + events = {} + for day in self.many_days.days.itervalues(): + for event in day.events: + id = CalendarPresentation.id + events[id] = calendar_canvas.Event( + id = id, + title = event.title, + start = event.start, + duration = event.duration + ) + CalendarPresentation.id += 1 + # TODO: distinguish between allday and timed events, for now, just + # put everything on the timed canvas + self.widget.calendar.SetEvents(events) + + @trellis.observer + def watch_range(self): + if None not in (self.widget, self.range_start): + start = datetime.combine(self.range_start, time(0)) + self.widget.SetRangeMode(self.range_mode, start, False) + + def set_range(self, event): + self.range_start = event.range_start.date() + + def set_range_mode(self, event): + self.range_start = event.range_start.date() + self.range_mode = event.range_mode + +def Demo(app=None): + import ocap.chandler.interaction as interaction + from datetime import datetime + if app is None: + wxApp = wx.PySimpleApp() + iApp = interaction.Application() + frame = wx.Frame(None, title="Calendar Mockup", size=wx.Size(200, 450)) + frame.CenterOnParent() + calendar = CalendarPresentation(frame, many_days=iApp.all_days) + calendar.widget.SetRange(datetime(2007,11,25)) + frame.Show() + + if app is None: + wxApp.MainLoop() + else: + # Make miniCalendarPresentation and interactionApp variables + # available to PyCrust. + from ocap.debugging import Debugger + debugger = Debugger(app) + debugger.variables['miniCalendarPresentation'] = minicalendar + debugger.variables['interactionApp'] = iApp + +if __name__ == '__main__': + Demo() Property changes on: branches/rearchitecture/Chandler-App/ocap/chandler/calendar_main.py ___________________________________________________________________ Name: svn:eol-style + native
Modified: branches/rearchitecture/Chandler-App/ocap/chandler/interaction.py (16002 => 16003)
--- branches/rearchitecture/Chandler-App/ocap/chandler/interaction.py 2007-12-01 02:36:33 UTC (rev 16002) +++ branches/rearchitecture/Chandler-App/ocap/chandler/interaction.py 2007-12-01 02:41:03 UTC (rev 16003) @@ -87,7 +87,7 @@ class MiniCalendar(trellis.Component): trellis.values( - range_start = None, + visible_range_start = None, months = trellis.Set(), months_displayed = 3, ) @@ -99,7 +99,7 @@ November = domain.Month( month_start = datetime.date(2007, 11, 1), - days=domain._makeDays(2007, 11, xrange(12, 20), (13, 17, 20, 21, 22, 23)) + days=domain._makeDays(2007, 11, xrange(12, 20), (9, 12, 17, 21, 22, 23)) ) class SidebarEntry(trellis.Component): @@ -192,7 +192,8 @@ class Application(trellis.Component): trellis.values( filter = None, # | 'calendar' | 'mail' | 'tasks' - selected_date = None + selected_date = None, + range_mode = 'week' ) @trellis.rule
Modified: branches/rearchitecture/Chandler-App/ocap/chandler/minicalendar.py (16002 => 16003)
--- branches/rearchitecture/Chandler-App/ocap/chandler/minicalendar.py 2007-12-01 02:36:33 UTC (rev 16002) +++ branches/rearchitecture/Chandler-App/ocap/chandler/minicalendar.py 2007-12-01 02:41:03 UTC (rev 16003) @@ -55,7 +55,7 @@ if first is None: return False year, month = first.year, first.month - month += self.months_displayed + 1 + month += self.months_displayed while month > 12: month -= 12 year += 1 @@ -87,15 +87,16 @@ app_cells = trellis.Cells(application) trellis.Component.__init__(self, #months_displayed = cells['months_displayed'], - #firstVisibleDate = cells['range_start'], + #firstVisibleDate = cells['visible_range_start'], busy_months = minicalendar.months, active_view = app_cells['active_view'], filter = app_cells['filter'], selectedDate = app_cells['selected_date'], + range_mode = app_cells['range_mode'], **kw) minicalendar.months_displayed = self.__cells__['months_displayed'] - minicalendar.range_start = self.__cells__['firstVisibleDate'] + minicalendar.visible_range_start = self.__cells__['firstVisibleDate'] # on Linux, because there are no borders around windows, we # want a line separating the minicalendar and preview area, @@ -117,7 +118,7 @@ @trellis.observer def updateRangeMode(self): - """Change the window style when view_displayed changes.""" + """Change the window style when active_view or range_mode changes.""" style = PLATFORM_BORDER if (self.active_view == 'calendar' and self.range_mode == 'week'): style |= minical.CAL_HIGHLIGHT_WEEK
_______________________________________________ Commits mailing list [email protected] http://lists.osafoundation.org/mailman/listinfo/commits
