5 Laying Out CAPI Panes

5.4 Constraining the size of layouts

The size of a layout (often referred to as its geometry) is calculated automatically on the basis of the size of each of its children. The algorithm used takes account of hints provided by the children, and from the description of the layout itself. Hints are specified with keyword arguments given to the panes when they are created.

The following four hints are recognized by all layouts:

:visible-min-width -- the minimum width of the child

:visible-max-width -- the maximum width of the child

:visible-min-height -- the minimum height of the child

:visible-max-height-- the maximum height of the child

Hints can take arguments in a number of formats, which are described in full in the CAPI Reference Manual. When given a number, the layout is constrained to that number of pixels. A number of characters can also be specified, as shown in the next example.

In the last section, you created a window with five panes, by combining row and column layouts. Now consider changing the definition of the editor pane so that it required to have a minimum size. This would be a sensible change to make, because editor panes need to be large enough to work with comfortably.

(setq editor2 (make-instance 'editor-pane
                    :visible-min-width '(:character 30)
                    :visible-min-height '(:character 10)))

You will now have to place this new editor into the layouts that contained the old one. Only one layout is affected: the overall column layout which brings all the panes together.

Before typing the following into the listener, you should close down all the windows created in this chapter, by using Works > Exit > Window on each in turn, in order to free up the instances ofButton1,Button2 and so forth.

(contain (make-instance 'column-layout
                        :description 
                          (list row1 row2 editor2)))

Figure 5.5 The result of resizing the sample layout


CAPI User Guide, Liquid Common Lisp Version 5.0 - 2 OCT 1997

Generated with Harlequin WebMaker