trichview.com

trichview.support




Re: Pixel coords of itemoffest in table cell


Return to index


Author

Message

Justin Turberville

Posted: 08/13/2002 18:39:13


Using the DrawItems works great, thanks - Sergey to the rescue once again!


"Sergey Tkachenko" <[email protected]> wrote in message

news:[email protected]...

> RichView stores information about coordinates for strings, not for

> individual characters.

> So, in general case, finding coordinates of given offset in text is not

> trivial.

>

> If you need coordinate of given item (itemno) in the given rvdata, the

code

> is:

>

> var ax, ay: Integer;

>

> fcurdata.getoriginex(ax,ay);

> fcurdata.getitemcoords(itemno,x,y);

> inc(x, ax);

> inc(y, ay);

> // (x,y) is a result.

> // checking for type of fcurdata is not necessary

>

> As for more more precise calculations...

> Try the following:

>

> var ax, ay, dno, doff: Integer;

>

> fcurdata.getoriginex(ax,ay);

> fcurdata.Item2DrawItem(itemno, itemoffs; dno, doff);

> x := fcurdata.DrawItems[dno].Left+ax;

> y := fcurdata.DrawItems[dno].Top+ay;

>

> At least y-coordinate will be calculated correctly.

>

>

> > I've found that in some cases just getting the coords of the item

> containing

> > the selection is not good enough - if it contains a large amount of

> > contiguous text, the selection may not be scrolled into view.

> > I know you said it would be a lot more difficult and am sorry to ask...

> It

> > only needs be a ballpark y coord so a shortcut method would probably be

> fine

> > if you can think of one.

> >

> > I tried this where the data height adjusted by the offset in the length

is

> > added, but it doesn't allow for line height variations:

> >

> >         if (fcurdata is TRVTableCellData) then

> >           TRVTableCellData(fcurdata).getoriginex(x,y)

> >         else

> >           frichview.getitemcoords(itemno,x,y);

> >

> >         // Adjust for offset

> >

> >

>

inc(y,round(TCustomRVFormattedData(fcurdata).getheight*(itemoffs/length(fcur

> > data.items[itemno]))));

> >

> >         frichview.scrollto(y);

> >

> >

> >

> >

>

>





Powered by ABC Amber Outlook Express Converter