A format object can
be used to turn a device
object into a table of graphicals. Two modes are defined. In column
mode, the graphicals are aligned in a two-dimensional grid that is
(depending on the orientation) n columns width or high. In
non-column mode, if aligns the graphicals in rows, very
similar as words are placed in a paragraph of text with no aligned right
margin.
A format object is
just a data-object. It is interpreted by attaching it to a graphical
device using device->format.
Examples:
Bugs:
The place of a graphical in the grid/row is determined by its
position in the format<-graphicals chain
of the figure. This makes it very difficult to modify the contents a
formatted figure and get the graphicals at the right position in the
grid.
There are no provisions for headers; similar to the multicolumn
mechanism of many text-formatters.
There is not way to draw lines between rows/columns.
They are unnecessary complicated and very confusing.
So, in short, a better alternative will be implemented some day. This
probably will in the form of one or more subclasses of class figure.
The functionalily provided by the format<->format
machanism will remain however.
<-columns
equals @on.
When present it should be a vector with the same number of elements as format<-width.
Each element is one of the names left, center
or right and determines the placement of the
graphical objects
in their cell. If format<-direction
= vertical left and
right should actually be read as top and bottom
The following creates a three column table with the first column aligned to the left, the middle centered and the last to the right:
?- new(D, device),
new(F, format(horizontal, 3, @on)),
send(F, adjustment, vector(left, center, right)),
send(D, format, F),
% fill the table.
send_list(D, display,
[ '1.1', '1.2', '1.3',
'2.1'
]).
See also format->column_sep
and format->row_sep.
<-columns
= @off this is
the distance between words of the paragraph. The default is
10 pixels. See also format->row_sep.<-columns
equals @off
the words are printed as the english do. vertical
prints as the chinese do.
If format<-columns
= @on, horizontal
produces vertical columns.
<-direction
= vertical this is the distance between columns. The default is 10
pixels.
See also format<->column_sep
and format<->adjustment.
->format
to achieve simple table layout. Arguments:
<-direction
If horizontal, the table consists of vertical columns and width
describes the horizontal width or number of columns
<-width If columns
is @on, the
number of columns to create. Otherwise the with in pixels in which the
formatting needs to be done.
<-columns
If @on, make a
table, otherwise format as words are formatted in a paragraph.
The format<-adjustment
variable describes the adjustment of the elements in their column.