Difference between revisions of "LCL AutoSizing"

From Free Pascal wiki
Jump to navigationJump to search
Line 23: Line 23:
 
The main method is TWinControl.AlignControls.
 
The main method is TWinControl.AlignControls.
  
#AdjustClient
+
#init RemainingClientRect to ClientRect and RemainingBorderSpace to Rect(0,0,0,0)
#alTop,alBottom,alLeft,alRight,alClient,alCustom,alNone,not aligned
+
#call AdjustClient to adjust RemainingClientRect
##
+
#apply ChildSizing.LeftRightSpacing,ChildSizing.TopBottomSpacing
 +
#call DoAlign with alTop,alBottom,alLeft,alRight,alClient,alCustom,alNone
 +
##DoAlign collects child controls with this Align value and call for each such control DoPosition
 +
###DoPosition calculates the new Left,Top,Width,Height

Revision as of 21:23, 5 September 2007

Overview / Terminology

This page explains the LCL auto sizing algorithm. AutoSizing means here: Automatic resizing and repositioning of LCL controls.

Properties

The following properties defines the behavior of the LCL autosizing:

  • Current Left,Top,Width,Height,ClientWidth,ClientHeight
  • Loaded Left,Top,Width,Height,ClientWidth,ClientHeight
  • AutoSize
  • Anchors
  • AnchorSides
  • Align
  • BorderSpacing
  • ChildSizing
  • Constraints

For Delphi compatibility the LCL supports the method AdjustClientRect which is an extension to the BorderSpacing properties.

Order

The main method is TWinControl.AlignControls.

  1. init RemainingClientRect to ClientRect and RemainingBorderSpace to Rect(0,0,0,0)
  2. call AdjustClient to adjust RemainingClientRect
  3. apply ChildSizing.LeftRightSpacing,ChildSizing.TopBottomSpacing
  4. call DoAlign with alTop,alBottom,alLeft,alRight,alClient,alCustom,alNone
    1. DoAlign collects child controls with this Align value and call for each such control DoPosition
      1. DoPosition calculates the new Left,Top,Width,Height