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

# TCustomSpeedButton.MeasureDraw

Calculates the Width and Height for the layout used on the speed button and optionally renders the control.

## Declaration

Source position: buttons.pp line 374

`protected procedure TCustomSpeedButton.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

TCustomSpeedButton.Glyph |  | The bitmap with the glyph image(s) displayed for button states.
TCustomSpeedButton.Margin |  | Space between the glyph bitmap and the aligned edge in the button layout.
TCustomSpeedButton.Spacing |  | Spacing between the Glyph bitmap and the Caption for the control.
TCustomSpeedButton.Layout |  | Indicates the alignment of the glyph bitmap relative to the caption for the control.
TCustomSpeedButton.ShowCaption |  | Indicates if the Caption for the speed button is displayed.
TCustomSpeedButton.Alignment |  | Horizontal alignment for the text displayed on the button control.
TCustomSpeedButton.FState |  | Internal member used to store the TButtonState for the control.
TCustomSpeedButton.Transparent |  | Indicates if the control is drawn with transparency.
TCustomSpeedButton.CalculatePreferredSize |  | Calculates the default height and Width required for the control.
TCustomSpeedButton.PaintBackground |  | Paints the background for the control to the specified rectangle.
TCustomSpeedButton.Paint |  | Updates the state for the control, and paints it to the control Canvas.
TCustomSpeedButton.GetDrawDetails |  | Gets the theme element details used to draw the control.
TCustomSpeedButton.GetGlyphSize |  | Gets the size of the glyph within the specified PaintRect.
TCustomSpeedButton.GetTextSize |  | Gets the size of the Caption text within the specified PaintRect.
TGraphicControl.Canvas |  | A clipped window into the parent Canvas.
TControl.Caption |  | The text displayed for the control.
TControl.UseRightToLeftReading |  | True when BiDiMode is not bdLeftToRight.
TThemeServices.DrawText |  | Draws the text for a themed control.