[comp.sys.mac.programmer] Window Zooming

lef@raybed2.UUCP (LEE FYOCK) (02/01/90)

Does anyone have any code for window zooming?  I've been trying to
get a window to zoom, but I must not be doing something right.

I created a window of the correct type, and I receive inZoomOut
events when I click in it.  Am I supposed to diddle with the
WStateData in the DataHandle part of the WindowRecord?  I tried
to initialize the values, but had trouble dereferencing and
typecasting DataHandle.  I finally got something to compile by
dereferencing DataHandle to a pointer, 'casting that, and storing
some rectangles there.

Playing around in the Debugger shows that I _always_ receive
inZoomOut events, never inZoomIn.  When I get the event, I call
TrackBox and ZoomWindow.  The window just blinks.

Sorry for the lack of details, but the code's at home.  Any ideas?


---------------------------------------------------------------------------
Lee Fyock                 Advanced Systems Section
lef@raybed6.RAY.COM       Raytheon MSD

cc100aa@prism.gatech.EDU (Ray Spalding) (02/01/90)

In article <1453@raybed2.UUCP> lef@raybed2.UUCP (LEE FYOCK) writes:
>I created a window of the correct type, and I receive inZoomOut
>events when I click in it.  

There's no such thing.  You get mouseDown events, to which you should
respond by calling FindWindow.

>Am I supposed to diddle with the
>WStateData in the DataHandle part of the WindowRecord?

No, not for ordinary zooming of a standard zoom window.  Remove any
such code as it may be interfering with proper operation.

>Playing around in the Debugger shows that I _always_ receive
>inZoomOut events, never inZoomIn.  When I get the event, I call
>TrackBox and ZoomWindow.  The window just blinks.

Be sure you're passing the return value from FindWindow (that is,
either inZoomOut or inZoomIn) as the partCode argument to TrackBox
and ZoomWindow.  For ordinary zooming, your code does not need to
worry about which way you're going.
-- 
Ray Spalding, Office of Computing Services
Georgia Institute of Technology, Atlanta Georgia, 30332-0275
uucp:     ...!{allegra,amd,hplabs,ut-ngp}!gatech!prism!cc100aa
Internet: cc100aa@prism.gatech.edu

tim@hoptoad.uucp (Tim Maroney) (02/02/90)

In article <1453@raybed2.UUCP> lef@raybed2.UUCP (LEE FYOCK) writes:
>>I created a window of the correct type, and I receive inZoomOut
>>events when I click in it.  

In article <5544@hydra.gatech.EDU> cc100aa@prism.gatech.EDU (Ray Spalding)
writes:
>There's no such thing.  You get mouseDown events, to which you should
>respond by calling FindWindow.

Cut the guy some slack, ferpetesake.  He was just speaking in an
abbreviated way; it was still perfectly comprehensible and correct.

>>Am I supposed to diddle with the
>>WStateData in the DataHandle part of the WindowRecord?

>No, not for ordinary zooming of a standard zoom window.  Remove any
>such code as it may be interfering with proper operation.

Agreed; most software shouldn't need to mess with this.
-- 
Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com

"Satanic is merely the name they give to the behavior of those who would
 disrupt the orderly way in which men want to live."
    -- Gabrielle, THE VAMPIRE LESTAT, Anne Rice

oster@dewey.soe.berkeley.edu (David Phillip Oster) (02/02/90)

In article <10003@hoptoad.uucp> tim@hoptoad.UUCP (Tim Maroney) writes:
_>>>Am I supposed to diddle with the
_>>>WStateData in the DataHandle part of the WindowRecord?

_>>No, not for ordinary zooming of a standard zoom window.  Remove any
_>>such code as it may be interfering with proper operation.

_>Agreed; most software shouldn't need to mess with this.

No, until Apple gets its act together, _all_ software _should_ mess with
this, or someone should write an INIT to solve the problem once and for
all. Consider:

You are working on a Mac with two CRTs. You put a window on the second
screen, and click its zoom box. What you want is for the window to zoom to
the full size of the _second_ CRT, the one it is on. What you get is it
zooms to the full size of the CRT with the menu bar: it jerks out from
under the mouse to somewhere else entirely. This is particularly annoying
if you were working on a large screen, and your window has suddenly zipped
to a small one.

After a MoveWindow(), I compare the window's portRect (translated to
global coordinates) with the rectangles on the gDevice list, and adjust
its max zoom size appropriately for the device the window is mostly on.

Even if you don't care about this nicety, you should at least adjust the
maximum zoom out size  so that it is no bigger than the entire document
the user is working on.

--- David Phillip Oster            --  No, I come from Boston. I just work
Arpa: oster@dewey.soe.berkeley.edu --  in cyberspace.
Uucp: {uwvax,decvax}!ucbvax!oster%dewey.soe.berkeley.edu

minow@mountn.dec.com (Martin Minow) (02/04/90)

lef@raybed2.UUCP (Lee Fyock) asks how to handle window zoom events.
Here's a code fragment.  I don't remember where I copied it from
(possibly "How to Write Macintosh Software"):

void
do_mouse()
{
	WindowPtr		the_window;
	int			partcode;
	
	partcode = FindWindow(event.where, &the_window);	
	switch (partcode) {
	... other cases here ...
	case inZoomIn:
	case inZoomOut:
	    if (TrackBox(the_window, event.where, partcode))  {
		GrafPtr		save_port;
		
		GetPort(&save_port);
		SetPort(the_window);		
		EraseRect(&the_window->portRect);
		ZoomWindow(the_window, partcode, FALSE);
		InvalRect(&the_window->portRect);
		/*
		 * Do all the window specific things that are size-dependent,
		 * such as LSize.
		 */
		DrawGrowIcon(the_window);
		SetPort(save_port);
	    }
	    break;

It may possible to be more clever so you don't repaint the entire screen
when you change the window's size.  Also, I'm not certain whether the
GetPort/SetPort stuff is really needed.

Hope this helps.

Martin Minow
minow@thundr.enet.dec.com

tim@hoptoad.uucp (Tim Maroney) (02/06/90)

>In article <10003@hoptoad.uucp> tim@hoptoad.UUCP (Tim Maroney) writes:
>>>>Am I supposed to diddle with the
>>>>WStateData in the DataHandle part of the WindowRecord?
>
>>>No, not for ordinary zooming of a standard zoom window.
>
>>Agreed; most software shouldn't need to mess with this.

In article <34074@ucbvax.BERKELEY.EDU> oster@dewey.soe.berkeley.edu.UUCP
(David Phillip Oster) writes:
>No, until Apple gets its act together, _all_ software _should_ mess with
>this, or someone should write an INIT to solve the problem once and for
>all.

I'm game, but I don't have the hardware to test the code on.  How about
mailing me the code to walk the list and correct the window state data;
I'll package it into an INIT that patches MoveWindow, and send it back
to you for testing; then we can post the INIT with source code here.
Sounds pretty straightforward all around.

>Even if you don't care about this nicety, you should at least adjust the
>maximum zoom out size  so that it is no bigger than the entire document
>the user is working on.

Well, actually, if you do this, it will interfere with the INIT unless
the application does it once after every MoveWindow.
-- 
Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com

"Don't talk to me about disclaimers!  I invented disclaimers!"
    - The Censored Hacker