home *** CD-ROM | disk | FTP | other *** search
/ Software 2000 / Software 2000 Volume 1 (Disc 1 of 2).iso / utilities / u262.dms / in.adf / LISTINGS.RUN / gfa-basic / IDCMP_Test.LST
Encoding:
File List  |  1992-04-11  |  3.6 KB  |  124 lines

  1. '
  2. ' IDCMP Test. SCR 29/1/91.
  3. '
  4. ' IDCMP Flags - CLOSEWINDOW, NEWSIZE, DISKINSERTED, DISKREMOVED, MOUSEBUTTONS, MENUPICK
  5. ' Window Flags - REPORTMOUSE, RMBTRAP, WINDOWSIZING, WINDOWDRAG, WINDOWDEPTH, WINDOWCLOSE,
  6. ' SMARTREFRESH
  7. '
  8. OPENW #1,50,50,200,100,99082,527
  9. TITLEW #1,"GFA IDCMP Demo"
  10. '
  11. ' Intuition Menu constants.
  12. ' See also functions at program end.
  13. '
  14. nomenu%=&H1F
  15. noitem%=&H3F
  16. nosub%=&H1F
  17. menunull%=&HFFFF
  18. '
  19. DIM m$(50)                ! To hold the menu items
  20. RESTORE menustuff
  21. DO
  22.     READ m$(i%)            ! Read the items
  23.     EXIT IF m$(i%)="*"
  24.     INC i%
  25. LOOP
  26. m$(i%)=""                    ! GFA end of menu list marker
  27. MENU m$()                    ! Set menu
  28. MENU KEY 2,65            ! Amiga-A on Info
  29. MENU KEY 10,90        ! Amiga-Z on Menu 1 Item 2 Sub 1
  30. '
  31. done%=0
  32. windowptr%=WINDOW(1)    ! Get pointer to Window Structure for window #1
  33. ' Get mp_SigBit mask
  34. signalmask%=SHL(1,PEEK(LPEEK(windowptr%+86)+15))
  35. WHILE done%<>1
  36.     signals%=Wait(signalmask%)    ! Wait() until an IDCMP message appears
  37.     IF (signals% AND signalmask%)    ! Wake up if there are signals
  38.         REPEAT
  39.             message%=GetMsg(LPEEK(windowptr%+86))    ! Try to get a message...
  40.             IF message%<>0        ! If there's a message out there,
  41.                 class%={message%+20}    ! get all we need
  42.                 code%=CARD{message%+24}
  43.                 amousex%=WORD{message%+32}    ! (MOUSEX and MOUSEY are GFA keywords, btw)
  44.                 amousey%=WORD{message%+34}
  45.                 ~ReplyMsg(message%)    ! Reply promptly
  46.                 SELECT class%        ! Message Class -
  47.                 CASE 512        ! CLOSEWINDOW gadget
  48.                     PRINT "CLOSEWINDOW"
  49.                     ALERT 0,"Really Quit?",2,"Yes|No",done%    ! Quit on "Yes" button
  50.                 CASE 2            ! NEWSIZE
  51.                     PRINT "NEWSIZE ";
  52.                     newx&=WORD{windowptr%+8}
  53.                     newy&=WORD{windowptr%+10}
  54.                     PRINT newx&;", ";newy&
  55.                     SIZEW #1,newx&,newy&    ! Tell GFA about the size change.
  56.                 CASE 32768        ! DISKINSERTED
  57.                     PRINT "DISKINSERTED"
  58.                 CASE 65536        ! DISKREMOVED
  59.                     PRINT "DISKREMOVED"
  60.                 CASE 8            ! MOUSEBUTTONS
  61.                     SELECT code%        ! What did the left button do?
  62.                     CASE 104
  63.                         PRINT "LEFT BUTTON PRESSED"
  64.                         PRINT "at ";amousex%;", ";amousey%
  65.                     CASE 232
  66.                         PRINT "LEFT BUTTON RELEASED"
  67.                         PRINT "at ";amousex%;", ";amousey%
  68.                     ENDSELECT
  69.                 CASE 256        ! MENUPICK
  70.                     PRINT "MENUPICK ";
  71.                     IF code%<>menunull%    ! If a menu was selected for real
  72.                         mnum%=@menunum(code%)    ! Menu number
  73.                         minum%=@itemnum(code%)    ! Item number (if any)
  74.                         msnum%=@subnum(code%)    ! Subitem number (if any)
  75.                         PRINT "menu ";mnum%
  76.                         IF minum%<>noitem%    ! If menu has items (the usual case)
  77.                             PRINT "item ";minum%
  78.                             IF msnum%<>nosub%    ! If item has subitems (rarer)
  79.                                 PRINT "sub ";msnum%
  80.                             ENDIF
  81.                         ENDIF
  82.                     ELSE
  83.                         PRINT "no selection"    ! Right button clicked aimlessly
  84.                     ENDIF
  85.                 ENDSELECT
  86.             ENDIF
  87.         UNTIL message%=0        ! Until there are no more messages
  88.         REPEAT                    ! Clean out any messages which may have appeared
  89.             message%=GetMsg(LPEEK(windowptr%+86))    ! Read the messages...
  90.             IF message%<>0
  91.                 ~ReplyMsg(message%)    ! Then bin 'em.
  92.             ENDIF
  93.         UNTIL message%=0    ! Until there are REALLY no more messages
  94.     ENDIF                        ! End {IF (signals% AND signalmask%)}
  95. WEND                            ! Main loop - but no busy-waiting!
  96. MENU KILL
  97. CLOSEW #1                    ! Tidy up
  98. END                                ! Quit if done% was set
  99. '
  100. FUNCTION menunum(n%)    ! These have been lifted straight from "intuition.h"
  101.     RETURN (n% AND &H1F)
  102. ENDFUNC
  103. '
  104. FUNCTION itemnum(n%)
  105.     RETURN (SHR&(n%,5) AND &H3F)
  106. ENDFUNC
  107. '
  108. FUNCTION subnum(n%)
  109.     RETURN (SHR&(n%,11) AND &H1F)
  110. ENDFUNC
  111. '
  112. ' GFA Menu features.
  113. ' - before entry makes it ghosted
  114. ' ! before entry creates a submenu
  115. ' Spaces after some entries are there for Amiga-Key
  116. ' combinations.
  117. ' And yes, there is meant to be a comma at the end
  118. ' of the first two lines.
  119. '
  120. menustuff:
  121. DATA main, about, info     , test,
  122. DATA file , load ,- save , sub ,! sub0,! sub1     ,! sub2,
  123. DATA *
  124.