Work proceeds apace, but this problem turns out to be *slightly* messy. Here's why:
I require the map to display an integral number of cells in each direction. This decision was made after considerable thought, and I'm convinced it's proper. So to initially size the window I use a formula like:
WindowWidth = LabelWidth + ScrollbarWidth + VisibleColumns * CellWidthInPixels
This is the old (i.e., pre-non-destructive gridlines) formula. To it I now add a new factor:
WindowWidth += int ( VisibleColumns / GridLineFreq )
So far so good, right?
The problem comes in when we allow users to resize the window. Now we have two variables to solve for using the above equation. The user has proposed a new WindowWidth; we have to reduce this by 0-24 pixels so we get all or none of the rightmost cell. But to calculate the rightmost cell we need to know the width of the window.
Well, I think I have a moderately messy but functional iterative solution to the problem, but I'm wondering if the chief algorithmist can earn his keep this week by offering any simplifying advice.
The non-destructive gridlines will force me to revisit the scrolling code as well, but that's a problem for another night.