[Overview][Constants][Types][Classes][Procedures and functions][Index] Reference for unit 'StdCtrls' (#lcl)

TCustomLabel.CalculatePreferredSize

Calculates the preferred size for the control using its anchoring and constraints.

Declaration

Source position: stdctrls.pp line 1571

protected procedure TCustomLabel.CalculatePreferredSize(

  var PreferredWidth: Integer;

  var PreferredHeight: Integer;

  WithThemeSpace: Boolean

); override;

Arguments

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 calculated the preferred size for the control. Values stored in the Anchors, Constraints, and WordWrap properties are used to determine the effective width for the control. CalculateSize is called to calculate the text rectangle for the control using the requested dimensions.

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 rotated by the number of radians needed for the property value. 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

TControl.CalculatePreferredSize

  

Override this method to return the preferred height and width for the control.


Version 3.2 Generated 2024-02-25 Home