DCL 3.7.4
Loading...
Searching...
No Matches
HtmlMenu Class Reference

#include <Menu.h>

Public Member Functions

 HtmlMenu ()
 ~HtmlMenu ()
void parse (const String &strMenu)
void setActive (int nPageID)
void assign (TextTemplate *pDest, TextTemplate *pSource, const Session &session)

Protected Attributes

PointerList __children
IntToPointerMap __mapPageToItem

Detailed Description

Definition at line 10 of file Menu.h.

Constructor & Destructor Documentation

◆ HtmlMenu()

HtmlMenu::HtmlMenu ( )

Definition at line 52 of file Menu.cpp.

53{
54}

◆ ~HtmlMenu()

HtmlMenu::~HtmlMenu ( )

Definition at line 56 of file Menu.cpp.

57{
58 PointerList::Iterator itList = __children.begin();
59 for(; itList != __children.end(); itList++)
60 delete (HtmlMenuItem*)(*itList);
61}
PointerList __children
Definition Menu.h:13

Member Function Documentation

◆ assign()

void HtmlMenu::assign ( TextTemplate * pDest,
TextTemplate * pSource,
const Session & session )

Definition at line 130 of file Menu.cpp.

135{
136 TextTemplate* ABEGIN = &(*pSource)[L"ABEGIN"];
137 TextTemplate* AEND = &(*pSource)[L"AEND"];
138 TextTemplate* BEGIN = &(*pSource)[L"BEGIN"];
139 TextTemplate* END = &(*pSource)[L"END"];
140 TextTemplate* LINK = &(*pSource)[L"LINK"];
141 TextTemplate* ACTIVE = &(*pSource)[L"ACTIVE"];
142 TextTemplate* CAPTION = &(*pSource)[L"CAPTION"];
143 TextTemplate* SEPARATOR = &(*pSource)[L"SEPARATOR"];
144
145 PointerList::Iterator itList = __children.begin();
146 for( ; itList != __children.end(); itList++) {
147 ((HtmlMenuItem*)(*itList))->assign(
148 pDest,
149 session,
150 ABEGIN, AEND,
151 BEGIN, END,
152 LINK, ACTIVE, CAPTION, SEPARATOR
153 );
154 }
155}

◆ parse()

void HtmlMenu::parse ( const String & strMenu)

Definition at line 63 of file Menu.cpp.

64{
65 StringArray lines;
66 strMenu.split(L'\n', lines);
67 HtmlMenuItem* pParent = NULL;
68 HtmlMenuItem* pItem = NULL;
69 StringArray::Iterator itLines = lines.begin();
70 for( ; itLines != lines.end(); itLines++) {
71 (*itLines).trim();
72 StringArray items;
73 (*itLines).split(L',', items);
74 StringArray::Iterator itItems = items.begin();
75 __DCL_TRACE1(L"%ls\n", (*itLines).data());
76 __DCL_ASSERT(itItems != items.end());
77
78 if ((*itItems).compareNoCase(L"BEGIN") == 0)
79 pParent = pItem;
80 else if ((*itItems).compareNoCase(L"END") == 0)
81 pParent = NULL;
82 else {
83 pItem = new HtmlMenuItem();
84 if ((*itItems).compareNoCase(L"SEPARATOR") == 0) {
85
86 }
87 else {
88 if (itItems != items.end()) {
89 pItem->__strTitle = *itItems;
90 ++itItems;
91 if (itItems != items.end()) {
92 pItem->__strLink = *itItems;
93 ++itItems;
94 if (itItems != items.end()) {
95 if (!(*itItems).isEmpty())
96 pItem->__nRoleID = Integer::parse(*itItems, 10, 10);
97 ++itItems;
98 if (itItems != items.end()) {
99 StringArray pages;
100 if ((*itItems).split(L' ', pages) > 0) {
101 StringArray::Iterator itPages = pages.begin();
102 for( ; itPages != pages.end(); itPages++) {
103 __mapPageToItem[Integer::parse(*itPages, 10, -1)]
104 = pItem;
105 }
106 }
107 }
108 }
109 }
110 }
111 }
112
113 if (pParent) {
114 pItem->__pParent = pParent;
115 pParent->__children.addTail(pItem);
116 }
117 else
118 __children.addTail(pItem);
119 }
120 }
121}
#define NULL
Definition Config.h:312
#define __DCL_TRACE1(fmt, arg1)
Definition Object.h:399
#define __DCL_ASSERT(expr)
Definition Object.h:394
IntToPointerMap __mapPageToItem
Definition Menu.h:14
HtmlMenuItem * __pParent
Definition Menu.cpp:26
PointerList __children
Definition Menu.cpp:27
String __strLink
Definition Menu.cpp:29
int __nRoleID
Definition Menu.cpp:30
String __strTitle
Definition Menu.cpp:28
static int parse(const wchar_t *_number, unsigned _base=10) __DCL_THROWS1(NumericConvertException *)
Definition Numeric.inl:36

◆ setActive()

void HtmlMenu::setActive ( int nPageID)

Definition at line 123 of file Menu.cpp.

124{
125 IntToPointerMap::Iterator it = __mapPageToItem.find(nPageID);
126 if (it != __mapPageToItem.end())
127 ((HtmlMenuItem*)(*it).value)->setActive();
128}

Member Data Documentation

◆ __children

PointerList HtmlMenu::__children
protected

Definition at line 13 of file Menu.h.

◆ __mapPageToItem

IntToPointerMap HtmlMenu::__mapPageToItem
protected

Definition at line 14 of file Menu.h.


The documentation for this class was generated from the following files: