home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / e / EasyGUI_v33b2.lha / Src / EasyGUI / testmulti.e < prev    next >
Text File  |  1997-02-13  |  2KB  |  60 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. MODULE 'tools/easygui', 'tools/exceptions'
  5.  
  6. RAISE "MEM" IF String()=NIL
  7.  
  8. DEF guis=1
  9.  
  10. PROC main() HANDLE
  11.   DEF mh=NIL
  12.   mh:=multiinit()
  13.   -> Start at level 0.
  14.   create(mh,0)
  15.   multiloop(mh)
  16. EXCEPT DO
  17.   cleanmulti(mh)
  18.   report_exception()
  19. ENDPROC
  20.  
  21. -> Add a new window to the group mh at level i.
  22. PROC add(level,gh:PTR TO guihandle) IS create(gh.mh,level)
  23.  
  24. -> Add a new window to the group mh at level i.
  25. PROC create(mh,level)
  26.   DEF s
  27.   -> Next level.
  28.   INC level
  29.   s:=StringF(String(10),'GUI \d',guis)
  30.   -> Got to NEW the gui since the same one is being used multiple times.
  31.   addmultiA(mh, s,
  32.             NEW [ROWS,
  33.               NEW [TEXT,'Multi GUI Test',NIL,TRUE,10],
  34.               NEW [COLS,
  35.                 NEW [NUM,level,'Level:',0,1],
  36.                 NEW [NUM,guis,'GUI:',0,1]
  37.                   ],
  38.               NEW [COLS,
  39.                     -> Recursive call to create() via add()!
  40.                 NEW [BUTTON,{add},'_Add',level,"a"],
  41.                 NEW [SPACE],
  42.                     -> Pressing the Quit button quits multiloop() and so
  43.                     -> then all windows are closed.
  44.                 NEW [BUTTON,0,'_Quit',0,"q"]
  45.                   ]
  46.                 ],
  47.             -> Open at a random position, with level as info.
  48.             [EG_LEFT,Rnd(400), EG_TOP,Rnd(400), EG_CLOSE,{close}, NIL])
  49.   -> Now another GUI.
  50.   INC guis
  51. ENDPROC
  52.  
  53. -> This function is called when the GUI close gadget is hit.
  54. -> (Hitting the close gadget closes only that window, unless it is the last.)
  55. PROC close(mh:PTR TO multihandle,info)
  56.   WriteF('GUIs left with open windows = \d\n',mh.opencount)
  57.   -> Is this the last open window?
  58.   IF mh.opencount=1 THEN quitgui(0) ELSE closewin(info)
  59. ENDPROC
  60.