📄 jvdocktree.pas
字号:
function TJvDockZone.SetControlName(const Value: string): Boolean;
var
Client: TControl;
begin
Client := nil;
with FTree do
begin
TWinControlAccessProtected(FDockSite).ReloadDockedControl(Value, Client);
Result := Client <> nil;
if Result then
begin
FReplacementZone := Self;
ChildControl := TWinControl(Client);
DoCustomSetControlName;
try
if IsInside then
Client.ManualDock(FDockSite, nil, alNone);
finally
SetChildControlVisible(Client, FControlVisibled);
FReplacementZone := nil;
end;
end;
end;
end;
procedure TJvDockZone.Update;
var
NewWidth, NewHeight: Integer;
R: TRect;
function ParentNotLast: Boolean;
var
Parent: TJvDockZone;
begin
Result := False;
Parent := FParentZone;
while Parent <> nil do
begin
if (Parent.VisibleNextSiblingCount > 0) and (Parent.Orientation = ParentZone.Orientation) then
begin
Result := True;
Exit;
end;
Parent := Parent.FParentZone;
end;
end;
begin
if Visibled and (ChildControl <> nil) and (FTree.FUpdateCount = 0) then
begin
ChildControl.DockOrientation := FParentZone.Orientation;
NewWidth := Width;
NewHeight := Height;
if ParentNotLast then
if FParentZone.Orientation = doHorizontal then
Dec(NewWidth, FTree.SplitterWidth)
else
Dec(NewHeight, FTree.SplitterWidth);
if ((NextSibling <> nil) and (VisibleNextSiblingTotal > 0)) or ((FParentZone <> FTree.FTopZone) and
((FParentZone.Orientation = FTree.FTopZone.Orientation) and
(FZoneLimit < FTree.TopXYLimit)) or
((FParentZone.Orientation <> FTree.FTopZone.Orientation) and
(FZoneLimit < FTree.FTopZone.ZoneLimit))) then
if FParentZone.Orientation = doHorizontal then
Dec(NewHeight, FTree.SplitterWidth)
else
Dec(NewWidth, FTree.SplitterWidth);
R := Bounds(Left, Top, NewWidth, NewHeight);
FTree.AdjustDockRect(ChildControl, R);
ChildControl.BoundsRect := R;
end;
end;
function TJvDockZone.GetFrameRect: TRect;
var
ALeft, ATop, ARight, ABottom, BorderWidth: Integer;
begin
ALeft := Left;
ATop := Top;
if NextSibling <> nil then
BorderWidth := Tree.BorderWidth
else
BorderWidth := 0;
ARight := ALeft + Width - BorderWidth;
ABottom := ATop + Height - BorderWidth;
Result := Rect(ALeft, ATop, ARight, ABottom);
end;
function TJvDockZone.GetFirstSibling: TJvDockZone;
begin
Result := Self;
while Result.PrevSibling <> nil do
Result := Result.PrevSibling;
end;
function TJvDockZone.GetLastSibling: TJvDockZone;
begin
Result := Self;
while (Result <> nil) and (Result.NextSibling <> nil) do
Result := Result.NextSibling;
end;
function TJvDockZone.GetFirstChild: TJvDockZone;
begin
Result := ChildZones;
end;
function TJvDockZone.GetLastChild: TJvDockZone;
begin
Result := ChildZones;
if Result <> nil then
Result := Result.LastSibling;
end;
function TJvDockZone.GetTopLeftArr(Orient: TDockOrientation): Integer;
begin
case Orient of
doHorizontal:
Result := Top;
doVertical:
Result := Left;
else
Result := 0;
end;
end;
function TJvDockZone.GetHeightWidthArr(Orient: TDockOrientation): Integer;
begin
case Orient of
doHorizontal:
Result := Height;
doVertical:
Result := Width;
else
Result := 0;
end;
end;
procedure TJvDockZone.AdjustZoneLimit(Value: Integer);
begin
FZoneLimit := Value;
if PrevSibling <> nil then
PrevSibling.ZoneLimit := PrevSibling.ZoneLimit + Value;
end;
procedure TJvDockZone.SetZoneSize(Size: Integer; Show: Boolean);
begin
InsertOrRemove(Size, Show, False);
end;
procedure TJvDockZone.InsertOrRemove(DockSize: Integer; Insert: Boolean; Hide: Boolean);
begin
end;
procedure TJvDockZone.Insert(DockSize: Integer; Hide: Boolean);
begin
InsertOrRemove(DockSize, True, Hide);
if (ParentZone <> nil) and (ParentZone.VisibleChildCount = 0) then
ParentZone.Insert(ParentZone.VisibleSize, Hide);
Visibled := True;
if ParentZone <> nil then
ParentZone.ResetChildren(Self);
Tree.SetNewBounds(ParentZone);
Tree.UpdateChild(ParentZone);
end;
procedure TJvDockZone.Remove(DockSize: Integer; Hide: Boolean);
var
Zone: TJvDockZone;
begin
InsertOrRemove(DockSize, False, Hide);
Visibled := not Hide;
if (ParentZone <> Tree.TopZone) and (ParentZone.VisibleChildCount = 0) then
ParentZone.Remove(ParentZone.LimitSize, Hide);
if AfterClosestVisibleZone = nil then
begin
Zone := BeforeClosestVisibleZone;
if Zone <> nil then
begin
Zone.ZoneLimit := ZoneLimit;
Tree.SetNewBounds(Zone);
end;
end;
ZoneLimit := LimitBegin;
end;
function TJvDockZone.GetVisibleChildCount: Integer;
var
Zone: TJvDockZone;
begin
Result := 0;
Zone := ChildZones;
while Zone <> nil do
begin
if Zone.Visibled then
Inc(Result);
Zone := Zone.NextSibling;
end;
end;
function TJvDockZone.GetChildTotal: Integer;
procedure DoFindChildCount(Zone: TJvDockZone);
begin
if Zone <> nil then
begin
DoFindChildCount(Zone.NextSibling);
DoFindChildCount(Zone.ChildZones);
Inc(Result);
end;
end;
begin
Result := 0;
DoFindChildCount(ChildZones);
end;
function TJvDockZone.GetVisibleChildTotal: Integer;
procedure DoFindVisibleChildCount(Zone: TJvDockZone);
begin
if Zone <> nil then
begin
DoFindVisibleChildCount(Zone.NextSibling);
DoFindVisibleChildCount(Zone.ChildZones);
if Zone.Visibled then
Inc(Result);
end;
end;
begin
Result := 0;
DoFindVisibleChildCount(ChildZones);
end;
function TJvDockZone.GetAfterClosestVisibleZone: TJvDockZone;
begin
Result := NextSibling;
while Result <> nil do
begin
if Result.Visibled then
Break;
Result := Result.NextSibling;
end;
end;
function TJvDockZone.GetBeforeClosestVisibleZone: TJvDockZone;
begin
Result := PrevSibling;
while Result <> nil do
begin
if Result.Visibled then
Break;
Result := Result.PrevSibling;
end;
end;
function TJvDockZone.GetAfterApoapsisVisibleZone: TJvDockZone;
begin
Result := LastSibling;
if Result <> nil then
Result := Result.BeforeClosestVisibleZone;
if Self = Result then
Result := nil;
end;
function TJvDockZone.GetBeforeApoapsisVisibleZone: TJvDockZone;
begin
Result := ParentZone.ChildZones;
if Result <> Self then
Result := Result.AfterClosestVisibleZone;
if Self = Result then
Result := nil;
end;
function TJvDockZone.GetNextSiblingCount: Integer;
var
AZone: TJvDockZone;
begin
Result := 0;
AZone := NextSibling;
while AZone <> nil do
begin
Inc(Result);
AZone := AZone.NextSibling;
end;
end;
function TJvDockZone.GetPrevSiblingCount: Integer;
var
AZone: TJvDockZone;
begin
Result := 0;
AZone := PrevSibling;
while AZone <> nil do
begin
Inc(Result);
AZone := AZone.PrevSibling;
end;
end;
procedure TJvDockZone.SetVisibled(const Value: Boolean);
begin
FVisibled := Value;
if (not FVisibled) and (Self <> Tree.TopZone) then
if ParentZone.Orientation = doNoOrient then
VisibleSize := Tree.TopXYLimit
else
VisibleSize := LimitSize;
end;
function TJvDockZone.GetVisibleNextSiblingCount: Integer;
var
Zone: TJvDockZone;
begin
Result := 0;
Zone := NextSibling;
while Zone <> nil do
begin
if Zone.Visibled then
Inc(Result);
Zone := Zone.NextSibling;
end;
end;
function TJvDockZone.GetVisibleNextSiblingTotal: Integer;
procedure DoFindVisibleNextSiblingCount(Zone: TJvDockZone);
begin
if Zone <> nil then
begin
DoFindVisibleNextSiblingCount(Zone.NextSibling);
DoFindVisibleNextSiblingCount(Zone.ChildZones);
if Zone.Visibled then
Inc(Result);
end;
end;
begin
Result := 0;
DoFindVisibleNextSiblingCount(NextSibling);
end;
function TJvDockZone.GetVisiblePrevSiblingCount: Integer;
var
Zone: TJvDockZone;
begin
Result := 0;
Zone := PrevSibling;
while Zone <> nil do
begin
if Zone.Visibled then
Inc(Result);
Zone := Zone.PrevSibling;
end;
end;
function TJvDockZone.GetVisiblePrevSiblingTotal: Integer;
procedure DoFindVisibleNextSiblingCount(Zone: TJvDockZone);
begin
if (Zone <> nil) and (Zone <> Self) then
begin
DoFindVisibleNextSiblingCount(Zone.NextSibling);
DoFindVisibleNextSiblingCount(Zone.ChildZones);
if Zone.Visibled then
Inc(Result);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -