#include <MenuWeb.h>
Inheritance diagram for Cgi::MenuWeb:
Public Member Functions | |
MenuWeb (int=MENU_STYLE_TOP) | |
MenuWeb (const std::string &, const std::string &, int=MENU_STYLE_TOP) | |
MenuWeb (int argc, char *argv[], const std::string &, const std::string &, int=MENU_STYLE_TOP) | |
~MenuWeb () | |
void | SetMenuStyle (int) |
const MENUITEM & | AddMenuItem (WebForm *, const std::string &title) |
void | AddMenuSeparator () |
void | AddMenuLink (const std::string &url, const std::string &title) |
void | AddMenuImage (const std::string &src) |
virtual void | ReadCookies () |
virtual void | FormInput () |
virtual void | CreateHeader () |
virtual void | GenerateDocument () |
std::string | GetCookiename () |
void | SetCookiename (const std::string &str) |
void | SetPage (int x) |
int | GetPage () |
void | SetMenuclass (const std::string &x) |
void | SetTheCookie () |
Private Member Functions | |
MenuWeb (const MenuWeb &) | |
MenuWeb & | operator= (const MenuWeb &) |
Private Attributes | |
int | m_count |
int | m_style |
int | m_page |
std::string | m_cookiename |
bool | m_bSetCookie |
menuitem_v | m_items |
std::string | m_strClass |
Definition at line 69 of file MenuWeb.h.
Cgi::MenuWeb::MenuWeb | ( | int | = MENU_STYLE_TOP |
) |
Definition at line 43 of file MenuWeb.cpp.
00043 : Web() 00044 ,m_count(0) 00045 ,m_style(style) 00046 ,m_page(0) 00047 ,m_cookiename("page") 00048 ,m_bSetCookie(false) 00049 ,m_strClass("") 00050 { 00051 }
Cgi::MenuWeb::MenuWeb | ( | const std::string & | , | |
const std::string & | , | |||
int | = MENU_STYLE_TOP | |||
) |
Definition at line 54 of file MenuWeb.cpp.
00054 : Web(cd,cp) 00055 ,m_count(0) 00056 ,m_style(style) 00057 ,m_page(0) 00058 ,m_cookiename("page") 00059 ,m_bSetCookie(false) 00060 { 00061 }
Cgi::MenuWeb::MenuWeb | ( | int | argc, | |
char * | argv[], | |||
const std::string & | , | |||
const std::string & | , | |||
int | = MENU_STYLE_TOP | |||
) |
Definition at line 64 of file MenuWeb.cpp.
00064 : Web(argc,argv,cd,cp) 00065 ,m_count(0) 00066 ,m_style(style) 00067 ,m_page(0) 00068 ,m_cookiename("page") 00069 ,m_bSetCookie(false) 00070 { 00071 }
Cgi::MenuWeb::~MenuWeb | ( | ) |
Definition at line 74 of file MenuWeb.cpp.
References m_items.
00075 { 00076 for (menuitem_v::iterator it = m_items.begin(); it != m_items.end(); it++) 00077 { 00078 MENUITEM *m = static_cast<MENUITEM *>(*it); 00079 delete m; 00080 } 00081 }
Cgi::MenuWeb::MenuWeb | ( | const MenuWeb & | ) | [inline, private] |
void Cgi::MenuWeb::SetMenuStyle | ( | int | ) |
Definition at line 85 of file MenuWeb.cpp.
References m_bSetCookie, and m_style.
Referenced by FormInput().
00086 { 00087 m_style = style; 00088 m_bSetCookie = true; 00089 }
Definition at line 93 of file MenuWeb.cpp.
References m_count, m_items, and Cgi::MENUITEM_TYPE_FORM.
00094 { 00095 MENUITEM *m = new MENUITEM; 00096 00097 m -> num = ++m_count; 00098 m -> type = MENUITEM_TYPE_FORM; 00099 m -> form = form; 00100 m -> title = title; 00101 m -> url = ""; 00102 m -> src = ""; 00103 m_items.insert(m_items.end(),m); 00104 return *m; 00105 }
void Cgi::MenuWeb::AddMenuSeparator | ( | ) |
Definition at line 108 of file MenuWeb.cpp.
References m_count, m_items, and Cgi::MENUITEM_TYPE_SEPARATOR.
00109 { 00110 MENUITEM *m = new MENUITEM; 00111 00112 m -> num = ++m_count; 00113 m -> type = MENUITEM_TYPE_SEPARATOR; 00114 m -> form = NULL; 00115 m -> title = ""; 00116 m -> url = ""; 00117 m -> src = ""; 00118 m_items.insert(m_items.end(),m); 00119 }
void Cgi::MenuWeb::AddMenuLink | ( | const std::string & | url, | |
const std::string & | title | |||
) |
Definition at line 122 of file MenuWeb.cpp.
References m_count, m_items, and Cgi::MENUITEM_TYPE_URL.
00123 { 00124 MENUITEM *m = new MENUITEM; 00125 00126 m -> num = ++m_count; 00127 m -> type = MENUITEM_TYPE_URL; 00128 m -> form = NULL; 00129 m -> title = title; 00130 m -> url = url; 00131 m -> src = ""; 00132 m_items.insert(m_items.end(),m); 00133 }
void Cgi::MenuWeb::AddMenuImage | ( | const std::string & | src | ) |
Definition at line 136 of file MenuWeb.cpp.
References m_count, m_items, and Cgi::MENUITEM_TYPE_URL.
00137 { 00138 MENUITEM *m = new MENUITEM; 00139 00140 m -> num = ++m_count; 00141 m -> type = MENUITEM_TYPE_URL; 00142 m -> form = NULL; 00143 m -> title = ""; 00144 m -> url = ""; 00145 m -> src = src; 00146 m_items.insert(m_items.end(),m); 00147 }
void Cgi::MenuWeb::ReadCookies | ( | ) | [virtual] |
Reimplemented from Cgi::Web.
Definition at line 150 of file MenuWeb.cpp.
References Cgi::Web::GetCookies(), Cgi::Parse::getvalue(), m_cookiename, m_page, m_style, and Cgi::Web::ReadCookies().
00151 { 00152 char slask[200]; 00153 00154 Web::ReadCookies(); 00155 00156 if (GetCookies() -> getvalue( (char *)m_cookiename.c_str(),slask,200)) 00157 { 00158 Cgi::Parse pa(slask,":"); 00159 m_style = pa.getvalue(); 00160 m_page = pa.getvalue(); 00161 } 00162 }
void Cgi::MenuWeb::FormInput | ( | ) | [virtual] |
Reimplemented from Cgi::Web.
Definition at line 165 of file MenuWeb.cpp.
References Cgi::Web::FormInput(), Cgi::Web::GetForm(), SetMenuStyle(), and SetPage().
00166 { 00167 char slask[200]; 00168 00169 Web::FormInput(); 00170 00171 if (GetForm() -> getvalue("page",slask,200) && *slask && atoi(slask) ) 00172 { 00173 SetPage(atoi(slask)); 00174 } 00175 if (GetForm() -> getvalue("style",slask,200) && *slask && atoi(slask) ) 00176 { 00177 SetMenuStyle(atoi(slask)); 00178 } 00179 }
void Cgi::MenuWeb::CreateHeader | ( | ) | [virtual] |
Reimplemented from Cgi::Web.
Definition at line 182 of file MenuWeb.cpp.
References Cgi::Web::CreateHeader(), m_bSetCookie, and SetTheCookie().
00183 { 00184 if (m_bSetCookie) 00185 { 00186 SetTheCookie(); 00187 } 00188 Web::CreateHeader(); 00189 }
void Cgi::MenuWeb::GenerateDocument | ( | ) | [virtual] |
Reimplemented from Cgi::Web.
Definition at line 192 of file MenuWeb.cpp.
References Cgi::Web::GetCgiName(), m_items, m_page, m_strClass, m_style, Cgi::MENU_STYLE_FRAME_LEFT, Cgi::MENU_STYLE_LEFT, Cgi::MENU_STYLE_TOP, Cgi::MENUITEM_TYPE_FORM, Cgi::MENUITEM_TYPE_IMAGE, Cgi::MENUITEM_TYPE_SEPARATOR, and Cgi::MENUITEM_TYPE_URL.
00193 { 00194 int colspan = 1; 00195 char slask[200]; 00196 char cls[200]; 00197 00198 if (m_strClass.size()) 00199 sprintf(cls," class=%s",m_strClass.c_str()); 00200 else 00201 *cls = 0; 00202 00203 switch (m_style) 00204 { 00205 case MENU_STYLE_FRAME_LEFT: 00206 break; 00207 case MENU_STYLE_TOP: 00208 { 00209 printf("<table width=\"100%%\"><tr><td>"); 00210 // menu items 00211 strcpy(slask,"[ "); 00212 for (menuitem_v::iterator it = m_items.begin(); it != m_items.end(); it++) 00213 { 00214 MENUITEM *m = static_cast<MENUITEM *>(*it); 00215 00216 switch (m -> type) 00217 { 00218 case MENUITEM_TYPE_FORM: 00219 printf("%s<a%s href=\"%s?page=%d\">%s</a> ", 00220 slask, 00221 cls, 00222 GetCgiName().c_str(), 00223 m -> num, 00224 m -> title.c_str()); 00225 strcpy(slask,"| "); 00226 break; 00227 case MENUITEM_TYPE_SEPARATOR: 00228 if (*slask == '|') 00229 { 00230 printf("]</td><td>"); 00231 strcpy(slask,"[ "); 00232 colspan++; 00233 } 00234 break; 00235 case MENUITEM_TYPE_URL: 00236 printf("%s<a%s href=\"%s\">%s</a> ", 00237 slask, 00238 cls, 00239 m -> url.c_str(), 00240 m -> title.c_str()); 00241 strcpy(slask,"| "); 00242 break; 00243 case MENUITEM_TYPE_IMAGE: 00244 break; 00245 } 00246 } 00247 if (*slask != '[') 00248 printf("]"); 00249 printf("</td></tr>"); 00250 printf("</table>"); 00251 // printf("<tr><td colspan=%d>",colspan); 00252 // selection 00253 { 00254 for (menuitem_v::iterator it = m_items.begin(); it != m_items.end(); it++) 00255 { 00256 MENUITEM *m = static_cast<MENUITEM *>(*it); 00257 if (m -> num == m_page) 00258 { 00259 m -> form -> Display(); 00260 break; 00261 } 00262 } 00263 } 00264 // printf("</td></tr></table>"); 00265 break; 00266 } 00267 case MENU_STYLE_LEFT: 00268 { 00269 printf("<table><tr>"); 00270 printf("<td valign=top align=middle>"); 00271 // menu items 00272 for (menuitem_v::iterator it = m_items.begin(); it != m_items.end(); it++) 00273 { 00274 MENUITEM *m = static_cast<MENUITEM *>(*it); 00275 00276 switch (m -> type) 00277 { 00278 case MENUITEM_TYPE_FORM: 00279 printf("<a%s href=\"%s?page=%d\">%s</a> ", 00280 cls, 00281 GetCgiName().c_str(), 00282 m -> num, 00283 m -> title.c_str()); 00284 break; 00285 case MENUITEM_TYPE_SEPARATOR: 00286 // printf("<hr>"); 00287 break; 00288 case MENUITEM_TYPE_URL: 00289 printf("<a%s href=\"%s\">%s</a> ", 00290 cls, 00291 m -> url.c_str(), 00292 m -> title.c_str()); 00293 break; 00294 case MENUITEM_TYPE_IMAGE: 00295 break; 00296 } 00297 printf("<br>"); 00298 } 00299 printf("</td>"); 00300 printf("<td valign=top>"); 00301 // selection 00302 { 00303 for (menuitem_v::iterator it = m_items.begin(); it != m_items.end(); it++) 00304 { 00305 MENUITEM *m = static_cast<MENUITEM *>(*it); 00306 if (m -> num == m_page) 00307 { 00308 m -> form -> Display(); 00309 break; 00310 } 00311 } 00312 } 00313 printf("</td>"); 00314 printf("</tr></table>"); 00315 break; 00316 } 00317 } 00318 }
std::string Cgi::MenuWeb::GetCookiename | ( | ) | [inline] |
void Cgi::MenuWeb::SetCookiename | ( | const std::string & | str | ) | [inline] |
void Cgi::MenuWeb::SetPage | ( | int | x | ) | [inline] |
Definition at line 91 of file MenuWeb.h.
References m_bSetCookie, and m_page.
Referenced by FormInput().
00091 { m_page = x; m_bSetCookie = true; }
int Cgi::MenuWeb::GetPage | ( | ) | [inline] |
void Cgi::MenuWeb::SetMenuclass | ( | const std::string & | x | ) | [inline] |
void Cgi::MenuWeb::SetTheCookie | ( | ) |
Definition at line 321 of file MenuWeb.cpp.
References m_cookiename, m_page, m_style, and Cgi::Web::SetCookie().
Referenced by CreateHeader().
00322 { 00323 char slask[200]; 00324 00325 sprintf(slask,"%d:%d",m_style,m_page); 00326 SetCookie(m_cookiename.c_str(),slask); 00327 }
int Cgi::MenuWeb::m_count [private] |
Definition at line 100 of file MenuWeb.h.
Referenced by AddMenuImage(), AddMenuItem(), AddMenuLink(), and AddMenuSeparator().
int Cgi::MenuWeb::m_style [private] |
Definition at line 101 of file MenuWeb.h.
Referenced by GenerateDocument(), ReadCookies(), SetMenuStyle(), and SetTheCookie().
int Cgi::MenuWeb::m_page [private] |
Definition at line 102 of file MenuWeb.h.
Referenced by GenerateDocument(), GetPage(), ReadCookies(), SetPage(), and SetTheCookie().
std::string Cgi::MenuWeb::m_cookiename [private] |
Definition at line 103 of file MenuWeb.h.
Referenced by GetCookiename(), ReadCookies(), SetCookiename(), and SetTheCookie().
bool Cgi::MenuWeb::m_bSetCookie [private] |
Definition at line 104 of file MenuWeb.h.
Referenced by CreateHeader(), SetMenuStyle(), and SetPage().
menuitem_v Cgi::MenuWeb::m_items [private] |
Definition at line 105 of file MenuWeb.h.
Referenced by AddMenuImage(), AddMenuItem(), AddMenuLink(), AddMenuSeparator(), GenerateDocument(), and ~MenuWeb().
std::string Cgi::MenuWeb::m_strClass [private] |