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

📄 umfuserdoc.pas

📁 DelphiDoc is a program for automatic generation of documentation on a Delphi-Project. At the momen
💻 PAS
字号:
{  JADD - Just Another DelphiDoc: Documentation from Delphi Source Code

Copyright (C) 2002-2008   Gerold Veith

This file is part of JADD - Just Another DelphiDoc.

DelphiDoc is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3 as
published by the Free Software Foundation.

DelphiDoc is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
}


unit UMFUserDoc;

{Contains a page to select the files of user documentation to include in the
 documentation. }

interface

uses Windows, Classes, Forms, Controls, StdCtrls, ExtCtrls,
{$IFDEF LINUX}
     Qt,
{$ENDIF}
     UMainFormFrame,
     UJADDState;

type
  {A page to select the files of user documentation to include in the
   documentation. }
  TMFUserDoc = class(TMainFormFrame)
    ListBox: TListBox;
    ButtonAdd: TButton;
    ButtonRemove: TButton;
    procedure ButtonAddClick(Sender: TObject);
    procedure ButtonRemoveClick(Sender: TObject);
    procedure ListBoxKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
  private
  protected
    //Called when the generator changes.
    procedure StateGeneratorChanged(State: TJADDState); override;

  public
    //Creates the components, shows the files and allows dropping of files.
    constructor Create(Parent: TWinControl; State: TJADDState); override;
    //Saves the list and frees the frame.
    destructor Destroy; override;

    //Called when some files are dropped on the form.
    procedure FilesDropped(Files: TStrings); override;
  end;


implementation

{$R *.dfm}

uses SysUtils,
     Dialogs;




{Creates the components, shows the files and allows dropping of files.
~param Parent the component to show the frame in, preferably a TPanel or a
              similar component
~param State  the state of the program }
constructor TMFUserDoc.Create(Parent: TWinControl; State: TJADDState);
begin
 inherited Create(Parent, State);             //create the page

 Include(FProperties, mffpAcceptsFileDrop);   //accept dropped files

 //show the already selected files
 ListBox.Items := State.FilesOfUserDocumentation;
end;

{Saves the list and frees the frame. }
destructor TMFUserDoc.Destroy;
begin
 if Assigned(State) then                      //save the list of selected files
  State.FilesOfUserDocumentation.Assign(ListBox.Items);

 inherited Destroy;                           //free the page
end;




{Called when some files are dropped on the form.
~param Files the list of the dropped files }
procedure TMFUserDoc.FilesDropped(Files: TStrings);
var       i         :Integer;                //counter through files
begin
 //supports files?
 if State.Generate.GeneratorSupportsUserDocumentation then
  for i := 0 to Files.Count - 1 do             //for each selected file
   if ListBox.Items.IndexOf(Files[i]) = -1 then  //if not already in list?
    ListBox.Items.Append(Files[i]);                //add the file
end;





{Called when the generator changes.
~param State the state that has been changed }
procedure TMFUserDoc.StateGeneratorChanged(State: TJADDState);
begin
 //only enable the controls, if the generator supports user documentation
 ListBox.Enabled := State.Generate.GeneratorSupportsUserDocumentation;
 ButtonAdd.Enabled := State.Generate.GeneratorSupportsUserDocumentation;
 ButtonRemove.Enabled := State.Generate.GeneratorSupportsUserDocumentation;
end;






{Called when the button to add files of user documentation to integrate in the
 documentation is clicked.
~param Sender the sender of the event, ~[link ButtonAdd] }
procedure TMFUserDoc.ButtonAddClick(Sender: TObject);
var       i         :Integer;             //counter through selected files
begin
 with TOpenDialog.Create(nil) do          //create the file open - dialog
  try
    DefaultExt := 'txt';
    Filter := 'Text files (*.txt)|*.txt|all files (*)|*';
    InitialDir := GetCurrentDir;
    Options := [ofHideReadOnly, ofAllowMultiSelect,
                ofFileMustExist, ofPathMustExist, ofEnableSizing, ofShowHelp];
    HelpContext := ButtonAdd.HelpContext;
    Title := 'Add additional Files of User Documentation';
    if Execute then                       //show the dialog; file selected?
     for i := 0 to Files.Count - 1 do             //for each selected file
      if ListBox.Items.IndexOf(Files[i]) = -1 then  //if not already in list?
       ListBox.Items.Append(Files[i]);                //add the file
  finally
   Free;                                  //free the dialog
  end;
end;

{Called when the button to remove files of user documentation to integrate in
 the documentation is is clicked or the list is double clicked.
~param Sender the sender of the event, ~[link ButtonRemove] or
              ~[link ListBox] }
procedure TMFUserDoc.ButtonRemoveClick(Sender: TObject);
var       i         :Integer;     //runner through all entries in the list
begin
 if State.Generate.GeneratorSupportsUserDocumentation then //editing allowed?
  begin
   ListBox.Items.BeginUpdate;
   try
     for i := ListBox.Items.Count - 1 downto 0 do //for all entries
      if ListBox.Selected[i] then                   //that are selected
       ListBox.Items.Delete(i);                       //remove them
   finally
     ListBox.Items.EndUpdate;
   end;
  end;
end;


{Called when a key is pressed in the check list box.
~param Sender the sender of the event, ~[link ListBox]
~param Key    the pressed key
~param Shift  the state of special modifying keys }
procedure TMFUserDoc.ListBoxKeyDown(Sender: TObject; var Key: Word;
                                    Shift: TShiftState);
begin
 if (Shift = []) and                                 //delete key pressed?
{$IFNDEF LINUX}
                     (Key = VK_DELETE) and
{$ELSE}
                     (Key = Key_Delete) and
{$ENDIF}
    State.Generate.GeneratorSupportsUserDocumentation then //editing allowed?
  ButtonRemoveClick(Sender);                           //delete the entries
end;

end.

⌨️ 快捷键说明

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