IDE: designer mediator: added InitFormInstance method

git-svn-id: trunk@21621 -
This commit is contained in:
mattias 2009-09-08 11:55:37 +00:00
parent 9e1dbe78ab
commit 463fff0bb4
3 changed files with 28 additions and 1 deletions

View File

@ -61,6 +61,7 @@ type
TJITReaderErrorEvent = procedure(Sender: TObject; Reader: TReader; TJITReaderErrorEvent = procedure(Sender: TObject; Reader: TReader;
ErrorType: TJITFormError; ErrorType: TJITFormError;
var Action: TModalResult) of object; var Action: TModalResult) of object;
TJITBeforeCreateEvent = procedure(Sender: TObject; Instance: TPersistent) of object;
TJITExceptionEvent = procedure(Sender: TObject; E: Exception; TJITExceptionEvent = procedure(Sender: TObject; E: Exception;
var Action: TModalResult) of object; var Action: TModalResult) of object;
TJITPropertyNotFoundEvent = procedure(Sender: TObject; Reader: TReader; TJITPropertyNotFoundEvent = procedure(Sender: TObject; Reader: TReader;
@ -88,6 +89,7 @@ type
FCurUnknownClass: string; FCurUnknownClass: string;
FCurUnknownProperty: string; FCurUnknownProperty: string;
FErrors: TLRPositionLinks; FErrors: TLRPositionLinks;
FOnBeforeCreate: TJITBeforeCreateEvent;
FOnException: TJITExceptionEvent; FOnException: TJITExceptionEvent;
FOnFindAncestors: TJITFindAncestors; FOnFindAncestors: TJITFindAncestors;
FOnFindClass: TJITFindClass; FOnFindClass: TJITFindClass;
@ -189,6 +191,7 @@ type
property OnPropertyNotFound: TJITPropertyNotFoundEvent property OnPropertyNotFound: TJITPropertyNotFoundEvent
read FOnPropertyNotFound write FOnPropertyNotFound; read FOnPropertyNotFound write FOnPropertyNotFound;
property OnException: TJITExceptionEvent read FOnException write FOnException; property OnException: TJITExceptionEvent read FOnException write FOnException;
property OnBeforeCreate: TJITBeforeCreateEvent read FOnBeforeCreate write FOnBeforeCreate;
property OnFindAncestors: TJITFindAncestors read FOnFindAncestors property OnFindAncestors: TJITFindAncestors read FOnFindAncestors
write FOnFindAncestors; write FOnFindAncestors;
property OnFindClass: TJITFindClass read FOnFindClass write FOnFindClass; property OnFindClass: TJITFindClass read FOnFindClass write FOnFindClass;
@ -1012,6 +1015,9 @@ begin
if (not Visible) and (Instance is TControl) then if (not Visible) and (Instance is TControl) then
TControl(Instance).ControlStyle:= TControl(Instance).ControlStyle:=
TControl(Instance).ControlStyle+[csNoDesignVisible]; TControl(Instance).ControlStyle+[csNoDesignVisible];
// event
if Assigned(OnBeforeCreate) then
OnBeforeCreate(Self,Instance);
// finish 'create' component // finish 'create' component
Instance.Create(nil); Instance.Create(nil);
if NewComponentName<>'' then begin if NewComponentName<>'' then begin

View File

@ -137,6 +137,7 @@ each control that's dropped onto the form
procedure SetObj_Inspector(AnObjectInspector: TObjectInspectorDlg); virtual; procedure SetObj_Inspector(AnObjectInspector: TObjectInspectorDlg); virtual;
procedure JITListReaderError(Sender: TObject; Reader: TReader; procedure JITListReaderError(Sender: TObject; Reader: TReader;
ErrorType: TJITFormError; var Action: TModalResult); virtual; ErrorType: TJITFormError; var Action: TModalResult); virtual;
procedure JITListBeforeCreate(Sender: TObject; Instance: TPersistent);
procedure JITListException(Sender: TObject; E: Exception; procedure JITListException(Sender: TObject; E: Exception;
var Action: TModalResult); var Action: TModalResult);
procedure JITListPropertyNotFound(Sender: TObject; Reader: TReader; procedure JITListPropertyNotFound(Sender: TObject; Reader: TReader;
@ -858,6 +859,7 @@ constructor TCustomFormEditor.Create;
procedure InitJITList(List: TJITComponentList); procedure InitJITList(List: TJITComponentList);
begin begin
List.OnReaderError:=@JITListReaderError; List.OnReaderError:=@JITListReaderError;
List.OnBeforeCreate:=@JITListBeforeCreate;
List.OnException:=@JITListException; List.OnException:=@JITListException;
List.OnPropertyNotFound:=@JITListPropertyNotFound; List.OnPropertyNotFound:=@JITListPropertyNotFound;
List.OnFindAncestors:=@JITListFindAncestors; List.OnFindAncestors:=@JITListFindAncestors;
@ -1248,7 +1250,6 @@ begin
if Result is TNonControlDesignerForm then begin if Result is TNonControlDesignerForm then begin
// create the mediator // create the mediator
MediatorClass:=GetDesignerMediatorClass(TComponentClass(LookupRoot.ClassType)); MediatorClass:=GetDesignerMediatorClass(TComponentClass(LookupRoot.ClassType));
debugln(['TCustomFormEditor.CreateNonFormForm AAA1 ',MediatorClass<>nil]);
if MediatorClass<>nil then if MediatorClass<>nil then
TNonControlDesignerForm(Result).Mediator:=MediatorClass.CreateMediator(nil,LookupRoot); TNonControlDesignerForm(Result).Mediator:=MediatorClass.CreateMediator(nil,LookupRoot);
end; end;
@ -2315,6 +2316,18 @@ begin
end; end;
end; end;
procedure TCustomFormEditor.JITListBeforeCreate(Sender: TObject;
Instance: TPersistent);
var
MediatorClass: TDesignerMediatorClass;
begin
if Instance is TComponent then begin
MediatorClass:=GetDesignerMediatorClass(TComponentClass(Instance.ClassType));
if MediatorClass<>nil then
MediatorClass.InitFormInstance(TComponent(Instance));
end;
end;
procedure TCustomFormEditor.JITListException(Sender: TObject; E: Exception; procedure TCustomFormEditor.JITListException(Sender: TObject; E: Exception;
var Action: TModalResult); var Action: TModalResult);
var var

View File

@ -93,6 +93,7 @@ type
public public
class function FormClass: TComponentClass; virtual; abstract; class function FormClass: TComponentClass; virtual; abstract;
class function CreateMediator(TheOwner, aForm: TComponent): TDesignerMediator; virtual; abstract; class function CreateMediator(TheOwner, aForm: TComponent): TDesignerMediator; virtual; abstract;
class procedure InitFormInstance(aForm: TComponent); virtual; // called after NewInstance, before constructor
end; end;
TDesignerMediatorClass = class of TDesignerMediator; TDesignerMediatorClass = class of TDesignerMediator;
@ -179,5 +180,12 @@ var
implementation implementation
{ TDesignerMediator }
class procedure TDesignerMediator.InitFormInstance(aForm: TComponent);
begin
end;
end. end.