lcl: LDockTree: fix drop to non-empty root zone (issue #0013770)

git-svn-id: trunk@20080 -
This commit is contained in:
paul 2009-05-20 14:55:59 +00:00
parent c521333873
commit 656d65cb06
3 changed files with 37 additions and 38 deletions

View File

@ -2125,11 +2125,11 @@ type
FDockSite: TWinControl; FDockSite: TWinControl;
FDockZoneClass: TDockZoneClass; FDockZoneClass: TDockZoneClass;
FFlags: TDockTreeFlags; FFlags: TDockTreeFlags;
FRootZone: TDockZone;
FUpdateCount: Integer; FUpdateCount: Integer;
procedure DeleteZone(Zone: TDockZone); procedure DeleteZone(Zone: TDockZone);
procedure SetDockSite(const AValue: TWinControl); procedure SetDockSite(const AValue: TWinControl);
protected protected
FRootZone: TDockZone;
function HitTest(const MousePos: TPoint; var HTFlag: Integer): TControl; virtual; function HitTest(const MousePos: TPoint; var HTFlag: Integer): TControl; virtual;
procedure PaintDockFrame(ACanvas: TCanvas; AControl: TControl; procedure PaintDockFrame(ACanvas: TCanvas; AControl: TControl;
const ARect: TRect); virtual; const ARect: TRect); virtual;

View File

@ -87,15 +87,13 @@ end;
function TDockZone.GetHeight: Integer; function TDockZone.GetHeight: Integer;
begin begin
if not Visible then if not Visible then
Result := 0 Exit(0);
if FTree.RootZone = Self then
Result := FTree.FDockSite.ClientHeight
else else
if (FChildControl <> nil) then if (FChildControl <> nil) then
begin Result := FChildControl.Height
if FTree.RootZone = Self then
Result := FChildControl.ClientHeight
else
Result := FChildControl.Height
end
else else
begin begin
if FParentZone.Orientation = doHorizontal then if FParentZone.Orientation = doHorizontal then
@ -108,15 +106,13 @@ end;
function TDockZone.GetLeft: Integer; function TDockZone.GetLeft: Integer;
begin begin
if not Visible then if not Visible then
Exit(0);
if FTree.RootZone = Self then
Result := 0 Result := 0
else else
if (FChildControl <> nil) then if (FChildControl <> nil) then
begin Result := FChildControl.Left
if FTree.RootZone = Self then
Result := 0
else
Result := FChildControl.Left
end
else else
begin begin
if FParentZone.Orientation = doVertical then if FParentZone.Orientation = doVertical then
@ -153,13 +149,11 @@ begin
if not Visible then if not Visible then
Exit(0); Exit(0);
if FTree.RootZone = Self then
Result := 0
else
if (FChildControl <> nil) then if (FChildControl <> nil) then
begin Result := FChildControl.Top
if FTree.RootZone = Self then
Result := 0
else
Result := FChildControl.Top
end
else else
begin begin
if FParentZone.Orientation = doHorizontal then if FParentZone.Orientation = doHorizontal then
@ -195,13 +189,11 @@ begin
if not Visible then if not Visible then
Exit(0); Exit(0);
if FTree.RootZone = Self then
Result := FTree.FDockSite.ClientWidth
else
if (FChildControl <> nil) then if (FChildControl <> nil) then
begin Result := FChildControl.Width
if FTree.RootZone = Self then
Result := FChildControl.ClientWidth
else
Result := FChildControl.Width
end
else else
begin begin
if FParentZone.Orientation = doVertical then if FParentZone.Orientation = doVertical then

View File

@ -1122,7 +1122,8 @@ begin
//DebugLn(['TLazDockTree.AnchorDockLayout CurControl.Parent=',DbgSName(CurControl.Parent),' ',CurControl.Visible]); //DebugLn(['TLazDockTree.AnchorDockLayout CurControl.Parent=',DbgSName(CurControl.Parent),' ',CurControl.Visible]);
for a := Low(TAnchorKind) to High(TAnchorKind) do for a := Low(TAnchorKind) to High(TAnchorKind) do
begin begin
CurControl.AnchorSide[a].Control := AnchorControls[a]; if AnchorControls[a] <> CurControl then
CurControl.AnchorSide[a].Control := AnchorControls[a];
if (AnchorControls[a] <> nil) and (AnchorControls[a].Parent = CurControl.Parent) then if (AnchorControls[a] <> nil) and (AnchorControls[a].Parent = CurControl.Parent) then
CurControl.AnchorSide[a].Side := DefaultSideForAnchorKind[a] CurControl.AnchorSide[a].Side := DefaultSideForAnchorKind[a]
else else
@ -1307,6 +1308,8 @@ begin
if OldParentZone <> nil then if OldParentZone <> nil then
OldParentZone.ReplaceChild(DropZone, NewParentZone); OldParentZone.ReplaceChild(DropZone, NewParentZone);
NewParentZone.AddAsFirstChild(DropZone); NewParentZone.AddAsFirstChild(DropZone);
if RootZone = DropZone then
FRootZone := NewParentZone;
end; end;
if DropZone.Parent = nil then if DropZone.Parent = nil then
@ -1808,19 +1811,23 @@ function TLazDockZone.GetParentControl: TWinControl;
var var
Zone: TDockZone; Zone: TDockZone;
begin begin
Result:=nil; Result := nil;
Zone:=Parent; Zone := Parent;
while Zone<>nil do begin while Zone <> nil do
if Zone.Orientation=doPages then begin begin
Result:=(Zone as TLazDockZone).Pages; if Zone.Orientation = doPages then
exit; Exit((Zone as TLazDockZone).Pages);
end;
if (Zone.Parent=nil) then begin if (Zone.Parent = nil) then
begin
if Zone.ChildControl is TWinControl then if Zone.ChildControl is TWinControl then
Result:=TWinControl(Zone.ChildControl); Result := TWinControl(Zone.ChildControl)
exit; else
if Zone = Tree.RootZone then
Result := Tree.DockSite;
Exit;
end; end;
Zone:=Zone.Parent; Zone := Zone.Parent;
end; end;
end; end;