Next Prev Up Top Contents Index

17.1.1 Conceptual Overview of Formatting Tables

CLIM makes it easy to construct tabular output. The usual way of making tables is by indicating what you want to put in the table and letting CLIM choose the placement of the row and column cells. CLIM also allows you to specify constraints on the placement of the table elements with some flexibility.

In the CLIM model of formatting tables, each cell of the table is handled separately:

The code for a cell draws to a stream that has a "private" (local to that cell) drawing plane. The code puts ink on the drawing plane, in the form of text, graphics, or both.

After output for a cell has finished, the bounding rectangle of all output on the "private" drawing plane is found. The region within that bounding rectangle forms the contents of a cell.

Additional rectangular regions, containing only background ink, are attached to the edges of the cell contents. These regions ensure that the cells satisfy the tabular constraints that within a row all cells have the same height, and within a column all cells have the same width. CLIM may also introduce additional background for other purposes.

The cells are assembled into rows and columns.

You are responsible only for specifying the contents of the cell. CLIM's table formatter will figure out how to lay out the table so that all the cells fit together properly. It derives the width of each column from the the widest cell within the column, and the height of each row from the the tallest cell within the row.

All the cells in a row have the same height. All the cells in a column have the same width. The contents of the cells can be of irregular shapes and sizes. You can impose both vertical and horizontal constraints on the objects within the cell, aligning them vertically at the top, bottom, or center of the cell, and horizontally at the left, right, or center of the cell.

Some tables are "multiple column" tables, in which two or more rows of the table are placed side by side (usually with intervening spacing) rather than all rows being aligned vertically. Multiple column tables are generally used to produce a table that is more esthetically pleasing, or to make more efficient use of space on the output device. When a table is a multiple column table, one additional step takes place in the formatting of the table: the rows of the table are rearranged into multiple columns in which some rows are placed side by side.

The programmer can give CLIM the following advice about assembling the table:

How to place the contents of the cell within the cell (such as centered vertically, flush-left, and so forth). The possibilities for this advice are described later.

Optionally, how much additional space to insert between columns and between rows of the table.

Optionally, whether to make all columns the same size.

You can specify other constraints that affect the appearance of the table, such as the width or length of the table.

Note that table formatting is inherently two-dimensional from the point of view of the application. Item list formatting is inherently one-dimensional output that is presented two-dimensionally. The canonical example is a menu, where the programmer specifies a list of items to be presented. If the list is small enough, a single column or row of menu entries suffices. In this case, formatting is done when viewport requirements make it desirable.

These constraints affect the appearance of item lists:

The number of rows (that is, allowing CLIM to choose the number of columns)

The number of columns (that is, allowing CLIM to choose the number of rows)

The maximum height (or width) of the column (that is, letting CLIM determine the number of rows and columns that satisfy that constraint)

See 17.5, Advanced Topics for the table and item list formatting protocols.


CommonLisp Interface Manager 2.0 User's Guide - 8 Aug 2003

Next Prev Up Top Contents Index