how to insert line?

General TRichView support forum. Please post your questions here
Post Reply
Ceprotec
Posts: 259
Joined: Thu Oct 28, 2010 6:09 pm
Contact:

how to insert line?

Post by Ceprotec »

hi sergey

how to put this line at the end of the text according to the space remaining to end the page?
Image
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

It is only possible by custom drawing in OnPaintPage event.
The most similar demos are in Demos\CustomDraw\Rectangles folder.

I assume you need to draw it only for the last page.

This event has the page coordinate in parameters: PageRect.

Line coordinates:

Left: PageRect.Left+SRV.LeftMargin100Pix
Right: PageRect.Right - SRV.RightMargin100Pix;
Bottom: PageRect.Bottom - SRV.BottomMargin100Pix;
Top:
Use SRV.GetItemBounds100 to get coordinates of the last item (index = SRV.RichViewEdit.ItemCount-1) relative to the page, and add PageRect.Top, like in the demo mentioned above.
Ceprotec
Posts: 259
Joined: Thu Oct 28, 2010 6:09 pm
Contact:

Post by Ceprotec »

I am not able to understand the examples, could cite any?
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I'll post the code tomorrow
Ceprotec
Posts: 259
Joined: Thu Oct 28, 2010 6:09 pm
Contact:

Post by Ceprotec »

ok, thank you for attention
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

The code in OnPaint is:

Code: Select all

procedure TForm3.SRichViewEdit1PaintPage(Sender: TObject; PageNo: Integer;
  PageRect, R: TRect; Canvas: TCanvas; Prepaint, Printing: Boolean);
var srv: TSRichViewEdit;
    pt: TPoint;
    FirstPageNo, LastPageNo: Integer;
    ItemRect: TRect;
begin
  srv := Sender as TSRichViewEdit;
  if Prepaint or (PageNo<srv.PageCount) then
    exit;
  pt.X := PageRect.Left + srv.LeftMargin100Pix;
  srv.GetItemBounds100(srv.RichViewEdit.RVData, srv.RichViewEdit.ItemCount-1,
    ItemRect, FirstPageNo, LastPageNo, -1);
  pt.Y := PageRect.Top+ItemRect.Bottom;
  Canvas.Pen.Color := clBlack;
  Canvas.Pen.Width := 1;
  Canvas.Pen.Style := psSolid;
  Canvas.MoveTo(pt.X, pt.Y);
  pt.X := PageRect.Right - srv.RightMargin100Pix;
  pt.Y := PageRect.Bottom - srv.BottomMargin100Pix;
  Canvas.LineTo(pt.X, pt.Y);
end;
Unfortunately, there is a problem. When you edit text, the component redraws only changed area. So, if document height is changed while editing, this line is not redrawn, or redrawn only partially.

A solution is calling UpdateBuffer in OnChange:

Code: Select all

procedure TForm3.SRichViewEdit1Change(Sender: TObject);
begin
 SRichViewEdit1.UpdateBuffer;
end;
But it means double redrawing on any change.
Last edited by Sergey Tkachenko on Sun Nov 02, 2014 11:36 am, edited 1 time in total.
Ceprotec
Posts: 259
Joined: Thu Oct 28, 2010 6:09 pm
Contact:

Post by Ceprotec »

was exactly what I needed.
thanks sergey.
Ceprotec
Posts: 259
Joined: Thu Oct 28, 2010 6:09 pm
Contact:

Post by Ceprotec »

and this, it's possible ?


Image
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

End of paragraph marks?
They are turned on when you include rvoShowSpecialCharacters in SRV.RVOptions. There is an action switching this flag, its button can be found on the toolbar of ActionTest demos.
Ceprotec
Posts: 259
Joined: Thu Oct 28, 2010 6:09 pm
Contact:

Post by Ceprotec »

I was unable to find in the examples, but now could not.
thank
Post Reply