From 8416ec2b2dea25a45ab27313fab297f157d89c52 Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 25 Sep 2006 20:34:51 +0000 Subject: [PATCH] IDE: using new unitname instead of default unitname git-svn-id: trunk@9975 - --- designer/designer.pp | 4 ++-- ide/componentpalette.pas | 2 +- ide/customformeditor.pp | 17 ++++++++++++----- ide/main.pp | 2 +- ideintf/formeditingintf.pas | 1 + 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/designer/designer.pp b/designer/designer.pp index 41d4ad178d..871643682f 100644 --- a/designer/designer.pp +++ b/designer/designer.pp @@ -1452,8 +1452,8 @@ var // create component and component interface NewCI := TComponentInterface(TheFormEditor.CreateComponent( - ParentCI,SelectedCompClass.ComponentClass - ,NewLeft,NewTop,NewWidth,NewHeight)); + ParentCI,SelectedCompClass.ComponentClass,'', + NewLeft,NewTop,NewWidth,NewHeight)); if NewCI=nil then exit; NewComponent:=NewCI.Component; diff --git a/ide/componentpalette.pas b/ide/componentpalette.pas index fbb1c6e492..aa1e78f3ef 100644 --- a/ide/componentpalette.pas +++ b/ide/componentpalette.pas @@ -239,7 +239,7 @@ begin if not FormEditingHook.GetDefaultComponentPosition(TypeClass,ParentCI,X,Y) then exit; //debugln('TComponentPalette.ComponentBtnDblClick ',dbgsName(Sender),' ',dbgs(X),',',dbgs(Y)); - CompIntf:=FormEditingHook.CreateComponent(ParentCI,TypeClass,X,Y,0,0); + CompIntf:=FormEditingHook.CreateComponent(ParentCI,TypeClass,'',X,Y,0,0); if CompIntf<>nil then begin GlobalDesignHook.PersistentAdded(CompIntf.Component,true); end; diff --git a/ide/customformeditor.pp b/ide/customformeditor.pp index 33b0d4b970..8620a8bd5b 100644 --- a/ide/customformeditor.pp +++ b/ide/customformeditor.pp @@ -198,9 +198,10 @@ each control that's dropped onto the form Function GetDefaultComponentPosition(TypeClass: TComponentClass; ParentCI: TIComponentInterface; var X,Y: integer): boolean; override; - Function CreateComponent(ParentCI : TIComponentInterface; + function CreateComponent(ParentCI: TIComponentInterface; TypeClass: TComponentClass; - X,Y,W,H : Integer): TIComponentInterface; override; + const AUnitName: shortstring; + X,Y,W,H: Integer): TIComponentInterface; override; Function CreateComponentFromStream(BinStream: TStream; AncestorType: TComponentClass; const NewUnitName: ShortString; @@ -210,7 +211,7 @@ each control that's dropped onto the form ParentControl: TWinControl): TIComponentInterface; override; Procedure SetComponentNameAndClass(CI: TIComponentInterface; const NewName, NewClassName: shortstring); - + // define properties procedure FindDefineProperty(const APersistentClassName, AncestorClassName, Identifier: string; @@ -1210,7 +1211,8 @@ begin end; Function TCustomFormEditor.CreateComponent(ParentCI: TIComponentInterface; - TypeClass: TComponentClass; X,Y,W,H: Integer): TIComponentInterface; + TypeClass: TComponentClass; const AUnitName: shortstring; X,Y,W,H: Integer + ): TIComponentInterface; Var Temp: TComponentInterface; NewJITIndex: Integer; @@ -1223,6 +1225,7 @@ Var AParent: TWinControl; NewComponentName: String; DesignForm: TCustomForm; + NewUnitName: String; Begin Result:=nil; Temp:=nil; @@ -1281,10 +1284,14 @@ Begin end else begin // create a toplevel component // -> a form or a datamodule or a custom component + if AUnitName='' then + NewUnitName:=DefaultJITUnitName + else + NewUnitName:=AUnitName; JITList:=GetJITListOfType(TypeClass); if JITList=nil then RaiseException('TCustomFormEditor.CreateComponent '+TypeClass.ClassName); - NewJITIndex := JITList.AddNewJITComponent(DefaultJITUnitName,TypeClass); + NewJITIndex := JITList.AddNewJITComponent(NewUnitName,TypeClass); if NewJITIndex >= 0 then // create component interface Temp := TComponentInterface.Create(JITList[NewJITIndex]) diff --git a/ide/main.pp b/ide/main.pp index 8e9473a6f5..25495d5518 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -3770,7 +3770,7 @@ begin // create jit component CInterface := TComponentInterface( FormEditor1.CreateComponent(nil,TComponentClass(AncestorType), - new_x, new_y, 400,300)); + NewUnitInfo.CreateUnitName, new_x, new_y, 400,300)); FormEditor1.SetComponentNameAndClass(CInterface, NewUnitInfo.ComponentName,'T'+NewUnitInfo.ComponentName); NewComponent:=CInterface.Component; diff --git a/ideintf/formeditingintf.pas b/ideintf/formeditingintf.pas index f5c98654da..437f115fdc 100644 --- a/ideintf/formeditingintf.pas +++ b/ideintf/formeditingintf.pas @@ -102,6 +102,7 @@ type var X,Y: integer): boolean; virtual; abstract; function CreateComponent(ParentCI: TIComponentInterface; TypeClass: TComponentClass; + const AUnitName: shortstring; X,Y,W,H: Integer): TIComponentInterface; virtual; abstract; function CreateComponentFromStream(BinStream: TStream; AncestorType: TComponentClass;