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

# TButtonGlyph.Draw

Draws the glyph for the button using the specified settings and state.

## Declaration

Source position: buttons.pp line 128

`public function TButtonGlyph.Draw(`
`Canvas: TCanvas;`
`const Client: TRect;`
`const Offset: TPoint;`
`State: TButtonState;`
`Transparent: Boolean;`
`BiDiFlags: LongInt`
`):TRect; function TButtonGlyph.Draw(`
`Canvas: TCanvas;`
`const Client: TRect;`
`const Offset: TPoint;`
`State: TButtonState;`
`Transparent: Boolean;`
`BiDiFlags: LongInt;`
`PPI: LongInt;`
`const ScaleFactor: Double`
`):TRect;`

## Arguments

`Canvas` |  | Canvas where the glyph is rendered.
`Client` |  | Client coordinates for the drawing operation.
`Offset` |  | Offset in the client coordinates where the glyph is drawn.
`State` |  | Button state.
`Transparent` |  | True if the glyph is drawn transparently.
`BiDiFlags` |  | Not used in the current implementation.

## Function result

Rectangle where the glyph was drawn.

## Arguments

`Canvas` |  | Canvas where the glyph is rendered.
`Client` |  | Client coordinates for the drawing operation.
`Offset` |  | Offset in the client coordinates where the glyph is drawn.
`State` |  | Button state.
`Transparent` |  | True if the glyph is drawn transparently.
`BiDiFlags` |  | Not used in the current implementation.
`PPI` |  | Pixels Per Inch for the image resolution requested in the method.
`ScaleFactor` |  | Canvas scaling factor used in the method.

## Description

Draw is a method used to draw the glyph for the button using the target and configuration specified in the arguments. Draw is overloaded to provide a variant which uses a scaling factor for the glyph image.

Canvas is the TCanvas instance where the glyph is rendered.

Client is a TRectangle instance with the client coordinates for the drawing operation.

Offset is a TPoint instance which contains the offset where the glyph is drawn in the Client rectangle.

State contains the button drawing state and is used to get both the glyph image and graphic drawing effect applied in the method.

Transparent indicates if the glyph is draw transparently.

PPI indicates the display density for the image resolution requested in the method.

ScaleFactor is the canvas scaling factor applied when the image is drawn.

Images used for button glyphs can be loaded from three (3) different sources.

- LCLGlyphResourceName property
- ExternalImages property
- Images property

By default, the LCL Glyph resource is used when the button is created. Setting values for the corresponding properties changes the source for the glyph image.

Draw calls GetImageIndexAndEffect to get the image resolution needed for the value in PPI, and the index for the image drawn in the method. The TScaledImageListResolution.Draw method is called to render the selected glyph in the resolution to the Canvas using the Client, Offset, and derived graphics drawing effect.

No actions are performed in the method when an bitmap has not been assigned to the Glyph property, when the coordinates in Client are invalid, or when an image resolution / image index was not found.

The return value is a TRectangle instance with the original value passed in Client. Please note, this is different than the Delphi VCL; it returns the text rectangle.

## See also

TButtonGlyph.LCLGlyphName |  | Stores the standard LCL resource name used for the Glyph in the class instance.
TButtonGlyph.ExternalImages |  | Contains a reference to an external list of images that can be used as the Glyph image,
TButtonGlyph.Images |  | The list of available images for the button glyph.
TButtonGlyph.GetImageIndexAndEffect |  | Gets the index for a button image using a given state, and the effect used to draw it.
TScaledImageListResolution |  | Implements a scaled image resolution (size).