Storing and Retrieving Points

Tim Rowledge tim at sumeru.stanford.edu
Fri Sep 28 04:45:59 UTC 2001


"Ken G. Brown" wrote:

> In general what would be the best way to store the location and extent of a
> window, for restoration the next time it is opened as a new instance.
I see that plenty of people have offered help on the first part of your
mail, but not the second. So, here goes...

I'll assume here that you are wanting to keep the position and extent of
a window that you are about to close in order that some time later you
can create a new window and place it in the same spot.  Your message is
a little unclear though since you say "next time it is opened as a new
instance" - if we are talking of a new instance, it cannot be 're'opened
since it will not have been opened before. So the first thing to do is
to make sure in your own mind whather you are closing windows and
creating replacements later or if you are 'hiding' the windows and then
reopening them later.

In either case, you could simply keep a list of Rectangles. Rectangles
can be created in a variety of ways including `Rectangle origin:
foo at blah corner: fee at fie` or 3 at 4 extent: 400 at 211 - and many others. A
look at the class will show the interstingly long list of things you can
do with them.

I suspect that you will want to associate some sort of
name/label/identifier with each or you saved Rectangles, so consider a
Dictionary. Let's say you use the window's label as the id, just for grins.

	savedWindowFrames := Dictionary new.
	savedWindowFrames at: thisWindow label put: thisWindow fullframe.

tim






More information about the Squeak-dev mailing list