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

📄 ueditguitopics.pas

📁 DelphiDoc is a program for automatic generation of documentation on a Delphi-Project. At the momen
💻 PAS
📖 第 1 页 / 共 4 页
字号:
begin
 Entry := Node.Data;                          //get entry of the node

 case Entry.LinkKind of                       //depending on kind of link
   gmilkNone:    Node.ImageIndex := Ord(iText);      //set the image
   gmilkGUI:     if not assigned(FGUIHelpData) then  //GUI not parsed?
                  Node.ImageIndex := Ord(iGUI)         //general GUI icon
                 else
                  if GUIKnown(Entry.LinkTarget) then   //link target known?
                   Node.ImageIndex := Ord(iGUIKnown)     //indicate this
                  else
                   Node.ImageIndex := Ord(iGUIUnknown);  //invalid GUI link
   gmilkUserDoc: if not assigned(FUserComments) then //user doc not parsed?
                  Node.ImageIndex := Ord(iUserDoc)     //generaly user doc icon
                 else
                  if UserDocPageKnown(Entry.LinkTarget) then //page known?
                   Node.ImageIndex := Ord(iUserDocKnown)       //indicate this
                  else
                   Node.ImageIndex := Ord(iUserDocUnknown);    //invalid page
   gmilkExtern:  Node.ImageIndex := Ord(iExtern);    //image for external link
 end;

 Node.SelectedIndex := Node.ImageIndex;       //same image when selected
end;


{Sets the caption and image of the node and recalculates inherited states.
~param Node the node to update }
procedure TFormGUITopics.UpdateNode(Node: TTreeNode);
begin
 SetNodeText(Node);              //update its caption
 SetNodeImage(Node);             //update its caption

 while assigned(Node.Parent) do  //search root of its part of the tree
  Node := Node.Parent;
 SetOverlay(Node);               //and recalculate overlay of all nodes in it
end;


{Sets the overlay image of the node indicating the state of its child nodes.
 This includes setting the overlay images of all child nodes.
~param Node the node whose overlay image should be set }
procedure TFormGUITopics.SetOverlay(Node: TTreeNode);
{$IFNDEF LINUX}
var       Child         :TTreeNode;   //each child node
          //whether a link of at least one child node is invalid
          Error         :Boolean;
          //whether all links of all child nodes are valid;
          ShowOK        :Boolean;     //False, when no checked links available
{$ENDIF}
begin
{$IFNDEF LINUX}
 Child := Node.GetFirstChild;         //get the first child node
 if Assigned(Child) then              //children available?
  begin
   Error := False;                      //no invalid links found so far
   ShowOK := False;                     //and also not valid ones

   repeat                               //for all child nodes
     SetOverlay(Child);                   //set overlay image of child node

     //get state by the overlay images (i.e. of indirect descendants) and state
     //of the child node
     Error := Error or
              (Child.OverlayIndex = Ord(iOverlayError)) or
              (Child.ImageIndex in [Ord(iGUIUnknown), Ord(iUserDocUnknown)]);
     ShowOK := ShowOK or
               (Child.OverlayIndex = Ord(iOverlayOK)) or
               (Child.ImageIndex in [Ord(iGUIKnown), Ord(iUserDocKnown)]);

     Child := Child.GetNextSibling;       //next sibling
   until Child = nil;                   //for all child nodes

   if Error then                        //at least on invalid link?
    Node.OverlayIndex := Ord(iOverlayError)
   else
    if ShowOK then                        //valid links available?
     Node.OverlayIndex := Ord(iOverlayOK)
    else
     Node.OverlayIndex := -1;               //no overlay image
  end
 else
  Node.OverlayIndex := -1;              //no overlay image
{$ENDIF}
end;

{Sets the overlay images of the part of the tree containing the nodex.
~param Node1, Node2 the nodes for whose parts of the tree the overlay images
                    should be recalculated, may be nil }
procedure TFormGUITopics.SetOverlays(Node1, Node2: TTreeNode);
begin
{$IFNDEF LINUX}
 if Assigned(Node1) then             //node specified?
  begin
   while Assigned(Node1.Parent) do     //search root of its part of the tree
    Node1 := Node1.Parent;
   SetOverlay(Node1);                  //recalculate overlay images
  end;

 if Assigned(Node2) then             //node specified?
  begin
   while Assigned(Node2.Parent) do     //search root of its part of the tree
    Node2 := Node2.Parent;
   if Node2 <> Node1 then              //different part?
    SetOverlay(Node2);                   //recalculate overlay images
  end;
{$ENDIF}
end;







{Loads the base names of all read logs files of GUIs into the combo box so one
 can be chosen.
~param Items the list to load the base names into }
procedure TFormGUITopics.LoadGUIBaseNames(Items: TStrings);
var       SortList      :TStringList;   //the list to sort the names
          i             :Integer;       //counter through all read logged GUIs
begin
 SortList := TStringList.Create;        //create list to sort base names
 try
   if assigned(FGUIHelpData) then       //logged GUIs available?
    begin
     SortList.Sorted := True;             //sort the list
     SortList.Duplicates := dupAccept;    //allow duplicates (just in case)

     for i := 0 to FGUIHelpData.Count - 1 do //add all base names
      SortList.Append(FGUIHelpData[i].BaseName);
    end;
   Items.Assign(SortList);              //assign the sorted list of base names
 finally
  SortList.Free;                        //free the sorted list
 end;
end;

{Loads all comments of the currently selected base names of a GUI into the
 other combo box so one can be chosen.
~param Items    the list to load the comments into
~param BaseName the base name of the selected GUI }
procedure TFormGUITopics.LoadGUIComments(Items: TStrings; BaseName: String);
var       SortList      :TStringList;    //the list to sort the comments in
          Index         :Integer;        //index of the selected GUI
          Data          :TICGUIHelpData; //the data of the selected GUI
          i             :Integer;        //counter through comments of the GUI
begin
 SortList := TStringList.Create;         //create list to sort the comments
 try
   if assigned(FGUIHelpData) then        //logged GUIs available?
    begin
     SortList.Sorted := True;              //sort the list
     SortList.Duplicates := dupAccept;     //allow duplicates (just in case)

     Index := FGUIHelpData.Count - 1;      //search selected GUI by its name
     while (Index > 0) and
           (CompareText(FGUIHelpData[Index].BaseName, BaseName) <> 0) do
      Dec(Index);

     if Index <> -1 then                   //valid name of a GUI specified?
      begin
       Data := FGUIHelpData[Index];          //get the data of the GUI
       for i := 0 to Data.Comments.Count - 1 do //add all comments
        SortList.Append(Data.Comments[i].Name);
      end;
    end;
   SortList.Append('');                  //add entry for link to the GUI itself
   SortList.Append('.default');          //add entry for the default comment
   Items.Assign(SortList);               //assign the sorted list of comments
 finally
  SortList.Free;                         //free the sorted list
 end;
end;

{Loads the names of all parsed pages of additional user documentation into the
 combo box so one can be chosen.
~param Items the list to load the names of all pages of user documentation
             into }
procedure TFormGUITopics.LoadUserDocPages(Items: TStrings);
var       SortList      :TStringList; //list to sort the pages by their name in
          i             :Integer;     //counter through all pages
begin
 SortList := TStringList.Create;      //create list to sort the pages
 try
   if assigned(FUserComments) then    //user documentation available?
    begin
     SortList.Sorted := True;           //sort the list
     SortList.Duplicates := dupAccept;  //allow duplicates (just in case)

     for i := 0 to FUserComments.PageCount - 1 do  //add names of all pages
      SortList.Append(FUserComments.Comment[i].TopicName);
    end;
   Items.Assign(SortList);            //assign the sorted list of pages
 finally
  SortList.Free;                      //free the sorted list
 end;
end;









{Called when the combo box to select the content of the captions of the nodes
 is changed.
~param Sender the sender of the event, ~[link ComboBoxNodeCaptions] }
procedure TFormGUITopics.ComboBoxNodeCaptionsChange(Sender: TObject);
var       i             :Integer;          //counter through all nodes
begin
 for i := 0 to TreeView.Items.Count - 1 do //refresh the captions of all nodes
  SetNodeText(TreeView.Items[i]);
end;



{Called when another node is selected in the tree view.
~param Sender the sender of the event, ~[link TreeView]
~param Node   the newly selected node }
procedure TFormGUITopics.TreeViewChange(Sender: TObject; Node: TTreeNode);
begin
 StartEditing(Node);              //start editing the entry of the node
end;

{Called when a node of the tree view is dragged over it.
~param Sender the sender of the event, ~[link TreeView]
~param Source the source of the dragged object, should also be the tree view
~param X, Y   current position where the object is being dragged
~param State  defines how the dragging is done
~param Accept out: whether the current node can accept the dragged object }
procedure TFormGUITopics.TreeViewDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
var       AtNode        :TTreeNode;   //the node the object is dragged to
          Selected      :TTreeNode;   //the dragged node
begin
 //is dragging a node inside the tree view?
 if (Sender = TreeView) and (Source = TreeView) then
  begin
   AtNode := TreeView.GetNodeAt(X, Y);  //get target node
   if assigned(AtNode) then             //dragged on a node?
    begin
     Selected := TreeView.Selected;       //get the dragged node
     //a node is dragged and not on itself and not on one of its child nodes?
     Accept := assigned(Selected) and
               (Selected <> AtNode) and not AtNode.HasAsParent(Selected);
    end;
  end;
end;

{Called when a node of the tree view is dragged and dropped over it.
~param Sender the sender of the event, ~[link TreeView]
~param Source the source of the dragged object, should also be the tree view
~param X, Y   the position where the object is being dropped }
procedure TFormGUITopics.TreeViewDragDrop(Sender, Source: TObject; X, Y: Integer);
var       AtNode        :TTreeNode;         //the node the object is dropped on
          Selected      :TTreeNode;         //the dragged and dropped node
          //whether the node was dragged below its old position (or above)
          MoveBelow     :Boolean;
          //whether the dropped node is explanded
          IsExpanded    :Boolean;
          OldParent     :TTreeNode;         //the parent of the dragged node
          InsertNode    :TTreeNode;         //the node to move the dragged to
          Entry         :TGUIMainIndexEntry; //the entry of the dragged node
          InsertAt      :TGUIMainIndexEntry; //the entry to move it to
begin
 if (Sender = TreeView) and (Source = TreeView) then //dragging a node?
  begin
   AtNode := TreeView.GetNodeAt(X, Y);       //get the target node
   Selected := TreeView.Selected;            //get the dragged node
   if assigned(AtNode) and assigned(Selected) and //not dropped on itself?
      (Selected <> AtNode) and not AtNode.HasAsParent(Selected) then
    begin
     //get whether moved below its old position or above
     MoveBelow := Selected.AbsoluteIndex < AtNode.AbsoluteIndex;
     IsExpanded := Selected.Expanded;          //was expanded before moving?
     OldParent := Selected.Parent;             //get its parent


     InsertAt := AtNode.Data;                  //get the entry to move to

     Entry := Selected.Data;                   //get the entry to move
     try
       if MoveBelow then                       //moving downwards?
        begin
         InsertNode := AtNode.GetNextSibling;    //needs additional offset
         if assigned(InsertNode) then            //was not the last child node?
          Selected.MoveTo(InsertNode, naInsert)    //insert after it
         else
          Selected.MoveTo(AtNode, naAdd);          //append as last child node

         //move the entry accordingly
         Entry.Parent.UnlinkEntry(Entry.ParentIndex);
         try
           InsertAt.Parent.InsertEntryAfter(InsertAt, Entry);
         except
           Entry.Free;
           raise;
         end;
        end //if MoveBelow
       else
        begin
         InsertNode := AtNode.GetPrevSibling;    //move above the node
         if assigned(InsertNode) then            //was not the first node?
          Selected.MoveTo(AtNode, naInsert)        //insert before the node
         else
          Selected.MoveTo(AtNode, naAddFirst);     //add as first child node

⌨️ 快捷键说明

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