Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
projects/msw/.gitignore: Ignore files
[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 parentItem = rootItem;
22         wxTreeItemId previousItem;
23         
24         wxTreeItemId lastItemAtLevel[9];
25         lastItemAtLevel[ODT::HelpTopicCurrentLevel::TOPIC_LEVEL1] = rootItem;
26         ODT::HelpTopicCurrentLevel previousLevel;
27         uint32_t itemIndex = 0;
29         for (auto tocItem : document->tocData)
30         {
31                 if (tocItem.tocItemLevel == ODT::HelpTopicCurrentLevel::TOPIC_LEVEL1)
32                 {
33                         lastItemAtLevel[0] = treHelpTopics->AppendItem(rootItem, tocItem.tocItemName, -1, -1, nullptr);
34                         tocItem.tocItemData = lastItemAtLevel[0].GetID();
35                 }
36                 else if (tocItem.tocItemLevel == ODT::HelpTopicCurrentLevel::TOPIC_LEVEL2)
37                 {
38                         lastItemAtLevel[1] = treHelpTopics->AppendItem(lastItemAtLevel[0], tocItem.tocItemName, -1, -1, nullptr);
39                         tocItem.tocItemData = lastItemAtLevel[1].GetID();
40                 }
41                 else if (tocItem.tocItemLevel == ODT::HelpTopicCurrentLevel::TOPIC_LEVEL3)
42                 {
43                         lastItemAtLevel[2] = treHelpTopics->AppendItem(lastItemAtLevel[1], tocItem.tocItemName, -1, -1, nullptr);
44                         tocItem.tocItemData = lastItemAtLevel[2].GetID();
45                 }
46                 else if (tocItem.tocItemLevel == ODT::HelpTopicCurrentLevel::TOPIC_LEVEL4)
47                 {
48                         lastItemAtLevel[3] = treHelpTopics->AppendItem(lastItemAtLevel[2], tocItem.tocItemName, -1, -1, nullptr);
49                         tocItem.tocItemData = lastItemAtLevel[3].GetID();
50                 }
51                 else
52                 {
53                         wxTreeItemId newItem = treHelpTopics->AppendItem(rootItem, tocItem.tocItemName, -1, -1, nullptr);
54                         tocItem.tocItemData = newItem.GetID();
55                 }
56         
57                 tocItemTreeData *tocItemIndexData = new tocItemTreeData();
58                 tocItemIndexData->itemIndex = itemIndex;
59                 treHelpTopics->SetItemData(tocItem.tocItemData, tocItemIndexData);
60                 
61                 itemIndex++;
62         }
64         // Load in the images.
65         
66         
68         SetTitle(document->title);
69 }
71 void frmMain::UpdateHelpTopic( wxTreeEvent& event )
72 {
73         wxTreeItemId currentTreeItem = event.GetItem();
74         tocItemTreeData *tocItemData = static_cast<tocItemTreeData*>(treHelpTopics->GetItemData(currentTreeItem));
75         
76         std::string pageData;
77         
78         pageData += "<h2>" + std::string(treHelpTopics->GetItemText(currentTreeItem).ToStdString()) + "</h2>\n";
79         
80         // Process the help topic sections.
81         
82         bool firstSection = true;
83         
84         for (auto helpTopicSection : document->helpTopicData[tocItemData->itemIndex].helpTopicSections)
85         {
86                 if (!firstSection)
87                         pageData += "<br><br>";
88                 
89                 firstSection = false;
90                 pageData += helpTopicSection.sectionText + "\n";
91         }
92         
93         // Process the foot note sections.
95         if (document->helpTopicData[tocItemData->itemIndex].helpTopicFootnotes.size() > 0)
96                 pageData += "<hr>\n";
97         
98         for (auto footnoteSection : document->helpTopicData[tocItemData->itemIndex].helpTopicFootnotes)
99         {
100                 std::string footnoteID = std::to_string(footnoteSection.footnoteID);
101                 pageData += "<a name=\"footnote" + footnoteID + "\"></a><sup>" + footnoteID + "</sup>&nbsp;" + footnoteSection.footnoteText + "<br>\n";
102         }
103         
104         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