
#include "ZipGUI.h"



extern ZipGUI_Globals	g;



void DoDragWindow( EventRecord *myEvent, WindowRef myWindow )
{
	Rect	dragBounds;

dragBounds = (*GetGrayRgn())->rgnBBox;
DragWindow( myWindow, myEvent->where, &dragBounds );
} /* DoDragWindow */



void DoZoomWindow( EventRecord *myEvent, WindowRef myWindow, short windowPart )
{
	if ( TrackBox( myWindow, myEvent->where, windowPart ) ) {
		EraseRect( &myWindow->portRect );
		ZoomWindow( myWindow, windowPart, true );
		DoAdjustWindow( myWindow );
	}
} /* DoZoomWindow */




void DoGrowWindow( EventRecord *myEvent, WindowRef myWindow )
{
	long 		growResult;
	short		newWidth,
				newHeight;
	Rect		myLimitRect,
				oldViewRect;

	SetRect( &myLimitRect, kMinWidth, kMinHeight, kMaxWidth, kMaxHeight );
									
	growResult = GrowWindow( myWindow, myEvent->where, &myLimitRect );
	if ( growResult ) {
		oldViewRect = (*((DocumentPtr)myWindow)->docTxt)->viewRect;
		newWidth = LoWord( growResult );
		newHeight = HiWord( growResult );
		SizeWindow( myWindow, newWidth, newHeight, true );
		DoAdjustWindow( myWindow );
		SectRect( &oldViewRect, &(*((DocumentPtr)myWindow)->docTxt)->viewRect,
					&oldViewRect ); 
		ValidRect( &oldViewRect );
	}
} /* DoGrowWindow */




void DoGoAway( EventRecord *myEvent, WindowRef myWindow )
{
	if ( TrackGoAway( myWindow, myEvent->where ) ) {
		DoClose( myWindow );
		g.menuAdjust = true;
	}		
} /* DoGoAway */





void DoAdjustWindow( WindowRef myWindow )
{
	TEHandle	myTxtH;

	myTxtH = ((DocumentPtr)myWindow)->docTxt;
	MyGetViewRect( myWindow, &(*myTxtH)->viewRect );
	DoAdjustViewRect( myTxtH );
	DoAdjustScrollSizes( myWindow );
	DoAdjustScrollValues( myWindow );
	DoAdjustText( myWindow );
	InvalRect( &myWindow->portRect );
} /* DoAdjustWindow */


