📄 umfgeneratemessages_kyl.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 UMFGenerateMessages_kyl;
{Contains a page to show the messages generated while generating the
documentation.
}
interface
uses Classes, Forms, Controls, StdCtrls, ExtCtrls, Buttons, Menus,
UMainFormFrame,
UJADDState, UGenerationMessages;
type
{A page to show the messages generated while generating the documentation. }
TMFGenerateMessagesKylix = class(TMainFormFrame)
ListBox: TListBox;
Memo: TMemo;
BitBtnFilter: TBitBtn;
CheckBoxFatal: TCheckBox;
CheckBoxError: TCheckBox;
CheckBoxWarning: TCheckBox;
CheckBoxHint: TCheckBox;
CheckBoxInformational: TCheckBox;
PopupMenu: TPopupMenu;
MenuItemFilterMessage: TMenuItem;
MenuItemFilterMessagesOfSource: TMenuItem;
MenuItemShowAllMessages: TMenuItem;
MenuItemClearFilter: TMenuItem;
MenuItemSeparator: TMenuItem;
MenuItemCopySelected: TMenuItem;
MenuItemCopyAll: TMenuItem;
MenuItemSaveTo: TMenuItem;
ComboBoxSortOrder: TComboBox;
LabelSortOrder: TLabel;
procedure ListBoxClick(Sender: TObject);
procedure ListBoxDblClick(Sender: TObject);
procedure BitBtnFilterClick(Sender: TObject);
procedure CheckBoxesClick(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
//filter for the messages
FFilter: TMessageFilter;
//Shows the messages filtered and sorted as specified in the GUI.
procedure ShowMessages;
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;
//Unregisters the event handlers and free the filter.
destructor Destroy; override;
//Called sometimes when the frame is to be replaces by another frame.
procedure SelectNextFrame(var NewFrameClass: TMainFormFrameClass;
IsNext: Boolean); override;
end;
implementation
{$R *.dfm}
uses SysUtils, IniFiles,
Dialogs,
GeneralVCL, USettingsKeeper,
UPascalConsts, UBaseIdents,
UMakeDoc,
UMessageFilterForm,
UMFGenerate;
//how to sort the list of messages
type TMessageSortOrder = (msoIndex, //show in same order as generated
msoPosition, //order by their positions
msoMessageNumber); //order by their kinds
{Loads and saves the settings of the pages to select classes to generate
documentation. }
TGenerateMessagesPageSettings = class(TAbstractSettings)
private
//kinds of shown messages
FSeriousnesses: TMessageSeriousnesses;
//filter for messages
FFilter: TMessageFilter;
//how to sort the list of messages
FSortOrder: TMessageSortOrder;
protected
public
//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 kinds of shown messages from the page.
procedure ReadMessageSettings(Page: TMFGenerateMessagesKylix);
property Seriousnesses: TMessageSeriousnesses read FSeriousnesses;
property Filter: TMessageFilter read FFilter;
property SortOrder: TMessageSortOrder 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
Sort :Integer; //the sort order
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;
//read the sort order
Sort := Ini.ReadInteger(Name, 'SortOrder', Ord(FSortOrder));
if (Sort >= Ord(Low(FSortOrder))) and (Sort <= Ord(High(FSortOrder))) then
FSortOrder := TMessageSortOrder(Sort); //if valid set it
FFilter.LoadFromIni(Ini); //load the filter
end;
{Saves the settings to the ini file.
~param Ini the ini file to save the settings to }
procedure TGenerateMessagesPageSettings.SaveToIni(Ini: TCustomIniFile);
begin
//write state of the check boxes
Ini.WriteBool(Name, 'ShowFatalErrors', msFatal in FSeriousnesses);
Ini.WriteBool(Name, 'ShowErrors', msError in FSeriousnesses);
Ini.WriteBool(Name, 'ShowWarnings', msWarning in FSeriousnesses);
Ini.WriteBool(Name, 'ShowHints', msHint in FSeriousnesses);
Ini.WriteBool(Name, 'ShowInformationals', msInformational in FSeriousnesses);
//write the sort order
Ini.WriteInteger(Name, 'SortOrder', Ord(FSortOrder));
FFilter.SaveToIni(Ini); //save the filter
end;
{Gets the settings from the page.
~param Page the page to read the values from }
procedure TGenerateMessagesPageSettings.ReadMessageSettings(Page:
TMFGenerateMessagesKylix);
begin
FSeriousnesses := []; //no messages so far
if Page.CheckBoxFatal.Checked then //fatal error messages wanted?
Include(FSeriousnesses, msFatal);
if Page.CheckBoxError.Checked then //error messages wanted?
Include(FSeriousnesses, msError);
if Page.CheckBoxWarning.Checked then //warning messages wanted?
Include(FSeriousnesses, msWarning);
if Page.CheckBoxHint.Checked then //hints wanted?
Include(FSeriousnesses, msHint);
if Page.CheckBoxInformational.Checked then //informational messages wanted?
Include(FSeriousnesses, msInformational);
//get the sort order
FSortOrder := TMessageSortOrder(Page.ComboBoxSortOrder.ItemIndex);
end;
{Creates the components and the filter.
~param Parent the component to show the frame in, preferably a TPanel or a
similar component
~param State the state of the program }
constructor TMFGenerateMessagesKylix.Create(Parent: TWinControl; State: TJADDState);
var Settings :TGenerateMessagesPageSettings; //to read ini settings
begin
inherited Create(Parent, State); //create the frame
ComboBoxSortOrder.ItemIndex := 0; //init with default sort order
//get object to load the settings from
Settings := TGenerateMessagesPageSettings(TGenerateMessagesPageSettings.
GetSettings(ClassName));
if not assigned(Settings) then //no object initialized?
begin //create a new object
Settings := TGenerateMessagesPageSettings.Create(ClassName);
Settings.ReadMessageSettings(Self); //initialize with the default values
Settings.Initialize; //and read from the ini file
end;
//initialize page with read values
FFilter := Settings.Filter;
CheckBoxFatal.Checked := msFatal in Settings.Seriousnesses;
CheckBoxError.Checked := msError in Settings.Seriousnesses;
CheckBoxWarning.Checked := msWarning in Settings.Seriousnesses;
CheckBoxHint.Checked := msHint in Settings.Seriousnesses;
CheckBoxInformational.Checked := msInformational in Settings.Seriousnesses;
ComboBoxSortOrder.ItemIndex := Ord(Settings.SortOrder);
end;
{Unregisters the event handlers and free the filter. }
destructor TMFGenerateMessagesKylix.Destroy;
var Settings :TGenerateMessagesPageSettings; //to write ini settings
begin
//get object to save the settings in
Settings := TGenerateMessagesPageSettings(TGenerateMessagesPageSettings.
GetSettings(ClassName));
if assigned(Settings) then
Settings.ReadMessageSettings(Self); //save current settings
inherited Destroy; //free the page
end;
{Called sometimes when the frame is to be replaces by another frame. This
method is ~[em not] always called before the frame is being replaced (and
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -