def DrawText(self, grid, dc, rect, text, hAlign, vAlign): """ Draw the label's text in the rectangle, using the alignment flags, and the grid's specified label font and color. """ dc.SetBackgroundMode(wx.TRANSPARENT) dc.SetTextForeground(grid.GetDefaultCellTextColour()) dc.SetFont(grid.GetLabelFont()) rect = wx.Rect(*rect) rect.Deflate(2, 2) grid.DrawTextRectangle(dc, text, rect, hAlign, vAlign)
def Draw(self, grid, attr, dc, rect, row, col, _isSelected): text = grid.GetCellValue(row, col) hAlign, vAlign = attr.GetAlignment() bg = wx.WHITE dc.SetTextBackground(bg) dc.SetTextForeground(attr.GetTextColour()) font = attr.GetFont() font.SetPointSize(font.GetPointSize() + 3) dc.SetFont(font) dc.SetBrush(wx.Brush(bg, wx.SOLID)) dc.SetPen(wx.TRANSPARENT_PEN) dc.DrawRectangleRect(rect) grid.DrawTextRectangle(dc, len(text) * '\N{BULLET}', rect, hAlign, vAlign)
def Draw(self, grid, attr, dc, rect, row, col, isSelected): text = grid.GetCellValue(row, col) hAlign, vAlign = attr.GetAlignment() dc.SetFont(attr.GetFont()) if isSelected: bg = grid.GetSelectionBackground() fg = grid.GetSelectionForeground() else: bg = random.choice(["pink", "sky blue", "cyan", "yellow", "plum"]) fg = attr.GetTextColour() dc.SetTextBackground(bg) dc.SetTextForeground(fg) dc.SetBrush(wx.Brush(bg, wx.SOLID)) dc.SetPen(wx.TRANSPARENT_PEN) dc.DrawRectangleRect(rect) grid.DrawTextRectangle(dc, text, rect, hAlign, vAlign)
def Draw(self, grid, attr, dc, rect, row, col, isSelected): text = grid.GetCellValue(row, col) dc.SetFont(attr.GetFont()) suggest_width = grid.GetColSize(col) text = self._wordwrap(text, suggest_width, dc, breakLongWords=False) hAlign, vAlign = attr.GetAlignment() if isSelected: bg = grid.GetSelectionBackground() fg = grid.GetSelectionForeground() else: bg = attr.GetBackgroundColour() fg = attr.GetTextColour() dc.SetTextBackground(bg) dc.SetTextForeground(fg) dc.SetBrush(wx.Brush(bg, wx.SOLID)) dc.SetPen(wx.TRANSPARENT_PEN) dc.DrawRectangle(rect) grid.DrawTextRectangle(dc, text, rect, hAlign, vAlign)
def Draw(self, grid, attr, dc, rect, row, col, isSelected): text = grid.GetCellValue(row, col) prog = 0 try: prog = float(ProgressCellRenderer.re_percent.search(text).group(1)) except: pass if prog > 100: prog = 100 total_width = rect.width units = int(float(prog / 100.0) * rect.width) prog_rect = wx.Rect(rect.x, rect.y, units, rect.height) other_rect = wx.Rect(rect.x + units, rect.y, rect.width - prog_rect.width, rect.height) hAlign, vAlign = attr.GetAlignment() dc.SetFont(attr.GetFont()) if isSelected: bg = grid.GetSelectionBackground() else: bg = wx.Colour(255, 255, 255) dc.SetBrush(wx.Brush(self.progColor, wx.SOLID)) #dc.SetPen(wx.BLACK_PEN) dc.DrawRectangleRect(prog_rect) # This fills in the rest of the cell background so it doesn't shear dc.SetBrush(wx.Brush(bg, wx.SOLID)) dc.SetPen(wx.TRANSPARENT_PEN) dc.DrawRectangleRect(other_rect) dc.SetTextForeground(wx.Colour(0, 0, 0)) grid.DrawTextRectangle(dc, text, rect, hAlign, vAlign)