Differences between revisions 1 and 2
Revision 1 as of 2002-04-20 06:47:35
Size: 1635
Editor: anonymous
Comment: missing edit-log entry for this revision
Revision 2 as of 2002-04-20 06:49:49
Size: 1668
Editor: anonymous
Comment: missing edit-log entry for this revision
Deletions are marked like this. Additions are marked like this.
Line 12: Line 12:

Back to the ["wxGrid Manual"]

wxGridCellRenderer

The cell renderer allows you to customize the display of a particular data type within the grid. For instance, it allows you to display a "colour" data type as a swatch of colour, rather than as a mere plain-text label. The class has a very simple API, using a standard wxDC for drawing into the cell's rectangle. A secondary function of the renderer is the determination of the "best size" for the cell.

  • void Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rect, int row, int col, bool isSelected) -- Draw the given cell on the provided DC inside the given rectangle using the style specified by the attribute and the default or selected state corresponding to the isSelected value. Keep in mind that this method will be called once for every instance of the data type, which may result in hundreds of calls for every display update of the grid. Care should be taken to make this a very fast method.

    • This pure virtual function has a default implementation which will prepare the DC using the given attribute: it will draw the rectangle with the background colour from attr and set the text colour and font.
  • wxSize GetBestSize(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, int row, int col) -- Get the preferred size of the cell for its contents. Note: this size determines both the viewing and editing size of the cell, so care should be taken to allow enough space for the editing controls for the data type.

  • Clone() -- Create a duplicate renderer, normally you can use return self.__class__() as seen for the cell editor.

Back to the ["wxGrid Manual"]

wxPyGridCellRenderer (last edited 2008-03-11 10:50:18 by localhost)

NOTE: To edit pages in this wiki you must be a member of the TrustedEditorsGroup.