home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / gfx / misc / imagefx_sdk / sas / scanlib / busy.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-26  |  1.9 KB  |  91 lines

  1. /*
  2.  * Lock user input from a window.  We take a clue from ASL and open
  3.  * an invisible Requester in the window in question.  This keeps us
  4.  * from mucking with the window gadget list, which causes problems
  5.  * in WBMode.
  6.  *
  7.  */
  8.  
  9. #include <exec/types.h>
  10. #include <exec/memory.h>
  11. #include <exec/execbase.h>
  12. #include <intuition/intuition.h>
  13. #include <clib/exec_protos.h>
  14. #include <clib/graphics_protos.h>
  15. #include <clib/intuition_protos.h>
  16.  
  17.  
  18. extern struct ExecBase *SysBase;
  19.  
  20.  
  21. struct Locker {
  22.    struct Window *Window;
  23.    struct Requester Request;
  24. };
  25.  
  26.  
  27. #define WAIT_HEIGHT  (16)
  28. #define WAIT_XO      (-6)
  29. #define WAIT_YO      (0)
  30.  
  31. /*
  32.  * This is a 2.0-style Clock...
  33.  */
  34. USHORT __chip WaitSprite[] =
  35.  {
  36.     0x0000,0x0000,
  37.     0x0400,0x07C0,0x0000,0x07C0,0x0100,0x0380,0x0000,0x07E0,
  38.     0x07C0,0x1FF8,0x1FF0,0x3FEC,0x3FF8,0x7FDE,0x3FF8,0x7FBE,
  39.     0x7FFC,0xFF7F,0x7EFC,0xFFFF,0x7FFC,0xFFFF,0x3FF8,0x7FFE,
  40.     0x3FF8,0x7FFE,0x1FF0,0x3FFC,0x07C0,0x1FF8,0x0000,0x07E0,
  41.     0x0000,0x0000,
  42.     };
  43.  
  44. void Busy (struct Window *w)
  45. {
  46.    if (SysBase->LibNode.lib_Version >= 39)
  47.       SetWindowPointer(w, WA_BusyPointer, TRUE, TAG_END);
  48.    else
  49.       SetPointer (w, WaitSprite, WAIT_HEIGHT, 16, WAIT_XO, WAIT_YO);
  50. }
  51.  
  52. APTR LockInput (struct Window *w)
  53. {
  54.    struct Requester *req;
  55.    struct Locker *lock;
  56.  
  57.    if (w == NULL) return(NULL);
  58.  
  59.    if (lock = AllocMem(sizeof(struct Locker), MEMF_CLEAR)) {
  60.  
  61.       lock->Window = w;
  62.  
  63.       req = &lock->Request;
  64.  
  65.       req->Flags = NOISYREQ;  /* we want mouse clicks */
  66.       req->LeftEdge = 0;
  67.       req->TopEdge = 0;
  68.       req->Width = 1;
  69.       req->Height = 1;
  70.       req->BackFill = ReadPixel(w->RPort, 0, 0);
  71.  
  72.       Busy(w);
  73.       Request(req, w);
  74.  
  75.       return((APTR)lock);
  76.    }
  77.    return(NULL);
  78. }
  79.  
  80. void UnlockInput (APTR alock)
  81. {
  82.    struct Locker *lock;
  83.  
  84.    if (lock = (struct Locker *)alock) {
  85.       EndRequest(&lock->Request, lock->Window);
  86.       ClearPointer(lock->Window);
  87.       FreeMem(lock, sizeof(struct Locker));
  88.    }
  89. }
  90.  
  91.