TFontInfo.Draw

<< Click to display table of contents >>

TFontInfo.Draw

Draws s on Canvas.

procedure Draw(const s: TRVUnicodeString; Canvas: TCanvas;

  ThisStyleNo: Integer; SpaceAtLeft, Left, Top, Width, Height
  {$IFDEF RVUSEBASELINE}

   ,BaseLine

  {$ELSE}

    {$IFDEF RVHIGHFONTS}

     ,DrawOffsY

    {$ENDIF}

  {$ENDIF}TRVCoord;
  TextWidth: TRVCoord; SpaceCount: Integer;
  RVStyle: TRVStyle;
  DrawState: TRVTextDrawStates;
  Printing, PreviewCorrection, ForMetafile: Boolean;
  ColorMode: TRVColorMode; DefBiDiMode: TRVBiDiMode;
  RefCanvas: TCanvas; GraphicInterface: TRVGraphicInterface;
  LeftNoExpIndex, RightNoExpIndex: Integer;

  PSaD: PRVScreenAndDevice; AControl: TControl = nil);

(changed in version 18 and 19)

Normally, this procedure is called from TRVStyle.OnDrawStyleText event. You just need to pass all the parameters of this event to this method. The parameters that do not exist in OnDrawStyleText are marked with "*".

This method assumes that correct settings (font, colors, character spacing etc.) are already applied to Canvas.

Parameters:

s string to draw.

Canvas canvas to paint.

ThisStyleNo must be equal to the index of this text style in RVStyle.TextStyles.

SpaceAtLeft distance from Left to the beginning of text. It must be 0 (unless you define RVOLDJUSTIFY in RV_Defs.inc).

Left, Top, Width, Height rectangle where the text must be drawn.

BaseLine Y coordinate of the text base line. This parameter exists only if RVUSEBASELINE is defined in RV_Defs.inc; in this case, Canvas's text align must include TA_BASELINE.

DrawOffsY: this parameter exists only if RVHIGHFONTS is defined and RVUSEBASELINE is not defined in RV_Defs.inc; in this case, the text top is drawn at Top+DrawOffsY.

TextWidth – width of s; this parameter is used only if SpaceCount<>0. This parameter is ignored, if PreviewCorrection=True (text width is recalculated before drawing).

SpaceCount:

if 0, the text is drawn as it is (unless PreviewCorrection=True);

if positive, it must be equal to the count of space characters in s; in this case, Width-SpaceAtLeft-TextWidth is distributed between space characters;

if equal to -100, Width-SpaceAtLeft-TextWidth is distributed between all characters in s that can be expanded.

RVStyle* TRVStyle component containing this text style.

Printing is True if the text is drawn while printing or print previewing.

PreviewCorrection is True if the text is drawn while print previewing, and TRVPrint.PreviewCorrection=True. In this case, s is fit to Width-SpaceLeft by adjusting character spacing. This parameter is ignored, of Canvas<>RefCanvas.

ForMetafile is True if drawing must be compatible with metafiles.

ColorMode allows printing text as black and white (although colors must already be assigned to Canvas).

DefBiDiMode is a bi-di mode of paragraph containing this text.

RefCanvas – canvas used to measure text:

when drawing in TRichView, TRichViewEdit, TRVReportHelper, TRVPrint, it must be equal to Canvas;

when drawing in TSRichViewEdit (ScaleRichView), it must be canvas returned by SRichViewEdit.RichViewEdit.RVData.GetScaleRichViewInterface.GetFormatCanvas.

GraphicInterface* RVStyle.GraphicInterface.

LeftNoExpIndex, RightNoExpIndex are used if SpaceCount=-100. If not negative, they specify indexes of characters in s (from 0) which must not be expanded.

PSaD – pointer to a record used for conversion between TRVStyleLength values and device pixels. It may be nil when applying to the screen. This parameter is necessary to apply CharSpacing correctly.

AControl – the editor where this text is drawn. This parameter is optional. It is necessary only in Delphi 10.4+, if ColorMode = rvcmVCLThemeColor, and the editor has StyleName property assigned. This parameter allows choosing a VCL theme specific for this editor instead of the global VCL theme.