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