Page 1 of 1
how to insert line?
Posted: Mon Oct 27, 2014 5:14 pm
by Ceprotec
hi sergey
how to put this line at the end of the text according to the space remaining to end the page?
Posted: Tue Oct 28, 2014 1:13 pm
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.
Posted: Tue Oct 28, 2014 3:17 pm
by Ceprotec
I am not able to understand the examples, could cite any?
Posted: Tue Oct 28, 2014 3:47 pm
by Sergey Tkachenko
I'll post the code tomorrow
Posted: Tue Oct 28, 2014 3:51 pm
by Ceprotec
ok, thank you for attention
Posted: Wed Oct 29, 2014 3:37 pm
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.
Posted: Thu Oct 30, 2014 1:10 pm
by Ceprotec
was exactly what I needed.
thanks sergey.
Posted: Tue Nov 04, 2014 11:01 am
by Ceprotec
and this, it's possible ?
Posted: Tue Nov 04, 2014 4:39 pm
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.
Posted: Wed Nov 05, 2014 3:57 pm
by Ceprotec
I was unable to find in the examples, but now could not.
thank