📄 colortxt.int
字号:
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.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -