TdxNavBarCustomBackgroundPainter.DrawBackground(TCanvas,TRect,TPicture,Boolean,TColor,TColor,TColor,Byte,Byte,TdxBarStyleGradientMode,TdxScaleFactor) Method
Renders a rectangular region on a specific canvas.
Declaration
class procedure DrawBackground(ACanvas: TCanvas; ARect: TRect; APicture: TPicture; AEraseBackground: Boolean; ABackgroundColor: TColor; AColor1: TColor; AColor2: TColor; AAlphaBlend1: Byte; AAlphaBlend2: Byte; AGradientMode: TdxBarStyleGradientMode; AScaleFactor: TdxScaleFactor);
Parameters
Name | Type |
---|---|
ACanvas | TCanvas |
ARect | TRect |
APicture | TPicture |
AEraseBackground | Boolean |
ABackgroundColor | TColor |
AColor1 | TColor |
AColor2 | TColor |
AAlphaBlend1 | Byte |
AAlphaBlend2 | Byte |
AGradientMode | TdxBarStyleGradientMode |
AScaleFactor | TdxScaleFactor |
Remarks
A common use of the DrawBackground method is to custom paint the NavBar control and group background via the OnCustomDraw.Background and OnCustomDraw.GroupClientBackground events.
The DrawBackground method fills the background specified by the ACanvas parameter with a linear gradient brush (gradual change of colors). The method also enables you to draw a picture and combine it with the gradient filling. The canvas rectangle filled by the method is specified by the R parameter.
First, the DrawBackground method tiles APicture on the specified canvas rectangle. If APicture contains no graphics and the AEraseBackground parameter is True, the rectangular region is cleared (filled with the color specified by the ABackgroundColor parameter). The DrawBackground method then fills the region with the color that changes smoothly across the rectangle (gradient filling). Use the AColor1 and AColor2 parameters to specify the colors of the starting and ending points of the gradient, respectively. To specify the direction of the color gradient filling, use the AGradientMode parameter.
The AAlphaBlend1 and AAlphaBlend2 parameters allow you to specify the transparency gradient of the filling. Each determines a value between 0 and 255 and this allows you to make the filling translucent. Setting the parameters to 0 makes the filling absolutely transparent (the background is painted without color blending). Conversely, a value of 255 makes the filling 100% opaque (the background is invisible).
Use the AScaleFactor parameter to scale the background.
The following screenshot shows a rectangle rendered by the DrawBackground method, which was passed a sample image as an APicture parameter. Other arguments were set as follows:
AEraseBackground is set to True
AColor1 is set to $507FFF
AColor2 is set to $C1B6FF
AAlphaBlend1 is set to 0
AAlphaBlend2 is set to 255
AGradientMode is set to gmForwardDiagonal