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

TWinControl.CalculatePreferredSize

Override this method to return a different preferred height and/or width for auto-sizing.

Declaration

Source position: controls.pp line 2192

protected procedure TWinControl.CalculatePreferredSize(

  var PreferredWidth: Integer;

  var PreferredHeight: Integer;

  WithThemeSpace: Boolean

); override;

Arguments

PreferredWidth

  

Width used for new instances of the control.

PreferredHeight

  

Height used for new instances of the control.

WithThemeSpace

  

Indicates if additional space is reserved for theme services.

Description

Calls the inherited method to calculate the default / preferred width and height for a TWinControl instance. It is used by the LCL auto-sizing algorithms as the default size. Only positive values are valid. Negative or 0 (Zero) values are treated as undefined, and the LCL uses other values to perform auto-sizing.

TWinControl overrides this:

For example the preferred size of a TButton is the size, where the label fits exactly. This relies on the current theme and widgetset.

This value is independent of constraints and siblings, only the inner parts are relevant for the calculates values.

WithThemeSpace adds space for stacking when set to True. For example: TRadioButton has a minimum size. But for stacking multiple TRadioButtons there should be space around each control. This space is theme-dependent, so it is passed as a parameter to the widgetset.

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