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

📄 jvdockvcstyle.pas

📁 East make Tray Icon in delphi
💻 PAS
📖 第 1 页 / 共 5 页
字号:
  end;
end;

function TJvDockVCTree.GetDockEdge(DockRect: TRect;
  MousePos: TPoint; var DropAlign: TAlign; Control: TControl): TControl;
var
  Zone: TJvDockZone;
  TempOrient: TDockOrientation;
begin
  inherited GetDockEdge(DockRect, MousePos, DropAlign, Control);

  MapWindowPoints(0, DockSite.Handle, DockRect, 2);
  InitDockHeightWidth(0, DockSite.Height, DockSite.Width);
  InitDockRectangles(DockRect);

  TempOrient := DockSiteOrientation;
  Zone := GetDropOnZone(TempOrient, DockRect, DropAlign);
  TempOrient := JvDockExchangeOrient(TempOrient);
  Result := GetDropOnControl(TempOrient, Zone, DockRect, DropAlign, Control);
  DropDockSize := DockRectangles[TempOrient, True] - DockRectangles[TempOrient, False];
end;

function TJvDockVCTree.GetDropOnControl(Orient: TDockOrientation; Zone: TJvDockZone;
  DockRect: TRect; var DropAlign: TAlign; Control: TControl): TControl;
var
  TempZone: TJvDockZone;
  Scale: Double;
  BeginBorderLimit: Integer;
  EndBorderLimit: Integer;

  procedure GetBeginBorderControl(Zone: TJvDockZone);
  begin
    BeginBorderLimit := Zone.TopLeft[Orient];

    if DockRectangles[Orient, False] < BeginBorderLimit then
    begin
      Result := Zone.ChildControl;
      DropAlign := DropAlignArray[Orient, False];
    end;
  end;

  procedure GetEndBorderControl(Zone: TJvDockZone);
  begin
    BeginBorderLimit := Zone.TopLeft[Orient];
    EndBorderLimit := BeginBorderLimit + Zone.HeightWidth[Orient];

    if DockRectangles[Orient, False] < EndBorderLimit then
    begin
      Result := Zone.ChildControl;
      if DockRectangles[Orient, False] = BeginBorderLimit then
        Scale := ScaleMaximum
      else
        Scale := (EndBorderLimit - DockRectangles[Orient, True]) / (DockRectangles[Orient, False] - BeginBorderLimit);
      if Scale >= 1 then
        DropAlign := DropAlignArray[Orient, False]
      else
      begin
        if (Zone.AfterClosestVisibleZone <> nil) and (Zone.AfterClosestVisibleZone.ChildControl = Control) then
        begin
          Result := Zone.AfterClosestVisibleZone.ChildControl;
          DropAlign := DropAlignArray[Orient, False];
        end
        else
          DropAlign := DropAlignArray[Orient, True];
      end;
    end;
  end;

begin
  Result := nil;
  Scale := 0;
  if Zone <> nil then
  begin
    if Zone.ChildCount = 0 then
    begin
      GetBeginBorderControl(Zone);
      if Result = nil then
        GetEndBorderControl(Zone);
    end
    else
    begin
      TempZone := Zone.ChildZones;
      if TempZone <> nil then
        GetBeginBorderControl(TempZone);
      while (TempZone <> nil) and (Result = nil) do
      begin
        GetEndBorderControl(TempZone);
        TempZone := TempZone.AfterClosestVisibleZone;
      end;
    end;
  end;
end;

function TJvDockVCTree.GetDropOnZone(Orient: TDockOrientation; DockRect: TRect;
  var DropAlign: TAlign): TJvDockZone;
var
  TempZone: TJvDockZone;
  Scale: Double;
  TempOrient: TDockOrientation;

  procedure GetBeginBorderZone(BorderLimit: Integer);
  begin
    if DockRectangles[Orient, True] = BorderLimit then
      Scale := ScaleMaximum
    else
      Scale := (BorderLimit - DockRectangles[Orient, False]) / (DockRectangles[Orient, True] - BorderLimit);
    if Scale >= 0 then
    begin
      if Scale >= 1 then
        Result := TempZone.BeforeClosestVisibleZone
      else
        Result := TempZone;
    end;
  end;

  procedure GetEndBorderZone(BorderLimit: Integer);
  begin
    if (DockRectangles[Orient, True] <= BorderLimit) then
      Scale := ScaleMaximum
    else
      Scale := (BorderLimit - DockRectangles[Orient, False]) / (DockRectangles[Orient, True] - BorderLimit);
    if Scale >= 0 then
    begin
      if Scale < 1 then
        Result := TempZone.AfterClosestVisibleZone
      else
        Result := TempZone;
    end;
  end;

begin
  Result := nil;
  TempOrient := JvDockExchangeOrient(Orient);
  if (DockRectangles[TempOrient, False] > DockHeightWidth[TempOrient]) or
    (DockRectangles[TempOrient, True] < 0) then
    Exit;

  if (DockRectangles[Orient, False] + DockRectangles[Orient, True]) div 2 <= 0 then
    DropAlign := DropAlignArray[Orient, False]
  else
  if (DockRectangles[Orient, False] + DockRectangles[Orient, True]) div 2 >= DockHeightWidth[Orient] then
    DropAlign := DropAlignArray[Orient, True]
  else
  begin
    if (TopZone.ChildCount <= 1) or (TopZone.Orientation <> Orient) then
      Result := TopZone
    else
    begin
      Scale := 0;
      TempZone := TopZone.ChildZones;
      GetBeginBorderZone(0);
      while (TempZone <> nil) and (Scale <= 0) do
      begin
        GetEndBorderZone(TempZone.ZoneLimit);
        TempZone := TempZone.AfterClosestVisibleZone;
      end;
    end;
  end;
end;

function TJvDockVCTree.GetLeftGrabbersHTFlag(const MousePos: TPoint;
  out HTFlag: Integer; Zone: TJvDockZone): TJvDockZone;
begin
  if (MousePos.X >= Zone.Left + BorderWidth) and (MousePos.X <= Zone.Left + BorderWidth + GrabberSize) and
    (MousePos.Y >= Zone.Top) and (MousePos.Y <= Zone.Top + Zone.Height) then
  begin
    Result := Zone;
    with Zone.ChildControl do
    begin
      if PtInRect(Rect(
        Left - GrabberSize + LeftOffset,
        Top + TopOffset,
        Left - GrabberSize + LeftOffset + ButtonWidth,
        Top + TopOffset + ButtonHeight), MousePos) then
        HTFlag := HTCLOSE
      else
      if PtInRect(Rect(
        Left - GrabberSize + LeftOffset,
        Top + ButtonHeight + TopOffset + ButtonSplitter,
        Left - GrabberSize + LeftOffset + ButtonWidth,
        Top + 2 * ButtonHeight + TopOffset + ButtonSplitter), MousePos) then
        HTFlag := HTEXPAND
      else
        HTFlag := HTCAPTION;
    end;
  end
  else
    Result := nil;
end;

function TJvDockVCTree.GetTopGrabbersHTFlag(const MousePos: TPoint;
  out HTFlag: Integer; Zone: TJvDockZone): TJvDockZone;
begin
  if (MousePos.Y >= Zone.Top + BorderWidth) and (MousePos.Y <= Zone.Top + BorderWidth + GrabberSize) and
    (MousePos.X >= Zone.Left) and (MousePos.X <= Zone.Left + Zone.Width) then
  begin
    Result := Zone;
    with Zone.ChildControl do
    begin
      if PtInRect(Rect(
        Left + Width - ButtonWidth - RightOffset,
        Top - GrabberSize + TopOffset,
        Left + Width - RightOffset,
        Top - GrabberSize + TopOffset + ButtonHeight), MousePos) then
        HTFlag := HTCLOSE
      else
      if PtInRect(Rect(
        Left + Width - 2 * ButtonWidth - RightOffset - ButtonSplitter,
        Top - GrabberSize + TopOffset,
        Left + Width - ButtonWidth - RightOffset - ButtonSplitter,
        Top - GrabberSize + TopOffset + ButtonHeight), MousePos) then
        HTFlag := HTEXPAND
      else
        HTFlag := HTCAPTION;
    end;
  end
  else
    Result := nil;
end;

procedure TJvDockVCTree.InsertControl(Control: TControl;
  InsertAt: TAlign; DropCtl: TControl);
begin
  inherited InsertControl(Control, InsertAt, DropCtl);
end;

procedure TJvDockVCTree.InsertNewParent(NewZone, SiblingZone: TJvDockZone;
  ParentOrientation: TDockOrientation; InsertLast, Update: Boolean);
begin
  inherited InsertNewParent(NewZone, SiblingZone,
    ParentOrientation, InsertLast, Update);
end;

procedure TJvDockVCTree.InsertSibling(NewZone, SiblingZone: TJvDockZone;
  InsertLast, Update: Boolean);
begin
  inherited InsertSibling(NewZone, SiblingZone, InsertLast, Update);
end;

procedure TJvDockVCTree.RemoveControl(Control: TControl);
var
  DockRect: TRect;
  OldDockSize: Integer;
begin
  OldDockSize := DropDockSize;

  DockRect := GetFrameRect(Control);
  if DockSiteOrientation = doHorizontal then
    DropDockSize := DockRect.Right - DockRect.Left
  else
  if DockSiteOrientation = doVertical then
    DropDockSize := DockRect.Bottom - DockRect.Top;

  inherited RemoveControl(Control);

  DropDockSize := OldDockSize;
end;

procedure TJvDockVCTree.RemoveZone(Zone: TJvDockZone; Hide: Boolean);
begin
  inherited RemoveZone(Zone, Hide);
end;

procedure TJvDockVCTree.ResetBounds(Force: Boolean);
var
  R: TRect;
begin
  BeginUpdate;
  try
    if not JvGlobalDockIsLoading then
    begin
      R := DockSite.ClientRect;

      if ResizeCount > 0 then
      begin
        if TopZone.ChildZones <> nil then
        begin
          if (DockSite.Align = alRight) and (R.Right <> PreviousRect.Right) then
          begin
            ShiftBy := -PreviousRect.Right + R.Right;
            ShiftScaleOrientation := doVertical;
            ForEachAt(TopZone.ChildZones, ShiftZone, tskForward);
            SetNewBounds(nil);
          end;
          if (DockSite.Align = alBottom) and (R.Bottom <> PreviousRect.Bottom) then
          begin
            ShiftBy := -PreviousRect.Bottom + R.Bottom;
            ShiftScaleOrientation := doHorizontal;
            ForEachAt(TopZone.ChildZones, ShiftZone, tskForward);
            SetNewBounds(nil);
          end;
        end;
      end;

      if (DockSiteOrientation = doVertical) and (R.Bottom <> PreviousRect.Bottom) then
      begin
        if PreviousRect.Bottom - PreviousRect.Top = 0 then
          ScaleBy := R.Bottom - R.Top
        else
        if PreviousRect.Bottom - PreviousRect.Top > 0 then
          ScaleBy := (R.Bottom - R.Top) / (PreviousRect.Bottom - PreviousRect.Top)
        else
          ScaleBy := 1;
        ShiftScaleOrientation := doHorizontal;
        if ScaleBy <> 1 then
          ForEachAt(nil, ScaleZone, tskForward);
      end;
      if (DockSiteOrientation = doHorizontal) and (R.Right <> PreviousRect.Right) then
      begin
        if PreviousRect.Right - PreviousRect.Left = 0 then
          ScaleBy := R.Right - R.Left
        else
        if PreviousRect.Right - PreviousRect.Left > 0 then
          ScaleBy := (R.Right - R.Left) / (PreviousRect.Right - PreviousRect.Left)
        else
          ScaleBy := 1;
        ShiftScaleOrientation := doVertical;
        if ScaleBy <> 1 then
          ForEachAt(nil, ScaleZone, tskForward);
      end;
    end;
    inherited ResetBounds(Force);
  finally
    EndUpdate;
  end;
end;

procedure TJvDockVCTree.ResetDockZoneSizeStyle(Parent: TJvDockZone;
  ZoneSizeStyle: TJvDockZoneSizeStyle; Exclude: TJvDockZone);
var
  Zone: TJvDockVCZone;
  ChildCount: Integer;
  AverageSize: Integer;
begin
  ChildCount := Parent.VisibleChildCount - Ord((Exclude <> nil) and (Exclude.ParentZone = Parent));
  if ChildCount = 0 then Exit; 
  AverageSize := DockSiteSizeAlternate div ChildCount;
  Assert(AverageSize > 0);
  Zone := TJvDockVCZone(Parent.FirstVisibleChildZone);
  while Zone <> nil do
  begin
    if Exclude <> Zone then
    begin
      Dec(ChildCount);
      if ZoneSizeStyle in [zssMaximum] then
      begin
        if Zone.ZoneSizeStyle = zssMinimum then
          Zone.ZoneLimit := Zone.LimitBegin + MinSize
        else
        if Zone.ZoneSizeStyle = zssMaximum then
          Zone.ZoneLimit := DockSiteSizeAlternate - ChildCount * MinSize;
      end
      else
      if ZoneSizeStyle in [zssNormal] then
        Zone.ZoneLimit := Zone.LimitBegin + AverageSize;
    end
    else
    if Exclude <> nil then
      Exclude.ZoneLimit := Exclude.LimitBegin;

    Zone := TJvDockVCZone(Zone.AfterClosestVisibleZone);
  end;
  SetNewBounds(Parent);
  ForEachAt(Parent, UpdateZone, tskForward);
end;

procedure TJvDockVCTree.ScaleChildZone(Zone: TJvDockZone);
begin
  if Zone <> nil then
    case TJvDockVCZone(Zone).ZoneSizeStyle of
      zssMinimum:
        begin
          Zone.ZoneLimit := Zone.LimitBegin + MinSize;
          Exit;
        end;
      zssMaximum:
        begin
          Zone.ZoneLimit := DockSiteSizeAlternate - Zone.VisibleNextSiblingCount * MinSize;
          Exit;
        end;
    end;
  inherited ScaleChildZone(Zone);

  if (Zone <> nil) and (Zone.ParentZone <> nil) and Zone.Visibled and
    (Zone.ParentZone.Orientation = ShiftScaleOrientation) then

⌨️ 快捷键说明

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