WPCubed Product Support

How to display the margins as dotted lines?

Hello!

In Full Layout Mode, how can I activate margin display,
I mean the margins as dotted lines like in Word.
I didn't find a property for this at TWPRichText.
I also didn't find an event or anything else where I could do this.

Thanx in advance,
E. Hess

#1 ♥ 0
8.7k Views 2 users read 4 min

Thank you, but I don't get it. Do you have a Demo for me?
There are several problems which I cannot solve:

  • reflect the size and the margins of the current page
  • actual zoom mode
  • In preview window (text not editable) , I should not see this margins.

I saw in the sources, that TWPPaintModes has the flag wppShowMargins.
Why don't you simply made it a public flag, which can be set at TWPRichtText? Sure, we would need some more Flags for the Preview window, and and which LayoutMode to show the margins.
Wouldn't this be a nice enhancement for the next version?

Thank you in advance,
E. Hess

#3 ♥ 0

Ah, WaterM3 demo.

WPLetterhead.PaintPageOnCanvas(0,
0, 0, 0, 0, toCanvas, [wppShowMargins],
XRes, YRes, -1, -1, [wpNoViewPortAPI]);

Is it ok to use function PaintPageOnCanvas (with wppShowMargins)?

Nevertheless, the feature-wish from my proevious posting remains ;-)

Regards,
E. Hess

#4 ♥ 0

Hmm, didn't work: "ghost" images (doubled texts) were displayed.
So, first I used WP.Memo.PaintRTFPage instead, but no change.

Now, I set some more PaintMode flags, and now it seems to be ok.
The paintMode flags I used are:
wppShowMargins
wppNoImages
wppNoTextAtAll
wppNoParShading
wppNoParLines
wppNoHeaderFooter
wppNoWatermarks
wppNoPageBackground

Is this ok, or should I use any other PaintMode flags?
Is it generally ok to use this method to display the margins?

And again:
Nevertheless, the "official" feature-wish from my proevious posting remains ;-)

Regards,
E. Hess

#5 ♥ 0

Did not work :-( "Ghost" bands appeared.
So, I watched the sources and realized the following in the Watermark event (C++ code):

if (PaintMode.Contains( wppInPaintDesktop )) {
if ((RTFEngine->LayoutMode == wplayLayout) ||
(RTFEngine->LayoutMode == wplayFullLayout) ||
(RTFEngine->LayoutMode == wpDualPageView)) {

Wprtedefs::TWPVirtPage *vp = NULL;
TWPRTFEnginePaintPages pp;
TRect textr;

if (RTFEngine->GetPaintPage( PaintPageNr, pp, vp)) {

textr = PageRect;
textr.Left = textr.Left + Wprtedefs::MulDiv( pp.MarginLeft, XRes, WPScreenPixelsPerInch );
textr.Right = textr.Right - Wprtedefs::MulDiv( pp.MarginRight, XRes, WPScreenPixelsPerInch );
textr.Top = textr.Top + Wprtedefs::MulDiv( pp.MarginTop, YRes, WPScreenPixelsPerInch );
textr.Bottom = textr.Bottom - Wprtedefs::MulDiv( pp.MarginBottom, YRes, WPScreenPixelsPerInch );

toCanvas->Pen->Width = 1;
toCanvas->Pen->Color = clSilver;
toCanvas->Pen->Style = psSolid; // psDot

if (!pp.Modes.Contains( wpNoXMargins )) {
if (pp.MarginLeft > 0) {
toCanvas->MoveTo( textr.Left, textr.Top );
toCanvas->LineTo( textr.Left, textr.Bottom );
}
if (pp.MarginRight > 0) {
toCanvas->MoveTo( textr.Right, textr.Top );
toCanvas->LineTo( textr.Right, textr.Bottom );
}
}
if (!pp.Modes.Contains( wpNoYMargins )) {
if (pp.MarginTop > 0) {
toCanvas->MoveTo( textr.Left, textr.Top );
toCanvas->LineTo( textr.Right, textr.Top );
}
if (pp.MarginBottom > 0) {
toCanvas->MoveTo( textr.Left, textr.Bottom );
toCanvas->LineTo( textr.Right, textr.Bottom );
}
}
}
}
}

This seems to work now.

Unfortunately, the margins now are also shown in the preview window.
But for the moment I can live with it.

Regards,
E. Hess

#6 ♥ 0
support

Hi,

What I had in mind was the use of the OnPaintWatermark event in this way:

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;
begin
  r.Left   := PageRect.Left + MulDiv( RTFEngine.RTFData.Header.LeftMargin, XRes, 1440);
  r.Top    := PageRect.Top + MulDiv( RTFEngine.RTFData.Header.TopMargin, YRes, 1440);
  r.Right  := PageRect.Right - MulDiv( RTFEngine.RTFData.Header.RightMargin, XRes, 1440);
  r.Bottom := PageRect.Bottom - MulDiv( RTFEngine.RTFData.Header.BottomMargin, YRes, 1440);
  toCanvas.Pen.Color := clBtnShadow;
  toCanvas.Pen.Width := 0;
  toCanvas.Brush.Style := bsClear;
  toCanvas.Rectangle(r);
end;

Yes, I will add a viewoption - but the above gives you more control.

Julian

#7 ♥ 0

Ok, thanx for the ViewOption.

I didn't test your example above. But is it sure, that changing page adjustments (e.g. new section with new paper format etc.) are correctly reflected ?
If yes, then I should again read the documentation... 🙂

Regards,
E. Hess

#8 ♥ 0
support

That was a simplified example

if RTFPageNr > 0 then
  begin
    r.Left := PageRect.Left + MulDiv(
         RTFEngine.DisplayedText.Pages[RTFPageNr - 1].PageMarginLeft, XRes, 1440);
    r.Top := PageRect.Top + MulDiv(
         RTFEngine.DisplayedText.Pages[RTFPageNr - 1].PageMarginTop, YRes, 1440);
    r.Right := PageRect.Right - MulDiv(
         RTFEngine.DisplayedText.Pages[RTFPageNr - 1].PageMarginRight, XRes, 1440);
    r.Bottom := PageRect.Bottom - MulDiv(
         RTFEngine.DisplayedText.Pages[RTFPageNr - 1].PageMarginBottom, YRes, 1440);
    toCanvas.Pen.Color := clBtnShadow;
    toCanvas.Pen.Width := 0;
    toCanvas.Brush.Style := bsClear;
    toCanvas.Rectangle(r);
  end;

uses the 'current page' properties

#9 ♥ 0
This category is archived. No new posts are possible.