Page 157 Table of Contents Index Page 159
Chapters
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
A, B, C, D, E





Chapter 17

Table Formatting

CLIM provides a mechanism for tabular formatting of arbitrary output.

To employ these facilities the programmer annotates some output-generating code with advisory
macros that describe the high-level formatting constraints, for example, what parts of code
produce a row of the table, what parts of that produce the cells in the row.

For example, the following produces a table consisting of three columns containing a number,
its square, and its cube. The output can be seen in Figure 17.1.

 
 (defun table-test (count stream)
   (fresh-line stream)
   (formatting-table (stream :x-spacing '(3 :character))
     (dotimes (i count)
       (formatting-row (stream)
         (formatting-cell (stream :align-x :right)
           (prin1 i stream))
         (formatting-cell (stream :align-x :right)
           (prin1 (* i i) stream))
         (formatting-cell (stream :align-x :right)
           (prin1 (* i i i) stream))))))
The general contract of these facilities is described in the next section.

17.1 Overview of Table Formatting Facilities

In general, table formatting involves a sharing of responsibilities between user-written code and
CLIM code. Code that employs only the lower level output facilities has full control over "where
every piece of ink goes" in the output. In contrast, code that employs CLIM's table formatting


Page 157 Table of Contents Index Page 159
Chapters
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
A, B, C, D, E