def paintDateCell(self, date, startX, startY, dc): # Choose cell background color bgCol = self.getBgColorForCount(self.getWordCountForDay(date)) brush = wx.Brush(bgCol) dc.SetBrush(brush) if self._isDarkColour(bgCol): dc.SetTextForeground(wx.WHITE) else: dc.SetTextForeground(wx.BLACK) resetPen = False # If this cell is selected, draw it differently if self.selectedDay == date and wx.Window.FindFocus() is self: dc.SetPen(wx.RED_PEN) resetPen = True dc.DrawRectangle(startX, startY, self.cellWidth, self.cellHeight) if resetPen: dc.SetPen(wx.TRANSPARENT_PEN) resetFont = False if self.today == date: dc.SetFont(self.boldFont) resetFont = True drawTextRight(dc, u"%i" % date.GetDay(), startX, startY, self.cellWidth) if resetFont: dc.SetFont(self.stdFont) dc.SetBrush(wx.NullBrush)
def paintMonth(self, startX, startY, month, dc): """ Paint the month on the device context dc """ cellShiftX = self.cellWidth + self.cellDistHor cellShiftY = self.cellHeight + self.cellDistVert date = month # Write month name yPos = startY dc.SetFont(self.boldFont) # monthName = wx.DateTime.GetMonthName(month[0], wx.DateTime.Name_Abbr) monthName = formatWxDate(u"%b %Y", date) drawTextCenter(dc, monthName, startX, yPos, self.monthWidth) # dc.DrawText(monthName, startX, yPos) # drawTextRight(dc, "%i" % month[1], startX, yPos, self.monthWidth) # Write weekday shortnames dc.SetFont(self.stdFont) yPos += cellShiftY xPos = startX if self.firstWeekDay == self.Sunday_First: wdOrder = range(7) else: wdOrder = range(1, 7) + [0] for i in wdOrder: wd = wx.DateTime.GetWeekDayName(i, wx.DateTime.Name_Abbr) drawTextRight(dc, wd, xPos, yPos, self.cellWidth) xPos += cellShiftX # Actual day grid yPos += cellShiftY dateShift = wx.TimeSpan_Day() dayCount = wx.DateTime.GetNumberOfDaysInMonth(month.GetMonth(), month.GetYear()) wdCol = self.getColForWeekDay(date.GetWeekDay()) xPos = startX + wdCol * cellShiftX for d in xrange(dayCount): self.paintDateCell(date, xPos, yPos, dc) # dc.DrawText("%i" % d, ) date = date + dateShift xPos += cellShiftX wdCol += 1 if wdCol > 6: # New row wdCol = 0 xPos = startX yPos += cellShiftY