mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-22 08:20:21 +02:00
IDE: store ResourceBaseClassName of designer components, added DesignerClassCanAppCreateForm
This commit is contained in:
parent
6a2c1915dc
commit
ba1f89639b
@ -191,13 +191,13 @@ type
|
|||||||
private
|
private
|
||||||
FNonFormProxyDesignerFormClass: array[0..1] of TNonFormProxyDesignerFormClass;
|
FNonFormProxyDesignerFormClass: array[0..1] of TNonFormProxyDesignerFormClass;
|
||||||
protected
|
protected
|
||||||
function GetDesignerBaseClasses(Index: integer): TComponentClass; virtual; abstract;
|
|
||||||
function GetStandardDesignerBaseClasses(Index: integer): TComponentClass; virtual; abstract;
|
|
||||||
procedure SetStandardDesignerBaseClasses(Index: integer; AValue: TComponentClass); virtual; abstract;
|
|
||||||
function GetDesigner(Index: integer): TIDesigner; virtual; abstract;
|
function GetDesigner(Index: integer): TIDesigner; virtual; abstract;
|
||||||
|
function GetDesignerBaseClasses(Index: integer): TComponentClass; virtual; abstract;
|
||||||
function GetDesignerMediators(Index: integer): TDesignerMediatorClass; virtual; abstract;
|
function GetDesignerMediators(Index: integer): TDesignerMediatorClass; virtual; abstract;
|
||||||
function GetNonFormProxyDesignerForm(Index: Integer): TNonFormProxyDesignerFormClass; virtual;
|
function GetNonFormProxyDesignerForm(Index: Integer): TNonFormProxyDesignerFormClass; virtual;
|
||||||
|
function GetStandardDesignerBaseClasses(Index: integer): TComponentClass; virtual; abstract;
|
||||||
procedure SetNonFormProxyDesignerForm(Index: Integer; AValue: TNonFormProxyDesignerFormClass); virtual;
|
procedure SetNonFormProxyDesignerForm(Index: Integer; AValue: TNonFormProxyDesignerFormClass); virtual;
|
||||||
|
procedure SetStandardDesignerBaseClasses(Index: integer; AValue: TComponentClass); virtual; abstract;
|
||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create;
|
||||||
// persistent
|
// persistent
|
||||||
@ -245,6 +245,8 @@ type
|
|||||||
function IndexOfDesignerBaseClass(AClass: TComponentClass): integer; virtual; abstract;
|
function IndexOfDesignerBaseClass(AClass: TComponentClass): integer; virtual; abstract;
|
||||||
function DescendFromDesignerBaseClass(AClass: TComponentClass): integer; virtual; abstract;
|
function DescendFromDesignerBaseClass(AClass: TComponentClass): integer; virtual; abstract;
|
||||||
function FindDesignerBaseClassByName(const AClassName: shortstring; WithDefaults: boolean): TComponentClass; virtual; abstract;
|
function FindDesignerBaseClassByName(const AClassName: shortstring; WithDefaults: boolean): TComponentClass; virtual; abstract;
|
||||||
|
function DesignerClassCanAppCreateForm(AClass: TComponentClass; CheckInherited: boolean = true): boolean; virtual; abstract;
|
||||||
|
procedure SetDesignerBaseClassCanAppCreateForm(AClass: TComponentClass; Value: boolean); virtual; abstract;
|
||||||
|
|
||||||
property StandardDesignerBaseClasses[Index: integer]: TComponentClass read GetStandardDesignerBaseClasses
|
property StandardDesignerBaseClasses[Index: integer]: TComponentClass read GetStandardDesignerBaseClasses
|
||||||
write SetStandardDesignerBaseClasses;
|
write SetStandardDesignerBaseClasses;
|
||||||
|
@ -76,6 +76,7 @@ type
|
|||||||
FDesignerBaseClasses: TFPList; // list of TComponentClass
|
FDesignerBaseClasses: TFPList; // list of TComponentClass
|
||||||
FDesignerMediatorClasses: TFPList;// list of TDesignerMediatorClass
|
FDesignerMediatorClasses: TFPList;// list of TDesignerMediatorClass
|
||||||
FOnNodeGetImageIndex: TOnOINodeGetImageEvent;
|
FOnNodeGetImageIndex: TOnOINodeGetImageEvent;
|
||||||
|
FDesignerBaseClassesCanCreateForm: TFPList; // list of TComponentClass
|
||||||
function GetPropertyEditorHook: TPropertyEditorHook;
|
function GetPropertyEditorHook: TPropertyEditorHook;
|
||||||
function FindDefinePropertyNode(const APersistentClassName: string
|
function FindDefinePropertyNode(const APersistentClassName: string
|
||||||
): TAvlTreeNode;
|
): TAvlTreeNode;
|
||||||
@ -181,6 +182,10 @@ type
|
|||||||
function IndexOfDesignerBaseClass(AClass: TComponentClass): integer; override;
|
function IndexOfDesignerBaseClass(AClass: TComponentClass): integer; override;
|
||||||
function DescendFromDesignerBaseClass(AClass: TComponentClass): integer; override;
|
function DescendFromDesignerBaseClass(AClass: TComponentClass): integer; override;
|
||||||
function FindDesignerBaseClassByName(const AClassName: shortstring; WithDefaults: boolean): TComponentClass; override; // can be UnitName/ClassName
|
function FindDesignerBaseClassByName(const AClassName: shortstring; WithDefaults: boolean): TComponentClass; override; // can be UnitName/ClassName
|
||||||
|
function DesignerClassCanAppCreateForm(AClass: TComponentClass;
|
||||||
|
CheckInherited: boolean=true): boolean; override;
|
||||||
|
procedure SetDesignerBaseClassCanAppCreateForm(AClass: TComponentClass;
|
||||||
|
AValue: boolean); override;
|
||||||
|
|
||||||
function StandardDesignerBaseClassesCount: Integer; override;
|
function StandardDesignerBaseClassesCount: Integer; override;
|
||||||
// designers
|
// designers
|
||||||
@ -497,6 +502,7 @@ begin
|
|||||||
FNonFormForms := TAvlTree.Create(@CompareNonFormDesignerForms);
|
FNonFormForms := TAvlTree.Create(@CompareNonFormDesignerForms);
|
||||||
FSelection := TPersistentSelectionList.Create;
|
FSelection := TPersistentSelectionList.Create;
|
||||||
FDesignerBaseClasses:=TFPList.Create;
|
FDesignerBaseClasses:=TFPList.Create;
|
||||||
|
FDesignerBaseClassesCanCreateForm:=TFPList.Create;
|
||||||
FDesignerMediatorClasses:=TFPList.Create;
|
FDesignerMediatorClasses:=TFPList.Create;
|
||||||
for l:=0 to StandardDesignerBaseClassesCount - 1 do
|
for l:=0 to StandardDesignerBaseClassesCount - 1 do
|
||||||
FDesignerBaseClasses.Add(StandardDesignerBaseClasses[l]);
|
FDesignerBaseClasses.Add(StandardDesignerBaseClasses[l]);
|
||||||
@ -529,6 +535,7 @@ begin
|
|||||||
FreeAndNil(JITFormList);
|
FreeAndNil(JITFormList);
|
||||||
FreeAndNil(JITNonFormList);
|
FreeAndNil(JITNonFormList);
|
||||||
FreeAndNil(FDesignerMediatorClasses);
|
FreeAndNil(FDesignerMediatorClasses);
|
||||||
|
FreeAndNil(FDesignerBaseClassesCanCreateForm);
|
||||||
FreeAndNil(FDesignerBaseClasses);
|
FreeAndNil(FDesignerBaseClasses);
|
||||||
FreeAndNil(FSelection);
|
FreeAndNil(FSelection);
|
||||||
FreeAndNil(FNonFormForms);
|
FreeAndNil(FNonFormForms);
|
||||||
@ -1878,11 +1885,19 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomFormEditor.DescendFromDesignerBaseClass(AClass: TComponentClass): integer;
|
function TCustomFormEditor.DescendFromDesignerBaseClass(AClass: TComponentClass): integer;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
Result:=FDesignerBaseClasses.Count-1;
|
Result:=-1;
|
||||||
while (Result>=0)
|
for i:=0 to FDesignerBaseClasses.Count-1 do
|
||||||
and (not AClass.InheritsFrom(TClass(FDesignerBaseClasses[Result]))) do
|
begin
|
||||||
dec(Result);
|
if AClass.InheritsFrom(TClass(FDesignerBaseClasses[i])) then
|
||||||
|
begin
|
||||||
|
if (Result<0)
|
||||||
|
or (TClass(FDesignerBaseClassesCanCreateForm[i]).InheritsFrom(TClass(FDesignerBaseClasses[Result]))) then
|
||||||
|
Result:=i;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomFormEditor.FindDesignerBaseClassByName(
|
function TCustomFormEditor.FindDesignerBaseClassByName(
|
||||||
@ -2204,6 +2219,41 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCustomFormEditor.DesignerClassCanAppCreateForm(
|
||||||
|
AClass: TComponentClass; CheckInherited: boolean): boolean;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
Result:=false;
|
||||||
|
if AClass=nil then exit;
|
||||||
|
// check standard classes
|
||||||
|
if (AClass=TCustomForm) or (AClass=TDataModule) then
|
||||||
|
exit(true);
|
||||||
|
if CheckInherited and (AClass.InheritsFrom(TCustomForm) or AClass.InheritsFrom(TDataModule)) then
|
||||||
|
exit(true);
|
||||||
|
// check addons
|
||||||
|
Result:=FDesignerBaseClassesCanCreateForm.IndexOf(AClass)>=0;
|
||||||
|
if CheckInherited then
|
||||||
|
begin
|
||||||
|
for i:=0 to FDesignerBaseClassesCanCreateForm.Count-1 do
|
||||||
|
if AClass.InheritsFrom(TComponentClass(FDesignerBaseClassesCanCreateForm[i])) then
|
||||||
|
exit(true);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCustomFormEditor.SetDesignerBaseClassCanAppCreateForm(
|
||||||
|
AClass: TComponentClass; AValue: boolean);
|
||||||
|
begin
|
||||||
|
if AValue then
|
||||||
|
begin
|
||||||
|
if FDesignerBaseClassesCanCreateForm.IndexOf(AClass)>=0 then exit;
|
||||||
|
FDesignerBaseClassesCanCreateForm.Add(AClass);
|
||||||
|
end else begin
|
||||||
|
if FDesignerBaseClassesCanCreateForm.IndexOf(AClass)<0 then exit;
|
||||||
|
FDesignerBaseClassesCanCreateForm.Remove(AClass);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TCustomFormEditor.FindNonFormFormNode(LookupRoot: TComponent): TAvlTreeNode;
|
function TCustomFormEditor.FindNonFormFormNode(LookupRoot: TComponent): TAvlTreeNode;
|
||||||
begin
|
begin
|
||||||
Result := FNonFormForms.FindKey(Pointer(LookupRoot),
|
Result := FNonFormForms.FindKey(Pointer(LookupRoot),
|
||||||
|
@ -295,6 +295,7 @@ type
|
|||||||
fOnLoadSaveFilename: TOnLoadSaveFilename;
|
fOnLoadSaveFilename: TOnLoadSaveFilename;
|
||||||
FOnUnitNameChange: TOnUnitNameChange;
|
FOnUnitNameChange: TOnUnitNameChange;
|
||||||
FProject: TProject;
|
FProject: TProject;
|
||||||
|
FResourceBaseClassname: string;
|
||||||
FRevertLockCount: integer;// >0 means IDE is currently reverting this unit
|
FRevertLockCount: integer;// >0 means IDE is currently reverting this unit
|
||||||
fSource: TCodeBuffer;
|
fSource: TCodeBuffer;
|
||||||
FSourceLFM: TCodeBuffer;
|
FSourceLFM: TCodeBuffer;
|
||||||
@ -465,6 +466,7 @@ type
|
|||||||
property ComponentState: TWindowState read FComponentState write FComponentState;
|
property ComponentState: TWindowState read FComponentState write FComponentState;
|
||||||
property ResourceBaseClass: TPFComponentBaseClass read FResourceBaseClass
|
property ResourceBaseClass: TPFComponentBaseClass read FResourceBaseClass
|
||||||
write FResourceBaseClass;
|
write FResourceBaseClass;
|
||||||
|
property ResourceBaseClassname: string read FResourceBaseClassname write FResourceBaseClassname;
|
||||||
property ComponentLastBinStreamSize: TStreamSeekType
|
property ComponentLastBinStreamSize: TStreamSeekType
|
||||||
read FComponentLastBinStreamSize write FComponentLastBinStreamSize;
|
read FComponentLastBinStreamSize write FComponentLastBinStreamSize;
|
||||||
property ComponentLastLRSStreamSize: TStreamSeekType
|
property ComponentLastLRSStreamSize: TStreamSeekType
|
||||||
@ -1107,7 +1109,7 @@ type
|
|||||||
write SetActiveBuildMode;
|
write SetActiveBuildMode;
|
||||||
property ActiveWindowIndexAtStart: integer read FActiveWindowIndexAtStart
|
property ActiveWindowIndexAtStart: integer read FActiveWindowIndexAtStart
|
||||||
write FActiveWindowIndexAtStart;
|
write FActiveWindowIndexAtStart;
|
||||||
property AutoCreateForms: boolean read FAutoCreateForms write FAutoCreateForms;
|
property AutoCreateForms: boolean read FAutoCreateForms write FAutoCreateForms; // add CreateForm for new forms
|
||||||
property AutoOpenDesignerFormsDisabled: boolean read FAutoOpenDesignerFormsDisabled
|
property AutoOpenDesignerFormsDisabled: boolean read FAutoOpenDesignerFormsDisabled
|
||||||
write SetAutoOpenDesignerFormsDisabled;
|
write SetAutoOpenDesignerFormsDisabled;
|
||||||
property Bookmarks: TProjectBookmarkList read FBookmarks write FBookmarks;
|
property Bookmarks: TProjectBookmarkList read FBookmarks write FBookmarks;
|
||||||
@ -1852,6 +1854,9 @@ begin
|
|||||||
XMLConfig.SetDeleteValue(Path+'ResourceBaseClass/Value',
|
XMLConfig.SetDeleteValue(Path+'ResourceBaseClass/Value',
|
||||||
PFComponentBaseClassNames[FResourceBaseClass],
|
PFComponentBaseClassNames[FResourceBaseClass],
|
||||||
PFComponentBaseClassNames[pfcbcNone]);
|
PFComponentBaseClassNames[pfcbcNone]);
|
||||||
|
XMLConfig.SetDeleteValue(Path+'ResourceBaseClassname/Value',
|
||||||
|
FResourceBaseClassname,
|
||||||
|
DefaultResourceBaseClassnames[FResourceBaseClass]);
|
||||||
s:=FUnitName;
|
s:=FUnitName;
|
||||||
if (s<>'') and (ExtractFileNameOnly(Filename)=s) then s:=''; // only save if UnitName differs from filename
|
if (s<>'') and (ExtractFileNameOnly(Filename)=s) then s:=''; // only save if UnitName differs from filename
|
||||||
XMLConfig.SetDeleteValue(Path+'UnitName/Value',s,'');
|
XMLConfig.SetDeleteValue(Path+'UnitName/Value',s,'');
|
||||||
@ -1926,6 +1931,8 @@ begin
|
|||||||
HasResources:=XMLConfig.GetValue(Path+'HasResources/Value',false);
|
HasResources:=XMLConfig.GetValue(Path+'HasResources/Value',false);
|
||||||
FResourceBaseClass:=StrToComponentBaseClass(
|
FResourceBaseClass:=StrToComponentBaseClass(
|
||||||
XMLConfig.GetValue(Path+'ResourceBaseClass/Value',''));
|
XMLConfig.GetValue(Path+'ResourceBaseClass/Value',''));
|
||||||
|
FResourceBaseClassname:=XMLConfig.GetValue(Path+'ResourceBaseClassname/Value',
|
||||||
|
DefaultResourceBaseClassnames[FResourceBaseClass]);
|
||||||
if not IgnoreIsPartOfProject then
|
if not IgnoreIsPartOfProject then
|
||||||
IsPartOfProject:=XMLConfig.GetValue(Path+'IsPartOfProject/Value',false);
|
IsPartOfProject:=XMLConfig.GetValue(Path+'IsPartOfProject/Value',false);
|
||||||
AFilename:=XMLConfig.GetValue(Path+'ResourceFilename/Value','');
|
AFilename:=XMLConfig.GetValue(Path+'ResourceFilename/Value','');
|
||||||
|
@ -69,7 +69,7 @@ uses
|
|||||||
ProjectIntf, PackageIntf, PackageLinkIntf, PackageDependencyIntf,
|
ProjectIntf, PackageIntf, PackageLinkIntf, PackageDependencyIntf,
|
||||||
// IDEIntf
|
// IDEIntf
|
||||||
IDEHelpIntf, IDECommands, IDEDialogs, IDEImagesIntf, LazIDEIntf, ToolBarIntf,
|
IDEHelpIntf, IDECommands, IDEDialogs, IDEImagesIntf, LazIDEIntf, ToolBarIntf,
|
||||||
IdeIntfStrConsts, MenuIntf, InputHistory,
|
IdeIntfStrConsts, MenuIntf, FormEditingIntf, InputHistory,
|
||||||
// IdeConfig
|
// IdeConfig
|
||||||
EnvironmentOpts, IDEOptionDefs, TransferMacros, IDEProcs,
|
EnvironmentOpts, IDEOptionDefs, TransferMacros, IDEProcs,
|
||||||
// IDE
|
// IDE
|
||||||
@ -315,6 +315,15 @@ implementation
|
|||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
function UpdateUnitInfoResourceBaseClass(AnUnitInfo: TUnitInfo; Quiet: boolean): boolean;
|
function UpdateUnitInfoResourceBaseClass(AnUnitInfo: TUnitInfo; Quiet: boolean): boolean;
|
||||||
|
|
||||||
|
procedure ClearUnitResInfo;
|
||||||
|
begin
|
||||||
|
AnUnitInfo.ResourceBaseClass:=pfcbcNone;
|
||||||
|
AnUnitInfo.ResourceBaseClassname:='';
|
||||||
|
AnUnitInfo.ComponentName:='';
|
||||||
|
AnUnitInfo.ComponentResourceName:='';
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
LFMFilename, LFMType, Ancestor, LFMClassName, LFMComponentName: String;
|
LFMFilename, LFMType, Ancestor, LFMClassName, LFMComponentName: String;
|
||||||
LFMCode, Code: TCodeBuffer;
|
LFMCode, Code: TCodeBuffer;
|
||||||
@ -325,6 +334,7 @@ var
|
|||||||
ListOfPFindContext: TFPList;
|
ListOfPFindContext: TFPList;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
Context: PFindContext;
|
Context: PFindContext;
|
||||||
|
CompClass, aDesignerBaseClass: TComponentClass;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
if AnUnitInfo.Component<>nil then
|
if AnUnitInfo.Component<>nil then
|
||||||
@ -343,18 +353,14 @@ begin
|
|||||||
exit(true); // no lfm -> clear info
|
exit(true); // no lfm -> clear info
|
||||||
finally
|
finally
|
||||||
if ClearOldInfo then begin
|
if ClearOldInfo then begin
|
||||||
AnUnitInfo.ResourceBaseClass:=pfcbcNone;
|
ClearUnitResInfo;
|
||||||
AnUnitInfo.ComponentName:='';
|
|
||||||
AnUnitInfo.ComponentResourceName:='';
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
try
|
try
|
||||||
if not FilenameExtIs(LFMFilename,'lfm',true) then
|
if not FilenameExtIs(LFMFilename,'lfm',true) then
|
||||||
exit(true); // no lfm format -> keep old info
|
exit(true); // no lfm format -> keep old info
|
||||||
// clear old info
|
// clear old info
|
||||||
AnUnitInfo.ResourceBaseClass:=pfcbcNone;
|
ClearUnitResInfo;
|
||||||
AnUnitInfo.ComponentName:='';
|
|
||||||
AnUnitInfo.ComponentResourceName:='';
|
|
||||||
// load lfm
|
// load lfm
|
||||||
LoadFileFlags:=[lbfUpdateFromDisk,lbfCheckIfText];
|
LoadFileFlags:=[lbfUpdateFromDisk,lbfCheckIfText];
|
||||||
if Quiet then
|
if Quiet then
|
||||||
@ -376,6 +382,7 @@ begin
|
|||||||
CodeToolBoss.Explore(Code,Tool,false,true);
|
CodeToolBoss.Explore(Code,Tool,false,true);
|
||||||
if Tool=nil then
|
if Tool=nil then
|
||||||
exit; // pas load error
|
exit; // pas load error
|
||||||
|
aDesignerBaseClass:=nil;
|
||||||
try
|
try
|
||||||
Node:=Tool.FindDeclarationNodeInInterface(LFMClassName,true);
|
Node:=Tool.FindDeclarationNodeInInterface(LFMClassName,true);
|
||||||
if Node=nil then
|
if Node=nil then
|
||||||
@ -391,37 +398,59 @@ begin
|
|||||||
for i:=0 to ListOfPFindContext.Count-1 do begin
|
for i:=0 to ListOfPFindContext.Count-1 do begin
|
||||||
Context:=PFindContext(ListOfPFindContext[i]);
|
Context:=PFindContext(ListOfPFindContext[i]);
|
||||||
Ancestor:=UpperCase(Context^.Tool.ExtractClassName(Context^.Node,false));
|
Ancestor:=UpperCase(Context^.Tool.ExtractClassName(Context^.Node,false));
|
||||||
if (Ancestor='TFORM') then begin
|
case Ancestor of
|
||||||
AnUnitInfo.ResourceBaseClass:=pfcbcForm;
|
'TFORM':
|
||||||
|
begin
|
||||||
|
AnUnitInfo.ResourceBaseClass:=pfcbcForm;
|
||||||
|
aDesignerBaseClass:=TForm;
|
||||||
|
end;
|
||||||
|
'TCUSTOMFORM':
|
||||||
|
begin
|
||||||
|
AnUnitInfo.ResourceBaseClass:=pfcbcCustomForm;
|
||||||
|
aDesignerBaseClass:=TCustomForm;
|
||||||
|
end;
|
||||||
|
'TDATAMODULE':
|
||||||
|
begin
|
||||||
|
AnUnitInfo.ResourceBaseClass:=pfcbcDataModule;
|
||||||
|
aDesignerBaseClass:=TDataModule;
|
||||||
|
end;
|
||||||
|
'TFRAME':
|
||||||
|
begin
|
||||||
|
AnUnitInfo.ResourceBaseClass:=pfcbcFrame;
|
||||||
|
aDesignerBaseClass:=TFrame;
|
||||||
|
end;
|
||||||
|
'TCUSTOMFRAME':
|
||||||
|
begin
|
||||||
|
AnUnitInfo.ResourceBaseClass:=pfcbcFrame;
|
||||||
|
aDesignerBaseClass:=TCustomFrame;
|
||||||
|
end;
|
||||||
|
'TCOMPONENT':
|
||||||
|
begin
|
||||||
|
CompClass:=FormEditingHook.FindDesignerBaseClassByName(Ancestor,false);
|
||||||
|
if CompClass<>nil then
|
||||||
|
begin
|
||||||
|
AnUnitInfo.ResourceBaseClass:=pfcbcOther;
|
||||||
|
aDesignerBaseClass:=CompClass;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
if aDesignerBaseClass<>nil then
|
||||||
|
begin
|
||||||
|
AnUnitInfo.ResourceBaseClassname:=aDesignerBaseClass.ClassName;
|
||||||
Result:=true;
|
Result:=true;
|
||||||
Break;
|
break;
|
||||||
end else if (Ancestor='TCUSTOMFORM') then begin
|
|
||||||
AnUnitInfo.ResourceBaseClass:=pfcbcCustomForm;
|
|
||||||
Result:=true;
|
|
||||||
Break;
|
|
||||||
end else if Ancestor='TDATAMODULE' then begin
|
|
||||||
AnUnitInfo.ResourceBaseClass:=pfcbcDataModule;
|
|
||||||
Result:=true;
|
|
||||||
Break;
|
|
||||||
end else if (Ancestor='TFRAME') or (Ancestor='TCUSTOMFRAME') then begin
|
|
||||||
AnUnitInfo.ResourceBaseClass:=pfcbcFrame;
|
|
||||||
Result:=true;
|
|
||||||
Break;
|
|
||||||
end else if Ancestor='TCOMPONENT' then begin
|
|
||||||
Result:=true;
|
|
||||||
Break;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
if aDesignerBaseClass=nil then exit;
|
||||||
except
|
except
|
||||||
exit; // syntax error or unit not found
|
exit; // syntax error or unit not found
|
||||||
end;
|
end;
|
||||||
if not Result then exit;
|
|
||||||
|
|
||||||
// Maybe auto-create it
|
// Maybe auto-create it
|
||||||
// (pfMainUnitHasCreateFormStatements in Project1.Flags)
|
if (LFMComponentName<>'')
|
||||||
// and Project1.AutoCreateForms are checked by caller.
|
and (pfMainUnitHasCreateFormStatements in Project1.Flags)
|
||||||
if (AnUnitInfo.ResourceBaseClass in [pfcbcForm,pfcbcCustomForm,pfcbcDataModule])
|
and Project1.AutoCreateForms
|
||||||
and (LFMComponentName<>'')
|
and FormEditingHook.DesignerClassCanAppCreateForm(aDesignerBaseClass)
|
||||||
and (IDEMessageDialog(lisAddToStartupComponents,
|
and (IDEMessageDialog(lisAddToStartupComponents,
|
||||||
Format(lisShouldTheComponentBeAutoCreatedWhenTheApplicationS,
|
Format(lisShouldTheComponentBeAutoCreatedWhenTheApplicationS,
|
||||||
[LFMComponentName]),
|
[LFMComponentName]),
|
||||||
|
@ -268,7 +268,7 @@ procedure CompleteUnitComponent(AnUnitInfo: TUnitInfo;
|
|||||||
function RemoveFilesFromProject(UnitInfos: TFPList): TModalResult;
|
function RemoveFilesFromProject(UnitInfos: TFPList): TModalResult;
|
||||||
function AskSaveProject(const ContinueText, ContinueBtn: string): TModalResult;
|
function AskSaveProject(const ContinueText, ContinueBtn: string): TModalResult;
|
||||||
function SaveEditorChangesToCodeCache(AEditor: TSourceEditorInterface): boolean;
|
function SaveEditorChangesToCodeCache(AEditor: TSourceEditorInterface): boolean;
|
||||||
|
function GetDsgnComponentBaseClassname(aCompClass: TClass): string;
|
||||||
|
|
||||||
// These are local functions. Forward reference is needed for most of them.
|
// These are local functions. Forward reference is needed for most of them.
|
||||||
// function AskToSaveEditors(EditorList: TList): TModalResult;
|
// function AskToSaveEditors(EditorList: TList): TModalResult;
|
||||||
@ -2287,12 +2287,16 @@ begin
|
|||||||
LRSFilename:=ChangeFileExt(NewUnitInfo.Filename,'.lrs');
|
LRSFilename:=ChangeFileExt(NewUnitInfo.Filename,'.lrs');
|
||||||
CodeToolBoss.CreateFile(LRSFilename);
|
CodeToolBoss.CreateFile(LRSFilename);
|
||||||
end;
|
end;
|
||||||
if ((NewUnitInfo.Component is TCustomForm) or (NewUnitInfo.Component is TDataModule))
|
//debugln(['NewFile custom LFM: ',DbgSName(NewUnitInfo.Component),' NewFileDescriptor.UseCreateFormStatements=',NewFileDescriptor.UseCreateFormStatements,' NewUnitInfo.IsPartOfProject=',NewUnitInfo.IsPartOfProject,' AProject.AutoCreateForms=',AProject.AutoCreateForms,' pfMainUnitHasCreateFormStatements=',pfMainUnitHasCreateFormStatements in AProject.Flags,' DesignerClassCanAppCreateForm=',(NewUnitInfo.Component<>nil) and (FormEditingHook.DesignerClassCanAppCreateForm(TComponentClass(NewUnitInfo.Component.ClassType)))]);
|
||||||
|
|
||||||
|
if (NewUnitInfo.Component<>nil)
|
||||||
and NewFileDescriptor.UseCreateFormStatements
|
and NewFileDescriptor.UseCreateFormStatements
|
||||||
and NewUnitInfo.IsPartOfProject
|
and NewUnitInfo.IsPartOfProject
|
||||||
and AProject.AutoCreateForms
|
and AProject.AutoCreateForms
|
||||||
and (pfMainUnitHasCreateFormStatements in AProject.Flags) then
|
and (pfMainUnitHasCreateFormStatements in AProject.Flags)
|
||||||
begin
|
and FormEditingHook.DesignerClassCanAppCreateForm(
|
||||||
|
TComponentClass(NewUnitInfo.Component.ClassType))
|
||||||
|
then begin
|
||||||
AProject.AddCreateFormToProjectFile(NewUnitInfo.Component.ClassName,
|
AProject.AddCreateFormToProjectFile(NewUnitInfo.Component.ClassName,
|
||||||
NewUnitInfo.Component.Name);
|
NewUnitInfo.Component.Name);
|
||||||
end;
|
end;
|
||||||
@ -4586,6 +4590,7 @@ begin
|
|||||||
and (csSetCaption in TControl(NewComponent).ControlStyle) then
|
and (csSetCaption in TControl(NewComponent).ControlStyle) then
|
||||||
TControl(NewComponent).Caption:=NewComponent.Name;
|
TControl(NewComponent).Caption:=NewComponent.Name;
|
||||||
NewUnitInfo.Component := NewComponent;
|
NewUnitInfo.Component := NewComponent;
|
||||||
|
NewUnitInfo.ResourceBaseClassname:=GetDsgnComponentBaseClassname(NewComponent.ClassType);
|
||||||
MainIDE.CreateDesignerForComponent(NewUnitInfo,NewComponent);
|
MainIDE.CreateDesignerForComponent(NewUnitInfo,NewComponent);
|
||||||
if NewComponent is TCustomDesignControl then
|
if NewComponent is TCustomDesignControl then
|
||||||
begin
|
begin
|
||||||
@ -4595,11 +4600,13 @@ begin
|
|||||||
|
|
||||||
NewUnitInfo.ComponentName:=NewComponent.Name;
|
NewUnitInfo.ComponentName:=NewComponent.Name;
|
||||||
NewUnitInfo.ComponentResourceName:=NewUnitInfo.ComponentName;
|
NewUnitInfo.ComponentResourceName:=NewUnitInfo.ComponentName;
|
||||||
|
//debugln(['CreateNewForm: ',DbgSName(NewUnitInfo.Component),' UseCreateFormStatements=',UseCreateFormStatements,' NewUnitInfo.IsPartOfProject=',NewUnitInfo.IsPartOfProject,' AProject.AutoCreateForms=',Project1.AutoCreateForms,' pfMainUnitHasCreateFormStatements=',pfMainUnitHasCreateFormStatements in Project1.Flags,' DesignerClassCanAppCreateForm=',(NewUnitInfo.Component<>nil) and (FormEditingHook.DesignerClassCanAppCreateForm(TComponentClass(NewUnitInfo.Component.ClassType)))]);
|
||||||
if UseCreateFormStatements
|
if UseCreateFormStatements
|
||||||
and ((NewComponent is TCustomForm) or (NewComponent is TDataModule))
|
|
||||||
and NewUnitInfo.IsPartOfProject
|
and NewUnitInfo.IsPartOfProject
|
||||||
and Project1.AutoCreateForms
|
and Project1.AutoCreateForms
|
||||||
and (pfMainUnitHasCreateFormStatements in Project1.Flags) then
|
and (pfMainUnitHasCreateFormStatements in Project1.Flags)
|
||||||
|
and FormEditor1.DesignerClassCanAppCreateForm(
|
||||||
|
TComponentClass(NewComponent.ClassType)) then
|
||||||
begin
|
begin
|
||||||
Project1.AddCreateFormToProjectFile(NewComponent.ClassName,
|
Project1.AddCreateFormToProjectFile(NewComponent.ClassName,
|
||||||
NewComponent.Name);
|
NewComponent.Name);
|
||||||
@ -6267,6 +6274,8 @@ begin
|
|||||||
|
|
||||||
Project1.InvalidateUnitComponentDesignerDependencies;
|
Project1.InvalidateUnitComponentDesignerDependencies;
|
||||||
AnUnitInfo.Component:=NewComponent;
|
AnUnitInfo.Component:=NewComponent;
|
||||||
|
if NewComponent<>nil then
|
||||||
|
AnUnitInfo.ResourceBaseClassname:=GetDsgnComponentBaseClassname(NewComponent.ClassType);
|
||||||
if (AncestorUnitInfo<>nil) then
|
if (AncestorUnitInfo<>nil) then
|
||||||
AnUnitInfo.AddRequiresComponentDependency(AncestorUnitInfo,[ucdtAncestor]);
|
AnUnitInfo.AddRequiresComponentDependency(AncestorUnitInfo,[ucdtAncestor]);
|
||||||
if NewComponent<>nil then begin
|
if NewComponent<>nil then begin
|
||||||
@ -8320,6 +8329,27 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function GetDsgnComponentBaseClassname(aCompClass: TClass): string;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
Result:='';
|
||||||
|
if aCompClass=nil then exit;
|
||||||
|
if aCompClass.InheritsFrom(TForm) then
|
||||||
|
exit(DefaultResourceBaseClassnames[pfcbcForm])
|
||||||
|
else if aCompClass=TCustomForm then
|
||||||
|
exit(DefaultResourceBaseClassnames[pfcbcCustomForm])
|
||||||
|
else if aCompClass.InheritsFrom(TFrame) then
|
||||||
|
exit(DefaultResourceBaseClassnames[pfcbcFrame])
|
||||||
|
else if aCompClass=TCustomFrame then
|
||||||
|
exit('TCustomFrame')
|
||||||
|
else if aCompClass.InheritsFrom(TDataModule) then
|
||||||
|
exit(DefaultResourceBaseClassnames[pfcbcDataModule]);
|
||||||
|
i:=FormEditingHook.IndexOfDesignerBaseClass(TComponentClass(aCompClass.ClassType));
|
||||||
|
if i<0 then exit;
|
||||||
|
Result:=FormEditingHook.DesignerBaseClasses[i].ClassName;
|
||||||
|
end;
|
||||||
|
|
||||||
function ReplaceUnitUse(OldFilename, OldUnitName, NewFilename, NewUnitName: string;
|
function ReplaceUnitUse(OldFilename, OldUnitName, NewFilename, NewUnitName: string;
|
||||||
IgnoreErrors, Quiet, Confirm: boolean): TModalResult;
|
IgnoreErrors, Quiet, Confirm: boolean): TModalResult;
|
||||||
// Replaces all references to a unit
|
// Replaces all references to a unit
|
||||||
|
@ -113,7 +113,8 @@ type
|
|||||||
pfcbcForm, // is TForm
|
pfcbcForm, // is TForm
|
||||||
pfcbcFrame, // is TFrame
|
pfcbcFrame, // is TFrame
|
||||||
pfcbcDataModule,// is TDataModule
|
pfcbcDataModule,// is TDataModule
|
||||||
pfcbcCustomForm // is TCustomForm (not TForm)
|
pfcbcCustomForm,// is TCustomForm (not TForm)
|
||||||
|
pfcbcOther // is a designer base class, see ResourceBaseClassname
|
||||||
);
|
);
|
||||||
|
|
||||||
const
|
const
|
||||||
@ -122,7 +123,16 @@ const
|
|||||||
'Form',
|
'Form',
|
||||||
'Frame',
|
'Frame',
|
||||||
'DataModule',
|
'DataModule',
|
||||||
'CustomForm'
|
'CustomForm',
|
||||||
|
''
|
||||||
|
);
|
||||||
|
DefaultResourceBaseClassnames: array[TPFComponentBaseClass] of string = (
|
||||||
|
'',
|
||||||
|
'TForm',
|
||||||
|
'TFrame',
|
||||||
|
'TDataModule',
|
||||||
|
'TCustomForm',
|
||||||
|
''
|
||||||
);
|
);
|
||||||
|
|
||||||
function StrToComponentBaseClass(const s: string): TPFComponentBaseClass;
|
function StrToComponentBaseClass(const s: string): TPFComponentBaseClass;
|
||||||
@ -150,6 +160,7 @@ type
|
|||||||
fFullFilenameStamp: integer;
|
fFullFilenameStamp: integer;
|
||||||
FPackage: TLazPackage;
|
FPackage: TLazPackage;
|
||||||
FResourceBaseClass: TPFComponentBaseClass;
|
FResourceBaseClass: TPFComponentBaseClass;
|
||||||
|
FResourceBaseClassname: string;
|
||||||
FSourceDirectoryReferenced: boolean;
|
FSourceDirectoryReferenced: boolean;
|
||||||
FSourceDirNeedReference: boolean;
|
FSourceDirNeedReference: boolean;
|
||||||
function GetAddToUsesPkgSection: boolean;
|
function GetAddToUsesPkgSection: boolean;
|
||||||
@ -196,8 +207,8 @@ type
|
|||||||
read GetAddToUsesPkgSection write SetAddToUsesPkgSection;
|
read GetAddToUsesPkgSection write SetAddToUsesPkgSection;
|
||||||
property AutoReferenceSourceDir: boolean read FAutoReferenceSourceDir
|
property AutoReferenceSourceDir: boolean read FAutoReferenceSourceDir
|
||||||
write SetAutoReferenceSourceDir;
|
write SetAutoReferenceSourceDir;
|
||||||
property ResourceBaseClass: TPFComponentBaseClass read FResourceBaseClass
|
property ResourceBaseClass: TPFComponentBaseClass read FResourceBaseClass write FResourceBaseClass;
|
||||||
write FResourceBaseClass;
|
property ResourceBaseClassname: string read FResourceBaseClassname write FResourceBaseClassname;
|
||||||
property ComponentPriority: TComponentPriority read FComponentPriority
|
property ComponentPriority: TComponentPriority read FComponentPriority
|
||||||
write FComponentPriority;
|
write FComponentPriority;
|
||||||
property Components[Index: integer]: TPkgComponent read GetComponents;// registered components
|
property Components[Index: integer]: TPkgComponent read GetComponents;// registered components
|
||||||
@ -1113,7 +1124,9 @@ begin
|
|||||||
else if aClass.InheritsFrom(TDataModule) then
|
else if aClass.InheritsFrom(TDataModule) then
|
||||||
Result:=pfcbcDataModule
|
Result:=pfcbcDataModule
|
||||||
else if aClass.InheritsFrom(TCustomForm) then
|
else if aClass.InheritsFrom(TCustomForm) then
|
||||||
Result:=pfcbcCustomForm;
|
Result:=pfcbcCustomForm
|
||||||
|
else
|
||||||
|
Result:=pfcbcOther;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CompareLazPackageID(Data1, Data2: Pointer): integer;
|
function CompareLazPackageID(Data1, Data2: Pointer): integer;
|
||||||
@ -1677,6 +1690,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
FResourceBaseClass:=StrToComponentBaseClass(
|
FResourceBaseClass:=StrToComponentBaseClass(
|
||||||
XMLConfig.GetValue(Path+'ResourceBaseClass/Value',''));
|
XMLConfig.GetValue(Path+'ResourceBaseClass/Value',''));
|
||||||
|
FResourceBaseClassname:=XMLConfig.GetValue(Path+'ResourceBaseClassname/Value',
|
||||||
|
DefaultResourceBaseClassnames[FResourceBaseClass]);
|
||||||
|
|
||||||
Config:=TXMLOptionsStorage.Create(XMLConfig);
|
Config:=TXMLOptionsStorage.Create(XMLConfig);
|
||||||
try
|
try
|
||||||
@ -1707,6 +1722,9 @@ begin
|
|||||||
XMLConfig.SetDeleteValue(Path+'ResourceBaseClass/Value',
|
XMLConfig.SetDeleteValue(Path+'ResourceBaseClass/Value',
|
||||||
PFComponentBaseClassNames[FResourceBaseClass],
|
PFComponentBaseClassNames[FResourceBaseClass],
|
||||||
PFComponentBaseClassNames[pfcbcNone]);
|
PFComponentBaseClassNames[pfcbcNone]);
|
||||||
|
XMLConfig.SetDeleteValue(Path+'ResourceBaseClassname/Value',
|
||||||
|
FResourceBaseClassname,
|
||||||
|
DefaultResourceBaseClassnames[FResourceBaseClass]);
|
||||||
|
|
||||||
Config:=TXMLOptionsStorage.Create(XMLConfig);
|
Config:=TXMLOptionsStorage.Create(XMLConfig);
|
||||||
try
|
try
|
||||||
|
Loading…
Reference in New Issue
Block a user