home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / dev / e / amiga_e / src / pd / blockinput.e < prev    next >
Text File  |  1992-09-02  |  3KB  |  149 lines

  1. /* blockinput.e (from p 207 of Libraries handbook, modified for E by 
  2.  * Trey Van Riper [jvanriper@uncavx.unca.edu])
  3.  */
  4.  
  5. /* blockinput.e -- program to demonstrate how to block the input from a 
  6.  * window using a minimal requester, and how to put up a busy pointer.
  7.  */
  8.  
  9. OPT OSVERSION=37
  10.  
  11. MODULE 'exec/types','intuition/intuition','exec/ports','exec/memory',
  12.        'utility/tagitem'
  13.  
  14. /*
  15.  * As far as I know, E doesn't let you put data directly in the
  16.  * chip RAM, so you have to CopyMem it from Fastram.  So....
  17.  */
  18.  
  19. DEF chippointer
  20.  
  21. /*
  22.  * beginWait()
  23.  *
  24.  * Clear the requester with InitRequester.  This makes a requester of
  25.  * width =0, height = 0, left = 0, top = 0; in fact, everything is zero.
  26.  * This requester will simply block input to the window until
  27.  * EndRequest is called.
  28.  *
  29.  * The pointer is set to a reasonable 4-color busy pointer, with proper offsets.
  30.  */
  31.  
  32. PROC beginWait(win, waitRequest)
  33.  
  34.  InitRequester(waitRequest)
  35.  IF Request(waitRequest, win)
  36.   SetPointer(win,chippointer, 16, 16, -6, 0)
  37.   SetWindowTitles(win,'Busy - Input Blocked', Not(0))
  38.   RETURN TRUE
  39.  ELSE
  40.   RETURN FALSE
  41.  ENDIF
  42.  
  43. ENDPROC
  44.  
  45. /* 
  46.  * endWait()
  47.  *
  48.  * Routine to reset the pointer to the system default, and remove the
  49.  * requester installed with beginWait().
  50.  */
  51.  
  52. PROC endWait(win, waitRequest)
  53.  
  54.  ClearPointer(win)
  55.  EndRequest(waitRequest, win)
  56.  SetWindowTitles(win,'Not Busy', Not(0))
  57.  
  58.  
  59. ENDPROC
  60.  
  61. /*
  62.  * processIDCMP()
  63.  *
  64.  * Wait for the user to close the window.
  65.  */
  66.  
  67. PROC processIDCMP (wintmp)
  68.  
  69.  DEF done, msg:PTR TO intuimessage, class, myreq:requester, tick_count,
  70.      temp:PTR TO mp,win:PTR TO window
  71.  
  72.  done:=FALSE
  73.  win:=wintmp
  74.  IF beginWait(win, myreq)
  75.   /*
  76.    * Insert code here for a window to act as the requester.
  77.    */
  78.   
  79.   /* We'll count down INTUITICKS, which come about ten times
  80.    * a second.  We'll keep the busy state for about three seconds.
  81.    */
  82.    tick_count := 30
  83.  ENDIF
  84.  temp := win.userport
  85.  WHILE Not(done)
  86.   Wait(Shl(1,temp.sigbit))
  87.   WHILE NIL <> (msg := GetMsg(win.userport))
  88.    class := msg.class
  89.    ReplyMsg(msg)
  90.    SELECT class
  91.     CASE IDCMP_CLOSEWINDOW
  92.      done := TRUE
  93.     CASE IDCMP_INTUITICKS
  94.      IF tick_count>0
  95.       DEC tick_count
  96.       IF tick_count = 0 THEN endWait(win,myreq)
  97.      ENDIF
  98.    ENDSELECT
  99.   ENDWHILE
  100.  ENDWHILE
  101. ENDPROC
  102.  
  103. PROC main()
  104.  DEF win:PTR TO window,waitpointer
  105.  
  106. waitpointer:=[$0000, $0000,
  107.  
  108.               $0400, $07C0,
  109.               $0000, $07C0,
  110.               $0100, $0380,
  111.               $0000, $07E0,
  112.               $07C0, $1FF8,
  113.               $1FF0, $3FEC,
  114.               $3FF8, $7FDE,
  115.               $3FF8, $7FBE,
  116.               $7FFC, $FF7F,
  117.               $7EFC, $FFFF,
  118.               $7FFC, $FFFF,
  119.               $3FF8, $7FFE,
  120.               $3FF8, $7FFE,
  121.               $1FF0, $3FFC,
  122.               $07C0, $1FF8,
  123.               $0000, $07E0,
  124.               
  125.               $0000, $0000]:INT
  126.  
  127. IF chippointer:=AllocVec(72,MEMF_CHIP)
  128.  CopyMemQuick(waitpointer,chippointer,72)
  129. ENDIF
  130.  
  131.  IF win:=OpenWindowTagList(NIL,
  132.                    [WA_IDCMP,IDCMP_CLOSEWINDOW OR IDCMP_INTUITICKS,
  133.                    WA_ACTIVATE, TRUE,
  134.                    WA_WIDTH, 320,
  135.                    WA_HEIGHT, 100,
  136.                    WA_CLOSEGADGET, TRUE,
  137.                    WA_DRAGBAR, TRUE,
  138.                    WA_DEPTHGADGET, TRUE,
  139.                    WA_SIZEGADGET, TRUE,
  140.                    WA_MAXWIDTH, Not(0),
  141.                    WA_MAXHEIGHT, Not(0)])
  142.  processIDCMP(win)
  143.  CloseWindow(win)
  144.  ENDIF
  145.  
  146. IF chippointer THEN FreeVec(chippointer)
  147.  
  148. ENDPROC
  149.