[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Resizing and moving a window?



Jeff Clites writes 2 Jul 1998 23:14:35 -0700 (PDT)

>>Is there a way to resize and move a window at the same time? Right now,
>>I am using this function, but it doesn't work very well, since it moves,
>>then resizes:
>
>If you really want to do both at the same time, the only way I know of is
>through ZoomWindow. The tricky part is that you have to fiddle directly
>with some components of the Mac Window's data structure, and I'm not sure
>from reading the pod docs if you can do this via Perl's interface to the
>toolbox routines; the docs say that the window's GrafPtr should be
>considered read-only, but I don't know if this is enforced or just a
>suggestion.

Neat idea. I couldn't resist trying it. I find you can indeed set the
'stdState' record in the windows', grafPtr. The 'userState' (IM tells me)
is set when the window opens and is automatically updated whenever the
window is resized manually by the user. (Hence the name presumably). So it
is 'stdState' which should be set.

In the ordinary run of events when the mouse is clicked in the zoom box,
FindWindow() returns a 7 if the window is in the 'stdState', and an 8 if
the window is in the 'userState'. Hence you know which value to put for
PARTCODE in ZoomWindow(WINDOW, PARTCODE, FRONT).

If ZoomWindow() is used within a MacPerl Script (i.e. without using the
mouse) I don't think there is anyway to find out whether the window is in
the 'userState' of the 'stdState'. However you do know for certain that the
window is in the 'userState' when it opens, and it is possible to set up a
flag to keep track of zooms thereafter.

This scrap toggles the window between the two states every time a key is hit:

    $ptr->stdState(RECT);
    ...
    sub get_key {
        if ($n) { ZoomWindow($ptr, 7, 1); $n = 0 }
        else    { ZoomWindow($ptr, 8, 1); $n = 1 }
    }

(More work would need to be done to make the flag also aware of hits on the
zoom box of course.)

Note the 'stdState' is always what you set it to be in RECT, and the
'userState' is the window size and position in which it was last left.

Alan Fry




***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch