IDEIntf: fixed designer mediator grand child bounds

git-svn-id: trunk@21668 -
This commit is contained in:
mattias 2009-09-12 16:06:18 +00:00
parent b6cf29d755
commit 9d47b22a8e
3 changed files with 18 additions and 14 deletions

View File

@ -2371,4 +2371,3 @@ msgstr "Laužyti tekstą"
msgid "Yes"
msgstr "Taip"

View File

@ -616,10 +616,14 @@ procedure TSelectedControl.SetFormRelativeBounds(ALeft, ATop, AWidth,
AHeight: integer);
var
ParentOffset: TPoint;
OldBounds: TRect;
begin
if not FIsTComponent then exit;
if Owner.Mediator<>nil then begin
Owner.Mediator.GetBounds(TComponent(FPersistent),OldBounds);
ParentOffset:=Owner.Mediator.GetComponentOriginOnForm(TComponent(FPersistent));
dec(ParentOffset.X,OldBounds.Left);
dec(ParentOffset.Y,OldBounds.Top);
Owner.Mediator.SetBounds(TComponent(FPersistent),
Bounds(ALeft-ParentOffset.X,ATop-ParentOffset.Y,AWidth,AHeight));
end else begin
@ -639,9 +643,8 @@ begin
if Owner.Mediator<>nil then begin
ALeftTop:=Owner.Mediator.GetComponentOriginOnForm(TComponent(FPersistent));
Owner.Mediator.GetBounds(TComponent(FPersistent),CurBounds);
OffsetRect(CurBounds,ALeftTop.X,ALeftTop.Y);
ALeft:=CurBounds.Left;
ATop:=CurBounds.Top;
ALeft:=ALeftTop.X;
ATop:=ALeftTop.Y;
AWidth:=CurBounds.Right-CurBounds.Left;
AHeight:=CurBounds.Bottom-CurBounds.Top;
end else begin

View File

@ -415,21 +415,18 @@ var
Parent: TComponent;
ClientArea: TRect;
ScrollOffset: TPoint;
ParentBounds: TRect;
NextParent: TComponent;
CurBounds: TRect;
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);
GetBounds(AComponent,CurBounds);
inc(Result.X,CurBounds.Left);
inc(Result.Y,CurBounds.Top);
GetClientArea(Parent,ClientArea,ScrollOffset);
inc(Result.X,ParentBounds.Left+ClientArea.Left+ScrollOffset.X);
inc(Result.Y,ParentBounds.Top+ClientArea.Top+ScrollOffset.Y);
inc(Result.X,ClientArea.Left+ScrollOffset.X);
inc(Result.Y,ClientArea.Top+ScrollOffset.Y);
AComponent:=Parent;
end;
end;
@ -471,14 +468,18 @@ var
ChildBounds: TRect;
Found: Boolean;
Childs: TFPList;
Offset: TPoint;
begin
Result:=Root;
while Result<>nil do begin
GetClientArea(Result,ClientArea,ScrollOffset);
Offset:=GetComponentOriginOnForm(Result);
//DebugLn(['TDesignerMediator.ComponentAtPos Parent=',DbgSName(Result),' Offset=',dbgs(Offset)]);
OffsetRect(ClientArea,Offset.X,Offset.Y);
Childs:=TFPList.Create;
try
GetChilds(Result,Childs);
//DebugLn(['TDesignerMediator.ComponentAtPos Result=',DbgSName(Result),' ChildCount=',childs.Count,' ']);
//DebugLn(['TDesignerMediator.ComponentAtPos Result=',DbgSName(Result),' ChildCount=',childs.Count,' ClientArea=',dbgs(ClientArea)]);
Found:=false;
// iterate backwards (z-order)
for i:=Childs.Count-1 downto 0 do begin
@ -494,6 +495,7 @@ begin
GetBounds(Child,ChildBounds);
OffsetRect(ChildBounds,ClientArea.Left+ScrollOffset.X,
ClientArea.Top+ScrollOffset.Y);
//DebugLn(['TDesignerMediator.ComponentAtPos ChildBounds=',dbgs(ChildBounds),' p=',dbgs(p)]);
if PtInRect(ChildBounds,p) then begin
Found:=true;
Result:=Child;