Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Capitalise Bitmaps and Tools directories
[xestiaab/.git] / source / Tools / odthelpbrowser / frmMain.cpp
1 #include "frmMain.h"
3 class tocItemTreeData : public wxTreeItemData
4 {
5 public:
6         uint32_t itemIndex;
8         tocItemTreeData()
9                 : wxTreeItemData()
10         {
11         };
12 };
14 frmMain::frmMain( wxWindow* parent, ODT::ODT *document )
15 :
16 frmMainADT( parent )
17 , document( document )
18 {
19         wxTreeItemId rootItem = treHelpTopics->AddRoot("Xestia Address Book", -1, -1, nullptr);
21         wxTreeItemId previousItem;
22         
23         wxTreeItemId lastItemAtLevel[9];
24         lastItemAtLevel[ODT::HelpTopicCurrentLevel::TOPIC_LEVEL1] = rootItem;
25         uint32_t itemIndex = 0;
27         for (auto tocItem : document->tocData)
28         {
29                 if (tocItem.tocItemLevel == ODT::HelpTopicCurrentLevel::TOPIC_LEVEL1)
30                 {
31                         lastItemAtLevel[0] = treHelpTopics->AppendItem(rootItem, tocItem.tocItemName, -1, -1, nullptr);
32                         tocItem.tocItemData = lastItemAtLevel[0].GetID();
33                 }
34                 else if (tocItem.tocItemLevel == ODT::HelpTopicCurrentLevel::TOPIC_LEVEL2)
35                 {
36                         lastItemAtLevel[1] = treHelpTopics->AppendItem(lastItemAtLevel[0], tocItem.tocItemName, -1, -1, nullptr);
37                         tocItem.tocItemData = lastItemAtLevel[1].GetID();
38                 }
39                 else if (tocItem.tocItemLevel == ODT::HelpTopicCurrentLevel::TOPIC_LEVEL3)
40                 {
41                         lastItemAtLevel[2] = treHelpTopics->AppendItem(lastItemAtLevel[1], tocItem.tocItemName, -1, -1, nullptr);
42                         tocItem.tocItemData = lastItemAtLevel[2].GetID();
43                 }
44                 else if (tocItem.tocItemLevel == ODT::HelpTopicCurrentLevel::TOPIC_LEVEL4)
45                 {
46                         lastItemAtLevel[3] = treHelpTopics->AppendItem(lastItemAtLevel[2], tocItem.tocItemName, -1, -1, nullptr);
47                         tocItem.tocItemData = lastItemAtLevel[3].GetID();
48                 }
49                 else
50                 {
51                         wxTreeItemId newItem = treHelpTopics->AppendItem(rootItem, tocItem.tocItemName, -1, -1, nullptr);
52                         tocItem.tocItemData = newItem.GetID();
53                 }
54         
55                 tocItemTreeData *tocItemIndexData = new tocItemTreeData();
56                 tocItemIndexData->itemIndex = itemIndex;
57                 treHelpTopics->SetItemData(tocItem.tocItemData, tocItemIndexData);
58                 
59                 itemIndex++;
60         }
62         // Load in the images.
63         
64         
66         SetTitle(document->title);
67 }
69 void frmMain::UpdateHelpTopic( wxTreeEvent& event )
70 {
71         wxTreeItemId currentTreeItem = event.GetItem();
72         tocItemTreeData *tocItemData = static_cast<tocItemTreeData*>(treHelpTopics->GetItemData(currentTreeItem));
73         
74         std::string pageData;
75         
76         pageData += "<h2>" + std::string(treHelpTopics->GetItemText(currentTreeItem).ToStdString()) + "</h2>\n";
77         
78         // Process the help topic sections.
79         
80         bool firstSection = true;
81         
82         for (auto helpTopicSection : document->helpTopicData[tocItemData->itemIndex].helpTopicSections)
83         {
84                 if (!firstSection)
85                         pageData += "<br><br>";
86                 
87                 firstSection = false;
88                 pageData += helpTopicSection.sectionText + "\n";
89         }
90         
91         // Process the foot note sections.
93         if (document->helpTopicData[tocItemData->itemIndex].helpTopicFootnotes.size() > 0)
94                 pageData += "<hr>\n";
95         
96         for (auto footnoteSection : document->helpTopicData[tocItemData->itemIndex].helpTopicFootnotes)
97         {
98                 std::string footnoteID = std::to_string(footnoteSection.footnoteID);
99                 pageData += "<a name=\"footnote" + footnoteID + "\"></a><sup>" + footnoteID + "</sup>&nbsp;" + footnoteSection.footnoteText + "<br>\n";
100         }
101         
102         htmPage->SetPage((wxString)pageData);
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy