MG: implemented indirect deletion of designed components

git-svn-id: trunk@3541 -
This commit is contained in:
lazarus 2002-10-23 14:12:04 +00:00
parent 9464792e01
commit d5ed4b368b
2 changed files with 22 additions and 15 deletions

View File

@ -2041,7 +2041,7 @@ begin
and (FPropertyEditorHook.LookupRoot<>nil) then begin and (FPropertyEditorHook.LookupRoot<>nil) then begin
Root:=FPropertyEditorHook.LookupRoot; Root:=FPropertyEditorHook.LookupRoot;
AddComponentToAvailComboBox(Root); AddComponentToAvailComboBox(Root);
//writeln('[TObjectInspector.FillComponentComboBox] B ',Root.Name,' ',Root.ComponentCount); writeln('[TObjectInspector.FillComponentComboBox] B ',Root.Name,' ',Root.ComponentCount);
for a:=0 to Root.ComponentCount-1 do for a:=0 to Root.ComponentCount-1 do
AddComponentToAvailComboBox(Root.Components[a]); AddComponentToAvailComboBox(Root.Components[a]);
end; end;

View File

@ -131,7 +131,7 @@ TCustomFormEditor
destructor Destroy; override; destructor Destroy; override;
Function AddSelected(Value : TComponent) : Integer; Function AddSelected(Value : TComponent) : Integer;
Procedure DeleteControl(Value : TComponent); Procedure DeleteControl(Value : TComponent; FreeComponent: boolean);
Function FormModified : Boolean; override; Function FormModified : Boolean; override;
Function FindComponentByName(const Name : ShortString) : TIComponentInterface; override; Function FindComponentByName(const Name : ShortString) : TIComponentInterface; override;
Function FindComponent(AComponent: TComponent): TIComponentInterface; override; Function FindComponent(AComponent: TComponent): TIComponentInterface; override;
@ -649,7 +649,8 @@ Begin
Obj_Inspector.Selections := FSelectedComponents; Obj_Inspector.Selections := FSelectedComponents;
end; end;
Procedure TCustomFormEditor.DeleteControl(Value : TComponent); Procedure TCustomFormEditor.DeleteControl(Value : TComponent;
FreeComponent: boolean);
var var
Temp : TComponentInterface; Temp : TComponentInterface;
i: integer; i: integer;
@ -660,21 +661,27 @@ Begin
begin begin
RemoveFromComponentInterfaceList(Temp); RemoveFromComponentInterfaceList(Temp);
if (Value is TCustomForm) then begin if (Value is TCustomForm) then begin
AForm:=TCustomForm(Value); if FreeComponent then begin
i:=AForm.ComponentCount-1; AForm:=TCustomForm(Value);
while i>=0 do begin i:=AForm.ComponentCount-1;
DeleteControl(AForm.Components[i]); while i>=0 do begin
dec(i); DeleteControl(AForm.Components[i],true);
if i>AForm.ComponentCount-1 then dec(i);
i:=AForm.ComponentCount-1; if i>AForm.ComponentCount-1 then
i:=AForm.ComponentCount-1;
end;
if not (AForm is TForm) then
writeln('WARNING: TCustomFormEditor.DeleteControl ',AForm.ClassName);
JITFormList.DestroyJITForm(TForm(AForm));
end; end;
if not (AForm is TForm) then
writeln('WARNING: TCustomFormEditor.DeleteControl ',AForm.ClassName);
JITFormList.DestroyJITForm(TForm(AForm));
Temp.Free; Temp.Free;
end end
else else begin
Temp.Delete; if FreeComponent then
Temp.Delete
else
Temp.Free;
end;
end; end;
end; end;