home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / forth / mac / 41 next >
Encoding:
Text File  |  1992-12-21  |  2.1 KB  |  67 lines

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!jvnc.net!netnews.upenn.edu!meded6.med.upenn.edu!user
  2. From: sorry no email address (Peters, Randolph)
  3. Newsgroups: comp.lang.forth.mac
  4. Subject: multi windows, pocket forth
  5. Message-ID: <sorry?no?email?address-211292102652@meded6.med.upenn.edu>
  6. Date: 21 Dec 92 15:39:34 GMT
  7. Sender: news@netnews.upenn.edu
  8. Followup-To: comp.lang.forth.mac
  9. Organization: Hospital of the University of Pennsylvania
  10. Lines: 54
  11. Nntp-Posting-Host: meded6.med.upenn.edu
  12.  
  13.  
  14. In regards to multiple windows in pocket forth, I figured out the answer to
  15. the question I asked last week; since there seem to be a few pocket
  16. forthers
  17. out there, I thought this post might be of general interest.
  18.  
  19. ( general use window words )
  20. : select ( windowptr -- ) 2>r ,$ a91f  ; ( _SelectWindow )
  21. : set    ( windowptr -- )   2>r ,$ a873 ; ( _SetPort )
  22. : show   ( windowptr -- ) 2>r ,$ a915 ;   ( _ShowWindow )
  23. : >front ( windowptr -- ) 2dup select set ;
  24.  
  25. : nuw 
  26.     0 0 2>r   128 >r   0 0 2>r   -1 s>d 2>r  
  27.     ( rstack: 0L resid 0L -1L )
  28.     ,$ a9bd  ( _GetNewWindow )
  29.     ( rstack: windowptr )
  30.     2r>  2dup show 2dup >front ;
  31.  
  32. 0 +md 2@      2constant w1 ( forth window )
  33. nuw           2constant w2 ( test window )
  34.  
  35. : d=  ( double1 double2 -- bool ) 
  36.    rot = rot rot = and ; 
  37.  
  38. : hello ." Hello" cr ;
  39. : goodbye ." Goodbye" cr ;
  40.  
  41. : evtwindow ( -- windowptr ) 150 +md 2@ ;
  42.  
  43. : myact ( bool -- )
  44.     if ( becoming active )
  45.          evtwindow w2 d= if   w2 >front    hello     then
  46.     else ( becoming inactive )
  47.          evtwindow w2 d= if   goodbye  w1 >front   then
  48.     then ;
  49.  
  50. page
  51.  
  52. ' myact 12 +md ! ( install new activate event handler )
  53.  
  54.  
  55. Please note that if you want to install event-loop code in the activate
  56. handler, then put it where "hello" goes above; it should be in the form 
  57. of a loop that exits when a deactivation event is posted (so you could
  58. also set a flag or something during activation and deactivation, which 
  59. will be tested inside the loop). This way, when your window is activated,
  60. the associated code will be invoked.
  61.  
  62.  
  63.  Randolph M. Peters
  64.  3rd Floor Silverstein Suite C
  65.  Hosp of the Univ of Pennsylvania
  66.  Philadelphia PA 19104
  67.