Google
Web alhem.net
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

Menu.cpp

Go to the documentation of this file.
00001 00005 /* 00006 Copyright (C) 2004 Anders Hedström (grymse@alhem.net) 00007 00008 This program is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU General Public License 00010 as published by the Free Software Foundation; either version 2 00011 of the License, or (at your option) any later version. 00012 00013 This program is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this program; if not, write to the Free Software 00020 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00021 */ 00022 #include <windows.h> 00023 #include "MenuHandler.h" 00024 #include "Menu.h" 00025 00026 00027 00028 Menu::Menu(MenuHandler& h,HMENU handle) : m_handler(h) 00029 ,m_h(handle) 00030 ,m_bInit(false) 00031 ,m_parent(NULL) 00032 { 00033 h.Add( this ); 00034 } 00035 00036 00037 Menu::~Menu() 00038 { 00039 for (menu_v::iterator it = m_submenulist.begin(); it != m_submenulist.end(); it++) 00040 { 00041 Menu *p = *it; 00042 Handler().Remove(p); 00043 delete p; 00044 } 00045 Handler().Remove( this ); 00046 } 00047 00048 00049 void Menu::OnInitPopupMenu(int relpos, bool winmenu) 00050 { 00051 if (!m_bInit) 00052 { 00053 Init(); 00054 m_bInit = true; 00055 } 00056 } 00057 00058 00059 void Menu::AddSubmenu(Menu *x) 00060 { 00061 m_submenulist.push_back(x); 00062 x->SetParent( this ); 00063 } 00064 00065 00066 int Menu::AddMenuitem(UINT flags,LPCTSTR item,UINT_PTR id_in) 00067 { 00068 int id = id_in; 00069 if (!id && item) 00070 { 00071 id = Handler().get_next_id(this); 00072 } 00073 AppendMenu(Handle(), flags, id, item); 00074 return id; 00075 } 00076 00077 00078 void Menu::Enable(int id,bool bEnable) 00079 { 00080 if (bEnable) 00081 { 00082 ::EnableMenuItem(Handle(), id, MF_ENABLED); 00083 } 00084 else 00085 { 00086 ::EnableMenuItem(Handle(), id, MF_DISABLED|MF_GRAYED); 00087 } 00088 } 00089 00090

Generated on Thu Feb 10 22:42:34 2005 for Distributed URL Classification Tool by doxygen 1.3.7