[Lazarus] Autosize behaviour

Birger Jansen birger at cnoc.nl
Mon Apr 5 22:25:06 CEST 2010


Sorry for dropping into the discussion...

There is a very good LAyoutControl in the DevExpress suite (Delphi 
controls). We use it for a lot of projects. I think it is an excellent 
example of how a layout manager could work in the ideal world:

http://www.devexpress.com/Products/VCL/ExLayoutControl/

If you want to see some specific examples let me know.

Kind regards,
   Birger

Op 5-4-2010 21:45, Mattias Gaertner schreef:
> On Mon, 5 Apr 2010 18:26:36 +0200 (CEST)
> Michael Van Canneyt<michael at freepascal.org>  wrote:
>
>> [...]
>> I have been thinking about layout managers. I think that this should be an add-on to the currently existing layouting (to preserve delphi compatibility):
>> I imagine a component that one drops on a form.
>> One sets the 'target' control (control whose children should be managed) and some properties.
>>
>> Depending on the layout one wants, a different component must be dropped:
>>
>> TLayout
>> +-  TAbsoluteLayout
>> +-  THBoxLayout
>> +-  TVBoxLayout
>> +-  TTableLayout
>> +-  TBorderLayout
>>     ...
>> Each descendent has different properties. Changing the layout just means
>> dropping another component; something that can be done run-time.
>>
>> Something like this exists in ExtJS, and it works very well.
>>
>> The only thing I am unsure about is whether TControl should be made TLayout-aware.
>> As far as I understand, a layouter only needs to be able to handle rectangles,
>> within some restrictions (some callbacks to get min/max rectangles).
>> It need not know anything about TControl or it's properties, and as such could
>> be implemented totally independent of the LCL.
>
> See below.
>
>> I discussed this idea once with Mattias Gaertner, but he seems to disagree
>> on the TControl-unawareness, if I recall correctly.
>
> With the new autosizing it is now possible to think about layout
> managers.
> A layout manager that handles the layout of children of a TWinControl
> must implement the following:
> - a computation of the total preferred space (children plus
>    space). At the moment this is done by TControl.CalculatePreferredSize.
> - a computation of the layout (position and size of each child)
>    (AlignControls).
> - a computation of the size (DoAutoSize)
>
> The layouter needs access to Left, Top, Width, Height, ClientWidth,
> ClientHeight, ReadBounds, BaseBounds, BaseParentClientSize,
> AdjustSize, InvalidatePreferredSize.
>
> Optionally a layouter could layout only a subset of the children (e.g.
> those with Align=alCustom or only those with default Anchors).
>
> So the LCL must call instead of its own functions the
> layouter. Namely: DoAutoSize, AlignControl, CalculatePreferredSize,
> ControlsAligned, CreateControlAlignList, CustomAlignInsertBefore,
> CustomAlignPosition, DoAlignChildControls.
>
> One solution would be a TWinControl property Layouter.
>
>
>> Maybe the planned Lazarus day in the netherlands would be a good place to
>> discuss this and settle things  once and for all :-)
>
> :)
>
> Mattias
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus




More information about the Lazarus mailing list