From 70eae36fcaae4ca08e9ba99bc5e617365ab4554e Mon Sep 17 00:00:00 2001 From: mattias Date: Sat, 31 Dec 2005 15:01:36 +0000 Subject: [PATCH] added new IDE item Library git-svn-id: trunk@8403 - --- ide/lazarusidestrconsts.pas | 3 ++ ide/main.pp | 1 + ide/project.pp | 66 +++++++++++++++++++++++++++++++++++++ ideintf/projectintf.pas | 7 ++++ 4 files changed, 77 insertions(+) diff --git a/ide/lazarusidestrconsts.pas b/ide/lazarusidestrconsts.pas index 8e4a3303c6..c39e3662e4 100644 --- a/ide/lazarusidestrconsts.pas +++ b/ide/lazarusidestrconsts.pas @@ -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'; diff --git a/ide/main.pp b/ide/main.pp index aea457cdd7..4f42da8339 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -1809,6 +1809,7 @@ begin LazProjectDescriptors:=TLazProjectDescriptors.Create; RegisterProjectDescriptor(TProjectApplicationDescriptor.Create); RegisterProjectDescriptor(TProjectProgramDescriptor.Create); + RegisterProjectDescriptor(TProjectLibraryDescriptor.Create); RegisterProjectDescriptor(TProjectManualProgramDescriptor.Create); end; diff --git a/ide/project.pp b/ide/project.pp index 58fa005a11..118a3b4a9b 100644 --- a/ide/project.pp +++ b/ide/project.pp @@ -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. diff --git a/ideintf/projectintf.pas b/ideintf/projectintf.pas index 456443a95f..1571100894 100644 --- a/ideintf/projectintf.pas +++ b/ideintf/projectintf.pas @@ -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);