type
TBaudRateProperty = class(TStringProperty)
public
function GetAttributes: TPropertyAttributes; override;
procedure GetValues(Proc: TGetStrProc); override;
function GetValue: string; override;
procedure SetValue(const Value: string); override;
end;
...
type
TBaudRate = (br110, br300, br600, br1200, br2400, br4800, br9600, br14400,
br19200, br38400, br56000, br128000, br256000);
const
BaudList: array[TBaudRate] of string[7] =
('110', '300', '600', '1200', '2400', '4800', '9600', '14400', '19200',
'38400', '56000', '128000', '256000');
{TBaudRateProperty}
function TBaudRateProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paValueList];
end;
procedure TBaudRateProperty.GetValues(Proc: TGetStrProc);
var
i: TBaudRate;
begin
for i := Low(TBaudRate) to High(TBaudRate) do
Proc(BaudList[i]);
end;
function TBaudRateProperty.GetValue: string;
begin
Result := BaudList[TBaudRate(GetOrdValue)];
end;
procedure TBaudRateProperty.SetValue(const Value: string);
var
i: TBaudRate;
begin
for i := Low(TBaudRate) to High(TBaudRate) do
if BaudList[i] = Value then
begin
SetOrdValue(integer(i));
EXIT;
end;
inherited SetValue(Value);
end;
|