#include "CCNode.h" #include "CCProtocols.h" #include "selector_protocol.h" namespace cocos2d{ class CCLabelTTF; class CCLabelAtlas; class CCSprite; class CCMenuItem : public CCNode { public: CCMenuItem(); static CCMenuItem * itemWithTarget(SelectorProtocol *rec, SEL_MenuHandler selector); bool initWithTarget(SelectorProtocol *rec, SEL_MenuHandler selector); CCRect rect(); void activate(); void selected(); void unselected(); void registerScriptHandler(const char* pszFunctionName); }; class CCMenuItemLabel : public CCMenuItem, public CCRGBAProtocol { public: CCMenuItemLabel(); static CCMenuItemLabel * itemWithLabel(CCNode*label, SelectorProtocol* target, SEL_MenuHandler selector); static CCMenuItemLabel* itemWithLabel(CCNode *label); bool initWithLabel(CCNode* label, SelectorProtocol* target, SEL_MenuHandler selector); void setString(const char * label); virtual void activate(); virtual void selected(); virtual void unselected(); virtual void setIsEnabled(bool enabled); virtual void setOpacity(GLubyte opacity); virtual GLubyte getOpacity(); virtual void setColor(ccColor3B color); virtual ccColor3B getColor(); virtual CCRGBAProtocol* convertToRGBAProtocol(); }; /** @brief A CCMenuItemAtlasFont Helper class that creates a MenuItemLabel class with a LabelAtlas */ class CCMenuItemAtlasFont : public CCMenuItemLabel { CCMenuItemAtlasFont(); static CCMenuItemAtlasFont* itemFromString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap); /** creates a menu item from a string and atlas. Use it with MenuItemToggle */ static CCMenuItemAtlasFont* itemFromString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, SelectorProtocol* target, SEL_MenuHandler selector); /** initializes a menu item from a string and atlas with a target/selector */ bool initFromString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, SelectorProtocol* target, SEL_MenuHandler selector); }; class CCMenuItemFont : public CCMenuItemLabel { CCMenuItemFont(); static void setFontSize(int s); static int fontSize(); /** set the font name */ static void setFontName(const char *name); /** get the font name */ static const char *fontName(); /** creates a menu item from a string without target/selector. To be used with CCMenuItemToggle */ static CCMenuItemFont * itemFromString(const char *value); /** creates a menu item from a string with a target/selector */ static CCMenuItemFont * itemFromString(const char *value, SelectorProtocol* target, SEL_MenuHandler selector); /** initializes a menu item from a string with a target/selector */ bool initFromString(const char *value, SelectorProtocol* target, SEL_MenuHandler selector); }; class CCMenuItemSprite : public CCMenuItem, public CCRGBAProtocol { CCMenuItemSprite(); static CCMenuItemSprite * itemFromNormalSprite(CCNode* normalSprite, CCNode* selectedSprite); static CCMenuItemSprite * itemFromNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, SelectorProtocol* target, SEL_MenuHandler selector); static CCMenuItemSprite * itemFromNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite, SelectorProtocol* target, SEL_MenuHandler selector); bool initFromNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite, SelectorProtocol* target, SEL_MenuHandler selector); void setColor(ccColor3B color); ccColor3B getColor(); void setOpacity(GLubyte opacity); GLubyte getOpacity(); void selected(); void unselected(); void setIsEnabled(bool bEnabled); CCRGBAProtocol* convertToRGBAProtocol(); }; class CCMenuItemImage : public CCMenuItemSprite { CCMenuItemImage(); static CCMenuItemImage* itemFromNormalImage(const char *normalImage, const char *selectedImage); static CCMenuItemImage* itemFromNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage); static CCMenuItemImage* itemFromNormalImage(const char *normalImage, const char *selectedImage, SelectorProtocol* target, SEL_MenuHandler selector); static CCMenuItemImage* itemFromNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, SelectorProtocol* target, SEL_MenuHandler selector); bool initFromNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, SelectorProtocol* target, SEL_MenuHandler selector); void setColor(ccColor3B color); ccColor3B getColor(); void setOpacity(GLubyte opacity); GLubyte getOpacity(); }; class CCMenuItemToggle : public CCMenuItem, public CCRGBAProtocol { CCMenuItemToggle(); static CCMenuItemToggle* itemWithItem(CCMenuItem *item); bool initWithItem(CCMenuItem *item); void addSubItem(CCMenuItem *item); CCMenuItem* selectedItem(); // super methods virtual void activate(); virtual void selected(); virtual void unselected(); void setIsEnabled(bool var); CCRGBAProtocol* convertToRGBAProtocol(); }; }