Enhanced HTML Help output.

1. Full-text-search is enabled
2. Additional buttons on the help window
3. The root page (contents) is now added to the tree
4. etc.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2487 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
1999-05-17 17:05:59 +00:00
parent 428db2ea5a
commit 119f7a8c81

View File

@@ -131,7 +131,7 @@ void SetCurrentChapterName(char *s, char *file)
CurrentChapterFile = copystring(file); CurrentChapterFile = copystring(file);
currentFileName = CurrentChapterFile; currentFileName = CurrentChapterFile;
SetCurrentTopic(s); SetCurrentTopic(s);
} }
void SetCurrentSectionName(char *s, char *file) void SetCurrentSectionName(char *s, char *file)
@@ -225,7 +225,7 @@ void ReopenSectionContentsFile(void)
* converting Latex-isms into HTML-isms, such as 2 newlines -> <P>. * converting Latex-isms into HTML-isms, such as 2 newlines -> <P>.
* *
*/ */
void ProcessText2HTML(TexChunk *chunk) void ProcessText2HTML(TexChunk *chunk)
{ {
bool changed = FALSE; bool changed = FALSE;
@@ -297,7 +297,7 @@ void ProcessText2HTML(TexChunk *chunk)
* and before TraverseDocument is called. * and before TraverseDocument is called.
* *
*/ */
void Text2HTML(TexChunk *chunk) void Text2HTML(TexChunk *chunk)
{ {
Tex2RTFYield(); Tex2RTFYield();
@@ -374,7 +374,7 @@ void AddBrowseButtons(char *upLabel, char *upFilename,
contentsReference = contentsReferenceBuf; contentsReference = contentsReferenceBuf;
sprintf(contentsReference, "<img align=center src=\"%s\" BORDER=0 ALT=\"Contents\">", ConvertCase("contents.gif")); sprintf(contentsReference, "<img align=center src=\"%s\" BORDER=0 ALT=\"Contents\">", ConvertCase("contents.gif"));
} }
char *upReference = NULL; char *upReference = NULL;
if (htmlBrowseButtons == HTML_BUTTONS_TEXT) if (htmlBrowseButtons == HTML_BUTTONS_TEXT)
upReference = UpNameString; upReference = UpNameString;
@@ -384,7 +384,7 @@ void AddBrowseButtons(char *upLabel, char *upFilename,
upReference = upReferenceBuf; upReference = upReferenceBuf;
sprintf(upReference, "<img align=center src=\"%s\" BORDER=0 ALT=\"Up\">", ConvertCase("up.gif")); sprintf(upReference, "<img align=center src=\"%s\" BORDER=0 ALT=\"Up\">", ConvertCase("up.gif"));
} }
char *backReference = NULL; char *backReference = NULL;
if (htmlBrowseButtons == HTML_BUTTONS_TEXT) if (htmlBrowseButtons == HTML_BUTTONS_TEXT)
backReference = "&lt;&lt;"; backReference = "&lt;&lt;";
@@ -394,7 +394,7 @@ void AddBrowseButtons(char *upLabel, char *upFilename,
backReference = backReferenceBuf; backReference = backReferenceBuf;
sprintf(backReference, "<img align=center src=\"%s\" BORDER=0 ALT=\"Previous\">", ConvertCase("back.gif")); sprintf(backReference, "<img align=center src=\"%s\" BORDER=0 ALT=\"Previous\">", ConvertCase("back.gif"));
} }
char *forwardReference = NULL; char *forwardReference = NULL;
if (htmlBrowseButtons == HTML_BUTTONS_TEXT) if (htmlBrowseButtons == HTML_BUTTONS_TEXT)
forwardReference = "&gt;&gt;"; forwardReference = "&gt;&gt;";
@@ -404,9 +404,9 @@ void AddBrowseButtons(char *upLabel, char *upFilename,
forwardReference = forwardReferenceBuf; forwardReference = forwardReferenceBuf;
sprintf(forwardReference, "<img align=center src=\"%s\" BORDER=0 ALT=\"Next\">", ConvertCase("forward.gif")); sprintf(forwardReference, "<img align=center src=\"%s\" BORDER=0 ALT=\"Next\">", ConvertCase("forward.gif"));
} }
TexOutput("<CENTER>"); TexOutput("<CENTER>");
char buf[200]; char buf[200];
/* /*
@@ -556,9 +556,9 @@ char *ParseColourString(char *bkStr, bool *isPicture)
int red = atoi(tok1); int red = atoi(tok1);
int green = atoi(tok2); int green = atoi(tok2);
int blue = atoi(tok3); int blue = atoi(tok3);
strcpy(resStr, "#"); strcpy(resStr, "#");
char buf[3]; char buf[3];
DecToHex(red, buf); DecToHex(red, buf);
strcat(resStr, buf); strcat(resStr, buf);
@@ -596,7 +596,7 @@ void OutputBodyStart(void)
TexOutput(" BGCOLOR="); TexOutput(s); TexOutput(" BGCOLOR="); TexOutput(s);
} }
} }
// Set foreground text colour, if one is specified // Set foreground text colour, if one is specified
if (textColourString) if (textColourString)
{ {
@@ -672,7 +672,7 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
sprintf(titleBuf, "%s_contents.html", FileNameFromPath(FileRoot)); sprintf(titleBuf, "%s_contents.html", FileNameFromPath(FileRoot));
fprintf(Chapters, "<A NAME=\"%s\"></A>", topicName); fprintf(Chapters, "<A NAME=\"%s\"></A>", topicName);
AddBrowseButtons("", titleBuf, // Up AddBrowseButtons("", titleBuf, // Up
lastTopic, lastFileName, // Last topic lastTopic, lastFileName, // Last topic
topicName, ChaptersName); // This topic topicName, ChaptersName); // This topic
@@ -717,7 +717,7 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
if (macroId != ltSECTIONSTAR) if (macroId != ltSECTIONSTAR)
sectionNo ++; sectionNo ++;
SetCurrentOutput(NULL); SetCurrentOutput(NULL);
startedSections = TRUE; startedSections = TRUE;
@@ -938,7 +938,7 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
OutputCurrentSection(); OutputCurrentSection();
TexOutput("</A><BR>"); TexOutput("</A><BR>");
*/ */
if (htmlWorkshopFiles) HTMLWorkshopAddToContents(2, topicName, SectionsName); if (htmlWorkshopFiles) HTMLWorkshopAddToContents(2, topicName, SectionsName);
SetCurrentOutput(Sections); SetCurrentOutput(Sections);
} }
@@ -1019,7 +1019,7 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
{ {
// End cell, start cell // End cell, start cell
TexOutput("</TD>"); TexOutput("</TD>");
// Start new row and cell, setting alignment for the first cell. // Start new row and cell, setting alignment for the first cell.
if (currentColumn < noColumns) if (currentColumn < noColumns)
currentColumn ++; currentColumn ++;
@@ -1033,7 +1033,7 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
{ {
// Convert from points * 20 into pixels. // Convert from points * 20 into pixels.
int points = TableData[currentColumn].width / 20; int points = TableData[currentColumn].width / 20;
// Say the display is 100 DPI (dots/pixels per inch). // Say the display is 100 DPI (dots/pixels per inch).
// There are 72 pts to the inch. So 1pt = 1/72 inch, or 100 * 1/72 dots. // There are 72 pts to the inch. So 1pt = 1/72 inch, or 100 * 1/72 dots.
int pixels = (int)(points * 100.0 / 72.0); int pixels = (int)(points * 100.0 / 72.0);
@@ -1070,7 +1070,7 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
if (start) if (start)
{ {
currentColumn = 0; currentColumn = 0;
// Start new row and cell, setting alignment for the first cell. // Start new row and cell, setting alignment for the first cell.
char buf[100]; char buf[100];
if (TableData[currentColumn].justification == 'c') if (TableData[currentColumn].justification == 'c')
@@ -1081,7 +1081,7 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
{ {
// Convert from points * 20 into pixels. // Convert from points * 20 into pixels.
int points = TableData[currentColumn].width / 20; int points = TableData[currentColumn].width / 20;
// Say the display is 100 DPI (dots/pixels per inch). // Say the display is 100 DPI (dots/pixels per inch).
// There are 72 pts to the inch. So 1pt = 1/72 inch, or 100 * 1/72 dots. // There are 72 pts to the inch. So 1pt = 1/72 inch, or 100 * 1/72 dots.
int pixels = (int)(points * 100.0 / 72.0); int pixels = (int)(points * 100.0 / 72.0);
@@ -1479,7 +1479,7 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
if (htmlFrameContents && FrameContents) if (htmlFrameContents && FrameContents)
{ {
SetCurrentOutput(FrameContents); SetCurrentOutput(FrameContents);
// Add a special label for the contents page. // Add a special label for the contents page.
TexOutput("<CENTER>\n"); TexOutput("<CENTER>\n");
TexOutput("<H3>\n"); TexOutput("<H3>\n");
@@ -1499,7 +1499,7 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
} }
TexOutput("\n</CENTER>\n"); TexOutput("\n</CENTER>\n");
TexOutput("<P><HR><P>\n"); TexOutput("<P><HR><P>\n");
SetCurrentOutput(Titlepage); SetCurrentOutput(Titlepage);
} }
*/ */
@@ -1701,7 +1701,7 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start)
{ {
if (!suppressNameDecoration) TexOutput("</B>"); if (!suppressNameDecoration) TexOutput("</B>");
} }
if (start && (arg_no == 3)) if (start && (arg_no == 3))
TexOutput("("); TexOutput("(");
if (!start && (arg_no == 3)) if (!start && (arg_no == 3))
@@ -1793,7 +1793,7 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start)
if (start) if (start)
{ {
char *sec = NULL; char *sec = NULL;
char *refName = GetArgData(); char *refName = GetArgData();
if (refName) if (refName)
{ {
@@ -1916,11 +1916,11 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start)
alignment = " align=left"; alignment = " align=left";
else if (macroId == ltIMAGER) else if (macroId == ltIMAGER)
alignment = " align=right"; alignment = " align=right";
// Try to find an XBM or GIF image first. // Try to find an XBM or GIF image first.
char *filename = copystring(GetArgData()); char *filename = copystring(GetArgData());
char buf[500]; char buf[500];
strcpy(buf, filename); strcpy(buf, filename);
StripExtension(buf); StripExtension(buf);
strcat(buf, ".xbm"); strcat(buf, ".xbm");
@@ -1998,7 +1998,7 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start)
// Try to find an XBM or GIF image first. // Try to find an XBM or GIF image first.
char *filename = copystring(GetArgData()); char *filename = copystring(GetArgData());
char buf[500]; char buf[500];
strcpy(buf, filename); strcpy(buf, filename);
StripExtension(buf); StripExtension(buf);
strcat(buf, ".xbm"); strcat(buf, ".xbm");
@@ -2552,7 +2552,7 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start)
return FALSE; return FALSE;
break; break;
} }
*/ */
case ltTABULAR: case ltTABULAR:
case ltSUPERTABULAR: case ltSUPERTABULAR:
{ {
@@ -2801,7 +2801,7 @@ bool HTMLGo(void)
if (TitlepageName) delete[] TitlepageName; if (TitlepageName) delete[] TitlepageName;
TitlepageName = copystring(buf); TitlepageName = copystring(buf);
Titlepage = fopen(buf, "w"); Titlepage = fopen(buf, "w");
if (truncateFilenames) if (truncateFilenames)
sprintf(buf, "%s_fc.htm", FileRoot); sprintf(buf, "%s_fc.htm", FileRoot);
else else
@@ -2907,7 +2907,7 @@ bool HTMLGo(void)
else else
fprintf(tmpTitle, "<HEAD><TITLE>%s</TITLE></HEAD>\n\n", FileNameFromPath(FileRoot)); fprintf(tmpTitle, "<HEAD><TITLE>%s</TITLE></HEAD>\n\n", FileNameFromPath(FileRoot));
} }
// Output frame information // Output frame information
if (htmlFrameContents) if (htmlFrameContents)
{ {
@@ -2922,13 +2922,13 @@ bool HTMLGo(void)
fprintf(tmpTitle, "<FRAME SRC=\"%s\">\n", ConvertCase(FileNameFromPath(contentsFrameName))); fprintf(tmpTitle, "<FRAME SRC=\"%s\">\n", ConvertCase(FileNameFromPath(contentsFrameName)));
fprintf(tmpTitle, "<FRAME SRC=\"%s\" NAME=\"mainwindow\">\n", ConvertCase(FileNameFromPath(firstFileName))); fprintf(tmpTitle, "<FRAME SRC=\"%s\" NAME=\"mainwindow\">\n", ConvertCase(FileNameFromPath(firstFileName)));
fprintf(tmpTitle, "</FRAMESET>\n"); fprintf(tmpTitle, "</FRAMESET>\n");
fprintf(tmpTitle, "<NOFRAMES>\n"); fprintf(tmpTitle, "<NOFRAMES>\n");
} }
// Output <BODY...> to temporary title page // Output <BODY...> to temporary title page
OutputBodyStart(); OutputBodyStart();
// Concat titlepage // Concat titlepage
FILE *fd = fopen(TitlepageName, "r"); FILE *fd = fopen(TitlepageName, "r");
if (fd) if (fd)
@@ -3039,27 +3039,40 @@ void GenerateHTMLWorkshopFiles(char *fname)
sprintf(buf, "%s.hhp", fname); sprintf(buf, "%s.hhp", fname);
f = fopen(buf, "wt"); f = fopen(buf, "wt");
fprintf(f, fprintf(f,
"[OPTIONS]\n" "[OPTIONS]\n"
"Compatibility=1.1 or later\n" "Compatibility=1.1\n"
"Full-text search=Yes\n"
"Contents file=%s.hhc\n" "Contents file=%s.hhc\n"
"Compiled file=%s.chm\n"
"Default Window=%sHelp\n"
"Default topic=%s\n" "Default topic=%s\n"
"Index file=%s.hhk\n" "Index file=%s.hhk\n"
"Title=", "Title=",
FileNameFromPath(fname), FileNameFromPath(fname),
FileNameFromPath(fname),
FileNameFromPath(fname),
FileNameFromPath(TitlepageName), FileNameFromPath(TitlepageName),
FileNameFromPath(fname) FileNameFromPath(fname)
); );
if (DocumentTitle) { if (DocumentTitle) {
SetCurrentOutput(f); SetCurrentOutput(f);
TraverseChildrenFromChunk(DocumentTitle); TraverseChildrenFromChunk(DocumentTitle);
} }
else fprintf(f, "(unknown)"); else fprintf(f, "(unknown)");
fprintf(f, "\n\n[WINDOWS]\n"
"%sHelp=,\"%s.hhc\",\"%s.hhk\",\"%s\",,,,,,0x2420,,0x380e,,,,,0,,,",
FileNameFromPath(fname),
FileNameFromPath(fname),
FileNameFromPath(fname),
FileNameFromPath(TitlepageName));
fprintf(f, "\n\n[FILES]\n"); fprintf(f, "\n\n[FILES]\n");
fprintf(f, "%s\n", FileNameFromPath(TitlepageName)); fprintf(f, "%s\n", FileNameFromPath(TitlepageName));
for (int i = 1; i <= fileId; i++) { for (int i = 1; i <= fileId; i++) {
if (truncateFilenames) if (truncateFilenames)
sprintf(buf, "%s%d.htm", FileNameFromPath(FileRoot), i); sprintf(buf, "%s%d.htm", FileNameFromPath(FileRoot), i);
else else
@@ -3097,7 +3110,7 @@ void GenerateHTMLWorkshopFiles(char *fname)
while (node1) while (node1)
{ {
char *s = (char *)node1->Data(); char *s = (char *)node1->Data();
fprintf(f, fprintf(f,
" <LI> <OBJECT type=\"text/sitemap\">\n" " <LI> <OBJECT type=\"text/sitemap\">\n"
" <param name=\"Local\" value=\"%s#%s\">\n" " <param name=\"Local\" value=\"%s#%s\">\n"
" <param name=\"Name\" value=\"%s\">\n" " <param name=\"Name\" value=\"%s\">\n"
@@ -3107,7 +3120,7 @@ void GenerateHTMLWorkshopFiles(char *fname)
} }
} }
} }
fprintf(f, "</UL>\n"); fprintf(f, "</UL>\n");
fclose(f); fclose(f);
} }
@@ -3123,19 +3136,19 @@ void HTMLWorkshopAddToContents(int level, char *s, char *file)
if (level > HTMLWorkshopLastLevel) if (level > HTMLWorkshopLastLevel)
for (i = HTMLWorkshopLastLevel; i < level; i++) for (i = HTMLWorkshopLastLevel; i < level; i++)
fprintf(HTMLWorkshopContents, "<UL>"); fprintf(HTMLWorkshopContents, "<UL>");
if (level < HTMLWorkshopLastLevel) if (level < HTMLWorkshopLastLevel)
for (i = level; i < HTMLWorkshopLastLevel; i++) for (i = level; i < HTMLWorkshopLastLevel; i++)
fprintf(HTMLWorkshopContents, "</UL>"); fprintf(HTMLWorkshopContents, "</UL>");
SetCurrentOutput(HTMLWorkshopContents); SetCurrentOutput(HTMLWorkshopContents);
fprintf(HTMLWorkshopContents, fprintf(HTMLWorkshopContents,
" <LI> <OBJECT type=\"text/sitemap\">\n" " <LI> <OBJECT type=\"text/sitemap\">\n"
" <param name=\"Local\" value=\"%s#%s\">\n" " <param name=\"Local\" value=\"%s#%s\">\n"
" <param name=\"Name\" value=\"", " <param name=\"Name\" value=\"",
file, s); file, s);
OutputCurrentSection(); OutputCurrentSection();
fprintf(HTMLWorkshopContents, fprintf(HTMLWorkshopContents,
"\">\n" "\">\n"
" </OBJECT>\n"); " </OBJECT>\n");
HTMLWorkshopLastLevel = level; HTMLWorkshopLastLevel = level;
@@ -3146,10 +3159,10 @@ void HTMLWorkshopStartContents()
{ {
char buf[300]; char buf[300];
sprintf(buf, "%s.hhc", FileRoot); sprintf(buf, "%s.hhc", FileRoot);
HTMLWorkshopContents = fopen(buf, "wt"); HTMLWorkshopContents = fopen(buf, "wt");
HTMLWorkshopLastLevel = 0; HTMLWorkshopLastLevel = 0;
fprintf(HTMLWorkshopContents, fprintf(HTMLWorkshopContents,
"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n" "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n"
"<HTML>\n" "<HTML>\n"
"<HEAD>\n" "<HEAD>\n"
@@ -3159,7 +3172,13 @@ void HTMLWorkshopStartContents()
"<OBJECT type=\"text/site properties\">\n" "<OBJECT type=\"text/site properties\">\n"
" <param name=\"ImageType\" value=\"Folder\">\n" " <param name=\"ImageType\" value=\"Folder\">\n"
"</OBJECT>\n" "</OBJECT>\n"
"<UL>\n"); "<UL>\n"
"<LI> <OBJECT type=\"text/sitemap\">\n"
"<param name=\"Local\" value=\"%s\">\n"
"<param name=\"Name\" value=\"Contents\">\n</OBJECT>\n",
FileNameFromPath(TitlepageName)
);
} }