- m_ContentsBox -> DeleteAllItems();
- roots[0] = m_ContentsBox -> AddRoot(_("(Help)"));
- m_ContentsBox -> SetItemImage(roots[0], IMG_RootFolder);
- m_ContentsBox -> SetItemSelectedImage(roots[0], IMG_RootFolder);
- imaged[0] = TRUE;
-
- for (it = m_Data->GetContents(), i = 0; i < cnt; i++, it++) {
- roots[it -> m_Level + 1] = m_ContentsBox -> AppendItem(
- roots[it -> m_Level], it -> m_Name, IMG_Page, -1,
- new wxHtmlHelpTreeItemData(i));
- m_PagesHash -> Put(it -> m_Book -> GetBasePath() + it -> m_Page,
- new wxHtmlHelpHashData(i, roots[it -> m_Level + 1]));
-
- if (it -> m_Level == 0) {
- m_ContentsBox -> SetItemBold(roots[1], TRUE);
- m_ContentsBox -> SetItemImage(roots[1], IMG_Book);
- m_ContentsBox -> SetItemSelectedImage(roots[1], IMG_Book);
- imaged[1] = TRUE;
- } else imaged[it -> m_Level + 1] = FALSE;
-
- if (!imaged[it -> m_Level]) {
- m_ContentsBox -> SetItemImage(roots[it -> m_Level], IMG_Folder);
- m_ContentsBox -> SetItemSelectedImage(roots[it -> m_Level], IMG_Folder);
- imaged[it -> m_Level] = TRUE;
+ for (it = m_Data->GetContents(), i = 0; i < cnt; i++, it++)
+ {
+ // Handle books:
+ if (it->m_Level == 0)
+ {
+ // special case, only one book, make it tree's root:
+ if (!hasSuperRoot)
+ {
+ roots[0] = roots[1] = m_ContentsBox->AddRoot(
+ it->m_Name, IMG_Book, -1,
+ new wxHtmlHelpTreeItemData(i));
+ imaged[0] = imaged[1] = TRUE;
+ m_ContentsBox->SetItemBold(roots[1], TRUE);
+ }
+ // multiple books:
+ else
+ {
+ if (m_hfStyle & wxHF_MERGE_BOOKS)
+ // VS: we don't want book nodes, books' content should
+ // appear under tree's root. This line will create "fake"
+ // record about book node so that the rest of this look
+ // will believe there really _is_ book node and will
+ // behave correctly.
+ roots[1] = roots[0];
+ else
+ {
+ roots[1] = m_ContentsBox->AppendItem(roots[0],
+ it->m_Name, IMG_Book, -1,
+ new wxHtmlHelpTreeItemData(i));
+ m_ContentsBox->SetItemBold(roots[1], TRUE);
+ }
+ imaged[1] = TRUE;
+ }
+ }
+ // ...and their contents:
+ else
+ {
+ roots[it->m_Level + 1] = m_ContentsBox->AppendItem(
+ roots[it->m_Level], it->m_Name, IMG_Page,
+ -1, new wxHtmlHelpTreeItemData(i));
+ imaged[it->m_Level + 1] = FALSE;
+ }
+
+ m_PagesHash->Put(it->GetFullPath(),
+ new wxHtmlHelpHashData(i, roots[it->m_Level + 1]));
+
+ // Set the icon for the node one level up in the hiearachy,
+ // unless already done (see comment above imaged[] declaration)
+ if (!imaged[it->m_Level])
+ {
+ int image = IMG_Folder;
+ if (m_hfStyle & wxHF_ICONS_BOOK)
+ image = IMG_Book;
+ else if (m_hfStyle & wxHF_ICONS_BOOK_CHAPTER)
+ image = (it->m_Level == 1) ? IMG_Book : IMG_Folder;
+ m_ContentsBox->SetItemImage(roots[it->m_Level], image);
+ m_ContentsBox->SetItemSelectedImage(roots[it->m_Level], image);
+ imaged[it->m_Level] = TRUE;