Fix/hack 1.
======== At present, if you wish to load a .hhc file instead of add books manually, you can only have one book - UNLESS you omit the outer <ul> </ul>. Then the contents will appear to have more than book, although in fact it's just one book that's displayed on level zero and therefore get the Book icons. However, you'll also get a dummy 'book' with the name of the project but no children. So my hack detects whether the .hhc file is trying to add books at level zero, and if so, throws away the first 'book', so that only the hhc-specified books get shown. So the end result is that our hhc file can specify multiple sections that don't all hang off one dummy book node which itself hangs off the root node -- which is a UI pain! Fix 2. ==== I changed the test if (!m_Page.IsEmpty()) to if (tag.GetParam("TYPE") == "text/sitemap") at around L.120 of helpdata.cpp as suggested in the comment, so we don't have to specify a URL for the node to be valid. Sometimes you don't want a URL in a contents item. I've added some tests to stop it complaining if you click on a URL-less item. Feature enhancement/Hack 3. ====================== I've added wxHtmlHelpController::SetBookBasePath so that the .hhp/.hhc files don't have to be in the same hierarchy as the HTML files. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9792 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -83,6 +83,10 @@ class WXDLLEXPORT wxHtmlHelpController : public wxHelpControllerBase // wxEvtHan
|
|||||||
virtual wxFrame *GetFrameParameters(wxSize *size = NULL,
|
virtual wxFrame *GetFrameParameters(wxSize *size = NULL,
|
||||||
wxPoint *pos = NULL,
|
wxPoint *pos = NULL,
|
||||||
bool *newFrameEachTime = NULL);
|
bool *newFrameEachTime = NULL);
|
||||||
|
|
||||||
|
// Sets the specified book or all books to have the given base path
|
||||||
|
virtual void SetBookBasePath(const wxString& basePath, int which = -1);
|
||||||
|
|
||||||
virtual bool Quit() ;
|
virtual bool Quit() ;
|
||||||
virtual void OnQuit() {};
|
virtual void OnQuit() {};
|
||||||
|
|
||||||
|
@@ -54,6 +54,10 @@ class WXDLLEXPORT wxHtmlBookRecord : public wxObject
|
|||||||
int GetContentsStart() const { return m_ContentsStart; }
|
int GetContentsStart() const { return m_ContentsStart; }
|
||||||
int GetContentsEnd() const { return m_ContentsEnd; }
|
int GetContentsEnd() const { return m_ContentsEnd; }
|
||||||
|
|
||||||
|
void SetTitle(const wxString& title) { m_Title = title; }
|
||||||
|
void SetBasePath(const wxString& path) { m_BasePath = path; }
|
||||||
|
void SetStart(const wxString& start) { m_Start = start; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxString m_BasePath;
|
wxString m_BasePath;
|
||||||
wxString m_Title;
|
wxString m_Title;
|
||||||
|
@@ -248,5 +248,20 @@ bool wxHtmlHelpController::Quit()
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sets the specified book or all books to have the given base path
|
||||||
|
void wxHtmlHelpController::SetBookBasePath(const wxString& basePath, int which)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
for (i = 0; i < m_helpData.GetBookRecArray().Count(); i++ )
|
||||||
|
{
|
||||||
|
if (i == (size_t) which || which == -1)
|
||||||
|
{
|
||||||
|
wxHtmlBookRecord& book = m_helpData.GetBookRecArray()[i];
|
||||||
|
book.SetBasePath(basePath);
|
||||||
|
}
|
||||||
|
if (i == (size_t) which)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -91,11 +91,12 @@ class HP_TagHandler : public wxHtmlTagHandler
|
|||||||
wxHtmlContentsItem *m_Items;
|
wxHtmlContentsItem *m_Items;
|
||||||
int m_ItemsCnt;
|
int m_ItemsCnt;
|
||||||
wxHtmlBookRecord *m_Book;
|
wxHtmlBookRecord *m_Book;
|
||||||
|
bool m_firstTime; // For checking if we're adding sections at level zero, so we 'delete' the first one
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HP_TagHandler(wxHtmlBookRecord *b) : wxHtmlTagHandler()
|
HP_TagHandler(wxHtmlBookRecord *b) : wxHtmlTagHandler()
|
||||||
{ m_Book = b; m_Items = NULL; m_ItemsCnt = 0; m_Name = m_Page = wxEmptyString;
|
{ m_Book = b; m_Items = NULL; m_ItemsCnt = 0; m_Name = m_Page = wxEmptyString;
|
||||||
m_Level = 0; m_ID = -1; }
|
m_Level = 0; m_ID = -1; m_firstTime = TRUE; }
|
||||||
wxString GetSupportedTags() { return wxT("UL,OBJECT,PARAM"); }
|
wxString GetSupportedTags() { return wxT("UL,OBJECT,PARAM"); }
|
||||||
bool HandleTag(const wxHtmlTag& tag);
|
bool HandleTag(const wxHtmlTag& tag);
|
||||||
void WriteOut(wxHtmlContentsItem*& array, int& size);
|
void WriteOut(wxHtmlContentsItem*& array, int& size);
|
||||||
@@ -117,10 +118,10 @@ bool HP_TagHandler::HandleTag(const wxHtmlTag& tag)
|
|||||||
m_Name = m_Page = wxEmptyString;
|
m_Name = m_Page = wxEmptyString;
|
||||||
ParseInner(tag);
|
ParseInner(tag);
|
||||||
|
|
||||||
if (!m_Page.IsEmpty())
|
if (tag.GetParam("TYPE") == "text/sitemap")
|
||||||
/* should be 'if (tag.GetParam("TYPE") == "text/sitemap")'
|
|
||||||
but this works fine. Valid HHW's file may contain only two
|
// if (!m_Page.IsEmpty())
|
||||||
object tags:
|
/* Valid HHW's file may contain only two object tags:
|
||||||
|
|
||||||
<OBJECT type="text/site properties">
|
<OBJECT type="text/site properties">
|
||||||
<param name="ImageType" value="Folder">
|
<param name="ImageType" value="Folder">
|
||||||
@@ -136,9 +137,19 @@ bool HP_TagHandler::HandleTag(const wxHtmlTag& tag)
|
|||||||
We're interested in the latter. !m_Page.IsEmpty() is valid
|
We're interested in the latter. !m_Page.IsEmpty() is valid
|
||||||
condition because text/site properties does not contain Local param
|
condition because text/site properties does not contain Local param
|
||||||
*/
|
*/
|
||||||
|
{
|
||||||
|
// We're reading in items at level zero, which must mean we want to specify
|
||||||
|
// our own 'books', so chuck out the first (empty) one that AddBook already
|
||||||
|
// created
|
||||||
|
if (m_firstTime && (m_Level == 0) && (m_ItemsCnt > 0))
|
||||||
|
{
|
||||||
|
m_ItemsCnt --;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (m_ItemsCnt % wxHTML_REALLOC_STEP == 0)
|
if (m_ItemsCnt % wxHTML_REALLOC_STEP == 0)
|
||||||
m_Items = (wxHtmlContentsItem*) realloc(m_Items, (m_ItemsCnt + wxHTML_REALLOC_STEP) * sizeof(wxHtmlContentsItem));
|
m_Items = (wxHtmlContentsItem*) realloc(m_Items, (m_ItemsCnt + wxHTML_REALLOC_STEP) * sizeof(wxHtmlContentsItem));
|
||||||
|
}
|
||||||
m_Items[m_ItemsCnt].m_Level = m_Level;
|
m_Items[m_ItemsCnt].m_Level = m_Level;
|
||||||
m_Items[m_ItemsCnt].m_ID = m_ID;
|
m_Items[m_ItemsCnt].m_ID = m_ID;
|
||||||
m_Items[m_ItemsCnt].m_Page = new wxChar[m_Page.Length() + 1];
|
m_Items[m_ItemsCnt].m_Page = new wxChar[m_Page.Length() + 1];
|
||||||
@@ -147,6 +158,8 @@ bool HP_TagHandler::HandleTag(const wxHtmlTag& tag)
|
|||||||
wxStrcpy(m_Items[m_ItemsCnt].m_Name, m_Name.c_str());
|
wxStrcpy(m_Items[m_ItemsCnt].m_Name, m_Name.c_str());
|
||||||
m_Items[m_ItemsCnt].m_Book = m_Book;
|
m_Items[m_ItemsCnt].m_Book = m_Book;
|
||||||
m_ItemsCnt++;
|
m_ItemsCnt++;
|
||||||
|
|
||||||
|
m_firstTime = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@@ -1100,10 +1100,13 @@ void wxHtmlHelpFrame::OnToolbar(wxCommandEvent& event)
|
|||||||
if (ha && ha->m_Index > 0)
|
if (ha && ha->m_Index > 0)
|
||||||
{
|
{
|
||||||
wxHtmlContentsItem *it = m_Data->GetContents() + (ha->m_Index - 1);
|
wxHtmlContentsItem *it = m_Data->GetContents() + (ha->m_Index - 1);
|
||||||
|
if (it->m_Page[0] != 0)
|
||||||
|
{
|
||||||
m_HtmlWin->LoadPage(it->m_Book->GetBasePath() + it->m_Page);
|
m_HtmlWin->LoadPage(it->m_Book->GetBasePath() + it->m_Page);
|
||||||
NotifyPageChanged();
|
NotifyPageChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxID_HTML_UPNODE :
|
case wxID_HTML_UPNODE :
|
||||||
@@ -1124,12 +1127,15 @@ void wxHtmlHelpFrame::OnToolbar(wxCommandEvent& event)
|
|||||||
it = m_Data->GetContents() + ind;
|
it = m_Data->GetContents() + ind;
|
||||||
while (ind >= 0 && it->m_Level != level) ind--, it--;
|
while (ind >= 0 && it->m_Level != level) ind--, it--;
|
||||||
if (ind >= 0)
|
if (ind >= 0)
|
||||||
|
{
|
||||||
|
if (it->m_Page[0] != 0)
|
||||||
{
|
{
|
||||||
m_HtmlWin->LoadPage(it->m_Book->GetBasePath() + it->m_Page);
|
m_HtmlWin->LoadPage(it->m_Book->GetBasePath() + it->m_Page);
|
||||||
NotifyPageChanged();
|
NotifyPageChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxID_HTML_DOWN :
|
case wxID_HTML_DOWN :
|
||||||
@@ -1149,10 +1155,14 @@ void wxHtmlHelpFrame::OnToolbar(wxCommandEvent& event)
|
|||||||
wxHtmlContentsItem *it = m_Data->GetContents() + (ha->m_Index + 1);
|
wxHtmlContentsItem *it = m_Data->GetContents() + (ha->m_Index + 1);
|
||||||
|
|
||||||
while (it->m_Book->GetBasePath() + it->m_Page == adr) it++;
|
while (it->m_Book->GetBasePath() + it->m_Page == adr) it++;
|
||||||
|
|
||||||
|
if (it->m_Page[0] != 0)
|
||||||
|
{
|
||||||
m_HtmlWin->LoadPage(it->m_Book->GetBasePath() + it->m_Page);
|
m_HtmlWin->LoadPage(it->m_Book->GetBasePath() + it->m_Page);
|
||||||
NotifyPageChanged();
|
NotifyPageChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxID_HTML_PANEL :
|
case wxID_HTML_PANEL :
|
||||||
@@ -1270,6 +1280,7 @@ void wxHtmlHelpFrame::OnContentsSel(wxTreeEvent& event)
|
|||||||
{
|
{
|
||||||
it = m_Data->GetContents() + (pg->m_Id);
|
it = m_Data->GetContents() + (pg->m_Id);
|
||||||
m_UpdateContents = FALSE;
|
m_UpdateContents = FALSE;
|
||||||
|
if (it->m_Page[0] != 0)
|
||||||
m_HtmlWin->LoadPage(it->m_Book->GetBasePath() + it->m_Page);
|
m_HtmlWin->LoadPage(it->m_Book->GetBasePath() + it->m_Page);
|
||||||
m_UpdateContents = TRUE;
|
m_UpdateContents = TRUE;
|
||||||
}
|
}
|
||||||
@@ -1280,6 +1291,7 @@ void wxHtmlHelpFrame::OnContentsSel(wxTreeEvent& event)
|
|||||||
void wxHtmlHelpFrame::OnIndexSel(wxCommandEvent& WXUNUSED(event))
|
void wxHtmlHelpFrame::OnIndexSel(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
wxHtmlContentsItem *it = (wxHtmlContentsItem*) m_IndexList->GetClientData(m_IndexList->GetSelection());
|
wxHtmlContentsItem *it = (wxHtmlContentsItem*) m_IndexList->GetClientData(m_IndexList->GetSelection());
|
||||||
|
if (it->m_Page[0] != 0)
|
||||||
m_HtmlWin->LoadPage(it->m_Book->GetBasePath() + it->m_Page);
|
m_HtmlWin->LoadPage(it->m_Book->GetBasePath() + it->m_Page);
|
||||||
NotifyPageChanged();
|
NotifyPageChanged();
|
||||||
}
|
}
|
||||||
@@ -1318,6 +1330,7 @@ void wxHtmlHelpFrame::OnIndexFind(wxCommandEvent& event)
|
|||||||
displ++;
|
displ++;
|
||||||
if (first)
|
if (first)
|
||||||
{
|
{
|
||||||
|
if (index[i].m_Page[0] != 0)
|
||||||
m_HtmlWin->LoadPage(index[i].m_Book->GetBasePath() + index[i].m_Page);
|
m_HtmlWin->LoadPage(index[i].m_Book->GetBasePath() + index[i].m_Page);
|
||||||
NotifyPageChanged();
|
NotifyPageChanged();
|
||||||
first = FALSE;
|
first = FALSE;
|
||||||
@@ -1348,6 +1361,7 @@ void wxHtmlHelpFrame::OnIndexAll(wxCommandEvent& WXUNUSED(event))
|
|||||||
m_IndexList->Append(index[i].m_Name, (char*)(index + i));
|
m_IndexList->Append(index[i].m_Name, (char*)(index + i));
|
||||||
if (first)
|
if (first)
|
||||||
{
|
{
|
||||||
|
if (index[i].m_Page[0] != 0)
|
||||||
m_HtmlWin->LoadPage(index[i].m_Book->GetBasePath() + index[i].m_Page);
|
m_HtmlWin->LoadPage(index[i].m_Book->GetBasePath() + index[i].m_Page);
|
||||||
NotifyPageChanged();
|
NotifyPageChanged();
|
||||||
first = FALSE;
|
first = FALSE;
|
||||||
@@ -1365,6 +1379,7 @@ void wxHtmlHelpFrame::OnSearchSel(wxCommandEvent& WXUNUSED(event))
|
|||||||
wxHtmlContentsItem *it = (wxHtmlContentsItem*) m_SearchList->GetClientData(m_SearchList->GetSelection());
|
wxHtmlContentsItem *it = (wxHtmlContentsItem*) m_SearchList->GetClientData(m_SearchList->GetSelection());
|
||||||
if (it)
|
if (it)
|
||||||
{
|
{
|
||||||
|
if (it->m_Page[0] != 0)
|
||||||
m_HtmlWin->LoadPage(it->m_Book->GetBasePath() + it->m_Page);
|
m_HtmlWin->LoadPage(it->m_Book->GetBasePath() + it->m_Page);
|
||||||
NotifyPageChanged();
|
NotifyPageChanged();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user