Google
Web alhem.net

MenuWeb.h

Go to the documentation of this file.
00001 // MenuWeb.h
00002 /*
00003 Copyright (C) 2003  Anders Hedstrom
00004 
00005 This program is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU General Public License
00007 as published by the Free Software Foundation; either version 2
00008 of the License, or (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 */
00019 
00020 #ifndef _MENUWEB_H
00021 #define _MENUWEB_H
00022 
00023 #ifdef _WIN32
00024 #define STL_USING_VECTOR
00025 #include <stlhelper.h>
00026 #else
00027 #include <vector>
00028 #endif
00029 
00030 namespace Cgi {
00031 
00033 
00034 enum
00035 {
00036         MENUITEM_TYPE_FORM = 1,
00037         MENUITEM_TYPE_SEPARATOR,
00038         MENUITEM_TYPE_URL,
00039         MENUITEM_TYPE_IMAGE
00040 };
00041 
00042 
00044 
00045 enum 
00046 {
00047         MENU_STYLE_FRAME_LEFT = 1,
00048         MENU_STYLE_TOP,
00049         MENU_STYLE_LEFT
00050 };
00051 
00052 
00054 
00055 typedef struct
00056 {
00057         int num;
00058         int type;
00059         WebForm *form;
00060         std::string title;
00061         std::string url; // <a href=...>
00062         std::string src; // <img src=...>
00063 } MENUITEM;
00064 typedef std::vector<MENUITEM *> menuitem_v;
00065 
00066 
00068 
00069 class MenuWeb : public Web
00070 {
00071 public:
00072         MenuWeb(int = MENU_STYLE_TOP);
00073         MenuWeb(const std::string &,const std::string &,int = MENU_STYLE_TOP);
00074         MenuWeb(int argc,char *argv[],const std::string &,const std::string &,int = MENU_STYLE_TOP);
00075         ~MenuWeb();
00076 
00077         void SetMenuStyle(int);
00078 
00079         const MENUITEM & AddMenuItem(WebForm *,const std::string &title);
00080         void AddMenuSeparator();
00081         void AddMenuLink(const std::string &url,const std::string &title);
00082         void AddMenuImage(const std::string &src);
00083 
00084         virtual void ReadCookies();
00085         virtual void FormInput();
00086         virtual void CreateHeader();
00087         virtual void GenerateDocument();
00088 
00089         std::string GetCookiename() { return m_cookiename; }
00090         void SetCookiename(const std::string &str) { m_cookiename = str; }
00091         void SetPage(int x) { m_page = x; m_bSetCookie = true; }
00092         int GetPage() { return m_page; }
00093         void SetMenuclass(const std::string &x) { m_strClass = x; }
00094 
00095         void SetTheCookie();
00096 
00097 private:
00098   MenuWeb(const MenuWeb& ) {}
00099   MenuWeb& operator=(const MenuWeb& ) { return *this; }
00100         int m_count;
00101         int m_style;
00102         int m_page;
00103         std::string m_cookiename;
00104         bool m_bSetCookie;
00105         menuitem_v m_items;
00106         std::string m_strClass;
00107 };
00108 
00109 } // namespace
00110 
00111 #endif // _MENUWEB_H

Generated for cgi++ by doxygen 1.3.7

Page, code, and content Copyright (C) 2004 by Anders Hedström