Example #1
0
static PyObject *Drag_ZoomRects(PyObject *_self, PyObject *_args)
{
	PyObject *_res = NULL;
	OSErr _err;
	Rect fromRect;
	Rect toRect;
	SInt16 zoomSteps;
	ZoomAcceleration acceleration;
#ifndef ZoomRects
	PyMac_PRECHECK(ZoomRects);
#endif
	if (!PyArg_ParseTuple(_args, "O&O&hh",
	                      PyMac_GetRect, &fromRect,
	                      PyMac_GetRect, &toRect,
	                      &zoomSteps,
	                      &acceleration))
		return NULL;
	_err = ZoomRects(&fromRect,
	                 &toRect,
	                 zoomSteps,
	                 acceleration);
	if (_err != noErr) return PyMac_Error(_err);
	Py_INCREF(Py_None);
	_res = Py_None;
	return _res;
}
Example #2
0
void ZoomRect (Rect *smallrect, Rect *bigrect, Boolean zoomup) 
{
	#if USE_DRAG_MANAGER_FOR_ZOOMS
		if (gZoomOn)
		{
			if (zoomup)
				ZoomRects(smallrect,bigrect,10,kZoomNoAcceleration);
			else
				ZoomRects(bigrect,smallrect,10,kZoomNoAcceleration);
		}
	#else
		Fixed		factor;
		Rect		rect1, rect2, rect3, rect4;
		GrafPtr		savePort, deskPort;
		int			i;
		long        tm;

		if (gZoomOn)
		{
			GetPort (&savePort);
			OpenPort (deskPort = (GrafPtr) NewPtr (sizeof (GrafPort)));
			InitPort (deskPort);
			SetPort (deskPort);
			PenPat (&qd.gray);		//¥ Original, comment for black zoom.
		//	PenPat (&qd.black);		//¥ Uncomment for black zoom.
			PenMode (notPatXor);	//¥ Original, comment for black zoom.
		//	PenMode (patXor);		//¥ Uncomment for black zoom.
			if (zoomup) 
			{
				rect1 = *smallrect;
				factor = FixRatio (6, 5);
				fract = FixRatio (541, 10000);
			}
			else
			{
				rect1 = *bigrect;
				factor = FixRatio (5, 6);
				fract = ONE;
			}
			rect2 = rect1;
			rect3 = rect1;
			FrameRect (&rect1);
			for (i = 1; i <= ZOOMSTEPS; i++) 
			{
				rect4.left = Blend (smallrect->left, bigrect->left);
				rect4.right = Blend (smallrect->right, bigrect->right);
				rect4.top = Blend (smallrect->top, bigrect->top);
				rect4.bottom = Blend (smallrect->bottom, bigrect->bottom);
				FrameRect (&rect4);
				FrameRect (&rect1);
				rect1 = rect2;
				rect2 = rect3;
				rect3 = rect4;
				fract = FixMul (fract, factor);
				tm = TickCount (); // These two lines are a crude waitvbl
				while (tm == TickCount ());
			}
			FrameRect (&rect1);
			FrameRect (&rect2);
			FrameRect (&rect3);
			ClosePort (deskPort);
			DisposePtr ((Ptr) deskPort);
			PenNormal ();
			SetPort (savePort);
		}
	#endif
}