forked from rofl0r/TntUnicode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTntForms_Design.pas
422 lines (356 loc) · 10.6 KB
/
TntForms_Design.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
{*****************************************************************************}
{ }
{ Tnt Delphi Unicode Controls }
{ http://www.tntware.com/delphicontrols/unicode/ }
{ Version: 2.3.0 }
{ }
{ Copyright (c) 2002-2007, Troy Wolbrink ([email protected]) }
{ }
{*****************************************************************************}
unit TntForms_Design;
{$INCLUDE ..\Source\TntCompilers.inc}
interface
uses
Classes, Windows, DesignIntf, ToolsApi;
type HICON = LongWord;
type
TTntNewFormWizard = class(TNotifierObject, IOTAWizard, IOTARepositoryWizard,
IOTAFormWizard
{$IFDEF COMPILER_6_UP}, IOTARepositoryWizard60{$ENDIF}
{$IFDEF COMPILER_9_UP}, IOTARepositoryWizard80{$ENDIF})
protected
function ThisFormName: WideString;
function ThisFormClass: TComponentClass; virtual; abstract;
function ThisFormUnit: WideString;
public
// IOTAWizard
function GetIDString: AnsiString;
function GetName: AnsiString; virtual;
function GetState: TWizardState;
procedure Execute;
// IOTARepositoryWizard
function GetAuthor: AnsiString;
function GetComment: AnsiString; virtual; abstract;
function GetPage: AnsiString;
function GetGlyph: HICON;
{$IFDEF COMPILER_6_UP}
// IOTARepositoryWizard60
function GetDesigner: AnsiString;
{$ENDIF}
{$IFDEF COMPILER_9_UP}
// IOTARepositoryWizard80
function GetGalleryCategory: IOTAGalleryCategory;
function GetPersonality: AnsiString;
{$ENDIF}
end;
procedure Register;
implementation
uses
TntForms, DesignEditors, WCtlForm, TypInfo, SysUtils;
type
TTntNewTntFormWizard = class(TTntNewFormWizard)
protected
function ThisFormClass: TComponentClass; override;
public
function GetName: AnsiString; override;
function GetComment: AnsiString; override;
end;
TTntNewTntFrameWizard = class(TTntNewFormWizard)
protected
function ThisFormClass: TComponentClass; override;
public
function GetName: AnsiString; override;
function GetComment: AnsiString; override;
end;
TTntFrameCustomModule = class(TWinControlCustomModule)
public
function Nestable: Boolean; override;
end;
TTntFormCustomModule = class(TCustomModule)
public
class function DesignClass: TComponentClass; override;
end;
procedure Register;
begin
RegisterCustomModule(TTntFrame, TTntFrameCustomModule);
RegisterPackageWizard(TTntNewTntFrameWizard.Create);
//--
RegisterCustomModule(TTntForm, TTntFormCustomModule);
//--
RegisterPackageWizard(TTntNewTntFormWizard.Create);
end;
function GetFirstModuleSupporting(const IID: TGUID): IOTAModule;
var
ModuleServices: IOTAModuleServices;
i: integer;
begin
Result := nil;
if Assigned(BorlandIDEServices) then
begin
// look for the first project
ModuleServices := BorlandIDEServices as IOTAModuleServices;
for i := 0 to ModuleServices.ModuleCount - 1 do
if Supports(ModuleServices.Modules[i], IID, Result) then
Break;
end;
end;
function MyGetActiveProject: IOTAProject;
{$IFDEF COMPILER_7_UP}
begin
Result := ToolsAPI.GetActiveProject;
{$ELSE}
var
ProjectGroup: IOTAProjectGroup;
begin
ProjectGroup := GetFirstModuleSupporting(IOTAProjectGroup) as IOTAProjectGroup;
if ProjectGroup = nil then
Result := nil
else
Result := ProjectGroup.ActiveProject;
{$ENDIF}
if (Result = nil) then
Result := GetFirstModuleSupporting(IOTAProject) as IOTAProject;
end;
{ TTntNewFormCreator }
type
TTntNewFormCreator = class(TInterfacedObject, IOTACreator, IOTAModuleCreator)
private
FAncestorName: WideString;
FUnitName: WideString;
public
// IOTACreator
function GetCreatorType: AnsiString;
function GetExisting: Boolean;
function GetFileSystem: AnsiString;
function GetOwner: IOTAModule;
function GetUnnamed: Boolean;
// IOTAModuleCreator
function GetAncestorName: AnsiString;
function GetImplFileName: AnsiString;
function GetIntfFileName: AnsiString;
function GetFormName: AnsiString;
function GetMainForm: Boolean;
function GetShowForm: Boolean;
function GetShowSource: Boolean;
function NewFormFile(const FormIdent, AncestorIdent: AnsiString): IOTAFile;
function NewImplSource(const ModuleIdent, FormIdent, AncestorIdent: AnsiString): IOTAFile;
function NewIntfSource(const ModuleIdent, FormIdent, AncestorIdent: AnsiString): IOTAFile;
procedure FormCreated(const FormEditor: IOTAFormEditor);
public
constructor Create(const UnitName, AncestorName: WideString);
end;
TTntSourceFile = class(TInterfacedObject, IOTAFile)
private
FSource: AnsiString;
public
function GetSource: AnsiString;
function GetAge: TDateTime;
constructor Create(const Source: AnsiString);
end;
constructor TTntNewFormCreator.Create(const UnitName, AncestorName: WideString);
begin
inherited Create;
FUnitName := UnitName;
FAncestorName := AncestorName;
end;
procedure TTntNewFormCreator.FormCreated(const FormEditor: IOTAFormEditor);
begin
end;
function TTntNewFormCreator.GetAncestorName: AnsiString;
begin
Result := FAncestorName;
end;
function TTntNewFormCreator.GetCreatorType: AnsiString;
begin
Result := sForm;
end;
function TTntNewFormCreator.GetExisting: Boolean;
begin
Result := False;
end;
function TTntNewFormCreator.GetFileSystem: AnsiString;
begin
Result := '';
end;
function TTntNewFormCreator.GetFormName: AnsiString;
begin
Result := '';
end;
function TTntNewFormCreator.GetImplFileName: AnsiString;
begin
Result := '';
end;
function TTntNewFormCreator.GetIntfFileName: AnsiString;
begin
Result := '';
end;
function TTntNewFormCreator.GetMainForm: Boolean;
begin
Result := False;
end;
function TTntNewFormCreator.GetOwner: IOTAModule;
begin
Result := MyGetActiveProject;
end;
function TTntNewFormCreator.GetShowForm: Boolean;
begin
Result := True;
end;
function TTntNewFormCreator.GetShowSource: Boolean;
begin
Result := True;
end;
function TTntNewFormCreator.GetUnnamed: Boolean;
begin
Result := True;
end;
function TTntNewFormCreator.NewFormFile(const FormIdent, AncestorIdent: AnsiString): IOTAFile;
begin
Result := nil;
end;
function TTntNewFormCreator.NewImplSource(const ModuleIdent, FormIdent, AncestorIdent: AnsiString): IOTAFile;
const
cSource =
'unit %s;' + #13#10 +
'' + #13#10 +
'interface' + #13#10 +
'' + #13#10 +
'uses' + #13#10 +
' Windows, Messages, SysUtils' + {$IFDEF COMPILER_6_UP}', Variants' + {$ENDIF}
', Classes, Graphics, Controls, Forms,' + #13#10 + ' Dialogs, %s;' + #13#10 +
'' + #13#10 +
'type' + #13#10 +
' T%s = class(T%s)' + #13#10 +
' private' + #13#10 +
' { Private declarations }' + #13#10 +
' public' + #13#10 +
' { Public declarations }' + #13#10 +
' end;' + #13#10 +
'' + #13#10 +
'var' + #13#10 +
' %s: T%s;' + #13#10 +
'' + #13#10 +
'implementation' + #13#10 +
'' + #13#10 +
'{$R *.DFM}' + #13#10 +
'' + #13#10 +
'end.';
begin
Result := TTntSourceFile.Create(Format{TNT-ALLOW Format}(cSource,
[ModuleIdent, FUnitName, FormIdent, AncestorIdent, FormIdent, FormIdent]));
end;
function TTntNewFormCreator.NewIntfSource(const ModuleIdent, FormIdent, AncestorIdent: AnsiString): IOTAFile;
begin
Result := nil;
end;
{ TTntNewFormWizard }
function TTntNewFormWizard.ThisFormName: WideString;
begin
Result := ThisFormClass.ClassName;
Delete(Result, 1, 1); // drop the 'T'
end;
function TTntNewFormWizard.ThisFormUnit: WideString;
begin
Result := GetTypeData(ThisFormClass.ClassInfo).UnitName;
end;
function TTntNewFormWizard.GetName: AnsiString;
begin
Result := ThisFormName;
end;
function TTntNewFormWizard.GetAuthor: AnsiString;
begin
Result := 'Troy Wolbrink';
end;
function TTntNewFormWizard.GetPage: AnsiString;
begin
Result := 'New';
end;
function TTntNewFormWizard.GetGlyph: HICON;
begin
Result := 0;
end;
function TTntNewFormWizard.GetState: TWizardState;
begin
Result := [wsEnabled];
end;
function TTntNewFormWizard.GetIDString: AnsiString;
begin
Result := 'Tnt.Create_'+ThisFormName+'.Wizard';
end;
procedure TTntNewFormWizard.Execute;
var
Module: IOTAModule;
begin
Module := (BorlandIDEServices as IOTAModuleServices).CreateModule(TTntNewFormCreator.Create(ThisFormUnit, ThisFormName));
end;
{$IFDEF COMPILER_6_UP}
function TTntNewFormWizard.GetDesigner: AnsiString;
begin
Result := dVCL;
end;
{$ENDIF}
{$IFDEF COMPILER_9_UP}
function TTntNewFormWizard.GetGalleryCategory: IOTAGalleryCategory;
var
Manager: IOTAGalleryCategoryManager;
begin
Result := nil;
Manager := BorlandIDEServices as IOTAGalleryCategoryManager;
if Assigned(Manager) then
Result := Manager.FindCategory(sCategoryDelphiNew);
end;
function TTntNewFormWizard.GetPersonality: AnsiString;
begin
Result := sDelphiPersonality;
end;
{$ENDIF}
{ TTntSourceFile }
constructor TTntSourceFile.Create(const Source: AnsiString);
begin
FSource := Source;
end;
function TTntSourceFile.GetAge: TDateTime;
begin
Result := -1;
end;
function TTntSourceFile.GetSource: AnsiString;
begin
Result := FSource;
end;
{ TTntNewTntFormWizard }
function TTntNewTntFormWizard.ThisFormClass: TComponentClass;
begin
Result := TTntForm;
end;
function TTntNewTntFormWizard.GetName: AnsiString;
begin
Result := ThisFormName + ' (Unicode)'
end;
function TTntNewTntFormWizard.GetComment: AnsiString;
begin
Result := 'Creates a new Unicode enabled TntForm';
end;
{ TTntNewTntFrameWizard }
function TTntNewTntFrameWizard.ThisFormClass: TComponentClass;
begin
Result := TTntFrame;
end;
function TTntNewTntFrameWizard.GetName: AnsiString;
begin
Result := ThisFormName + ' (Unicode)'
end;
function TTntNewTntFrameWizard.GetComment: AnsiString;
begin
Result := 'Creates a new Unicode enabled TntFrame';
end;
{ TTntFrameCustomModule }
function TTntFrameCustomModule.Nestable: Boolean;
begin
Result := True;
end;
{ TTntFormCustomModule }
class function TTntFormCustomModule.DesignClass: TComponentClass;
begin
Result := TTntForm;
end;
end.