OnCustomLinePaintBefore property

Applies to
TWPPreview

Declaration
property OnCustomLinePaintBefore: TWPVirtPagePaintEvent;

Description
This event is used like OnCustomLinePaintAfter but is triggered before the text has been rendered. This makes it possible to draw to the background of the text.
This example code will draw brackets into the left margin to show how paragraphs are linked together using the KeepN property:
    procedure TWPTBXForm.WPRichText1CustomLinePaintBefore(Sender: TObject;
  RTFEngine: TWPRTFEngineBasis; Param: TWPVirtPagePaintParam;
  EndOfPageRun: Boolean);
var r: TRect; o: Integer; par: TParagraph; thiskeep, prevkeep, nextkeep: Boolean;
begin
  if (Param.Par.ParentTable = nil) and (Param.PaintingInEditor) then
  begin
    if not EndOfPageRun then
    begin
      Param.CallAgainToClose := TRUE; // Make sure we get that EndOfPageRun!
    end else
    begin
      par := Param.Par.prev;
      prevkeep := (par <> nil) and (par.AGetDef(WPAT_ParKeepN, 0) = 1);
      thiskeep := Param.par.AGetDef(WPAT_ParKeepN, 0) = 1;
      nextkeep := TRUE;
      par := Param.Par.next;
      if (par = nil) or (par.AGetDef(WPAT_ParKeepN, 0) = 0) then
      begin
        nextkeep := FALSE;
      end;
      r := Param.UnionRect;
      o := 30;
      Param.Canvas.Pen.Width := 0;
      Param.Canvas.Pen.Color := clRed;
      if thiskeep and not prevkeep then
      begin
        Param.Canvas.MoveTo(r.Left, r.Top);
        Param.Canvas.LineTo(r.Left - o, r.Top);
      end;

      if thiskeep or prevkeep then
      begin
        Param.Canvas.MoveTo(r.Left - o, r.Top);
        Param.Canvas.LineTo(r.Left - o, r.Bottom);
      end;

      if not thiskeep and prevkeep and not nextkeep then
      begin
        Param.Canvas.MoveTo(r.Left - o, r.Bottom);
        Param.Canvas.LineTo(r.Left, r.Bottom);
      end;
    end;
  end;
end;

Category
Paragraph-Reference


Copyright (C) by WPCUBED GmbH - Munich
http://www.wpcubed.com