rvico TRichView Reference | TRVStyle | TFontInfo


Top  Previous  Next

Draws s on Canvas.

procedure Draw(const s: TRVRawByteString; Canvas: TCanvas; ThisStyleNo: Integer;
  SpaceAtLeft, Left, Top, Width, Height
  TextWidth, SpaceCount: Integer;
  RVStyle: TRVStyle;
  DrawState: TRVTextDrawStates;
  Printing, PreviewCorrection, ForMetafile: Boolean;
  ColorMode: TRVColorMode; DefBiDiMode: TRVBiDiMode;
  RefCanvas: TCanvas; GraphicInterface: TRVGraphicInterface;
  LeftNoExpIndex, RightNoExpIndex: Integer);

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.


s – string to draw. If the specified text style is Unicode (see RVStyle.TextStyles[ThisStyleNo].Unicode], this is a raw unicode string. Otherwise, this is an ANSI string (of the character set assigned to Canvas.Font.Charset).

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


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.


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

TRichView © trichview.com