def makeBitmap(self, gc, text): width, height = gc.GetTextExtent(text) bitmap = wx.EmptyBitmap(width + 2*WEEKDAY_PADDING, height) mdc = wx.MemoryDC(bitmap) mdc.SetBackground(wx.BLACK_BRUSH) mdc.Clear() mdc.DrawText(text, 0, 0) return bitmap def DrawBackground(self, gc): if self.weekdayBitmaps is None: names = dateFormatSymbols.getWeekdays() gc.SetFont(self._font, self._thisMonthColour) # ICU makes this list 1-based, skip the first empty element self.weekdayBitmaps = [self.makeBitmap(gc, n) for n in names[1:]] control = self.multiWeekControl.widget columnPositions = control.columnPositions columnWidths = control.columnWidths firstDay = GregorianCalendarInstance.getFirstDayOfWeek() for day in xrange(7): column = day + 1 dayBitmap = self.weekdayBitmaps[(day + firstDay - 1) % 7] width, height = dayBitmap.GetSize() dy = min(HEADER_HEIGHT - height, 0) if True or columnWidths[column] <= width: dx = columnPositions[column] gc.DrawBitmap(dayBitmap, dx, dy, width, height)