Keywords: manual

Next: 1.11 Borders Up: 1. Renaissance AutoLayout Previous: 1.9 AutoLayout flags

# 1.10 How AutoLayout flags are determined

When a container manages a view, it has to determine the align flags of the view. When the view is first added, the container calls the method `-autolayoutDefaultHorizontalAlignment` of the view, to get its horizontal align flag, and the method `-autolayoutDefaultVerticalAlignment` to get its vertical align flag. If the values returned by those methods are not appropriate, it is possible to change the flags by calling methods of the container manually for each view (for example, for boxes, by calling the method `-setHorizontalAlignment:forView:`). Any flag manually set will override the default flags.

Renaissance AutoLayout adds a category to NSView, implementing the following methods:

- `- (GSAutoLayoutAlignment) autolayoutDefaultHorizontalAlignment`, which should return the default alignment in the horizontal direction for that view (given the view's class and attributes).
- `- (GSAutoLayoutAlignment) autolayoutDefaultVerticalAlignment`, which should return the default alignment in the vertical direction for that view (given the view's class and attributes).

The default implementation of those methods in `NSView` returns `GSAutoLayoutAlignCenter` for both of them; Renaissance AutoLayout also provides implementations of those methods (as categories) for most standard AppKit classes; generally returning `GSAutoLayoutExpand` if the control benefits from being expanded in a direction, and `GSAutoLayoutAlignCenter` otherwise.

You should implement those methods in your subclasses to make sure they interact properly with Renaissance AutoLayout.

Next: 1.11 Borders Up: 1. Renaissance AutoLayout Previous: 1.9 AutoLayout flags