00001
00011 #ifndef DEFINE_H_YMENU
00012 #define DEFINE_H_YMENU
00013
00014 #include <vector>
00015 #include <map>
00016 #include <basic.h>
00017 #include <btron/hmi.h>
00018 #include "yaction.h"
00019 #include "ystring.h"
00020
00021 class YMenuSeparator;
00022 class YMenuLabel;
00023 class YMenuParentLabel;
00024
00030 class YMenuItem {
00031
00032 protected:
00033 enum YMenuItemType { LABEL, SEPARATOR, SWITCH, PARENT } type;
00034
00035 public:
00037 YMenuSeparator* createSeparator();
00038
00040 YMenuLabel* createLabel(const YString& label, YAction* act, bool inactive = false);
00041
00043 YMenuLabel* createSwitch(const YString& label, YAction* act, bool indicator = false, bool inact = false);
00044
00046 YMenuParentLabel* createParentLabel(const YString& label, bool inactive = false);
00047
00048 };
00049
00056 class YMenuSeparator : public YMenuItem {
00057 friend class YMenuItem;
00058 };
00059
00067 class YMenuLabel : public YMenuItem {
00068 friend class YMenuItem;
00069
00070 protected:
00071 YAction *act;
00072 YString label;
00073 bool inact;
00074 bool indicator;
00075 };
00076
00083 class YMenuParentLabel : public YMenuItem {
00084 friend class YMenuItem;
00085
00086 protected:
00087 YString label;
00088 std::vector<YMenuItem*> mitem;
00089 bool inact;
00090
00091 public:
00092 void add(YMenuItem *item);
00093
00094 };
00095
00100 class YMenu {
00101 private:
00102 bool dirty;
00103 std::vector<YString*> menuitem;
00104 std::vector<YMenuItem*> menu;
00105 std::map<int, YAction*> actionMap;
00106 int currentChildNumber;
00107
00108 public:
00110 YMenu() {
00111 currentChildNumber = 0;
00112 dirty = false;
00113 }
00114
00120 void addItem(YMenuItem* item);
00121
00123 virtual ~YMenu() {
00124
00125 ;
00126 }
00127
00128 };
00129 #endif // DEFINE_H_YMENU
00130