Generic FunctionPackage: cgToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 8.2
Unrevised from 8.1 to 8.2.
8.1 version


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. The default mthod calls cell-horizontal-padding, cell-vertical-padding, cell-horizontal-justification, cell-vertical-justification, cell-wrapped-p, data-read-converter, draw-string-in-box, inflate-box, and read-cell-value.

(defmethod draw-cell ((row grid-row)(column grid-column)
                      row-num column-num cell-box stream)
  (let* ((converter (or (data-read-converter column) #'identity))
         (value (funcall converter
                          row column row-num column-num))))
    (when value
       stream (princ-to-string value) nil nil
       (inflate-box cell-box
                    (- (cell-horizontal-padding row column))
                    (- (cell-vertical-padding row column)))
       (cell-horizontal-justification row column)
       (cell-vertical-justification row column)
       nil (cell-wrapped-p 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.

Even if you are not using the built-in cell widgets such as those provided by editable-text-column-mixin or combo-box-column-mixin, you still likely won't need to write custom draw-cell methods for cells that simply display a string for the value you are returning from a read-cell-value method. And if you need to modify the way in which the default draw-cell method draws the string, you can alternately do that by writing methods on generic functions such as cell-background-color, cell-font, and cell-vertical-padding.

Before Common Graphics calls draw-cell, it will first set the current font of the stream to be the font that's returned by cell-font. It will also set the current foreground-color and background-color of the stream to be the values returned by cell-foreground-color and cell-background-color, and fill the cell with the background color. So a custom draw-cell method does not need to handle those aspects of the drawing.

See also draw-cell-focus.

Copyright (c) 1998-2012, Franz Inc. Oakland, CA., USA. All rights reserved.
Documentation for Allegro CL version 8.2. This page was not revised from the 8.1 page.
Created 2010.1.21.

Allegro CL version 8.2
Unrevised from 8.1 to 8.2.
8.1 version