MSGBOX1.MOD 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. IMPLEMENTATION MODULE MsgBox1;
  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/msgbox1.mov 1.5 10 Mar 1991 15:29:44 coleb $
  12. *
  13. *)
  14. IMPORT GenLists;
  15. IMPORT KbdInput;
  16. IMPORT ListUtils;
  17. IMPORT LowLevel;
  18. IMPORT Numbers;
  19. IMPORT NumTypes;
  20. IMPORT SmartScreen;
  21. IMPORT SYSTEM;
  22. IMPORT VWindows;
  23. IMPORT WindowPrims;
  24. VAR
  25. Initialized : BOOLEAN;
  26. PROCEDURE Init();
  27. BEGIN
  28. IF Initialized THEN
  29. RETURN;
  30. ELSE
  31. Initialized := TRUE;
  32. END;
  33. GenLists.Init();
  34. KbdInput.Init();
  35. ListUtils.Init();
  36. LowLevel.Init();
  37. Numbers.Init();
  38. NumTypes.Init();
  39. SmartScreen.Init();
  40. VWindows.Init();
  41. WindowPrims.Init();
  42. END Init;
  43. CONST
  44. lftcol = 4;
  45. toprow = 3;
  46. rtcol = 44;
  47. btmrow = 14;
  48. midcol = 24;
  49. midrow = 9;
  50. (* These define the starting points for the 4 msg box areas *)
  51. PROCEDURE FindCoords( locatn: VWindows.Compass; MaxWidth,
  52. MaxHeight: CARDINAL; VAR col1, row1, col2, row2: CARDINAL );
  53. BEGIN
  54. CASE locatn OF
  55. VWindows.West, VWindows.NW, VWindows.SW :
  56. col1 := lftcol;
  57. | VWindows.North, VWindows.South :
  58. col1 := midcol;
  59. | VWindows.East, VWindows.NE, VWindows.SE :
  60. col1 := rtcol;
  61. END;
  62. CASE locatn OF
  63. VWindows.North, VWindows.NW, VWindows.NE :
  64. row1 := toprow;
  65. | VWindows.East, VWindows.West :
  66. row1 := midrow;
  67. | VWindows.South, VWindows.SE, VWindows.SW :
  68. row1 := btmrow;
  69. END;
  70. col2 := col1 + MaxWidth + 3;
  71. row2 := row1 + MaxHeight + 3;
  72. END FindCoords;
  73. PROCEDURE NullScan( StrAddr: SYSTEM.ADDRESS ): CARDINAL;
  74. BEGIN
  75. RETURN LowLevel.ScanEQ( 32767, 0C, StrAddr );
  76. END NullScan;
  77. PROCEDURE WinMsgBox( TheWindow: VWindows.AWindowHandle;
  78. TextPtr: SYSTEM.ADDRESS; CaptionPtr: SYSTEM.ADDRESS;
  79. WinType: CARDINAL ): CARDINAL;
  80. VAR
  81. TxtLngth, CaptionLngth: CARDINAL;
  82. TmpList: GenLists.GenList;
  83. KeyPressed: CARDINAL;
  84. BEGIN
  85. TxtLngth := NullScan( TextPtr );
  86. CaptionLngth := NullScan( CaptionPtr );
  87. GenLists.NewList( TmpList );
  88. GenLists.ListInsertAdr( TextPtr, TxtLngth,
  89. GenLists.StrCode, TmpList, 1 );
  90. ListMsgBox( VWindows.NE, TmpList, KbdInput.AnyKeyNum,
  91. KeyPressed );
  92. GenLists.DisposeList( TmpList );
  93. RETURN KeyPressed;
  94. END WinMsgBox;
  95. PROCEDURE ListMsgBox(locatn : VWindows.Compass; TheList :
  96. GenLists.GenList; LegalKeys: KbdInput.KeyNumSet; VAR KeyPressed :
  97. CARDINAL);
  98. VAR
  99. leng, breakspot, lastbreak, LinesAdded, BytesAdded : INTEGER;
  100. StartLine, CursorLine, CursorCol, LstLngth, maxleng, newleng, i,
  101. col1, row1, col2, row2, rowspot, colspot: CARDINAL;
  102. BytePos : LONGINT;
  103. screen : WindowPrims.ScreenType;
  104. TmpAdr: SYSTEM.ADDRESS;
  105. TypeCode, TmpSize: CARDINAL;
  106. BEGIN
  107. WindowPrims.PushColors();
  108. WindowPrims.PushCursorCoords();
  109. WindowPrims.PushCursorHeight();
  110. SmartScreen.SetCursorHeight(0);
  111. SmartScreen.SetAttribOrColor( WindowPrims.MsgForeColor,
  112. WindowPrims.MsgBackColor, WindowPrims.MsgMonoAtrib );
  113. maxleng := Numbers.Min( ListUtils.LongestLine(
  114. TheList ), SmartScreen.MaxCol - rtcol - 3 );
  115. StartLine := 1;
  116. CursorLine := 1;
  117. CursorCol := 1;
  118. BytePos := NumTypes.L0;
  119. ListUtils.ReformPara( TheList, 0, maxleng - 2, StartLine,
  120. CursorLine, CursorCol, LinesAdded, BytesAdded, BytePos );
  121. LstLngth := Numbers.Min( GenLists.ListLength(
  122. TheList ), SmartScreen.MaxRow - btmrow - 3 );
  123. FindCoords( locatn, maxleng, LstLngth, col1, row1, col2, row2 );
  124. WindowPrims.ScreenSave(screen, col1, row1, col2, row2 );
  125. SmartScreen.ClearPart(col1, row1, col2, row2);
  126. (* save & clear an area of the required size *)
  127. WindowPrims.DrawThisBox( WindowPrims.SingleBox, col1, row1,
  128. col2, row2 );
  129. (* draw a box of the required size *)
  130. colspot := col1+2;
  131. rowspot := row1+1;
  132. FOR i := 1 TO LstLngth DO
  133. (* write text in window *)
  134. GenLists.GetElmtAdr( TheList, i, TmpAdr, TmpSize, TypeCode );
  135. TmpSize := ListUtils.ElmtSize( TheList, i );
  136. IF TypeCode = GenLists.StrCode THEN
  137. SmartScreen.AdrWriteAt( colspot, rowspot+i, TmpAdr, TmpSize );
  138. END;
  139. END;
  140. KeyPressed := KbdInput.KeyHit( LegalKeys );
  141. WindowPrims.ScreenRestore(screen, col1, row1);
  142. WindowPrims.PopCursorCoords();
  143. WindowPrims.PopCursorHeight();
  144. WindowPrims.PopColors();
  145. (* restore screen, cursor, and mode *)
  146. END ListMsgBox;
  147. BEGIN
  148. Initialized := FALSE;
  149. Init();
  150. END MsgBox1.