mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-17 14:49:28 +02:00
ide, designer: allow negative left and top for non-visual components (also fixes bug #0013468)
git-svn-id: trunk@21561 -
This commit is contained in:
parent
21c78cf0ad
commit
f5b7d75df5
@ -700,15 +700,16 @@ var
|
||||
AForm: TCustomForm;
|
||||
CompRect: TRect;
|
||||
begin
|
||||
AForm:=DesignerForm;
|
||||
if (AForm=nil) or (not FIsTComponent) then exit;
|
||||
CompRect.Left:=LongRec(TComponent(FPersistent).DesignInfo).Lo;
|
||||
CompRect.Top:=LongRec(TComponent(FPersistent).DesignInfo).Hi;
|
||||
CompRect.Right:=CompRect.Left+NonVisualCompWidth;
|
||||
CompRect.Bottom:=CompRect.Top+NonVisualCompWidth;
|
||||
//writeln('TSelectedControl.InvalidateNonVisualComponent A ',CompRect.Left,',',CompRect.Top,',',CompRect.Right,',',CompRect.Bottom);
|
||||
AForm := DesignerForm;
|
||||
if (AForm = nil) or (not FIsTComponent) then Exit;
|
||||
|
||||
CompRect.Left := LeftFromDesignInfo(TComponent(FPersistent).DesignInfo);
|
||||
CompRect.Top := TopFromDesignInfo(TComponent(FPersistent).DesignInfo);
|
||||
CompRect.Right := CompRect.Left+NonVisualCompWidth;
|
||||
CompRect.Bottom := CompRect.Top+NonVisualCompWidth;
|
||||
|
||||
if AForm.HandleAllocated then
|
||||
InvalidateDesignerRect(AForm.Handle,@CompRect);
|
||||
InvalidateDesignerRect(AForm.Handle, @CompRect);
|
||||
end;
|
||||
|
||||
function TSelectedControl.GetLeft: integer;
|
||||
@ -721,34 +722,29 @@ begin
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
procedure TSelectedControl.SetLeft(ALeft: integer);
|
||||
var
|
||||
M: Word;
|
||||
procedure TSelectedControl.SetLeft(ALeft: Integer);
|
||||
begin
|
||||
if FIsTControl then
|
||||
TControl(FPersistent).Left:=Aleft
|
||||
TControl(FPersistent).Left := Aleft
|
||||
else
|
||||
if FIsTComponent then
|
||||
begin
|
||||
M := 32000;
|
||||
if DesignerForm <> nil then
|
||||
M := Max(0, Min(M, DesignerForm.ClientWidth - NonVisualCompWidth));
|
||||
|
||||
with LongRec(TComponent(FPersistent).DesignInfo) do
|
||||
Lo := Word(Min(M, Max(0, ALeft)));
|
||||
end;
|
||||
if FIsTComponent then
|
||||
begin
|
||||
ALeft := Max(Low(SmallInt), Min(ALeft, High(SmallInt)));
|
||||
TComponent(FPersistent).DesignInfo := DesignInfoFrom(ALeft, Top);
|
||||
end;
|
||||
|
||||
FCachedLeft:=ALeft;
|
||||
FCachedLeft := ALeft;
|
||||
end;
|
||||
|
||||
function TSelectedControl.GetTop: integer;
|
||||
begin
|
||||
if FUseCache then
|
||||
Result:=FCachedTop
|
||||
else if FIsTComponent then
|
||||
Result:=GetComponentTop(TComponent(FPersistent))
|
||||
Result := FCachedTop
|
||||
else
|
||||
if FIsTComponent then
|
||||
Result := GetComponentTop(TComponent(FPersistent))
|
||||
else
|
||||
Result:=0;
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
procedure TSelectedControl.SetOwner(const AValue: TControlSelection);
|
||||
@ -758,31 +754,26 @@ begin
|
||||
end;
|
||||
|
||||
procedure TSelectedControl.SetTop(ATop: integer);
|
||||
var
|
||||
M: Word;
|
||||
begin
|
||||
if FIsTControl then
|
||||
TControl(FPersistent).Top:=ATop
|
||||
TControl(FPersistent).Top := ATop
|
||||
else
|
||||
if FIsTComponent then
|
||||
begin
|
||||
M := 32000;
|
||||
if DesignerForm <> nil then
|
||||
M := Max(0, Min(M, DesignerForm.ClientHeight - NonVisualCompWidth));
|
||||
|
||||
with LongRec(TComponent(FPersistent).DesignInfo) do
|
||||
Hi := Word(Min(M, Max(0, ATop)));
|
||||
end;
|
||||
if FIsTComponent then
|
||||
begin
|
||||
ATop := Max(Low(SmallInt), Min(ATop, High(SmallInt)));
|
||||
TComponent(FPersistent).DesignInfo := DesignInfoFrom(Left, ATop);
|
||||
end;
|
||||
|
||||
FCachedTop:=ATop;
|
||||
FCachedTop := ATop;
|
||||
end;
|
||||
|
||||
function TSelectedControl.GetWidth: integer;
|
||||
begin
|
||||
if FUseCache then
|
||||
Result:=FCachedWidth
|
||||
else if FIsTComponent then
|
||||
Result:=GetComponentWidth(TComponent(FPersistent));
|
||||
Result := FCachedWidth
|
||||
else
|
||||
if FIsTComponent then
|
||||
Result := GetComponentWidth(TComponent(FPersistent));
|
||||
end;
|
||||
|
||||
procedure TSelectedControl.SetUseCache(const AValue: boolean);
|
||||
@ -802,9 +793,10 @@ end;
|
||||
function TSelectedControl.GetHeight: integer;
|
||||
begin
|
||||
if FUseCache then
|
||||
Result:=FCachedHeight
|
||||
else if FIsTComponent then
|
||||
Result:=GetComponentHeight(TComponent(FPersistent))
|
||||
Result := FCachedHeight
|
||||
else
|
||||
if FIsTComponent then
|
||||
Result := GetComponentHeight(TComponent(FPersistent))
|
||||
else
|
||||
Result:=0;
|
||||
end;
|
||||
|
@ -835,8 +835,8 @@ var
|
||||
break;
|
||||
until false;
|
||||
AComponent.DesignInfo := DesignInfoFrom(
|
||||
Word(Max(0, Min(P.x, Form.ClientWidth - NonVisualCompWidth))),
|
||||
Word(Max(0, Min(P.y, Form.ClientHeight - NonVisualCompWidth))));
|
||||
SmallInt(Max(0, Min(P.x, Form.ClientWidth - NonVisualCompWidth))),
|
||||
SmallInt(Max(0, Min(P.y, Form.ClientHeight - NonVisualCompWidth))));
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -1113,10 +1113,8 @@ end;
|
||||
|
||||
function TDesigner.NonVisualComponentLeftTop(AComponent: TComponent): TPoint;
|
||||
begin
|
||||
Result.X:=Max(0, Min(LongRec(AComponent.DesignInfo).Lo,
|
||||
Form.ClientWidth-NonVisualCompWidth));
|
||||
Result.Y:=Max(0, Min(LongRec(AComponent.DesignInfo).Hi,
|
||||
Form.ClientHeight-NonVisualCompWidth));
|
||||
Result.X := LeftFromDesignInfo(AComponent.DesignInfo);
|
||||
Result.Y := TopFromDesignInfo(AComponent.DesignInfo);
|
||||
end;
|
||||
|
||||
procedure TDesigner.InvalidateWithParent(AComponent: TComponent);
|
||||
|
@ -112,8 +112,10 @@ function GetComponentHeight(AComponent: TComponent): integer;
|
||||
|
||||
procedure InvalidateDesignerRect(aHandle: HWND; ARect: pRect);
|
||||
|
||||
function DesignInfoFrom(const Left, Top: Word): LongInt;
|
||||
|
||||
function DesignInfoFrom(const ALeft, ATop: SmallInt): LongInt;
|
||||
procedure DesignInfoTo(ADesignInfo: LongInt; out ALeft, ATop: SmallInt);
|
||||
function LeftFromDesignInfo(ADesignInfo: LongInt): SmallInt;
|
||||
function TopFromDesignInfo(ADesignInfo: LongInt): SmallInt;
|
||||
|
||||
implementation
|
||||
|
||||
@ -141,8 +143,8 @@ begin
|
||||
end;
|
||||
end else
|
||||
begin
|
||||
Result.X := LongRec(Component.DesignInfo).Lo;
|
||||
Result.Y := LongRec(Component.DesignInfo).Hi;
|
||||
Result.X := LeftFromDesignInfo(Component.DesignInfo);
|
||||
Result.Y := TopFromDesignInfo(Component.DesignInfo);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -214,53 +216,51 @@ end;
|
||||
procedure GetComponentBounds(AComponent: TComponent;
|
||||
var Left, Top, Width, Height: integer);
|
||||
begin
|
||||
if AComponent is TControl then begin
|
||||
Left:=TControl(AComponent).Left;
|
||||
Top:=TControl(AComponent).Top;
|
||||
Width:=TControl(AComponent).Width;
|
||||
Height:=TControl(AComponent).Height;
|
||||
end else begin
|
||||
Left:=LongRec(AComponent.DesignInfo).Lo;
|
||||
Top:=LongRec(AComponent.DesignInfo).Hi;
|
||||
Width:=NonVisualCompWidth;
|
||||
Height:=Width;
|
||||
if AComponent is TControl then
|
||||
begin
|
||||
Left := TControl(AComponent).Left;
|
||||
Top := TControl(AComponent).Top;
|
||||
Width := TControl(AComponent).Width;
|
||||
Height := TControl(AComponent).Height;
|
||||
end else
|
||||
begin
|
||||
Left := LeftFromDesignInfo(AComponent.DesignInfo);
|
||||
Top := TopFromDesignInfo(AComponent.DesignInfo);
|
||||
Width := NonVisualCompWidth;
|
||||
Height := Width;
|
||||
end;
|
||||
end;
|
||||
|
||||
function GetComponentLeft(AComponent: TComponent): integer;
|
||||
begin
|
||||
if AComponent is TControl then begin
|
||||
Result:=TControl(AComponent).Left;
|
||||
end else begin
|
||||
Result:=LongRec(AComponent.DesignInfo).Lo;
|
||||
end;
|
||||
if AComponent is TControl then
|
||||
Result := TControl(AComponent).Left
|
||||
else
|
||||
Result := LeftFromDesignInfo(AComponent.DesignInfo);
|
||||
end;
|
||||
|
||||
function GetComponentTop(AComponent: TComponent): integer;
|
||||
begin
|
||||
if AComponent is TControl then begin
|
||||
Result:=TControl(AComponent).Top;
|
||||
end else begin
|
||||
Result:=LongRec(AComponent.DesignInfo).Hi;
|
||||
end;
|
||||
if AComponent is TControl then
|
||||
Result := TControl(AComponent).Top
|
||||
else
|
||||
Result := TopFromDesignInfo(AComponent.DesignInfo);
|
||||
end;
|
||||
|
||||
function GetComponentWidth(AComponent: TComponent): integer;
|
||||
begin
|
||||
if AComponent is TControl then begin
|
||||
Result:=TControl(AComponent).Width;
|
||||
end else begin
|
||||
Result:=NonVisualCompWidth;
|
||||
end;
|
||||
if AComponent is TControl then
|
||||
Result := TControl(AComponent).Width
|
||||
else
|
||||
Result := NonVisualCompWidth;
|
||||
end;
|
||||
|
||||
function GetComponentHeight(AComponent: TComponent): integer;
|
||||
begin
|
||||
if AComponent is TControl then begin
|
||||
Result:=TControl(AComponent).Height;
|
||||
end else begin
|
||||
Result:=NonVisualCompWidth;
|
||||
end;
|
||||
if AComponent is TControl then
|
||||
Result := TControl(AComponent).Height
|
||||
else
|
||||
Result := NonVisualCompWidth;
|
||||
end;
|
||||
|
||||
procedure InvalidateDesignerRect(aHandle: HWND; ARect: pRect);
|
||||
@ -323,10 +323,46 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function DesignInfoFrom(const Left, Top: Word): LongInt;
|
||||
function DesignInfoFrom(const ALeft, ATop: SmallInt): LongInt;
|
||||
var
|
||||
ResultRec: packed record
|
||||
Left: SmallInt;
|
||||
Top: SmallInt;
|
||||
end absolute Result;
|
||||
begin
|
||||
LongRec(Result).Hi := Top;
|
||||
LongRec(Result).Lo := Left;
|
||||
ResultRec.Left := ALeft;
|
||||
ResultRec.Top := ATop;
|
||||
end;
|
||||
|
||||
procedure DesignInfoTo(ADesignInfo: LongInt; out ALeft, ATop: SmallInt);
|
||||
var
|
||||
DesignInfoRec: packed record
|
||||
Left: SmallInt;
|
||||
Top: SmallInt;
|
||||
end absolute ADesignInfo;
|
||||
begin
|
||||
ALeft := DesignInfoRec.Left;
|
||||
ATop := DesignInfoRec.Top;
|
||||
end;
|
||||
|
||||
function LeftFromDesignInfo(ADesignInfo: LongInt): SmallInt;
|
||||
var
|
||||
DesignInfoRec: packed record
|
||||
Left: SmallInt;
|
||||
Top: SmallInt;
|
||||
end absolute ADesignInfo;
|
||||
begin
|
||||
Result := DesignInfoRec.Left;
|
||||
end;
|
||||
|
||||
function TopFromDesignInfo(ADesignInfo: LongInt): SmallInt;
|
||||
var
|
||||
DesignInfoRec: packed record
|
||||
Left: SmallInt;
|
||||
Top: SmallInt;
|
||||
end absolute ADesignInfo;
|
||||
begin
|
||||
Result := DesignInfoRec.Top;
|
||||
end;
|
||||
|
||||
{ TDesignerDeviceContext }
|
||||
|
@ -137,8 +137,8 @@ procedure TFrameDesignerForm.DoLoadBounds;
|
||||
|
||||
var
|
||||
CurControl: TControl;
|
||||
NewLeft: integer;
|
||||
NewTop: integer;
|
||||
NewLeft: SmallInt;
|
||||
NewTop: SmallInt;
|
||||
begin
|
||||
inherited;
|
||||
|
||||
@ -146,8 +146,7 @@ begin
|
||||
begin
|
||||
CurControl := TControl(LookupRoot);
|
||||
// restore designer position
|
||||
NewLeft:=LongRec(LookupRoot.DesignInfo).Lo;
|
||||
NewTop:=LongRec(LookupRoot.DesignInfo).Hi;
|
||||
DesignInfoTo(LookupRoot.DesignInfo, NewLeft, NewTop);
|
||||
// resize designer form
|
||||
SetNewBounds(NewLeft,NewTop,CurControl.Width,CurControl.Height);
|
||||
//DebugLn(['TFrameDesignerForm.DoLoadBounds ',NewLeft,',',NewTop]);
|
||||
|
@ -109,25 +109,25 @@ procedure TNonControlDesignerForm.DoLoadBounds;
|
||||
|
||||
var
|
||||
CurDataModule: TDataModule;
|
||||
NewLeft: Integer;
|
||||
NewTop: Integer;
|
||||
NewWidth: Integer;
|
||||
NewHeight: Integer;
|
||||
NewLeft, NewTop: SmallInt;
|
||||
NewWidth, NewHeight: Integer;
|
||||
begin
|
||||
inherited DoLoadBounds;
|
||||
|
||||
if LookupRoot is TDataModule then begin
|
||||
CurDataModule:=TDataModule(LookupRoot);
|
||||
NewLeft:=CurDataModule.DesignOffset.X;
|
||||
NewTop:=CurDataModule.DesignOffset.Y;
|
||||
NewWidth:=CurDataModule.DesignSize.X;
|
||||
NewHeight:=CurDataModule.DesignSize.Y;
|
||||
if LookupRoot is TDataModule then
|
||||
begin
|
||||
CurDataModule := TDataModule(LookupRoot);
|
||||
NewLeft := CurDataModule.DesignOffset.X;
|
||||
NewTop := CurDataModule.DesignOffset.Y;
|
||||
NewWidth := CurDataModule.DesignSize.X;
|
||||
NewHeight := CurDataModule.DesignSize.Y;
|
||||
|
||||
SetNewBounds(NewLeft,NewTop,NewWidth,NewHeight);
|
||||
end else if LookupRoot<>nil then begin
|
||||
NewLeft:=LongRec(LookupRoot.DesignInfo).Lo;
|
||||
NewTop:=LongRec(LookupRoot.DesignInfo).Hi;
|
||||
SetNewBounds(NewLeft,NewTop,Width,Height);
|
||||
SetNewBounds(NewLeft, NewTop, NewWidth, NewHeight);
|
||||
end else
|
||||
if LookupRoot <> nil then
|
||||
begin
|
||||
DesignInfoTo(LookupRoot.DesignInfo, NewLeft, NewTop);
|
||||
SetNewBounds(NewLeft, NewTop, Width, Height);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -1684,19 +1684,16 @@ begin
|
||||
end
|
||||
else begin
|
||||
// non TControl
|
||||
if CompWidth<=0 then CompWidth:=50;
|
||||
if CompHeight<=0 then CompHeight:=50;
|
||||
if CompLeft<0 then
|
||||
CompLeft:=Max(1,Min(250,Screen.Width-CompWidth-50));
|
||||
if CompTop<0 then
|
||||
CompTop:=Max(1,Min(250,Screen.Height-CompHeight-50));
|
||||
with LongRec(Temp.Component.DesignInfo) do begin
|
||||
Lo:=word(Min(32000,CompLeft));
|
||||
Hi:=word(Min(32000,CompTop));
|
||||
end;
|
||||
if (ParentComponent<>nil) then begin
|
||||
DesignForm:=GetDesignerForm(ParentComponent);
|
||||
if DesignForm<>nil then DesignForm.Invalidate;
|
||||
if CompWidth <= 0 then CompWidth := 50;
|
||||
if CompHeight <= 0 then CompHeight := 50;
|
||||
|
||||
CompLeft := Max(Low(SmallInt), Min(High(SmallInt), CompLeft));
|
||||
CompTop := Max(Low(SmallInt), Min(High(SmallInt), CompTop));
|
||||
Temp.Component.DesignInfo := DesignInfoFrom(CompLeft, CompTop);
|
||||
if ParentComponent <> nil then
|
||||
begin
|
||||
DesignForm := GetDesignerForm(ParentComponent);
|
||||
if DesignForm <> nil then DesignForm.Invalidate;
|
||||
end;
|
||||
end;
|
||||
except
|
||||
|
@ -369,7 +369,7 @@
|
||||
<CompilerOptions>
|
||||
<Version Value="8"/>
|
||||
<Target>
|
||||
<Filename Value="../lazarus"/>
|
||||
<Filename Value="../lazarus.win32.exe"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<OtherUnitFiles Value="frames/;../debugger/;../debugger/frames/;/home/mattias/pascal/wichtig/lazarus/packager/frames/"/>
|
||||
|
Loading…
Reference in New Issue
Block a user