Sign in Join
FPDoc Onlineexperiment

TButtonGlyph.Draw function

Member of TButtonGlyphpublicIn unit Buttons

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

Declaration

pascal
function Draw(Canvas: TCanvas; const Client: TRect; 
 const Offset: TPoint; State: TButtonState; 
 Transparent: Boolean; BiDiFlags: LongInt): TRect
function 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.

TransparentTrue 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.

Function result

Rectangle where the glyph was drawn.

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

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