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 previousItem;
23 wxTreeItemId lastItemAtLevel[9];
24 lastItemAtLevel[ODT::HelpTopicCurrentLevel::TOPIC_LEVEL1] = rootItem;
25 uint32_t itemIndex = 0;
27 for (auto tocItem : document->tocData)
29 if (tocItem.tocItemLevel == ODT::HelpTopicCurrentLevel::TOPIC_LEVEL1)
31 lastItemAtLevel[0] = treHelpTopics->AppendItem(rootItem, tocItem.tocItemName, -1, -1, nullptr);
32 tocItem.tocItemData = lastItemAtLevel[0].GetID();
34 else if (tocItem.tocItemLevel == ODT::HelpTopicCurrentLevel::TOPIC_LEVEL2)
36 lastItemAtLevel[1] = treHelpTopics->AppendItem(lastItemAtLevel[0], tocItem.tocItemName, -1, -1, nullptr);
37 tocItem.tocItemData = lastItemAtLevel[1].GetID();
39 else if (tocItem.tocItemLevel == ODT::HelpTopicCurrentLevel::TOPIC_LEVEL3)
41 lastItemAtLevel[2] = treHelpTopics->AppendItem(lastItemAtLevel[1], tocItem.tocItemName, -1, -1, nullptr);
42 tocItem.tocItemData = lastItemAtLevel[2].GetID();
44 else if (tocItem.tocItemLevel == ODT::HelpTopicCurrentLevel::TOPIC_LEVEL4)
46 lastItemAtLevel[3] = treHelpTopics->AppendItem(lastItemAtLevel[2], tocItem.tocItemName, -1, -1, nullptr);
47 tocItem.tocItemData = lastItemAtLevel[3].GetID();
51 wxTreeItemId newItem = treHelpTopics->AppendItem(rootItem, tocItem.tocItemName, -1, -1, nullptr);
52 tocItem.tocItemData = newItem.GetID();
55 tocItemTreeData *tocItemIndexData = new tocItemTreeData();
56 tocItemIndexData->itemIndex = itemIndex;
57 treHelpTopics->SetItemData(tocItem.tocItemData, tocItemIndexData);
62 // Load in the images.
66 SetTitle(document->title);
69 void frmMain::UpdateHelpTopic( wxTreeEvent& event )
71 wxTreeItemId currentTreeItem = event.GetItem();
72 tocItemTreeData *tocItemData = static_cast<tocItemTreeData*>(treHelpTopics->GetItemData(currentTreeItem));
76 pageData += "<h2>" + std::string(treHelpTopics->GetItemText(currentTreeItem).ToStdString()) + "</h2>\n";
78 // Process the help topic sections.
80 bool firstSection = true;
82 for (auto helpTopicSection : document->helpTopicData[tocItemData->itemIndex].helpTopicSections)
85 pageData += "<br><br>";
88 pageData += helpTopicSection.sectionText + "\n";
91 // Process the foot note sections.
93 if (document->helpTopicData[tocItemData->itemIndex].helpTopicFootnotes.size() > 0)
96 for (auto footnoteSection : document->helpTopicData[tocItemData->itemIndex].helpTopicFootnotes)
98 std::string footnoteID = std::to_string(footnoteSection.footnoteID);
99 pageData += "<a name=\"footnote" + footnoteID + "\"></a><sup>" + footnoteID + "</sup> " + footnoteSection.footnoteText + "<br>\n";
102 htmPage->SetPage((wxString)pageData);