[futurebasic] Re: [FB] Animated Cursor

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 2002 : Group Archive : Group : All Groups

From: Alain Pastor <apastor@...>
Date: Wed, 27 Feb 2002 04:27:45 +0100
Peter Bancroft wrote:
> 
> This is a repost from Jim who can't email the list.
> ____________________________________________________________
> 
> I throw in the towel .. I have a curser set of 7 Hour Glasses .. I need
> the code of an FN to use them for an Animated Color Cursor that I can
> insert as an internal FN in the Local FN that puts a very large Text
> document into memory before the FN breaks it into 32000 Char segments ..
> It takes a while and I want the cursor to animate during this time
> 

I don't know if it is a good advice, but perhaps animated cursor
could be realized with a time task, like in the program below (note
the CURSOR statement handles automatically color cursors).


'~Header

BEGIN RECORD TMTask
DIM qLink      AS ptr'QElemPtr 
DIM qType      AS short 
DIM tmAddr     AS proc'TimerUPP 
DIM tmCount    AS long 
DIM tmWakeUp   AS long 
DIM tmReserved AS long 
END RECORD

#DEFINE TMTaskPtr AS PTR 'TO TMTask
TOOLBOX InsTime (TMTaskPtr QElemPtr) `0x205F,0xA058
TOOLBOX PrimeTime (TMTaskPtr QElemPtr,long count) `0x201F,0x205F,0xA05A
TOOLBOX RmvTime (TMTaskPtr QElemPtr) `0x205F,0xA059
#IF CarbonLib
TOOLBOX FN NewTimerUPP(PTR) = PTR
#ENDIF

'~Globals

Begin Globals
Dim gCursorTask As TMTask
Dim gCursor     As Int
Dim gAppBusy    As Boolean
End Globals


'~Functions
/*
     This fn will install the Time task
*/
Local Fn SetCursorTask
gCursorTask.tmWakeUp   = 0
gCursorTask.tmReserved = 0
gCursorTask.tmAddr     = Proc "Cursor Task"'the procedure to call
#If CarbonLib
gCursorTask.tmAddr = Fn NewTimerUPP([gCursorTask.tmAddr + _FBprocToProcPtrOffset])
#Endif
Call InsTime(gCursorTask)
End Fn

/*
     When the gAppBusy flag is True this fn
     is called by the time task
*/
Local fn ChangeCursor
Def Cycle(_arrowCursor,_watchCursor,gCursor)
Cursor gCursor
End Fn

Local Fn DoSmartThings
Dim curTick As Long
curTick = Fn TickCount
Do
Until Fn TickCount > CurTick + 10*60
End fn
/*
     This fn initializes the program and
     install the Time task
*/
Local Fn InitProg
Window 1
Fn SetCursorTask'install our time task
Call PrimeTime(gCursorTask,1000)'start our time task
End Fn

'~Main Program
// Note: Handleevents is not required for a Time Task

Fn InitProg'set up window and time task

Print "I'm working"
/*
     gAppBusy will inform the time task that the
     app is gonna have a busy time doing splendid things
*/
gAppBusy = _zTrue
Fn DoSmartThings
/*
     Inform the time task now we are done
*/
gAppBusy = _false
Cursor _arrowCursor
Print "Click the mouse to end"

Do
Handleevents
Until Fn Button
Call RmvTime(gCursorTask)
End

/*
     The call back proc will update the cursor
     when the app is busy then it will tirelessly
     reschedule the same task
*/
"Cursor Task"
Enterproc Fn procCursorTask
If gAppBusy Then Fn ChangeCursor
Call PrimeTime(gCursorTask,300)
Exitproc

-- 

Alain

-----------------------------------------------------
FB^3 in Europe:  http://euro.futurebasic.com/
FB II Pouch:     http://www.pixmix.com/FB/outils.html
-----------------------------------------------------