diff --git a/designer/designer.pp b/designer/designer.pp index bb80bb0035..b228f72e7f 100644 --- a/designer/designer.pp +++ b/designer/designer.pp @@ -2507,7 +2507,9 @@ end; procedure TDesigner.SetMediator(const AValue: TDesignerMediator); begin if FMediator=AValue then exit; + if FMediator<>nil then FMediator.Designer:=nil; FMediator:=AValue; + if FMediator<>nil then FMediator.Designer:=Self; end; procedure TDesigner.SetShowEditorHints(const AValue: boolean); diff --git a/designer/noncontroldesigner.pas b/designer/noncontroldesigner.pas index d13ae23186..b1507f6f8d 100644 --- a/designer/noncontroldesigner.pas +++ b/designer/noncontroldesigner.pas @@ -43,6 +43,7 @@ type private FFrameWidth: integer; FMediator: TDesignerMediator; + procedure SetMediator(const AValue: TDesignerMediator); protected procedure SetFrameWidth(const AValue: integer); virtual; public @@ -53,7 +54,7 @@ type procedure DoSaveBounds; override; public property FrameWidth: integer read FFrameWidth write SetFrameWidth; - property Mediator: TDesignerMediator read FMediator write FMediator; + property Mediator: TDesignerMediator read FMediator write SetMediator; end; @@ -62,6 +63,14 @@ implementation { TNonControlDesignerForm } +procedure TNonControlDesignerForm.SetMediator(const AValue: TDesignerMediator); +begin + if FMediator=AValue then exit; + if FMediator<>nil then FMediator.LCLForm:=nil; + FMediator:=AValue; + if FMediator<>nil then FMediator.LCLForm:=Self; +end; + procedure TNonControlDesignerForm.SetFrameWidth(const AValue: integer); begin if FFrameWidth = AValue then diff --git a/ideintf/formeditingintf.pas b/ideintf/formeditingintf.pas index e809f2abf0..bb9cd4e70b 100644 --- a/ideintf/formeditingintf.pas +++ b/ideintf/formeditingintf.pas @@ -90,10 +90,21 @@ type which will emulate the painting, handle the mouse and editing bounds. } TDesignerMediator = class(TComponent) + private + FDesigner: TComponentEditorDesigner; + FLCLForm: TForm; + protected + procedure SetDesigner(const AValue: TComponentEditorDesigner); + procedure SetLCLForm(const AValue: TForm); virtual; public class function FormClass: TComponentClass; virtual; abstract; class function CreateMediator(TheOwner, aForm: TComponent): TDesignerMediator; virtual; abstract; class procedure InitFormInstance(aForm: TComponent); virtual; // called after NewInstance, before constructor + public + procedure SetBounds(AComponent: TComponent; NewBounds: TRect); virtual; abstract; + procedure GetBounds(AComponent: TComponent; out CurBounds: TRect); virtual; abstract; + property LCLForm: TForm read FLCLForm write SetLCLForm; + property Designer: TComponentEditorDesigner read FDesigner write SetDesigner; end; TDesignerMediatorClass = class of TDesignerMediator; @@ -182,6 +193,19 @@ implementation { TDesignerMediator } +procedure TDesignerMediator.SetDesigner(const AValue: TComponentEditorDesigner + ); +begin + if FDesigner=AValue then exit; + FDesigner:=AValue; +end; + +procedure TDesignerMediator.SetLCLForm(const AValue: TForm); +begin + if FLCLForm=AValue then exit; + FLCLForm:=AValue; +end; + class procedure TDesignerMediator.InitFormInstance(aForm: TComponent); begin