+ def OnSetFocus(self, event):
+ self.hasFocus = True
+ self.DrawFocusIndicator(True)
+
+ def OnKillFocus(self, event):
+ self.hasFocus = False
+ self.DrawFocusIndicator(False)
+
+ def OnKeyDown(self, event):
+ if not self.hasFocus:
+ event.Skip()
+ return
+
+ key_code = event.GetKeyCode()
+
+ if key_code == wx.WXK_TAB:
+ forward = not event.ShiftDown()
+ ne = wx.NavigationKeyEvent()
+ ne.SetDirection(forward)
+ ne.SetCurrentFocus(self)
+ ne.SetEventObject(self)
+ self.GetParent().GetEventHandler().ProcessEvent(ne)
+ event.Skip()
+ return
+
+ delta = None
+
+ if key_code == wx.WXK_UP:
+ delta = -7
+ elif key_code == wx.WXK_DOWN:
+ delta = 7
+ elif key_code == wx.WXK_LEFT:
+ delta = -1
+ elif key_code == wx.WXK_RIGHT:
+ delta = 1
+ elif key_code == wx.WXK_HOME:
+ curDate = wx.DateTimeFromDMY(int(self.cal_days[self.sel_key]),self.month - 1,self.year)
+ newDate = wx.DateTime_Now()
+ ts = newDate - curDate
+ delta = ts.GetDays()
+
+ if delta <> None:
+ curDate = wx.DateTimeFromDMY(int(self.cal_days[self.sel_key]),self.month - 1,self.year)
+ timeSpan = wx.TimeSpan_Days(delta)
+ newDate = curDate + timeSpan
+
+ if curDate.GetMonth() == newDate.GetMonth():
+ self.set_day = newDate.GetDay()
+ key = self.sel_key + delta
+ self.SelectDay(key)
+ else:
+ self.month = newDate.GetMonth() + 1
+ self.year = newDate.GetYear()
+ self.set_day = newDate.GetDay()
+ self.sel_key = None
+ self.DoDrawing(wx.ClientDC(self))
+
+ event.Skip()
+