This works, except that when zoomed out far enough, a border of in my case 96 width and height (document coordinates) gets added to right and bottom of the actual document boundary.
I don’t understand why you are overriding any GoView properties or methods for this. If you just set GoView.ShowsNegativeCoordinates to false, set GoView.Document.FixedSize to true, and set the GoView.Document.Size to the desired value, everything should work as I think you want it.
Note that if the document size is small enough, combined with a GoView.DocScale that is small enough, the user could see outside of the document's bounds. If you want to avoid this, you'll need to override GoView.LimitDocScale to make sure the new GoView.DocScale value will prevent that, according to whatever guidelines you wish.
I am overriding DocExtentSize to prevent the grid to get drawn outside of the document bounds.
I don't want to suggest to the user that this region is valid in any way.
If the entire document is visible in the view, but the aspect ratio of the view is not the same as that of the document, there will be a region in the view that is empty; i.e. where the document does not extend to.
In this case , the DocExtentSize is larger than the document size in at least one direction.
The view does display the grid in that region, however, whichis what I want to prevent.
By limiting the DocExtentSize to the document size, no grid gets drawn in the region outside the document, but I have to include an offset of 96 in document coordinates to prevent a thin border to the right and/or bottom of the document to show.
My question is: why the offset, can I get rid of it, or if not do I need to calculate it in a less ad hoc way ?
Everything works as expected indeed, except for the apparent offset (of 96) between the drawing in the view and the document size.
Now that the DocExtentSize override is only used for avoiding unwanted resizing of the GoOverview, the offset is not that important anymore, although I'm still curious about its origins.
Perhaps that depends on when you look at the original (base) value of GoView.DocExtentSize. If you look at it at a time that there are scrollbars, and if the GoView.DocScale is 0.25 (?? or something like that), then I could imagine that the discrepancy of 96 is caused by the size of the scrollbars that later disappeared.