TWinControl.CalculatePreferredSize procedure
Override this method to return a different preferred height and/or width for auto-sizing.
Declaration
procedure CalculatePreferredSize(var PreferredWidth: Integer;
var PreferredHeight: Integer;
WithThemeSpace: Boolean); overrideArguments
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:
- If there are child components, their total preferred size is calculated
- If this value cannot be computed (e.g. the children depend too much on their parent clientrect), then the interface is asked for the preferred size
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
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
