home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 2 / DATAFILE_PDCD2.iso / utilities2 / desklib / Libraries / Icon / c / ClickWait < prev    next >
Encoding:
Text File  |  1993-04-11  |  1.1 KB  |  41 lines

  1. #include "Wimp.h"
  2. #include "WimpSWIs.h"
  3. #include "SWI.h"
  4. #include "Event.h"
  5.  
  6.  
  7. #define SWI_OS_ReadMonotonicTime 0x20042
  8.  
  9. extern void Icon_ClickWait(int waittime)
  10. {
  11.   static int      waitingonclick = FALSE;
  12.   int             time;
  13.   event_pollblock event;
  14.   event_pollmask  mask;
  15.  
  16.   if (waitingonclick)        /* Don't allow re-entrant call on this function */
  17.     return;
  18.  
  19.   waitingonclick = TRUE;
  20.  
  21.   SWI(0, 1, SWI_OS_ReadMonotonicTime, &time);
  22.   time += waittime;
  23.  
  24.   do
  25.   {
  26.     mask.value = 0;                           /* enable null polls */
  27.     Wimp_PollIdle(mask, &event, time);        /* Wait until time up or event */
  28.  
  29.     if (event.type != event_CLICK && event.type != event_NULL)
  30.       Event_Process(&event);                           /* Process this event */
  31.  
  32.   } while (event.type == event_CLICK || event.type == event_REDRAW);
  33.  
  34.   /*  Wait until not a button click event, and also ignore redraws as a
  35.    *  termination condition, as redraw is very likely (indenting a button)
  36.    *  on the first poll after the click which called us!
  37.    */
  38.  
  39.   waitingonclick = FALSE;
  40. }
  41.