TCustomSpeedButton.MeasureDraw procedure
Calculates the Width and Height for the layout used on the speed button and optionally renders the control.
Declaration
procedure MeasureDraw(Draw: Boolean; PaintRect: TRect;
out PreferredWidth: Integer;
out PreferredHeight: Integer)Arguments
Draw | True if the background and content for the control are drawn. False to calculate the preferred width and height only. |
PaintRect | Drawing area on the canvas where the content is positioned. |
PreferredWidth | Returns the preferred width calculated for the control. |
PreferredHeight | Returns the preferred height calculated for the control. |
Description
MeasureDraw determines the space needed to draw the content for the
speed button control. Values in the Caption, ShowCaption, Glyph, Margin,
Spacing, and Layout properties are used to determine the layout for the control
elements and the space needed to draw the control without clipping.
When Draw is enabled, the control is rendered to its Canvas using the State, Transparent and Layout settings. Otherwise, only measurements are performed in the method.
No actions are performed in the method if the Glyph property has not been assigned for the control; in this case, the output parameters in PreferredWidth and PreferredHeight are unchanged from their default values.
PaintRect contains the area where the control is drawn on its Canvas, and provides the bounds for the background on the control.
GetGlyphSize is called to get the dimensions for the glyph bitmap including any drawing effect applied in ThemeServices for the control State.
When Caption has been assigned and ShowCaption is enabled, the text size is included in the calculated space requirements. The values in Margins and Spacing are included in the horizontal or vertical size based on the value in Layout. Values in Alignment and UseRightToLeftReading are used when the text rectangle is calculated. If the Font matches the default System font settings, ThemeServices.DrawText is called to measure/render the text for the control.
Values in PreferredWidth and PreferredHeight are updated and returned to the calling routine in the output parameters.
Used in the implementation of the CalculatePreferredSize and Paint methods.
See also
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
