[Lazarus] AnchorSide clarification

Hans-Peter Diettrich DrDiettrich1 at aol.com
Sat Jan 1 14:28:08 CET 2011


The FPDoc description of TAnchorSide looks wrong to me. IMO it should 
reflect the following:

Every side of a TControl can be anchored to another control, as 
described by TControl.AnchorSides[side].

TAnchorSide.Owner is the control *to be* anchored.
[should read: Control]
[ctrl.AnchorSide[side].Owner = ctrl]

TAnchorSide.Kind is the control side (index in AnchorSides).
[should read: ControlSide]
[ctrl.AnchorSide[side].Kind = side]

TAnchorSide.Control is the anchor control,
[should read: AnchorControl]

and TAnchorSide.Side is the side of that control, *to* which Owner is 
anchored or aligned (plus asrCenter).
[should read: AlignTo]

If this is correct, the FPDoc should be updated accordingly.


This is how IMO a control can be anchored:

Normally the TControl.Top/Left is the absolute control origin within its 
Parent, Width/Height is the absolute extent (size) of the control.

The sides of a control can be anchored to its Parent (ClientRect) sides, 
as specified by TControl.Anchors. For every such anchored side the 
distance to the Parent.ClientRect is preserved when the Parent is resized.

Lazarus adds another anchoring method to beforementioned Delphi 
compatible anchoring:

AnchorSides[] allow to anchor the control to other controls (siblings 
only?).
For every side a TAnchorSide object can specify the control and its 
side, to which the control's side is anchored. For every such anchored 
side the distance to the anchor control is preserved, as specified in 
the control's BorderSpacing.


DoDi





More information about the Lazarus mailing list