ZitatThere must be a lot of advantages/reasons to using watermarks (in view of how much energy and code you put into that feature). What are some of them?
Also, what triggers the <TWPRichText>.OnPaintWatermark event?
- diamond
WPTools 5 has additional watermark support you might have seen in the code. This is not active now - the idea is to handle watermarks which habe been loaded from file *inside* the WPTools core.
You might also have seen references to "External Pages" - this feature is already operational but not documented yet. It is a unique feature WPTools 5 to insert pages which are drawn by different code (such as metafiles exported from a RAVE or RB report) into the stream of RTF pages - - Imagine you can show the user a letter (which can be edited) and attached to this s/he sees the report which will be also sent to the client but consists of readonly pages!
The OnPaintWatermark event is always triggered, no ViewOptions is used anymore to enable it.
You can use it to render some lines on the background of the virtual page, draw a filling pattern or draw your letter head.
This is the piece of code from the watermark demo - it works close to the OnPaintPage event of WPTools 4 but still different. See the comments:
procedure TWaterM.WPRichText1PaintWatermark(Sender: TObject;
RTFEngine: TWPRTFEnginePaint; toCanvas: TCanvas;
PageRect: TRect; PaintPageNr, RTFPageNr: Integer; WaterMarkRef: TObject;
XRes, YRes: Integer;
FCurrentZoom : Single;
PaintMode: TWPPaintModes);
var r: TRect;
offx, offy: Integer;
begin
r := PageRect;
{ if WPRichText1.PrintParameter.Printing then
begin
toCanvas.Pen.Color := clBlack; // on Printer !
// Please note that if we print we need to respect the physical offset
// This is calculated in the printer engine and provided as twips
offx := MulDiv(WPRichText1.PrintParameter.PrintXOffset, XRes, 1440);
offy := MulDiv(WPRichText1.PrintParameter.PrintYOffset, YRes, 1440);
// Subtract the pysical offset since the printer is adding this anyway
dec(r.Left, offx);
dec(r.Top, offy);
dec(r.Right, offx);
dec(r.Bottom, offy);
end
else }
begin
toCanvas.Pen.Color := clGray; // On screen
r := PageRect;
end;
toCanvas.Brush.Style := bsClear;
toCanvas.Pen.Style := psSolid;
toCanvas.Rectangle(
r.Left + XRes div 2,
r.Top + YRes div 2,
r.Right - XRes div 2,
r.Bottom - YRes div 2);
toCanvas.StretchDraw(
Rect(r.Right - XRes * 2,
r.Top + YRes div 4,
r.Right - XRes div 2,
r.Top + YRes div 2),
Image1.Picture.Metafile);
// We want a marker at 2,2 Inch
toCanvas.Font.Height := XRes div 4;
toCanvas.Font.Color := clRed;
toCanvas.TextOut(r.Left + XRes*2,r.Top + YRes*2,'This is Pos 2,2 INCH');
end;
Alles anzeigen
Julian Ziersch