VWINDOWS.MOD 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. IMPLEMENTATION MODULE VWindows;
  2. (*
  3. * REPERTOIRE
  4. * Release 1.6
  5. * By Charles Bradford and Cole Brecheen
  6. * (c) Copyright 1985-1992 PMI
  7. * Green Bay, Wisconsin
  8. * All rights reserved
  9. * (414) 468-6040
  10. *
  11. * $Header: D:/logfiles/mods/vwindows.mov 1.7 10 Mar 1991 15:34:42 coleb $
  12. *
  13. *)
  14. (*EntryDiag:
  15. IMPORT Diagnostics;
  16. :EntryDiag*)
  17. IMPORT LowLevel;
  18. IMPORT MsColors;
  19. IMPORT MsgBox1;
  20. IMPORT SmartScreen;
  21. IMPORT SYSTEM;
  22. IMPORT WindowPrims;
  23. VAR
  24. Initialized : BOOLEAN;
  25. handle: CARDINAL;
  26. TYPE
  27. AWindowHandle = POINTER TO CARDINAL;
  28. VAR
  29. NormalBackGround: MsColors.AColor;
  30. NormalAttrib: MsColors.AMonoAttribute;
  31. PROCEDURE NullScan( StrAddr: SYSTEM.ADDRESS ): CARDINAL;
  32. BEGIN
  33. RETURN LowLevel.ScanEQ( 32767, 0C, StrAddr );
  34. END NullScan;
  35. PROCEDURE AtrbSetToAtrb( TheSet: SmartScreen.AttributeSet ):
  36. SmartScreen.TextAttribute;
  37. BEGIN
  38. IF SmartScreen.plain IN TheSet THEN
  39. RETURN SmartScreen.plain;
  40. ELSIF SmartScreen.bold IN TheSet THEN
  41. RETURN SmartScreen.bold;
  42. ELSIF SmartScreen.underscored IN TheSet THEN
  43. RETURN SmartScreen.underscored;
  44. ELSIF SmartScreen.blinking IN TheSet THEN
  45. RETURN SmartScreen.blinking;
  46. ELSIF SmartScreen.ReverseVideo IN TheSet THEN
  47. RETURN SmartScreen.ReverseVideo;
  48. ELSE
  49. RETURN SmartScreen.plain;
  50. END;
  51. END AtrbSetToAtrb;
  52. PROCEDURE DefaultGetCursorHeight( TheWindow: AWindowHandle ):
  53. CARDINAL;
  54. BEGIN
  55. RETURN WindowPrims.GetCursorHeight();
  56. END DefaultGetCursorHeight;
  57. PROCEDURE DefaultSetCursorHeight( TheWindow: AWindowHandle;
  58. LinesInCursor: CARDINAL );
  59. BEGIN
  60. SmartScreen.SetCursorHeight( LinesInCursor );
  61. END DefaultSetCursorHeight;
  62. PROCEDURE DefaultGetCursorCoords( TheWindow: AWindowHandle; VAR
  63. x, y: CARDINAL );
  64. BEGIN
  65. WindowPrims.GetCursorCoords( x, y );
  66. END DefaultGetCursorCoords;
  67. PROCEDURE DefaultDrawBox( TheWindow: AWindowHandle; BoxChars: BoxStr;
  68. col1, row1, col2, row2 : CARDINAL);
  69. BEGIN
  70. WindowPrims.DrawThisBox( BoxStr(BoxChars), col1, row1,
  71. col2, row2 );
  72. END DefaultDrawBox;
  73. PROCEDURE DefaultDrawStr( TheWindow: AWindowHandle; x, y:
  74. CARDINAL; StrAddr: SYSTEM.ADDRESS; StrLength: CARDINAL );
  75. BEGIN
  76. IF StrLength = 0 THEN
  77. StrLength := NullScan( StrAddr );
  78. END;
  79. SmartScreen.AdrWriteAt( x, y, StrAddr, StrLength );
  80. END DefaultDrawStr;
  81. PROCEDURE DefaultClearPart( TheWindow: AWindowHandle;
  82. col1, row1, col2, row2: CARDINAL );
  83. BEGIN
  84. IF (col1 <= 1) AND (col2 >= SmartScreen.EndCol()) AND (row1 <= 1)
  85. AND (row2 >= SmartScreen.EndRow() ) THEN
  86. (*If they're clearing the whole window, we assume they're
  87. changing the NormalBackGround color.*)
  88. NormalBackGround := MsColors.AColor(SmartScreen.BackGround);
  89. NormalAttrib := MsColors.AMonoAttribute( AtrbSetToAtrb(
  90. SmartScreen.TextModeNow));
  91. END;
  92. SmartScreen.ClearPart( col1, row1, col2, row2 );
  93. END DefaultClearPart;
  94. PROCEDURE DefaultEndCol( TheWindow: AWindowHandle ): CARDINAL;
  95. BEGIN
  96. RETURN SmartScreen.EndCol();
  97. END DefaultEndCol;
  98. PROCEDURE DefaultEndRow( TheWindow: AWindowHandle ): CARDINAL;
  99. BEGIN
  100. RETURN SmartScreen.EndRow();
  101. END DefaultEndRow;
  102. PROCEDURE DefaultGotoXY( TheWindow: AWindowHandle; x, y: CARDINAL );
  103. BEGIN
  104. SmartScreen.GotoXY( x, y );
  105. END DefaultGotoXY;
  106. PROCEDURE DefaultReverseColors( TheWindow: AWindowHandle );
  107. BEGIN
  108. SmartScreen.ReverseColors();
  109. END DefaultReverseColors;
  110. PROCEDURE DefaultSetMonoAttr( TheWindow: AWindowHandle;
  111. NewMonoAttr : MsColors.AMonoAttribute );
  112. BEGIN
  113. SmartScreen.SetAttribOrColor( SmartScreen.ForeGround,
  114. SmartScreen.BackGround,
  115. SmartScreen.TextAttribute(NewMonoAttr) );
  116. END DefaultSetMonoAttr;
  117. PROCEDURE DefaultSetForeColor( TheWindow: AWindowHandle;
  118. NewForeColor : MsColors.AColor );
  119. BEGIN
  120. SmartScreen.SetAttribOrColor( SmartScreen.Colors( NewForeColor ),
  121. SmartScreen.BackGround, AtrbSetToAtrb(SmartScreen.TextModeNow) );
  122. END DefaultSetForeColor;
  123. PROCEDURE DefaultSetBackColor( TheWindow: AWindowHandle;
  124. NewBackColor : MsColors.AColor );
  125. BEGIN
  126. SmartScreen.SetAttribOrColor( SmartScreen.ForeGround,
  127. SmartScreen.Colors( NewBackColor ),
  128. AtrbSetToAtrb(SmartScreen.TextModeNow) );
  129. END DefaultSetBackColor;
  130. PROCEDURE DefaultMsgBox( TheWindow: AWindowHandle;
  131. TextPtr: SYSTEM.ADDRESS; CaptionPtr: SYSTEM.ADDRESS;
  132. WinType: CARDINAL ): CARDINAL;
  133. BEGIN
  134. RETURN MsgBox1.WinMsgBox( TheWindow, TextPtr, CaptionPtr, WinType );
  135. END DefaultMsgBox;
  136. PROCEDURE DefaultMonoAttr( TheWindow: AWindowHandle ):
  137. MsColors.AMonoAttribute;
  138. VAR
  139. TmpAttr : MsColors.AMonoAttribute;
  140. BEGIN
  141. (*
  142. TmpAttr := MsColors.AMonoAttribute(
  143. AtrbSetToAtrb(SmartScreen.TextModeNow) );
  144. RETURN TmpAttr;
  145. *)
  146. RETURN NormalAttrib;
  147. END DefaultMonoAttr;
  148. PROCEDURE DefaultForeColor( TheWindow: AWindowHandle ): MsColors.AColor;
  149. BEGIN
  150. RETURN MsColors.AColor( SmartScreen.ForeGround );
  151. END DefaultForeColor;
  152. PROCEDURE DefaultBackColor( TheWindow: AWindowHandle ): MsColors.AColor;
  153. BEGIN
  154. (* We need something that tells us what color to use in
  155. clearing the window, so we hijack this function for that
  156. purpose. Neither it nor the ForeColor function were
  157. particularly useful in their old roles because you
  158. should always know the colors in which you want to
  159. write. You don't need the window manager to tell you
  160. the colors in which you are writing. *)
  161. RETURN NormalBackGround;
  162. (*
  163. RETURN MsColors.AColor( SmartScreen.BackGround );
  164. *)
  165. END DefaultBackColor;
  166. PROCEDURE DefaultScrollVertically( TheWindow: AWindowHandle;
  167. col1, row1, col2, row2: CARDINAL; lines: INTEGER ): BOOLEAN;
  168. BEGIN
  169. WindowPrims.ScrollWindow( col1, row1, col2, row2, lines );
  170. RETURN TRUE;
  171. END DefaultScrollVertically;
  172. PROCEDURE DefaultScrollHorizontally( TheWindow: AWindowHandle;
  173. col1, row1, col2, row2: CARDINAL; lines: INTEGER ): BOOLEAN;
  174. BEGIN
  175. (*We don't have a fast routine to scroll horizontally, so
  176. we leave it to the client module to repaint. *)
  177. RETURN FALSE;
  178. END DefaultScrollHorizontally;
  179. VAR
  180. col1, row1, col2, row2: CARDINAL;
  181. PROCEDURE DefaultSetScrollPos( TheWindow: AWindowHandle;
  182. WhichScrollBar: INTEGER; AmountScrolled: INTEGER );
  183. PROCEDURE DrawMarkedLine( col1, row1, col2, row2:
  184. CARDINAL; LineType: CHAR; TotalLengthOrWidth,
  185. scrolled: CARDINAL);
  186. PROCEDURE FigurePlacement( VisibleUnits, TotalUnits,
  187. ScrolledUnits: CARDINAL; VAR offs1, offs2: CARDINAL );
  188. VAR
  189. ratio: CARDINAL;
  190. BEGIN
  191. (*First we figure out how many lines of TotalUnits a
  192. single line of VisibleUnits corresponds to.*)
  193. IF VisibleUnits >= TotalUnits THEN
  194. offs1 := 1;
  195. offs2 := 2;
  196. RETURN;
  197. END;
  198. ratio := TotalUnits DIV VisibleUnits;
  199. offs1 := ScrolledUnits DIV ratio;
  200. offs2 := ((TotalUnits - VisibleUnits) -
  201. ScrolledUnits);
  202. (*offs2 now represents the number of units in
  203. TotalUnits below those visible.*)
  204. offs2 := VisibleUnits - (offs2 DIV ratio);
  205. IF offs1 = 0 THEN
  206. INC( offs1 );
  207. INC( offs2 );
  208. END;
  209. IF offs2 = offs1 THEN
  210. (*Now we make sure the marks don't come out on top of
  211. each other.*)
  212. IF offs1 > 1 THEN
  213. DEC(offs1);
  214. ELSE
  215. INC(offs2);
  216. END
  217. END;
  218. END FigurePlacement;
  219. VAR
  220. LineChar, MarkChar: CHAR;
  221. offs1, offs2: CARDINAL;
  222. BEGIN
  223. (*DrawMarkedLine*)
  224. IF col1 < col2 THEN
  225. (*We're drawing a horizontal line.*)
  226. IF LineType = 'D' THEN
  227. LineChar := 315C;
  228. (*horizontal double-lined char*)
  229. MarkChar := 330C;
  230. ELSE
  231. LineChar := 304C;
  232. (*horizontal single-lined char*)
  233. MarkChar := 305C;
  234. END;
  235. WindowPrims.DrawLine( col1 + 1, row2, col2 - 1, row2,
  236. LineChar);
  237. (*This wipes out any previous marks.*)
  238. FigurePlacement( (col2 - col1) - 1, TotalLengthOrWidth,
  239. scrolled, offs1, offs2 );
  240. DrawStr( TheWindow, col1 + offs1, row2, SYSTEM.ADR(MarkChar), 1 );
  241. DrawStr( TheWindow, col1 + offs2, row2, SYSTEM.ADR(MarkChar), 1 );
  242. ELSE
  243. (*We're drawing a vertical line.*)
  244. IF LineType = 'D' THEN
  245. LineChar := 272C;
  246. (*vertical double-lined char*)
  247. MarkChar := 327C;
  248. ELSE
  249. LineChar := CHR(179);
  250. (*vertical single-lined char*)
  251. MarkChar := CHR(197);
  252. END;
  253. WindowPrims.DrawLine( col2, row1 + 1, col2, row2 - 1,
  254. LineChar );
  255. (*This wipes out any previous marks.*)
  256. FigurePlacement( (row2 - row1) - 1, TotalLengthOrWidth,
  257. scrolled, offs1, offs2 );
  258. DrawStr( TheWindow, col2, row1 + offs1,
  259. SYSTEM.ADR(MarkChar), 1 );
  260. DrawStr( TheWindow, col2, row1 + offs2,
  261. SYSTEM.ADR(MarkChar), 1 );
  262. END;
  263. END DrawMarkedLine;
  264. VAR
  265. box: CHAR;
  266. BEGIN
  267. IF WhichScrollBar = SbVert THEN
  268. DrawMarkedLine( col2, row1, col2,
  269. row2, box, row2 - row1 + 1, AmountScrolled );
  270. ELSIF WhichScrollBar = SbHorz THEN
  271. DrawMarkedLine( col1, row2, col2,
  272. row2, box, col2 - col1 + 1, AmountScrolled );
  273. END;
  274. END DefaultSetScrollPos;
  275. PROCEDURE DefaultSetScrollRange( TheWindow: AWindowHandle;
  276. WhichScrollBar, MinPos, MaxPos: INTEGER );
  277. BEGIN
  278. IF WhichScrollBar = SbVert THEN
  279. row1 := MinPos;
  280. row2 := MaxPos;
  281. ELSIF WhichScrollBar = SbHorz THEN
  282. col1 := MinPos;
  283. col2 := MaxPos;
  284. END;
  285. END DefaultSetScrollRange;
  286. PROCEDURE Init();
  287. BEGIN
  288. IF Initialized THEN
  289. RETURN;
  290. ELSE
  291. Initialized := TRUE;
  292. END;
  293. (*EntryDiag:
  294. Diagnostics.Init();
  295. :EntryDiag*)
  296. LowLevel.Init();
  297. MsColors.Init();
  298. MsgBox1.Init();
  299. SmartScreen.Init();
  300. WindowPrims.Init();
  301. (*EntryDiag:
  302. Diagnostics.diagS( 'Entering VWindows', '' );
  303. :EntryDiag*)
  304. SingleBox[0] := CHR(218);
  305. SingleBox[1] := CHR(196);
  306. SingleBox[2] := CHR(191);
  307. SingleBox[3] := CHR(179);
  308. SingleBox[4] := CHR(179);
  309. SingleBox[5] := CHR(192);
  310. SingleBox[6] := CHR(196);
  311. SingleBox[7] := CHR(217);
  312. SingleBox[8] := 0C;
  313. DoubleBox[0] := CHR(201);
  314. DoubleBox[1] := CHR(205);
  315. DoubleBox[2] := CHR(187);
  316. DoubleBox[3] := CHR(186);
  317. DoubleBox[4] := CHR(186);
  318. DoubleBox[5] := CHR(200);
  319. DoubleBox[6] := CHR(205);
  320. DoubleBox[7] := CHR(188);
  321. DoubleBox[8] := 0C;
  322. NormalBackGround := MsColors.black;
  323. NormalAttrib := MsColors.plain;
  324. BackColor := DefaultBackColor;
  325. ClearPart := DefaultClearPart;
  326. CurrentWindow := SYSTEM.ADR(handle);
  327. handle:=0;
  328. DrawBox := DefaultDrawBox;
  329. DrawStr := DefaultDrawStr;
  330. EndCol := DefaultEndCol;
  331. EndRow := DefaultEndRow;
  332. ForeColor := DefaultForeColor;
  333. GetCursorHeight := DefaultGetCursorHeight;
  334. GetCursorCoords := DefaultGetCursorCoords;
  335. GotoXY := DefaultGotoXY;
  336. MessageBox := DefaultMsgBox;
  337. MonoAttr := DefaultMonoAttr;
  338. ReverseColors := DefaultReverseColors;
  339. ScrollHorizontally := DefaultScrollHorizontally;
  340. ScrollVertically := DefaultScrollVertically;
  341. SetBackColor := DefaultSetBackColor;
  342. SetCursorHeight := DefaultSetCursorHeight;
  343. SetForeColor := DefaultSetForeColor;
  344. SetMonoAttr := DefaultSetMonoAttr;
  345. SetScrollPos := DefaultSetScrollPos;
  346. SetScrollRange := DefaultSetScrollRange;
  347. (*EntryDiag:
  348. Diagnostics.diagS( 'Exiting VWindows', '' );
  349. :EntryDiag*)
  350. END Init;
  351. BEGIN
  352. Initialized := FALSE;
  353. Init();
  354. END VWindows.
  355.