📄 uicguihelpdata.pas
字号:
uses SysUtils,
UFilePaths;
{ * * * *** * * * *** TICGUIHelpData *** * * * *** * * * }
{Creates the object and parses the log file.
~param LogFileName the name of the log file to parse
~param MessageLogger the generator to log all messages to
~param MessageID the ID of the messages to use when they are logged
~param MessageNumber the number of the message to use when they are logged }
constructor TICGUIHelpData.Create(const LogFileName: String;
MessageLogger: TMakeDoc;
MessageID: TMessageID;
MessageNumber: TMessageNumber);
begin
//create the object and parse the log file
inherited Create(LogFileName, MessageLogger, MessageID, MessageNumber);
FAliases := TStringList.Create; //create all needed lists
FManualLinks := TStringList.Create;
FComments := TICGUICommentList.Create;
// FCommentMapping := TStringList.Create;
// FCommentMapping.Sorted := True; //sorted and unique
// FCommentMapping.Duplicates := dupError;
end;
{Frees the parsed data and the object.}
destructor TICGUIHelpData.Destroy;
var i :Integer; //counter through lists
Rect :PRect; //each position
begin
FImage.Free; //free the image
FDefaultComment.Free; //free special comments
FPreface.Free;
FEpilogue.Free;
FComments.Free; //free all lists
// FCommentMapping.Free;
if Assigned(FManualLinks) then
for i := 0 to FManualLinks.Count - 1 do //free all positions of links
begin
Rect := PRect(FManualLinks.Objects[i]); //get position
Dispose(Rect); //free it
end;
FManualLinks.Free;
FAliases.Free;
inherited Destroy; //free the object
end;
{Returns the title or, if no title is defined, the base name of the file.
~result the title or the base name of the data }
function TICGUIHelpData.GetTitleOrBaseName: String;
begin
if Title <> '' then //title not empty?
Result := FTitle //return the title
else
Result := BaseName; //return the base name
end;
{Adds a manual link to the image.
~param Position the position of the link on the image
~param Link the link to link to
~result whether the position is valid }
function TICGUIHelpData.AddManualLink(const Position, Link: String): Boolean;
var Rect :TRect; //position of the link
Pointer :PRect; //new position to save it
begin
Result := ParseRectString(Position, Rect); //parse position
if Result then //position valid?
begin //create position
New(Pointer);
try
Pointer^ := Rect; //assign the position
FManualLinks.AddObject(Link, TObject(Pointer)); //add link and position
except
Dispose(Pointer);
raise;
end;
end;
end;
(*
{Gets the comment with specified name or nil if it has not been defined.
~param Name the name of the comment to be returned
~result the comment with the name or nil }
function TICGUIHelpData.GetComment(const Name: String): TICGUIComment;
var Index :Integer; //the index of the comment
begin
Index := FCommentMapping.IndexOf(Name); //search comment with the name
if Index <> -1 then //comment found?
Result := FComments[Index] //return it
else
Result := nil; //no matching comment found
end;
*)
{ * * * *** * * * *** TICGUIHelpList *** * * * *** * * * }
{Creates the list of the data of the GUI to generate documentation about. }
constructor TICGUIHelpList.Create;
begin
inherited Create; //create the object
FGUIHelpFiles := TStringList.Create; //create list of files
FGUIHelpData := TList.Create; //create the list for TGUIHelpData's
end;
{Frees the object and all read data of the GUI. }
destructor TICGUIHelpList.Destroy;
var i :Integer; //counter through FGUIHelpData
begin
FGUIHelpFiles.Free; //free the list of the files
if assigned(FGUIHelpData) then //list was created?
begin
for i := 0 to FGUIHelpData.Count - 1 do //for each entry
TICGUIHelpData(FGUIHelpData[i]).Free; //free the object
FGUIHelpData.Free; //free the list
end;
inherited Destroy; //free the object
end;
{Returns the current file of the GUI the help is generated about.
~result the current file of the GUI }
function TICGUIHelpList.GetCurrentGUIHelpFile: TICGUIHelpData;
begin
Assert(Assigned(FGUIHelpData));
Assert(FCurrentGUIHelpFileIndex > -1);
Result := FGUIHelpData[FCurrentGUIHelpFileIndex];
end;
{Returns an data item about a GUI to generate help about.
~param Index the index of the data to return (0..~[link Count]-1)
~result the requested data item }
function TICGUIHelpList.GetData(Index: Integer): TICGUIHelpData;
begin
Result := FGUIHelpData[Index]; //return the item
end;
{Parses all log files to generate a help on a GUI.
~param GUIHelpFileList the list of log files with the data of the GUI
~param MessageLogger the generator to log all messages to
~param MessageID the ID of the messages to use when they are logged
~param MessageNumber the number of the message to use when they are logged }
procedure TICGUIHelpList.ParseAllLogFiles(GUIHelpFileList: TStrings;
MessageLogger: TMakeDoc;
MessageID: TMessageID;
MessageNumber: TMessageNumber);
var i :Integer; //counter through all log files
Data :TICGUIHelpData; //each data of each file
begin
FGUIHelpFiles.Assign(GUIHelpFileList); //save the list
try
FCurrentGUIHelpTopic := GUIHelpTopicSpecialPrefix + 'log';
for i := 0 to GUIHelpFiles.Count - 1 do //for each log file
begin
CurrentGUIHelpFileIndex := i;
Assert(not FileExists(GUIHelpFiles[i]) or
IsAbsolutePath(GUIHelpFiles[i]));
Data := TICGUIHelpData.Create(GUIHelpFiles[i], //parse it
MessageLogger, MessageID, MessageNumber);
try
FGUIHelpData.Add(Data); //and add it to the list
except
Data.Free;
raise;
end;
end;
finally
FCurrentGUIHelpFileIndex := -1; //reset the index
end;
end;
{Returns the number of parsed files with data about a GUI.
~result the number of parsed files }
function TICGUIHelpList.Count: Integer;
begin
Result := FGUIHelpData.Count; //return numer of parsed data files
end;
{Returns the index of the parsed file with data about a GUI in the list.
~param Data the data item to return the index of
~result the index of the data item in the list }
function TICGUIHelpList.IndexOf(Data: TICGUIHelpData): Integer;
begin
Result := FGUIHelpData.IndexOf(Data); //return index of data
assert(Result <> -1);
end;
{ * * * *** * * * *** TICGUICommenList *** * * * *** * * * }
{$INCLUDE ..\..\General\Templates\ListTemplate.inc}
{Searches a comment by its name.
~param Name the name of the comment to be searched
~result the index of the comment with the name or -1 }
function TICGUICommentList.GetIndexOfName(const Name: String): Integer;
begin
Result := 0; //search the whole list for the item
while (Result < FCount) and (CompareText(FContent[Result].Name, Name) <> 0) do
inc(Result);
if Result = FCount then //item not in list?
Result := -1;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -