📄 jvdockvcstyle.pas
字号:
begin
if DockBaseControl is TJvDockClient then
begin
ADockClient := TJvDockClient(DockBaseControl);
if IsCreate then
begin
FOldEachOtherDock := ADockClient.EachOtherDock;
ADockClient.EachOtherDock := False;
ADockClient.DirectDrag := True;
end
else
ADockClient.EachOtherDock := FOldEachOtherDock;
end;
end;
//=== { TJvDockVCTree } ======================================================
constructor TJvDockVCTree.Create(DockSite: TWinControl; DockZoneClass: TJvDockZoneClass;
ADockStyle: TComponent);
begin
inherited Create(DockSite, DockZoneClass, ADockStyle);
Version := RsDockVCDockTreeVersion;
BorderWidth := 4;
MinSize := 20;
end;
procedure TJvDockVCTree.BeginDrag(Control: TControl; Immediate: Boolean; Threshold: Integer);
begin
JvGlobalDockManager.BeginDrag(Control, True, 0);
end;
procedure TJvDockVCTree.CalcSplitterPos;
var
TestLimit: Integer;
TempPos: TPoint;
begin
TempPos := SizePos;
if SizingZone.ParentZone.Orientation = doHorizontal then
begin
TestLimit := SizingZone.Top + MinSize;
if TempPos.Y <= TestLimit then
begin
if DockSiteOrientation = doVertical then
begin
if TempPos.Y <= (SizingZone.VisiblePrevSiblingCount + 1) * MinSize - SplitterWidth div 2 then
TempPos.Y := (SizingZone.VisiblePrevSiblingCount + 1) * MinSize - SplitterWidth div 2;
end
else
TempPos.Y := TestLimit;
end;
TestLimit := GetSplitterLimit(SizingZone, False, True) - MinSize;
if TempPos.Y >= TestLimit then
begin
if DockSiteOrientation = doVertical then
begin
if TempPos.Y >= DockSiteSizeAlternate - SizingZone.VisibleNextSiblingCount * MinSize then
TempPos.Y := DockSiteSizeAlternate - SizingZone.VisibleNextSiblingCount * MinSize;
end
else
TempPos.Y := TestLimit;
end;
end
else
begin
TestLimit := SizingZone.Left + MinSize;
if TempPos.X <= TestLimit then
begin
if DockSiteOrientation = doHorizontal then
begin
if TempPos.X <= (SizingZone.VisiblePrevSiblingCount + 1) * MinSize - SplitterWidth div 2 then
TempPos.X := (SizingZone.VisiblePrevSiblingCount + 1) * MinSize - SplitterWidth div 2;
end
else
TempPos.X := TestLimit;
end;
TestLimit := GetSplitterLimit(SizingZone, False, True) - MinSize;
if TempPos.X >= TestLimit then
begin
if DockSiteOrientation = doHorizontal then
begin
if TempPos.X >= DockSiteSizeAlternate - SizingZone.VisibleNextSiblingCount * MinSize then
TempPos.X := DockSiteSizeAlternate - SizingZone.VisibleNextSiblingCount * MinSize;
end
else
TempPos.X := TestLimit;
end;
end;
SizePos := TempPos;
end;
procedure TJvDockVCTree.ControlVisibilityChanged(Control: TControl; Visible: Boolean);
begin
inherited ControlVisibilityChanged(Control, Visible);
end;
procedure TJvDockVCTree.CustomLoadZone(Stream: TStream; var Zone: TJvDockZone);
begin
Stream.Read(TJvDockVCZone(Zone).FZoneSizeStyle, SizeOf(TJvDockZoneSizeStyle));
inherited CustomLoadZone(Stream, Zone);
end;
procedure TJvDockVCTree.CustomSaveZone(Stream: TStream; Zone: TJvDockZone);
begin
Stream.Write(TJvDockVCZone(Zone).FZoneSizeStyle, SizeOf(TJvDockZoneSizeStyle));
inherited CustomSaveZone(Stream, Zone);
end;
function TJvDockVCTree.DoLButtonDown(var Msg: TWMMouse;
var Zone: TJvDockZone; out HTFlag: Integer): Boolean;
var
TempZone: TJvDockVCZone;
Active: Boolean;
begin
Result := inherited DoLButtonDown(Msg, Zone, HTFlag);
if (Zone <> nil) and (HTFlag = HTEXPAND) then
begin
TempZone := TJvDockVCZone(Zone);
Active := ((TempZone.ParentZone.Orientation <> DockSiteOrientation) and
(TempZone.ParentZone.VisibleChildCount >= 2));
if Active then
begin
TempZone.ExpandButtonDown := True;
TempZone.MouseDown := True;
FExpandBtnZone := TempZone;
DockSite.Invalidate;
end;
end;
end;
procedure TJvDockVCTree.DoLButtonUp(var Msg: TWMMouse;
var Zone: TJvDockZone; out HTFlag: Integer);
var
TempZone: TJvDockVCZone;
begin
inherited DoLButtonUp(Msg, Zone, HTFlag);
if (SizingZone = nil) and (FExpandBtnZone <> nil) then
begin
FExpandBtnZone := nil;
if (Zone <> nil) and (HTFlag = HTEXPAND) then
begin
TempZone := TJvDockVCZone(Zone);
TempZone.ExpandButtonDown := False;
if TempZone.ZoneSizeStyle in [zssMaximum] then
TJvDockVCZone(TempZone.ParentZone).DoSetChildSizeStyle(zssNormal)
else
begin
TJvDockVCZone(TempZone.ParentZone).DoSetChildSizeStyle(zssMinimum);
TempZone.ZoneSizeStyle := zssMaximum;
end;
ResetDockZoneSizeStyle(TempZone.ParentZone, TempZone.ZoneSizeStyle, nil);
DockSite.Invalidate;
end;
end;
end;
procedure TJvDockVCTree.DoMouseMove(var Msg: TWMMouse;
var Zone: TJvDockZone; out HTFlag: Integer);
var
TempZone: TJvDockVCZone;
begin
inherited DoMouseMove(Msg, Zone, HTFlag);
if SizingZone = nil then
begin
TempZone := TJvDockVCZone(Zone);
if ((TempZone <> nil) and (TempZone.ExpandButtonDown <> (HTFlag = HTEXPAND)) and
((FExpandBtnZone = TempZone) and FExpandBtnZone.MouseDown)) then
begin
TempZone.ExpandButtonDown := (HTFlag = HTEXPAND) and FExpandBtnZone.MouseDown;
DockSite.Invalidate;
end;
end;
end;
procedure TJvDockVCTree.DoOtherHint(Zone: TJvDockZone;
HTFlag: Integer; var HintStr: string);
begin
inherited DoOtherHint(Zone, HTFlag, HintStr);
if HTFlag = HTEXPAND then
HintStr := RsDockVCDockTreeExpandBtnHint;
end;
procedure TJvDockVCTree.DrawDockGrabber(Control: TControl; const ARect: TRect);
var
VCDockZone: TJvDockVCZone;
DrawRect: TRect;
{$IFDEF JVCLThemesEnabled}
Details: TThemedElementDetails;
CurrentThemeTypeBtn: TThemedWindow;
CurrentThemeTypeSB: TThemedScrollBar;
{$ENDIF JVCLThemesEnabled}
procedure DrawCloseButton(Left, Top: Integer);
var
ADockClient: TJvDockClient;
begin
if VCDockZone <> nil then
begin
ADockClient := FindDockClient(Control);
if (ADockClient <> nil) and not ADockClient.EnableCloseButton then
Exit;
{$IFDEF JVCLThemesEnabled}
if ThemeServices.ThemesAvailable and ThemeServices.ThemesEnabled then
begin
CurrentThemeTypeBtn := twSmallCloseButtonNormal;
if VCDockZone.CloseBtnDown then
CurrentThemeTypeBtn := twSmallCloseButtonPushed;
Details := ThemeServices.GetElementDetails(CurrentThemeTypeBtn);
ThemeServices.DrawElement(Canvas.Handle, Details, Rect(Left, Top,
Left + ButtonWidth, Top + ButtonHeight));
end
else
{$ENDIF JVCLThemesEnabled}
DrawFrameControl(Canvas.Handle, Rect(Left, Top, Left + ButtonWidth,
Top + ButtonHeight), DFC_CAPTION, DFCS_CAPTIONCLOSE or Ord(VCDockZone.CloseBtnDown) * DFCS_PUSHED);
end;
end;
procedure DrawExpendBotton(Left, Top: Integer);
const
{$IFDEF COMPILER6_UP}
ArrowOrient: array [TAlign] of DWORD =
(0, DFCS_SCROLLUP, DFCS_SCROLLDOWN, DFCS_SCROLLLEFT, DFCS_SCROLLRIGHT, 0, 0);
{$IFDEF JVCLThemesEnabled}
ArrowOrientTheme: array [TAlign] of TThemedScrollBar =
(tsScrollBarDontCare, tsArrowBtnUpNormal, tsArrowBtnDownNormal, tsArrowBtnLeftNormal,
tsArrowBtnRightNormal, tsScrollBarDontCare, tsScrollBarDontCare);
{$ENDIF JVCLThemesEnabled}
{$ELSE}
ArrowOrient: array [TAlign] of DWORD =
(0, DFCS_SCROLLUP, DFCS_SCROLLDOWN, DFCS_SCROLLLEFT, DFCS_SCROLLRIGHT, 0);
{$IFDEF JVCLThemesEnabled}
ArrowOrientTheme: array [TAlign] of TThemedScrollBar =
(tsScrollBarDontCare, tsArrowBtnUpNormal, tsArrowBtnDownNormal, tsArrowBtnLeftNormal,
tsArrowBtnRightNormal, tsScrollBarDontCare);
{$ENDIF JVCLThemesEnabled}
{$ENDIF COMPILER6_UP}
CurrArrow: array [Boolean, TDockOrientation] of TAlign =
((alNone, alLeft, alTop), (alNone, alRight, alBottom));
var
InActive: Boolean;
IsMaximum: Boolean;
begin
if VCDockZone <> nil then
begin
InActive := not ((VCDockZone.ParentZone.Orientation <> DockSiteOrientation) and
(VCDockZone.ParentZone.VisibleChildCount >= 2));
IsMaximum := VCDockZone.ZoneSizeStyle in [zssMaximum];
{$IFDEF JVCLThemesEnabled}
if ThemeServices.ThemesAvailable and ThemeServices.ThemesEnabled then
begin
CurrentThemeTypeSB := ArrowOrientTheme[CurrArrow[IsMaximum, DockSiteOrientation]];
if VCDockZone.ExpandButtonDown then
CurrentThemeTypeSB := TThemedScrollBar(Ord(CurrentThemeTypeSB) + 2);
if InActive then
CurrentThemeTypeSB := TThemedScrollBar(Ord(CurrentThemeTypeSB) + 3);
Details := ThemeServices.GetElementDetails(CurrentThemeTypeSB);
ThemeServices.DrawElement(Canvas.Handle, Details, Rect(Left, Top, Left + ButtonWidth, Top + ButtonHeight));
end
else
{$ENDIF JVCLThemesEnabled}
DrawFrameControl(Canvas.Handle, Rect(Left, Top, Left + ButtonWidth,
Top + ButtonHeight), DFC_SCROLL,
ArrowOrient[CurrArrow[IsMaximum, DockSiteOrientation]] +
Cardinal(Ord(InActive)) * DFCS_INACTIVE +
Cardinal(Ord(VCDockZone.ExpandButtonDown)) * DFCS_PUSHED);
end;
end;
procedure DrawGrabberLine(Left, Top, Right, Bottom: Integer);
begin
if (Left >= Right) or (Top >= Bottom) then
Exit;
with Canvas do
begin
Pen.Color := clBtnHighlight;
MoveTo(Right, Top);
LineTo(Left, Top);
LineTo(Left, Bottom);
Pen.Color := clBtnShadow;
LineTo(Right, Bottom);
LineTo(Right, Top - 1);
end;
end;
begin
VCDockZone := TJvDockVCZone(FindControlZone(Control));
DrawRect := ARect;
Canvas.Brush.Color := TWinControlAccessProtected(DockSite).Color;
Canvas.FillRect(DrawRect);
with ARect do
case GrabbersPosition of
gpLeft:
begin
DrawExpendBotton(Left + BorderWidth + LeftOffset,
Top + TopOffset + ButtonHeight + ButtonSplitter + BorderWidth);
DrawCloseButton(Left + BorderWidth + LeftOffset, Top + TopOffset + BorderWidth);
DrawGrabberLine(Left + BorderWidth + LeftOffset + 3,
Top + 2 * ButtonHeight + TopOffset + ButtonSplitter + BottomOffset + BorderWidth + 3,
Left + BorderWidth + LeftOffset + 5, Bottom - BorderWidth - 2);
DrawGrabberLine(Left + BorderWidth + LeftOffset + 7,
Top + 2 * ButtonHeight + TopOffset + ButtonSplitter + BottomOffset + BorderWidth + 3,
Left + BorderWidth + LeftOffset + 9, Bottom - BorderWidth - 2);
end;
gpTop:
begin
DrawExpendBotton(Right - LeftOffset - 2 * ButtonWidth - ButtonSplitter - BorderWidth,
Top + TopOffset + BorderWidth);
DrawCloseButton(Right - LeftOffset - ButtonWidth - BorderWidth, Top + TopOffset + BorderWidth);
DrawGrabberLine(Left + BorderWidth, Top + BorderWidth + TopOffset + 3,
Right - 2 * ButtonWidth - RightOffset - ButtonSplitter - LeftOffset - BorderWidth - 3,
Top + BorderWidth + TopOffset + 5);
DrawGrabberLine(Left + BorderWidth, Top + BorderWidth + TopOffset + 7,
Right - 2 * ButtonWidth - RightOffset - ButtonSplitter - LeftOffset - BorderWidth - 3,
Top + BorderWidth + TopOffset + 9);
end;
gpBottom:
begin
end;
gpRight:
begin
end;
end;
end;
procedure TJvDockVCTree.DrawDockSiteRect;
var
Rect: TRect;
begin
inherited DrawDockSiteRect;
Rect := DockSite.ClientRect;
InflateRect(Rect, BorderWidth, 0);
if DockSite.Align = alTop then
Inc(Rect.Bottom, BorderWidth)
else
if DockSite.Align = alBottom then
Dec(Rect.Top, BorderWidth);
Frame3D(Canvas, Rect, clBtnShadow, clBtnHighlight, 1);
Frame3D(Canvas, Rect, clBtnHighlight, clBtnShadow, 1);
Canvas.Pen.Color := clBlack;
if DockSite.Align = alRight then
begin
Canvas.MoveTo(0, 0);
Canvas.LineTo(0, DockSite.Height);
end
else
if DockSite.Align = alBottom then
begin
Canvas.MoveTo(0, 0);
Canvas.LineTo(DockSite.Width, 0);
end;
end;
procedure TJvDockVCTree.DrawSplitterRect(const ARect: TRect);
var
Rect: TRect;
begin
inherited DrawSplitterRect(ARect);
Rect := ARect;
InflateRect(Rect, 1, 1);
DrawFrameControl(Canvas.Handle, Rect, DFC_BUTTON, DFCS_BUTTONPUSH or DFCS_ADJUSTRECT);
end;
procedure TJvDockVCTree.GetCaptionRect(var Rect: TRect);
begin
case GrabbersPosition of
gpTop:
Rect.Bottom := Rect.Top + GrabberSize + 2;
gpLeft:
Rect.Right := Rect.Left + GrabberSize + 2;
end;
end;
function TJvDockVCTree.GetDockAlign(Client: TControl; var DropCtl: TControl): TAlign;
begin
Result := inherited GetDockAlign(Client, DropCtl);
case DockSite.Align of
alLeft, alRight:
if (Result in [alLeft, alRight]) and (DropCtl <> nil) then
DropCtl := nil;
alTop, alBottom:
if (Result in [alTop, alBottom]) and (DropCtl <> nil) then
DropCtl := nil;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -