On Mon, 5 Apr 2010 18:26:36 +0200 (CEST) Michael Van Canneyt <[email protected]> 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 [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
