Page 1 of 1

Draw Items Background

Posted: Sun Feb 22, 2015 8:58 am
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

Posted: Sun Feb 22, 2015 2:01 pm
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.

Posted: Sun Feb 22, 2015 3:37 pm
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.

Posted: Sun Feb 22, 2015 9:00 pm
by Sergey Tkachenko
OnDrawTextBack is for drawing background of text items.
If you need to draw something on paragraphs, use OnDrawParaBack.

Posted: Sun Feb 22, 2015 9:16 pm
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

Posted: Mon Feb 23, 2015 9:32 am
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;

Posted: Mon Feb 23, 2015 8:04 pm
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