window.sl 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. % WINDOW.SL.10 28 March 83
  2. % derived from {DSK}WINDOW.PSL;1 4-MAR-83 16:25:00
  3. (glispconstants
  4. (screenxoffset -255 integer)
  5. (screenyoffset -255 integer)
  6. (screenxscale 256.0 real)
  7. (screenyscale 256.0 real)
  8. )
  9. (GLISPOBJECTS
  10. (MENU (listobject (ITEMS (LISTOF ATOM))
  11. (window window))
  12. MSG ((SELECT MENU-select RESULT ATOM)))
  13. (MOUSE ANYTHING)
  14. (grpos integer
  15. prop ((screenvalue ((self + screenxoffset) / screenxscale ))))
  16. (grvector (list (x grpos) (y grpos))
  17. supers (vector))
  18. (WINDOW (listobject (start grvector)
  19. (size grvector)
  20. (title string)
  21. (lastfilledline integer)
  22. (lastposition grvector))
  23. PROP ((leftmargin (left + 1))
  24. (rightmargin (right - 2)))
  25. MSG ((CLEAR window-clear)
  26. (OPEN window-open)
  27. (CLOSE window-close)
  28. (movetoxy window-movetoxy OPEN T)
  29. (INVERTAREA WINDOW-INVERTAREA)
  30. (MOVETO WINDOW-MOVETO OPEN T)
  31. (PRINTAT WINDOW-PRINTAT OPEN T)
  32. (printatxy window-printatxy)
  33. (PRETTYPRINTAT WINDOW-PRETTYPRINTAT)
  34. (UNPRINTAT WINDOW-UNPRINTAT OPEN T)
  35. (unprintatxy window-unprintatxy)
  36. (DRAWLINE WINDOW-DRAWLINE OPEN T)
  37. (drawlinexy window-drawlinexy OPEN T)
  38. (UNDRAWLINE WINDOW-UNDRAWLINE OPEN T)
  39. (undrawlinexy window-undrawlinexy OPEN T)
  40. (CENTEROFFSET WINDOW-CENTEROFFSET))
  41. supers (region) )
  42. )
  43. (GLISPGLOBALS
  44. (MOUSE MOUSE)
  45. )
  46. (glispconstants
  47. (windowcharwidth 8 integer)
  48. (windowlineyspacing 20 integer)
  49. )
  50. (setq mouse 'mouse)
  51. (setq gevmenuwindow nil)
  52. (setq menustart (a vector with x = 320 y = 0))
  53. % Initialize graphics routines.
  54. (dg window-init (w:window)
  55. (prog ()
  56. (graphics-init)
  57. (color-display)
  58. (set-color white)
  59. (set-line-style solid)
  60. (set-char-size (quotient 7.0 screenxscale) (quotient 16.0 screenyscale))
  61. ))
  62. % Done with graphics
  63. (dg window-term (w:window)
  64. (prog ()
  65. (graphics-term)))
  66. % Alias graphics function names without underline characters
  67. (de graphics-init () (graphics_init))
  68. (de graphics-term () (graphics_term))
  69. (de display-init (unit mode) (display_init unit mode))
  70. (de set-color (x) (set_color x))
  71. (de set-line-style (x) (set_line_style x))
  72. (de clear-display () (clear_display))
  73. (de set-char-size (w h) (set_char_size w h))
  74. (de set-text-rot (x y) (set_text_rot x y))
  75. (de set-display-lim (x0 x1 y0 y1) (set_display_lim x0 x1 y0 y1))
  76. (de set-viewport (x0 x1 y0 y1) (set_viewport x0 x1 y0 y1))
  77. (de init-9111 () (init_9111))
  78. (de sample-locator () (sample_locator))
  79. (de await-locator () (await_locator))
  80. (de color-display () (color_display))
  81. % Clear a graphics window.
  82. (dg window-clear (w:window)
  83. )
  84. % Open a graphics window.
  85. (dg window-open (w:window)
  86. (send w drawlinexy w:left w:bottom w:left w:top)
  87. (send w drawlinexy w:left w:top w:right w:top)
  88. (send w drawlinexy w:right w:top w:right w:bottom)
  89. (send w drawlinexy w:right w:bottom w:left w:bottom)
  90. )
  91. % Open a graphics window.
  92. (dg window-close (w:window)
  93. (send w undrawlinexy w:left w:bottom w:left w:top)
  94. (send w undrawlinexy w:left w:top w:right w:top)
  95. (send w undrawlinexy w:right w:top w:right w:bottom)
  96. (send w undrawlinexy w:right w:bottom w:left w:bottom)
  97. )
  98. % GSN 2-MAR-83 16:19
  99. (DG MOUSE-POSITIONIN (M:MOUSE W:WINDOW)
  100. (GETMOUSESTATE)(A VECTOR WITH X = (LASTMOUSEX W)
  101. Y = (LASTMOUSEY W)))
  102. % GSN 2-MAR-83 16:19
  103. (DG MOUSE-TESTBUTTON (M:MOUSE BUTTON:INTEGER)
  104. (GETMOUSESTATE)(NOT (ZEROP (LOGAND LASTMOUSEBUTTONS BUTTON))))
  105. % GSN 2-FEB-83 13:57
  106. (DG WINDOW-CENTEROFFSET (W:WINDOW V:VECTOR)
  107. (SEND W:REGION CENTEROFFSET V))
  108. % GSN 28-FEB-83 16:10
  109. (DG WINDOW-DRAWLINE (W:WINDOW FROM:grVECTOR TO:grVECTOR)
  110. (send w drawlinexy from:x from:y to:x to:y))
  111. (DG WINDOW-DRAWLINExy (W:WINDOW fromx:grpos fromy:grpos tox:grpos toy:grpos)
  112. (gdraw white solid fromx:screenvalue fromy:screenvalue
  113. tox:screenvalue toy:screenvalue))
  114. % GSN 28-FEB-83 16:58
  115. (DG WINDOW-INVERTAREA (W:WINDOW AREA:REGION)
  116. nil)
  117. % GSN 13-JAN-83 15:29
  118. (DG WINDOW-MOVETO (W:WINDOW POS:grVECTOR)
  119. (send w movetoxy pos:x pos:y))
  120. % Move to position specified as separate x and y coordinates.
  121. (dg window-movetoxy (w:window x:grpos y:grpos)
  122. (gmove x:screenvalue y:screenvalue))
  123. % GSN 2-MAR-83 13:58
  124. (DG WINDOW-PRETTYPRINTAT (W:WINDOW VALUE POSITION:grVECTOR)
  125. (set-color white)
  126. (send w moveto pos)
  127. (w:lastposition _ position)
  128. (gtext value))
  129. % GSN 13-JAN-83 16:25
  130. (DG WINDOW-PRINTAT (W:WINDOW S:STRING POS:grVECTOR)
  131. (set-color white)
  132. (send w moveto pos)
  133. (gtext s))
  134. (DG WINDOW-PRINTATxy (W:WINDOW S:STRING x:grpos y:grpos)
  135. (set-color white)
  136. (send w movetoxy x y)
  137. (gtext s))
  138. % GSN 28-FEB-83 16:11
  139. (DG WINDOW-UNDRAWLINE (W:WINDOW FROM:VECTOR TO:grVECTOR)
  140. (send w undrawlinexy from:x from:y to:x to:y))
  141. (DG WINDOW-unDRAWLINExy (W:WINDOW fromx:grpos fromy:grpos tox:grpos toy:grpos)
  142. (gdraw background solid fromx:screenvalue fromy:screenvalue
  143. tox:screenvalue toy:screenvalue))
  144. % GSN 13-JAN-83 16:24
  145. (DG WINDOW-UNPRINTAT (W:WINDOW S:STRING POS:grVECTOR)
  146. (set-color background)
  147. (send w moveto pos)
  148. (gtext s))
  149. (DG WINDOW-UNPRINTATxy (W:WINDOW S:STRING x:grpos y:grpos)
  150. (set-color background)
  151. (send w movetoxy x y)
  152. (gtext s))
  153. % Present a pop-up menu and select an item from it. GSN 14 March 83
  154. (dg menu-select (m:menu)
  155. (prog (maxw i n saveglq result)
  156. (if ~gevactiveflg then (geventer))
  157. (saveglq _ glquietflg)
  158. (glquiteflg _ t)
  159. (maxw _ 0)
  160. (for x in m:items do (maxw _ (max maxw x:pname:length)))
  161. (maxw _ (min maxw 20))
  162. (m:window _ (a window with start = menustart
  163. size = (a vector with x = (maxw + 5)* windowcharwidth
  164. y = (min (length m:items) 19) * windowlineyspacing)
  165. title = "Menu"))
  166. (send m:window open)
  167. (I _ 0)
  168. (for x in m:items do
  169. (i _+ 1)
  170. (send m:window printatxy (concat (gevstringify i)
  171. (concat (if i<10 then " " else " ")
  172. (gevstringify x)))
  173. 1 (m:window:height - i * windowlineyspacing) ))
  174. lp
  175. (prin2 "Menu:")
  176. (n _ (read))
  177. (if n is integer and n > 0 and n <= (length m:items)
  178. then (result _ (car (PNth m:items n))) (go out)
  179. elseif n = 'q then (result _ nil) (go out)
  180. else (prin1 n)
  181. (prin2 " ?")
  182. (terpri)
  183. (go lp) )
  184. out
  185. (setq glquietflg saveglq)
  186. (if ~gevactiveflg then (gevexit))
  187. (return result)
  188. ))