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

📄 jvdocktree.pas

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

begin
  Result := 0;
  DoFindVisibleNextSiblingCount(ParentZone);
end;

procedure TJvDockZone.SetZoneLimit(const Value: Integer);
begin
  FZoneLimit := Value;
end;

function TJvDockZone.GetFirstVisibleChildZone: TJvDockZone;
begin
  Result := ChildZones;
  while (Result <> nil) and (not Result.Visibled) do
    Result := Result.NextSibling;
end;

function TJvDockZone.GetSplitterLimit(IsMin: Boolean): Integer;
begin
  if IsMin then
    Result := ZoneLimit
  else
    Result := LimitBegin;

  if ChildZones <> nil then
    ChildZones.DoGetSplitterLimit(ParentZone.Orientation, IsMin, Result);
end;

function TJvDockZone.DoGetSplitterLimit(Orientation: TDockOrientation;
  IsMin: Boolean; var LimitResult: Integer): Integer;
begin
  Result := 0;
  if (ParentZone <> nil) and (ParentZone.Orientation = Orientation) and Visibled then
    if IsMin then
      LimitResult := Min(LimitResult, ZoneLimit)
    else
    if AfterClosestVisibleZone <> nil then
      LimitResult := Max(LimitResult, ZoneLimit);

  if NextSibling <> nil then
    NextSibling.DoGetSplitterLimit(Orientation, IsMin, LimitResult);

  if ChildZones <> nil then
    ChildZones.DoGetSplitterLimit(Orientation, IsMin, LimitResult);
end;

function TJvDockZone.GetLastVisibleChildZone: TJvDockZone;
var
  Zone: TJvDockZone;
begin
  Result := nil;
  Zone := ChildZones;
  while (Zone <> nil) and Zone.Visibled do
  begin
    Result := Zone;
    Zone := Zone.NextSibling;
  end;
end;

procedure TJvDockZone.DoCustomSetControlName;
begin
end;

procedure TJvDockZone.LButtonDblClkMethod;
begin
  if ChildControl <> nil then
    ChildControl.ManualDock(nil, nil, alTop);
end;

procedure TJvDockZone.SetIsInside(const Value: Boolean);
begin
  FIsInside := Value;
end;

procedure TJvDockZone.SetChildControlVisible(Client: TControl; AVisible: Boolean);
begin
  if Client <> nil then
    Client.Visible := FControlVisibled;
end;

//=== { TJvDockTree } ========================================================

constructor TJvDockTree.Create(ADockSite: TWinControl;
  ADockZoneClass: TJvDockZoneClass; ADockStyle: TComponent); {TJvDockBasicStyle}
var
  I: Integer;
begin
  // (rom) added inherited Create
  inherited Create;
  // (rom) Canvas now always existent
  FCanvas := TControlCanvas.Create;
  FDockZoneClass := ADockZoneClass;
  FBorderWidth := 0;
  FSplitterWidth := 4;
  FDockSite := ADockSite;
  {$IFDEF JVCL_DOCKING_NOTIFYLISTENERS}
  FDockStyle := ADockStyle;
  if Assigned(FDockStyle) then
  begin
    TJvDockBasicStyle(FDockStyle).AddDockTreeListener(Self);
    FDockStyleListener := True; // must unhook our listener link unless this flag is turned off.
    if TJvDockBasicStyle(FDockStyle).ConjoinServerOption.GrabbersSize > 0 then
        FGrabberSize := TJvDockBasicStyle(FDockStyle).ConjoinServerOption.GrabbersSize
  end
  else
    FGrabberSize := 18; {Default Grabber Height}
  {$ELSE}
  FGrabberSize := 18; {Default Grabber Height}
  {$ENDIF JVCL_DOCKING_NOTIFYLISTENERS}

  FDockSite.ShowHint := True;
  FVersion := RsDockBaseDockTreeVersion;

  FMinSize := 12;
  FTopZone := FDockZoneClass.Create(Self);
  FBrush := TBrush.Create;
  FBrush.Bitmap := AllocPatternBitmap(clBlack, clWhite);

  FGrabberBgColor := clBtnFace; // default grabber color.
  FGrabberShowLines := True;
  FGrabberBottomEdgeColor := clBtnShadow; // Dark gray, usually.
  
  BeginUpdate;
  try
    for I := 0 to DockSite.ControlCount - 1 do
      InsertControl(DockSite.Controls[I], alLeft, nil);
    FTopZone.ResetChildren(nil);
  finally
    EndUpdate;
  end;
  if not (csDesigning in DockSite.ComponentState) then
  begin
    FOldWndProc := FDockSite.WindowProc;
    FDockSite.WindowProc := WindowProc;
  end;
end;

destructor TJvDockTree.Destroy;
begin
  {$IFDEF JVCL_DOCKING_NOTIFYLISTENERS}
  if Assigned(FDockStyle) and FDockStyleListener then
  begin
    TJvDockBasicStyle(FDockStyle).RemoveDockTreeListener(Self);
    FDockStyleListener := True; // must unhook our listener link unless this flag is turned off.
  end;
  {$ENDIF JVCL_DOCKING_NOTIFYLISTENERS}

  if Assigned(FOldWndProc) then
    FDockSite.WindowProc := FOldWndProc;
  PruneZone(FTopZone);
  FBrush.Free;
  inherited Destroy;
  // (rom) free a Canvas always AFTER inherited Destroy
  FCanvas.Free;
end;

{$IFDEF JVDOCK_DEBUG}

procedure TJvDockTree.Debug(BasePropertyName: string; Strs: TStrings);
var
  N: Integer;
begin
    Assert(Assigned(Strs));
    Strs.Clear;
    N := 0;
    DebugDump(N, '',  BasePropertyName, TopZone, Strs);
    if (Strs.Count = 0) or (N = 0) then
       Strs.Add('<empty>This tree is empty</empty>');
end;

//XXX Helper routines for DebugDump: XXX

procedure TJvDockTree._ParentDump(LevelsLeft: Integer; AParent: TWinControl; Indent: string; Strs: TStrings);
var
  DockServer: TJvDockServer;
  LClassName, LName: string;

  procedure Write(S: string);
  begin
    Strs.Add(S);
  end;

begin
  if Assigned(AParent) then
  begin
    LClassName := AParent.ClassName;
    LName := AParent.Name;
    Write(Indent + '      <parent>');
    Write(Indent + '        <class>' + LClassName + '</class>');
    Write(Indent + '        <name>' + LName + '@' + IntToHex(Integer(AParent), 8) + '</name>');
    if AParent is TJvDockPanel then
    begin
      DockServer := TJvDockPanel(AParent).DockServer;
      if Assigned(DockServer) then
         Write(Indent + '        <dockserver>' + DockServer.Name + '</dockserver>')
      else
         Write(Indent + '        <error>TJvDockPanel has no DockServer</name>');
    end;
    // recurse down:
    if (LevelsLeft > 0) then
      if AParent.Parent <> AParent then // don't show controls where they are their own parent!
        _ParentDump(LevelsLeft - 1, AParent.Parent, Indent + '    ', Strs);
    Write(Indent + '      </parent>');
  end;
end;

procedure TJvDockTree._PageControlDump(PageControl: TWinControl; Indent: string; Strs: TStrings); {actually TJvDockTabPageControl}
var
  I, J, Count: Integer;
  PageID: string;
  LPageControl: TJvDockTabPageControl;
  LClassName, LName: string;

  procedure Write(S: string);
  begin
    Strs.Add(S);
  end;

begin
  if Assigned(PageControl) then
  begin
    LPageControl := PageControl as TJvDockTabPageControl;
    LClassName := LPageControl.ClassName;
    LName := LPageControl.Name;
    Count := LPageControl.Count;
    Write(Indent + '      <pageControl>');
    Write(Indent + '         <class>' + LClassName + '</class>');
    Write(Indent + '         <name>' + LName + '</name>');
    for I := 0 to Count-1 do
    begin
      PageID := 'Page' + IntToStr(I + 1);
      Write(Indent + '           <' + PageID + '>');
      Write(Indent + '              <class>' + LPageControl.Pages[I].ClassName + '</class>');
      Write(Indent + '              <name>' + LPageControl.Pages[I].Name + '</name>');
      Write(Indent + '              <pageCaption>' + LPageControl.Pages[I].Caption + '</pageCaption>');
      Write('');
      for J := 0 to LPageControl.Pages[I].ControlCount - 1 do
      begin
        _ControlDump(LPageControl.Pages[I].Controls[J] as TWinControl, Indent + '             ', Strs);
        Write('');
      end;
      Write(Indent + '           </' + PageID + '>');
      Write('');
    end;

    Write(Indent + '      </pageControl>');
    Write('');
  end
  else
    Write(Indent + '      <ERROR>No pagecontrol in the TJvDockTabHostForm.</ERROR>');
end;

procedure TJvDockTree._ControlDump(AControl: TWinControl; Indent: string; Strs: TStrings);
var
  LClassName, LName: string;
  LForm: TForm;
  DockClient: TJvDockClient;

  procedure Write(S: string);
  begin
    Strs.Add(S);
  end;

begin
   Write(Indent + '   <Control>');
   LClassName := AControl.ClassName;
   LName := AControl.Name;
   Write(Indent + '      <class>' + LClassName + '</class>');
   Write(Indent + '      <name>' + LName + '</name>');
   Write(Indent + '      <visible>' + BoolToStr(AControl.Visible, True) + '</visible>');
   Write(Indent + '      <enabled>' + BoolToStr(AControl.Enabled, True) + '</enabled>');

   if AControl is TForm then
   begin
     LForm := TForm(AControl);
     Write(Indent + '      <caption>' + LForm.Caption + '</caption>');
     DockClient := FindDockClient(AControl);
     if Assigned(DockClient) then
     begin
       LClassName := DockClient.ClassName;
       LName := DockClient.Name;
       Write(Indent + '      <dockclient>');
       Write(Indent + '         <class>' + LClassName + '</class>');
       Write(Indent + '         <name>' + LName + '</name>');
       Write(Indent + '         <customdock>' + BoolToStr(DockClient.CustomDock, True) + '</customdock>');

       // uses DockStateStr - utility function in JvDockControlForm.pas:
       Write(Indent + '         <dockstate>' + DockStateStr(DockClient.DockState) + '</dockstate>');

       Write(Indent + '      </dockclient>');
     end
     else
       Write(Indent + '      <WARNING>No dockclient found in this form.</WARNING>');
     if LForm is TJvDockTabHostForm then
        _PageControlDump(TJvDockTabHostForm(LForm).PageControl, Indent, Strs);
   end;

   { LAST for each control, recursively dump the TWinControl.Parent
     tree, but limit to only a few levels
     so we can avoid information overload. Oops. Too late. :-) }
   _ParentDump(3, AControl.Parent, Indent, Strs);

   Write(Indent + '   </Control>');
end;

// This helps us to understand the current contents of the tree at runtime,
// by allowing  us to build an XML dump of the TJvDockTree.
procedure TJvDockTree.DebugDump(var Index: Integer; Indent, Entity: string; TreeZone: TJvDockZone; Strs: TStrings); //virtual;
var
  Zone: TJvDockZone;
  WasIndex: Integer;

  procedure Write(S: string);
  begin
    Strs.Add(S);
  end;

begin
  Zone := TreeZone;

  { while loop over siblings at this level...}
  while Assigned(Zone) do
  begin
    WasIndex := Index;
    Inc(Index);

    {xml Entity begins }
    Write(Indent + '<' + Entity + IntToStr(WasIndex) + '>');

    {for every tree and tree item inside it that we dump, report actual class name }
    Write(Indent + '   <class>' + Zone.ClassName + '</class>');

    { Dump controls recursively }
    if Assigned(Zone.ChildControl) then
      _ControlDump(Zone.ChildControl, Indent, Strs);

    { Dump children recursively }
    DebugDump(Index, Indent + '       ', Entity + '.ChildZone', Zone.ChildZones, Strs);

    {xml Entity ends }
    Write(Indent + '</' + Entity + IntToStr(WasIndex) + '>');

    {blank line after each Entity ends}
    Write('');

    {dump all siblings at this level immediately after current item }
    Zone := Zone.NextSibling;
  end;
end;

{$ENDIF JVDOCK_DEBUG}

{$IFDEF JVDOCK_QUERY}

// This helps us to find particular Controls (ie Forms) that are
// docked to a particular dock panel, or are floating, etc.
//
// DockedTo - return only items docked to this parent control,
//            or if the parameter DockedTo is NIL, then query for
//            floating Forms. These forms must contain a
//            JvDockClient that says it is currently in a Floating state.
//
// FoundItems - OUT: TList of results (pointers to TWinControl objects).
//
//
procedure TJvDockTree.ControlQuery(DockedTo: TWinControl; FoundItems: TList);
begin
  Assert(Assigned(FoundItems));
  FoundItems.Clear;
  // Root tree node is TopZone. The tree is made of nodes called
  // Zones and Zones may have Controls. Some of those Controls are Forms
  // we might be querying for, and some are parent container forms containing

⌨️ 快捷键说明

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