IDEIntf: designer mediator: fixed GetComponentOriginOnForm

git-svn-id: trunk@21667 -
This commit is contained in:
mattias 2009-09-12 15:04:52 +00:00
parent f34aac3514
commit b6cf29d755
4 changed files with 15 additions and 7 deletions

View File

@ -1549,6 +1549,7 @@ var
NewTop:=Min(MouseDownPos.Y,MouseUpPos.Y);
if (Mediator<>nil) then begin
ParentClientOrigin:=Mediator.GetComponentOriginOnForm(NewParent);
DebugLn(['AddComponent ParentClientOrigin=',dbgs(ParentClientOrigin)]);
// adjust left,top to parent origin
dec(NewLeft,ParentClientOrigin.X);
dec(NewTop,ParentClientOrigin.Y);
@ -1581,7 +1582,7 @@ var
end;
// create component and component interface
DebugLn(['AddComponent ',DbgSName(NewComponentClass),' ',NewLeft,',',NewTop,',',NewWidth,',',NewHeight]);
DebugLn(['AddComponent ',DbgSName(NewComponentClass),' Parent=',DbgSName(NewParent),' ',NewLeft,',',NewTop,',',NewWidth,',',NewHeight]);
NewCI := TComponentInterface(TheFormEditor.CreateComponent(
ParentCI,NewComponentClass,'',
NewLeft,NewTop,NewWidth,NewHeight));

View File

@ -29,8 +29,8 @@ object MyForm1: TMyForm1
Visible = False
Caption = 'MyGroupBox1'
object MyGroupBox2: TMyGroupBox
Left = 166
Top = 92
Left = 10
Top = 10
Width = 70
Height = 53
Visible = False

View File

@ -8,6 +8,6 @@ LazarusResources.Add('TMyForm1','FORMDATA',[
+'F'#5'Width'#2'K'#6'Height'#2#25#7'Visible'#8#7'Caption'#6#9'MyButton2'#0#0
+#11'TMyGroupBox'#11'MyGroupBox1'#4'Left'#3#144#0#3'Top'#2'A'#5'Width'#2'i'#6
+'Height'#2'K'#7'Visible'#8#7'Caption'#6#11'MyGroupBox1'#0#11'TMyGroupBox'#11
+'MyGroupBox2'#4'Left'#3#166#0#3'Top'#2'\'#5'Width'#2'F'#6'Height'#2'5'#7'Vis'
+'ible'#8#7'Caption'#6#11'MyGroupBox2'#0#0#0#0
+'MyGroupBox2'#4'Left'#2#10#3'Top'#2#10#5'Width'#2'F'#6'Height'#2'5'#7'Visibl'
+'e'#8#7'Caption'#6#11'MyGroupBox2'#0#0#0#0
]);

View File

@ -415,14 +415,21 @@ var
Parent: TComponent;
ClientArea: TRect;
ScrollOffset: TPoint;
ParentBounds: TRect;
NextParent: TComponent;
begin
Result:=Point(0,0);
while AComponent<>nil do begin
Parent:=AComponent.GetParentComponent;
if Parent=nil then break;
NextParent:=Parent.GetParentComponent;
if NextParent<>nil then
GetBounds(Parent,ParentBounds)
else
ParentBounds:=Rect(0,0,0,0);
GetClientArea(Parent,ClientArea,ScrollOffset);
inc(Result.X,ClientArea.Left+ScrollOffset.X);
inc(Result.Y,ClientArea.Top+ScrollOffset.Y);
inc(Result.X,ParentBounds.Left+ClientArea.Left+ScrollOffset.X);
inc(Result.Y,ParentBounds.Top+ClientArea.Top+ScrollOffset.Y);
AComponent:=Parent;
end;
end;