⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jvdockvcstyle.pas

📁 East make Tray Icon in delphi
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    Source.DropOnControl := JvDockManager.GetDockEdge(Source.EraseDockRect,
      Source.DragPos, DropAlign, Source.Control);
    Source.DropAlign := DropAlign;

    SysCaptionHeight := Ord(Source.Control.Floating) * JvDockGetSysCaptionHeight;

    PanelScreenRect := BoundsRect;
    MapWindowPoints(Parent.Handle, 0, PanelScreenRect, 2);

    if ((Align in [alTop, alBottom]) and
      (Source.DockRect.Right = PanelScreenRect.Right) and
      (Source.DockRect.Left = PanelScreenRect.Left)) or
      ((Align in [alLeft, alRight]) and
      (Source.DockRect.Top = PanelScreenRect.Top) and
      (Source.DockRect.Bottom = PanelScreenRect.Bottom)) then
      Exit;

    if ((Source.DropOnControl <> nil) and (Source.DropOnControl <> Source.Control)) and
      (Source.DropOnControl.HostDockSite <> Source.Control.HostDockSite) then
    begin
      if DropAlign in [alTop, alBottom] then
      begin
        if ((Source.Control.DockOrientation = doVertical) or (Source.Control.HostDockSite = nil)) then
        begin
          R := Source.DockRect;
          R.Bottom := Source.DockRect.Top + Source.Control.UndockHeight - SysCaptionHeight;
          Source.DockRect := R;
        end;
      end
      else
      if DropAlign in [alLeft, alRight] then
        if (Source.Control.DockOrientation = doHorizontal) or (Source.Control.HostDockSite = nil) then
        begin
          R := Source.DockRect;
          R.Right := Source.DockRect.Left + Source.Control.UndockWidth - SysCaptionHeight;
          Source.DockRect := R;
        end;
    end;
  end;
end;

procedure TJvDockVCPanel.CustomGetDockEdge(Source: TJvDockDragDockObject;
  MousePos: TPoint; var DropAlign: TAlign);
begin
end;

procedure TJvDockVCPanel.CustomGetSiteInfo(Source: TJvDockDragDockObject; Client: TControl;
  var InfluenceRect: TRect; MousePos: TPoint; var CanDock: Boolean);
begin
  GetWindowRect(Handle, InfluenceRect);
  with Client, JvGlobalDockManager.DragObject do
    case Self.Align of
      alTop:
        if MousePos.Y >= InfluenceRect.Top then
          InflateRect(InfluenceRect, 0,
            JvDockGetMinOffset(TBDockHeight, Height, MouseDeltaY));
      alBottom:
        if MousePos.Y <= InfluenceRect.Top then
          InflateRect(InfluenceRect, 0,
            JvDockGetMinOffset(TBDockHeight, Height, 1 - MouseDeltaY));
      alLeft:
        if MousePos.X >= InfluenceRect.Left then
          InflateRect(InfluenceRect,
            JvDockGetMinOffset(LRDockWidth, Width, MouseDeltaX), 0);
      alRight:
        if MousePos.X <= InfluenceRect.Left then
          InflateRect(InfluenceRect,
            JvDockGetMinOffset(LRDockWidth, Width, 1 - MouseDeltaX), 0);
    end;
  CanDock := IsDockable(Self, Client, Source.DropOnControl, Source.DropAlign);
end;

procedure TJvDockVCPanel.CustomPositionDockRect(Source: TJvDockDragDockObject; X, Y: Integer);
var
  R: TRect;
  BorderWidth: Integer;
  GrabberSize: Integer;
  PanelScreenRect: TRect;
  SysCaptionHeight: Integer;
  DockSize: Integer;

  procedure GetDockSize;
  begin
    if Align in [alLeft, alRight] then
    begin
      if (Source.Control.HostDockSite <> nil) and
        (Source.Control.HostDockSite <> Source.TargetControl) then
        DockSize := Source.Control.UndockHeight
      else
        DockSize := Source.Control.Height;
    end
    else
    begin
      if (Source.Control.HostDockSite <> nil) and
        (Source.Control.HostDockSite <> Source.TargetControl) then
        DockSize := Source.Control.UndockWidth
      else
        DockSize := Source.Control.Width;
    end;
  end;

  procedure SetMaxDockSize(Align: TAlign);
  begin
    if Align in [alLeft, alRight] then
    begin
      if R.Bottom - R.Top >= PanelScreenRect.Bottom - PanelScreenRect.Top then
      begin
        R.Top := PanelScreenRect.Top;
        R.Bottom := PanelScreenRect.Bottom;
      end;
    end
    else
    begin
      if R.Right - R.Left >= PanelScreenRect.Right - PanelScreenRect.Left then
      begin
        R.Left := PanelScreenRect.Left;
        R.Right := PanelScreenRect.Right;
      end;
    end;
  end;

begin
  if Source.Control.HostDockSite is TJvDockCustomPanel then
  begin
    BorderWidth := TJvDockCustomPanel(Source.Control.HostDockSite).JvDockManager.BorderWidth;
    GrabberSize := TJvDockCustomPanel(Source.Control.HostDockSite).JvDockManager.GrabberSize;
  end
  else
  begin
    BorderWidth := 0;
    GrabberSize := 0;
  end;

  PanelScreenRect := BoundsRect;
  MapWindowPoints(Parent.Handle, 0, PanelScreenRect, 2);

  SysCaptionHeight := Ord(Source.Control.Floating) * JvDockGetSysCaptionHeight;

  GetDockSize;

  with Source.Control do
  begin
    case Self.Align of
      alTop:
        begin
          R.TopLeft := Self.ClientToScreen(Point(0, 0));
          R.BottomRight := Self.ClientToScreen(Point(Self.Width, TBDockHeight));
          R.Top := R.Top + Y -
            JvDockGetMinOffset(TBDockHeight, Height + 2 * BorderWidth, Source.MouseDeltaY);
          R.Bottom := R.Top + TBDockHeight;
          if (Self.Height > 0) and (R.Top + TBDockHeight div 2 < PanelScreenRect.Bottom) and
            (R.Bottom - TBDockHeight div 2 > PanelScreenRect.Top) then
          begin
            R.Left := R.Left + X - Round((Width + 2 * BorderWidth + GrabberSize) * Source.MouseDeltaX);
            R.Right := R.Left + DockSize + 2 * BorderWidth + GrabberSize - SysCaptionHeight;
          end;
        end;
      alBottom:
        begin
          R.TopLeft := Self.ClientToScreen(Point(0, -TBDockHeight));
          R.BottomRight := Self.ClientToScreen(Point(Self.Width, 0));
          R.Top := R.Top + Y +
            JvDockGetMinOffset(TBDockHeight, Height + 2 * BorderWidth, 1 - Source.MouseDeltaY);
          R.Bottom := R.Top + TBDockHeight;
          if (Self.Height > 0) and (R.Top + TBDockHeight div 2 < PanelScreenRect.Bottom) and
            (R.Bottom - TBDockHeight div 2 > PanelScreenRect.Top) then
          begin
            R.Left := R.Left + X - Round((Width + 2 * BorderWidth + GrabberSize) * Source.MouseDeltaX);
            R.Right := R.Left + DockSize + 2 * BorderWidth + GrabberSize - SysCaptionHeight;
          end;
        end;
      alLeft:
        begin
          R.TopLeft := Self.ClientToScreen(Point(0, 0));
          R.BottomRight := Self.ClientToScreen(Point(LRDockWidth, Self.Height));
          R.Left := R.Left + X -
            JvDockGetMinOffset(LRDockWidth, Width + 2 * BorderWidth, Source.MouseDeltaX);
          R.Right := R.Left + LRDockWidth;
          if (Self.Width > 0) and ((R.Left + LRDockWidth div 2 < PanelScreenRect.Right) and
            (R.Right - LRDockWidth div 2 > PanelScreenRect.Left)) then
          begin
            R.Top := R.Top + Y - Round((Height + 2 * BorderWidth + GrabberSize) * Source.MouseDeltaY);
            R.Bottom := R.Top + DockSize + 2 * BorderWidth + GrabberSize - SysCaptionHeight;
          end;
        end;
      alRight:
        begin
          R.TopLeft := Self.ClientToScreen(Point(-LRDockWidth, 0));
          R.BottomRight := Self.ClientToScreen(Point(Self.Width, Self.Height));
          R.Left := R.Left + X +
            JvDockGetMinOffset(LRDockWidth, Width + 2 * BorderWidth, 1 - Source.MouseDeltaX);
          R.Right := R.Left + LRDockWidth;
          if (Self.Width > 0) and (R.Left + LRDockWidth div 2 > PanelScreenRect.Left) and
            (R.Right - LRDockWidth div 2 < PanelScreenRect.Right) then
          begin
            R.Top := R.Top + Y - Round((Height + 2 * BorderWidth + GrabberSize) * Source.MouseDeltaY);
            R.Bottom := R.Top + DockSize + 2 * BorderWidth + GrabberSize - SysCaptionHeight;
          end;
        end;
    end;
  end;
  SetMaxDockSize(Align);
  Inc(R.Left);
  Source.DockRect := R;
end;

function TJvDockVCPanel.CustomUnDock(Source: TJvDockDragDockObject; NewTarget: TWinControl;
  Client: TControl): Boolean;
var
  DropAlign: TAlign;
  MousePos: TPoint;
begin
  if (NewTarget = nil) or (NewTarget = Client.HostDockSite) then
  begin
    DropAlign := Source.DropAlign;
    Source.DropOnControl := JvDockManager.GetDockEdge(
      Source.DockRect, Source.DragPos, DropAlign, Source.Control);
    Source.DropAlign := DropAlign;
  end;
  MousePos := ScreenToClient(Source.DragPos);
  if ((Align in [alTop, alBottom]) and ((0 > MousePos.X) or (Width < MousePos.X))) or
    ((Align in [alLeft, alRight]) and ((0 > MousePos.Y) or (Height < MousePos.Y))) or
    (Source.CtrlDown) or Source.Floating then
    Result := inherited CustomUnDock(Source, NewTarget, Client)
  else
  if Source.DropOnControl <> Source.Control then
    Result := inherited CustomUnDock(Source, NewTarget, Client)
  else
    Result := True;
end;

function TJvDockVCPanel.GetDockEdge(MousePos: TPoint): TAlign;
begin
  Result := inherited GetDockEdge(MousePos);
end;

//=== { TJvDockVCSplitter } ==================================================

constructor TJvDockVCSplitter.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FOldSize := MinSize;
end;

function TJvDockVCSplitter.DoCanResize(var NewSize: Integer): Boolean;
var
  DockPanel: TJvDockPanel;
  Limit, MinSize: Integer;
begin
  Result := inherited DoCanResize(NewSize);
  if Result and (FOldSize > NewSize) then
  begin
    DockPanel := DockServer.DockPanelWithAlign[Align];
    if DockPanel = nil then
    begin
      Result := False;
      Exit;
    end;
    Limit := DockPanel.JvDockManager.GetDockClientLimit(JvDockGetControlOrient(DockPanel),
      Align in [alLeft, alTop]);
    MinSize := DockPanel.JvDockManager.MinSize;

    if DockPanel.Align in [alLeft, alTop] then
    begin
      if NewSize < Limit + MinSize then
        Result := False;
    end
    else
    begin
      if NewSize < JvDockGetControlSize(DockPanel) - Limit + MinSize then
        Result := False;
    end;
  end;
  if Result then
    FOldSize := NewSize;
end;

procedure TJvDockVCSplitter.MouseUp(Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  DockPanel: TJvDockPanel;
begin
  DockPanel := DockServer.DockPanelWithAlign[Align];
  if Assigned(DockPanel) then
  begin
    DockPanel.JvDockManager.BeginResizeDockSite;
    try
      inherited MouseUp(Button, Shift, X, Y);
    finally
      DockPanel.JvDockManager.EndResizeDockSite;
    end;
  end;
end;

procedure TJvDockVCSplitter.Paint;
var
  Rect: TRect;
begin
  Rect := ClientRect;
  Inc(Rect.Right, 2);
  case Align of
    alLeft:
      InflateRect(Rect, 0, 2);
    alRight:
      begin
        OffsetRect(Rect, -1, 0);
        InflateRect(Rect, 0, 2);
      end;
    alTop:
      begin
        Inc(Rect.Bottom, 2);
        InflateRect(Rect, 2, 0);
      end;
    alBottom:
      begin
        Dec(Rect.Top, 2);
        InflateRect(Rect, 2, 1);
      end;
  end;
  Canvas.Brush.Color := Color;
  DrawFrameControl(Canvas.Handle, Rect, DFC_BUTTON, DFCS_BUTTONPUSH or DFCS_ADJUSTRECT);
end;

//=== { TJvDockVCStyle } =====================================================

constructor TJvDockVCStyle.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  DockPanelClass := TJvDockVCPanel;
  DockSplitterClass := TJvDockVCSplitter;
  ConjoinPanelClass := TJvDockVCConjoinPanel;
  TabDockClass := TJvDockVCTabPageControl;
  DockPanelTreeClass := TJvDockVCTree;
  DockPanelZoneClass := TJvDockVCZone;
  ConjoinPanelTreeClass := TJvDockVCTree;
  ConjoinPanelZoneClass := TJvDockVCZone;
  ConjoinServerOptionClass := TJvDockVCConjoinServerOption;
  TabServerOptionClass := TJvDockVCTabServerOption;
end;

procedure TJvDockVCStyle.AssignConjoinServerOption(APanel: TJvDockCustomPanel);
begin
  inherited AssignConjoinServerOption(APanel);
  if ConjoinServerOption is TJvDockVCConjoinServerOption then
    APanel.JvDockManager.BorderWidth := TJvDockVCConjoinServerOption(ConjoinServerOption).BorderWidth;
end;

function TJvDockVCStyle.CanSetEachOtherDocked(ADockBaseControl: TJvDockBaseControl): Boolean;
begin
  Result := False;
end;

procedure TJvDockVCStyle.CreateConjoinServerOption(var Option: TJvDockBasicConjoinServerOption);
begin
  Option := TJvDockVCConjoinServerOption.Create(Self);
end;

procedure TJvDockVCStyle.CreateTabServerOption(var Option: TJvDockBasicTabServerOption);
begin
  Option := TJvDockVCTabServerOption.Create(Self);
end;

procedure TJvDockVCStyle.FormGetDockEdge(DockClient: TJvDockClient;
  Source: TJvDockDragDockObject; MousePos: TPoint; var DropAlign: TAlign);
begin
end;

procedure TJvDockVCStyle.FormStartDock(DockClient: TJvDockClient;
  var Source: TJvDockDragDockObject);
begin
  inherited FormStartDock(DockClient, Source);
  Source := TJvDockVCDragDockObject.Create(DockClient.ParentForm);
end;

{$IFNDEF USEJVCL}
function TJvDockVCStyle.GetControlName: string;
begin
  Result := Format(RsDockLikeVCStyle, [inherited GetControlName]);
end;
{$ENDIF !USEJVCL}

procedure TJvDockVCStyle.SetDockBaseControl(IsCreate: Boolean;
  DockBaseControl: TJvDockBaseControl);
var
  ADockClient: TJvDockClient;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -