📄 designeditors.pas
字号:
begin
SetStrValue(Value);
end;
{ TComponentNameProperty }
function TComponentNameProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paNotNestable];
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];
end;
procedure TSetElementProperty.GetValues(Proc: TGetStrProc);
begin
Proc(BooleanIdents[False]);
Proc(BooleanIdents[True]);
end;
procedure TSetElementProperty.SetValue(const Value: string);
var
S: TIntegerSet;
begin
Integer(S) := GetOrdValue;
if CompareText(Value, BooleanIdents[True]) = 0 then
Include(S, FElement)
else
Exclude(S, FElement);
SetOrdValue(Integer(S));
end;
function TSetElementProperty.GetIsDefault: Boolean;
var
S: TIntegerSet;
ShouldBeInSet: Boolean;
HasStoredProc: Integer;
ProcAsInt: Integer;
begin
Result := inherited GetIsDefault;
if not Result then
begin
// Are we the one item in the set that is non-default?
// The trouble with this is that we don't know what
// the "default" set is used by the IsStored option.
// So, if that procedure is valid, then don't highlight individual items.
// Otherwise, we can use the default set value.
ProcAsInt := Integer(PPropInfo(GetPropInfo)^.StoredProc);
HasStoredProc := ProcAsInt and $FFFFFF00;
if HasStoredProc = 0 then
begin
Integer(S) := PPropInfo(GetPropInfo)^.Default;
ShouldBeInSet := FElement in S;
Integer(S) := GetOrdValue;
if ShouldBeInSet then
Result := FElement in S
else
Result := not (FElement in S);
end;
end;
end;
{ TSetProperty }
function TSetProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paMultiSelect, paSubProperties, paReadOnly, paRevertable];
end;
procedure TSetProperty.GetProperties(Proc: TGetPropProc);
var
I: Integer;
begin
with GetTypeData(GetTypeData(GetPropType)^.CompType^)^ do
for I := MinValue to MaxValue do
Proc(TSetElementProperty.Create(Self, I));
end;
function TSetProperty.GetValue: string;
var
S: TIntegerSet;
TypeInfo: PTypeInfo;
I: Integer;
begin
Integer(S) := GetOrdValue;
TypeInfo := GetTypeData(GetPropType)^.CompType^;
Result := '[';
for I := 0 to SizeOf(Integer) * 8 - 1 do
if I in S then
begin
if Length(Result) <> 1 then Result := Result + ',';
Result := Result + GetEnumName(TypeInfo, I);
end;
Result := Result + ']';
end;
{ TClassProperty }
function TClassProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paMultiSelect, paSubProperties, paReadOnly];
end;
procedure TClassProperty.GetProperties(Proc: TGetPropProc);
var
I: Integer;
J: Integer;
Components: IDesignerSelections;
begin
Components := TDesignerSelections.Create;
for I := 0 to PropCount - 1 do
begin
J := GetOrdValueAt(I);
if J <> 0 then
Components.Add(TComponent(GetOrdValueAt(I)));
end;
if Components.Count > 0 then
GetComponentProperties(Components, tkProperties, Designer, Proc);
end;
function TClassProperty.GetValue: string;
begin
FmtStr(Result, '(%s)', [GetPropType^.Name]);
end;
{ TComponentProperty }
procedure TComponentProperty.Edit;
var
Temp: TComponent;
begin
if (Designer.GetShiftState * [ssCtrl, ssLeft] = [ssCtrl, ssLeft]) then
begin
Temp := GetComponentReference;
if Temp <> nil then
Designer.SelectComponent(Temp)
else
inherited Edit;
end
else
inherited Edit;
end;
function TComponentProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paMultiSelect];
if Assigned(GetPropInfo^.SetProc) then
Result := Result + [paValueList, paSortList, paRevertable]
else
Result := Result + [paReadOnly];
if GReferenceExpandable and (GetComponentReference <> nil) and AllEqual then
Result := Result + [paSubProperties, paVolatileSubProperties];
end;
function TComponentProperty.GetSelections: IDesignerSelections;
var
I: Integer;
begin
Result := nil;
if (GetComponentReference <> nil) and AllEqual then
begin
Result := TDesignerSelections.Create;
for I := 0 to PropCount - 1 do
Result.Add(TComponent(GetOrdValueAt(I)));
end;
end;
procedure TComponentProperty.GetProperties(Proc: TGetPropProc);
var
LComponents: IDesignerSelections;
LDesigner: IDesigner;
begin
LComponents := GetSelections;
if LComponents <> nil then
begin
if not Supports(FindRootDesigner(LComponents[0]), IDesigner, LDesigner) then
LDesigner := Designer;
GetComponentProperties(LComponents, tkAny, LDesigner, Proc, FilterFunc);
end;
end;
function TComponentProperty.GetEditLimit: Integer;
begin
Result := 127;
end;
function TComponentProperty.GetValue: string;
begin
Result := Designer.GetComponentName(GetComponentReference);
end;
procedure TComponentProperty.GetValues(Proc: TGetStrProc);
begin
Designer.GetComponentNames(GetTypeData(GetPropType), Proc);
end;
procedure TComponentProperty.SetValue(const Value: string);
var
Component: TComponent;
begin
if Value = '' then
Component := nil
else
begin
Component := Designer.GetComponent(Value);
if not (Component is GetTypeData(GetPropType)^.ClassType) then
raise EPropertyError.CreateRes(@SInvalidPropertyValue);
end;
SetOrdValue(LongInt(Component));
end;
function TComponentProperty.AllEqual: Boolean;
var
I: Integer;
LInstance: TComponent;
begin
Result := False;
LInstance := TComponent(GetOrdValue);
if PropCount > 1 then
for I := 1 to PropCount - 1 do
if TComponent(GetOrdValueAt(I)) <> LInstance then
Exit;
Result := Supports(FindRootDesigner(LInstance), IDesigner);
end;
function TComponentProperty.GetComponentReference: TComponent;
begin
Result := TComponent(GetOrdValue);
end;
function TComponentProperty.FilterFunc(const ATestEditor: IProperty): Boolean;
begin
Result := not (paNotNestable in ATestEditor.GetAttributes);
end;
{ TInterfaceProperty }
function TInterfaceProperty.AllEqual: Boolean;
var
I: Integer;
LInterface: IInterface;
begin
Result := False;
LInterface := GetIntfValue;
if PropCount > 1 then
for I := 1 to PropCount - 1 do
if GetIntfValueAt(I) <> LInterface then
Exit;
Result := Supports(FindRootDesigner(GetComponent(LInterface)), IDesigner);
end;
function TInterfaceProperty.GetComponent(const AInterface: IInterface): TComponent;
var
ICR: IInterfaceComponentReference;
begin
if (AInterface <> nil) and
Supports(AInterface, IInterfaceComponentReference, ICR) then
Result := ICR.GetComponent
else
Result := nil;
end;
function TInterfaceProperty.GetComponentReference: TComponent;
begin
Result := GetComponent(GetIntfValue);
end;
function TInterfaceProperty.GetSelections: IDesignerSelections;
var
I: Integer;
begin
Result := nil;
if (GetIntfValue <> nil) and AllEqual then
begin
Result := TDesignerSelections.Create;
for I := 0 to PropCount - 1 do
Result.Add(GetComponent(GetIntfValueAt(I)));
end;
end;
procedure TInterfaceProperty.ReceiveComponentNames(const S: string);
var
Temp: TComponent;
Intf: IInterface;
begin
Temp := Designer.GetComponent(S);
if Assigned(FGetValuesStrProc) and
Assigned(Temp) and
Supports(TObject(Temp), GetTypeData(GetPropType)^.Guid, Intf) then
FGetValuesStrProc(S);
end;
procedure TInterfaceProperty.GetValues(Proc: TGetStrProc);
begin
FGetValuesStrProc := Proc;
try
Designer.GetComponentNames(GetTypeData(TypeInfo(TComponent)), ReceiveComponentNames);
finally
FGetValuesStrProc := nil;
end;
end;
procedure TInterfaceProperty.SetValue(const Value: string);
var
Intf: IInterface;
Component: TComponent;
begin
if Value = '' then
Intf := nil
else
begin
Component := Designer.GetComponent(Value);
if (Component = nil) or
not Supports(TObject(Component), GetTypeData(GetPropType)^.Guid, Intf) then
raise EPropertyError.CreateRes(@SInvalidPropertyValue);
end;
SetIntfValue(Intf);
end;
{ TMethodProperty }
function TMethodProperty.AllEqual: Boolean;
var
I: Integer;
V, T: TMethod;
begin
Result := False;
if PropCount > 1 then
begin
V := GetMethodValue;
for I := 1 to PropCount - 1 do
begin
T := GetMethodValueAt(I);
if (T.Code <> V.Code) or (T.Data <> V.Data) then Exit;
end;
end;
Result := True;
end;
function TMethodProperty.AllNamed: Boolean;
var
I: Integer;
begin
Result := True;
for I := 0 to PropCount - 1 do
if GetComponent(I).GetNamePath = '' then
begin
Result := False;
Break;
end;
end;
procedure TMethodProperty.Edit;
var
FormMethodName: string;
begin
if not AllNamed then
raise EPropertyError.CreateRes(@SCannotCreateName);
FormMethodName := GetValue;
if (FormMethodName = '') or
Designer.MethodFromAncestor(GetMethodValue) then
begin
if FormMethodName = '' then
FormMethodName := GetFormMethodName;
if FormMethodName = '' then
raise EPropertyError.CreateRes(@SCannotCreateName);
SetValue(FormMethodName);
end;
Designer.ShowMethod(FormMethodName);
end;
function TMethodProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paMultiSelect, paValueList, paSortList, paRevertable];
end;
function TMethodProperty.GetEditLimit: Integer;
begin
Result := MaxIdentLength;
end;
function TMethodProperty.GetFormMethodName: string;
var
I: Integer;
begin
if GetComponent(0) = Designer.GetRoot then
begin
Result := Designer.GetRootClassName;
if (Result <> '') and (Result[1] = 'T') then
Delete(Result, 1, 1);
end
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -