mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-20 17:08:40 +02:00
registered TStrings.Strings as define property
git-svn-id: trunk@8400 -
This commit is contained in:
parent
f37495ee05
commit
d36315c0c6
@ -118,7 +118,10 @@ each control that's dropped onto the form
|
|||||||
FSelection: TPersistentSelectionList;
|
FSelection: TPersistentSelectionList;
|
||||||
FObj_Inspector: TObjectInspector;
|
FObj_Inspector: TObjectInspector;
|
||||||
FDefineProperties: TAVLTree;
|
FDefineProperties: TAVLTree;
|
||||||
|
FStandardDefinePropertiesRegistered: Boolean;
|
||||||
function GetPropertyEditorHook: TPropertyEditorHook;
|
function GetPropertyEditorHook: TPropertyEditorHook;
|
||||||
|
function FindDefinePropertyNode(const APersistentClassName: string
|
||||||
|
): TAVLTreeNode;
|
||||||
protected
|
protected
|
||||||
FNonControlForms: TAVLTree; // tree of TNonControlDesignerForm sorted for LookupRoot
|
FNonControlForms: TAVLTree; // tree of TNonControlDesignerForm sorted for LookupRoot
|
||||||
procedure SetSelection(const ASelection: TPersistentSelectionList);
|
procedure SetSelection(const ASelection: TPersistentSelectionList);
|
||||||
@ -212,6 +215,9 @@ each control that's dropped onto the form
|
|||||||
procedure FindDefineProperty(const APersistentClassName,
|
procedure FindDefineProperty(const APersistentClassName,
|
||||||
AncestorClassName, Identifier: string;
|
AncestorClassName, Identifier: string;
|
||||||
var IsDefined: boolean);
|
var IsDefined: boolean);
|
||||||
|
procedure RegisterDefineProperty(const APersistentClassName,
|
||||||
|
Identifier: string);
|
||||||
|
procedure RegisterStandardDefineProperties;
|
||||||
|
|
||||||
// keys
|
// keys
|
||||||
function TranslateKeyToDesignerCommand(Key: word; Shift: TShiftState): word;
|
function TranslateKeyToDesignerCommand(Key: word; Shift: TShiftState): word;
|
||||||
@ -254,7 +260,8 @@ each control that's dropped onto the form
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TDefinePropertiesPersistent }
|
{ TDefinePropertiesPersistent
|
||||||
|
Wrapper class, to call the protected method 'DefineProperties' }
|
||||||
|
|
||||||
TDefinePropertiesPersistent = class(TPersistent)
|
TDefinePropertiesPersistent = class(TPersistent)
|
||||||
private
|
private
|
||||||
@ -274,7 +281,6 @@ function ComparePersClassNameAndDefPropCacheItem(Key: Pointer;
|
|||||||
Item: TDefinePropertiesCacheItem): integer;
|
Item: TDefinePropertiesCacheItem): integer;
|
||||||
procedure RegisterStandardClasses;
|
procedure RegisterStandardClasses;
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
|
||||||
@ -312,7 +318,7 @@ end;
|
|||||||
|
|
||||||
procedure RegisterStandardClasses;
|
procedure RegisterStandardClasses;
|
||||||
begin
|
begin
|
||||||
RegisterClasses([TStrings]);
|
RegisterClasses([TStringList]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TComponentInterface }
|
{ TComponentInterface }
|
||||||
@ -866,7 +872,7 @@ Begin
|
|||||||
ANode:=FComponentInterfaces.FindLowest;
|
ANode:=FComponentInterfaces.FindLowest;
|
||||||
while ANode<>nil do begin
|
while ANode<>nil do begin
|
||||||
Result := TIComponentInterface(ANode.Data);
|
Result := TIComponentInterface(ANode.Data);
|
||||||
if AnsiCompareText(TComponentInterface(Result).Component.Name,Name)=0 then
|
if CompareText(TComponentInterface(Result).Component.Name,Name)=0 then
|
||||||
exit;
|
exit;
|
||||||
ANode:=FComponentInterfaces.FindSuccessor(ANode);
|
ANode:=FComponentInterfaces.FindSuccessor(ANode);
|
||||||
end;
|
end;
|
||||||
@ -1554,11 +1560,8 @@ begin
|
|||||||
// ' AncestorClassName="',AncestorClassName,'"',
|
// ' AncestorClassName="',AncestorClassName,'"',
|
||||||
// ' Identifier="',Identifier,'"');
|
// ' Identifier="',Identifier,'"');
|
||||||
IsDefined:=false;
|
IsDefined:=false;
|
||||||
if FDefineProperties=nil then
|
RegisterStandardDefineProperties;
|
||||||
FDefineProperties:=
|
ANode:=FindDefinePropertyNode(APersistentClassName);
|
||||||
TAVLTree.Create(TListSortCompare(@CompareDefPropCacheItems));
|
|
||||||
ANode:=FDefineProperties.FindKey(PChar(APersistentClassName),
|
|
||||||
TListSortCompare(@ComparePersClassNameAndDefPropCacheItem));
|
|
||||||
if ANode=nil then begin
|
if ANode=nil then begin
|
||||||
// cache component class, try to retrieve the define properties
|
// cache component class, try to retrieve the define properties
|
||||||
CacheItem:=TDefinePropertiesCacheItem.Create;
|
CacheItem:=TDefinePropertiesCacheItem.Create;
|
||||||
@ -1575,7 +1578,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
if APersistent<>nil then begin
|
if APersistent<>nil then begin
|
||||||
//debugln('TCustomFormEditor.GetDefineProperties Getting define properties for ',APersistent.ClassName);
|
debugln('TCustomFormEditor.GetDefineProperties Getting define properties for ',APersistent.ClassName);
|
||||||
|
|
||||||
// try creating a component class and call DefineProperties
|
// try creating a component class and call DefineProperties
|
||||||
DefinePropertiesReader:=nil;
|
DefinePropertiesReader:=nil;
|
||||||
DefinePropertiesPersistent:=nil;
|
DefinePropertiesPersistent:=nil;
|
||||||
@ -1631,6 +1635,34 @@ begin
|
|||||||
IsDefined:=CacheItem.DefineProperties.IndexOf(Identifier)>=0;
|
IsDefined:=CacheItem.DefineProperties.IndexOf(Identifier)>=0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomFormEditor.RegisterDefineProperty(const APersistentClassName,
|
||||||
|
Identifier: string);
|
||||||
|
var
|
||||||
|
ANode: TAVLTreeNode;
|
||||||
|
CacheItem: TDefinePropertiesCacheItem;
|
||||||
|
begin
|
||||||
|
//DebugLn('TCustomFormEditor.RegisterDefineProperty ',APersistentClassName,' ',Identifier);
|
||||||
|
ANode:=FindDefinePropertyNode(APersistentClassName);
|
||||||
|
if ANode=nil then begin
|
||||||
|
CacheItem:=TDefinePropertiesCacheItem.Create;
|
||||||
|
CacheItem.PersistentClassname:=APersistentClassName;
|
||||||
|
FDefineProperties.Add(CacheItem);
|
||||||
|
end else begin
|
||||||
|
CacheItem:=TDefinePropertiesCacheItem(ANode.Data);
|
||||||
|
end;
|
||||||
|
if (CacheItem.DefineProperties=nil) then
|
||||||
|
CacheItem.DefineProperties:=TStringList.Create;
|
||||||
|
if (CacheItem.DefineProperties.IndexOf(Identifier)<0) then
|
||||||
|
CacheItem.DefineProperties.Add(Identifier);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCustomFormEditor.RegisterStandardDefineProperties;
|
||||||
|
begin
|
||||||
|
if FStandardDefinePropertiesRegistered then exit;
|
||||||
|
FStandardDefinePropertiesRegistered:=true;
|
||||||
|
RegisterDefineProperty('TStrings','Strings');
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomFormEditor.JITListReaderError(Sender: TObject;
|
procedure TCustomFormEditor.JITListReaderError(Sender: TObject;
|
||||||
ErrorType: TJITFormError; var Action: TModalResult);
|
ErrorType: TJITFormError; var Action: TModalResult);
|
||||||
var
|
var
|
||||||
@ -1729,6 +1761,16 @@ begin
|
|||||||
Result:=Obj_Inspector.PropertyEditorHook;
|
Result:=Obj_Inspector.PropertyEditorHook;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCustomFormEditor.FindDefinePropertyNode(
|
||||||
|
const APersistentClassName: string): TAVLTreeNode;
|
||||||
|
begin
|
||||||
|
if FDefineProperties=nil then
|
||||||
|
FDefineProperties:=
|
||||||
|
TAVLTree.Create(TListSortCompare(@CompareDefPropCacheItems));
|
||||||
|
Result:=FDefineProperties.FindKey(PChar(APersistentClassName),
|
||||||
|
TListSortCompare(@ComparePersClassNameAndDefPropCacheItem));
|
||||||
|
end;
|
||||||
|
|
||||||
function TCustomFormEditor.CreateUniqueComponentName(AComponent: TComponent
|
function TCustomFormEditor.CreateUniqueComponentName(AComponent: TComponent
|
||||||
): string;
|
): string;
|
||||||
begin
|
begin
|
||||||
@ -1754,7 +1796,7 @@ begin
|
|||||||
Result:=RightStr(Result,length(Result)-1);
|
Result:=RightStr(Result,length(Result)-1);
|
||||||
Result:=Result+IntToStr(i);
|
Result:=Result+IntToStr(i);
|
||||||
while (j>=0)
|
while (j>=0)
|
||||||
and (AnsiCompareText(Result,OwnerComponent.Components[j].Name)<>0) do
|
and (CompareText(Result,OwnerComponent.Components[j].Name)<>0) do
|
||||||
dec(j);
|
dec(j);
|
||||||
if j<0 then exit;
|
if j<0 then exit;
|
||||||
inc(i);
|
inc(i);
|
||||||
@ -1988,7 +2030,7 @@ end;
|
|||||||
|
|
||||||
procedure TDefinePropertiesPersistent.PublicDefineProperties(Filer: TFiler);
|
procedure TDefinePropertiesPersistent.PublicDefineProperties(Filer: TFiler);
|
||||||
begin
|
begin
|
||||||
debugln('TDefinePropertiesPersistent.PublicDefineProperties A ',ClassName,' ',dbgsName(FTarget));
|
debugln('TDefinePropertiesPersistent.PublicDefineProperties START ',ClassName,' ',dbgsName(FTarget));
|
||||||
Target.DefineProperties(Filer);
|
Target.DefineProperties(Filer);
|
||||||
debugln('TDefinePropertiesPersistent.PublicDefineProperties END ',ClassName,' ',dbgsName(FTarget));
|
debugln('TDefinePropertiesPersistent.PublicDefineProperties END ',ClassName,' ',dbgsName(FTarget));
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user