draw-cell

Generic Function

Package: common-graphics

Arguments: row column row-num column-num cell-box stream

Called for drawing the interior of each individual cell of a grid (see grid-widget class). If not using one of the built-in widget column types, then supply a draw-cell method to draw your custom cell. cell-box is the region within stream that contains the interior of the cell, so you should draw only within that area of stream.

Here is the default method, which is used for any cell not handled either by one of the special built-in grid-column types such as combo-box-column-mixin or by an application-defined draw-cell method. It simply draws the printed representation of the cell's value. Note that it calls read-cell-value to find the value to draw for this particular cell; this is the suggested approach, though the draw-cell method may determine what to draw by whatever means is suitable to the application.

(defmethod draw-cell ((row grid-row) column
                      row-num column-num cell-box stream)
  (declare (ignore row-num column-num))
  (let* ((converter (or (data-read-converter column) #'identity))
         (value (funcall converter
                         (read-cell-value row column)))) 
                                         ;; <7105>
    (when value
      (grid-draw-string stream 
                        (nprin1-to-string value)
                        cell-box
                        (cell-wrapped-p row column)
                        (cell-horizontal-justification 
                                     row column)
                        (cell-vertical-justification 
                                     row column)))))

Common Graphics will call draw-cell any time a grid cell gets partly uncovered or is invalidated (such as by calling invalidate-cell or invalidate-section), so an application need not call it.

A draw-cell method often calls read-cell-value to retrieve the value that should be displayed in the cell. Otherwise it may call the data-reader of the column and/or directly access the data-object of the row to find the value. Those techniques are handy if the grid follows the common paradigm where each grid row represents a data object and each grid column represents an attribute of those objects. Otherwise, a draw-cell method may use a completely custom technique for determining the value to draw, keying in some way off of the names or types of the row and column or the sub-row and sub-column indices.

See also draw-cell-focus.

Common Graphics and IDE documentation is described in About Common Graphics and IDE documentation in cgide.htm.

The documentation is described in introduction.htm and the index is in index.htm.

Copyright (c) 1998-2000, Franz Inc. Berkeley, CA., USA. All rights reserved.

Created 2000.10.5.