View Issue Details

IDProjectCategoryView StatusLast Update
0037507pas2jsrtlpublic2020-08-08 19:02
ReporterSven Barth Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionfixed 
Product Versiontrunk 
Fixed in Versiontrunk 
Summary0037507: TComponent does not stream Left and Top properties
DescriptionIn FPC/Delphi TComponent handles Left and Top properties as "virtual" properties that are kept inside the DesignInfo property. This is required to stream descendants of TComponent that are not descendants of TControl (for example TTimer, another example would be the DB related components) as the Left and Top properties are only relevant for the designer.
Additional InformationAttached is a patch that implements the streaming of Left and Top in a similar way as in FPC.
TagsNo tags attached.
Fixed in Revision815
Attached Files

Activities

Sven Barth

2020-08-07 17:34

developer  

tcomponent-lefttop.patch (2,397 bytes)   
Index: packages/rtl/classes.pas
===================================================================
--- packages/rtl/classes.pas	(revision 814)
+++ packages/rtl/classes.pas	(working copy)
@@ -555,13 +555,18 @@
     function GetComponentCount: Integer;
     function GetComponentIndex: Integer;
     procedure Insert(AComponent: TComponent);
+    procedure ReadLeft(AReader: TReader);
+    procedure ReadTop(AReader: TReader);
     procedure Remove(AComponent: TComponent);
     procedure RemoveNotification(AComponent: TComponent);
     procedure SetComponentIndex(Value: Integer);
     procedure SetReference(Enable: Boolean);
+    procedure WriteLeft(AWriter: TWriter);
+    procedure WriteTop(AWriter: TWriter);
   protected
     FComponentStyle: TComponentStyle;
     procedure ChangeName(const NewName: TComponentName);
+    procedure DefineProperties(Filer: TFiler); override;
     procedure GetChildren(Proc: TGetChildProc; Root: TComponent); virtual;
     function GetChildOwner: TComponent; virtual;
     function GetChildParent: TComponent; virtual;
@@ -4328,6 +4333,20 @@
 end;
 
 
+procedure TComponent.ReadLeft(AReader: TReader);
+
+begin
+  FDesignInfo := (FDesignInfo and $ffff0000) or (AReader.ReadInteger and $ffff);
+end;
+
+
+procedure TComponent.ReadTop(AReader: TReader);
+
+begin
+  FDesignInfo := ((AReader.ReadInteger and $ffff) shl 16) or (FDesignInfo and $ffff);
+end;
+
+
 procedure TComponent.Remove(AComponent: TComponent);
 
 begin
@@ -4386,6 +4405,22 @@
 end;
 
 
+procedure TComponent.DefineProperties(Filer: TFiler);
+
+var
+  Temp: LongInt;
+  Ancestor: TComponent;
+begin
+  Ancestor := TComponent(Filer.Ancestor);
+  if Assigned(Ancestor) then
+    Temp := Ancestor.FDesignInfo
+  else
+    Temp := 0;
+  Filer.DefineProperty('Left', @ReadLeft, @WriteLeft, (FDesignInfo and $ffff) <> (Temp and $ffff));
+  Filer.DefineProperty('Top', @ReadTop, @WriteTop, (FDesignInfo and $ffff0000) <> (Temp and $ffff0000));
+end;
+
+
 procedure TComponent.GetChildren(Proc: TGetChildProc; Root: TComponent);
 
 begin
@@ -4614,6 +4649,20 @@
 end;
 
 
+procedure TComponent.WriteLeft(AWriter: TWriter);
+
+begin
+  AWriter.WriteInteger(FDesignInfo and $ffff);
+end;
+
+
+procedure TComponent.WriteTop(AWriter: TWriter);
+
+begin
+  AWriter.WriteInteger((FDesignInfo shr 16) and $ffff);
+end;
+
+
 procedure TComponent.ValidateContainer(AComponent: TComponent);
 
 begin
tcomponent-lefttop.patch (2,397 bytes)   

Michael Van Canneyt

2020-08-08 11:21

administrator   ~0124661

Applied, thank you very much !

Sven Barth

2020-08-08 19:02

developer   ~0124674

Thank you!

Issue History

Date Modified Username Field Change
2020-08-07 17:34 Sven Barth New Issue
2020-08-07 17:34 Sven Barth File Added: tcomponent-lefttop.patch
2020-08-08 11:21 Michael Van Canneyt Assigned To => Michael Van Canneyt
2020-08-08 11:21 Michael Van Canneyt Status new => resolved
2020-08-08 11:21 Michael Van Canneyt Resolution open => fixed
2020-08-08 11:21 Michael Van Canneyt Fixed in Version => trunk
2020-08-08 11:21 Michael Van Canneyt Fixed in Revision => 815
2020-08-08 11:21 Michael Van Canneyt Note Added: 0124661
2020-08-08 19:02 Sven Barth Status resolved => closed
2020-08-08 19:02 Sven Barth Note Added: 0124674