window.def 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. (* Copyright (C) 1987 Jensen & Partners International *)
  2. DEFINITION MODULE Window;
  3. (* Window Management *)
  4. CONST
  5. ScreenWidth = 80;
  6. ScreenDepth = 25;
  7. PaletteSize = 10;
  8. PaletteMax = PaletteSize-1;
  9. TYPE
  10. WinType = POINTER TO WinDescriptor;
  11. RelCoord = CARDINAL;
  12. AbsCoord = CARDINAL;
  13. Color = ( Black, Blue, Green, Cyan,
  14. Red, Magenta, Brown, LightGray,
  15. DarkGray, LightBlue, LightGreen, LightCyan,
  16. LightRed, LightMagenta, Yellow, White );
  17. PaletteRange = SHORTCARD [ 0..PaletteMax ];
  18. TitleStr = ARRAY[0..ScreenWidth-1] OF CHAR;
  19. FrameStr = ARRAY[0..8] OF CHAR; (* Characters for frame *)
  20. (* 0 1 2 *)
  21. (* 3 4 *)
  22. (* 5 6 7 *)
  23. WinDef = RECORD
  24. X1,Y1,
  25. X2,Y2 : AbsCoord; (* outer co-ordinates of
  26. opposite corners *)
  27. Foreground,
  28. Background : Color; (* not used if Palette *)
  29. CursorOn : BOOLEAN; (* if cursor active *)
  30. WrapOn : BOOLEAN; (* if EOL wrap enabled *)
  31. Hidden : BOOLEAN; (* if window on view *)
  32. FrameOn : BOOLEAN; (* if frame *)
  33. FrameDef : FrameStr; (* only used if frame *)
  34. FrameFore,
  35. FrameBack : Color; (* only used if frame
  36. and not Palette Window *)
  37. END;
  38. TitleMode = ( NoTitle,
  39. LeftUpperTitle,CenterUpperTitle,RightUpperTitle,
  40. LeftLowerTitle,CenterLowerTitle,RightLowerTitle );
  41. CONST
  42. SingleFrame = FrameStr('ÚÄ¿³³ÀÄÙ') ;
  43. DoubleFrame = FrameStr('ÉÍ»ººÈͼ') ;
  44. FullScreenDef = WinDef ( 0,0, ScreenWidth-1,ScreenDepth-1,
  45. White,Black,TRUE,TRUE,FALSE,FALSE,
  46. ' ',Black,Black );
  47. VAR
  48. FullScreen : WinType;
  49. PROCEDURE Open(WD: WinDef) : WinType;
  50. (*
  51. creates a new window, clears the window, and puts it on view
  52. on top of any existing windows
  53. *)
  54. PROCEDURE SetTitle( W : WinType;
  55. Title : ARRAY OF CHAR;
  56. Mode : TitleMode);
  57. (*
  58. updates the window title within the window frame,
  59. positioning it in the position defined by the title mode
  60. *)
  61. PROCEDURE SetFrame( W : WinType;
  62. Frame : FrameStr;
  63. Fore, Back : Color);
  64. (*
  65. Changes the frame around the specified window,
  66. redisplaying title if required
  67. *)
  68. PROCEDURE Use(W: WinType);
  69. (*
  70. Causes all subsequent output (by the current process)
  71. to appear in the specified Window
  72. NB does not have to be Top Window (or in fact on the screen at all)
  73. *)
  74. PROCEDURE PutOnTop(W : WinType);
  75. (*
  76. Puts the specified window on the top of the window stack,
  77. ensuring that it is fully visible.
  78. If this results in other windows becoming obscured then a buffer
  79. is allocated for each of these windows.
  80. All otherwise undirected output (i.e. with no Use) will appear
  81. within this window.
  82. *)
  83. PROCEDURE PutBeneath(W: WinType; WA: WinType);
  84. (*
  85. Puts window W beneath window WA
  86. *)
  87. PROCEDURE Hide(W: WinType);
  88. (*
  89. Removes window from the Window stack and also the screen,
  90. placing the windows contents in a buffer for possible re-display later.
  91. Uncovers obscured windows.
  92. *)
  93. PROCEDURE Change(W: WinType; X1,Y1,X2,Y2: AbsCoord);
  94. (*
  95. Changes the size and/or position of the specified window.
  96. The contents of the window will be moved with it.
  97. *)
  98. PROCEDURE SnapShot;
  99. (*
  100. Updates the Window buffer from the screen
  101. only works with non-palette windows
  102. To capture the screen,
  103. first Open should be used with Hidden set in WinDef,
  104. then SnapShot can be called to capture the screen contents
  105. then PutOnTop can be used to 'unhide' the window.
  106. *)
  107. PROCEDURE Close(VAR W: WinType);
  108. (*
  109. Removes the specified window from the screen,
  110. deletes window descriptor and
  111. de-allocates any buffers previously allocated.
  112. Also sets W to Nil to prevent further use of window.
  113. *)
  114. PROCEDURE Used(): WinType;
  115. (*
  116. Returns the current window being used for output for this process.
  117. If no window assigned by Use then returns Top.
  118. *)
  119. PROCEDURE Top() : WinType;
  120. (*
  121. Returns the current top Window.
  122. *)
  123. PROCEDURE ObscuredAt(W : WinType; X,Y: RelCoord) : BOOLEAN;
  124. (*
  125. Returns if the specified window is obscured at the specified position.
  126. *)
  127. PROCEDURE At(X,Y: AbsCoord) : WinType;
  128. (*
  129. Returns the window displayed at the absolute position X,Y
  130. *)
  131. PROCEDURE SetProcessLocks(LockProc,UnlockProc: PROC);
  132. (*
  133. Enables process locking in window system
  134. *)
  135. PROCEDURE GotoXY(X,Y: RelCoord);
  136. (*
  137. Sets the current X Y position of the window currently being used
  138. *)
  139. PROCEDURE WhereX() : RelCoord;
  140. (*
  141. Returns the current X position of the window currently being used
  142. *)
  143. PROCEDURE WhereY() : RelCoord;
  144. (*
  145. Returns the current Y position of the window currently being used
  146. *)
  147. PROCEDURE ConvertCoords( W : WinType;
  148. X,Y : RelCoord;
  149. VAR XO,YO : AbsCoord);
  150. (*
  151. Converts window relative co-ordinates to absolute screen co-ordinates
  152. *)
  153. PROCEDURE Clear;
  154. (*
  155. clears the current window
  156. *)
  157. PROCEDURE CursorOn;
  158. (*
  159. Turns the cursor on in the current window.
  160. NB cursor is only visible when turned on AND window is on top.
  161. *)
  162. PROCEDURE CursorOff;
  163. (*
  164. Turns the cursor off in the current window.
  165. *)
  166. PROCEDURE InsLine;
  167. (*
  168. Inserts a blank line at the cursor position
  169. scrolling the screen down beneath
  170. *)
  171. PROCEDURE DelLine;
  172. (*
  173. Deletes the line at the cursor position
  174. scrolling the screen up below
  175. *)
  176. PROCEDURE ClrEol;
  177. (*
  178. Clears from the cursor to the end of line
  179. *)
  180. PROCEDURE TextColor(c: Color);
  181. (*
  182. Sets the text foreground color of the current window
  183. *)
  184. PROCEDURE TextBackground(c: Color);
  185. (*
  186. Sets the text background color of the current window
  187. *)
  188. PROCEDURE DirectWrite(X,Y : RelCoord; (* start coords *)
  189. A : ADDRESS; (* address of char array *)
  190. Len : CARDINAL); (* length to be written *)
  191. (*
  192. Writes directly to current window at the specified X,Y coordinates
  193. with no check for special (i.e. control) chars or eol wrap.
  194. *)
  195. PROCEDURE SetWrap(on: BOOLEAN);
  196. (*
  197. Enables/disables automatic wrap when writing beyond the right end of
  198. the current window
  199. *)
  200. PROCEDURE Info(W: WinType; VAR WD: WinDef);
  201. (* gets information for the specified window *)
  202. (* ------------------------------------------------------------------- *)
  203. (* Palette Windows *)
  204. (* --------------------------------------------------------------------*)
  205. TYPE
  206. PaletteColorDef = RECORD Fore,Back : Color END;
  207. PaletteDef = ARRAY PaletteRange OF PaletteColorDef;
  208. CONST
  209. NormalPaletteColor = 0;
  210. FramePaletteColor = 1;
  211. PROCEDURE PaletteOpen(WD : WinDef; Pal: PaletteDef) : WinType;
  212. (*
  213. Creates a new palette window, clears the window to NormalPaletteColor,
  214. draws the frame in FramePaletteColor and puts it on view on top of
  215. any existing windows,
  216. *)
  217. PROCEDURE SetPalette(W: WinType; Pal: PaletteDef);
  218. (*
  219. Changes the Palette of the specified window,
  220. redisplaying the changed colors
  221. *)
  222. PROCEDURE PaletteColor() : PaletteRange;
  223. PROCEDURE SetPaletteColor(pc: PaletteRange);
  224. PROCEDURE PaletteColorUsed(W: WinType; pc: PaletteRange) : BOOLEAN;
  225. (*
  226. Returns if color in use anywhere in the window W.
  227. Returns false if W not a palette window.
  228. *)
  229. (* Low level routines to read and write to the window buffer direct *)
  230. (* a single line at a time *)
  231. PROCEDURE (*$F*) RdBufferLn ( W : WinType; (* Source window *)
  232. X,Y : RelCoord; (* start co-ords *)
  233. Dest : ADDRESS; (* address of buffer *)
  234. Len : CARDINAL ); (* length in WORDs *)
  235. PROCEDURE (*$F*) WrBufferLn ( W : WinType; (* Dest window *)
  236. X,Y : RelCoord; (* start co-ords *)
  237. Src : ADDRESS; (* address of buffer *)
  238. Len : CARDINAL ); (* length in WORDs *)
  239. TYPE
  240. BufferPtr = POINTER TO ARRAY [0..ScreenWidth*ScreenDepth-1] OF CARDINAL ;
  241. WinDescriptor = RECORD (* Internal *)
  242. Guard : CARDINAL ;
  243. Next : WinType ;
  244. CursorChain : WinType ;
  245. WDef : WinDef ;
  246. XA,YA,XB,YB : AbsCoord ; (* inner window pane *)
  247. OWidth,ODepth : CARDINAL ; (* outer window *)
  248. Width, Depth : CARDINAL ; (* inner pane *)
  249. Title : POINTER TO TitleStr ;
  250. TMode : TitleMode ;
  251. CurrentX,
  252. CurrentY : RelCoord ;
  253. IsPalette : BOOLEAN ;
  254. PalAttr : ARRAY PaletteRange OF SHORTCARD ;
  255. CurPalColor : PaletteRange ;
  256. Buffer : BufferPtr ;
  257. UserRecord : ADDRESS ;
  258. END ;
  259. END Window.
  260.