3 class tocItemTreeData : public wxTreeItemData
14 frmMain::frmMain( wxWindow* parent, ODT::ODT *document )
17 , document( document )
19 wxTreeItemId rootItem = treHelpTopics->AddRoot("Xestia Address Book", -1, -1, nullptr);
21 wxTreeItemId parentItem = rootItem;
22 wxTreeItemId previousItem;
24 wxTreeItemId lastItemAtLevel[9];
25 lastItemAtLevel[ODT::HelpTopicCurrentLevel::TOPIC_LEVEL1] = rootItem;
26 uint32_t itemIndex = 0;
28 for (auto tocItem : document->tocData)
30 if (tocItem.tocItemLevel == ODT::HelpTopicCurrentLevel::TOPIC_LEVEL1)
32 lastItemAtLevel[0] = treHelpTopics->AppendItem(rootItem, tocItem.tocItemName, -1, -1, nullptr);
33 tocItem.tocItemData = lastItemAtLevel[0].GetID();
35 else if (tocItem.tocItemLevel == ODT::HelpTopicCurrentLevel::TOPIC_LEVEL2)
37 lastItemAtLevel[1] = treHelpTopics->AppendItem(lastItemAtLevel[0], tocItem.tocItemName, -1, -1, nullptr);
38 tocItem.tocItemData = lastItemAtLevel[1].GetID();
40 else if (tocItem.tocItemLevel == ODT::HelpTopicCurrentLevel::TOPIC_LEVEL3)
42 lastItemAtLevel[2] = treHelpTopics->AppendItem(lastItemAtLevel[1], tocItem.tocItemName, -1, -1, nullptr);
43 tocItem.tocItemData = lastItemAtLevel[2].GetID();
45 else if (tocItem.tocItemLevel == ODT::HelpTopicCurrentLevel::TOPIC_LEVEL4)
47 lastItemAtLevel[3] = treHelpTopics->AppendItem(lastItemAtLevel[2], tocItem.tocItemName, -1, -1, nullptr);
48 tocItem.tocItemData = lastItemAtLevel[3].GetID();
52 wxTreeItemId newItem = treHelpTopics->AppendItem(rootItem, tocItem.tocItemName, -1, -1, nullptr);
53 tocItem.tocItemData = newItem.GetID();
56 tocItemTreeData *tocItemIndexData = new tocItemTreeData();
57 tocItemIndexData->itemIndex = itemIndex;
58 treHelpTopics->SetItemData(tocItem.tocItemData, tocItemIndexData);
63 // Load in the images.
67 SetTitle(document->title);
70 void frmMain::UpdateHelpTopic( wxTreeEvent& event )
72 wxTreeItemId currentTreeItem = event.GetItem();
73 tocItemTreeData *tocItemData = static_cast<tocItemTreeData*>(treHelpTopics->GetItemData(currentTreeItem));
77 pageData += "<h2>" + std::string(treHelpTopics->GetItemText(currentTreeItem).ToStdString()) + "</h2>\n";
79 // Process the help topic sections.
81 bool firstSection = true;
83 for (auto helpTopicSection : document->helpTopicData[tocItemData->itemIndex].helpTopicSections)
86 pageData += "<br><br>";
89 pageData += helpTopicSection.sectionText + "\n";
92 // Process the foot note sections.
94 if (document->helpTopicData[tocItemData->itemIndex].helpTopicFootnotes.size() > 0)
97 for (auto footnoteSection : document->helpTopicData[tocItemData->itemIndex].helpTopicFootnotes)
99 std::string footnoteID = std::to_string(footnoteSection.footnoteID);
100 pageData += "<a name=\"footnote" + footnoteID + "\"></a><sup>" + footnoteID + "</sup> " + footnoteSection.footnoteText + "<br>\n";
103 htmPage->SetPage((wxString)pageData);