From b6cf29d75504fb5d5a7aa7741739ca9d84b3f77e Mon Sep 17 00:00:00 2001 From: mattias Date: Sat, 12 Sep 2009 15:04:52 +0000 Subject: [PATCH] IDEIntf: designer mediator: fixed GetComponentOriginOnForm git-svn-id: trunk@21667 - --- designer/designer.pp | 3 ++- examples/designnonlcl/project/unit1.lfm | 4 ++-- examples/designnonlcl/project/unit1.lrs | 4 ++-- ideintf/formeditingintf.pas | 11 +++++++++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/designer/designer.pp b/designer/designer.pp index dea8d42b1d..5488857ed9 100644 --- a/designer/designer.pp +++ b/designer/designer.pp @@ -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)); diff --git a/examples/designnonlcl/project/unit1.lfm b/examples/designnonlcl/project/unit1.lfm index 4f186752a2..d90dc26cb0 100644 --- a/examples/designnonlcl/project/unit1.lfm +++ b/examples/designnonlcl/project/unit1.lfm @@ -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 diff --git a/examples/designnonlcl/project/unit1.lrs b/examples/designnonlcl/project/unit1.lrs index 6b8f098e67..6c4a9365d8 100644 --- a/examples/designnonlcl/project/unit1.lrs +++ b/examples/designnonlcl/project/unit1.lrs @@ -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 ]); diff --git a/ideintf/formeditingintf.pas b/ideintf/formeditingintf.pas index 0014b0063d..02e248512f 100644 --- a/ideintf/formeditingintf.pas +++ b/ideintf/formeditingintf.pas @@ -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;