source: trunk/IDE/ProjectTemplates.pas

Last change on this file was 75, checked in by chronos, 6 months ago
  • Modified: Removed U prefix from unit names.
  • Modified: Updated Common package.
File size: 3.2 KB
Line 
1unit ProjectTemplates;
2
3interface
4
5uses
6 Classes, SysUtils, Project;
7
8type
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
39implementation
40
41resourcestring
42 SConsoleApplication = 'Console application';
43 SUnit = 'Unit';
44 SPackage = 'Package';
45 SGUIApplication = 'GUI application';
46
47{ TProjectTemplateUnit }
48
49constructor TProjectTemplateUnit.Create;
50begin
51 inherited Create;
52 Name := SUnit;
53 IsProject := False;
54end;
55
56procedure TProjectTemplateUnit.InitProject(var Project: TProject);
57var
58 NewFile: TProjectFile;
59begin
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;
71end;
72
73{ TProjectTemplatePackage }
74
75constructor TProjectTemplatePackage.Create;
76begin
77 inherited Create;
78 Name := SPackage;
79 IsProject := True;
80end;
81
82procedure TProjectTemplatePackage.InitProject(var Project: TProject);
83var
84 NewFile: TProjectFile;
85begin
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;
97end;
98
99{ TProjectTemplateGUIApp }
100
101constructor TProjectTemplateGUIApp.Create;
102begin
103 inherited Create;
104 Name := SGUIApplication;
105 IsProject := True;
106end;
107
108procedure TProjectTemplateGUIApp.InitProject(var Project: TProject);
109var
110 NewFile: TProjectFile;
111begin
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;
129end;
130
131{ TProjectTemplateConsoleApp }
132
133constructor TProjectTemplateConsoleApp.Create;
134begin
135 inherited Create;
136 Name := SConsoleApplication;
137 IsProject := True;
138end;
139
140procedure TProjectTemplateConsoleApp.InitProject(var Project: TProject);
141var
142 NewFile: TProjectFile;
143begin
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;
153end;
154
155end.
156
Note: See TracBrowser for help on using the repository browser.