home *** CD-ROM | disk | FTP | other *** search
File List | 1992-04-11 | 3.6 KB | 124 lines |
- '
- ' IDCMP Test. SCR 29/1/91.
- '
- ' IDCMP Flags - CLOSEWINDOW, NEWSIZE, DISKINSERTED, DISKREMOVED, MOUSEBUTTONS, MENUPICK
- ' Window Flags - REPORTMOUSE, RMBTRAP, WINDOWSIZING, WINDOWDRAG, WINDOWDEPTH, WINDOWCLOSE,
- ' SMARTREFRESH
- '
- OPENW #1,50,50,200,100,99082,527
- TITLEW #1,"GFA IDCMP Demo"
- '
- ' Intuition Menu constants.
- ' See also functions at program end.
- '
- nomenu%=&H1F
- noitem%=&H3F
- nosub%=&H1F
- menunull%=&HFFFF
- '
- DIM m$(50) ! To hold the menu items
- RESTORE menustuff
- DO
- READ m$(i%) ! Read the items
- EXIT IF m$(i%)="*"
- INC i%
- LOOP
- m$(i%)="" ! GFA end of menu list marker
- MENU m$() ! Set menu
- MENU KEY 2,65 ! Amiga-A on Info
- MENU KEY 10,90 ! Amiga-Z on Menu 1 Item 2 Sub 1
- '
- done%=0
- windowptr%=WINDOW(1) ! Get pointer to Window Structure for window #1
- ' Get mp_SigBit mask
- signalmask%=SHL(1,PEEK(LPEEK(windowptr%+86)+15))
- WHILE done%<>1
- signals%=Wait(signalmask%) ! Wait() until an IDCMP message appears
- IF (signals% AND signalmask%) ! Wake up if there are signals
- REPEAT
- message%=GetMsg(LPEEK(windowptr%+86)) ! Try to get a message...
- IF message%<>0 ! If there's a message out there,
- class%={message%+20} ! get all we need
- code%=CARD{message%+24}
- amousex%=WORD{message%+32} ! (MOUSEX and MOUSEY are GFA keywords, btw)
- amousey%=WORD{message%+34}
- ~ReplyMsg(message%) ! Reply promptly
- SELECT class% ! Message Class -
- CASE 512 ! CLOSEWINDOW gadget
- PRINT "CLOSEWINDOW"
- ALERT 0,"Really Quit?",2,"Yes|No",done% ! Quit on "Yes" button
- CASE 2 ! NEWSIZE
- PRINT "NEWSIZE ";
- newx&=WORD{windowptr%+8}
- newy&=WORD{windowptr%+10}
- PRINT newx&;", ";newy&
- SIZEW #1,newx&,newy& ! Tell GFA about the size change.
- CASE 32768 ! DISKINSERTED
- PRINT "DISKINSERTED"
- CASE 65536 ! DISKREMOVED
- PRINT "DISKREMOVED"
- CASE 8 ! MOUSEBUTTONS
- SELECT code% ! What did the left button do?
- CASE 104
- PRINT "LEFT BUTTON PRESSED"
- PRINT "at ";amousex%;", ";amousey%
- CASE 232
- PRINT "LEFT BUTTON RELEASED"
- PRINT "at ";amousex%;", ";amousey%
- ENDSELECT
- CASE 256 ! MENUPICK
- PRINT "MENUPICK ";
- IF code%<>menunull% ! If a menu was selected for real
- mnum%=@menunum(code%) ! Menu number
- minum%=@itemnum(code%) ! Item number (if any)
- msnum%=@subnum(code%) ! Subitem number (if any)
- PRINT "menu ";mnum%
- IF minum%<>noitem% ! If menu has items (the usual case)
- PRINT "item ";minum%
- IF msnum%<>nosub% ! If item has subitems (rarer)
- PRINT "sub ";msnum%
- ENDIF
- ENDIF
- ELSE
- PRINT "no selection" ! Right button clicked aimlessly
- ENDIF
- ENDSELECT
- ENDIF
- UNTIL message%=0 ! Until there are no more messages
- REPEAT ! Clean out any messages which may have appeared
- message%=GetMsg(LPEEK(windowptr%+86)) ! Read the messages...
- IF message%<>0
- ~ReplyMsg(message%) ! Then bin 'em.
- ENDIF
- UNTIL message%=0 ! Until there are REALLY no more messages
- ENDIF ! End {IF (signals% AND signalmask%)}
- WEND ! Main loop - but no busy-waiting!
- MENU KILL
- CLOSEW #1 ! Tidy up
- END ! Quit if done% was set
- '
- FUNCTION menunum(n%) ! These have been lifted straight from "intuition.h"
- RETURN (n% AND &H1F)
- ENDFUNC
- '
- FUNCTION itemnum(n%)
- RETURN (SHR&(n%,5) AND &H3F)
- ENDFUNC
- '
- FUNCTION subnum(n%)
- RETURN (SHR&(n%,11) AND &H1F)
- ENDFUNC
- '
- ' GFA Menu features.
- ' - before entry makes it ghosted
- ' ! before entry creates a submenu
- ' Spaces after some entries are there for Amiga-Key
- ' combinations.
- ' And yes, there is meant to be a comma at the end
- ' of the first two lines.
- '
- menustuff:
- DATA main, about, info , test,
- DATA file , load ,- save , sub ,! sub0,! sub1 ,! sub2,
- DATA *
-