TCustomShape.DrawToCanvas procedure
Draws the Shape for the control on the specified canvas.
Declaration
procedure DrawToCanvas(ACanvas: TCanvas); virtualDescription
DrawToCanvas is a method used to draw the shaped control on the
TCanvas instance specified in the
ACanvas argument. It calculates
the drawing area (TRect) needed using the control Width and Height, the width
of the Pen on the canvas, and the Shape for the control.
The Brush style and color for the canvas are set in the calling routine. This allows the same method to be used to draw either the content for the shaped control or its Monochrome mask - depending on the settings in the canvas.
DrawToCanvas calls methods in ACanvas to perform drawing operations needed for the value in Shape. For example:
- stRectangle, stSquare
- Calls the Rectangle method.
- stRoundRect, stRoundSquare
- Calls the RoundRect method.
- stCircle, stEllipse
- Calls the Ellipse method.
- stSquaredDiamond, stDiamond
- Allocates TPoint instances with the four (4) vertices needed for the shape and calls the Polygon method.
- stTriangle, stTriangleDown, stTriangleLeft, stTriangleRight
- Allocates TPoint instances with the three (3) vertices needed for the shape and calls the Polygon method.
- stStar, stStarDown
- Calculates the center point and radii needed to scale the width or height for the shape. Allocates the eleven (11) vertices needed for the shape and calls the Polyon method.
- stPolygon
- Signals the OnShapePoints event handler (when assigned) to get the vertices and polygon winding for a user-specified or irregular polygonal shape. If the event handler returns more than 2 vertices, the Polygon method is called using the points. No actions are performed if 2 (or fewer points) are returned as vertices for the polygon. Please note that the Shape is not drawn on the control canvas at design-time; a rectangle with a dashed border and a red 'X' are drawn to the corners of the designer surface.
DrawToCanvas is called from the UpdateMask and Paint methods.
Added in LCL version 4.0.
See also
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
