home *** CD-ROM | disk | FTP | other *** search
-
- /*⌐ Copyright 1988-1991 UserLand Software, Inc. All Rights Reserved.*/
-
-
-
- #include <applet.h>
- #include "cursor.h"
-
-
-
- int lastcursor = cursorisdirty;
-
- int beachballstate = cursorisbeachball4;
-
- int earthstate = cursorisearth7;
-
- long ticklastroll = 0;
-
-
-
-
- void setcursortype (newcursor) tycursortype newcursor; {
-
- /*
- 7/30/90 dmb: don't assume that cursor is never changed behind your back
- */
-
- register int cursor = newcursor;
- register CursHandle hcursor;
-
- /*
- if (cursor == lastcursor) /*no change%/
- return;
- */
-
- lastcursor = cursor; /*remember for next time*/
-
- if (cursor == cursorisdirty)
- return;
-
- if (cursor == cursorisarrow) {
-
- ticklastroll = 0; /*disable rolling until reinitialized*/
-
- SetCursor (&arrow);
-
- return;
- }
-
- hcursor = GetCursor (cursor);
-
- if (hcursor == nil) /*resource error*/
- return;
-
- SetCursor (*hcursor);
- } /*setcursortype*/
-
-
- void obscurecursor (void) {
-
- ObscureCursor ();
- } /*obscurecursor*/
-
-
- static boolean rollingtimerexpired (void) {
-
- register long tc;
-
- if (ticklastroll == 0) /*timer hasn't been initted*/
- return (false);
-
- tc = TickCount ();
-
- if ((ticklastroll + 6) > tc) /*a tenth of a second hasn't passed since last bump*/
- return (false);
-
- ticklastroll = tc; /*enough time has passed, reset the timer*/
-
- return (true);
- } /*rollingtimerexpired*/
-
-
- void initbeachball (void) {
-
- beachballstate = cursorisbeachball4;
-
- ticklastroll = TickCount ();
- } /*initbeachball*/
-
-
- void rollbeachball (void) {
-
- register int state;
-
- if (rollingtimerexpired ()) {
-
- state = beachballstate + 1;
-
- if (state > cursorisbeachball4) /*wrap around*/
- state = cursorisbeachball1;
-
- setcursortype (state);
-
- beachballstate = state;
- }
- } /*rollbeachball*/
-
-
- static boolean beachballcursor (void) {
-
- /*
- return true if the cursor is one of the beachballs.
-
- 12/26/90 dmb: new test accounts for the fact that, after an initbeachball,
- lastcursor won't be a beach ball until the timer has expired. this test
- will return true if either rolling cursor is active (earth or beach ball)
- */
-
- /*
- return ((lastcursor >= cursorisbeachball1) && (lastcursor <= cursorisbeachball4));
- */
-
- return (ticklastroll != 0);
- } /*beachballcursor*/
-
-
- void initearth (void) {
-
- earthstate = cursorisearth1;
-
- ticklastroll = TickCount ();
- } /*initearth*/
-
-
- void rollearth (void) {
-
- register int state;
-
- if (rollingtimerexpired ()) {
-
- state = earthstate + 1;
-
- if (state > cursorisearth7) /*wrap around*/
- state = cursorisearth1;
-
- setcursortype (state);
-
- earthstate = state;
- }
- } /*rollearth*/
-
-
-
-
-