Category : Miscellaneous Language Source Code
Archive   : DLGDS411.ZIP
Filename : COLORTXT.INT

 
Output of file : COLORTXT.INT contained in archive : DLGDS411.ZIP
Unit ColorTxt;

{
TColoredText is a descendent of TStaticText designed to allow the writing
of colored text when color monitors are used. With a monochrome or BW
monitor, TColoredText acts the same as TStaticText.

TColoredText is used in exactly the same way as TStaticText except that
the constructor has an extra Byte parameter specifying the attribute
desired. (Do not use a 0 attribute, black on black).

The source for TColoredText is listed below except for the Draw method.
Since the Draw method is 99% the same as that for TStaticText found in
Borland's Run Time Library source, I didn't feel that it was appropriate
for me copy it here. If you have the RTL you can reconstruct the draw
method since I do show the changes made.
}

Interface
uses Objects, Drivers, Views, Dialogs, App;

type
PColoredText = ^TColoredText;
TColoredText = object(TStaticText)
Attr : Byte;
constructor Init(var Bounds: TRect; AText: String; Attribute : Byte);
constructor Load(var S: TStream);
function GetTheColor : byte; virtual;
procedure Draw; virtual;
procedure Store(var S: TStream);
end;

const
RColoredText: TStreamRec = (
ObjType: 611;
VmtLink: Ofs(TypeOf(TColoredText)^);
Load: @TColoredText.Load;
Store: @TColoredText.Store
);

Implementation

constructor TColoredText.Init(var Bounds: TRect; AText: String;
Attribute : Byte);
begin
TStaticText.Init(Bounds, AText);
Attr := Attribute;
end;

constructor TColoredText.Load(var S: TStream);
begin
TStaticText.Load(S);
S.Read(Attr, Sizeof(Attr));
end;

procedure TColoredText.Store(var S: TStream);
begin
TStaticText.Store(S);
S.Write(Attr, Sizeof(Attr));
end;

function TColoredText.GetTheColor : byte;
begin
if AppPalette = apColor then
GetTheColor := Attr
else
GetTheColor := GetColor(1);
end;

procedure TColoredText.Draw;

Copy TStaticText.Draw from DIALOGS.PAS. Change the first line from
Color := GetColor(1);
to
Color := GetTheColor;


end.


  3 Responses to “Category : Miscellaneous Language Source Code
Archive   : DLGDS411.ZIP
Filename : COLORTXT.INT

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/