mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-14 21:40:20 +02:00
changed projects forms into components
git-svn-id: trunk@3061 -
This commit is contained in:
parent
b34a1f9d88
commit
af2a2823fb
175
ide/main.pp
175
ide/main.pp
@ -407,7 +407,8 @@ type
|
|||||||
function CreateNewCodeBuffer(NewUnitType:TNewUnitType;
|
function CreateNewCodeBuffer(NewUnitType:TNewUnitType;
|
||||||
NewFilename: string; var NewCodeBuffer: TCodeBuffer;
|
NewFilename: string; var NewCodeBuffer: TCodeBuffer;
|
||||||
var NewUnitName: string): TModalResult;
|
var NewUnitName: string): TModalResult;
|
||||||
function CreateNewForm(NewUnitInfo: TUnitInfo): TModalResult;
|
function CreateNewForm(NewUnitInfo: TUnitInfo; AncestorType: TComponentClass;
|
||||||
|
ResourceCode: TCodeBuffer): TModalResult;
|
||||||
|
|
||||||
// methods for 'save unit'
|
// methods for 'save unit'
|
||||||
function DoLoadResourceFile(AnUnitInfo: TUnitInfo;
|
function DoLoadResourceFile(AnUnitInfo: TUnitInfo;
|
||||||
@ -978,7 +979,7 @@ begin
|
|||||||
writeln('[TMainIDE.OnPropHookGetMethods] ************');
|
writeln('[TMainIDE.OnPropHookGetMethods] ************');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
if not CodeToolBoss.GetCompatiblePublishedMethods(ActiveUnitInfo.Source,
|
if not CodeToolBoss.GetCompatiblePublishedMethods(ActiveUnitInfo.Source,
|
||||||
ActiveUnitInfo.Form.ClassName,TypeData,Proc) then
|
ActiveUnitInfo.Component.ClassName,TypeData,Proc) then
|
||||||
begin
|
begin
|
||||||
DoJumpToCodeToolBossError;
|
DoJumpToCodeToolBossError;
|
||||||
end;
|
end;
|
||||||
@ -2165,11 +2166,11 @@ var
|
|||||||
begin
|
begin
|
||||||
AnUnitInfo:=Project1.FirstUnitWithForm;
|
AnUnitInfo:=Project1.FirstUnitWithForm;
|
||||||
while AnUnitInfo<>nil do begin
|
while AnUnitInfo<>nil do begin
|
||||||
if AnUnitInfo.Form<>nil then begin
|
if AnUnitInfo.Component<>nil then begin
|
||||||
if AnUnitInfo.Form is TControl then
|
if AnUnitInfo.Component is TControl then
|
||||||
TControl(AnUnitInfo.Form).Invalidate;
|
TControl(AnUnitInfo.Component).Invalidate;
|
||||||
end;
|
end;
|
||||||
AnUnitInfo:=AnUnitInfo.NextUnitWithForm;
|
AnUnitInfo:=AnUnitInfo.NextUnitWithComponent;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2691,8 +2692,9 @@ var EnvironmentOptionsDialog: TEnvironmentOptionsDialog;
|
|||||||
begin
|
begin
|
||||||
AnUnitInfo:=Project1.FirstUnitWithForm;
|
AnUnitInfo:=Project1.FirstUnitWithForm;
|
||||||
while AnUnitInfo<>nil do begin
|
while AnUnitInfo<>nil do begin
|
||||||
if (AnUnitInfo.Form<>nil) and (AnUnitInfo.Form is TCustomForm) then begin
|
if (AnUnitInfo.Component<>nil) and (AnUnitInfo.Component is TCustomForm)
|
||||||
AForm:=TCustomForm(AnUnitInfo.Form);
|
then begin
|
||||||
|
AForm:=TCustomForm(AnUnitInfo.Component);
|
||||||
ADesigner:=TDesigner(AForm.Designer);
|
ADesigner:=TDesigner(AForm.Designer);
|
||||||
if ADesigner<>nil then begin
|
if ADesigner<>nil then begin
|
||||||
ADesigner.ShowEditorHints:=EnvironmentOptions.ShowEditorHints;
|
ADesigner.ShowEditorHints:=EnvironmentOptions.ShowEditorHints;
|
||||||
@ -2700,7 +2702,7 @@ var EnvironmentOptionsDialog: TEnvironmentOptionsDialog;
|
|||||||
EnvironmentOptions.ShowComponentCaptions;
|
EnvironmentOptions.ShowComponentCaptions;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
AnUnitInfo:=AnUnitInfo.NextUnitWithForm;
|
AnUnitInfo:=AnUnitInfo.NextUnitWithComponent;
|
||||||
end;
|
end;
|
||||||
InvalidateAllDesignerForms;
|
InvalidateAllDesignerForms;
|
||||||
end;
|
end;
|
||||||
@ -2830,15 +2832,18 @@ begin
|
|||||||
Result:=mrCancel;
|
Result:=mrCancel;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TMainIDE.CreateNewForm(NewUnitInfo: TUnitInfo): TModalResult;
|
function TMainIDE.CreateNewForm(NewUnitInfo: TUnitInfo;
|
||||||
|
AncestorType: TComponentClass; ResourceCode: TCodeBuffer): TModalResult;
|
||||||
var
|
var
|
||||||
NewForm: TCustomForm;
|
NewForm: TCustomForm;
|
||||||
ResourceCode: TCodeBuffer;
|
|
||||||
CInterface : TComponentInterface;
|
CInterface : TComponentInterface;
|
||||||
begin
|
begin
|
||||||
// create a buffer for the new resource file and for the LFM file
|
// create a buffer for the new resource file and for the LFM file
|
||||||
ResourceCode:=
|
if ResourceCode=nil then begin
|
||||||
CodeToolBoss.CreateFile(ChangeFileExt(NewUnitInfo.Filename,ResourceFileExt));
|
ResourceCode:=
|
||||||
|
CodeToolBoss.CreateFile(ChangeFileExt(NewUnitInfo.Filename,
|
||||||
|
ResourceFileExt));
|
||||||
|
end;
|
||||||
ResourceCode.Source:='{ '+lisResourceFileComment+' }';
|
ResourceCode.Source:='{ '+lisResourceFileComment+' }';
|
||||||
CodeToolBoss.CreateFile(ChangeFileExt(NewUnitInfo.Filename,'.lfm'));
|
CodeToolBoss.CreateFile(ChangeFileExt(NewUnitInfo.Filename,'.lfm'));
|
||||||
|
|
||||||
@ -2849,16 +2854,16 @@ begin
|
|||||||
|
|
||||||
// create jitform
|
// create jitform
|
||||||
CInterface := TComponentInterface(
|
CInterface := TComponentInterface(
|
||||||
FormEditor1.CreateComponent(nil,TForm,
|
FormEditor1.CreateComponent(nil,AncestorType,
|
||||||
ObjectInspector1.Left+ObjectInspector1.Width+60,Top+Height+80,400,300));
|
ObjectInspector1.Left+ObjectInspector1.Width+60,Top+Height+80,400,300));
|
||||||
FormEditor1.SetFormNameAndClass(CInterface,
|
FormEditor1.SetComponentNameAndClass(CInterface,
|
||||||
NewUnitInfo.FormName,'T'+NewUnitInfo.FormName);
|
NewUnitInfo.ComponentName,'T'+NewUnitInfo.ComponentName);
|
||||||
NewForm:=TForm(CInterface.Component);
|
NewForm:=TForm(CInterface.Component);
|
||||||
NewUnitInfo.Form:=NewForm;
|
NewUnitInfo.Component:=NewForm;
|
||||||
SetDefaultsForForm(NewForm);
|
SetDefaultsForForm(NewForm);
|
||||||
|
|
||||||
NewUnitInfo.FormName:=NewForm.Name;
|
NewUnitInfo.ComponentName:=NewForm.Name;
|
||||||
NewUnitInfo.FormResourceName:=NewUnitInfo.FormName;
|
NewUnitInfo.ComponentResourceName:=NewUnitInfo.ComponentName;
|
||||||
if NewUnitInfo.IsPartOfProject and Project1.AutoCreateForms then
|
if NewUnitInfo.IsPartOfProject and Project1.AutoCreateForms then
|
||||||
Project1.AddCreateFormToProjectFile(NewForm.ClassName,NewForm.Name);
|
Project1.AddCreateFormToProjectFile(NewForm.ClassName,NewForm.Name);
|
||||||
|
|
||||||
@ -2899,7 +2904,7 @@ begin
|
|||||||
if Result=mrAbort then exit;
|
if Result=mrAbort then exit;
|
||||||
end;
|
end;
|
||||||
// load lfm file
|
// load lfm file
|
||||||
if (not AnUnitInfo.IsVirtual) and (AnUnitInfo.Form<>nil) then begin
|
if (not AnUnitInfo.IsVirtual) and (AnUnitInfo.Component<>nil) then begin
|
||||||
LFMFilename:=ChangeFileExt(AnUnitInfo.Filename,'.lfm');
|
LFMFilename:=ChangeFileExt(AnUnitInfo.Filename,'.lfm');
|
||||||
if (FileExists(LFMFilename)) then begin
|
if (FileExists(LFMFilename)) then begin
|
||||||
Result:=DoLoadCodeBuffer(LFMCode,LFMFilename,[lbfCheckIfText]);
|
Result:=DoLoadCodeBuffer(LFMCode,LFMFilename,[lbfCheckIfText]);
|
||||||
@ -3085,7 +3090,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// check new resource file
|
// check new resource file
|
||||||
if AnUnitInfo.FormName='' then begin
|
if AnUnitInfo.ComponentName='' then begin
|
||||||
// unit has no form
|
// unit has no form
|
||||||
// -> remove lfm file, so that it will not be auto loaded on next open
|
// -> remove lfm file, so that it will not be auto loaded on next open
|
||||||
NewLFMFilename:=ChangeFileExt(NewFilename,'.lfm');
|
NewLFMFilename:=ChangeFileExt(NewFilename,'.lfm');
|
||||||
@ -3207,7 +3212,7 @@ begin
|
|||||||
// save lrs - lazarus resource file and lfm - lazarus form text file
|
// save lrs - lazarus resource file and lfm - lazarus form text file
|
||||||
// Note: When there is a bug in the source, no resource code can be found,
|
// Note: When there is a bug in the source, no resource code can be found,
|
||||||
// but the LFM file should always be saved
|
// but the LFM file should always be saved
|
||||||
if (AnUnitInfo.Form<>nil) then begin
|
if (AnUnitInfo.Component<>nil) then begin
|
||||||
// stream component to resource code and to lfm file
|
// stream component to resource code and to lfm file
|
||||||
FormSavingOk:=true;
|
FormSavingOk:=true;
|
||||||
|
|
||||||
@ -3222,7 +3227,7 @@ begin
|
|||||||
try
|
try
|
||||||
Writer:=TWriter.Create(Driver);
|
Writer:=TWriter.Create(Driver);
|
||||||
try
|
try
|
||||||
Writer.WriteDescendent(AnUnitInfo.Form,nil);
|
Writer.WriteDescendent(AnUnitInfo.Component,nil);
|
||||||
finally
|
finally
|
||||||
Writer.Free;
|
Writer.Free;
|
||||||
end;
|
end;
|
||||||
@ -3231,8 +3236,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
except
|
except
|
||||||
ACaption:=lisStreamingError;
|
ACaption:=lisStreamingError;
|
||||||
AText:=Format(lisUnableToStreamT, [AnUnitInfo.FormName,
|
AText:=Format(lisUnableToStreamT, [AnUnitInfo.ComponentName,
|
||||||
AnUnitInfo.FormName]);
|
AnUnitInfo.ComponentName]);
|
||||||
Result:=MessageDlg(ACaption, AText, mtError,
|
Result:=MessageDlg(ACaption, AText, mtError,
|
||||||
[mbAbort, mbRetry, mbIgnore], 0);
|
[mbAbort, mbRetry, mbIgnore], 0);
|
||||||
if Result=mrAbort then exit;
|
if Result=mrAbort then exit;
|
||||||
@ -3260,7 +3265,7 @@ begin
|
|||||||
try
|
try
|
||||||
BinCompStream.Position:=0;
|
BinCompStream.Position:=0;
|
||||||
BinaryToLazarusResourceCode(BinCompStream,MemStream
|
BinaryToLazarusResourceCode(BinCompStream,MemStream
|
||||||
,'T'+AnUnitInfo.FormName,'FORMDATA');
|
,'T'+AnUnitInfo.ComponentName,'FORMDATA');
|
||||||
MemStream.Position:=0;
|
MemStream.Position:=0;
|
||||||
SetLength(CompResourceCode,MemStream.Size);
|
SetLength(CompResourceCode,MemStream.Size);
|
||||||
MemStream.Read(CompResourceCode[1],length(CompResourceCode));
|
MemStream.Read(CompResourceCode[1],length(CompResourceCode));
|
||||||
@ -3274,10 +3279,10 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
// replace lazarus form resource code
|
// replace lazarus form resource code
|
||||||
if not (sfSaveToTestDir in Flags) then begin
|
if not (sfSaveToTestDir in Flags) then begin
|
||||||
if (AnUnitInfo.FormName<>AnUnitInfo.FormResourceName)
|
if (AnUnitInfo.ComponentName<>AnUnitInfo.ComponentResourceName)
|
||||||
and (AnUnitInfo.FormResourceName<>'') then begin
|
and (AnUnitInfo.ComponentResourceName<>'') then begin
|
||||||
CodeToolBoss.RemoveLazarusResource(ResourceCode,
|
CodeToolBoss.RemoveLazarusResource(ResourceCode,
|
||||||
'T'+AnUnitInfo.FormResourceName);
|
'T'+AnUnitInfo.ComponentResourceName);
|
||||||
end;
|
end;
|
||||||
if (not CodeToolBoss.AddLazarusResourceHeaderComment(ResourceCode,
|
if (not CodeToolBoss.AddLazarusResourceHeaderComment(ResourceCode,
|
||||||
lisResourceFileComment)) then
|
lisResourceFileComment)) then
|
||||||
@ -3289,18 +3294,19 @@ begin
|
|||||||
if Result=mrAbort then exit;
|
if Result=mrAbort then exit;
|
||||||
end;
|
end;
|
||||||
if (not CodeToolBoss.AddLazarusResource(ResourceCode,
|
if (not CodeToolBoss.AddLazarusResource(ResourceCode,
|
||||||
'T'+AnUnitInfo.FormName,CompResourceCode)) then
|
'T'+AnUnitInfo.ComponentName,CompResourceCode)) then
|
||||||
begin
|
begin
|
||||||
ACaption:=lisResourceSaveError;
|
ACaption:=lisResourceSaveError;
|
||||||
AText:=Format(
|
AText:=Format(
|
||||||
lisUnableToAddResourceTFORMDATAToResourceFileProbably, [
|
lisUnableToAddResourceTFORMDATAToResourceFileProbably, [
|
||||||
AnUnitInfo.FormName, #13, '"', ResourceCode.FileName, '"', #13]
|
AnUnitInfo.ComponentName,
|
||||||
|
#13, '"', ResourceCode.FileName, '"', #13]
|
||||||
);
|
);
|
||||||
Result:=MessageDlg(ACaption, AText, mtError, [mbIgnore, mbAbort],0);
|
Result:=MessageDlg(ACaption, AText, mtError, [mbIgnore, mbAbort],0);
|
||||||
if Result=mrAbort then exit;
|
if Result=mrAbort then exit;
|
||||||
end else begin
|
end else begin
|
||||||
AnUnitInfo.ResourceFileName:=ResourceCode.Filename;
|
AnUnitInfo.ResourceFileName:=ResourceCode.Filename;
|
||||||
AnUnitInfo.FormResourceName:=AnUnitInfo.FormName;
|
AnUnitInfo.ComponentResourceName:=AnUnitInfo.ComponentName;
|
||||||
end;
|
end;
|
||||||
end else begin
|
end else begin
|
||||||
ResourceCode.Source:=CompResourceCode;
|
ResourceCode.Source:=CompResourceCode;
|
||||||
@ -3342,7 +3348,7 @@ begin
|
|||||||
ACaption:=lisStreamingError;
|
ACaption:=lisStreamingError;
|
||||||
AText:=Format(
|
AText:=Format(
|
||||||
lisUnableToTransformBinaryComponentStreamOfTIntoText, [
|
lisUnableToTransformBinaryComponentStreamOfTIntoText, [
|
||||||
AnUnitInfo.FormName, AnUnitInfo.FormName]);
|
AnUnitInfo.ComponentName, AnUnitInfo.ComponentName]);
|
||||||
Result:=MessageDlg(ACaption, AText, mtError,
|
Result:=MessageDlg(ACaption, AText, mtError,
|
||||||
[mbAbort, mbRetry, mbIgnore], 0);
|
[mbAbort, mbRetry, mbIgnore], 0);
|
||||||
if Result=mrAbort then exit;
|
if Result=mrAbort then exit;
|
||||||
@ -3558,7 +3564,8 @@ begin
|
|||||||
|
|
||||||
// create jitform
|
// create jitform
|
||||||
CInterface := TComponentInterface(
|
CInterface := TComponentInterface(
|
||||||
FormEditor1.CreateFormFromStream(BinLFMStream));
|
FormEditor1.CreateComponentFromStream(BinLFMStream,
|
||||||
|
TForm));
|
||||||
if CInterface=nil then begin
|
if CInterface=nil then begin
|
||||||
ACaption:=lisFormLoadError;
|
ACaption:=lisFormLoadError;
|
||||||
AText:=Format(lisUnableToBuildFormFromFile, [#13, '"',
|
AText:=Format(lisUnableToBuildFormFromFile, [#13, '"',
|
||||||
@ -3567,13 +3574,13 @@ begin
|
|||||||
if Result=mrCancel then Result:=mrAbort;
|
if Result=mrCancel then Result:=mrAbort;
|
||||||
if Result<>mrOk then exit;
|
if Result<>mrOk then exit;
|
||||||
TempForm:=nil;
|
TempForm:=nil;
|
||||||
AnUnitInfo.Form:=TempForm;
|
AnUnitInfo.Component:=TempForm;
|
||||||
end else begin
|
end else begin
|
||||||
TempForm:=TForm(CInterface.Component);
|
TempForm:=TForm(CInterface.Component);
|
||||||
AnUnitInfo.Form:=TempForm;
|
AnUnitInfo.Component:=TempForm;
|
||||||
SetDefaultsForForm(TempForm);
|
SetDefaultsForForm(TempForm);
|
||||||
AnUnitInfo.FormName:=TempForm.Name;
|
AnUnitInfo.ComponentName:=TempForm.Name;
|
||||||
AnUnitInfo.FormResourceName:=AnUnitInfo.FormName;
|
AnUnitInfo.ComponentResourceName:=AnUnitInfo.ComponentName;
|
||||||
// show form
|
// show form
|
||||||
TDesigner(TempForm.Designer).SourceEditor:=
|
TDesigner(TempForm.Designer).SourceEditor:=
|
||||||
SourceNoteBook.GetActiveSE;
|
SourceNoteBook.GetActiveSE;
|
||||||
@ -3614,8 +3621,8 @@ var
|
|||||||
i: integer;
|
i: integer;
|
||||||
OldDesigner: TDesigner;
|
OldDesigner: TDesigner;
|
||||||
begin
|
begin
|
||||||
AForm:=TCustomForm(AnUnitInfo.Form);
|
AForm:=TCustomForm(AnUnitInfo.Component);
|
||||||
if AForm<>nil then begin
|
if (AForm<>nil) and (AForm is TCustomForm) then begin
|
||||||
if FLastFormActivated=AForm then
|
if FLastFormActivated=AForm then
|
||||||
FLastFormActivated:=nil;
|
FLastFormActivated:=nil;
|
||||||
// unselect controls
|
// unselect controls
|
||||||
@ -3626,7 +3633,7 @@ begin
|
|||||||
// free designer and design form
|
// free designer and design form
|
||||||
OldDesigner:=TDesigner(AForm.Designer);
|
OldDesigner:=TDesigner(AForm.Designer);
|
||||||
OldDesigner.DeleteFormAndFree;
|
OldDesigner.DeleteFormAndFree;
|
||||||
AnUnitInfo.Form:=nil;
|
AnUnitInfo.Component:=nil;
|
||||||
end;
|
end;
|
||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
end;
|
end;
|
||||||
@ -4037,9 +4044,9 @@ begin
|
|||||||
|
|
||||||
// create source code
|
// create source code
|
||||||
if nfCreateDefaultSrc in NewFlags then begin
|
if nfCreateDefaultSrc in NewFlags then begin
|
||||||
if NewUnitType in [nuForm] then begin
|
if NewUnitType in [nuForm,nuDataModule] then begin
|
||||||
NewUnitInfo.FormName:=Project1.NewUniqueFormName(NewUnitType);
|
NewUnitInfo.ComponentName:=Project1.NewUniqueComponentName(NewUnitType);
|
||||||
NewUnitInfo.FormResourceName:='';
|
NewUnitInfo.ComponentResourceName:='';
|
||||||
CodeToolBoss.CreateFile(ChangeFileExt(NewFilename,ResourceFileExt));
|
CodeToolBoss.CreateFile(ChangeFileExt(NewFilename,ResourceFileExt));
|
||||||
end;
|
end;
|
||||||
NewUnitInfo.CreateStartCode(NewUnitType,NewUnitName);
|
NewUnitInfo.CreateStartCode(NewUnitType,NewUnitName);
|
||||||
@ -4064,7 +4071,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// syntax highlighter type
|
// syntax highlighter type
|
||||||
if NewUnitType in [nuForm, nuUnit,nuDataModule] then begin
|
if NewUnitType in [nuForm,nuUnit,nuDataModule] then begin
|
||||||
NewUnitInfo.SyntaxHighlighter:=lshFreePascal;
|
NewUnitInfo.SyntaxHighlighter:=lshFreePascal;
|
||||||
end else begin
|
end else begin
|
||||||
NewUnitInfo.SyntaxHighlighter:=
|
NewUnitInfo.SyntaxHighlighter:=
|
||||||
@ -4085,14 +4092,14 @@ begin
|
|||||||
|
|
||||||
// create form
|
// create form
|
||||||
if NewUnitType in [nuForm] then begin
|
if NewUnitType in [nuForm] then begin
|
||||||
Result:=CreateNewForm(NewUnitInfo);
|
Result:=CreateNewForm(NewUnitInfo,TForm,nil);
|
||||||
if Result<>mrOk then exit;
|
if Result<>mrOk then exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// show form and select form
|
// show form and select form
|
||||||
if NewUnitType in [nuForm] then begin
|
if NewUnitType in [nuForm] then begin
|
||||||
// show form
|
// show form
|
||||||
TDesigner(TCustomForm(NewUnitInfo.Form).Designer).SourceEditor :=
|
TDesigner(TCustomForm(NewUnitInfo.Component).Designer).SourceEditor :=
|
||||||
SourceNoteBook.GetActiveSE;
|
SourceNoteBook.GetActiveSE;
|
||||||
DoShowDesignerFormOfCurrentSrc;
|
DoShowDesignerFormOfCurrentSrc;
|
||||||
end else begin
|
end else begin
|
||||||
@ -4256,7 +4263,7 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.DoSaveEditorFile B');{$ENDIF}
|
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.DoSaveEditorFile B');{$ENDIF}
|
||||||
// save resource file and lfm file
|
// save resource file and lfm file
|
||||||
if (ResourceCode<>nil) or (ActiveUnitInfo.Form<>nil) then begin
|
if (ResourceCode<>nil) or (ActiveUnitInfo.Component<>nil) then begin
|
||||||
Result:=DoSaveFileResources(ActiveUnitInfo,ResourceCode,LFMCode,Flags);
|
Result:=DoSaveFileResources(ActiveUnitInfo,ResourceCode,LFMCode,Flags);
|
||||||
if Result in [mrIgnore, mrOk] then
|
if Result in [mrIgnore, mrOk] then
|
||||||
Result:=mrCancel
|
Result:=mrCancel
|
||||||
@ -4288,7 +4295,7 @@ begin
|
|||||||
Result:=mrCancel;
|
Result:=mrCancel;
|
||||||
GetUnitWithPageIndex(PageIndex,ActiveSrcEdit,ActiveUnitInfo);
|
GetUnitWithPageIndex(PageIndex,ActiveSrcEdit,ActiveUnitInfo);
|
||||||
if ActiveUnitInfo=nil then exit;
|
if ActiveUnitInfo=nil then exit;
|
||||||
if ActiveUnitInfo.Form=FLastFormActivated then
|
if ActiveUnitInfo.Component=FLastFormActivated then
|
||||||
FLastFormActivated:=nil;
|
FLastFormActivated:=nil;
|
||||||
|
|
||||||
// save some meta data of the source
|
// save some meta data of the source
|
||||||
@ -4508,12 +4515,12 @@ begin
|
|||||||
if FilenameIsPascalUnit(AFilename) then begin
|
if FilenameIsPascalUnit(AFilename) then begin
|
||||||
// this could be a unit with a form
|
// this could be a unit with a form
|
||||||
if EnvironmentOptions.AutoCreateFormsOnOpen
|
if EnvironmentOptions.AutoCreateFormsOnOpen
|
||||||
or (NewUnitInfo.Form<>nil) then begin
|
or (NewUnitInfo.Component<>nil) then begin
|
||||||
// -> try to (re)load the lfm file
|
// -> try to (re)load the lfm file
|
||||||
Result:=DoLoadLFM(NewUnitInfo,Flags);
|
Result:=DoLoadLFM(NewUnitInfo,Flags);
|
||||||
if Result<>mrOk then exit;
|
if Result<>mrOk then exit;
|
||||||
end;
|
end;
|
||||||
end else if NewUnitInfo.Form<>nil then begin
|
end else if NewUnitInfo.Component<>nil then begin
|
||||||
// this is no pascal source and there is a designer form
|
// this is no pascal source and there is a designer form
|
||||||
// This can be the case, when the file is renamed and reverted
|
// This can be the case, when the file is renamed and reverted
|
||||||
// -> close form
|
// -> close form
|
||||||
@ -4585,9 +4592,9 @@ Begin
|
|||||||
if not Project1.Units[i].IsPartOfProject then continue;
|
if not Project1.Units[i].IsPartOfProject then continue;
|
||||||
if OnlyForms then begin
|
if OnlyForms then begin
|
||||||
// add all form names of project
|
// add all form names of project
|
||||||
if Project1.Units[i].FormName<>'' then begin
|
if Project1.Units[i].ComponentName<>'' then begin
|
||||||
UnitList.Add(TViewUnitsEntry.Create(
|
UnitList.Add(TViewUnitsEntry.Create(
|
||||||
Project1.Units[i].FormName,i,Project1.Units[i]=ActiveUnitInfo));
|
Project1.Units[i].ComponentName,i,Project1.Units[i]=ActiveUnitInfo));
|
||||||
end;
|
end;
|
||||||
end else begin
|
end else begin
|
||||||
// add all unit names of project
|
// add all unit names of project
|
||||||
@ -4630,8 +4637,9 @@ Begin
|
|||||||
end;
|
end;
|
||||||
if (AnUnitInfo<>nil) then begin
|
if (AnUnitInfo<>nil) then begin
|
||||||
AForm:=SourceNotebook;
|
AForm:=SourceNotebook;
|
||||||
if OnlyForms and (AnUnitInfo.Form<>nil) then begin
|
if OnlyForms and (AnUnitInfo.Component<>nil)
|
||||||
AForm:=TForm(AnUnitInfo.Form);
|
and (AForm is TCustomForm) then begin
|
||||||
|
AForm:=TForm(AnUnitInfo.Component);
|
||||||
end;
|
end;
|
||||||
AForm.ShowOnTop;
|
AForm.ShowOnTop;
|
||||||
end;
|
end;
|
||||||
@ -5413,9 +5421,9 @@ Begin
|
|||||||
then
|
then
|
||||||
Project1.MainUnitInfo.Modified:=true;
|
Project1.MainUnitInfo.Modified:=true;
|
||||||
end;
|
end;
|
||||||
if (AnUnitInfo.FormName<>'') then begin
|
if (AnUnitInfo.ComponentName<>'') then begin
|
||||||
Project1.RemoveCreateFormFromProjectFile(
|
Project1.RemoveCreateFormFromProjectFile(
|
||||||
'T'+AnUnitInfo.FormName,AnUnitInfo.FormName);
|
'T'+AnUnitInfo.ComponentName,AnUnitInfo.ComponentName);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -5965,7 +5973,7 @@ var
|
|||||||
i: integer;
|
i: integer;
|
||||||
begin
|
begin
|
||||||
if AForm<>nil then begin
|
if AForm<>nil then begin
|
||||||
i:=Project1.IndexOfUnitWithForm(AForm,false,nil);
|
i:=Project1.IndexOfUnitWithComponent(AForm,false,nil);
|
||||||
if i>=0 then begin
|
if i>=0 then begin
|
||||||
ActiveUnitInfo:=Project1.Units[i];
|
ActiveUnitInfo:=Project1.Units[i];
|
||||||
ActiveSourceEditor:=SourceNoteBook.FindSourceEditorWithPageIndex(
|
ActiveSourceEditor:=SourceNoteBook.FindSourceEditorWithPageIndex(
|
||||||
@ -6406,7 +6414,7 @@ var
|
|||||||
begin
|
begin
|
||||||
AnUnitInfo:=Project1.FirstUnitWithForm;
|
AnUnitInfo:=Project1.FirstUnitWithForm;
|
||||||
while AnUnitInfo<>nil do begin
|
while AnUnitInfo<>nil do begin
|
||||||
NextUnitInfo:=AnUnitInfo.NextUnitWithForm;
|
NextUnitInfo:=AnUnitInfo.NextUnitWithComponent;
|
||||||
if not AnUnitInfo.NeedsSaveToDisk then
|
if not AnUnitInfo.NeedsSaveToDisk then
|
||||||
CloseDesignerForm(AnUnitInfo);
|
CloseDesignerForm(AnUnitInfo);
|
||||||
AnUnitInfo:=NextUnitInfo;
|
AnUnitInfo:=NextUnitInfo;
|
||||||
@ -6478,7 +6486,7 @@ var
|
|||||||
begin
|
begin
|
||||||
if SourceNoteBook.NoteBook = nil then exit;
|
if SourceNoteBook.NoteBook = nil then exit;
|
||||||
if FLastFormActivated <> nil then begin
|
if FLastFormActivated <> nil then begin
|
||||||
ActiveUnitInfo:= Project1.UnitWithForm(FLastFormActivated);
|
ActiveUnitInfo:= Project1.UnitWithComponent(FLastFormActivated);
|
||||||
if (ActiveUnitInfo <> nil) and (ActiveUnitInfo.EditorIndex >= 0) then
|
if (ActiveUnitInfo <> nil) and (ActiveUnitInfo.EditorIndex >= 0) then
|
||||||
begin
|
begin
|
||||||
SourceNotebook.Notebook.PageIndex:= ActiveUnitInfo.EditorIndex;
|
SourceNotebook.Notebook.PageIndex:= ActiveUnitInfo.EditorIndex;
|
||||||
@ -7230,7 +7238,7 @@ begin
|
|||||||
RaiseException('[TMainIDE.OnDesignerAddComponent] Error: TDesigner without a form');
|
RaiseException('[TMainIDE.OnDesignerAddComponent] Error: TDesigner without a form');
|
||||||
end;
|
end;
|
||||||
// find source for form
|
// find source for form
|
||||||
i:=Project1.IndexOfUnitWithForm(ActiveForm,false,nil);
|
i:=Project1.IndexOfUnitWithComponent(ActiveForm,false,nil);
|
||||||
if i<0 then begin
|
if i<0 then begin
|
||||||
RaiseException('[TMainIDE.OnDesignerAddComponent] Error: form without source');
|
RaiseException('[TMainIDE.OnDesignerAddComponent] Error: form without source');
|
||||||
end;
|
end;
|
||||||
@ -7245,7 +7253,7 @@ procedure TMainIDE.OnDesignerModified(Sender: TObject);
|
|||||||
var i: integer;
|
var i: integer;
|
||||||
SrcEdit: TSourceEditor;
|
SrcEdit: TSourceEditor;
|
||||||
begin
|
begin
|
||||||
i:=Project1.IndexOfUnitWithForm(TDesigner(Sender).Form,false,nil);
|
i:=Project1.IndexOfUnitWithComponent(TDesigner(Sender).Form,false,nil);
|
||||||
if i>=0 then begin
|
if i>=0 then begin
|
||||||
Project1.Units[i].Modified:=true;
|
Project1.Units[i].Modified:=true;
|
||||||
if Project1.Units[i].Loaded then
|
if Project1.Units[i].Loaded then
|
||||||
@ -8161,8 +8169,8 @@ begin
|
|||||||
if ActiveUnitInfo = nil then Exit;
|
if ActiveUnitInfo = nil then Exit;
|
||||||
|
|
||||||
SaveSpeedBtn.Enabled := SourceNotebook.GetActiveSe.Modified;
|
SaveSpeedBtn.Enabled := SourceNotebook.GetActiveSe.Modified;
|
||||||
ToggleFormSpeedBtn.Enabled := Assigned(ActiveUnitInfo.Form)
|
ToggleFormSpeedBtn.Enabled := Assigned(ActiveUnitInfo.Component)
|
||||||
or (ActiveUnitInfo.FormName<>'');
|
or (ActiveUnitInfo.ComponentName<>'');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//this is fired when the editor is focused, changed, ?. Anything that causes the status change
|
//this is fired when the editor is focused, changed, ?. Anything that causes the status change
|
||||||
@ -8266,7 +8274,7 @@ begin
|
|||||||
raise Exception.Create(Format(lisComponentNameIsNotAValidIdentifier, ['"',
|
raise Exception.Create(Format(lisComponentNameIsNotAValidIdentifier, ['"',
|
||||||
Newname, '"']));
|
Newname, '"']));
|
||||||
BeginCodeTool(ADesigner,ActiveSrcEdit,ActiveUnitInfo,[ctfSwitchToFormSource]);
|
BeginCodeTool(ADesigner,ActiveSrcEdit,ActiveUnitInfo,[ctfSwitchToFormSource]);
|
||||||
ActiveUnitInfo:=Project1.UnitWithForm(ADesigner.Form);
|
ActiveUnitInfo:=Project1.UnitWithComponent(ADesigner.Form);
|
||||||
if CodeToolBoss.IsKeyWord(ActiveUnitInfo.Source,NewName) then
|
if CodeToolBoss.IsKeyWord(ActiveUnitInfo.Source,NewName) then
|
||||||
raise Exception.Create(Format(lisComponentNameIsKeyword, ['"', Newname, '"']
|
raise Exception.Create(Format(lisComponentNameIsKeyword, ['"', Newname, '"']
|
||||||
));
|
));
|
||||||
@ -8285,7 +8293,7 @@ begin
|
|||||||
// replace createform statement
|
// replace createform statement
|
||||||
|
|
||||||
// check if formname already exists
|
// check if formname already exists
|
||||||
i:=Project1.IndexOfUnitWithFormName(NewName,true,ActiveUnitInfo);
|
i:=Project1.IndexOfUnitWithComponentName(NewName,true,ActiveUnitInfo);
|
||||||
if i>=0 then
|
if i>=0 then
|
||||||
raise Exception.Create(
|
raise Exception.Create(
|
||||||
Format(lisThereIsAlreadyAFormWithTheName, ['"',
|
Format(lisThereIsAlreadyAFormWithTheName, ['"',
|
||||||
@ -8297,10 +8305,10 @@ begin
|
|||||||
AComponent.Name,AComponent.ClassName,
|
AComponent.Name,AComponent.ClassName,
|
||||||
NewName,NewClassName);
|
NewName,NewClassName);
|
||||||
ApplyBossResult(Format(lisUnableToRenameFormInSourceSeeMessages, [#13]));
|
ApplyBossResult(Format(lisUnableToRenameFormInSourceSeeMessages, [#13]));
|
||||||
ActiveUnitInfo.FormName:=NewName;
|
ActiveUnitInfo.ComponentName:=NewName;
|
||||||
|
|
||||||
// rename form class
|
// rename form class
|
||||||
FormEditor1.JITFormList.RenameFormClass(TForm(AComponent),NewClassName);
|
FormEditor1.JITFormList.RenameComponentClass(AComponent,NewClassName);
|
||||||
|
|
||||||
// change createform statement
|
// change createform statement
|
||||||
if ActiveUnitInfo.IsPartOfProject and (Project1.MainUnitID>=0)
|
if ActiveUnitInfo.IsPartOfProject and (Project1.MainUnitID>=0)
|
||||||
@ -8568,9 +8576,9 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if (AnUnitInfo.FormName<>'') then begin
|
if (AnUnitInfo.ComponentName<>'') then begin
|
||||||
Dummy:=Project1.RemoveCreateFormFromProjectFile(
|
Dummy:=Project1.RemoveCreateFormFromProjectFile(
|
||||||
'T'+AnUnitInfo.FormName,AnUnitInfo.FormName);
|
'T'+AnUnitInfo.ComponentName,AnUnitInfo.ComponentName);
|
||||||
if not Dummy then begin
|
if not Dummy then begin
|
||||||
ApplyCodeToolChanges;
|
ApplyCodeToolChanges;
|
||||||
DoJumpToCodeToolBossError;
|
DoJumpToCodeToolBossError;
|
||||||
@ -8634,9 +8642,9 @@ procedure TMainIDE.DoSwitchToFormSrc(ADesigner: TDesigner;
|
|||||||
var i: integer;
|
var i: integer;
|
||||||
begin
|
begin
|
||||||
if (ADesigner<>nil) then
|
if (ADesigner<>nil) then
|
||||||
i:=Project1.IndexOfUnitWithForm(ADesigner.Form,false,nil)
|
i:=Project1.IndexOfUnitWithComponent(ADesigner.Form,false,nil)
|
||||||
else if GlobalDesignHook.LookupRoot<>nil then
|
else if GlobalDesignHook.LookupRoot<>nil then
|
||||||
i:=Project1.IndexOfUnitWithForm(GlobalDesignHook.LookupRoot,false,nil)
|
i:=Project1.IndexOfUnitWithComponent(GlobalDesignHook.LookupRoot,false,nil)
|
||||||
else
|
else
|
||||||
i:=-1;
|
i:=-1;
|
||||||
if (i>=0) then begin
|
if (i>=0) then begin
|
||||||
@ -8654,11 +8662,11 @@ end;
|
|||||||
function TMainIDE.GetFormOfSource(AnUnitInfo: TUnitInfo; LoadForm: boolean
|
function TMainIDE.GetFormOfSource(AnUnitInfo: TUnitInfo; LoadForm: boolean
|
||||||
): TCustomForm;
|
): TCustomForm;
|
||||||
begin
|
begin
|
||||||
Result:=TCustomForm(AnUnitInfo.Form);
|
Result:=TCustomForm(AnUnitInfo.Component);
|
||||||
if (Result=nil) and LoadForm and (not AnUnitInfo.IsVirtual)
|
if (Result=nil) and LoadForm and (not AnUnitInfo.IsVirtual)
|
||||||
and FilenameIsPascalSource(AnUnitInfo.Filename) then begin
|
and FilenameIsPascalSource(AnUnitInfo.Filename) then begin
|
||||||
DoLoadLFM(AnUnitInfo,[]);
|
DoLoadLFM(AnUnitInfo,[]);
|
||||||
Result:=TCustomForm(AnUnitInfo.Form);
|
Result:=TCustomForm(AnUnitInfo.Component);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -8675,8 +8683,8 @@ begin
|
|||||||
writeln('[TMainIDE.OnPropHookMethodExists] ************ ',AMethodName);
|
writeln('[TMainIDE.OnPropHookMethodExists] ************ ',AMethodName);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Result:=CodeToolBoss.PublishedMethodExists(ActiveUnitInfo.Source,
|
Result:=CodeToolBoss.PublishedMethodExists(ActiveUnitInfo.Source,
|
||||||
ActiveUnitInfo.Form.ClassName,AMethodName,TypeData,
|
ActiveUnitInfo.Component.ClassName,AMethodName,TypeData,
|
||||||
MethodIsCompatible,MethodIsPublished,IdentIsMethod);
|
MethodIsCompatible,MethodIsPublished,IdentIsMethod);
|
||||||
if CodeToolBoss.ErrorMessage<>'' then begin
|
if CodeToolBoss.ErrorMessage<>'' then begin
|
||||||
DoJumpToCodeToolBossError;
|
DoJumpToCodeToolBossError;
|
||||||
raise Exception.Create(lisUnableToFindMethodPlzFixTheErrorShownInTheMessage
|
raise Exception.Create(lisUnableToFindMethodPlzFixTheErrorShownInTheMessage
|
||||||
@ -8702,15 +8710,15 @@ begin
|
|||||||
try
|
try
|
||||||
// create published method
|
// create published method
|
||||||
r:=CodeToolBoss.CreatePublishedMethod(ActiveUnitInfo.Source,
|
r:=CodeToolBoss.CreatePublishedMethod(ActiveUnitInfo.Source,
|
||||||
ActiveUnitInfo.Form.ClassName,AMethodName,ATypeInfo);
|
ActiveUnitInfo.Component.ClassName,AMethodName,ATypeInfo);
|
||||||
{$IFDEF IDE_DEBUG}
|
{$IFDEF IDE_DEBUG}
|
||||||
writeln('');
|
writeln('');
|
||||||
writeln('[TMainIDE.OnPropHookCreateMethod] ************2 ',r,' ',AMethodName);
|
writeln('[TMainIDE.OnPropHookCreateMethod] ************2 ',r,' ',AMethodName);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
ApplyCodeToolChanges;
|
ApplyCodeToolChanges;
|
||||||
if r then begin
|
if r then begin
|
||||||
Result:=FormEditor1.JITFormList.CreateNewMethod(TForm(ActiveUnitInfo.Form)
|
Result:=FormEditor1.JITFormList.CreateNewMethod(
|
||||||
,AMethodName);
|
TForm(ActiveUnitInfo.Component),AMethodName);
|
||||||
end else begin
|
end else begin
|
||||||
DoJumpToCodeToolBossError;
|
DoJumpToCodeToolBossError;
|
||||||
raise Exception.Create(lisUnableToCreateNewMethodPlzFixTheErrorShownIn);
|
raise Exception.Create(lisUnableToCreateNewMethodPlzFixTheErrorShownIn);
|
||||||
@ -8734,7 +8742,7 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
if CodeToolBoss.JumpToPublishedMethodBody(ActiveUnitInfo.Source,
|
if CodeToolBoss.JumpToPublishedMethodBody(ActiveUnitInfo.Source,
|
||||||
ActiveUnitInfo.Form.ClassName,AMethodName,
|
ActiveUnitInfo.Component.ClassName,AMethodName,
|
||||||
NewSource,NewX,NewY,NewTopLine) then
|
NewSource,NewX,NewY,NewTopLine) then
|
||||||
begin
|
begin
|
||||||
DoJumpToCodePos(ActiveSrcEdit, ActiveUnitInfo,
|
DoJumpToCodePos(ActiveSrcEdit, ActiveUnitInfo,
|
||||||
@ -8761,14 +8769,14 @@ begin
|
|||||||
try
|
try
|
||||||
// create published method
|
// create published method
|
||||||
r:=CodeToolBoss.RenamePublishedMethod(ActiveUnitInfo.Source,
|
r:=CodeToolBoss.RenamePublishedMethod(ActiveUnitInfo.Source,
|
||||||
ActiveUnitInfo.Form.ClassName,CurName,NewName);
|
ActiveUnitInfo.Component.ClassName,CurName,NewName);
|
||||||
{$IFDEF IDE_DEBUG}
|
{$IFDEF IDE_DEBUG}
|
||||||
writeln('');
|
writeln('');
|
||||||
writeln('[TMainIDE.OnPropHookRenameMethod] ************2 ',r);
|
writeln('[TMainIDE.OnPropHookRenameMethod] ************2 ',r);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
ApplyCodeToolChanges;
|
ApplyCodeToolChanges;
|
||||||
if r then begin
|
if r then begin
|
||||||
FormEditor1.JITFormList.RenameMethod(TForm(ActiveUnitInfo.Form),
|
FormEditor1.JITFormList.RenameMethod(TForm(ActiveUnitInfo.Component),
|
||||||
CurName,NewName);
|
CurName,NewName);
|
||||||
end else begin
|
end else begin
|
||||||
DoJumpToCodeToolBossError;
|
DoJumpToCodeToolBossError;
|
||||||
@ -9098,6 +9106,9 @@ end.
|
|||||||
|
|
||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.590 2003/05/31 10:07:33 mattias
|
||||||
|
changed projects forms into components
|
||||||
|
|
||||||
Revision 1.589 2003/05/30 16:25:47 mattias
|
Revision 1.589 2003/05/30 16:25:47 mattias
|
||||||
started datamodule
|
started datamodule
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user