2 {*****************************************************************************}
4 { Tnt Delphi Unicode Controls }
5 { http://www.tntware.com/delphicontrols/unicode/ }
8 { Copyright (c) 2002-2007, Troy Wolbrink (troy.wolbrink@tntware.com) }
10 {*****************************************************************************}
14 {$INCLUDE ..\Source\TntCompilers.inc}
19 Classes
, Windows
, DesignIntf
, ToolsApi
;
21 type HICON
= LongWord
;
24 TTntNewFormWizard
= class(TNotifierObject
, IOTAWizard
, IOTARepositoryWizard
,
26 {$IFDEF COMPILER_6_UP}, IOTARepositoryWizard60
{$ENDIF}
27 {$IFDEF COMPILER_9_UP}, IOTARepositoryWizard80
{$ENDIF})
29 function ThisFormName
: WideString
;
30 function ThisFormClass
: TComponentClass
; virtual; abstract;
31 function ThisFormUnit
: WideString
;
34 function GetIDString
: AnsiString
;
35 function GetName
: AnsiString
; virtual;
36 function GetState
: TWizardState
;
38 // IOTARepositoryWizard
39 function GetAuthor
: AnsiString
;
40 function GetComment
: AnsiString
; virtual; abstract;
41 function GetPage
: AnsiString
;
42 function GetGlyph
: HICON
;
43 {$IFDEF COMPILER_6_UP}
44 // IOTARepositoryWizard60
45 function GetDesigner
: AnsiString
;
47 {$IFDEF COMPILER_9_UP}
48 // IOTARepositoryWizard80
49 function GetGalleryCategory
: IOTAGalleryCategory
;
50 function GetPersonality
: AnsiString
;
59 TntForms
, DesignEditors
, WCtlForm
, TypInfo
, SysUtils
;
62 TTntNewTntFormWizard
= class(TTntNewFormWizard
)
64 function ThisFormClass
: TComponentClass
; override;
66 function GetName
: AnsiString
; override;
67 function GetComment
: AnsiString
; override;
70 TTntNewTntFrameWizard
= class(TTntNewFormWizard
)
72 function ThisFormClass
: TComponentClass
; override;
74 function GetName
: AnsiString
; override;
75 function GetComment
: AnsiString
; override;
78 TTntFrameCustomModule
= class(TWinControlCustomModule
)
80 function Nestable
: Boolean; override;
83 TTntFormCustomModule
= class(TCustomModule
)
85 class function DesignClass
: TComponentClass
; override;
90 RegisterCustomModule(TTntFrame
, TTntFrameCustomModule
);
91 RegisterPackageWizard(TTntNewTntFrameWizard
.Create
);
93 RegisterCustomModule(TTntForm
, TTntFormCustomModule
);
95 RegisterPackageWizard(TTntNewTntFormWizard
.Create
);
98 function GetFirstModuleSupporting(const IID
: TGUID
): IOTAModule
;
100 ModuleServices
: IOTAModuleServices
;
104 if Assigned(BorlandIDEServices
) then
106 // look for the first project
107 ModuleServices
:= BorlandIDEServices
as IOTAModuleServices
;
108 for i
:= 0 to ModuleServices
.ModuleCount
- 1 do
109 if Supports(ModuleServices
.Modules
[i
], IID
, Result
) then
114 function MyGetActiveProject
: IOTAProject
;
115 {$IFDEF COMPILER_7_UP}
117 Result
:= ToolsAPI
.GetActiveProject
;
120 ProjectGroup
: IOTAProjectGroup
;
122 ProjectGroup
:= GetFirstModuleSupporting(IOTAProjectGroup
) as IOTAProjectGroup
;
123 if ProjectGroup
= nil then
126 Result
:= ProjectGroup
.ActiveProject
;
128 if (Result
= nil) then
129 Result
:= GetFirstModuleSupporting(IOTAProject
) as IOTAProject
;
132 { TTntNewFormCreator }
134 TTntNewFormCreator
= class(TInterfacedObject
, IOTACreator
, IOTAModuleCreator
)
136 FAncestorName
: WideString
;
137 FUnitName
: WideString
;
140 function GetCreatorType
: AnsiString
;
141 function GetExisting
: Boolean;
142 function GetFileSystem
: AnsiString
;
143 function GetOwner
: IOTAModule
;
144 function GetUnnamed
: Boolean;
146 function GetAncestorName
: AnsiString
;
147 function GetImplFileName
: AnsiString
;
148 function GetIntfFileName
: AnsiString
;
149 function GetFormName
: AnsiString
;
150 function GetMainForm
: Boolean;
151 function GetShowForm
: Boolean;
152 function GetShowSource
: Boolean;
153 function NewFormFile(const FormIdent
, AncestorIdent
: AnsiString
): IOTAFile
;
154 function NewImplSource(const ModuleIdent
, FormIdent
, AncestorIdent
: AnsiString
): IOTAFile
;
155 function NewIntfSource(const ModuleIdent
, FormIdent
, AncestorIdent
: AnsiString
): IOTAFile
;
156 procedure FormCreated(const FormEditor
: IOTAFormEditor
);
158 constructor Create(const UnitName
, AncestorName
: WideString
);
161 TTntSourceFile
= class(TInterfacedObject
, IOTAFile
)
165 function GetSource
: AnsiString
;
166 function GetAge
: TDateTime
;
167 constructor Create(const Source
: AnsiString
);
170 constructor TTntNewFormCreator
.Create(const UnitName
, AncestorName
: WideString
);
173 FUnitName
:= UnitName
;
174 FAncestorName
:= AncestorName
;
177 procedure TTntNewFormCreator
.FormCreated(const FormEditor
: IOTAFormEditor
);
181 function TTntNewFormCreator
.GetAncestorName
: AnsiString
;
183 Result
:= FAncestorName
;
186 function TTntNewFormCreator
.GetCreatorType
: AnsiString
;
191 function TTntNewFormCreator
.GetExisting
: Boolean;
196 function TTntNewFormCreator
.GetFileSystem
: AnsiString
;
201 function TTntNewFormCreator
.GetFormName
: AnsiString
;
206 function TTntNewFormCreator
.GetImplFileName
: AnsiString
;
211 function TTntNewFormCreator
.GetIntfFileName
: AnsiString
;
216 function TTntNewFormCreator
.GetMainForm
: Boolean;
221 function TTntNewFormCreator
.GetOwner
: IOTAModule
;
223 Result
:= MyGetActiveProject
;
226 function TTntNewFormCreator
.GetShowForm
: Boolean;
231 function TTntNewFormCreator
.GetShowSource
: Boolean;
236 function TTntNewFormCreator
.GetUnnamed
: Boolean;
241 function TTntNewFormCreator
.NewFormFile(const FormIdent
, AncestorIdent
: AnsiString
): IOTAFile
;
246 function TTntNewFormCreator
.NewImplSource(const ModuleIdent
, FormIdent
, AncestorIdent
: AnsiString
): IOTAFile
;
249 'unit %s;' + #13#10 +
251 'interface' + #13#10 +
254 ' Windows, Messages, SysUtils' + {$IFDEF COMPILER_6_UP}', Variants' + {$ENDIF}
255 ', Classes, Graphics, Controls, Forms,' + #13#10 + ' Dialogs, %s;' + #13#10 +
258 ' T%s = class(T%s)' + #13#10 +
259 ' private' + #13#10 +
260 ' { Private declarations }' + #13#10 +
262 ' { Public declarations }' + #13#10 +
266 ' %s: T%s;' + #13#10 +
268 'implementation' + #13#10 +
270 '{$R *.DFM}' + #13#10 +
274 Result
:= TTntSourceFile
.Create(Format
{TNT-ALLOW Format}(cSource
,
275 [ModuleIdent
, FUnitName
, FormIdent
, AncestorIdent
, FormIdent
, FormIdent
]));
278 function TTntNewFormCreator
.NewIntfSource(const ModuleIdent
, FormIdent
, AncestorIdent
: AnsiString
): IOTAFile
;
283 { TTntNewFormWizard }
285 function TTntNewFormWizard
.ThisFormName
: WideString
;
287 Result
:= ThisFormClass
.ClassName
;
288 Delete(Result
, 1, 1); // drop the 'T'
291 function TTntNewFormWizard
.ThisFormUnit
: WideString
;
293 Result
:= GetTypeData(ThisFormClass
.ClassInfo
).UnitName
;
296 function TTntNewFormWizard
.GetName
: AnsiString
;
298 Result
:= ThisFormName
;
301 function TTntNewFormWizard
.GetAuthor
: AnsiString
;
303 Result
:= 'Troy Wolbrink';
306 function TTntNewFormWizard
.GetPage
: AnsiString
;
311 function TTntNewFormWizard
.GetGlyph
: HICON
;
316 function TTntNewFormWizard
.GetState
: TWizardState
;
318 Result
:= [wsEnabled
];
321 function TTntNewFormWizard
.GetIDString
: AnsiString
;
323 Result
:= 'Tnt.Create_'+ThisFormName
+'.Wizard';
326 procedure TTntNewFormWizard
.Execute
;
330 Module
:= (BorlandIDEServices
as IOTAModuleServices
).CreateModule(TTntNewFormCreator
.Create(ThisFormUnit
, ThisFormName
));
333 {$IFDEF COMPILER_6_UP}
334 function TTntNewFormWizard
.GetDesigner
: AnsiString
;
340 {$IFDEF COMPILER_9_UP}
341 function TTntNewFormWizard
.GetGalleryCategory
: IOTAGalleryCategory
;
343 Manager
: IOTAGalleryCategoryManager
;
346 Manager
:= BorlandIDEServices
as IOTAGalleryCategoryManager
;
347 if Assigned(Manager
) then
348 Result
:= Manager
.FindCategory(sCategoryDelphiNew
);
351 function TTntNewFormWizard
.GetPersonality
: AnsiString
;
353 Result
:= sDelphiPersonality
;
359 constructor TTntSourceFile
.Create(const Source
: AnsiString
);
364 function TTntSourceFile
.GetAge
: TDateTime
;
369 function TTntSourceFile
.GetSource
: AnsiString
;
374 { TTntNewTntFormWizard }
376 function TTntNewTntFormWizard
.ThisFormClass
: TComponentClass
;
381 function TTntNewTntFormWizard
.GetName
: AnsiString
;
383 Result
:= ThisFormName
+ ' (Unicode)'
386 function TTntNewTntFormWizard
.GetComment
: AnsiString
;
388 Result
:= 'Creates a new Unicode enabled TntForm';
391 { TTntNewTntFrameWizard }
393 function TTntNewTntFrameWizard
.ThisFormClass
: TComponentClass
;
398 function TTntNewTntFrameWizard
.GetName
: AnsiString
;
400 Result
:= ThisFormName
+ ' (Unicode)'
403 function TTntNewTntFrameWizard
.GetComment
: AnsiString
;
405 Result
:= 'Creates a new Unicode enabled TntFrame';
408 { TTntFrameCustomModule }
410 function TTntFrameCustomModule
.Nestable
: Boolean;
415 { TTntFormCustomModule }
417 class function TTntFormCustomModule
.DesignClass
: TComponentClass
;