43
42
Buttons, SysUtils, Classes, LCLProc, ComCtrls, Controls, Dialogs,
44
Forms, StdCtrls, ExtCtrls, FileProcs,
43
Forms, StdCtrls, ExtCtrls, FileProcs, ButtonPanel,
45
44
IDEWindowIntf, IDEImagesIntf, NewItemIntf, PackageIntf, ProjectIntf,
47
LazarusIDEStrConsts, IDEContextHelpEdit, Project, MainIntf, ButtonPanel;
45
LazIDEIntf, IDEHelpIntf,
46
InputHistory, LazarusIDEStrConsts, Project, MainIntf;
50
49
{ TNewLazIDEItemCategory }
192
192
FNewItem := TNewIDEItemTemplate(ANode.Data);
194
InputHistories.NewFileType:=FNewItem.Name;
195
//debugln(['TNewOtherDialog.OKButtonClick InputHistories.NewFileType=',InputHistories.NewFileType]);
194
197
// if the selected item is an inherited one
195
198
if FNewItem is TNewItemProjectFile then
201
InputHistories.NewProjectType:=FNewItem.Name;
198
203
NewFile:=TNewItemProjectFile(FNewItem);
199
204
if (NewFile.Descriptor is TFileDescInheritedItem) then
201
AInheritedNode := nil;
202
206
// If we are inheriting from a form
203
207
if (NewFile.Descriptor is TFileDescInheritedComponent) then begin
204
208
InhCompItem:=TFileDescInheritedComponent(NewFile.Descriptor);
205
209
AInheritedNode := InheritableComponentsListView.Selected;
206
// load the ancestor component
207
AnUnitInfo:=TUnitInfo(AInheritedNode.Data);
208
if LazarusIDE.DoOpenComponent(AnUnitInfo.Filename,
209
[ofOnlyIfExists,ofQuiet,ofLoadHiddenResource,ofUseCache],[],
210
AncestorComponent)<>mrOk then
212
MessageDlg(lisErrorOpeningComponent,
213
lisUnableToOpenAncestorComponent, mtError, [mbCancel], 0);
210
if Assigned(AInheritedNode) then begin
211
// load the ancestor component
212
AnUnitInfo:=TUnitInfo(AInheritedNode.Data);
213
if LazarusIDE.DoOpenComponent(AnUnitInfo.Filename,
214
[ofOnlyIfExists,ofQuiet,ofLoadHiddenResource,ofUseCache],[],
215
AncestorComponent)<>mrOk then
217
MessageDlg(lisErrorOpeningComponent,
218
lisUnableToOpenAncestorComponent, mtError, [mbCancel], 0);
221
// Set the resource class of the file descriptor
222
InhCompItem.ResourceClass := TPersistentClass(AncestorComponent.ClassType);
223
InhCompItem.InheritedUnit := AnUnitInfo;
224
InhCompItem.DeclareClassVariable := not AncestorComponent.ClassType.InheritsFrom(TFrame);
225
//DebugLn(['TNewOtherDialog.OKButtonClick ',InhCompItem.InheritedUnit.Filename,' ',dbgsname(InhCompItem.ResourceClass)]);
216
// Set the resource class of the file descriptor
217
InhCompItem.ResourceClass := TPersistentClass(AncestorComponent.ClassType);
218
InhCompItem.InheritedUnit := AnUnitInfo;
219
InhCompItem.DeclareClassVariable := not AncestorComponent.ClassType.InheritsFrom(TFrame);
220
//DebugLn(['TNewOtherDialog.OKButtonClick ',InhCompItem.InheritedUnit.Filename,' ',dbgsname(InhCompItem.ResourceClass)]);
330
336
DescriptionGroupBox.Caption := lisCodeHelpDescrTag;
331
337
DescriptionLabel.Caption := '';
333
ButtonPanel.OKButton.Caption := lisOk;
339
ButtonPanel.OKButton.Caption := lisMenuOk;
334
340
ButtonPanel.HelpButton.Caption := lisMenuHelp;
335
ButtonPanel.CancelButton.Caption := dlgCancel;
341
ButtonPanel.CancelButton.Caption := lisCancel;
338
344
procedure TNewOtherDialog.UpdateDescription;
369
375
DescriptionLabel.Caption := Desc;
378
function TNewOtherDialog.FindItem(const aName: string): TTreeNode;
380
if aName='' then exit(nil);
381
Result:=ItemsTreeView.Items.GetFirstNode;
382
while Result<>nil do begin
383
if (Result.Data<>nil)
384
and (TObject(Result.Data) is TNewIDEItemTemplate)
385
and (CompareText(TNewIDEItemTemplate(Result.Data).Name,aName)=0) then
387
Result:=Result.GetNext;
372
391
constructor TNewOtherDialog.Create(TheOwner: TComponent);
374
395
inherited Create(TheOwner);
375
396
Caption := lisMenuNewOther;
378
399
FillProjectInheritableItemsList;
379
400
InheritableComponentsListView.Visible := false;
380
401
IDEDialogLayoutList.ApplyLayout(Self, 570, 400);
403
Node:=FindItem(InputHistories.NewFileType);
405
Node:=FindItem(InputHistories.NewProjectType);
407
ItemsTreeView.Selected:=Node;
383
410
destructor TNewOtherDialog.Destroy;