1 #ifndef _SHARED_PLATFORM_POPUPMENU_H_ 2 #define _SHARED_PLATFORM_POPUPMENU_H_ 3 4 #include <vector> 5 #include <string> 6 #include <windows.h> 7 8 using std::vector; 9 using std::string; 10 11 namespace Shared{ namespace Platform{ 12 13 class Menu; 14 15 // ===================================================== 16 // class MenuBase 17 // ===================================================== 18 19 class MenuBase{ 20 private: 21 static int nextId; 22 23 protected: 24 int id; 25 string text; 26 HMENU handle; 27 28 public: 29 void init(const string &text=""); ~MenuBase()30 virtual ~MenuBase(){}; 31 32 virtual void create(Menu *parent)= 0; destroy()33 virtual void destroy(){}; 34 getId()35 int getId() const {return id;} getText()36 const string &getText() const {return text;} getHandle()37 HMENU getHandle() const {return handle;} 38 }; 39 40 // ===================================================== 41 // class Menu 42 // ===================================================== 43 44 class Menu: public MenuBase{ 45 private: 46 typedef vector<MenuBase*> MenuChildren; 47 48 private: 49 MenuChildren children; 50 51 public: 52 virtual void create(Menu *parent= NULL); 53 virtual void destroy(); 54 getChildCount()55 int getChildCount() const {return children.size();} getChild(int i)56 MenuBase *getChild(int i) const {return children[i];} 57 addChild(MenuBase * menu)58 void addChild(MenuBase *menu) {children.push_back(menu);} 59 }; 60 61 // ===================================================== 62 // class MenuItem 63 // ===================================================== 64 65 class MenuItem: public MenuBase{ 66 private: 67 bool isChecked; 68 Menu *parent; 69 70 public: 71 virtual void create(Menu *parent); 72 73 void setChecked(bool checked); 74 getParent()75 Menu *getParent() const {return parent;} getChecked()76 bool getChecked() const {return isChecked;} 77 }; 78 79 // ===================================================== 80 // class MenuSeparator 81 // ===================================================== 82 83 class MenuSeparator: public MenuBase{ 84 public: 85 virtual void create(Menu *parent); 86 }; 87 88 }}//end namespace 89 90 #endif 91