add delphi compatible property editor classnames

git-svn-id: trunk@5075 -
This commit is contained in:
micha 2004-01-19 15:13:15 +00:00
parent 43ca43fc48
commit a38e93a1a7

View File

@ -41,7 +41,7 @@ interface
{$DEFINE NewListPropEdit} {$DEFINE NewListPropEdit}
uses uses
Classes, TypInfo, SysUtils, LCLProc, Forms, Controls, GraphType, Graphics, Classes, TypInfo, SysUtils, LCLProc, Forms, Controls, GraphType, Graphics,
StdCtrls, Buttons, ComCtrls, Menus, LCLType, ExtCtrls, LCLIntf, Dialogs, StdCtrls, Buttons, ComCtrls, Menus, LCLType, ExtCtrls, LCLIntf, Dialogs,
ColumnDlg, ObjInspStrConsts; ColumnDlg, ObjInspStrConsts;
@ -493,7 +493,7 @@ type
procedure GetProperties(Proc: TGetPropEditProc); override; procedure GetProperties(Proc: TGetPropEditProc); override;
function OrdValueToVisualValue(OrdValue: longint): string; override; function OrdValueToVisualValue(OrdValue: longint): string; override;
end; end;
{ TClassPropertyEditor { TClassPropertyEditor
Default property editor for all objects. Does not allow modifying the Default property editor for all objects. Does not allow modifying the
property but does display the class name of the object and will allow the property but does display the class name of the object and will allow the
@ -576,10 +576,10 @@ type
procedure SetValue(const NewValue: ansistring); override; procedure SetValue(const NewValue: ansistring); override;
end; end;
{ TDateProperty { TDatePropertyEditor
Property editor for date portion of TDateTime type. } Property editor for date portion of TDateTime type. }
TDateProperty = class(TPropertyEditor) TDatePropertyEditor = class(TPropertyEditor)
function GetAttributes: TPropertyAttributes; override; function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override; function GetValue: string; override;
procedure SetValue(const Value: string); override; procedure SetValue(const Value: string); override;
@ -719,7 +719,7 @@ type
{ TListPropertyEditor { TListPropertyEditor
A property editor with dynamic sub properties representing a list of objects. A property editor with dynamic sub properties representing a list of objects.
UNDER CONSTRUCTION by Mattias} UNDER CONSTRUCTION by Mattias}
// MWE: changed TObject to TPersistent, TObject decendants can't have properties // MWE: changed TObject to TPersistent, TObject decendants can't have properties
TListPropertyEditor = class(TPropertyEditor) TListPropertyEditor = class(TPropertyEditor)
@ -798,6 +798,43 @@ type
procedure Edit; override; procedure Edit; override;
end; end;
//==============================================================================
// Delphi Compatible Property Editor Classnames
type
TOrdinalProperty = TOrdinalPropertyEditor;
TIntegerProperty = TIntegerPropertyEditor;
TCharProperty = TCharPropertyEditor;
TEnumProperty = TEnumPropertyEditor;
TBoolProperty = TBoolPropertyEditor;
TInt64Property = TInt64PropertyEditor;
TFloatProperty = TFloatPropertyEditor;
TStringProperty = TStringPropertyEditor;
TNestedProperty = TNestedPropertyEditor;
TSetElementProperty = TSetElementPropertyEditor;
TSetProperty = TSetPropertyEditor;
TClassProperty = TClassPropertyEditor;
TMethodProperty = TMethodPropertyEditor;
TComponentProperty = TComponentPropertyEditor;
TComponentNameProperty = TComponentNamePropertyEditor;
// TFontNameProperty = TFontNamePropertyEditor;
// TFontCharsetProperty = TFontCharsetPropertyEditor;
// TImeNameProperty = TImeNamePropertyEditor;
// TColorProperty = TColorPropertyEditor;
// TBrushStyleProperty = TBrushStylePropertyEditor;
// TPenStyleProperty = TPenStylePropertyEditor;
TCursorProperty = TCursorPropertyEditor;
// TFontProperty = TFontPropertyEditor;
TModalResultProperty = TModalResultPropertyEditor;
TShortCutProperty = TShortCutPropertyEditor;
// TMPFilenameProperty = TMPFilenamePropertyEditor;
TTabOrderProperty = TTabOrderPropertyEditor;
TCaptionProperty = TCaptionPropertyEditor;
TDateProperty = TDatePropertyEditor;
TTimeProperty = TTimePropertyEditor;
TDateTimeProperty = TDateTimePropertyEditor;
//============================================================================== //==============================================================================
{ RegisterPropertyEditor { RegisterPropertyEditor
@ -902,7 +939,7 @@ type
procedure Assign(SourceSelectionList: TPersistentSelectionList); procedure Assign(SourceSelectionList: TPersistentSelectionList);
property Items[AIndex: integer]: TPersistent read GetItems write SetItems; default; property Items[AIndex: integer]: TPersistent read GetItems write SetItems; default;
end; end;
TBackupComponentList = class TBackupComponentList = class
private private
FComponentList: TList; FComponentList: TList;
@ -974,7 +1011,7 @@ type
TPropHookModified = procedure(Sender: TObject) of object; TPropHookModified = procedure(Sender: TObject) of object;
TPropHookRevert = procedure(Instance:TPersistent; PropInfo:PPropInfo) of object; TPropHookRevert = procedure(Instance:TPersistent; PropInfo:PPropInfo) of object;
TPropHookRefreshPropertyValues = procedure of object; TPropHookRefreshPropertyValues = procedure of object;
TPropHookType = ( TPropHookType = (
// lookup root // lookup root
htChangeLookupRoot, htChangeLookupRoot,
@ -1227,7 +1264,7 @@ type
//============================================================================== //==============================================================================
Function ClassTypeInfo(Value: TClass): PTypeInfo; Function ClassTypeInfo(Value: TClass): PTypeInfo;
var var
GlobalDesignHook: TPropertyEditorHook; GlobalDesignHook: TPropertyEditorHook;
@ -1353,7 +1390,7 @@ type
{ TPropInfoList } { TPropInfoList }
constructor TPropInfoList.Create(Instance:TPersistent; Filter:TTypeKinds); constructor TPropInfoList.Create(Instance:TPersistent; Filter:TTypeKinds);
var var
BigList: PPropList; BigList: PPropList;
TypeInfo: PTypeInfo; TypeInfo: PTypeInfo;
TypeData: PTypeData; TypeData: PTypeData;
@ -1376,7 +1413,7 @@ begin
// read property count // read property count
CurCount:=PWord(PropInfo)^; CurCount:=PWord(PropInfo)^;
inc(Longint(PropInfo),SizeOf(Word)); inc(Longint(PropInfo),SizeOf(Word));
{writeln('TPropInfoList.Create D ',CurCount,' TypeData^.ClassType=',HexStr(Cardinal(TypeData^.ClassType),8)); {writeln('TPropInfoList.Create D ',CurCount,' TypeData^.ClassType=',HexStr(Cardinal(TypeData^.ClassType),8));
writeln('TPropInfoList.Create E ClassName="',TypeData^.ClassType.ClassName,'"', writeln('TPropInfoList.Create E ClassName="',TypeData^.ClassType.ClassName,'"',
' TypeInfo=',HexStr(Cardinal(TypeInfo),8), ' TypeInfo=',HexStr(Cardinal(TypeInfo),8),
@ -1390,13 +1427,13 @@ begin
' CurParent.ClassInfo=',HexStr(Cardinal(CurParent.ClassInfo),8), ' CurParent.ClassInfo=',HexStr(Cardinal(CurParent.ClassInfo),8),
''); '');
end;} end;}
// read properties // read properties
while CurCount>0 do begin while CurCount>0 do begin
if PropInfo^.PropType^.Kind in Filter then begin if PropInfo^.PropType^.Kind in Filter then begin
// check if name already exists in list // check if name already exists in list
i:=FCount-1; i:=FCount-1;
while (i>=0) and (BigList^[i]^.Name<>PropInfo^.Name) do while (i>=0) and (BigList^[i]^.Name<>PropInfo^.Name) do
dec(i); dec(i);
if (i<0) then begin if (i<0) then begin
// add property info to BigList // add property info to BigList
@ -1412,7 +1449,7 @@ begin
TypeInfo:=TypeData^.ParentInfo; TypeInfo:=TypeData^.ParentInfo;
if TypeInfo=nil then break; if TypeInfo=nil then break;
until false; until false;
// create FList // create FList
FSize:=FCount * SizeOf(Pointer); FSize:=FCount * SizeOf(Pointer);
GetMem(FList,FSize); GetMem(FList,FSize);
@ -1601,7 +1638,7 @@ begin
Candidates.Delete(I); Candidates.Delete(I);
Continue; Continue;
end; end;
EdClass := GetEditorClass(PropInfo, Instance); EdClass := GetEditorClass(PropInfo, Instance);
if EdClass = nil if EdClass = nil
then begin then begin
@ -1632,15 +1669,15 @@ begin
// Create a property info list for each component in the selection // Create a property info list for each component in the selection
for I := 0 to SelCount - 1 do for I := 0 to SelCount - 1 do
PropLists[i] := TPropInfoList.Create(ASelection[I], AFilter); PropLists[i] := TPropInfoList.Create(ASelection[I], AFilter);
// Eliminate each property in Candidates that is not in all property lists // Eliminate each property in Candidates that is not in all property lists
for I := 0 to SelCount - 1 do for I := 0 to SelCount - 1 do
Candidates.Intersect(TPropInfoList(PropLists[I])); Candidates.Intersect(TPropInfoList(PropLists[I]));
// Eliminate each property in the property list that are not in Candidates // Eliminate each property in the property list that are not in Candidates
for I := 0 to SelCount - 1 do for I := 0 to SelCount - 1 do
TPropInfoList(PropLists[I]).Intersect(Candidates); TPropInfoList(PropLists[I]).Intersect(Candidates);
// PropList now has a matrix of PropInfo's. // PropList now has a matrix of PropInfo's.
// -> create a property editor for each property // -> create a property editor for each property
for I := 0 to Candidates.Count - 1 do for I := 0 to Candidates.Count - 1 do
@ -1864,7 +1901,7 @@ Function GetFloatProp(Instance : TObject;PropInfo : PPropInfo) : Extended;
var var
Index,Ivalue : longint; Index,Ivalue : longint;
Value : Extended; Value : Extended;
begin begin
SetIndexValues(PropInfo,Index,Ivalue); SetIndexValues(PropInfo,Index,Ivalue);
case (PropInfo^.PropProcs) and 3 of case (PropInfo^.PropProcs) and 3 of
@ -1881,7 +1918,7 @@ begin
Value:=PComp(Pointer(Instance)+Longint(PropInfo^.GetProc))^; Value:=PComp(Pointer(Instance)+Longint(PropInfo^.GetProc))^;
{$endif m68k} {$endif m68k}
end; end;
ptStatic: ptStatic:
Case GetTypeData(PropInfo^.PropType)^.FloatType of Case GetTypeData(PropInfo^.PropType)^.FloatType of
ftSingle: ftSingle:
@ -3730,14 +3767,14 @@ begin
PropertyHook.ComponentRenamed(TComponent(GetComponent(0))); PropertyHook.ComponentRenamed(TComponent(GetComponent(0)));
end; end;
{ TDateProperty } { TDatePropertyEditor }
function TDateProperty.GetAttributes: TPropertyAttributes; function TDatePropertyEditor.GetAttributes: TPropertyAttributes;
begin begin
Result := [paMultiSelect, paRevertable]; Result := [paMultiSelect, paRevertable];
end; end;
function TDateProperty.GetValue: string; function TDatePropertyEditor.GetValue: string;
var var
DT: TDateTime; DT: TDateTime;
begin begin
@ -3748,7 +3785,7 @@ begin
Result := DateToStr(DT); Result := DateToStr(DT);
end; end;
procedure TDateProperty.SetValue(const Value: string); procedure TDatePropertyEditor.SetValue(const Value: string);
var var
DT: TDateTime; DT: TDateTime;
begin begin
@ -4056,7 +4093,7 @@ const
VK_DELETE or scCtrl, VK_DELETE or scCtrl,
VK_BACK or scAlt, VK_BACK or scAlt,
VK_BACK or scShift or scAlt); VK_BACK or scShift or scAlt);
function TShortCutPropertyEditor.GetAttributes: TPropertyAttributes; function TShortCutPropertyEditor.GetAttributes: TPropertyAttributes;
begin begin
Result := [paMultiSelect, paValueList, paRevertable, paHasDefaultValue]; Result := [paMultiSelect, paValueList, paRevertable, paHasDefaultValue];
@ -4243,7 +4280,7 @@ begin
try try
ListColumns := TListColumns(GetOrdValue); ListColumns := TListColumns(GetOrdValue);
ColumnDlg.Columns.Assign(ListColumns); ColumnDlg.Columns.Assign(ListColumns);
if ColumnDlg.ShowModal = mrOK then begin if ColumnDlg.ShowModal = mrOK then begin
ListColumns.Assign(ColumnDlg.Columns); ListColumns.Assign(ColumnDlg.Columns);
end; end;
@ -5273,7 +5310,7 @@ begin
end; end;
PropertyClassList.Free; PropertyClassList.Free;
PropertyClassList:=nil; PropertyClassList:=nil;
FreeAndNil(ListPropertyEditors); FreeAndNil(ListPropertyEditors);
// XXX workaround for missing typeinfo function // XXX workaround for missing typeinfo function