WINDOW.DEF 11 KB

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