Page 1 of 1

Coordinates of the object on the page, if it is in the table

Posted: Sat Jan 03, 2026 6:27 pm
by Vitalii
I have a question about the coordinates of the TCustomRVItemInfo object on the page. I need to draw a graphic primitive next to the object. Everything works fine, but if the object is in a table, the approach failed. Here is a part of a code:

Code: Select all

procedure TEditor.SRVEditPaint(Sender: TSRichViewEdit; Canvas: TCanvas; Prepaint: Boolean; PaintRect: TRect);
begin
  { .. }
  PageNo := Sender.GetPageNo( RVData, Node.ItemNo, 0 );
  BoundRect := Sender.GetItemBounds( RVData, Node.ItemNo );
  PageClientRect := Sender.GetPageClientRect(PageNo);
  X1 := BoundRect.Left   + PageClientRect.Left;
  Y1 := BoundRect.Top    + PageClientRect.Top;
  X2 := BoundRect.Right  + PageClientRect.Left;
  Y2 := BoundRect.Bottom + PageClientRect.Top;
  Canvas.Rectangle( X1, Y1, X2, Y2 );
  { .. }
end;
How can I correctly take into account that an object is in a table?

Re: Coordinates of the object on the page, if it is in the table

Posted: Sat Jan 03, 2026 7:23 pm
by standay
I don't use the SRVE, but maybe you have to reference the TopLevelEditor? I have to do that with the regular rve to handle table stuff, e.g., rve.TopLevelEditor...

Stan

Re: Coordinates of the object on the page, if it is in the table

Posted: Sun Jan 04, 2026 9:42 am
by Vitalii
standay wrote: Sat Jan 03, 2026 7:23 pm I don't use the SRVE, but maybe you have to reference the TopLevelEditor? I have to do that with the regular rve to handle table stuff, e.g., rve.TopLevelEditor...
Hi Stan, you're right. The key is in the correct RVData. I changed the linear text loop to a recursive table loop, and now the coordinates are calculated correctly. Thanks!

Re: Coordinates of the object on the page, if it is in the table

Posted: Sun Jan 04, 2026 11:22 am
by Sergey Tkachenko
For any case, see the ScaleRichView demos in Demos\Delphi\CustomDraw\Rectangles\
This folder has demos that draw rectangles:
- around all items
- around the item below the mouse pointer
- around the item containing the caret