IDE: fixed example designnonlcl

git-svn-id: trunk@56283 -
This commit is contained in:
mattias 2017-11-04 15:27:50 +00:00
parent 50a915579e
commit 5a8b53d7bf
3 changed files with 22 additions and 3 deletions

View File

@ -120,7 +120,7 @@ end;
procedure TFrameDesignerForm.Create; procedure TFrameDesignerForm.Create;
begin begin
inherited Create; inherited Create;
// workaround problem with out assumption that Width = ClientWidth, Height = ClientHeight // workaround problem with assumption that Width = ClientWidth, Height = ClientHeight
NonFormProxyDesignerForm.AutoScroll := False; NonFormProxyDesignerForm.AutoScroll := False;
end; end;

View File

@ -42,6 +42,9 @@ type
TMyWidgetMediator = class(TDesignerMediator,IMyWidgetDesigner) TMyWidgetMediator = class(TDesignerMediator,IMyWidgetDesigner)
private private
FMyForm: TMyForm; FMyForm: TMyForm;
protected
procedure Notification(AComponent: TComponent; Operation: TOperation);
override;
public public
// needed by the Lazarus form editor // needed by the Lazarus form editor
class function CreateMediator(TheOwner, aForm: TComponent): TDesignerMediator; class function CreateMediator(TheOwner, aForm: TComponent): TDesignerMediator;
@ -102,6 +105,20 @@ begin
inherited Destroy; inherited Destroy;
end; end;
procedure TMyWidgetMediator.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
if Operation=opRemove then
begin
if FMyForm=AComponent then
begin
FMyForm.Designer:=nil;
FMyForm:=nil;
end;
end;
end;
class function TMyWidgetMediator.CreateMediator(TheOwner, aForm: TComponent class function TMyWidgetMediator.CreateMediator(TheOwner, aForm: TComponent
): TDesignerMediator; ): TDesignerMediator;
var var
@ -110,6 +127,7 @@ begin
Result:=inherited CreateMediator(TheOwner,aForm); Result:=inherited CreateMediator(TheOwner,aForm);
Mediator:=TMyWidgetMediator(Result); Mediator:=TMyWidgetMediator(Result);
Mediator.FMyForm:=aForm as TMyForm; Mediator.FMyForm:=aForm as TMyForm;
Mediator.FMyForm.FreeNotification(Mediator);
Mediator.FMyForm.Designer:=Mediator; Mediator.FMyForm.Designer:=Mediator;
end; end;

View File

@ -86,7 +86,7 @@ type
function OnPropHookGetAncestorInstProp(const InstProp: TInstProp; function OnPropHookGetAncestorInstProp(const InstProp: TInstProp;
out AncestorInstProp: TInstProp): boolean; out AncestorInstProp: TInstProp): boolean;
protected protected
FNonFormForms: TAvlTree; // tree of TNonControlDesignerForm sorted for LookupRoot FNonFormForms: TAvlTree; // tree of TNonFormProxyDesignerForm sorted for LookupRoot
procedure SetSelection(const ASelection: TPersistentSelectionList); procedure SetSelection(const ASelection: TPersistentSelectionList);
procedure OnObjectInspectorModified(Sender: TObject); procedure OnObjectInspectorModified(Sender: TObject);
procedure SetObj_Inspector(AnObjectInspector: TObjectInspectorDlg); virtual; procedure SetObj_Inspector(AnObjectInspector: TObjectInspectorDlg); virtual;
@ -845,7 +845,8 @@ begin
(Result as INonFormDesigner).LookupRoot := LookupRoot; (Result as INonFormDesigner).LookupRoot := LookupRoot;
FNonFormForms.Add(Result); FNonFormForms.Add(Result);
if Result is BaseFormEditor1.NonFormProxyDesignerForm[NonControlProxyDesignerFormId] then begin if Result is BaseFormEditor1.NonFormProxyDesignerForm[NonControlProxyDesignerFormId]
then begin
// create the mediator // create the mediator
MediatorClass:=GetDesignerMediatorClass(TComponentClass(LookupRoot.ClassType)); MediatorClass:=GetDesignerMediatorClass(TComponentClass(LookupRoot.ClassType));
if MediatorClass<>nil then if MediatorClass<>nil then