[mod.mac.sources] MarqueeRect.c

dubois@uwmacc.UUCP (Paul DuBois) (07/10/86)

The procedure below can be used to achieve a marquee effect - that is,
the rectangle is framed with a dashed line, where the dashes move.
To use it, set up a rectangle, then call MarqueeRect repeatedly to
achieve the effect of motion.  A generalization to MarqueeRgn for
regions is straightforward.

The procedure is written in LightspeedC.

---
/* include a QuickDraw header file here */

Pattern		marqueePat = { 0x0f, 0x87, 0xc3, 0xe1, 0xf0, 0x78, 0x3c, 0x1e };


MarqueeRect (r)
Rect	*r;
{
PenState	p;
Byte		b;
int			i;

	GetPenState (&p);
	PenPat (marqueePat);
	PenMode (patCopy);
	FrameRect (r);
	SetPenState (&p);
	b = marqueePat[0];		/* shift pattern up for next call */
	for (i = 0; i < 7; ++i)		/* (could shift sideways instead) */
		marqueePat[i] = marqueePat[i+1];
	marqueePat[7] = b;
}