|
@@ -18,32 +18,38 @@
|
|
Function TComponent.GetComponent(AIndex: Integer): TComponent;
|
|
Function TComponent.GetComponent(AIndex: Integer): TComponent;
|
|
|
|
|
|
begin
|
|
begin
|
|
- If assigned(FComponents) then
|
|
|
|
- Result:=TComponent(FComponents.Items[Aindex])
|
|
|
|
|
|
+ If not assigned(FComponents) then
|
|
|
|
+ Result:=Nil
|
|
else
|
|
else
|
|
- Result:=Nil;
|
|
|
|
|
|
+ Result:=TComponent(FComponents.Items[Aindex]);
|
|
end;
|
|
end;
|
|
|
|
|
|
function TComponent.IsImplementorOf (const Intf:IInterface):boolean;
|
|
function TComponent.IsImplementorOf (const Intf:IInterface):boolean;
|
|
var ref : IInterfaceComponentReference;
|
|
var ref : IInterfaceComponentReference;
|
|
begin
|
|
begin
|
|
- result:=assigned(intf) and supports(intf,IInterfaceComponentReference,ref) and (ref.getcomponent=self);
|
|
|
|
|
|
+ result:=assigned(intf) and supports(intf,IInterfaceComponentReference,ref);
|
|
|
|
+ if result then
|
|
|
|
+ result:=ref.getcomponent=self;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TComponent.ReferenceInterface(const intf:IInterface;op:TOperation);
|
|
procedure TComponent.ReferenceInterface(const intf:IInterface;op:TOperation);
|
|
var ref : IInterfaceComponentReference;
|
|
var ref : IInterfaceComponentReference;
|
|
|
|
+ comp : TComponent;
|
|
begin
|
|
begin
|
|
if assigned(intf) and supports(intf,IInterfaceComponentReference,ref) then
|
|
if assigned(intf) and supports(intf,IInterfaceComponentReference,ref) then
|
|
- ref.getcomponent.notification(self,op);
|
|
|
|
|
|
+ begin
|
|
|
|
+ comp:=ref.getcomponent;
|
|
|
|
+ comp.notification(self,op);
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
|
|
|
|
Function TComponent.GetComponentCount: Integer;
|
|
Function TComponent.GetComponentCount: Integer;
|
|
|
|
|
|
begin
|
|
begin
|
|
- If assigned(FComponents) then
|
|
|
|
- Result:=FComponents.Count
|
|
|
|
- else
|
|
|
|
|
|
+ If not assigned(FComponents) then
|
|
result:=0
|
|
result:=0
|
|
|
|
+ else
|
|
|
|
+ Result:=FComponents.Count;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -51,7 +57,7 @@ Function TComponent.GetComponentIndex: Integer;
|
|
|
|
|
|
begin
|
|
begin
|
|
If Assigned(FOwner) and Assigned(FOwner.FComponents) then
|
|
If Assigned(FOwner) and Assigned(FOwner.FComponents) then
|
|
- Result:=FOwner.FComponents.IndexOf(Self)
|
|
|
|
|
|
+ Result:=FOWner.FComponents.IndexOf(Self)
|
|
else
|
|
else
|
|
Result:=-1;
|
|
Result:=-1;
|
|
end;
|
|
end;
|
|
@@ -85,7 +91,7 @@ Procedure TComponent.Remove(AComponent: TComponent);
|
|
|
|
|
|
begin
|
|
begin
|
|
AComponent.FOwner:=Nil;
|
|
AComponent.FOwner:=Nil;
|
|
- If assigned(FComponents) then
|
|
|
|
|
|
+ If assigned(FCOmponents) then
|
|
begin
|
|
begin
|
|
FComponents.Remove(AComponent);
|
|
FComponents.Remove(AComponent);
|
|
IF FComponents.Count=0 then
|
|
IF FComponents.Count=0 then
|
|
@@ -107,7 +113,7 @@ begin
|
|
begin
|
|
begin
|
|
FFreeNotifies.Free;
|
|
FFreeNotifies.Free;
|
|
FFreeNotifies:=nil;
|
|
FFreeNotifies:=nil;
|
|
- Exclude(FComponentState, csFreeNotification);
|
|
|
|
|
|
+ Exclude(FComponentState,csFreeNotification);
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
@@ -118,7 +124,7 @@ Procedure TComponent.SetComponentIndex(Value: Integer);
|
|
Var Temp,Count : longint;
|
|
Var Temp,Count : longint;
|
|
|
|
|
|
begin
|
|
begin
|
|
- If Not assigned(FOwner) then exit;
|
|
|
|
|
|
+ If Not assigned(Fowner) then exit;
|
|
Temp:=getcomponentindex;
|
|
Temp:=getcomponentindex;
|
|
If temp<0 then exit;
|
|
If temp<0 then exit;
|
|
If value<0 then value:=0;
|
|
If value<0 then value:=0;
|
|
@@ -224,13 +230,13 @@ end;
|
|
Procedure TComponent.Loaded;
|
|
Procedure TComponent.Loaded;
|
|
|
|
|
|
begin
|
|
begin
|
|
- Exclude(FComponentState, csLoading);
|
|
|
|
|
|
+ Exclude(FComponentState,csLoading);
|
|
end;
|
|
end;
|
|
|
|
|
|
Procedure TComponent.Loading;
|
|
Procedure TComponent.Loading;
|
|
|
|
|
|
begin
|
|
begin
|
|
- Include(FComponentState, csLoading);
|
|
|
|
|
|
+ Include(FComponentState,csLoading);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -243,11 +249,10 @@ begin
|
|
If (Operation=opRemove) and Assigned(FFreeNotifies) then
|
|
If (Operation=opRemove) and Assigned(FFreeNotifies) then
|
|
begin
|
|
begin
|
|
FFreeNotifies.Remove(AComponent);
|
|
FFreeNotifies.Remove(AComponent);
|
|
- If FFreeNotifies.Count=0 then
|
|
|
|
|
|
+ If FFreeNotifies.Count=0 then
|
|
begin
|
|
begin
|
|
FFreeNotifies.Free;
|
|
FFreeNotifies.Free;
|
|
FFreenotifies:=Nil;
|
|
FFreenotifies:=Nil;
|
|
- Exclude(FComponentState, csFreeNotification);
|
|
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
If assigned(FComponents) then
|
|
If assigned(FComponents) then
|
|
@@ -274,9 +279,9 @@ Var Runner : Longint;
|
|
|
|
|
|
begin
|
|
begin
|
|
If Value then
|
|
If Value then
|
|
- Include(FComponentState, csAncestor)
|
|
|
|
|
|
+ Include(FComponentState,csAncestor)
|
|
else
|
|
else
|
|
- Exclude(FComponentState, csAncestor);
|
|
|
|
|
|
+ Exclude(FCOmponentState,csAncestor);
|
|
if Assigned(FComponents) then
|
|
if Assigned(FComponents) then
|
|
For Runner:=0 To FComponents.Count-1 do
|
|
For Runner:=0 To FComponents.Count-1 do
|
|
TComponent(FComponents.Items[Runner]).SetAncestor(Value);
|
|
TComponent(FComponents.Items[Runner]).SetAncestor(Value);
|
|
@@ -289,9 +294,9 @@ Var Runner : Longint;
|
|
|
|
|
|
begin
|
|
begin
|
|
If Value then
|
|
If Value then
|
|
- Include(FComponentState, csDesigning)
|
|
|
|
|
|
+ Include(FComponentState,csDesigning)
|
|
else
|
|
else
|
|
- Exclude(FComponentState, csDesigning);
|
|
|
|
|
|
+ Exclude(FComponentState,csDesigning);
|
|
if Assigned(FComponents) and SetChildren then
|
|
if Assigned(FComponents) and SetChildren then
|
|
For Runner:=0 To FComponents.Count - 1 do
|
|
For Runner:=0 To FComponents.Count - 1 do
|
|
TComponent(FComponents.items[Runner]).SetDesigning(Value);
|
|
TComponent(FComponents.items[Runner]).SetDesigning(Value);
|
|
@@ -301,18 +306,18 @@ Procedure TComponent.SetDesignInstance(Value: Boolean);
|
|
|
|
|
|
begin
|
|
begin
|
|
If Value then
|
|
If Value then
|
|
- Include(FComponentState, csDesignInstance)
|
|
|
|
|
|
+ Include(FComponentState,csDesignInstance)
|
|
else
|
|
else
|
|
- Exclude(FComponentState, csDesignInstance);
|
|
|
|
|
|
+ Exclude(FComponentState,csDesignInstance);
|
|
end;
|
|
end;
|
|
|
|
|
|
Procedure TComponent.SetInline(Value: Boolean);
|
|
Procedure TComponent.SetInline(Value: Boolean);
|
|
|
|
|
|
begin
|
|
begin
|
|
If Value then
|
|
If Value then
|
|
- Include(FComponentState, csInline)
|
|
|
|
|
|
+ Include(FComponentState,csInline)
|
|
else
|
|
else
|
|
- Exclude(FComponentState, csInline);
|
|
|
|
|
|
+ Exclude(FComponentState,csInline);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -349,14 +354,14 @@ end;
|
|
Procedure TComponent.Updating;
|
|
Procedure TComponent.Updating;
|
|
|
|
|
|
begin
|
|
begin
|
|
- Include(FComponentState, csUpdating);
|
|
|
|
|
|
+ Include (FComponentState,csUpdating);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
Procedure TComponent.Updated;
|
|
Procedure TComponent.Updated;
|
|
|
|
|
|
begin
|
|
begin
|
|
- Exclude(FComponentState, csUpdating);
|
|
|
|
|
|
+ Exclude(FComponentState,csUpdating);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -409,27 +414,30 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
-Procedure TComponent.BeforeDestruction;
|
|
|
|
-
|
|
|
|
-begin
|
|
|
|
- Destroying;
|
|
|
|
- inherited BeforeDestruction;
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
Destructor TComponent.Destroy;
|
|
Destructor TComponent.Destroy;
|
|
|
|
|
|
Var
|
|
Var
|
|
I : Integer;
|
|
I : Integer;
|
|
- L : TList;
|
|
|
|
|
|
+ C : TComponent;
|
|
|
|
+
|
|
begin
|
|
begin
|
|
|
|
+ Destroying;
|
|
If Assigned(FFreeNotifies) then
|
|
If Assigned(FFreeNotifies) then
|
|
begin
|
|
begin
|
|
- L := FFreeNotifies;
|
|
|
|
- FFreenotifies:=Nil;
|
|
|
|
- for I := L.Count - 1 downto 0 do
|
|
|
|
- TComponent(L.Items[I]).Notification(self,opRemove);
|
|
|
|
- L.Free;
|
|
|
|
|
|
+ I:=FFreeNotifies.Count-1;
|
|
|
|
+ While (I>=0) do
|
|
|
|
+ begin
|
|
|
|
+ C:=TComponent(FFreeNotifies.Items[I]);
|
|
|
|
+ // Delete, so one component is not notified twice, if it is owned.
|
|
|
|
+ FFreeNotifies.Delete(I);
|
|
|
|
+ C.Notification (self,opRemove);
|
|
|
|
+ If (FFreeNotifies=Nil) then
|
|
|
|
+ I:=0
|
|
|
|
+ else if (I>FFreeNotifies.Count) then
|
|
|
|
+ I:=FFreeNotifies.Count;
|
|
|
|
+ dec(i);
|
|
|
|
+ end;
|
|
|
|
+ FreeAndNil(FFreeNotifies);
|
|
end;
|
|
end;
|
|
DestroyComponents;
|
|
DestroyComponents;
|
|
If FOwner<>Nil Then FOwner.RemoveComponent(Self);
|
|
If FOwner<>Nil Then FOwner.RemoveComponent(Self);
|
|
@@ -437,6 +445,13 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
+Procedure TComponent.BeforeDestruction;
|
|
|
|
+begin
|
|
|
|
+ if not(csDestroying in FComponentstate) then
|
|
|
|
+ Destroying;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+
|
|
Procedure TComponent.DestroyComponents;
|
|
Procedure TComponent.DestroyComponents;
|
|
|
|
|
|
Var acomponent: TComponent;
|
|
Var acomponent: TComponent;
|
|
@@ -457,7 +472,7 @@ Var Runner : longint;
|
|
|
|
|
|
begin
|
|
begin
|
|
If csDestroying in FComponentstate Then Exit;
|
|
If csDestroying in FComponentstate Then Exit;
|
|
- Include(FComponentState, csDestroying);
|
|
|
|
|
|
+ include (FComponentState,csDestroying);
|
|
If Assigned(FComponents) then
|
|
If Assigned(FComponents) then
|
|
for Runner:=0 to FComponents.Count-1 do
|
|
for Runner:=0 to FComponents.Count-1 do
|
|
TComponent(FComponents.Items[Runner]).Destroying;
|
|
TComponent(FComponents.Items[Runner]).Destroying;
|
|
@@ -500,11 +515,8 @@ begin
|
|
AComponent.Notification(Self,opRemove)
|
|
AComponent.Notification(Self,opRemove)
|
|
else
|
|
else
|
|
begin
|
|
begin
|
|
- If not Assigned(FFreeNotifies) then
|
|
|
|
- begin
|
|
|
|
- FFreeNotifies:=TList.Create;
|
|
|
|
- Include(FComponentState, csFreeNotification);
|
|
|
|
- end;
|
|
|
|
|
|
+ If not (Assigned(FFreeNotifies)) then
|
|
|
|
+ FFreeNotifies:=TList.Create;
|
|
If FFreeNotifies.IndexOf(AComponent)=-1 then
|
|
If FFreeNotifies.IndexOf(AComponent)=-1 then
|
|
begin
|
|
begin
|
|
FFreeNotifies.Add(AComponent);
|
|
FFreeNotifies.Add(AComponent);
|