home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / MADTRB16.ZIP / PIBMENUS.FIX < prev    next >
Encoding:
Text File  |  1986-02-15  |  9.1 KB  |  205 lines

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