added new IDE item Library

git-svn-id: trunk@8403 -
This commit is contained in:
mattias 2005-12-31 15:01:36 +00:00
parent 362f7962be
commit 70eae36fca
4 changed files with 77 additions and 0 deletions

View File

@ -2879,6 +2879,9 @@ resourcestring
+'freepascal program. The program file is automatically maintained by '
+'lazarus.';
lisCustomProgramAFreepascalProgram = 'Custom Program%sA freepascal program.';
lisLibraryAFreepascalLibraryDllUnderWindowsSoUnderLin = 'Library%sA '
+'freepascal library (.dll under windows, .so under linux, .so under '
+'macosx). The library source file is automatically maintained by Lazarus.';
lisNPSelectAProjectType = 'Select a project type';
lisNPCreateANewProject = 'Create a new project';
lisNPCreate = 'Create';

View File

@ -1809,6 +1809,7 @@ begin
LazProjectDescriptors:=TLazProjectDescriptors.Create;
RegisterProjectDescriptor(TProjectApplicationDescriptor.Create);
RegisterProjectDescriptor(TProjectProgramDescriptor.Create);
RegisterProjectDescriptor(TProjectLibraryDescriptor.Create);
RegisterProjectDescriptor(TProjectManualProgramDescriptor.Create);
end;

View File

@ -377,6 +377,17 @@ type
function CreateStartFiles(AProject: TLazProject): TModalResult; override;
end;
{ TProjectLibraryDescriptor }
TProjectLibraryDescriptor = class(TProjectDescriptor)
public
constructor Create; override;
function GetLocalizedName: string; override;
function GetLocalizedDescription: string; override;
function InitProject(AProject: TLazProject): TModalResult; override;
function CreateStartFiles(AProject: TLazProject): TModalResult; override;
end;
{ TProjectManualProgramDescriptor }
TProjectManualProgramDescriptor = class(TProjectDescriptor)
@ -3982,5 +3993,60 @@ begin
FAddMainSource:=false;
end;
{ TProjectLibraryDescriptor }
constructor TProjectLibraryDescriptor.Create;
begin
inherited Create;
Name:=ProjDescNameLibrary;
end;
function TProjectLibraryDescriptor.GetLocalizedName: string;
begin
Result:='Library';
end;
function TProjectLibraryDescriptor.GetLocalizedDescription: string;
begin
Result:= Format(lisLibraryAFreepascalLibraryDllUnderWindowsSoUnderLin, [#13]);
end;
function TProjectLibraryDescriptor.InitProject(AProject: TLazProject
): TModalResult;
var
le: String;
NewSource: String;
MainFile: TLazProjectFile;
begin
Result:=inherited InitProject(AProject);
MainFile:=AProject.CreateProjectFile('project1.lpr');
MainFile.IsPartOfProject:=true;
AProject.AddFile(MainFile,false);
AProject.MainFileID:=0;
// create program source
le:=LineEnding;
NewSource:='library Project1;'+le
+le
+'{$mode objfpc}{$H+}'+le
+le
+'uses'+le
+' Classes'+le
+' { add your units here };'+le
+le
+'begin'+le
+'end.'+le
+le;
AProject.MainFile.SetSourceText(NewSource);
end;
function TProjectLibraryDescriptor.CreateStartFiles(AProject: TLazProject
): TModalResult;
begin
Result:=LazarusIDE.DoOpenEditorFile(AProject.MainFile.Filename,-1,
[ofProjectLoading,ofRegularFile]);
end;
end.

View File

@ -34,6 +34,7 @@ const
ProjDescGroupName = 'Project';
ProjDescNameApplication = 'Application';
ProjDescNameProgram = 'Program';
ProjDescNameLibrary = 'Library';
ProjDescNameCustomProgram = 'Custom Program';
type
@ -571,6 +572,7 @@ var
function ProjectDescriptorApplication: TProjectDescriptor;
function ProjectDescriptorProgram: TProjectDescriptor;
function ProjectDescriptorLibrary: TProjectDescriptor;
function ProjectDescriptorCustomProgram: TProjectDescriptor;
const
@ -677,6 +679,11 @@ begin
Result:=ProjectDescriptors.FindByName(ProjDescNameProgram);
end;
function ProjectDescriptorLibrary: TProjectDescriptor;
begin
Result:=ProjectDescriptors.FindByName(ProjDescNameLibrary);
end;
function ProjectDescriptorCustomProgram: TProjectDescriptor;
begin
Result:=ProjectDescriptors.FindByName(ProjDescNameCustomProgram);