📄 dsgnintf.pas
字号:
Result := GetStrValueAt(0);
end;
function TPropertyEditor.GetStrValueAt(Index: Integer): string;
begin
with FPropList^[Index] do Result := GetStrProp(Instance, PropInfo);
end;
function TPropertyEditor.GetVarValue: Variant;
begin
Result := GetVarValueAt(0);
end;
function TPropertyEditor.GetVarValueAt(Index: Integer): Variant;
begin
with FPropList^[Index] do Result := GetVariantProp(Instance, PropInfo);
end;
function TPropertyEditor.GetValue: string;
begin
Result := srUnknown;
end;
procedure TPropertyEditor.GetValues(Proc: TGetStrProc);
begin
end;
procedure TPropertyEditor.Initialize;
begin
end;
procedure TPropertyEditor.Modified;
begin
Designer.Modified;
end;
procedure TPropertyEditor.SetFloatValue(Value: Extended);
var
I: Integer;
begin
for I := 0 to FPropCount - 1 do
with FPropList^[I] do SetFloatProp(Instance, PropInfo, Value);
Modified;
end;
procedure TPropertyEditor.SetMethodValue(const Value: TMethod);
var
I: Integer;
begin
for I := 0 to FPropCount - 1 do
with FPropList^[I] do SetMethodProp(Instance, PropInfo, Value);
Modified;
end;
procedure TPropertyEditor.SetOrdValue(Value: Longint);
var
I: Integer;
begin
for I := 0 to FPropCount - 1 do
with FPropList^[I] do SetOrdProp(Instance, PropInfo, Value);
Modified;
end;
procedure TPropertyEditor.SetPropEntry(Index: Integer;
AInstance: TPersistent; APropInfo: PPropInfo);
begin
with FPropList^[Index] do
begin
Instance := AInstance;
PropInfo := APropInfo;
end;
end;
procedure TPropertyEditor.SetStrValue(const Value: string);
var
I: Integer;
begin
for I := 0 to FPropCount - 1 do
with FPropList^[I] do SetStrProp(Instance, PropInfo, Value);
Modified;
end;
procedure TPropertyEditor.SetVarValue(const Value: Variant);
var
I: Integer;
begin
for I := 0 to FPropCount - 1 do
with FPropList^[I] do SetVariantProp(Instance, PropInfo, Value);
Modified;
end;
procedure TPropertyEditor.Revert;
var
I: Integer;
begin
for I := 0 to FPropCount - 1 do
with FPropList^[I] do Designer.Revert(Instance, PropInfo);
end;
procedure TPropertyEditor.SetValue(const Value: string);
begin
end;
function TPropertyEditor.ValueAvailable: Boolean;
var
I: Integer;
S: string;
begin
Result := True;
for I := 0 to FPropCount - 1 do
begin
if (FPropList^[I].Instance is TComponent) and
(csCheckPropAvail in TComponent(FPropList^[I].Instance).ComponentStyle) then
begin
try
S := GetValue;
AllEqual;
except
Result := False;
end;
Exit;
end;
end;
end;
{ TOrdinalProperty }
function TOrdinalProperty.AllEqual: Boolean;
var
I: Integer;
V: Longint;
begin
Result := False;
if PropCount > 1 then
begin
V := GetOrdValue;
for I := 1 to PropCount - 1 do
if GetOrdValueAt(I) <> V then Exit;
end;
Result := True;
end;
function TOrdinalProperty.GetEditLimit: Integer;
begin
Result := 63;
end;
{ TIntegerProperty }
function TIntegerProperty.GetValue: string;
begin
with GetTypeData(GetPropType)^ do
if (MinValue > MaxValue) then // unsigned
Result := IntToStr(Cardinal(GetOrdValue))
else
Result := IntToStr(GetOrdValue);
end;
procedure TIntegerProperty.SetValue(const Value: String);
procedure Error(const Args: array of const);
begin
raise EPropertyError.CreateFmt(SOutOfRange, Args);
end;
var
L: Int64;
begin
L := StrToInt64(Value);
with GetTypeData(GetPropType)^ do
if (MinValue > MaxValue) then
begin // unsigned compare and reporting needed
if (L < Cardinal(MinValue)) or (L > Cardinal(MaxValue)) then
// bump up to Int64 to get past the %d in the format string
Error([Int64(Cardinal(MinValue)), Int64(Cardinal(MaxValue))]);
end
else if (L < MinValue) or (L > MaxValue) then
Error([MinValue, MaxValue]);
SetOrdValue(L);
end;
{ TCharProperty }
function TCharProperty.GetValue: string;
var
Ch: Char;
begin
Ch := Chr(GetOrdValue);
if Ch in [#33..#127] then
Result := Ch else
FmtStr(Result, '#%d', [Ord(Ch)]);
end;
procedure TCharProperty.SetValue(const Value: string);
var
L: Longint;
begin
if Length(Value) = 0 then L := 0 else
if Length(Value) = 1 then L := Ord(Value[1]) else
if Value[1] = '#' then L := StrToInt(Copy(Value, 2, Maxint)) else
raise EPropertyError.Create(SInvalidPropertyValue);
with GetTypeData(GetPropType)^ do
if (L < MinValue) or (L > MaxValue) then
raise EPropertyError.CreateFmt(SOutOfRange, [MinValue, MaxValue]);
SetOrdValue(L);
end;
{ TEnumProperty }
function TEnumProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paMultiSelect, paValueList, paSortList, paRevertable];
end;
function TEnumProperty.GetValue: string;
var
L: Longint;
begin
L := GetOrdValue;
with GetTypeData(GetPropType)^ do
if (L < MinValue) or (L > MaxValue) then L := MaxValue;
Result := GetEnumName(GetPropType, L);
end;
procedure TEnumProperty.GetValues(Proc: TGetStrProc);
var
I: Integer;
EnumType: PTypeInfo;
begin
EnumType := GetPropType;
with GetTypeData(EnumType)^ do
for I := MinValue to MaxValue do Proc(GetEnumName(EnumType, I));
end;
procedure TEnumProperty.SetValue(const Value: string);
var
I: Integer;
begin
I := GetEnumValue(GetPropType, Value);
if I < 0 then raise EPropertyError.Create(SInvalidPropertyValue);
SetOrdValue(I);
end;
{ TBoolProperty }
function TBoolProperty.GetValue: string;
begin
if GetOrdValue = 0 then
Result := 'False'
else
Result := 'True';
end;
procedure TBoolProperty.GetValues(Proc: TGetStrProc);
begin
Proc('False');
Proc('True');
end;
procedure TBoolProperty.SetValue(const Value: string);
var
I: Integer;
begin
if CompareText(Value, 'False') = 0 then
I := 0
else if CompareText(Value, 'True') = 0 then
I := -1
else
I := StrToInt(Value);
SetOrdValue(I);
end;
{ TFloatProperty }
function TFloatProperty.AllEqual: Boolean;
var
I: Integer;
V: Extended;
begin
Result := False;
if PropCount > 1 then
begin
V := GetFloatValue;
for I := 1 to PropCount - 1 do
if GetFloatValueAt(I) <> V then Exit;
end;
Result := True;
end;
function TFloatProperty.GetValue: string;
const
Precisions: array[TFloatType] of Integer = (7, 15, 18, 18, 18);
begin
Result := FloatToStrF(GetFloatValue, ffGeneral,
Precisions[GetTypeData(GetPropType)^.FloatType], 0);
end;
procedure TFloatProperty.SetValue(const Value: string);
begin
SetFloatValue(StrToFloat(Value));
end;
{ TStringProperty }
function TStringProperty.AllEqual: Boolean;
var
I: Integer;
V: string;
begin
Result := False;
if PropCount > 1 then
begin
V := GetStrValue;
for I := 1 to PropCount - 1 do
if GetStrValueAt(I) <> V then Exit;
end;
Result := True;
end;
function TStringProperty.GetEditLimit: Integer;
begin
if GetPropType^.Kind = tkString then
Result := GetTypeData(GetPropType)^.MaxLength else
Result := 255;
end;
function TStringProperty.GetValue: string;
begin
Result := GetStrValue;
end;
procedure TStringProperty.SetValue(const Value: string);
begin
SetStrValue(Value);
end;
{ TComponentNameProperty }
function TComponentNameProperty.GetAttributes: TPropertyAttributes;
begin
Result := [];
end;
function TComponentNameProperty.GetEditLimit: Integer;
begin
Result := MaxIdentLength;
end;
{ TNestedProperty }
constructor TNestedProperty.Create(Parent: TPropertyEditor);
begin
FDesigner := Parent.Designer;
FPropList := Parent.FPropList;
FPropCount := Parent.PropCount;
end;
destructor TNestedProperty.Destroy;
begin
end;
{ TSetElementProperty }
constructor TSetElementProperty.Create(Parent: TPropertyEditor; AElement: Integer);
begin
inherited Create(Parent);
FElement := AElement;
end;
function TSetElementProperty.AllEqual: Boolean;
var
I: Integer;
S: TIntegerSet;
V: Boolean;
begin
Result := False;
if PropCount > 1 then
begin
Integer(S) := GetOrdValue;
V := FElement in S;
for I := 1 to PropCount - 1 do
begin
Integer(S) := GetOrdValueAt(I);
if (FElement in S) <> V then Exit;
end;
end;
Result := True;
end;
function TSetElementProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paMultiSelect, paValueList, paSortList];
end;
function TSetElementProperty.GetName: string;
begin
Result := GetEnumName(GetTypeData(GetPropType)^.CompType^, FElement);
end;
function TSetElementProperty.GetValue: string;
var
S: TIntegerSet;
begin
Integer(S) := GetOrdValue;
Result := BooleanIdents[FElement in S];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -