Best way to manage a scrollview

I have a situation (similar to the main window of the Xojo IDE)

There is an array of Objects, each object has a coordinate (X,Y) the “main object” [think window] alway has a X,Y of (0,0), every other object can have any coordinate (including negative values)

I’m trying to figure out a way to calcuate the best contentview size for a NSScrollArea based on the coordinates and size of all the objects.

Right now its finding the min and max values for the object coordinates and sizes, from that calculate an offset and repostion all the objects accordingly…