#ifndef __PLAYER_MENU_SERVICE_WIN_H_ #define __PLAYER_MENU_SERVICE_WIN_H_ #include #include #include "cocos2d.h" #include "stdafx.h" #include "PlayerMenuServiceProtocol.h" PLAYER_NS_BEGIN class PlayerMenuItemWin : public PlayerMenuItem { public: static PlayerMenuItemWin *create(const std::string &menuId, const std::string &title); virtual ~PlayerMenuItemWin(); virtual void setTitle(const std::string &title); virtual void setEnabled(bool enabled); virtual void setChecked(bool checked); virtual void setShortcut(const std::string &shortcut); protected: PlayerMenuItemWin(); PlayerMenuItemWin *_parent; UINT _commandId; HMENU _hmenu; bool _menubarEnabled; cocos2d::Vector _children; friend class PlayerMenuServiceWin; }; class PlayerMenuServiceWin : public PlayerMenuServiceProtocol { public: PlayerMenuServiceWin(HWND hwnd); virtual ~PlayerMenuServiceWin(); virtual PlayerMenuItem *addItem(const std::string &menuId, const std::string &title, const std::string &parentId, int order = MAX_ORDER); virtual PlayerMenuItem *addItem(const std::string &menuId, const std::string &title); virtual PlayerMenuItem *getItem(const std::string &menuId); virtual bool removeItem(const std::string &menuId); virtual void setMenuBarEnabled(bool enabled); PlayerMenuItemWin *getItemByCommandId(WORD commandId); private: static WORD _newCommandId; HWND _hwnd; bool _menubarEnabled; PlayerMenuItemWin _root; std::unordered_map _items; std::unordered_map _commandId2menuId; bool removeItemInternal(const std::string &menuId, bool isUpdateChildrenOrder); void updateChildrenOrder(PlayerMenuItemWin *parent); }; PLAYER_NS_END #endif // __PLAYER_MENU_SERVICE_WIN_H_