IDE designer: limit component position to form client area

git-svn-id: trunk@13996 -
This commit is contained in:
tombo 2008-02-06 11:45:50 +00:00
parent 5e3feae994
commit a7714f09e0
2 changed files with 30 additions and 10 deletions

View File

@ -716,12 +716,22 @@ begin
end;
procedure TSelectedControl.SetLeft(ALeft: integer);
var
M: Word;
begin
if FIsTControl then
TControl(FPersistent).Left:=Aleft
else if FIsTComponent then
LongRec(TComponent(FPersistent).DesignInfo).Lo:=
word(Min(32000,Max(0,ALeft)));
else
if FIsTComponent then
begin
M := 32000;
if DesignerForm <> nil then
M := Max(0, Min(M, DesignerForm.ClientWidth - NonVisualCompWidth));
LongRec(TComponent(FPersistent).DesignInfo).Lo:=
word(Min(M, Max(0,ALeft)));
end;
FCachedLeft:=ALeft;
end;
@ -742,12 +752,22 @@ begin
end;
procedure TSelectedControl.SetTop(ATop: integer);
var
M: Word;
begin
if FIsTControl then
TControl(FPersistent).Top:=ATop
else if FIsTComponent then
LongRec(TComponent(FPersistent).DesignInfo).Hi:=
word(Min(32000,Max(0,ATop)));
else
if FIsTComponent then
begin
M := 32000;
if DesignerForm <> nil then
M := Max(0, Min(M, DesignerForm.ClientHeight - NonVisualCompWidth));
LongRec(TComponent(FPersistent).DesignInfo).Hi:=
word(Min(M, Max(0,ATop)));
end;
FCachedTop:=ATop;
end;

View File

@ -1075,10 +1075,10 @@ end;
function TDesigner.NonVisualComponentLeftTop(AComponent: TComponent): TPoint;
begin
Result.X:=Min(LongRec(AComponent.DesignInfo).Lo,
Form.ClientWidth-NonVisualCompWidth);
Result.Y:=Min(LongRec(AComponent.DesignInfo).Hi,
Form.ClientHeight-NonVisualCompWidth);
Result.X:=Max(0, Min(LongRec(AComponent.DesignInfo).Lo,
Form.ClientWidth-NonVisualCompWidth));
Result.Y:=Max(0, Min(LongRec(AComponent.DesignInfo).Hi,
Form.ClientHeight-NonVisualCompWidth));
end;
procedure TDesigner.InvalidateWithParent(AComponent: TComponent);