Next Prev Up Top Contents Index

grid-layout

Class
Summary

The grid-layout is a layout which positions its children on a two dimensional grid.

Superclasses

x-y-adjustable-layout

Subclasses

row-layout
column-layout

Slots

orientation

The orientation of the children.

rows

The number of rows in the grid.

columns

The number of columns in the grid.

x-ratios

The ratios between the columns.

y-ratios

The ratios between the rows.

x-gap

The gap between each column.

y-gap

The gap between each row.

x-uniform-size-p

If t , make each of the columns the same size.

y-uniform-size-p

If t , make each of the rows the same size.

Accessors

layout-x-ratios

layout-y-ratios

layout-x-gap

layout-y-gap

Description

The row and column sizes are controlled by the constraints on their children. For example, the visible-min-width of any column is the maximum of the visible-min-width s of the children in the column. The size of the layout is controlled by the constraints on the rows and columns.

The description is either a two dimensional array or a list in the order specified by the orientation (which defaults to :row ). In the latter case, one of :columns or :rows can be given to specify the dimensions (the default is two columns).

The x-ratios and y-ratios slots control the sizes of the elements in a grid layout in the following manner:

The elements of x-ratios (or y-ratios ) control the size of each child relative to the others. If an element in x-ratios (or y-ratios) is nil the child is fixed at its minimum size. Otherwise the size is calculated as follows

(round (* total ratio ) ratio-sum )

where ratio-sum is the sum of the non- nil elements of x-ratios (or y-ratios ) and ratio is the element of ratios corresponding to the child. If this ideal ratio size does not fit the maximum or minimum constraints on the child size, and the constraint means that changing the ratio size would not assist the sum of the child sizes fitting the total space available, then the child is fixed at its constrained size, the child is removed from the ratio calculation, and the calculation is performed again. If x-ratios (or y-ratios ) has fewer elements than the number of children, 1 is used for each of the missing ratios. Leaving x-ratios (or y-ratios ) nil causes all of the children to be the same size.

The positions of each pane in the layout can be specified using x-adjust and y-adjust like every other x-y-adjustable-layout , except that if there is one value then it is used for all of the panes, whereas if it is a list then each value in the list refers to one row or column. If the list does not contain a value for every row or column then the last value is taken to refer to all of the remaining panes.

Example
(capi:contain (make-instance
               'capi:grid-layout
               :description '("1" "2" "3"
                              "4" "5" "6"
                              "7" "8" "9")
               :columns 3))
(capi:contain (make-instance
               'capi:grid-layout
               :description (list "List:"
                                  (make-instance
                                   'capi:list-panel
                                   :items '(1 2 3))
                                   "Buttons:"
                                  (make-instance
                                   'capi:button-panel
                                   :items '(1 2 3)))))
(capi:contain (make-instance
               'capi:grid-layout
               :description (list "List:"
                                  (make-instance
                                   'capi:list-panel
                                   :items '(1 2 3))
                                  "Buttons:"
                                  (make-instance
                                   'capi:button-panel
                                   :items '(1 2 3)))
               :x-adjust '(:right :left)
               :y-adjust '(:center :bottom)))
(capi:contain (make-instance
               'capi:grid-layout
               :description (list "List:"
                                  (make-instance
                                   'capi:list-panel
                                   :items '(1 2 3))
                                  "Buttons:"
                                  (make-instance
                                   'capi:button-panel
                                   :items '(1 2 3)))
               :orientation :column))
See also

layout


LispWorks CAPI Reference Manual - 14 Dec 2001

Next Prev Up Top Contents Index