📄 jvdockvcstyle.pas
字号:
begin
if Zone.LimitSize < MinSize then
Zone.ZoneLimit := Zone.LimitBegin + MinSize;
if (Zone.BeforeClosestVisibleZone <> nil) and
(Zone.LimitBegin > DockSiteSizeWithOrientation[Zone.ParentZone.Orientation] -
(Zone.VisibleNextSiblingCount + 1) * MinSize + SplitterWidth div 2) then
Zone.BeforeClosestVisibleZone.ZoneLimit := DockSiteSizeWithOrientation[Zone.ParentZone.Orientation] -
(Zone.VisibleNextSiblingCount + 1) * MinSize + SplitterWidth div 2;
end;
end;
procedure TJvDockVCTree.ScaleSiblingZone(Zone: TJvDockZone);
begin
inherited ScaleSiblingZone(Zone);
end;
procedure TJvDockVCTree.ScaleZone(Zone: TJvDockZone);
begin
if Zone <> nil then
case TJvDockVCZone(Zone).ZoneSizeStyle of
zssMinimum:
Zone.ZoneLimit := Zone.LimitBegin + MinSize;
zssMaximum:
Zone.ZoneLimit := DockSiteSizeAlternate - Zone.VisibleNextSiblingCount * MinSize;
else
inherited ScaleZone(Zone);
end
else
inherited ScaleZone(Zone);
end;
procedure TJvDockVCTree.ShiftZone(Zone: TJvDockZone);
begin
inherited ShiftZone(Zone);
if (Zone <> nil) and (Zone <> TopZone) and
(Zone.ParentZone.Orientation = ShiftScaleOrientation) then
begin
if Zone.LimitSize < MinSize then
Zone.ZoneLimit := Zone.LimitBegin + MinSize;
end;
end;
procedure TJvDockVCTree.SplitterMouseUp;
begin
BeginUpdate;
try
ShiftBy := 0;
if (DockSiteOrientation = doVertical) and
(SizingZone.ParentZone.Orientation = doVertical) then
ShiftBy := SizePos.X + (SplitterWidth div 2) - SizingZone.ZoneLimit
else
if (DockSiteOrientation = doHorizontal) and
(SizingZone.ParentZone.Orientation = doHorizontal) then
ShiftBy := SizePos.Y + (SplitterWidth div 2) - SizingZone.ZoneLimit;
if (ShiftBy <> 0) and (SizingZone.AfterClosestVisibleZone <> nil) then
begin
if (DockSite.Align in [alLeft, alTop]) then
begin
ShiftScaleOrientation := DockSiteOrientation;
ForEachAt(SizingZone.AfterClosestVisibleZone, ShiftZone, tskForward);
inherited SplitterMouseUp;
end
else
begin
ShiftBy := -ShiftBy;
ShiftScaleOrientation := DockSiteOrientation;
ForEachAt(SizingZone.AfterClosestVisibleZone, ShiftZone, tskForward);
SizePos := Point(SizePos.X + ShiftBy, SizePos.Y + ShiftBy);
inherited SplitterMouseUp;
end;
DockSiteSize := DockSiteSize + ShiftBy;
end
else
begin
TJvDockVCZone(SizingZone.ParentZone).DoSetChildSizeStyle(zssNormal);
inherited SplitterMouseUp;
end;
finally
EndUpdate;
end;
end;
procedure TJvDockVCTree.WindowProc(var Msg: TMessage);
begin
inherited WindowProc(Msg);
end;
//=== { TJvDockVCZone } ======================================================
constructor TJvDockVCZone.Create(Tree: TJvDockTree);
begin
inherited Create(Tree);
FZoneSizeStyle := zssNormal;
FExpandButtonDown := False;
end;
procedure TJvDockVCZone.DoSetChildSizeStyle(ZoneSizeStyle: TJvDockZoneSizeStyle);
var
Zone: TJvDockVCZone;
begin
Zone := TJvDockVCZone(ChildZones);
while Zone <> nil do
begin
Zone.ZoneSizeStyle := ZoneSizeStyle;
Zone := TJvDockVCZone(Zone.AfterClosestVisibleZone);
end;
end;
procedure TJvDockVCZone.Insert(DockSize: Integer; Hide: Boolean);
var
PrevShift, NextShift: Integer;
TempSize: Integer;
BorderSize: Integer;
BeforeVisibleZone, AfterVisibleZone: TJvDockZone;
begin
if (ParentZone <> nil) and (ParentZone.VisibleChildCount = 0) then
ParentZone.Insert(ParentZone.VisibleSize, Hide);
if (ParentZone = nil) or ((ParentZone = Tree.TopZone) and (ParentZone.ChildCount <= 1)) then
begin
Visibled := True;
Exit;
end;
BeforeVisibleZone := BeforeClosestVisibleZone;
AfterVisibleZone := AfterClosestVisibleZone;
BorderSize := TJvDockVCTree(Tree).BorderWidth * Ord(AfterClosestVisibleZone = nil);
if ParentZone.Orientation <> TJvDockVCTree(Tree).DockSiteOrientation then
begin
if ((BeforeVisibleZone <> nil) and (TJvDockVCZone(BeforeVisibleZone).ZoneSizeStyle in [zssMaximum, zssMinimum])) or
((AfterVisibleZone <> nil) and (TJvDockVCZone(AfterVisibleZone).ZoneSizeStyle in [zssMaximum, zssMinimum])) then
begin
ZoneSizeStyle := zssMinimum;
TJvDockVCTree(Tree).ResetDockZoneSizeStyle(ParentZone, zssMaximum, nil);
Visibled := True;
Exit;
end;
case TJvDockVCTree(Tree).DockSiteOrientation of
doVertical:
TempSize := Tree.DockSite.Height;
doHorizontal:
TempSize := Tree.DockSite.Width;
else
raise Exception.CreateRes(@RsEInvalidDockSiteOrientationValue);
end;
if DockSize >= TempSize - (ParentZone.VisibleChildCount) * TJvDockVCTree(Tree).MinSize then
DockSize := (TempSize - (ParentZone.VisibleChildCount) * TJvDockVCTree(Tree).MinSize) div 2;
TempSize := ParentZone.HeightWidth[ParentZone.Orientation] + BorderSize;
if DockSize = 0 then
DockSize := TempSize div 2;
Visibled := False;
if (BeforeVisibleZone = nil) and (AfterVisibleZone = nil) then
begin
PrevShift := 0;
NextShift := 0;
end
else
if BeforeVisibleZone = nil then
begin
PrevShift := 0;
NextShift := DockSize + BorderSize;
ZoneLimit := DockSize + BorderSize;
if ParentZone.VisibleChildCount = 1 then
AfterVisibleZone.ZoneLimit := TempSize;
end
else
if AfterVisibleZone = nil then
begin
PrevShift := DockSize + BorderSize;
NextShift := 0;
if (ParentZone.VisibleChildCount = 1) and (ParentZone = Tree.TopZone) then
BeforeVisibleZone.ZoneLimit := Tree.TopXYLimit - PrevShift
else
BeforeVisibleZone.ZoneLimit := BeforeVisibleZone.ZoneLimit - PrevShift;
ZoneLimit := TempSize;
end
else
begin
PrevShift := Round((BeforeVisibleZone.ZoneLimit) * (DockSize + BorderSize) / TempSize);
NextShift := DockSize - PrevShift;
if (ParentZone.VisibleChildCount = 1) and (ParentZone = Tree.TopZone) then
BeforeVisibleZone.ZoneLimit := Tree.TopXYLimit - PrevShift
else
BeforeVisibleZone.ZoneLimit := BeforeVisibleZone.ZoneLimit - PrevShift;
ZoneLimit := BeforeVisibleZone.ZoneLimit + DockSize;
end;
Visibled := True;
if PrevShift <> 0 then
begin
with TJvDockVCTree(Tree) do
begin
ReplacementZone := BeforeVisibleZone;
try
if BeforeVisibleZone.ZoneLimit + PrevShift <> 0 then
ScaleBy := PrevSibling.ZoneLimit / (BeforeVisibleZone.ZoneLimit + PrevShift)
else
ScaleBy := 1;
ShiftScaleOrientation := ParentZone.Orientation;
if ScaleBy <> 1 then
ForEachAt(ParentZone.ChildZones, ScaleZone, tskForward);
finally
ReplacementZone := nil;
end;
end;
if BeforeVisibleZone.LimitSize < TJvDockVCTree(Tree).MinSize then
BeforeVisibleZone.ZoneLimit := BeforeVisibleZone.LimitBegin + TJvDockVCTree(Tree).MinSize;
end;
if NextShift <> 0 then
begin
with TJvDockVCTree(Tree) do
begin
if TempSize - ZoneLimit + NextShift <> 0 then
ScaleBy := (TempSize - ZoneLimit) / (TempSize - ZoneLimit + NextShift)
else
ScaleBy := 1;
ParentLimit := TempSize;
ShiftScaleOrientation := ParentZone.Orientation;
if ScaleBy <> 1 then
ForEachAt(AfterVisibleZone, ScaleSiblingZone, tskForward);
end;
if AfterVisibleZone.LimitSize < TJvDockVCTree(Tree).MinSize then
AfterVisibleZone.ZoneLimit := AfterVisibleZone.LimitBegin + TJvDockVCTree(Tree).MinSize;
end;
end
else
begin
with TJvDockVCTree(Tree) do
begin
TempSize := DockHeightWidth[DockSiteOrientation] - BorderSize;
if BeforeVisibleZone <> nil then
begin
if (Tree.TopZone.VisibleChildCount = 2) and Visibled then
BeforeVisibleZone.ZoneLimit := Tree.TopXYLimit + BorderSize;
if Visibled then
ZoneLimit := BeforeVisibleZone.ZoneLimit + TempSize
else
ZoneLimit := BeforeVisibleZone.ZoneLimit + DockSize + BorderSize;
TempSize := ZoneLimit;
end;
if AfterVisibleZone <> nil then
begin
if Visibled then
ZoneLimit := LimitBegin + TempSize
else
ZoneLimit := LimitBegin + DockSize - BorderSize;
ShiftBy := ZoneLimit;
ShiftScaleOrientation := DockSiteOrientation;
ForEachAt(AfterVisibleZone, ShiftZone, tskForward);
TempSize := DockSiteSize + ZoneLimit - LimitBegin;
end;
Visibled := True;
DockSiteSize := TempSize;
TJvDockPanel(DockSite).DockServer.GetClientAlignControl(DockSite.Align);
end;
end;
Visibled := True;
end;
procedure TJvDockVCZone.InsertOrRemove(DockSize: Integer; Insert: Boolean; Hide: Boolean);
var
PrevShift, NextShift: Integer;
TempSize: Integer;
BorderWidth: Integer;
begin
if not Insert then
Visibled := False;
if (ParentZone <> nil) and (ParentZone.VisibleChildCount = 0) and (ParentZone <> Tree.TopZone) then
begin
if Insert then
TempSize := ParentZone.VisibleSize
else
TempSize := ParentZone.LimitSize;
ParentZone.InsertOrRemove(TempSize, Insert, Hide);
end;
if ParentZone = nil then
Exit;
if ParentZone.Orientation <> TJvDockVCTree(Tree).DockSiteOrientation then
begin
if TJvDockVCZone(ParentZone.ChildZones).ZoneSizeStyle in [zssMaximum, zssMinimum] then
begin
if Insert then
begin
ZoneSizeStyle := zssMinimum;
TJvDockVCTree(Tree).ResetDockZoneSizeStyle(ParentZone, zssMaximum, nil);
end
else
begin
if ZoneSizeStyle = zssMinimum then
TJvDockVCTree(Tree).ResetDockZoneSizeStyle(ParentZone, zssMaximum, Self)
else
if ZoneSizeStyle = zssMaximum then
begin
TJvDockVCTree(Tree).ResetDockZoneSizeStyle(ParentZone, zssNormal, Self);
TJvDockVCZone(ParentZone).DoSetChildSizeStyle(zssNormal);
end;
end;
Exit;
end;
case TJvDockVCTree(Tree).DockSiteOrientation of
doVertical:
TempSize := Tree.DockSite.Height;
doHorizontal:
TempSize := Tree.DockSite.Width;
else
raise Exception.CreateRes(@RsEInvalidDockSiteOrientationValue);
end;
if DockSize > TempSize - (ParentZone.VisibleChildCount - 1) * TJvDockVCTree(Tree).MinSize then
DockSize := TempSize - (ParentZone.VisibleChildCount - 1) * TJvDockVCTree(Tree).MinSize;
BorderWidth := TJvDockVCTree(Tree).BorderWidth;
TempSize := ParentZone.HeightWidth[ParentZone.Orientation] + BorderWidth;
if DockSize = 0 then
DockSize := TempSize div 2;
if BeforeClosestVisibleZone = nil then
begin
PrevShift := 0;
NextShift := (2 * Ord(Insert) - 1) * (DockSize + BorderWidth);
ZoneLimit := Ord(Insert) * (DockSize + BorderWidth);
if ParentZone.VisibleChildCount = 2 then
NextSibling.ZoneLimit := TempSize;
end
else
if AfterClosestVisibleZone = nil then
begin
PrevShift := (2 * Ord(Insert) - 1) * (DockSize + BorderWidth);
NextShift := 0;
begin
if ParentZone.ChildCount = 2 then
PrevSibling.ZoneLimit := TempSize - Ord(Insert) * PrevShift
else
PrevSibling.ZoneLimit := PrevSibling.ZoneLimit - PrevShift;
end;
ZoneLimit := TempSize;
end
else
begin
PrevShift := (2 * Ord(Insert) - 1) * Round((PrevSibling.ZoneLimit) *
(DockSize + BorderWidth) / (TempSize - Ord(not Insert) * (DockSize + BorderWidth)));
NextShift := (2 * Ord(Insert) - 1) * DockSize - PrevShift;
PrevSibling.ZoneLimit := PrevSibling.ZoneLimit - PrevShift;
ZoneLimit := Ord(Insert) * (DockSize + BorderWidth) + PrevSibling.ZoneLimit;
end;
if PrevShift <> 0 then
begin
with TJvDockVCTree(Tree) do
begin
ReplacementZone := PrevSibling;
try
if PrevSibling.ZoneLimit + PrevShift <> 0 then
ScaleBy := PrevSibling.ZoneLimit / (PrevSibling.ZoneLimit + PrevShift)
else
ScaleBy := 1;
ShiftScaleOrientation := ParentZone.Orientation;
if
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -