📄 jvdockinfo.pas
字号:
finally
FAppStorage.Path := OldPath;
end;
end;
end;
inherited ScanTreeZone(TreeZone);
end;
{$ELSE}
procedure TJvDockInfoTree.ScanTreeZone(TreeZone: TJvDockBaseZone);
var
I: Integer;
begin
// FJvDockInfoStyle := isReadFileInfo;
if (FJvDockInfoStyle = isReadFileInfo) or (FJvDockInfoStyle = isReadRegInfo) then
begin
for I := 0 to TreeZone.GetChildCount - 1 do
with TJvDockInfoZone(TreeZone.GetChildZone(I)) do
DockControl := FindDockForm(DockFormName);
SetDockControlInfo(TJvDockInfoZone(TreeZone));
end
else
if FJvDockInfoStyle = isWriteFileInfo then
begin
if TreeZone <> TopTreeZone then
with TJvDockInfoZone(TreeZone), DockInfoIni do
begin
WriteString(DockFormName, 'ParentName', ParentName);
WriteInteger(DockFormName, 'DockLeft', DockRect.Left);
WriteInteger(DockFormName, 'DockTop', DockRect.Top);
WriteInteger(DockFormName, 'DockRight', DockRect.Right);
WriteInteger(DockFormName, 'DockBottom', DockRect.Bottom);
WriteString(DockFormName, 'LastDockSiteName', LastDockSiteName);
WriteInteger(DockFormName, 'UnDockLeft', UnDockLeft);
WriteInteger(DockFormName, 'UnDockTop', UnDockTop);
WriteInteger(DockFormName, 'LRDockWidth', LRDockWidth);
WriteInteger(DockFormName, 'TBDockHeight', TBDockHeight);
WriteInteger(DockFormName, 'UnDockWidth', UnDockWidth);
WriteInteger(DockFormName, 'UnDockHeight', UnDockHeight);
WriteInteger(DockFormName, 'VSPaneWidth', VSPaneWidth);
WriteBool(DockFormName, 'Visible', Visible);
WriteInteger(DockFormName, 'BorderStyle', Integer(BorderStyle));
WriteInteger(DockFormName, 'WindowState', Integer(WindowState));
WriteInteger(DockFormName, 'FormStyle', Integer(FormStyle));
WriteInteger(DockFormName, 'DockFormStyle', Integer(DockFormStyle));
WriteBool(DockFormName, 'CanDocked', CanDocked);
WriteBool(DockFormName, 'EachOtherDocked', EachOtherDocked);
WriteBool(DockFormName, 'LeftDocked', LeftDocked);
WriteBool(DockFormName, 'TopDocked', TopDocked);
WriteBool(DockFormName, 'RightDocked', RightDocked);
WriteBool(DockFormName, 'BottomDocked', BottomDocked);
WriteBool(DockFormName, 'CustomDocked', CustomDocked); {NEW!}
WriteString(DockFormName, 'DockClientData', DockClientData);
end;
end
else
if FJvDockInfoStyle = isWriteRegInfo then
begin
if TreeZone <> TopTreeZone then
with TJvDockInfoZone(TreeZone), DockInfoReg do
begin
OpenKey(FRegName, True);
WriteString('FormNames', ReadString('FormNames') + DockFormName + '\');
OpenKey(FRegName + '\' + DockFormName, True);
WriteString('ParentName', ParentName);
WriteInteger('DockLeft', DockRect.Left);
WriteInteger('DockTop', DockRect.Top);
WriteInteger('DockRight', DockRect.Right);
WriteInteger('DockBottom', DockRect.Bottom);
WriteString('LastDockSiteName', LastDockSiteName);
WriteInteger('UnDockLeft', UnDockLeft);
WriteInteger('UnDockTop', UnDockTop);
WriteInteger('LRDockWidth', LRDockWidth);
WriteInteger('TBDockHeight', TBDockHeight);
WriteInteger('UnDockWidth', UnDockWidth);
WriteInteger('UnDockHeight', UnDockHeight);
WriteInteger('VSPaneWidth', VSPaneWidth);
WriteBool('Visible', Visible);
WriteInteger('BorderStyle', Integer(BorderStyle));
WriteInteger('FormStyle', Integer(FormStyle));
WriteInteger('WindowState', Integer(WindowState));
WriteInteger('DockFormStyle', Integer(DockFormStyle));
WriteBool('CanDocked', CanDocked);
WriteBool('EachOtherDocked', EachOtherDocked);
WriteBool('LeftDocked', LeftDocked);
WriteBool('TopDocked', TopDocked);
WriteBool('RightDocked', RightDocked);
WriteBool('BottomDocked', BottomDocked);
WriteBool('CustomDocked', CustomDocked); {NEW!}
WriteString('DockClientData', DockClientData);
CloseKey;
end;
end;
inherited ScanTreeZone(TreeZone);
end;
{$ENDIF USEJVCL}
procedure TJvDockInfoTree.SetDockControlInfo(ATreeZone: TJvDockInfoZone);
var
DockBaseControl: TJvDockBaseControl;
Host: TWinControl;
begin
with ATreeZone do
begin
if DockFormName = '' then
Exit;
Host := FindDockHost(DockFormName);
if (Host = nil) and (ATreeZone.GetChildControlCount > 1) then
Host := CreateHostControl(ATreeZone);
if (Host <> nil) and (DockClientData <> '') and (FDataStream <> nil) then
begin
FDataStream.Clear;
JvDockStringToStreamData(FDataStream, DockClientData);
FDataStream.Position := 0;
if Host is TJvDockTabHostForm then
begin
with TJvDockTabHostForm(Host).PageControl do
begin
DisableAlign;
try
LoadFromStream(FDataStream);
finally
EnableAlign;
end;
end;
end
else
if Host is TJvDockConjoinHostForm then
begin
with TJvDockConjoinHostForm(Host).Panel do
begin
DisableAlign;
try
DockManager.LoadFromStream(FDataStream);
finally
EnableAlign;
end;
end;
end
else
if Host is TJvDockPanel then
begin
with TJvDockPanel(Host) do
begin
DisableAlign;
try
DockManager.LoadFromStream(FDataStream);
finally
EnableAlign;
end;
end;
end;
end;
if Host <> nil then
begin
SetDockInfoFromNodeToControl(Host);
DockBaseControl := FindDockBaseControl(Host);
if DockBaseControl <> nil then
SetDockInfoFromNodeToDockControl(DockBaseControl);
end;
end;
end;
{$IFDEF USEJVCL}
procedure TJvDockInfoTree.WriteInfoToAppStorage;
begin
AppStorage.BeginUpdate;
try
AppStorage.DeleteSubTree(AppStoragePath);
try
FJvDockInfoStyle := isJVCLWriteInfo;
MiddleScanTree(TopTreeZone);
finally
FJvDockInfoStyle := isNone;
end;
finally
AppStorage.EndUpdate;
end;
end;
{$ENDIF USEJVCL}
procedure TJvDockInfoTree.WriteInfoToIni;
var
Sections: TStringList;
I: Integer;
begin
Sections := TStringList.Create;
try
DockInfoIni.ReadSections(Sections);
for I := 0 to Sections.Count - 1 do
DockInfoIni.EraseSection(Sections[I]);
finally
Sections.Free;
end;
{$IFDEF USEJVCL}
FJvDockInfoStyle := isJVCLWriteInfo;
{$ELSE}
FJvDockInfoStyle := isWriteFileInfo;
{$ENDIF USEJVCL}
MiddleScanTree(TopTreeZone);
FJvDockInfoStyle := isNone;
end;
procedure TJvDockInfoTree.WriteInfoToReg(const RegName: string);
begin
try
if DockInfoReg.OpenKey(RegName, False) then
DockInfoReg.DeleteKey(RegName);
DockInfoReg.CreateKey(RegName);
DockInfoReg.CloseKey;
FRegName := RegName;
FJvDockInfoStyle := isWriteRegInfo;
MiddleScanTree(TopTreeZone);
FJvDockInfoStyle := isNone;
finally
DockInfoReg.CloseKey;
end;
end;
//=== { TJvDockInfoZone } ====================================================
function TJvDockInfoZone.GetChildControlCount: Integer;
var
Zone: TJvDockBaseZone;
begin
Result := 0;
if ChildZone <> nil then
begin
Inc(Result);
Zone := ChildZone;
while Zone.NextSibling <> nil do
begin
Zone := Zone.NextSibling;
if TJvDockInfoZone(Zone).DockControl <> nil then
Inc(Result);
end;
end;
end;
procedure TJvDockInfoZone.SetDockInfoFromControlToNode(Control: TControl);
begin
DockRect := Control.BoundsRect;
UnDockWidth := Control.UnDockWidth;
UnDockHeight := Control.UnDockHeight;
if Control is TJvDockVSPopupPanel then
Control.Visible := False
else
Visible := Control.Visible;
if Control is TForm then
begin
BorderStyle := TForm(Control).BorderStyle;
FormStyle := TForm(Control).FormStyle;
WindowState := TForm(Control).WindowState;
LRDockWidth := Control.LRDockWidth;
TBDockHeight := Control.TBDockHeight;
end;
end;
procedure TJvDockInfoZone.SetDockInfoFromDockControlToNode(DockControl: TJvDockBaseControl);
function GetLastDockSiteName(AControl: TControl): string;
begin
Result := RsDockCannotFindWindow;
if AControl <> nil then
begin
if AControl.Parent is TJvDockableForm then
Result := AControl.Parent.Name
else
if AControl is TJvDockPanel then
Result := AControl.Parent.Name + RsDockJvDockInfoSplitter + AControl.Name;
end;
end;
begin
CanDocked := DockControl.EnableDock;
EachOtherDocked := DockControl.EachOtherDock;
LeftDocked := DockControl.LeftDock;
TopDocked := DockControl.TopDock;
RightDocked := DockControl.RightDock;
BottomDocked := DockControl.BottomDock;
CustomDocked := DockControl.CustomDock; {NEW!}
if DockControl is TJvDockClient then
begin
VSPaneWidth := TJvDockClient(DockControl).VSPaneWidth;
UnDockLeft := TJvDockClient(DockControl).UnDockLeft;
UnDockTop := TJvDockClient(DockControl).UnDockTop;
LastDockSiteName := GetLastDockSiteName(TJvDockClient(DockControl).LastDockSite);
end
else
VSPaneWidth := 0;
end;
{ When restoring a Control (form) properties when loading layout, this sets one form's properties.}
procedure TJvDockInfoZone.SetDockInfoFromNodeToControl(Control: TControl);
var
DS: TJvDockServer;
procedure SetPopupPanelSize(PopupPanel: TJvDockVSPopupPanel);
begin
end;
procedure SetDockSiteSize(DockSite: TJvDockPanel);
begin
if DockSite.Align in [alTop, alBottom] then
DockSite.JvDockManager.DockSiteSize := DockRect.Bottom - DockRect.Top
else
DockSite.JvDockManager.DockSiteSize := DockRect.Right - DockRect.Left;
end;
begin
if (ParentName = '') or ((Control is TJvDockPanel) and
(TJvDockPanel(Control).VisibleDockClientCount > 0)) then
begin
TWinControl(Control).DisableAlign;
try
if Control is TForm then
begin
TForm(Control).BorderStyle := BorderStyle;
TForm(Control).FormStyle := FormStyle;
if WindowState = wsNormal then
Control.BoundsRect := DockRect;
TForm(Control).WindowState := WindowState;
end
else
begin
if Control is TJvDockVSPopupPanel then
SetPopupPanelSize(Control as TJvDockVSPopupPanel)
else
SetDockSiteSize(Control as TJvDockPanel);
end;
DS := FindDockServer(Control);
if DS <> nil then
begin
DS.GetClientAlignControl(alTop);
DS.GetClientAlignControl(alBottom);
DS.GetClientAlignControl(alLeft);
DS.GetClientAlignControl(alRight);
end;
finally
TWinControl(Control).EnableAlign;
end;
end;
Control.Visible := Visible;
Control.LRDockWidth := LRDockWidth;
Control.TBDockHeight := TBDockHeight;
Control.UnDockHeight := UnDockHeight;
Control.UnDockWidth := UnDockWidth;
end;
{ Restores settings in the TjvDockClient inside the form, when loading docking layout. }
procedure TJvDockInfoZone.SetDockInfoFromNodeToDockControl(DockControl: TJvDockBaseControl);
function GetLastDockSite(const AName: string): TWinControl;
begin
Result := FindDockPanel(AName);
if Result = nil then
begin
Result := FindDockForm(AName);
if Result is TJvDockableForm then
Result := TJvDockableForm(Result).DockableControl;
end;
end;
begin
if DockControl is TJvDockClient then
begin
TJvDockClient(DockControl).UnDockLeft := UnDockLeft;
TJvDockClient(DockControl).UnDockTop := UnDockTop;
TJvDockClient(DockControl).LastDockSite := GetLastDockSite(LastDockSiteName);
if Visible then
begin
TJvDockClient(DockControl).ParentVisible := False;
TJvDockClient(DockControl).MakeShowEvent;
end
else
TJvDockClient(DockControl).MakeHideEvent;
TJvDockClient(DockControl).VSPaneWidth := VSPaneWidth;
end;
DockControl.EnableDock := CanDocked;
DockControl.LeftDock := LeftDocked;
DockControl.TopDock := TopDocked;
DockControl.BottomDock := BottomDocked;
DockControl.CustomDock := CustomDocked; {NEW!}
DockControl.RightDock := RightDocked;
end;
{$IFDEF USEJVCL}
{$IFDEF UNITVERSIONING}
initialization
RegisterUnitVersion(HInstance, UnitVersioning);
finalization
UnregisterUnitVersion(HInstance);
{$ENDIF UNITVERSIONING}
{$ENDIF USEJVCL}
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -