Path: utzoo!attcan!uunet!zaphod.mps.ohio-state.edu!usc!apple!well!oster From: oster@well.sf.ca.us (David Phillip Oster) Newsgroups: comp.sys.mac.programmer Subject: Re: animated cursors Message-ID: <21373@well.sf.ca.us> Date: 26 Oct 90 14:24:23 GMT References: <14469@imag.imag.fr> Organization: Whole Earth 'Lectronic Link, Sausalito, CA Lines: 63 In article <14469@imag.imag.fr> baulac@imag.fr (Yves Baulac) writes: >How to get easily these nice animated watch cursors.I notice that the Finder has >a resource of type 'acur' where the different cursors IDs are specified. Call InitCursors(); early in your program. Call SpinCursor(1); periodically in your program. SpinCursor(-1) spins backwards. You might want to wrap SpinCursor(1); in a function to guarantee that SpinCursor(1); will not be called more frequently than 3 times a second. I wrote these. /* CursorList - these resources define the animated cursor data structure */ typedef union UHand { CursHandle h; struct { short i; short fill; } i; } UHand; typedef struct CursorList { short cnt; short current; UHand curs[1]; } CursorList, *CursorPList, **CursorHList; /* InitCursors - initialize our anuimated cursor structure */ void InitCursors(){ CursHandle h; short i; if(NIL != (acurs = (CursorHList) GetResource('acur', 0))){ for(i = 0; i < (**acurs).cnt; i++){ h = (CursHandle) GetCursor((**acurs).curs[i].i.i); HNoPurge((Handle) h); (**acurs).curs[i].h = h; } } } /* SpinCursor - transit the cursor to the next in the series. SpinCursor(1) spins forward SpinCursor(-1) spins backward */ void SpinCursor(delta)short delta;{ short c; if(acurs != NIL){ c = (**acurs).current + delta; if(c >= (**acurs).cnt){ c = 0; }else if(c < 0){ c = (**acurs).cnt-1; } (**acurs).current = c; SetCursor( *((**acurs).curs[c].h) ); } } -- -- David Phillip Oster - Note new signature. Old one has gone Bye Bye. -- oster@well.sf.ca.us = {backbone}!well!oster