mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-07-05 20:45:55 +02:00
IDE: using mediator to set and load bounds when creating new component
git-svn-id: trunk@22635 -
This commit is contained in:
parent
415c71e3ac
commit
eceb0f4670
@ -77,6 +77,7 @@ begin
|
|||||||
if FMediator<>nil then begin
|
if FMediator<>nil then begin
|
||||||
FMediator.LCLForm:=Self;
|
FMediator.LCLForm:=Self;
|
||||||
FMediator.FreeNotification(Self);
|
FMediator.FreeNotification(Self);
|
||||||
|
DoLoadBounds;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -98,6 +98,8 @@ end;
|
|||||||
|
|
||||||
destructor TMyWidgetMediator.Destroy;
|
destructor TMyWidgetMediator.Destroy;
|
||||||
begin
|
begin
|
||||||
|
if FMyForm<>nil then FMyForm.Designer:=nil;
|
||||||
|
FMyForm:=nil;
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -1597,8 +1597,10 @@ var
|
|||||||
DesignForm: TCustomForm;
|
DesignForm: TCustomForm;
|
||||||
NewUnitName: String;
|
NewUnitName: String;
|
||||||
s: String;
|
s: String;
|
||||||
Mediator: TDesignerMediator;
|
|
||||||
MonitorBounds: TRect;
|
MonitorBounds: TRect;
|
||||||
|
Mediator: TDesignerMediator;
|
||||||
|
FreeMediator: Boolean;
|
||||||
|
MediatorClass: TDesignerMediatorClass;
|
||||||
|
|
||||||
function ActiveMonitor: TMonitor;
|
function ActiveMonitor: TMonitor;
|
||||||
begin
|
begin
|
||||||
@ -1618,6 +1620,7 @@ begin
|
|||||||
AParent:=nil;
|
AParent:=nil;
|
||||||
NewComponent:=nil;
|
NewComponent:=nil;
|
||||||
Mediator:=nil;
|
Mediator:=nil;
|
||||||
|
FreeMediator:=false;
|
||||||
try
|
try
|
||||||
//DebugLn(['[TCustomFormEditor.CreateComponent] Class="'+TypeClass.ClassName+'" ',X,',',Y,',',W,'x',H]);
|
//DebugLn(['[TCustomFormEditor.CreateComponent] Class="'+TypeClass.ClassName+'" ',X,',',Y,',',W,'x',H]);
|
||||||
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TCustomFormEditor.CreateComponent A');{$ENDIF}
|
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TCustomFormEditor.CreateComponent A');{$ENDIF}
|
||||||
@ -1796,6 +1799,14 @@ begin
|
|||||||
DesignForm := GetDesignerForm(ParentComponent);
|
DesignForm := GetDesignerForm(ParentComponent);
|
||||||
if DesignForm <> nil then DesignForm.Invalidate;
|
if DesignForm <> nil then DesignForm.Invalidate;
|
||||||
end;
|
end;
|
||||||
|
if Mediator=nil then begin
|
||||||
|
MediatorClass:=GetDesignerMediatorClass(TComponentClass(NewComponent.ClassType));
|
||||||
|
if MediatorClass<>nil then begin
|
||||||
|
Mediator:=MediatorClass.CreateMediator(nil,NewComponent);
|
||||||
|
FreeMediator:=Mediator<>nil;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
//DebugLn(['TCustomFormEditor.CreateComponent ',DbgSName(NewComponent),' ',dbgs(Bounds(CompLeft,CompTop,CompWidth,CompHeight)),' ',Mediator<>nil]);
|
||||||
if Mediator<>nil then begin
|
if Mediator<>nil then begin
|
||||||
Mediator.InitComponent(NewComponent,ParentComponent,
|
Mediator.InitComponent(NewComponent,ParentComponent,
|
||||||
Bounds(CompLeft,CompTop,CompWidth,CompHeight));
|
Bounds(CompLeft,CompTop,CompWidth,CompHeight));
|
||||||
@ -1826,6 +1837,20 @@ begin
|
|||||||
Result := Temp;
|
Result := Temp;
|
||||||
finally
|
finally
|
||||||
// clean up carefully
|
// clean up carefully
|
||||||
|
if FreeMediator and (Mediator<>nil) then begin
|
||||||
|
try
|
||||||
|
FreeAndNil(Mediator);
|
||||||
|
except
|
||||||
|
on E: Exception do begin
|
||||||
|
s:='Error destroying mediator '+Mediator.ClassName
|
||||||
|
+' of unit '+AUnitName+':'#13
|
||||||
|
+E.Message;
|
||||||
|
DebugLn(['TCustomFormEditor.CreateComponent ',s]);
|
||||||
|
DumpExceptionBackTrace;
|
||||||
|
MessageDlg('Error destroying mediator',s,mtError,[mbCancel],0);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
if Result=nil then begin
|
if Result=nil then begin
|
||||||
if Temp=nil then begin
|
if Temp=nil then begin
|
||||||
if NewComponent<>nil then begin
|
if NewComponent<>nil then begin
|
||||||
|
Loading…
Reference in New Issue
Block a user