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

📄 umfgeneratemessages.pas

📁 DelphiDoc is a program for automatic generation of documentation on a Delphi-Project. At the momen
💻 PAS
📖 第 1 页 / 共 3 页
字号:
{  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 UMFGenerateMessages;

{Contains a page to show the messages generated while generating the
 documentation.
}

interface

uses Windows, Classes, Forms,
     Controls, StdCtrls, ExtCtrls, Buttons, Menus, ComCtrls, ImgList,
     UMainFormFrame,
     UJADDState, UGenerationMessages, GeneratorMessagesGrid;

type
  {A page to show the messages generated while generating the documentation. }
  TMFGenerateMessages = class(TMainFormFrame)
    Memo: TMemo;
    BitBtnFilter: TBitBtn;
    CheckBoxFatal: TCheckBox;
    CheckBoxError: TCheckBox;
    CheckBoxWarning: TCheckBox;
    CheckBoxHint: TCheckBox;
    CheckBoxInformational: TCheckBox;
    PopupMenu: TPopupMenu;
    MenuItemSeparatorToGridPopUp: TMenuItem;
    MenuItemFilterMessage: TMenuItem;
    MenuItemFilterMessagesOfSource: TMenuItem;
    MenuItemShowAllMessages: TMenuItem;
    MenuItemClearFilter: TMenuItem;
    MenuItemSeparator: TMenuItem;
    MenuItemCopySelectedSum: TMenuItem;
    MenuItemCopyAllSum: TMenuItem;
    MenuItemSaveToSum: TMenuItem;
    ImageListCaptions: TImageList;
    MenuItemClearSortingOrder: TMenuItem;
    MenuItemSummaryLine: TMenuItem;
    MenuItemTabulatorSeparatedColumns: TMenuItem;
    MenuItemCopySelectedTab: TMenuItem;
    MenuItemCopyAllTab: TMenuItem;
    MenuItemSaveToTab: TMenuItem;
    procedure BitBtnFilterClick(Sender: TObject);
    procedure CheckBoxesClick(Sender: TObject);
    procedure MenuItemClearSortingOrderClick(Sender: TObject);
    procedure MenuItemFilterMessageClick(Sender: TObject);
    procedure MenuItemFilterMessagesOfSourceClick(Sender: TObject);
    procedure MenuItemShowAllMessagesClick(Sender: TObject);
    procedure MenuItemClearFilterClick(Sender: TObject);
    procedure MenuItemCopySelectedClick(Sender: TObject);
    procedure MenuItemCopyAllClick(Sender: TObject);
    procedure MenuItemSaveToClick(Sender: TObject);
  private
    //the grid used to show the messages of the generator
    FGrid: TGMGrid;

    //filter for the messages
    FFilter: TMessageFilter;



    //Gets the selected range of messages as a string.
    function GetMessages(First, Last: Integer; AsSummaryLine: Boolean): String;

    //Shows the messages filtered and sorted as specified in the GUI.
    procedure ShowMessages;


    //Shows the information about the selected message.
    procedure GridClick(Sender: TObject);
    //Shows the position of the selected message.
    procedure GridDblClick(Sender: TObject);
    //Shows the position of the selected message.
    procedure GridKeyPressed(Sender: TObject; var Key: Char);
    //Sorts the grid by the selected column.
    procedure GridFixedClick(Sender: TObject; ACol: Integer);


  protected
    //Called when the generator changes.
    procedure StateGeneratorChanged(State: TJADDState); override;

  public
    //Creates the components and the filter.
    constructor Create(Parent: TWinControl; State: TJADDState); override;
    //Save the settings and frees the page.
    destructor Destroy; override;


    //Called sometimes when the frame is to be replaced by another frame.
    procedure SelectNextFrame(var NewFrameClass: TMainFormFrameClass;
                              IsNext: Boolean); override;

    property Grid: TGMGrid read FGrid;
  end;


implementation

{$R *.dfm}

uses SysUtils, IniFiles, ClipBrd,
     Dialogs,
     General, USettingsKeeper,
     UMessageFilterForm,
     UMFGenerate,
     GeneratorMessagesUtilities;



type


  {Loads and saves the settings of the page to show the messages of the last
   generation of documentation. }
  TGenerateMessagesPageSettings = class(TAbstractSettings)
  private
    //kinds of shown messages
    FSeriousnesses: TMessageSeriousnesses;
    //filter for messages
    FFilter: TMessageFilter;

    //the widths of the columns of the grid to show the messages
    FGridColWidths: TGMColumnTypWidths;
    //the number of shown columns
    FGridColCount: Integer;
    //the map from the number of the columns to the kind of data shown in them
    FGridColumnTypes: TColumnToGMColumnType;
    //the options of the grid
    FGridOptions: TGMGridOptions;
    //the height of a data row in the grid
    FGridRowHeight: Integer;
    //how the line with the titles of the columns should be shown
    FGridShowTitle: TShowTitle;

    //the number of fields in ~[link FSortOrder] to sort the messages by
    FSortCount: Integer;
    //how the messages in the list should be sorted, the number of valid
    //entries in this array is saved in ~[link FSortOrder]
    FSortOrder: TGMSortOrders;


  protected
    //Creates the object for settings and the filter object.
    constructor Create(Name: String);
    //Frees also the filter object.
    destructor Destroy; override;


    //Loads the settings from the ini file.
    procedure LoadFromIni(Ini: TCustomIniFile); override;
    //Saves the settings to the ini file.
    procedure SaveToIni(Ini: TCustomIniFile); override;

    //Gets the settings from the page.
    procedure ReadSettings(Page: TMFGenerateMessages);

    property Seriousnesses: TMessageSeriousnesses read FSeriousnesses;
    property Filter: TMessageFilter read FFilter;

    property GridColWidths: TGMColumnTypWidths read FGridColWidths;
    property GridColCount: Integer read FGridColCount;
    property GridColumnTypes: TColumnToGMColumnType read FGridColumnTypes;
    property GridOptions: TGMGridOptions read FGridOptions;
    property GridRowHeight: Integer read FGridRowHeight;
    property GridShowTitle: TShowTitle read FGridShowTitle;
    property GridSortCount: Integer read FSortCount;
    property GridSortOrder: TGMSortOrders read FSortOrder;
  end;



{Creates the object for settings and the filter object.
~param Name the name of the settings }
constructor TGenerateMessagesPageSettings.Create(Name: String);
begin
 inherited Create(Name);                   //create the object

 FFilter := TMessageFilter.Create;         //create the filter
end;

{Frees also the filter object. }
destructor TGenerateMessagesPageSettings.Destroy;
begin
 FFilter.Free;                             //free the filter

 inherited Destroy;                        //free the object
end;


{Loads the settings from the ini file.
~param Ini the ini file to load the settings from }
procedure TGenerateMessagesPageSettings.LoadFromIni(Ini: TCustomIniFile);
var       Seriousnesses   :TMessageSeriousnesses; //the kinds of shown messages
          tmp             :Integer;          //a read value before transforming
          Index           :TGMColumnShowed;  //counter through column types
          i               :Integer;          //counter through columns/fields
          S               :String;           //a value represented as a string
          Option          :TGMGridOption;    //each possible option
          SIndex          :Integer;          //index in the string of fields
          Order           :TGMSortOrders;    //order to sort the messages by
          OrderCount      :Integer;          //number of fields to sort by
          Descending      :Boolean;          //ordering the field descending?
begin
 Seriousnesses := [];                        //no messages so far
 //fatal error messages wanted?
 if Ini.ReadBool(Name, 'ShowFatalErrors', msFatal in FSeriousnesses) then
  Include(Seriousnesses, msFatal);
 //error messages wanted?
 if Ini.ReadBool(Name, 'ShowErrors', msError in FSeriousnesses) then
  Include(Seriousnesses, msError);
 //warning messages wanted?
 if Ini.ReadBool(Name, 'ShowWarnings', msWarning in FSeriousnesses) then
  Include(Seriousnesses, msWarning);
 //hints wanted?
 if Ini.ReadBool(Name, 'ShowHints', msHint in FSeriousnesses) then
  Include(Seriousnesses, msHint);
 if Ini.ReadBool(Name, 'ShowInformationals', //informational messages wanted?
                 msInformational in FSeriousnesses) then
  Include(Seriousnesses, msInformational);
 FSeriousnesses := Seriousnesses;

 FFilter.LoadFromIni(Ini);                     //load the filter

 //read widths of the fields shown in the columns of the grid
 for Index := Low(Index) to High(Index) do
  begin
   tmp := Ini.ReadInteger(Name, Format('GridColWidth%d', [Ord(Index)]), -1);
   if tmp > 0 then
    FGridColWidths[Index] := tmp;
  end;

 //read the fields shown in the columns of the grid
 tmp := Ini.ReadInteger(Name, 'GridShownColumnCount', -1);
 if (tmp > 0) and
    (tmp <= (High(FGridColumnTypes) - Low(FGridColumnTypes) + 1)) then
  FGridColCount := tmp;
 for i := 0 to FGridColCount - 1 do
  begin
   tmp := Ini.ReadInteger(Name, Format('GridColumnType%d', [i]), -1);
   if (tmp >= Ord(Low(FGridColumnTypes[i]))) and
      (tmp <= Ord(High(FGridColumnTypes[i]))) then
    FGridColumnTypes[i] := TGMColumnShowed(tmp);
  end;

 //read general options of the grid
 S := Ini.ReadString(Name, 'GridOptions', '');
 if Length(S) = Ord(High(Option)) - Ord(Low(Option)) + 1 then
  for Option := Low(Option) to High(option) do
   if S[Ord(Option) + 1] in ['0', '1'] then
    if S[Ord(Option) + 1] = '1' then
     Include(FGridOptions, Option)
    else
     Exclude(FGridOptions, Option);

 //and read settings for the rows
 tmp := Ini.ReadInteger(Name, 'GridRowHeight', -1);
 if tmp > 0 then
  FGridRowHeight := tmp;
 tmp := Ini.ReadInteger(Name, 'GridTitles', -1);
 if (tmp >= Ord(Low(TShowTitle))) and (tmp <= Ord(High(TShowTitle))) then
  FGridShowTitle := TShowTitle(tmp);

 //read the sorting order
 S := Ini.ReadString(Name, 'GridSortOrder', ' ');
 OrderCount := 0;
 if S <> ' ' then
  begin
   if S <> '' then
    repeat
      SIndex := Pos(',', S);
      if SIndex = 0 then
       SIndex := Length(S) + 1;
      Descending := S[1] = '-';
      if Descending then
       begin
        Delete(S, 1, 1);
        Dec(SIndex);
       end;
      if (S <> '') and (SIndex > 1) then
       begin
        Val(Copy(S, 1, SIndex - 1), tmp, i);
        if (i <> 0) or (tmp < Ord(Low(Order[OrderCount].Field))) or
                       (tmp > Ord(High(Order[OrderCount].Field))) then
         OrderCount := High(Order) + 1           //abort with error
        else
         begin
          Order[OrderCount].Field := TGMColumnShowed(tmp);
          if Descending then
           Order[OrderCount].Direction := -1
          else
           Order[OrderCount].Direction := 1;
          Inc(OrderCount);
          Delete(S, 1, SIndex);
         end;
       end
      else
       begin
        OrderCount := High(Order) + 1;           //abort
        S := '1';                                //with an error
       end;
    until (S = '') or (OrderCount > High(Order));

   if S = '' then
    begin
     FSortCount := OrderCount;
     FSortOrder := Order;
    end;
  end;

⌨️ 快捷键说明

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