5 Laying Out CAPI Panes
column-layout
and row-layout
elements are provided to make this easy. The following is a simple example showing the use ofcolumn-layout
.
(contain (make-instance 'column-layout :description (list (make-instance 'text-input-pane) (make-instance 'list-panel :items '(1 2 3 4 5)))))
Figure 5.1 An example of usingcolumn-layout
(setq button1 (make-instance 'push-button :data "Button 1" :callback 'test-callback))(setq button2 (make-instance 'push-button :data "Button 2" :callback 'test-callback))
(setq editor (make-instance 'editor-pane))
(setq message (make-instance 'display-pane :text "A display pane"))
(setq text (make-instance 'text-input-pane :title "Text: " :title-position :left :callback 'test-callback))
column-layout
, listing the elements you wish to use. For instance, to displaytitle
, followed bytext
andbutton1
, type the following into a Listener:(contain (make-instance 'column-layout :description (list text button1)))
Figure 5.2 A number of elements displayed in a column
To arrange the same elements in a row, simply replacecolumn-layout
in the example above with row-layout
. If you run this example, note that the elements in the original column layout disappear as soon as the row layout is created: each CAPI element can only be on the screen once at any time. Putting it into a new layout will remove it from its previous parent.
Layouts can be given horizontal and vertical scroll bars, if desired; the keywords:horizontal-scroll
and:vertical-scroll
can be set tot
ornil
, as necessary.
When creating panes which can be resized (for instance, list panels, editor panes and so on) you can specify the size of each pane relative to the others by listing the proportions of each. This can be done via either the:y-ratios
keyword (for column layouts) or the:x-ratios
keyword (for row layouts).
(contain (make-instance 'column-layout :description (list (make-instance 'display-pane) (make-instance 'editor-pane) (make-instance 'listener-pane)) :y-ratios '(1 5 3)))You may need to resize this window in order to see the size of each pane.
Note that the heights of the three panes are in the proportions specified. The:x-ratios
keyword will adjust the width of panes in a row-layout in a similar way.
Generated with Harlequin WebMaker