home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / progrmng / xlisp2.sit / glue.lsp < prev    next >
Encoding:
Lisp/Scheme  |  1985-11-08  |  5.3 KB  |  252 lines

  1.  
  2. ;            GLUE.LSP 1.0
  3. ;            
  4. ;    "Glue" functions for the toolbox call supported by XLISP 1.5b.
  5.  
  6. ;
  7. ;   This is a rough and very incomplete description of the toolbox
  8. ;   facilities available.  Please send corrections and suggestions
  9. ;   to me by easyplex on CIS (George Acton 73026,2663), or to David
  10. ;   Betz at his board (603-623-1711).
  11. ;
  12.  
  13. ;   THE 1.5b GRAPHICS WINDOW
  14. ;
  15. ;   The current version of XLISP has a number of toolbox calls 
  16. ;   implemented in a separate graphics window.  The global 
  17. ;   *graphics-window* holds a pointer to that window for the
  18. ;   toolbox calls.  When one of the built-in graphics functions is
  19. ;   executed, the graphics output is sent to that window and the
  20. ;   current window is reset to the *command-window* on exit.
  21. ;   
  22.     
  23. ;
  24. ;      XLISP GLUE
  25. ;
  26.  
  27. ;
  28. ;   ClearScreen -- defines screen as rectangle, then erases
  29. ;
  30. (defun ClearScreen (&aux screen)
  31.        (setq screen (NewPtr 8))
  32.        (SetRect screen 0 0 512 342)
  33.        (EraseRect screen) ) 
  34.  
  35. ;
  36. ;   simple event manager -- responds to mouse and keyboard
  37. ;
  38. (defun event-man ()
  39.        (prog (result *mou*)
  40.              (setq *mou* (NewPtr 4))
  41.              loop
  42.          (setq result (event-loop *mou*))
  43.          (print result)
  44.          (go loop)) )
  45.  
  46. (defun event-loop (*mou*)
  47.        (prog (ch)
  48.              loop
  49.              (cond ((= (Button) 256)
  50.                (GetMouse *mou*)
  51.                (return (list 'mouse 
  52.                           (peek *mou*) 
  53.                           (peek (+ 2 *mou*)) )) )
  54.          ((setq ch (read-char-no-hang))
  55.              (return (list 'key ch)) )
  56.          (t (go loop)) ) )  )
  57.        
  58. ;
  59. ;       TOOLBOX GLUE  -- keyed to Chernicoff
  60. ;
  61.  
  62. ;
  63. ;   2.2.1 Single Bit Access   
  64. ;
  65. (defun BitTst (ptr offset) 
  66.        (toolbox-16 #xA85D (LoWord ptr) (HiWord ptr)
  67.                           (LoWord offset) (HiWord offset) ) )
  68.  
  69. ;
  70. ;
  71. ;   Word Access -- duplicates HiWord and LoWord 2.2.3
  72. ;
  73. ;    NB HiWord and LoWord are implemented as primitives in XLISP 1.5b.
  74. ;
  75. (defun HiBytes (x)
  76.        (/ x 65536))
  77.        
  78. (defun LoWord (x)
  79.        (rem x 65536))
  80.  
  81. ;
  82. ;   4.1.1 Points
  83. ;
  84. (defun SetPt (pt hc vc)
  85.        (toolbox #xA880 (LoWord pt) (HiWord pt) hc vc) )
  86.        
  87. ;
  88. ;   4.1.2 Rectangles
  89. ;
  90. (defun SetRect (rect left top right bottom)
  91.        (toolbox #xA8A7 (LoWord rect) (HiWord rect) left top right bottom)) 
  92.        
  93. ;
  94. ;   4.1.5 Regions
  95. ;
  96. (defun NewRgn ()
  97.        (toolbox-32 #xA8D8) )
  98.        
  99. (defun DisposeRgn (rgn)
  100.        (toolbox #xA8D9 (LoWord rgn) (HiWord rgn)) )
  101.  
  102. (defun OpenRgn (rgn)
  103.        (toolbox #xA8DA (LoWord rgn) (HiWord rgn)) )
  104.  
  105. (defun CloseRgn (rgn)
  106.        (toolbox #xA8DB (LoWord rgn) (HiWord rgn)) )
  107.  
  108. ;
  109. ;   5.2.2 Setting Pen Characteristics
  110. ;
  111. (defun PenSize (h w)
  112.        (toolbox #xA89B h w) )
  113.  
  114. (defun PenPat (pat)
  115.        (toolbox #xA89D pat) )
  116.        
  117. (defun PenMode (mode)
  118.        (toolbox #xA89C mode) )
  119.  
  120. (defun PenNormal ()
  121.        (toolbox #xA89E) )
  122.        
  123. ;
  124. ;   5.2.3 Hiding and Showing the Pen
  125. ;
  126. (defun HidePen ()
  127.        (toolbox #xA896) )       
  128.  
  129. (defun ShowPen ()
  130.        (toolbox #xA897) )
  131.        
  132. ;
  133. ;   5.2.4 Drawing Lines
  134. ;
  135. (defun GetPen (pt)
  136.        (toolbox #xA89A (LoWord pt) (HiWord pt)) )
  137.        
  138. (defun Move (x y)
  139.        (toolbox #xA894 x y))
  140.  
  141. (defun MoveTo (x y)
  142.        (toolbox #xA893 x y))
  143.  
  144. (defun Line (x y)
  145.        (toolbox #xA892 x y))
  146.  
  147. (defun LineTo (x y)
  148.        (toolbox #xA891 x y))
  149.  
  150. ;
  151. ;   5.3.2 Drawing Rectangles
  152. ;
  153. (defun FrameRect (rect)
  154.        (toolbox #xA8A1 (LoWord rect) (HiWord rect)) )
  155.  
  156. (defun PaintRect (rect)
  157.        (toolbox #xA8A2 (LoWord rect) (HiWord rect)) )
  158.  
  159. (defun EraseRect (rect)
  160.        (toolbox #xA8A3 (LoWord rect) (HiWord rect)) )
  161.  
  162. (defun InvertRect (rect)
  163.        (toolbox #xA8A4 (LoWord rect) (HiWord rect)) )
  164.  
  165. ;
  166. ;   5.3.4 Drawing Ovals
  167. ;
  168. (defun FrameOval (rect)
  169.        (toolbox #xA8B7 (LoWord rect) (HiWord rect)) )
  170.  
  171. (defun PaintOval (rect)
  172.        (toolbox #xA8B8 (LoWord rect) (HiWord rect)) )
  173.  
  174. (defun EraseOval (rect)
  175.        (toolbox #xA8B9 (LoWord rect) (HiWord rect)) )
  176.  
  177. (defun InvertOval (rect)
  178.        (toolbox #xA8BA (LoWord rect) (HiWord rect)) )
  179.  
  180.  
  181. ;
  182. ;   5.3.7 Drawing Regions
  183. ;
  184. (defun FrameRgn (rgn)
  185.        (toolbox #xA8D2 (LoWord rgn) (HiWord rgn)) )
  186.        
  187. (defun EraseRgn (rgn)
  188.        (toolbox #xA8D4 (LoWord rgn) (HiWord rgn)) )
  189.  
  190. ;
  191. ;   8.3.2 Setting Text Characteristics
  192. ;
  193. (defun TextFont (x)
  194.        (toolbox #xA887 x))
  195.       
  196. (defun TextSize (x)
  197.        (toolbox #xA88A x))
  198.        
  199. (defun TextFace (x)
  200.        (toolbox #xA888 x))
  201.         
  202. (defun TextMode (x)
  203.        (toolbox #xA889 x))
  204.        
  205. ;
  206. ;   8.3.3 Drawing Text
  207. ;
  208. (defun DrawChar (x)
  209.        (toolbox #xA883 x))
  210.  
  211. ;
  212. ;   Chernikoff -- vol. 2
  213. ;
  214.  
  215. ;
  216. ;   Event Management
  217. ;
  218. ;   The XLISP event loop uses the toolbox call GetNextEvent, which clears
  219. ;   the event queue.  It is possible to read the mouse and keyboard
  220. ;   buffers directly.  Also, the XLISP function (get-char-no-hang) can be
  221. ;   used to examine the keyboard.
  222. ;
  223.  
  224. ;
  225. ;   2.4.1 Reading the Mouse Position
  226. ;
  227. (defun GetMouse (pt)
  228.        (toolbox #xA972 (LoWord pt) (HiWord pt)) )
  229.        
  230. ;
  231. ;   2.4.2 Reading the Mouse Button
  232. ;
  233. (defun Button ()
  234.        (toolbox-16 #xA974) )
  235.  
  236. ;
  237. ;   1.6.1 Reading the Keyboard
  238. ;
  239. ;    keymap: 16 bytes
  240. ;    global: $174
  241. ;
  242. (defun GetKeys (keymap)
  243.        (toolbox #xA976 (LoWord keymap) (HiWord keymap)) )
  244. ;
  245. ;   2.8.1 Beeping the Speaker
  246. ;
  247. ;    NB mistake in Chernikoff.  Arg is ticks, not secs.
  248. ;
  249. (defun Sysbeep (n)
  250.        (toolbox #xA9C8 n))
  251.