def Draw ( self, grid, attr, dc, rect, row, column, is_selected ): """ Renders the specified grid cell using the specified drawing information. """ # Create a cell adapter, then ask the editor to paint the cell contents: editor = self._editor # Draw the 'missing' leftmost cell border (if necessary): x = rect.x if (x == 0) and (editor.grid_line_color is not None): rect.x = x + 1 rect.width -= 1 dc.SetPen( wx.Pen( editor.grid_line_color ) ) dc.DrawLine( x, rect.y, x, rect.y + rect.height ) # Draw the contents of the cell: cell_adapter.init( set_standard_font( dc ), rect, editor.grid_adapter, editor.data_row_for( row ), editor.data_column_for( column ), row, is_selected, '' ) editor.paint_cell( cell_adapter ) # Reset the clipping region set by the editor; otherwise the wx.Grid # will not be able to do later updates correctly: dc.DestroyClippingRegion()
def draw_column_labels ( self, dc, columns, height ): """ Draws the set of column labels specified by *columns* using the device context specified by *dc*. """ # Draw the contents of the column labels: grid = self.control adapter = self.grid_adapter dcf = self.data_column_for ctr = grid.ColToRect cell_adapter = WxCell() for column in columns: # Get the bounds of the current column: rect = ctr( column ) rect.height = height # Draw the label border (if necessary): if self.grid_line_color is not None: dc.SetPen( wx.Pen( self.grid_line_color ) ) dc.SetBrush( wx.TRANSPARENT_BRUSH ) x = rect.x width = rect.width + 1 if x != 0: x -= 1 width += 1 else: rect.x = 1 rect.width -= 1 dc.DrawRectangle( x, rect.y, width, height ) rect.y += 1 rect.height -= 2 # Determine any extra text to be added to the label if the current # column is also the current sort column: extra = '' if column == self.grid_sort_column: extra = SortOrder[ self.sort_normal + (2 * is_win32) ] # Set up the cell adapter and draw the current label: cell_adapter.init( set_standard_font( dc ), rect, adapter, -1, dcf( column ), -1, False, extra ) self.paint_cell( cell_adapter ) # Reset the clipping region set by the editor; otherwise subsequent # updates will not work correctly: dc.DestroyClippingRegion()