Recent

Author Topic: TCustomGrid "physical" offset  (Read 804 times)

Zoran

  • Hero Member
  • *****
  • Posts: 1949
    • http://wiki.lazarus.freepascal.org/User:Zoran
TCustomGrid "physical" offset
« on: June 17, 2023, 03:55:38 pm »
In TCustomGrid there is a method OffsetToColRow. One of the parameters is boolean named Physical.
The documentation for the method says:
Quote
Physical True for a physical offset, False for a logical offset.
But I can't figure out myself what physical and logical offsets are. :(
I tried searching the forum, but could not find the answer.
Swan, ZX Spectrum emulator https://github.com/zoran-vucenovic/swan

wp

  • Hero Member
  • *****
  • Posts: 12909
Re: TCustomGrid "physical" offset
« Reply #1 on: June 17, 2023, 05:00:21 pm »
Not very clear words, indeed...

Run the attached experiment. "Offset" (in column mode, i.e. when IsCol=true) is the distance of a location from the left edge of the grid. This is marked in the project by a bevel seen at the top and bottom of the grid.

The left button "Physical=true" calls OffsetToColRow with the "physical" parameter set to true, and the other button "Physical=false" calls it with Physical = false. The column indices are displayed in the fixed row of the grid.

Now run the demo. Click the left button - the output of OffsetToColRow is displayed in the form's caption, it says: "Index = 2"; since we have IsCol=true this means: Our offset points to column 2. The same happens when you click the other button which queries for Physical = false.

Now scroll the grid horizontally. At the end of the scrollbar, the marker is in column 6 on my system - and this is returned when you click the "Physical = true" button. But when you click the "Physical = false" button we still get Column 2.

So it is clear: Physical = true returns the column index when the grid is scrolled, and Physical = false returns the column index for the unscrolled grid.

I updated the docs file.
« Last Edit: June 17, 2023, 05:13:59 pm by wp »

Zoran

  • Hero Member
  • *****
  • Posts: 1949
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: TCustomGrid "physical" offset
« Reply #2 on: June 17, 2023, 05:29:50 pm »
Thank you very much, wp, for this nice example project and the thorough explanation!

So it is clear: Physical = true returns the column index when the grid is scrolled, and Physical = false returns the column index for the unscrolled grid.

Now completely clear indeed!

I updated the docs file.

Thank you for that, too!
Swan, ZX Spectrum emulator https://github.com/zoran-vucenovic/swan

 

TinyPortal © 2005-2018