home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / COLOR.ZIP / COLOR.DER next >
Encoding:
Text File  |  1988-02-03  |  2.2 KB  |  87 lines

  1. (*
  2.   This is the best way I know to select colors. It is similar to the
  3.   color setup in TInst and/or MakeMenu. You should include this code
  4.   in DER11.ARC
  5.  
  6. The NEW Interface section should look like:
  7. *)
  8. Interface
  9. Uses
  10.   Crt,
  11.   Dos,
  12.   Dates,   { Scott Bussinger's Dates unit from CIS BORPRO DL2 }
  13.   QWIK,    { Jim LeMay's QWIK40a unit from CIS BORPRO DL2 }
  14.   WNDWVars,{ This has been added }
  15.   WNDW;    { Jim LeMay's WNDW40  unit from CIS BORPRO DL2 }
  16.  
  17. Function  SelectColor(RR,CC,DR,DC : Byte) : Byte;
  18. (*
  19. In the Implementation section add:
  20. *)
  21. Function SelectColor(RR,CC,DR,DC : Byte) : Byte;
  22. { Coordinates of Color Window: (RR,CC) ... (RR+10,CC+18)
  23.   DR = Default Row color selection
  24.   DC = Default Col color selection
  25.  
  26.   No Error checking is done, so make sure RR is in [1..15]
  27.   and CC is in [1..60]
  28. }
  29. Const
  30.   Clear : Char = #4;
  31.   Flag  : Char = #15;
  32. Var
  33.   Row,
  34.   Col : Byte;
  35.   Att : Integer;
  36.   TC  : Char;
  37.   TLimit,BLimit,Rlimit,LLimit : Byte;
  38.  
  39. Begin
  40.   TLimit := RR + 1;
  41.   BLimit := RR + 8;
  42.   LLimit := CC + 1;
  43.   RLimit := CC + 16;
  44.  
  45.   MakeWindow(RR,CC,10,18,-1,-1,SingleBrdr,aWindow);
  46.   TitleWindow(Top,Center,' Colors ');
  47.   For Row := 0 to 7 Do For Col := 0 to 15 Do
  48.   Begin
  49.     Att := Attr(Col,Row);  { Col = foreground, Row = background }
  50.     QFill(RR + Row + 1,CC + Col + 1,1,1,Att,Clear);
  51.   End;
  52.  
  53.   Row := RR + DR;
  54.   Col := CC + DC;
  55.   Repeat
  56.     GotoRC(Row,Col);
  57.     QFill(Row,Col,1,1,-1,Flag);
  58.     TC := ReadChar;
  59.     QFill(Row,Col,1,1,-1,Clear);
  60.     Case TC Of
  61.       CursorDown: Begin
  62.                     If Row = BLimit Then Row := Tlimit
  63.                     Else Inc(Row);
  64.                   End;
  65.       CursorUp:   Begin
  66.                     If Row = TLimit Then Row := BLimit
  67.                     Else Dec(Row);
  68.                   End;
  69.      CursorRight: Begin
  70.                     If Col = RLimit Then Col := LLimit
  71.                     Else Inc(Col);
  72.                   End;
  73.       CursorLeft: Begin
  74.                     If Col = LLimit Then Col := RLimit
  75.                     Else Dec(Col);
  76.                   End;
  77.     End;
  78.   Until TC = Return;
  79.   RemoveWindow;
  80. {
  81.   Note:
  82.     ForeGround := Col - CC - 1
  83.     BackGround := Row - RR - 1
  84. }
  85.   SelectColor := Attr(Col - CC - 1,Row - RR - 1);
  86. End;
  87.