4
TColoredText is a descendent of TStaticText designed to allow the writing
5
of colored text when color monitors are used. With a monochrome or BW
6
monitor, TColoredText acts the same as TStaticText.
8
TColoredText is used in exactly the same way as TStaticText except that
9
the constructor has an extra Byte parameter specifying the attribute
10
desired. (Do not use a 0 attribute, black on black).
28
objects, drivers, views, dialogs, app, fvconsts;
31
PColoredText = ^TColoredText;
32
TColoredText = object(TStaticText)
34
constructor Init(var Bounds: TRect; const AText: String; Attribute : Byte);
35
constructor Load(var S: TStream);
36
function GetTheColor : byte; virtual;
37
procedure Draw; virtual;
38
procedure Store(var S: TStream);
42
RColoredText: TStreamRec = (
43
ObjType: idColoredText;
44
VmtLink: Ofs(TypeOf(TColoredText)^);
45
Load: @TColoredText.Load;
46
Store: @TColoredText.Store
51
constructor TColoredText.Init(var Bounds: TRect; const AText: String;
54
TStaticText.Init(Bounds, AText);
58
constructor TColoredText.Load(var S: TStream);
61
S.Read(Attr, Sizeof(Attr));
64
procedure TColoredText.Store(var S: TStream);
67
S.Write(Attr, Sizeof(Attr));
70
function TColoredText.GetTheColor : byte;
72
if AppPalette = apColor then
75
GetTheColor := GetColor(1);
78
procedure TColoredText.Draw;
82
I, J, L, P, Y: Sw_Integer;
94
MoveChar(B, ' ', Color, Size.X);
105
while (P <= L) and (S[P] = ' ') do Inc(P);
106
while (P <= L) and (S[P] <> ' ') and (S[P] <> #13) do Inc(P);
107
until (P > L) or (P >= I + Size.X) or (S[P] = #13);
108
if P > I + Size.X then
109
if J > I then P := J else P := I + Size.X;
110
if Center then J := (Size.X - P + I) div 2 else J := 0;
111
MoveBuf(B[J], S[I], Color, P - I);
112
while (P <= L) and (S[P] = ' ') do Inc(P);
113
if (P <= L) and (S[P] = #13) then
117
if (P <= L) and (S[P] = #10) then Inc(P);
120
WriteLine(0, Y, Size.X, 1, B);