home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 113 / EnigmaAmiga113CD.iso / software / sviluppo / easygui_os12 / examples / easygui / testmulti_os12.e < prev    next >
Encoding:
Text File  |  2000-06-05  |  2.0 KB  |  74 lines

  1. -> testmulti.e - Simple (recursive) use of multi-window GUI support.
  2. -> (Note: Intuition gets a bit weird with lots of windows -- lockups or
  3. -> crashes with huge numbers of windows are not EasyGUI's fault...)
  4.  
  5. OPT PREPROCESS
  6.  
  7. -> RST: Added conditional EASY_OS12 support
  8. #define EASY_OS12
  9.  
  10. #ifdef EASY_OS12
  11.   MODULE 'tools/easygui_os12'
  12. #endif
  13. #ifndef EASY_OS12
  14.   OPT OSVERSION=37
  15.   MODULE 'tools/easygui'
  16. #endif
  17.  
  18. MODULE 'tools/exceptions'
  19.  
  20. RAISE "MEM" IF String()=NIL
  21.  
  22. DEF guis=1
  23.  
  24. PROC main() HANDLE
  25.   DEF mh=NIL
  26.   mh:=multiinit()
  27.   -> Start at level 0.
  28.   create(mh,0)
  29.   multiloop(mh)
  30. EXCEPT DO
  31.   cleanmulti(mh)
  32.   report_exception()
  33. ENDPROC
  34.  
  35. -> Add a new window to the group mh at level i.
  36. PROC add(level,gh:PTR TO guihandle) IS create(gh.mh,level)
  37.  
  38. -> Add a new window to the group mh at level i.
  39. PROC create(mh,level)
  40.   DEF s
  41.   -> Next level.
  42.   INC level
  43.   s:=StringF(String(10),'GUI \d',guis)
  44.   -> Got to NEW the gui since the same one is being used multiple times.
  45.   addmultiA(mh, s,
  46.             NEW [ROWS,
  47.               NEW [TEXT,'Multi GUI Test',NIL,TRUE,10],
  48.               NEW [COLS,
  49.                 NEW [NUM,level,'Level:',0,1],
  50.                 NEW [NUM,guis,'GUI:',0,1]
  51.                   ],
  52.               NEW [COLS,
  53.                     -> Recursive call to create() via add()!
  54.                 NEW [BUTTON,{add},'_Add',level,"a"],
  55.                 NEW [SPACE],
  56.                     -> Pressing the Quit button quits multiloop() and so
  57.                     -> then all windows are closed.
  58.                 NEW [BUTTON,0,'_Quit',0,"q"]
  59.                   ]
  60.                 ],
  61.             -> Open at a random position, with level as info.
  62.             [EG_LEFT,Rnd(400), EG_TOP,Rnd(400), EG_CLOSE,{close}, NIL])
  63.   -> Now another GUI.
  64.   INC guis
  65. ENDPROC
  66.  
  67. -> This function is called when the GUI close gadget is hit.
  68. -> (Hitting the close gadget closes only that window, unless it is the last.)
  69. PROC close(mh:PTR TO multihandle,info)
  70.   WriteF('GUIs left with open windows = \d\n',mh.opencount)
  71.   -> Is this the last open window?
  72.   IF mh.opencount=1 THEN quitgui(0) ELSE closewin(info)
  73. ENDPROC
  74.