TRVStyle.OnDrawStyleText

<< Click to display table of contents >>

TRVStyle.OnDrawStyleText

Allows to perform custom drawing of a text item of the StyleNo-th text style.

property OnDrawStyleText: TRVDrawStyleTextEvent

VCL and LCL:

type

  TRVDrawStyleTextEvent = procedure (Sender: TRVStyle;
    const s: TRVUnicodeString; ACanvas: TCanvas; StyleNo: Integer;
    SpaceAtLeft, ALeft, ATop, AWidth, AHeight
    {$IFDEF RVUSEBASELINE},BaseLine{$ELSE}

    {$IFDEF RVHIGHFONTS},DrawOffsY{$ENDIF}

    {$ENDIF}TRVCoord;
    TextWidth: TRVCoord; SpaceCount: Integer;
    DrawState: TRVTextDrawStates;
    Printing, PreviewCorrection, ForMetafile: Boolean;
    ColorMode: TRVColorMode; DarkMode: Boolean;

    DefBiDiMode: TRVBiDiMode;
    RefCanvas: TCanvas;
    LeftNoExpIndex, RightNoExpIndex: Integer;

    PSaD: PRVScreenAndDevice
    var DoDefault: Boolean) of object;

(introduced in version 1.3; new states in TRVTextDrawStates since 1.4; changed in v16, v18, v23)

FireMonkey:

type

  TRVDrawStyleTextEvent = procedure (Sender: TRVStyle;
    const s: TRVUnicodeString; ACanvas: TRVFMXCanvas;

    StyleNo: Integer;
    SpaceAtLeft, ALeft, ATop, AWidth, AHeight
    {$IFDEF RVUSEBASELINE},BaseLine{$ELSE}

    {$IFDEF RVHIGHFONTS},DrawOffsY{$ENDIF}

    {$ENDIF}TRVCoord;
    TextWidth: TRVCoord; SpaceCount: Integer;
    DrawState: TRVTextDrawStates;
    Printing, PreviewCorrection, ForMetafile: Boolean;
    ColorMode: TRVColorMode; DarkMode: Boolean;

    DefBiDiMode: TRVBiDiMode;
    RefCanvas: TCanvas;
    LeftNoExpIndex, RightNoExpIndex: Integer;

    PSaD: PRVScreenAndDevice
    var DoDefault: Boolean) of object;

 

You can use this event to modify drawing of text of some or all text styles.

Input parameters:

The same is in TFontInfo.Draw. You can call Sender.TextStyles[StyleNo].Draw(..) passing the even parameters.

"Hidden" input parameters:

Sender.RVData: TPersistent, document containing this paragraph. It should be typecasted to TCustomRVFormattedData before using.

Sender.ItemNo: Integer, index of the item in Sender.RVData.

Self.OffsetInItem: Integer, index of the first character in the item to draw.

These parameters allow to get additional information about the item being painted.

For example:

uses ..., CRVFData;

...

var ItemTag: TRVTag;

...

ItemTag := TCustomRVFormattedData(Sender.RVData).GetItemTag(

  Sender.ItemNo));

 

Output parameters:

DoDefault – set to False to prevent default drawing.

 

Note: In VCL/LCL, RVUSEBASELINE is defined by default, but you can disable this definition in RV_Defs.inc.

In FireMonkey, RVUSEBASELINE is not defined, and FireMonkey version does not support drawing relative to a base line.

RVHIGHFONTS is defined in all frameworks by default.

 

See also events:

OnApplyStyle;

OnApplyStyleColor;

OnDrawTextBack.

See also properties:

TextStyles.

Demo projects:

Demos\*\Assorted\Custom Draw\