TCustomLabel.CalculatePreferredSize procedure
Calculates the preferred size of the control based on size restrictions such as anchoring, aligning, constraints and the WordWrapLength parameter.
Declaration
procedure CalculatePreferredSize(var PreferredWidth: Integer;
var PreferredHeight: Integer;
WithThemeSpace: Boolean); overrideArguments
PreferredWidth | Preferred width calculated for the control. |
PreferredHeight | Preferred height calculated for the control. |
WithThemeSpace | True to reserve space for theme element details. |
Description
CalculatePreferredSize is an overridden method used to calculate
the preferred size for the control. This size is used when the
AutoSize
property of the control is switched to
True. Values stored in the
Anchors,
Align,
Constraints, and
WordWrapLength properties
are evaluated to determine the effective size for the control. Rotated and
word-wrapped text is handled correctly.
CalculatePreferredSize checks the assigned Font for the control to
determine whether text rotation is used in its Orientation
property. When a value other than 0 (zero) is used, the text
rectangle is calculated on the basis of the rotation angle (given in 1/10 degrees
in the Font.Orientation property).
The values in PreferredWidth and PreferredHeight are
updated for the new text rectangle.
No actions are performed in the method if Parent has not been
assigned (contains Nil), or when a handle has not been allocated in
the Parent control.
Please note that CalculatePreferredSize does not call the inherited method.
See also
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
