Draw Items Background

General TRichView support forum. Please post your questions here
Post Reply
Jim Knopf
Posts: 241
Joined: Mon Dec 30, 2013 10:07 pm
Location: Austria
Contact:

Draw Items Background

Post by Jim Knopf »

Is there a possibility to draw items background depending not on style-no but on item number?

It is for text analysis - easy-to-read to difficult in five different levels
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Do you mean text background?
OnDrawTextBack event has "hidden" parameters, including item number.
However, it would be simple to change Canvas.Brush.Color instead of drawing background yourself.
If you need, I can add similar hidden parameters to OnApplyStyleColor event.
Jim Knopf
Posts: 241
Joined: Mon Dec 30, 2013 10:07 pm
Location: Austria
Contact:

Post by Jim Knopf »

Sergey Tkachenko wrote:Do you mean text background?
Exactly! Only some soft colored background to mark paragraphs as difficult ... or easy-readable text.
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

OnDrawTextBack is for drawing background of text items.
If you need to draw something on paragraphs, use OnDrawParaBack.
Jim Knopf
Posts: 241
Joined: Mon Dec 30, 2013 10:07 pm
Location: Austria
Contact:

Post by Jim Knopf »

Sergey Tkachenko wrote:OnDrawTextBack is for drawing background of text items.
If you need to draw something on paragraphs, use OnDrawParaBack.
Yes, works fide but that way I only can paint the background depending on ParaStyle number. I must paint depending on certain items. Item numbers. It is alway the whole paragraph that contains different difficulty-levels of text. First item an all with SameAsPrev until next paragraph break
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

OnDrawParaBack has hidden parameters as well:
http://www.trichview.com/help/idh_trvst ... aback.html :

TCustomRVData(Sender.RVData) is a document containing the item. Normally it is RichViewEdit.RVData, but may be a table cell or RVData of cell inplace editor.
Sender.ItemNo is the index of the last item in the paragraph. To get the first item:

Code: Select all

FirstItemNo := Sender.ItemNo;
for i := FirstItemNo downto 0 do
  if TCustomRVData(Sender.RVData).IsParaStart(i) then begin
    FirstItemNo := i;
    break;
  end;
Jim Knopf
Posts: 241
Joined: Mon Dec 30, 2013 10:07 pm
Location: Austria
Contact:

Post by Jim Knopf »

I see ... Sender.ItemNo is the secret. And it seems that always the last item of a paragraph is to be monitored for painting the desired color into Canvas with ARect.

Thank you
Post Reply