IDEIntf: added TLazProject.Resources

git-svn-id: trunk@32596 -
This commit is contained in:
mattias 2011-10-01 19:49:29 +00:00
parent f5d82af704
commit 38c75a8c1f
11 changed files with 44 additions and 34 deletions

View File

@ -1286,7 +1286,7 @@ begin
if AnUnitInfo.IsPartOfProject then if AnUnitInfo.IsPartOfProject then
begin begin
// use project resource type // use project resource type
Result := Project1.Resources.ResourceType; Result := Project1.ProjResources.ResourceType;
end end
else else
Result := rtLRS; Result := rtLRS;
@ -1357,7 +1357,7 @@ var
Code: TCodeBuffer; Code: TCodeBuffer;
begin begin
// update project resource // update project resource
Project1.Resources.Regenerate(Project1.MainFileName, False, True, TestDir); Project1.ProjResources.Regenerate(Project1.MainFileName, False, True, TestDir);
AnUnitInfo := Project1.FirstPartOfProject; AnUnitInfo := Project1.FirstPartOfProject;
while AnUnitInfo<>nil do while AnUnitInfo<>nil do
begin begin

View File

@ -217,10 +217,10 @@ begin
begin begin
TitleEdit.Text := Title; TitleEdit.Text := Title;
UseAppBundleCheckBox.Checked := UseAppBundle; UseAppBundleCheckBox.Checked := UseAppBundle;
UseXPManifestCheckBox.Checked := TProjectXPManifest(Resources[TProjectXPManifest]).UseManifest; UseXPManifestCheckBox.Checked := TProjectXPManifest(ProjResources[TProjectXPManifest]).UseManifest;
DpiAwareCheckBox.Checked := TProjectXPManifest(Resources[TProjectXPManifest]).DpiAware; DpiAwareCheckBox.Checked := TProjectXPManifest(ProjResources[TProjectXPManifest]).DpiAware;
DpiAwareCheckBox.Enabled := UseXPManifestCheckBox.Checked; DpiAwareCheckBox.Enabled := UseXPManifestCheckBox.Checked;
AStream := TProjectIcon(Resources[TProjectIcon]).GetStream; AStream := TProjectIcon(ProjResources[TProjectIcon]).GetStream;
try try
SetIconFromStream(AStream); SetIconFromStream(AStream);
finally finally
@ -238,13 +238,13 @@ begin
Title := TitleEdit.Text; Title := TitleEdit.Text;
AStream := GetIconAsStream; AStream := GetIconAsStream;
try try
TProjectIcon(Resources[TProjectIcon]).SetStream(AStream); TProjectIcon(ProjResources[TProjectIcon]).SetStream(AStream);
finally finally
AStream.Free; AStream.Free;
end; end;
UseAppBundle := UseAppBundleCheckBox.Checked; UseAppBundle := UseAppBundleCheckBox.Checked;
TProjectXPManifest(Resources[TProjectXPManifest]).UseManifest := UseXPManifestCheckBox.Checked; TProjectXPManifest(ProjResources[TProjectXPManifest]).UseManifest := UseXPManifestCheckBox.Checked;
TProjectXPManifest(Resources[TProjectXPManifest]).DpiAware := DpiAwareCheckBox.Checked; TProjectXPManifest(ProjResources[TProjectXPManifest]).DpiAware := DpiAwareCheckBox.Checked;
end; end;
end; end;

View File

@ -84,7 +84,7 @@ begin
UseDesignTimePkgsCheckBox.Checked := (pfUseDesignTimePackages in Flags); UseDesignTimePkgsCheckBox.Checked := (pfUseDesignTimePackages in Flags);
AlwaysBuildCheckBox.Checked := (pfAlwaysBuild in Flags); AlwaysBuildCheckBox.Checked := (pfAlwaysBuild in Flags);
LRSInOutputDirCheckBox.Checked := (pfLRSFilesInOutputDirectory in Flags); LRSInOutputDirCheckBox.Checked := (pfLRSFilesInOutputDirectory in Flags);
case Resources.ResourceType of case ProjResources.ResourceType of
rtLRS: UseLRSFilesRadioButton.Checked := True; rtLRS: UseLRSFilesRadioButton.Checked := True;
rtRes: UseFPCResourcesRadioButton.Checked := True; rtRes: UseFPCResourcesRadioButton.Checked := True;
end; end;
@ -127,9 +127,9 @@ begin
SetProjectFlag(pfLRSFilesInOutputDirectory, LRSInOutputDirCheckBox.Checked); SetProjectFlag(pfLRSFilesInOutputDirectory, LRSInOutputDirCheckBox.Checked);
Project.Flags := NewFlags; Project.Flags := NewFlags;
if UseLRSFilesRadioButton.Checked then if UseLRSFilesRadioButton.Checked then
Project.Resources.ResourceType := rtLRS Project.ProjResources.ResourceType := rtLRS
else else
Project.Resources.ResourceType := rtRes; Project.ProjResources.ResourceType := rtRes;
case PathDelimComboBox.ItemIndex of case PathDelimComboBox.ItemIndex of
0: Project.StorePathDelim:=pdsNone; 0: Project.StorePathDelim:=pdsNone;
1: Project.StorePathDelim:=pdsUnix; 1: Project.StorePathDelim:=pdsUnix;

View File

@ -127,7 +127,7 @@ procedure TProjectVersionInfoOptionsFrame.ReadSettings(AOptions: TAbstractIDEOpt
var var
i: integer; i: integer;
begin begin
FVersionInfo := TProjectVersionInfo((AOptions as TProject).Resources[TProjectVersionInfo]); FVersionInfo := TProjectVersionInfo((AOptions as TProject).ProjResources[TProjectVersionInfo]);
UseVersionInfoCheckBox.Checked := FVersionInfo.UseVersionInfo; UseVersionInfoCheckBox.Checked := FVersionInfo.UseVersionInfo;
MajorVersionSpinEdit.Value := FVersionInfo.MajorVersionNr; MajorVersionSpinEdit.Value := FVersionInfo.MajorVersionNr;
@ -164,7 +164,7 @@ var
i: integer; i: integer;
t: TProjectVersionStringTable; t: TProjectVersionStringTable;
begin begin
VersionInfo := TProjectVersionInfo((AOptions as TProject).Resources[TProjectVersionInfo]); VersionInfo := TProjectVersionInfo((AOptions as TProject).ProjResources[TProjectVersionInfo]);
VersionInfo.UseVersionInfo := UseVersionInfoCheckBox.Checked; VersionInfo.UseVersionInfo := UseVersionInfoCheckBox.Checked;
VersionInfo.AutoIncrementBuild := AutomaticallyIncreaseBuildCheckBox.Checked; VersionInfo.AutoIncrementBuild := AutomaticallyIncreaseBuildCheckBox.Checked;
VersionInfo.MajorVersionNr := MajorVersionSpinEdit.Value; VersionInfo.MajorVersionNr := MajorVersionSpinEdit.Value;

View File

@ -5105,10 +5105,10 @@ begin
SetAutoCreateForms; SetAutoCreateForms;
// extend include path // extend include path
AProject.AutoAddOutputDirToIncPath; AProject.AutoAddOutputDirToIncPath;
if AProject.Resources.Modified and (AProject.MainUnitID >= 0) then if AProject.ProjResources.Modified and (AProject.MainUnitID >= 0) then
begin begin
if not AProject.Resources.Regenerate(AProject.MainFilename, True, False, '') then if not AProject.ProjResources.Regenerate(AProject.MainFilename, True, False, '') then
MessageDlg(AProject.Resources.Messages.Text, mtWarning, [mbOk], 0); MessageDlg(AProject.ProjResources.Messages.Text, mtWarning, [mbOk], 0);
end; end;
UpdateCaption; UpdateCaption;
AProject.DefineTemplates.AllChanged; AProject.DefineTemplates.AllChanged;
@ -8272,7 +8272,7 @@ begin
begin begin
GetMainUnit(MainUnitInfo, MainUnitSrcEdit, true); GetMainUnit(MainUnitInfo, MainUnitSrcEdit, true);
if not Project1.Resources.RenameDirectives(MainUnitInfo.Filename,NewProgramFilename) if not Project1.ProjResources.RenameDirectives(MainUnitInfo.Filename,NewProgramFilename)
then begin then begin
DebugLn(['TMainIDE.DoShowSaveProjectAsDialog failed renaming directives Old="',MainUnitInfo.Filename,'" New="',NewProgramFilename,'"']); DebugLn(['TMainIDE.DoShowSaveProjectAsDialog failed renaming directives Old="',MainUnitInfo.Filename,'" New="',NewProgramFilename,'"']);
// silently ignore // silently ignore
@ -10552,7 +10552,7 @@ begin
end; end;
// init resource files // init resource files
if not Project1.Resources.Regenerate(Project1.MainFilename, True, False,'') then if not Project1.ProjResources.Regenerate(Project1.MainFilename, True, False,'') then
DebugLn('TMainIDE.DoNewProject Project1.Resources.Regenerate failed'); DebugLn('TMainIDE.DoNewProject Project1.Resources.Regenerate failed');
finally finally
Project1.EndUpdate; Project1.EndUpdate;
@ -11319,7 +11319,7 @@ begin
Result:=DoSaveAll([sfCheckAmbiguousFiles]) Result:=DoSaveAll([sfCheckAmbiguousFiles])
else else
Result:=DoSaveProjectToTestDirectory([sfSaveNonProjectFiles]); Result:=DoSaveProjectToTestDirectory([sfSaveNonProjectFiles]);
Project1.Resources.DoBeforeBuild(AReason, Project1.IsVirtual); Project1.ProjResources.DoBeforeBuild(AReason, Project1.IsVirtual);
Project1.UpdateExecutableType; Project1.UpdateExecutableType;
if Result<>mrOk then begin if Result<>mrOk then begin
{$IFDEF VerboseSaveForBuild} {$IFDEF VerboseSaveForBuild}
@ -11599,7 +11599,7 @@ begin
Result:=DoSaveForBuild(AReason); Result:=DoSaveForBuild(AReason);
if Result<>mrOk then exit; if Result<>mrOk then exit;
if (Project1.Resources.ResourceType=rtRes) then begin if (Project1.ProjResources.ResourceType=rtRes) then begin
// FPC resources are only supported with FPC 2.4+ // FPC resources are only supported with FPC 2.4+
CodeToolBoss.GetFPCVersionForDirectory( CodeToolBoss.GetFPCVersionForDirectory(
ExtractFilePath(Project1.MainFilename),FPCVersion,FPCRelease,FPCPatch); ExtractFilePath(Project1.MainFilename),FPCVersion,FPCRelease,FPCPatch);
@ -11730,7 +11730,7 @@ begin
if not (Result in [mrOk,mrIgnore]) then exit; if not (Result in [mrOk,mrIgnore]) then exit;
end; end;
if not Project1.Resources.Regenerate(Project1.MainFilename, False, True, TargetExeDirectory) then if not Project1.ProjResources.Regenerate(Project1.MainFilename, False, True, TargetExeDirectory) then
Exit; Exit;
// execute compilation tool 'Before' // execute compilation tool 'Before'
@ -11809,7 +11809,7 @@ begin
end; end;
end; end;
Project1.Resources.DoAfterBuild(AReason, Project1.IsVirtual); Project1.ProjResources.DoAfterBuild(AReason, Project1.IsVirtual);
// add success message // add success message
MessagesView.AddMsg(Format(lisProjectSuccessfullyBuilt, ['"', MessagesView.AddMsg(Format(lisProjectSuccessfullyBuilt, ['"',
Project1.ShortDescription, '"']),'',-1); Project1.ShortDescription, '"']),'',-1);

View File

@ -647,7 +647,7 @@ end;
function TFileDescPascalUnitWithProjectResource.GetResourceType: TResourceType; function TFileDescPascalUnitWithProjectResource.GetResourceType: TResourceType;
begin begin
Result := Project1.Resources.ResourceType; Result := Project1.ProjResources.ResourceType;
end; end;
end. end.

View File

@ -784,7 +784,6 @@ type
fProjectInfoFileBufChangeStamp: integer; fProjectInfoFileBufChangeStamp: integer;
fProjectInfoFileDate: LongInt; fProjectInfoFileDate: LongInt;
FPublishOptions: TPublishProjectOptions; FPublishOptions: TPublishProjectOptions;
FResources: TProjectResources;
FRevertLockCount: integer; FRevertLockCount: integer;
FRunParameterOptions: TRunParamsOptions; FRunParameterOptions: TRunParamsOptions;
FSessionModifiedBackup: boolean; FSessionModifiedBackup: boolean;
@ -804,6 +803,7 @@ type
function GetFirstUnitWithEditorIndex: TUnitInfo; function GetFirstUnitWithEditorIndex: TUnitInfo;
function GetMainFilename: String; function GetMainFilename: String;
function GetMainUnitInfo: TUnitInfo; function GetMainUnitInfo: TUnitInfo;
function GetProjResources: TProjectResources;
function GetTargetFilename: string; function GetTargetFilename: string;
function GetUnits(Index: integer): TUnitInfo; function GetUnits(Index: integer): TUnitInfo;
function JumpHistoryCheckPosition( function JumpHistoryCheckPosition(
@ -1088,7 +1088,7 @@ type
read GetProjectInfoFile write SetProjectInfoFile; read GetProjectInfoFile write SetProjectInfoFile;
property PublishOptions: TPublishProjectOptions property PublishOptions: TPublishProjectOptions
read FPublishOptions write FPublishOptions; read FPublishOptions write FPublishOptions;
property Resources: TProjectResources read FResources; property ProjResources: TProjectResources read GetProjResources;
property RunParameterOptions: TRunParamsOptions read FRunParameterOptions; property RunParameterOptions: TRunParamsOptions read FRunParameterOptions;
property SourceDirectories: TFileReferenceList read FSourceDirectories; property SourceDirectories: TFileReferenceList read FSourceDirectories;
@ -2575,7 +2575,7 @@ begin
FUnitList := TFPList.Create; // list of TUnitInfo FUnitList := TFPList.Create; // list of TUnitInfo
FResources := TProjectResources.Create(Self); FResources := TProjectResources.Create(Self);
FResources.OnModified := @EmbeddedObjectModified; ProjResources.OnModified := @EmbeddedObjectModified;
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -2864,7 +2864,7 @@ begin
''); '');
// Resources // Resources
Resources.WriteToProjectFile(xmlconfig, Path); ProjResources.WriteToProjectFile(xmlconfig, Path);
// save custom data // save custom data
SaveStringToStringTree(xmlconfig,CustomData,Path+'CustomData/'); SaveStringToStringTree(xmlconfig,CustomData,Path+'CustomData/');
@ -3410,7 +3410,7 @@ begin
LoadBuildModes(XMLConfig,Path,true); LoadBuildModes(XMLConfig,Path,true);
// Resources // Resources
Resources.ReadFromProjectFile(xmlconfig, Path); ProjResources.ReadFromProjectFile(xmlconfig, Path);
// load custom data // load custom data
LoadStringToStringTree(xmlconfig,CustomData,Path+'CustomData/'); LoadStringToStringTree(xmlconfig,CustomData,Path+'CustomData/');
@ -3834,7 +3834,7 @@ begin
if not AValue then if not AValue then
begin begin
PublishOptions.Modified := False; PublishOptions.Modified := False;
Resources.Modified := False; ProjResources.Modified := False;
BuildModes.Modified:=false; BuildModes.Modified:=false;
SessionModified := False; SessionModified := False;
end; end;
@ -4236,7 +4236,7 @@ end;
procedure TProject.EmbeddedObjectModified(Sender: TObject); procedure TProject.EmbeddedObjectModified(Sender: TObject);
begin begin
if Resources.Modified then if ProjResources.Modified then
Modified := True; Modified := True;
end; end;
@ -4268,6 +4268,11 @@ begin
Result:=nil; Result:=nil;
end; end;
function TProject.GetProjResources: TProjectResources;
begin
Result:=TProjectResources(Resources);
end;
function TProject.GetProjectInfoFile:string; function TProject.GetProjectInfoFile:string;
begin begin
Result:=fProjectInfoFile; Result:=fProjectInfoFile;
@ -5137,7 +5142,7 @@ begin
if MainUnitInfo = AnUnitInfo then if MainUnitInfo = AnUnitInfo then
begin begin
// we are renaming a project => update resource directives // we are renaming a project => update resource directives
Resources.RenameDirectives(OldUnitName, NewUnitName); ProjResources.RenameDirectives(OldUnitName, NewUnitName);
end; end;
end; end;
end; end;

View File

@ -39,7 +39,8 @@ interface
uses uses
Classes, SysUtils, Laz_XMLCfg, Classes, SysUtils, Laz_XMLCfg,
Controls, Forms, SynRegExpr, FileProcs, LCLProc, Controls, Forms, SynRegExpr, FileProcs, LCLProc,
CompOptsIntf, ProjectIntf, PublishModule, LazIDEIntf, CompOptsIntf, ProjectIntf, PublishModule, LazIDEIntf, W32Manifest,
ProjectResourcesIntf,
frmCustomApplicationOptions, IDEProcs, LazarusIDEStrConsts; frmCustomApplicationOptions, IDEProcs, LazarusIDEStrConsts;
type type
@ -1276,6 +1277,7 @@ begin
AProject.AddFile(MainFile,false); AProject.AddFile(MainFile,false);
AProject.MainFileID:=0; AProject.MainFileID:=0;
AProject.UseAppBundle:=true; AProject.UseAppBundle:=true;
TProjectXPManifest(TAbstractProjectResources(AProject.Resources)[TProjectXPManifest]).UseManifest:=true;
// create program source // create program source
le:=LineEnding; le:=LineEnding;
@ -1339,6 +1341,7 @@ begin
AProject.AddFile(MainFile,false); AProject.AddFile(MainFile,false);
AProject.MainFileID:=0; AProject.MainFileID:=0;
AProject.UseAppBundle:=true; AProject.UseAppBundle:=true;
TProjectXPManifest(TAbstractProjectResources(AProject.Resources)[TProjectXPManifest]).UseManifest:=true;
// create program source // create program source
le:=LineEnding; le:=LineEnding;

View File

@ -106,7 +106,7 @@ end;
constructor TProjectXPManifest.Create; constructor TProjectXPManifest.Create;
begin begin
inherited Create; inherited Create;
UseManifest := True; UseManifest := False;
DpiAware := False; DpiAware := False;
end; end;

View File

@ -354,6 +354,7 @@ type
protected protected
FLazCompilerOptions: TLazCompilerOptions; FLazCompilerOptions: TLazCompilerOptions;
FFlags: TProjectFlags; FFlags: TProjectFlags;
FResources: TObject;
function GetMainFile: TLazProjectFile; virtual; abstract; function GetMainFile: TLazProjectFile; virtual; abstract;
function GetMainFileID: Integer; virtual; abstract; function GetMainFileID: Integer; virtual; abstract;
procedure SetMainFileID(const AValue: Integer); virtual; abstract; procedure SetMainFileID(const AValue: Integer); virtual; abstract;
@ -418,6 +419,7 @@ type
property CustomData: TStringToStringTree read FCustomData; property CustomData: TStringToStringTree read FCustomData;
property CustomSessionData: TStringToStringTree read FCustomSessionData; property CustomSessionData: TStringToStringTree read FCustomSessionData;
property UseAppBundle: Boolean read FUseAppBundle write FUseAppBundle; property UseAppBundle: Boolean read FUseAppBundle write FUseAppBundle;
property Resources: TObject read FResources; // TAbstractProjectResources
end; end;
TLazProjectClass = class of TLazProject; TLazProjectClass = class of TLazProject;