Shardik,
Oh, yes, we did discuss the wait cursors back in June of 2011! For my own use, I'd like a 'wait cursor' for those times that are not as long as needing a progress bar but longer than 'is the program working?'. The added code of the Carbon version wasn't worth the effort but the simple Cocoa cursor change looked easy (one line).. but there wasn't any cursor that looked like waiting. I suppose I could use the 'full hand' to show waiting.
Wilbert's spinning progress bar is interesting. Actually that is pretty cool. I think that goes to the top of the list.
[later] Actually, the Mac 'spinning ball' (SPOD) is very effective at showing a wait state and over-writes any cursor anyway so trying to make a wait cursor is useless. If I need a wait indication then a progress gadget would seem to be the best option (like Wilbert's example).
Here is a Procedure to start a spinning wait animation and then stop it. It uses a ProgressGadget that is drawn (where ever you like - like the middle of the screen) and then is erased when the wait is over. It doesn't seem to matter that it appears on top of another gadget. I threw in some error checking but haven't really tried all the possibilities.
Code: Select all
Procedure Wait(wndw,state)
Static Indicator,efid,startwndw
If State=1 And startwndw=0 ; can't send start twice
startwndw=wndw
efid=ProgressBarGadget(#PB_Any, WindowWidth(wndw)/2, WindowHeight(wndw)/2, 0, 0, 0, 0) ; center of window
Indicator = GadgetID(efid)
CocoaMessage(0, Indicator, "setIndeterminate:", #YES)
CocoaMessage(0, Indicator, "setStyle:", 1)
CocoaMessage(0, Indicator, "setControlSize:", 1)
CocoaMessage(0, Indicator, "sizeToFit")
CocoaMessage(0, Indicator, "startAnimation:", #nil)
Else
If wndw=startwndw ; must be same as start window
CocoaMessage(0, Indicator, "stopAnimation:", #nil)
If IsGadget(efid) : FreeGadget(efid) : EndIf ; in case stop is sent before start
startwndw=0
EndIf
EndIf
EndProcedure
[addendum] The above only works because the ProgressGadget is drawn by Cocoa, if you use a normal ProgressGadget (with bars) it will not draw completely because it needs to go thru the event loop. You will get the bar but not the enclosing box.