Drawing in TSRichViewEdit
Drawing in TSRichViewEdit
Hi!
I want to draw rectangle around items in TSRichViewEdit with specified tags. How I can do this?
I know how to find items by tags in SRVE, I can't understand how calculate items coordinates in Canvas (I use OnPaint event).
P.S. is needed account for that items can be placed in tables cells.
Thank you!
I want to draw rectangle around items in TSRichViewEdit with specified tags. How I can do this?
I know how to find items by tags in SRVE, I can't understand how calculate items coordinates in Canvas (I use OnPaint event).
P.S. is needed account for that items can be placed in tables cells.
Thank you!
use the
converts the coordinates of the RV in the coordinates of the SRV.
or function (see their description in help):
Code: Select all
ConvertRVtoSRV (p: TPoint): TPoint;
or function (see their description in help):
Code: Select all
procedure GetItemCoords100 (RVData: TCustomRVFormattedData; ItemNo: Integer; var ALeft, ATop: Integer; var PageNo: Integer);
procedure GetItemBounds100 (RVData: TCustomRVFormattedData; ItemNo: Integer; var ARect: TRect; var PageNoB, PageNoE: Integer);
function GetItemBounds (RVData: TCustomRVData; ItemNo: Integer): TRect;
Thank you!proxy3d wrote:use theconverts the coordinates of the RV in the coordinates of the SRV.Code: Select all
ConvertRVtoSRV (p: TPoint): TPoint;
or function (see their description in help):Code: Select all
procedure GetItemCoords100 (RVData: TCustomRVFormattedData; ItemNo: Integer; var ALeft, ATop: Integer; var PageNo: Integer); procedure GetItemBounds100 (RVData: TCustomRVFormattedData; ItemNo: Integer; var ARect: TRect; var PageNoB, PageNoE: Integer); function GetItemBounds (RVData: TCustomRVData; ItemNo: Integer): TRect;
P.S. There is no description for GetItemCoords100 and GetItemBounds100 in help.
-
- Site Admin
- Posts: 17602
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Will this code work correctly with any zoom?Sergey Tkachenko wrote:100 at the end of the method means that coordinates are calculated in 100% zoom.
Code: Select all
function GetItemRect(ItemNo: Integer; RVData: TCustomRVFormattedData): TRect;
var
FirstPageNo: Integer;
LastPageNo: Integer;
PageRect: TRect;
begin
srve.GetItemPages(RVData, ItemNo, FirstPageNo, LastPageNo);
PageRect := srve.GetPageClientRect(FirstPageNo);
Result := srve.GetItemBounds(RVData, ItemNo);
Result.Left := Result.Left + PageRect.Left;
Result.Right := Result.Right + PageRect.Left;
Result.Top := Result.Top + PageRect.Top;
Result.Bottom := Result.Bottom + PageRect.Top;
end;
procedure TForm1.srveContentPaint(Sender: TSRichViewEdit; Canvas: TCanvas; Prepaint: Boolean);
var
i: Integer;
begin
Canvas.Brush.Style := bsClear;
for i := 0 to Sender.RichViewEdit.ItemCount - 1 do
Canvas.Rectangle(GetItemRect(i, Sender.RichViewEdit.RVData));
end;
Sergey Tkachenko wrote:If your item is a text item, you can consider using SRichViewEdit.RichViewEdit.Style.OnDrawStyleText event.
My items may be of any kind.
-
- Site Admin
- Posts: 17602
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Your cycle iterates only through items in the main editor (from 0 to ItemCount-1). To include items in cells, you need to iterates through items in cells too.
In the next ScaleRichView update, we will include functions allowing to do this work more efficiently (to draw only for items on visible pages, drawing for multiline text items)
We will post updated example here.
In the next ScaleRichView update, we will include functions allowing to do this work more efficiently (to draw only for items on visible pages, drawing for multiline text items)
We will post updated example here.
-
- Site Admin
- Posts: 17602
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17602
- Joined: Sat Aug 27, 2005 10:28 am
- Contact: