IDEIntf: designer mediator: LCLForm and Designer

git-svn-id: trunk@21624 -
This commit is contained in:
mattias 2009-09-08 15:26:39 +00:00
parent dca985f3e8
commit 4e4340b68b
3 changed files with 36 additions and 1 deletions

View File

@ -2507,7 +2507,9 @@ end;
procedure TDesigner.SetMediator(const AValue: TDesignerMediator); procedure TDesigner.SetMediator(const AValue: TDesignerMediator);
begin begin
if FMediator=AValue then exit; if FMediator=AValue then exit;
if FMediator<>nil then FMediator.Designer:=nil;
FMediator:=AValue; FMediator:=AValue;
if FMediator<>nil then FMediator.Designer:=Self;
end; end;
procedure TDesigner.SetShowEditorHints(const AValue: boolean); procedure TDesigner.SetShowEditorHints(const AValue: boolean);

View File

@ -43,6 +43,7 @@ type
private private
FFrameWidth: integer; FFrameWidth: integer;
FMediator: TDesignerMediator; FMediator: TDesignerMediator;
procedure SetMediator(const AValue: TDesignerMediator);
protected protected
procedure SetFrameWidth(const AValue: integer); virtual; procedure SetFrameWidth(const AValue: integer); virtual;
public public
@ -53,7 +54,7 @@ type
procedure DoSaveBounds; override; procedure DoSaveBounds; override;
public public
property FrameWidth: integer read FFrameWidth write SetFrameWidth; property FrameWidth: integer read FFrameWidth write SetFrameWidth;
property Mediator: TDesignerMediator read FMediator write FMediator; property Mediator: TDesignerMediator read FMediator write SetMediator;
end; end;
@ -62,6 +63,14 @@ implementation
{ TNonControlDesignerForm } { 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); procedure TNonControlDesignerForm.SetFrameWidth(const AValue: integer);
begin begin
if FFrameWidth = AValue then if FFrameWidth = AValue then

View File

@ -90,10 +90,21 @@ type
which will emulate the painting, handle the mouse and editing bounds. } which will emulate the painting, handle the mouse and editing bounds. }
TDesignerMediator = class(TComponent) TDesignerMediator = class(TComponent)
private
FDesigner: TComponentEditorDesigner;
FLCLForm: TForm;
protected
procedure SetDesigner(const AValue: TComponentEditorDesigner);
procedure SetLCLForm(const AValue: TForm); virtual;
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 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; end;
TDesignerMediatorClass = class of TDesignerMediator; TDesignerMediatorClass = class of TDesignerMediator;
@ -182,6 +193,19 @@ implementation
{ TDesignerMediator } { 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); class procedure TDesignerMediator.InitFormInstance(aForm: TComponent);
begin begin