home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 106 / EnigmaAmiga106CD.iso / www / afc / afc-dir / afc_examples.lha / NodeMaster_Examples.lha / Examples / EasyGUI_Example.e < prev    next >
Text File  |  1997-09-09  |  3KB  |  102 lines

  1. /*
  2. ** NodeMaster_EGui.e
  3. **
  4. ** (C)1996/97 Amiga Foundation Classes
  5. **
  6. ** This code is placed in the Public Domain.
  7. ** It is intended FOR demostration of NodeMaster only.
  8. **
  9. ** Feel free of examine, modify AND DO whatever you want!
  10. **
  11. */
  12.  
  13. /*
  14. ** DESCRIPTION:
  15. **
  16. ** NodeMaster can HANDLE Exec Lists of everything.
  17. **
  18. ** Just TO show its power, you'll see a way of creating
  19. ** multiwindows application relying on Wouter's EasyGUI AND
  20. ** my NodeMaster. This application is quite complicated AND I'll try TO
  21. ** explain it in the better way I can. ;)
  22. */
  23. OPT OSVERSION = 37
  24.  
  25. MODULE 'afc/nodemaster',               -> This is OUR MODULE
  26.        'afc/explain_exception',
  27.        'tools/easygui'                    -> 'tools/easygui'... GUESS!
  28.  
  29. DEF nm:PTR TO nodemaster -> This is an hinstance of our NodeMaster
  30.  
  31. PROC main() HANDLE       -> Please, note: HANDLE keyword FOR EXCEPTIONS handling
  32.   NEW nm.nodemaster()    -> Here we setup our OBJECT.
  33.  
  34.   dogui()                -> we MUST have at least one gui!
  35.  
  36.   REPEAT                 -> We will hear FOR GUI events
  37.     multiwait()          -> (Of multiple windows ;) ...
  38.   UNTIL FALSE
  39.  
  40. EXCEPT DO                -> In CASE of some problems... (OR just TO quit)
  41.   explain_exception()
  42.   closeall()
  43.   END nm                 -> Remeber ALWAYS TO END a OBJECT!!!
  44.   CleanUp(0)             -> Let's keep things clean...
  45. ENDPROC
  46.  
  47. PROC dogui() HANDLE      -> This PROC creates a GUI on the WB screen
  48.   DEF gh=NIL:PTR TO guihandle -> a guihandle (NOTE: It is LOCAL! ;)
  49.  
  50.   gh:=guiinitA('NEW EasyGUI Window!',
  51.               [EQROWS,
  52.                 [SBUTTON, {dogui}, 'Create!'],  -> This button just call dogui() again!
  53.                 [BAR],
  54.                 [SBUTTON, {do_quit},'Quit!']   -> This will quit ALL!
  55.               ])
  56.  
  57.   nm.add(gh)     -> Here we add this GUI_handle TO our NodeMaster OBJECT
  58.   Wait(gh.sig)   -> AND wait FOR this window's first signal
  59.  
  60. EXCEPT           -> In CASE of any error
  61.   remgui(gh)     -> we remove THIS window from thje Windows LIST
  62.   ReThrow()      -> AND rethrow() error one level up!
  63. ENDPROC
  64.  
  65. PROC multiwait()  -> This is one of the most important PROCS!
  66.   DEF gh:PTR TO guihandle -> Another LOCAL gui_handle var!
  67.   DEF res                 -> Here we store Window event value...
  68.  
  69.   IF nm.first()   -> Let's start from the first GUI_handler we have stored...
  70.     REPEAT
  71.       gh:=nm.obj()  -> Here we set our gh TO original GUI_handler
  72.       res:=guimessage(gh) -> We get one message
  73.       IF res>=0           -> AND eventually close this GUI window
  74.         remgui(gh)
  75.       ENDIF
  76.     UNTIL nm.succ() = FALSE  -> Now we JUMP TO the next one
  77.   ENDIF
  78. ENDPROC
  79.  
  80. PROC do_quit() IS Raise("END!")
  81.  
  82. PROC closeall() -> This PROC just close ALL opened windows
  83.  
  84.   IF nm.first() -> We start from the first
  85.     REPEAT
  86.       cleangui(nm.obj())    -> we clear things up
  87.     UNTIL nm.succ() = FALSE  -> AND get the next
  88.   ENDIF
  89. ENDPROC
  90.  
  91. PROC remgui(gh:PTR TO guihandle) -> This PROC remove just one desired gui
  92.   IF nm.first()                  -> Here we scan LIST from the first
  93.     REPEAT
  94.       IF gh = nm.obj()           -> IF the current item is exactly the one we want
  95.         nm.del()                 -> We remove the item from the LIST
  96.         cleangui(gh)             -> AND clear the interface
  97.         RETURN                   -> THEN exit without ending the LOOP
  98.       ENDIF
  99.     UNTIL nm.succ() = FALSE      -> Here we look FOR the next item...
  100.   ENDIF
  101. ENDPROC
  102.