[Lazarus] Autosize behaviour

Hans-Peter Diettrich DrDiettrich1 at aol.com
Wed Apr 7 14:11:25 CEST 2010


Michael Van Canneyt schrieb:

>> IMO it's quite simple. A layout affects the position of child controls 
>> inside a container control, nothing else. Borders, Constraints and 
>> Autosize are general properties of all controls, which must be handled 
>> in/by the control itself.
> 
> I agree for Constraints, but not the other two.
> 
> It is in contradiction with what Mattias said, where he claimed that
> when doing layouting you must always work inside-out and outside-in.
> Borderspacing IS used when layouting: it determines the available space
> for childs inside/outside the control.

The control determines its client extent from given bounds, by taking 
into account its specified border style. A layout manager has no idea of 
such borders, bevels etc., and also not of the visible rectangle of a 
TScrollingWindowControl.

> Autosize as well: if autosize is true, then the size of the control
> changes, and therefor the layout internal to the control, but also 
> externally. Hence it belongs in the layouter.

In the simplest case the layouter has not to care about autosize at all. 
The control determines its required extent, based on e.g. font size and 
nationalized text, and reports it as its required extent. There is 
nothing beyond that extent that a layout manager has to know about.

Only when a control can adopt itself to different *given* extents, by 
e.g. breaking its content into multiple lines, a layout manager has to 
split the available extent into zones for the client controls. Such a 
layout manager would accept an extent in one direction, and calculate 
the resulting extent in the other direction, or spread the client 
controls evenly. This is a different behaviour from the beforementioned 
Autosize of controls with no child controls.


> IMHO a control needs only 5 properties: top/left/width,height and
> constraints. All the rest is layouting.

You mean that every control should have borders or bevels, as specified 
by the layout manager? How should such a manager know about different 
border styles for its client controls?

DoDi





More information about the Lazarus mailing list