📄 umfguihelpfiles.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 UMFGUIHelpFiles;
{Contains a page to select the (log) files to be used to generate a help on a
GUI. }
interface
uses Classes, Controls, StdCtrls, ExtCtrls, CheckLst, Dialogs,
UJADDState,
UMFSelectFiles;
type
{A page to select the (log) files to be used to generate a help on a GUI. }
TMFGUIHelpFiles = class(TMFSelectFiles)
ButtonIndex: TButton;
CheckBoxUseLoadedGUILogs: TCheckBox;
ButtonLoad: TButton;
ButtonSave: TButton;
procedure ButtonLoadClick(Sender: TObject);
procedure ButtonSaveClick(Sender: TObject);
procedure ButtonIndexClick(Sender: TObject);
private
//Loads a GUI help project ini file.
procedure LoadProject(FileName: String);
//Saves a GUI help project ini file.
procedure SaveProject(FileName: String);
protected
//Called when the generator changes.
procedure StateGeneratorChanged(State: TJADDState); override;
//Shows the list of files in the check list box.
procedure ShowList; override;
//Saves the list of files from the check list box.
procedure SaveList; override;
//Sets the filter and default file extension for the dialog to select
//files.
procedure SetFileDialogFilterAndExtension(Dialog: TOpenDialog); override;
public
//Called when the default action of the form should be executed.
procedure DefaultAction; override;
end;
implementation
{$R *.dfm}
uses SysUtils, IniFiles,
UFilePaths,
UCommandParameters,
UMakeDoc, UICCommentDoc,
UILComment, UICGUIHelpData,
UEditGUITopics;
{Called when the default action of the form should be executed. }
procedure TMFGUIHelpFiles.DefaultAction;
begin
ButtonIndexClick(ButtonIndex); //edit content of main index file
end;
{Called when the generator changes.
~param State the state that has been changed }
procedure TMFGUIHelpFiles.StateGeneratorChanged(State: TJADDState);
var GUIHelpParsed :Boolean; //whether GUI help has been generated
begin
inherited StateGeneratorChanged(State);
GUIHelpParsed := State.Generate.GeneratorAvailable and
(gcGUIHelp in State.Generate.GeneratorCapabilities) and
(State.Generate.TheGenerator is TICCommentDoc) and
assigned(TICCommentDoc(State.Generate.TheGenerator).
GUIHelpData);
CheckBoxUseLoadedGUILogs.Enabled := GUIHelpParsed;
CheckBoxUseLoadedGUILogs.Checked := GUIHelpParsed;
end;
{Shows the list of files in the check list box. }
procedure TMFGUIHelpFiles.ShowList;
var i :Integer; //counter through the files
begin
CheckListBox.Items := State.GUIHelpLogFiles; //get all files
for i := 0 to CheckListBox.Items.Count - 1 do //also show if they are marked
CheckListBox.Checked[i] := Assigned(CheckListBox.Items.Objects[i]);
end;
{Saves the list of files from the check list box. }
procedure TMFGUIHelpFiles.SaveList;
var i :Integer; //counter through the files
begin
for i := 0 to CheckListBox.Items.Count - 1 do //save whether they are marked
CheckListBox.Items.Objects[i] := Pointer(Ord(CheckListBox.Checked[i]));
State.GUIHelpLogFiles.Assign(CheckListBox.Items); //save all files
end;
{Sets the filter and default file extension for the dialog to select files.
~param Dialog the file dialog to set the filter and extension of }
procedure TMFGUIHelpFiles.SetFileDialogFilterAndExtension(Dialog:
TOpenDialog);
begin
Dialog.Filter := 'GUI Log files (*.log)|*.log|all files (*)|*';
Dialog.DefaultExt := 'log';
end;
{Loads a GUI help project ini file.
~param FileName the name of the GUI help project ini file to load }
procedure TMFGUIHelpFiles.LoadProject(FileName: String);
var Ini :TIniFile; //the GUI help project file
begin
//ini files need to be marked to be local (in current directory)
if (Pos(PathDelimiter, FileName) = 0) and (Pos(':', FileName) = 0) then
FileName := '.' + PathDelimiter + FileName;
Ini := TIniFile.Create(FileName); //open the file
try
State.LoadGUIProject(Ini); //load the project
finally
Ini.Free; //close the file
end;
ShowList;
end;
{Saves a GUI help project ini file.
~param FileName the name of the GUI help project ini file to save }
procedure TMFGUIHelpFiles.SaveProject(FileName: String);
var Ini :TIniFile; //the GUI help project file
begin
SaveList; //set current list of files
//ini files need to be marked to be local (in current directory)
if (Pos(PathDelimiter, FileName) = 0) and (Pos(':', FileName) = 0) then
FileName := '.' + PathDelimiter + FileName;
Ini := TIniFile.Create(FileName); //open the file
try
State.SaveGUIProject(Ini); //save the project
finally
Ini.Free; //close the file
end;
end;
{Called when the button to load a GUI help project file is clicked.
~param Sender the sender of the event, ~[link ButtonLoad] }
procedure TMFGUIHelpFiles.ButtonLoadClick(Sender: TObject);
begin
with TOpenDialog.Create(nil) do //create a file open - dialog
try
DefaultExt := DDGHDefaultExtension;
Filter := Format('DelphiDoc-GUI-Help-Project (*.%s)|*.%s|initialization files (*.ini)|*.ini|all files (*)|*',
[DDGHDefaultExtension, DDGHDefaultExtension]);
InitialDir := GetCurrentDir;
Options := [ofHideReadOnly, ofFileMustExist, ofPathMustExist,
ofEnableSizing, ofShowHelp];
HelpContext := ButtonLoad.HelpContext;
Title := 'Load DelphiDoc - GUI Help - Project';
if Execute then //show the dialog; file chosen?
LoadProject(FileName); //load the GUI help project file
finally
Free; //free the dialog
end;
end;
{Called when the button to save the GUI help project file is clicked.
~param Sender the sender of the event, ~[link ButtonSave] }
procedure TMFGUIHelpFiles.ButtonSaveClick(Sender: TObject);
begin
with TSaveDialog.Create(nil) do //create a file save - dialog
try
DefaultExt := DDGHDefaultExtension;
Filter := Format('DelphiDoc-GUI-Help-Project (*.%s)|*.%s|initialization files (*.ini)|*.ini|all files (*)|*',
[DDGHDefaultExtension, DDGHDefaultExtension]);
InitialDir := GetCurrentDir;
Options := [ofOverwritePrompt, ofHideReadOnly, ofPathMustExist,
ofEnableSizing, ofShowHelp];
HelpContext := ButtonSave.HelpContext;
Title := 'Save DelphiDoc - GUI Help - Project';
if Execute then //show the dialog; file chosen?
SaveProject(FileName); //save the GUI help project
finally
Free; //free the dialog
end;
end;
{Called when the button to edit the content of the main index for the help on a
GUI to be generated should be edited is clicked.
~param Sender the sender of the event, ~[link ButtonIndex] }
procedure TMFGUIHelpFiles.ButtonIndexClick(Sender: TObject);
var GUIHelpData :TICGUIHelpList; //most recent data about a GUI
UserComments :TICUserDocComments; //most recent user documentation
begin
//data of most recent generation should be used
if CheckBoxUseLoadedGUILogs.Checked and
State.Generate.GeneratorAvailable and //and is available?
(gcGUIHelp in State.Generate.GeneratorCapabilities) and
(State.Generate.TheGenerator is TICCommentDoc) then
begin //use the data
GUIHelpData := TICCommentDoc(State.Generate.TheGenerator).GUIHelpData;
UserComments := TICCommentDoc(State.Generate.TheGenerator).UserComments;
end
else
begin
GUIHelpData := nil; //no data available
UserComments := nil;
end;
//edit the content of the main topic
EditGUIHelpMainIndex(State.Generate.GUIMainIndexRoot,
GUIHelpData, UserComments);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -