home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / dos / prg / pas / swag / oop.swg / 0021_VIEWCOLR.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  3KB  |  94 lines

  1. (*
  2. > Does somebody know how to get correct colors in a view.
  3. > That is: Exactly the colors I want to specify without mapping
  4. > on the colors of the views owner?
  5.  
  6. Now you're getting even more complicated than the actual method of doing it.
  7. (as if that wasn't complicated enough!)
  8.  
  9. The BP7 Turbo Vision Guide (and I'll assume the TP7 TVGuide as well) do a much
  10. better job at explaning the palette's that the TP6 version. The colors are not
  11. as much maps, as they are indexes. Only the TProgram Object actual contains any
  12. color codes. TApplication, by design, inherits that palette as is. Any inserted
  13. views palette will contain a String of indexes into that palette.
  14.  
  15. There are a couple of ways to customize your colors. Either adjust where your
  16. current views index points to, or adjust the actual applications palette.
  17.  
  18. > The manual says that such is done to get "decent colors". But the
  19. > problem is that defining what should be "decent" is to the Programmer,
  20. > not to the designer of a compiler :-)
  21.  
  22. > How to get just Absolute colors in a view, thats the question.
  23.  
  24. The easiest method I've found For adjusting colors, is directly adjusting the
  25. actual TApllications GetPalette Method.
  26.  
  27.  
  28. Function TMyApp.GetPalette:PPalette;
  29. Const
  30.   P: Array[apColor..apMonochrome] of String[Length(CColor)] =
  31.     (CColor, CBlackWhite, CMonochrome);
  32. begin
  33.   p[apcolor,1] := #$1A;   {background}
  34.   p[apcolor,2] := #$1F;   {normal Text}
  35.   p[apcolor,33] := #$74;  {tdialog frame active}
  36.   p[apcolor,51] := #$1B;  {inputline selected}
  37.   p[apcolor,56] := #$4F;  {history Window scrollbar control}
  38.   getpalette := @p[apppalette];
  39. end;
  40.  
  41.  
  42. This lets you change and adjust your entire pallete, and have those changes
  43. reflected throughout your entire application... Just consult your TVGuide to
  44. find the offset into the String of the item you want to change.
  45.  
  46. Heres a nifty Program to display all the colors available, and what they look
  47. like (not only tested.. but used quite a bit!) :
  48. *)
  49.  
  50. Program Colourtest;
  51.  
  52. Uses
  53.   Crt;
  54. Type
  55.   str2 = String[2];
  56. Var
  57.  i, y, x,
  58.  TA       : Byte;
  59.  
  60. Function Hexit(w : Byte) : str2;
  61. Const
  62.   Letr : String[16] = '0123456789ABCDEF';
  63. begin
  64.   Hexit := Letr[w shr 4 + 1] + Letr[w and $0F + 1];
  65. end;
  66.  
  67. begin
  68.   TA := TextAttr ;
  69.   ClrScr;
  70.   For y := 0 to 7 do
  71.   begin
  72.     GotoXY(1, y + 5);
  73.     For i := 0 to 15 do
  74.     begin
  75.       TextAttr := y * 16 + i;
  76.       Write('[', Hexit(TextAttr), ']');
  77.     end;
  78.   end;
  79.   Writeln;
  80.   Writeln;
  81.   GotoXY(1, 15);
  82.   Textattr := TA;
  83.   Write(' For ');
  84.   Textattr := TA or $80;
  85.   Write(' Flashing ');
  86.   Textattr := TA;
  87.   Writeln('Attribute : Color = Color or $80');
  88.   Writeln;
  89.   Write(' Press any key to quit : ');
  90.   ReadKey;
  91.   ClrScr;
  92. end.
  93.  
  94.