| 1 | unit ProjectTemplates;
|
|---|
| 2 |
|
|---|
| 3 | interface
|
|---|
| 4 |
|
|---|
| 5 | uses
|
|---|
| 6 | Classes, SysUtils, Project;
|
|---|
| 7 |
|
|---|
| 8 | type
|
|---|
| 9 |
|
|---|
| 10 | { TProjectTemplateConsoleApp }
|
|---|
| 11 |
|
|---|
| 12 | TProjectTemplateConsoleApp = class(TProjectTemplate)
|
|---|
| 13 | constructor Create; override;
|
|---|
| 14 | procedure InitProject(var Project: TProject); override;
|
|---|
| 15 | end;
|
|---|
| 16 |
|
|---|
| 17 | { TProjectTemplateGUIApp }
|
|---|
| 18 |
|
|---|
| 19 | TProjectTemplateGUIApp = class(TProjectTemplate)
|
|---|
| 20 | constructor Create; override;
|
|---|
| 21 | procedure InitProject(var Project: TProject); override;
|
|---|
| 22 | end;
|
|---|
| 23 |
|
|---|
| 24 | { TProjectTemplatePackage }
|
|---|
| 25 |
|
|---|
| 26 | TProjectTemplatePackage = class(TProjectTemplate)
|
|---|
| 27 | constructor Create; override;
|
|---|
| 28 | procedure InitProject(var Project: TProject); override;
|
|---|
| 29 | end;
|
|---|
| 30 |
|
|---|
| 31 | { TProjectTemplateUnit }
|
|---|
| 32 |
|
|---|
| 33 | TProjectTemplateUnit = class(TProjectTemplate)
|
|---|
| 34 | constructor Create; override;
|
|---|
| 35 | procedure InitProject(var Project: TProject); override;
|
|---|
| 36 | end;
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 | implementation
|
|---|
| 40 |
|
|---|
| 41 | resourcestring
|
|---|
| 42 | SConsoleApplication = 'Console application';
|
|---|
| 43 | SUnit = 'Unit';
|
|---|
| 44 | SPackage = 'Package';
|
|---|
| 45 | SGUIApplication = 'GUI application';
|
|---|
| 46 |
|
|---|
| 47 | { TProjectTemplateUnit }
|
|---|
| 48 |
|
|---|
| 49 | constructor TProjectTemplateUnit.Create;
|
|---|
| 50 | begin
|
|---|
| 51 | inherited Create;
|
|---|
| 52 | Name := SUnit;
|
|---|
| 53 | IsProject := False;
|
|---|
| 54 | end;
|
|---|
| 55 |
|
|---|
| 56 | procedure TProjectTemplateUnit.InitProject(var Project: TProject);
|
|---|
| 57 | var
|
|---|
| 58 | NewFile: TProjectFile;
|
|---|
| 59 | begin
|
|---|
| 60 | //inherited InitProject(Project);
|
|---|
| 61 | NewFile := Project.Files.AddFile('Unit1.pas');
|
|---|
| 62 | with NewFile.Source do begin
|
|---|
| 63 | Add('unit Unit1;');
|
|---|
| 64 | Add('');
|
|---|
| 65 | Add('interface');
|
|---|
| 66 | Add('');
|
|---|
| 67 | Add('implementation');
|
|---|
| 68 | Add('');
|
|---|
| 69 | Add('end.');
|
|---|
| 70 | end;
|
|---|
| 71 | end;
|
|---|
| 72 |
|
|---|
| 73 | { TProjectTemplatePackage }
|
|---|
| 74 |
|
|---|
| 75 | constructor TProjectTemplatePackage.Create;
|
|---|
| 76 | begin
|
|---|
| 77 | inherited Create;
|
|---|
| 78 | Name := SPackage;
|
|---|
| 79 | IsProject := True;
|
|---|
| 80 | end;
|
|---|
| 81 |
|
|---|
| 82 | procedure TProjectTemplatePackage.InitProject(var Project: TProject);
|
|---|
| 83 | var
|
|---|
| 84 | NewFile: TProjectFile;
|
|---|
| 85 | begin
|
|---|
| 86 | inherited InitProject(Project);
|
|---|
| 87 | NewFile := Project.Files.AddFile('Package1.bpl');
|
|---|
| 88 | with NewFile.Source do begin
|
|---|
| 89 | Add('package Package1;');
|
|---|
| 90 | Add('');
|
|---|
| 91 | Add('requires');
|
|---|
| 92 | Add(' RTL;');
|
|---|
| 93 | Add('');
|
|---|
| 94 | Add('end.');
|
|---|
| 95 | end;
|
|---|
| 96 | Project.MainSource := NewFile;
|
|---|
| 97 | end;
|
|---|
| 98 |
|
|---|
| 99 | { TProjectTemplateGUIApp }
|
|---|
| 100 |
|
|---|
| 101 | constructor TProjectTemplateGUIApp.Create;
|
|---|
| 102 | begin
|
|---|
| 103 | inherited Create;
|
|---|
| 104 | Name := SGUIApplication;
|
|---|
| 105 | IsProject := True;
|
|---|
| 106 | end;
|
|---|
| 107 |
|
|---|
| 108 | procedure TProjectTemplateGUIApp.InitProject(var Project: TProject);
|
|---|
| 109 | var
|
|---|
| 110 | NewFile: TProjectFile;
|
|---|
| 111 | begin
|
|---|
| 112 | inherited InitProject(Project);
|
|---|
| 113 | NewFile := Project.Files.AddFile('Project1.dpr');
|
|---|
| 114 | with NewFile.Source do begin
|
|---|
| 115 | Add('program Project1;');
|
|---|
| 116 | Add('');
|
|---|
| 117 | Add('uses');
|
|---|
| 118 | Add(' GUI;');
|
|---|
| 119 | Add('');
|
|---|
| 120 | Add('var');
|
|---|
| 121 | Add(' Application: TApplication');
|
|---|
| 122 | Add('begin');
|
|---|
| 123 | Add(' Application := TApplication.Create;');
|
|---|
| 124 | Add(' Application.Run;');
|
|---|
| 125 | Add(' Application.Free;');
|
|---|
| 126 | Add('end.');
|
|---|
| 127 | end;
|
|---|
| 128 | Project.MainSource := NewFile;
|
|---|
| 129 | end;
|
|---|
| 130 |
|
|---|
| 131 | { TProjectTemplateConsoleApp }
|
|---|
| 132 |
|
|---|
| 133 | constructor TProjectTemplateConsoleApp.Create;
|
|---|
| 134 | begin
|
|---|
| 135 | inherited Create;
|
|---|
| 136 | Name := SConsoleApplication;
|
|---|
| 137 | IsProject := True;
|
|---|
| 138 | end;
|
|---|
| 139 |
|
|---|
| 140 | procedure TProjectTemplateConsoleApp.InitProject(var Project: TProject);
|
|---|
| 141 | var
|
|---|
| 142 | NewFile: TProjectFile;
|
|---|
| 143 | begin
|
|---|
| 144 | inherited InitProject(Project);
|
|---|
| 145 | NewFile := Project.Files.AddFile('Project1.dpr');
|
|---|
| 146 | with NewFile.Source do begin
|
|---|
| 147 | Add('program Project1;');
|
|---|
| 148 | Add('');
|
|---|
| 149 | Add('begin');
|
|---|
| 150 | Add('end.');
|
|---|
| 151 | end;
|
|---|
| 152 | Project.MainSource := NewFile;
|
|---|
| 153 | end;
|
|---|
| 154 |
|
|---|
| 155 | end.
|
|---|
| 156 |
|
|---|