mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 17:39:20 +02:00
designer: csInline component fixes:
- fix relative coords of non-visual components if their owner has parent - clip non-visual components by parent client rectangle git-svn-id: trunk@23082 -
This commit is contained in:
parent
8469b98fc7
commit
39c6ed894c
@ -245,7 +245,7 @@ type
|
||||
destructor Destroy; override;
|
||||
|
||||
procedure Modified; override;
|
||||
procedure SelectOnlyThisComponent(AComponent:TComponent); override;
|
||||
procedure SelectOnlyThisComponent(AComponent: TComponent); override;
|
||||
function CopySelection: boolean; override;
|
||||
function CutSelection: boolean; override;
|
||||
function CanPaste: Boolean; override;
|
||||
@ -1338,7 +1338,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDesigner.SelectOnlyThisComponent(AComponent:TComponent);
|
||||
procedure TDesigner.SelectOnlyThisComponent(AComponent: TComponent);
|
||||
begin
|
||||
ControlSelection.AssignPersistent(AComponent);
|
||||
end;
|
||||
@ -1431,15 +1431,16 @@ function TDesigner.NonVisualComponentLeftTop(AComponent: TComponent): TPoint;
|
||||
begin
|
||||
Result.X := LeftFromDesignInfo(AComponent.DesignInfo);
|
||||
Result.Y := TopFromDesignInfo(AComponent.DesignInfo);
|
||||
// convert to owner coords
|
||||
while AComponent.Owner <> FLookupRoot do
|
||||
// convert to lookuproot coords
|
||||
if (AComponent.Owner <> FLookupRoot) and (FLookupRoot is TControl) then
|
||||
begin
|
||||
AComponent := AComponent.Owner;
|
||||
if AComponent is TControl then
|
||||
begin
|
||||
inc(Result.X, TControl(AComponent).Left);
|
||||
inc(Result.Y, TControl(AComponent).Top);
|
||||
end;
|
||||
with TControl(FLookupRoot).ScreenToClient(TControl(AComponent).ClientToScreen(Point(0, 0))) do
|
||||
begin
|
||||
inc(Result.X, X);
|
||||
inc(Result.Y, Y);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -2991,10 +2992,11 @@ var
|
||||
Icon: TBitmap;
|
||||
ItemLeft, ItemTop, ItemRight, ItemBottom: integer;
|
||||
Diff, ItemLeftTop: TPoint;
|
||||
IconRect, TextRect: TRect;
|
||||
OwnerRect, IconRect, TextRect: TRect;
|
||||
TextSize: TSize;
|
||||
IsSelected: Boolean;
|
||||
Root: TComponent;
|
||||
RGN: HRGN;
|
||||
begin
|
||||
// also call draw for the inline components children
|
||||
if (csInline in AComponent.ComponentState) or (AComponent.Owner=nil) then
|
||||
@ -3002,7 +3004,9 @@ begin
|
||||
else
|
||||
Root:=AComponent.Owner;
|
||||
TComponentAccess(AComponent).GetChildren(@DrawNonVisualComponent, Root);
|
||||
if not ComponentIsIcon(AComponent) then
|
||||
if not ComponentIsIcon(AComponent) or (AComponent.Owner = nil) then
|
||||
Exit;
|
||||
if not (AComponent.Owner is TControl) then
|
||||
Exit;
|
||||
// actual draw
|
||||
Diff := FDDC.FormOrigin;
|
||||
@ -3019,6 +3023,19 @@ begin
|
||||
IsSelected := ControlSelection.IsSelected(AComponent);
|
||||
FDDC.Save;
|
||||
|
||||
// set clipping
|
||||
if AComponent.Owner <> FDDC.Form then
|
||||
begin
|
||||
OwnerRect := TControl(AComponent.Owner).ClientRect;
|
||||
Diff := FDDC.Form.ScreenToClient(TControl(AComponent.Owner).ClientToScreen(Point(0, 0)));
|
||||
OffsetRect(OwnerRect, Diff.X, Diff.Y);
|
||||
// don't restore later FDDC.Restore will do this itself
|
||||
with OwnerRect do
|
||||
RGN := CreateRectRGN(Left, Top, Right, Bottom);
|
||||
SelectClipRGN(FDDC.DC, RGN);
|
||||
DeleteObject(RGN);
|
||||
end;
|
||||
|
||||
if FSurface = nil then
|
||||
begin
|
||||
FSurface := TBitmap.Create;
|
||||
@ -3249,21 +3266,10 @@ end;
|
||||
|
||||
procedure TDesigner.MoveNonVisualComponentIntoForm(AComponent: TComponent);
|
||||
var
|
||||
P: TPoint;
|
||||
Tmp: TComponent;
|
||||
X, Y: SmallInt;
|
||||
begin
|
||||
P := NonVisualComponentLeftTop(AComponent);
|
||||
Tmp := AComponent;
|
||||
while Tmp.Owner <> FLookupRoot do
|
||||
begin
|
||||
Tmp := Tmp.Owner;
|
||||
if Tmp is TControl then
|
||||
begin
|
||||
dec(P.X, TControl(Tmp).Left);
|
||||
dec(P.Y, TControl(Tmp).Top);
|
||||
end;
|
||||
end;
|
||||
AComponent.DesignInfo := LeftTopToDesignInfo(P.X, P.Y);
|
||||
DesignInfoToLeftTop(AComponent.DesignInfo, X, Y);
|
||||
AComponent.DesignInfo := LeftTopToDesignInfo(X, Y);
|
||||
end;
|
||||
|
||||
procedure TDesigner.MoveNonVisualComponentsIntoForm;
|
||||
|
@ -139,19 +139,22 @@ begin
|
||||
end;
|
||||
end else
|
||||
begin
|
||||
ParentForm := GetDesignerForm(Component);
|
||||
Result.X := LeftFromDesignInfo(Component.DesignInfo);
|
||||
Result.Y := TopFromDesignInfo(Component.DesignInfo);
|
||||
while (Component <> nil) and (Component.Owner <> ParentForm) do
|
||||
ParentForm := GetDesignerForm(Component);
|
||||
if ParentForm = nil then
|
||||
Exit;
|
||||
|
||||
if (Component <> nil) and (Component.Owner <> ParentForm) then
|
||||
begin
|
||||
Component := Component.Owner;
|
||||
if Component = nil then
|
||||
break;
|
||||
if (csInline in Component.ComponentState) and
|
||||
(Component is TControl) then
|
||||
if (csInline in Component.ComponentState) and (Component is TControl) then
|
||||
begin
|
||||
inc(Result.X, TControl(Component).Left);
|
||||
inc(Result.Y, TControl(Component).Top);
|
||||
with ParentForm.ScreenToClient(TControl(Component).ClientToScreen(Point(0, 0))) do
|
||||
begin
|
||||
inc(Result.X, X);
|
||||
inc(Result.Y, Y);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -218,16 +221,16 @@ begin
|
||||
ParentForm := GetDesignerForm(Component);
|
||||
if ParentForm = nil then
|
||||
Exit;
|
||||
while (Component <> nil) and (Component.Owner <> ParentForm) do
|
||||
if (Component <> nil) and (Component.Owner <> ParentForm) then
|
||||
begin
|
||||
Component := Component.Owner;
|
||||
if Component = nil then
|
||||
break;
|
||||
if (csInline in Component.ComponentState) and
|
||||
(Component is TControl) then
|
||||
if (csInline in Component.ComponentState) and (Component is TControl) then
|
||||
begin
|
||||
inc(Result.X, TControl(Component).Left);
|
||||
inc(Result.Y, TControl(Component).Top);
|
||||
with ParentForm.ScreenToClient(TControl(Component).ClientToScreen(Point(0, 0))) do
|
||||
begin
|
||||
inc(Result.X, X);
|
||||
inc(Result.Y, Y);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user