00001
00002
00003
00004
00005
00006
00007 #ifndef M_MENU_H
00008 #define M_MENU_H
00009
00010 namespace MWidgets
00011 {
00012
00014 class Menu
00015 {
00016 protected:
00017 HMENU m_hMenu;
00018 std::map<std::string,BaseEventHandler*> m_mapHandlers;
00019 public:
00021 Menu();
00023 ~Menu();
00025 HMENU GetHMENU();
00030 void InsertSubMenu(string path,int position, string label);
00034 void UpdateSubMenu(string path, string label);
00038 void EnableSubMenu(string path, BOOL enable);
00041 void RemoveSubMenu(string path);
00047 void InsertSubMenuItem(string path,int position, string label,BaseEventHandler* pEventHandler);
00054 template<class T>
00055 void InsertSubMenuItem(string path,int position, string label,T *pProcessor,void (T::*EventCallBack)(Widget* sender))
00056 {
00057 BaseEventHandler* onClickHandler=new EventHandler<T>(pProcessor,EventCallBack);
00058 InsertSubMenuItem(path,position, label,onClickHandler);
00059 };
00063 void InsertSubMenuSeparator(string path,int position);
00066 void RemoveSubMenuItem(string path);
00070 void EnableSubMenuItem(string path, BOOL enable);
00074 void UpdateSubMenuItem(string path, string label);
00078 void UpdateSubMenuItem(string path, BaseEventHandler* pEventHandler);
00083 template<class T>
00084 void UpdateSubMenuItem(string path,T *pProcessor,void (T::*EventCallBack)(Widget* sender))
00085 {
00086 BaseEventHandler* onClickHandler=new EventHandler<T>(pProcessor,EventCallBack);
00087 UpdateSubMenuItem(path,onClickHandler);
00088 };
00089 };
00090
00092 class ContextMenu:public Menu
00093 {
00094 public:
00095 ContextMenu();
00096 void TrackMenu(int x,int y,Widget* pParent);
00097 };
00098 };
00099
00100 #endif