def __DrawDia(self, dc, rect, holeOffset, thumbBmp, diaNo, label, selected=False, highlighted=False): font = wx.SystemSettings.GetFont(wx.SYS_ANSI_FIXED_FONT) font.SetPointSize(9) dc.SetFont(font) colour = wx.Colour(235, 235, 235) bmpX = rect.x + self.GAP // 2 bmpY = (rect.height - thumbBmp.GetHeight()) // 2 holeX = rect.x + self.GAP // 2 - (holeOffset % (self.HOLE_WIDTH + self.HOLE_PADDING)) dc.SetClippingRegion(rect.GetX(), rect.GetY(), rect.GetWidth(), rect.GetHeight()) if selected: dc.SetBackground(wx.Brush(wx.Colour(38, 54, 70))) dc.Clear() dc.SetPen(wx.Pen(wx.Colour(237, 156, 0))) dc.SetBrush(wx.Brush(wx.Colour(237, 156, 0))) dc.DrawRectangle(rect.x, 0, rect.right + 1, 3) dc.DrawRectangle(rect.x, rect.bottom - 2, rect.right + 1, rect.bottom) else: dc.SetBackground(wx.BLACK_BRUSH) dc.Clear() dc.SetTextForeground(wx.Colour(237, 156, 0)) dc.SetBrush(wx.Brush(colour)) dc.SetPen(wx.Pen(colour)) diaNoWidth, textHeight = dc.GetTextExtent(diaNo) label, labelWidth = ChopText(dc, label, thumbBmp.GetWidth()) dc.DrawBitmap(thumbBmp, bmpX, bmpY, True) dc.DrawText(diaNo, rect.x + (rect.width - diaNoWidth) // 2, self.LABEL_MARGIN - 3) dc.DrawText(label, rect.x + (rect.width - labelWidth) // 2, rect.height - self.LABEL_MARGIN - textHeight) while holeX <= rect.right + 1: dc.DrawRoundedRectangle(holeX, self.BORDER - self.HOLE_MARGIN - self.HOLE_HEIGHT, self.HOLE_WIDTH, self.HOLE_HEIGHT, 2) dc.DrawRoundedRectangle(holeX, self.BORDER + self.THUMB_HEIGHT + self.HOLE_MARGIN, self.HOLE_WIDTH, self.HOLE_HEIGHT, 2) holeX += self.HOLE_WIDTH + self.HOLE_PADDING if highlighted: dc.SetPen(wx.TRANSPARENT_PEN) dc.SetBrush(wx.Brush(wx.Colour(77, 136, 196, 80))) dc.DrawRectangle(rect) dc.DestroyClippingRegion()
def OnPaint(self, event): # pylint: disable=unused-argument dc = wx.AutoBufferedPaintDC(self) dc.SetBackground(wx.Brush(self.GetParent().GetBackgroundColour())) sz = self.GetSize() dc.Clear() if self.mouseOver: dc.DrawBitmap(self.bmpDiaSelected, 0, 0) else: dc.DrawBitmap(self.bmpDia, 0, 0) thumbSz = self.bmpThumb.GetSize() thumbRect = wx.Rect(sz[0] // 2 - thumbSz[0] // 2, sz[1] // 2 - thumbSz[1] // 2 - 15, thumbSz[0], thumbSz[1]) dc.DrawBitmap(self.bmpThumb, thumbRect.GetTopLeft()) thumbRect.Inflate(1, 1) dc.SetBrush(wx.TRANSPARENT_BRUSH) dc.DrawRectangle(thumbRect) label, width = ChopText(dc, self.label, 138) dc.DrawText(label, sz[0] // 2 - width // 2, 97)