trichview.com

trichview.support




Re: Selection drawing


Return to index


Author

Message

Sergey Tkachenko

Posted: 05/05/2002 19:56:52


Hi,


Put this code on TRVStyle.OnDrawStyleText.

It implements Word-style selection.



procedure TForm1.RVStyle1DrawStyleText(Sender: TRVStyle; const s: String;

  Canvas: TCanvas; StyleNo, SpaceBefore, Left, Top, Width, Height: Integer;

  DrawState: TRVTextDrawStates; var DoDefault: Boolean);

var i, linebottom, linetop, dummy: Integer;

    RVData: TCustomRVFormattedData;

begin

  if rvtsSelected in DrawState then begin

    RVData := TCustomRVFormattedData(Sender.RVData);

    RVData.Item2DrawItem(Sender.ItemNo, Sender.OffsetInItem, i, dummy);

    while (i>0) and not RVData.DrawItems[i].FromNewLine do

      dec(i);

    with RVData.DrawItems[i] do begin

      linetop := Top;

      linebottom := Top+Height+ExtraSpaceBelow;

    end;

    inc(i);

    while (i<RVData.DrawItems.Count) and not RVData.DrawItems[i].FromNewLine

do

      with RVData.DrawItems[i] do begin

        if Top<linetop then

          linetop := Top;

        if Top+Height+ExtraSpaceBelow>linebottom then

          linebottom := Top+Height+ExtraSpaceBelow;

        inc(i);

      end;

    dummy := RVData.GetVOffs;

    dec(LineTop, dummy);

    dec(LineBottom, dummy);

    Canvas.FillRect(Rect(Left, LineTop, Left+Width, LineBottom));

  end;

end;




> Hi!

>

> This is my first post to this newsgroup, as I just recently became a

> RichView user.

> I have to say, I fell in love with the components instantly - they're

going

> to save me soooo much precious time!(Registration is already in progress

> =D).

>

> Now, I have a small question regarding the selection drawing...

> I see that the component draws selection rectangle depending on individual

> character dimensions as opposed to majority of word processors, which draw

> selection according to the tallest character in line.

> I didn't find any related property to control this, so I was wondering if

> there was a way to have the selection drawn differently? If not, would it

be

> feasible to implement it?

>

> Below are the screenshots of RichView vs. MS Word selection style.

>

> Thank you for your answers!

>

> Aleksander

>

>

>

>

>





Powered by ABC Amber Outlook Express Converter