def DrawLine(self, gc, x0, y0, x1, y1): return gc.DrawLines([(x0, y0), (x1, y1)]) def DrawPolygon(self, gc, points, offsetx, offsety, rule): points = [(x + offsetx, y + offsety) for x, y in points] return gc.DrawLines(points, rule) # event handlers def OnMiniCalPaint(self, event): size = self.GetClientSize() width = size.x height = size.y gc = wx.GraphicsContext.Create(wx.PaintDC(self)) font = self.GetDeviceFont() boldFont = wx.Font(font.GetPointSize(), font.GetFamily(), font.GetStyle(), wx.BOLD, font.GetUnderlined(), font.GetFaceName(), font.GetEncoding()) y = 0 # draw the sequential month-selector gc.SetBrush(wx.TRANSPARENT_BRUSH) gc.SetPen(wx.LIGHT_GREY_PEN) if self.lineAboveToday: self.DrawLine(gc, 0, y, width, y) self.DrawLine(gc, 0, y + self.todayHeight, width, y + self.todayHeight) buttonWidth = width / 5 self.DrawLine(gc, buttonWidth, y, buttonWidth, y + self.todayHeight) self.DrawLine(gc, buttonWidth * 4, y, buttonWidth * 4, y + self.todayHeight) # Get extent of today button todaytext = _(u"Today") (todayw, todayh) = gc.GetTextExtent(todaytext) # Draw today button self.todayRect = wx.Rect(buttonWidth, y, buttonWidth * 4, self.todayHeight) todayx = ((self.widthCol * DAYS_PER_WEEK) - todayw) / 2 todayy = ((self.todayHeight - todayh) / 2) + y gc.SetFont(gc.CreateFont(boldFont, wx.BLACK)) gc.DrawText(todaytext, todayx, todayy, gc.CreateBrush(wx.TRANSPARENT_BRUSH)) # calculate the "month-arrows" arrowheight = todayh - 5 leftarrow = [(0, arrowheight / 2), (arrowheight / 2, 0), (arrowheight / 2, arrowheight - 1)] rightarrow = [(0, 0), (arrowheight / 2, arrowheight / 2), (0, arrowheight - 1)] # draw the "month-arrows" arrowy = (self.todayHeight - arrowheight) / 2 + y larrowx = (buttonWidth - (arrowheight / 2)) / 2 rarrowx = (buttonWidth / 2) + buttonWidth * 4 # Draw left arrow self.leftArrowRect = wx.Rect(0, y, buttonWidth - 1, self.todayHeight) gc.SetBrush(gc.CreateBrush(wx.BLACK_BRUSH)) gc.SetPen(gc.CreatePen(wx.BLACK_PEN)) self.DrawPolygon(gc, leftarrow, larrowx , arrowy, wx.WINDING_RULE) # Draw right arrow self.rightArrowRect = wx.Rect(buttonWidth * 4 + 1, y, buttonWidth - 1, self.todayHeight) gc.SetBrush(wx.BLACK_BRUSH) gc.SetPen(wx.BLACK_PEN) self.DrawPolygon(gc, rightarrow, rarrowx , arrowy, wx.WINDING_RULE) y += self.todayHeight dateToDraw = self.firstVisibleDate for i in xrange(MONTHS_TO_DISPLAY): y = self.DrawMonth(gc, dateToDraw, y, True, font, boldFont, width, height) dateToDraw = MonthDelta(dateToDraw, 1)