home *** CD-ROM | disk | FTP | other *** search
/ Hall of Fame / HallofFameCDROM.cdr / prpascal / pibmenu.lzh / PIBMENUS.FIX < prev    next >
Text File  |  1986-01-16  |  12KB  |  268 lines

  1. Date:  April 1, 1985
  2. From:  Philip R. Burns
  3. To:    PIBMENUS users
  4.  
  5.  
  6. This file contains fixes to the PIBMENUS routines so that they
  7. will work correctly with version 3.0 of Turbo Pascal.
  8.  
  9. First, add the following global variable declaration to the others
  10. in PIBMENUS:
  11.  
  12.    Menu_Turbo_Version   : Integer             (* Version of Turbo Pascal *);
  13.  
  14. This variable will take on values of 2 or 3, depending upon the
  15. version of Turbo Pascal.  You may set this variable (to 2 or 3)
  16. in the initialization code of your program, or you may call the
  17. following procedure, which will also set the variable:
  18.  
  19. ----------------------------------------------------------------------------
  20.  
  21. (*----------------------------------------------------------------------*)
  22. (*          Set_Turbo_Version --- Set version of Turbo Pascal           *)
  23. (*----------------------------------------------------------------------*)
  24.  
  25. Procedure Set_Turbo_Version;
  26.  
  27. (*----------------------------------------------------------------------*)
  28. (*                                                                      *)
  29. (*     Procedure:  Set_Turbo_Version                                    *)
  30. (*                                                                      *)
  31. (*     Purpose:   Set version of Turbo Pascal                           *)
  32. (*                                                                      *)
  33. (*     Calling Sequence:                                                *)
  34. (*                                                                      *)
  35. (*        Set_Turbo_Version;                                            *)
  36. (*                                                                      *)
  37. (*      Calls:   Window                                                 *)
  38. (*                                                                      *)
  39. (*      Remarks:                                                        *)
  40. (*                                                                      *)
  41. (*         This routine heuristically determines which version (2 or 3) *)
  42. (*         of Turbo Pascal it has been compiled with.  This information *)
  43. (*         is needed to save the coordinates of the current window when *)
  44. (*         performing a screen save.                                    *)
  45. (*                                                                      *)
  46. (*----------------------------------------------------------------------*)
  47.  
  48. BEGIN (* Set_Turbo_Version *)
  49.  
  50.                                    (* Set an unusual window *)
  51.    Window( 53, 23, 78, 25 );
  52.  
  53.    IF ( MEM[ Dseg : 4 ] = 52 ) AND
  54.       ( MEM[ Dseg : 5 ] = 22 ) THEN
  55.       Menu_Turbo_Version := 3
  56.    ELSE
  57.       Menu_Turbo_Version := 2;
  58.  
  59.    Window( 1, 1, 80, 25 );
  60.  
  61. END   (* Set_Turbo_Version *);
  62.  
  63. ----------------------------------------------------------------------------
  64.  
  65.  
  66. It is VITAL to provide the correct version number of the compiler
  67. you are using, else PIBMENUS will take off for hyperspace and very
  68. likely take your machine with it, requiring a re-boot.
  69.  
  70. You must also replace the following routines with the revised
  71. versions of those routines provided here:
  72.  
  73.      -- Upper_Left_Column
  74.      -- Upper_Left_Row
  75.      -- Draw_Menu_Frame
  76.  
  77. The revised versions follow.  These routines will work correctly
  78. with either version 2 or version 3, as long as the variable
  79. 'Menu_Turbo_Version' has been set correctly as described above.
  80. Also see the final comment after the following code.
  81.  
  82.  
  83. ----------------------------------------------------------------------------
  84.  
  85. (*----------------------------------------------------------------------*)
  86. (*                TURBO Pascal Window Location Routines                 *)
  87. (*----------------------------------------------------------------------*)
  88. (*                                                                      *)
  89. (*  These routines and constants give the four corners of the current   *)
  90. (*  Turbo window:                                                       *)
  91. (*                                                                      *)
  92. (*    Lower right-hand corner: (Lower_Right_Column, Lower_Right_Row)    *)
  93. (*    Upper left_hand corner:  (Upper_Left_Column, Upper_Right_Column)  *)
  94. (*                                                                      *)
  95. (*----------------------------------------------------------------------*)
  96.  
  97.                                    (* Lower right corner of     *)
  98.                                    (* current TURBO window      *)
  99. Var
  100.    Lower_Right_Column  : Byte ABSOLUTE Cseg:$016A;
  101.    Lower_Right_Row     : Byte ABSOLUTE Cseg:$016B;
  102.  
  103. (*----------------------------------------------------------------------*)
  104. (*    Upper_Left_Column ---  Upper Left Col. Position of current window *)
  105. (*----------------------------------------------------------------------*)
  106.  
  107. Function Upper_Left_Column : Integer;
  108.  
  109. (*                                                                      *)
  110. (*     Function:   Upper_Left_Column                                    *)
  111. (*                                                                      *)
  112. (*     Purpose:    Returns upper left col. pos. of current TURBO window *)
  113. (*                                                                      *)
  114. (*     Calling Sequence:                                                *)
  115. (*                                                                      *)
  116. (*        Pos := Upper_Left_Column : Integer;                           *)
  117. (*                                                                      *)
  118. (*     Calls:   Mem                                                     *)
  119. (*                                                                      *)
  120.  
  121. Begin  (* Upper_Left_Column *)
  122.  
  123.    IF Menu_Turbo_Version = 2 THEN
  124.       Upper_Left_Column := MEM[ Dseg:$0156 ] + 1
  125.    ELSE
  126.       Upper_Left_Column := MEM[ Dseg:$0004 ] + 1;
  127.  
  128. End    (* Upper_Left_Column *);
  129.  
  130. (*----------------------------------------------------------------------*)
  131. (*    Upper_Left_Row ---  Upper Left Row Position of current window     *)
  132. (*----------------------------------------------------------------------*)
  133.  
  134. Function Upper_Left_Row : Integer;
  135.  
  136. (*                                                                      *)
  137. (*     Function:   Upper_Left_Row                                       *)
  138. (*                                                                      *)
  139. (*     Purpose:    Returns upper left row pos. of current TURBO window  *)
  140. (*                                                                      *)
  141. (*     Calling Sequence:                                                *)
  142. (*                                                                      *)
  143. (*        Pos := Upper_Left_Row : Integer;                              *)
  144. (*                                                                      *)
  145. (*     Calls:   Mem                                                     *)
  146. (*                                                                      *)
  147.  
  148. Begin  (* Upper_Left_Row *)
  149.  
  150.    IF Menu_Turbo_Version = 2 THEN
  151.       Upper_Left_Row := Mem[ Dseg:$0157 ] + 1
  152.    ELSE
  153.       Upper_Left_Row := Mem[ Dseg:$0005 ] + 1;
  154.  
  155. End    (* Upper_Left_Row *);
  156.  
  157. (*----------------------------------------------------------------------*)
  158. (*                Draw_Menu_Frame --- Draw a Frame                      *)
  159. (*----------------------------------------------------------------------*)
  160.  
  161. Procedure Draw_Menu_Frame( UpperLeftX,  UpperLeftY,
  162.                            LowerRightX, LowerRightY : Integer;
  163.                            Frame_Color, Title_Color : Integer;
  164.                            Menu_Title: AnyStr );
  165.  
  166. (*                                                                      *)
  167. (*     Procedure:  Draw_Menu_Frame                                      *)
  168. (*                                                                      *)
  169. (*     Purpose:    Draws a titled frame using PC graphics characters    *)
  170. (*                                                                      *)
  171. (*     Calling Sequence:                                                *)
  172. (*                                                                      *)
  173. (*        Draw_Menu_Frame( UpperLeftX,  UpperLeftY,                     *)
  174. (*                         LowerRightX, LowerRightY,                    *)
  175. (*                         Frame_Color, Title_Color : Integer;          *)
  176. (*                         Menu_Title: AnyStr );                        *)
  177. (*                                                                      *)
  178. (*           UpperLeftX,  UpperLeftY  --- Upper left coordinates        *)
  179. (*           LowerRightX, LowerRightY --- Lower right coordinates       *)
  180. (*           Frame_Color              --- Color for frame               *)
  181. (*           Title_Color              --- Color for title text          *)
  182. (*           Menu_Title               --- Menu Title                    *)
  183. (*                                                                      *)
  184. (*     Calls:   GoToXY                                                  *)
  185. (*              Window                                                  *)
  186. (*              ClrScr                                                  *)
  187. (*                                                                      *)
  188. (*     Remarks:                                                         *)
  189. (*                                                                      *)
  190. (*        The area inside the frame is cleared after the frame is       *)
  191. (*        drawn.  If a box without a title is desired, enter a null     *)
  192. (*        string for a title.                                           *)
  193.  
  194. Var
  195.    I  : Integer;
  196.    L  : Integer;
  197.    LT : Integer;
  198.  
  199. Begin (* Draw_Menu_Frame *)
  200.  
  201.                                    (* Move to top left-hand corner of menu *)
  202.    GoToXY( UpperLeftX, UpperLeftY );
  203.  
  204.    L  := LowerRightX - UpperLeftX;
  205.    LT := LENGTH( Menu_Title );
  206.                                    (* Adjust title length if necessary *)
  207.    If LT > ( L - 5 ) Then Menu_Title[0] := CHR( L - 5 );
  208.  
  209.                                    (* Color for frame                  *)
  210.    TextColor( Frame_Color );
  211.                                    (* Write upper left hand corner and title *)
  212.    If LT > 0 Then
  213.       Begin
  214.          Write('╒[ ');
  215.          TextColor( Title_Color );
  216.          Write( Menu_Title );
  217.          TextColor( Frame_Color );
  218.          Write(' ]');
  219.       End
  220.    Else
  221.       Write('╒════');
  222.                                    (* Draw remainder of top of frame *)
  223.  
  224.    For I := ( UpperLeftX + LT + 5 ) To ( LowerRightX - 1 ) Do Write('═');
  225.  
  226.    Write('╕');
  227.                                   (* Draw sides of frame *)
  228.  
  229.    For I := UpperLeftY+1 To LowerRightY-1 Do
  230.       Begin
  231.          GoToXY( UpperLeftX  , I );  Write( '│' );
  232.          GoToXY( LowerRightX , I );  Write( '│' );
  233.       End;
  234.  
  235.                                   (* Draw bottom of frame     *)
  236.  
  237.    GoToXY( UpperLeftX, LowerRightY );
  238.    Write( '╘' );
  239.  
  240.    For I := UpperLeftX+1 To LowerRightX-1 Do Write( '═' );
  241.    Write( '╛' );
  242.  
  243.                                    (* Establish scrolling window area *)
  244.  
  245.    Window( UpperLeftX+1, UpperLeftY+1, LowerRightX-2, LowerRightY-1 );
  246.  
  247.                                    (* Clear out the window area       *)
  248.    ClrScr;
  249.                                    (* Ensure proper color for text    *)
  250.    TextColor( Title_Color );
  251.  
  252. End   (* Draw_Menu_Frame *);
  253.  
  254.  
  255. ----------------------------------------------------------------------------
  256.  
  257. Please advise me of any other problems you encounter with PIBMENUS.
  258. And, if you make any improvements, please leave me a note as well,
  259. so that I can incorporate them in future versions of PIBMENUS.
  260. You can reach me on either of the following two Chicago BBSs:
  261.  
  262.       Gene Plantz's BBS (312) 882 4227
  263.       Ron Fox's BBS     (312) 940 6496
  264.  
  265. Thanks,
  266. Phil Burnswing two Chicago BBSs:
  267.  
  268.       Gene Plantz's BBS (31