📄 dsgnintf.pas
字号:
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, 'True') = 0 then
Include(S, FElement) else
Exclude(S, FElement);
SetOrdValue(Integer(S));
end;
{ TSetProperty }
function TSetProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paMultiSelect, paSubProperties, paReadOnly, paRevertable];
end;
procedure TSetProperty.GetProperties(Proc: TGetPropEditProc);
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: TGetPropEditProc);
var
I: Integer;
Components: TComponentList;
begin
Components := TComponentList.Create;
try
for I := 0 to PropCount - 1 do
Components.Add(TComponent(GetOrdValueAt(I)));
GetComponentProperties(Components, tkProperties, Designer, Proc);
finally
Components.Free;
end;
end;
function TClassProperty.GetValue: string;
begin
FmtStr(Result, '(%s)', [GetPropType^.Name]);
end;
{ TComponentProperty }
function TComponentProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paMultiSelect, paValueList, paSortList, paRevertable];
end;
function TComponentProperty.GetEditLimit: Integer;
begin
Result := 127;
end;
function TComponentProperty.GetValue: string;
begin
Result := Designer.GetComponentName(TComponent(GetOrdValue));
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.Create(SInvalidPropertyValue);
end;
SetOrdValue(Longint(Component));
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;
procedure TMethodProperty.Edit;
var
FormMethodName: string;
begin
FormMethodName := GetValue;
if (FormMethodName = '') or
Designer.MethodFromAncestor(GetMethodValue) then
begin
if FormMethodName = '' then
FormMethodName := GetFormMethodName;
if FormMethodName = '' then
raise EPropertyError.Create(SCannotCreateName);
SetMethodValue(Designer.CreateMethod(FormMethodName,
GetTypeData(GetPropType)));
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.Form then
Result := 'Form'
else
begin
Result := Designer.GetObjectName(GetComponent(0));
for I := Length(Result) downto 1 do
if Result[I] in ['.','[',']'] then
Delete(Result, I, 1);
end;
if Result = '' then
raise EPropertyError.Create(SCannotCreateName);
Result := Result + GetTrimmedEventName;
end;
function TMethodProperty.GetTrimmedEventName: string;
begin
Result := GetName;
if (Length(Result) >= 2) and
(Result[1] in ['O','o']) and (Result[2] in ['N','n']) then
Delete(Result,1,2);
end;
function TMethodProperty.GetValue: string;
begin
Result := Designer.GetMethodName(GetMethodValue);
end;
procedure TMethodProperty.GetValues(Proc: TGetStrProc);
begin
Designer.GetMethods(GetTypeData(GetPropType), Proc);
end;
procedure TMethodProperty.SetValue(const AValue: string);
var
NewMethod: Boolean;
CurValue: string;
begin
CurValue:= GetValue;
if (CurValue <> '') and (AValue <> '') and
((CompareText(CurValue, AValue) = 0) or
not Designer.MethodExists(AValue)) then
Designer.RenameMethod(CurValue, AValue)
else
begin
NewMethod := (AValue <> '') and not Designer.MethodExists(AValue);
SetMethodValue(Designer.CreateMethod(AValue, GetTypeData(GetPropType)));
if NewMethod then Designer.ShowMethod(AValue);
end;
end;
{ TFontNameProperty }
function TFontNameProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paMultiSelect, paValueList, paSortList, paRevertable];
end;
procedure TFontNameProperty.GetValues(Proc: TGetStrProc);
var
I: Integer;
begin
for I := 0 to Screen.Fonts.Count - 1 do Proc(Screen.Fonts[I]);
end;
{ TFontCharsetProperty }
function TFontCharsetProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paMultiSelect, paSortList, paValueList];
end;
function TFontCharsetProperty.GetValue: string;
begin
if not CharsetToIdent(TFontCharset(GetOrdValue), Result) then
FmtStr(Result, '%d', [GetOrdValue]);
end;
procedure TFontCharsetProperty.GetValues(Proc: TGetStrProc);
begin
GetCharsetValues(Proc);
end;
procedure TFontCharsetProperty.SetValue(const Value: string);
var
NewValue: Longint;
begin
if IdentToCharset(Value, NewValue) then
SetOrdValue(NewValue)
else inherited SetValue(Value);
end;
{ TImeNameProperty }
function TImeNameProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paValueList, paSortList, paMultiSelect];
end;
procedure TImeNameProperty.GetValues(Proc: TGetStrProc);
var
I: Integer;
begin
for I := 0 to Screen.Imes.Count - 1 do Proc(Screen.Imes[I]);
end;
{ TMPFilenameProperty }
procedure TMPFilenameProperty.Edit;
var
MPFileOpen: TOpenDialog;
begin
MPFileOpen := TOpenDialog.Create(Application);
MPFileOpen.Filename := GetValue;
MPFileOpen.Filter := SMPOpenFilter;
MPFileOpen.HelpContext := hcDMediaPlayerOpen;
MPFileOpen.Options := MPFileOpen.Options + [ofShowHelp, ofPathMustExist,
ofFileMustExist];
try
if MPFileOpen.Execute then SetValue(MPFileOpen.Filename);
finally
MPFileOpen.Free;
end;
end;
function TMPFilenameProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog, paRevertable];
end;
{ TColorProperty }
procedure TColorProperty.Edit;
var
ColorDialog: TColorDialog;
IniFile: TRegIniFile;
procedure GetCustomColors;
begin
IniFile := TRegIniFile.Create('\Software\Borland\Delphi\3.0');
try
IniFile.ReadSectionValues(SCustomColors,
ColorDialog.CustomColors);
except
{ Ignore errors reading values }
end;
end;
procedure SaveCustomColors;
var
I, P: Integer;
S: string;
begin
if IniFile <> nil then
with ColorDialog do
for I := 0 to CustomColors.Count - 1 do
begin
S := CustomColors.Strings[I];
P := Pos('=', S);
if P <> 0 then
begin
S := Copy(S, 1, P - 1);
IniFile.WriteString(SCustomColors, S,
CustomColors.Values[S]);
end;
end;
end;
begin
IniFile := nil;
ColorDialog := TColorDialog.Create(Application);
try
GetCustomColors;
ColorDialog.Color := GetOrdValue;
ColorDialog.HelpContext := hcDColorEditor;
ColorDialog.Options := [cdShowHelp];
if ColorDialog.Execute then SetOrdValue(ColorDialog.Color);
SaveCustomColors;
finally
if IniFile <> nil then IniFile.Free;
ColorDialog.Free;
end;
end;
function TColorProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paMultiSelect, paDialog, paValueList, paRevertable];
end;
function TColorProperty.GetValue: string;
begin
Result := ColorToString(TColor(GetOrdValue));
end;
procedure TColorProperty.GetValues(Proc: TGetStrProc);
begin
GetColorValues(Proc);
end;
procedure TColorProperty.SetValue(const Value: string);
var
NewValue: Longint;
begin
if IdentToColor(Value, NewValue) then
SetOrdValue(NewValue)
else inherited SetValue(Value);
end;
{ TCursorProperty }
function TCursorProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paMultiSelect, paValueList, paSortList, paRevertable];
end;
function TCursorProperty.GetValue: string;
begin
Result := CursorToString(TCursor(GetOrdValue));
end;
procedure TCursorProperty.GetValues(Proc: TGetStrProc);
begin
GetCursorValues(Proc);
end;
procedure TCursorProperty.SetValue(const Value: string);
var
NewValue: Longint;
begin
if IdentToCursor(Value, NewValue) then
SetOrdValue(NewValue)
else inherited SetValue(Value);
end;
{ TFontProperty }
procedure TFontProperty.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -