Sign in Join
FPDoc Onlineexperiment

TControl.CalculatePreferredSize procedure

Member of TControlprotectedIn unit Controls

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

Declaration

pascal
procedure CalculatePreferredSize(var PreferredWidth: Integer; 
 var PreferredHeight: Integer; 
 WithThemeSpace: Boolean); virtual

Arguments

PreferredWidth

Set this argument to the preferred width.

PreferredHeight

Set this argument to the preferred height.

WithThemeSpaceTrue when space around stacked controls should be added.

Description

Calculates the preferred width and height for a control, which is used by the LCL auto-sizing algorithms as the default size. Negative or zero (0) values are treated as undefined and the LCL uses other sizes instead. This value is independent of constraints and siblings, only the inner parts are relevant.

TWinControl overrides this and asks the interface for theme dependent values. See CalculatePreferredSize for more information.

When WithThemeSpace contains True, space is added for stacking.

For example: TRadioButton has a minimum size. But for stacking multiple TRadioButtons there should be some space around the controls. This space is theme-dependent, so the parameter is passed to the widgetset.

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.