mirror of https://github.com/axmolengine/axmol.git
140 lines
5.1 KiB
Plaintext
140 lines
5.1 KiB
Plaintext
#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 registerMenuHandler(const char* fn);
|
|
|
|
};
|
|
|
|
class CCMenuItemLabel : public CCMenuItem, public CCRGBAProtocol
|
|
{
|
|
|
|
public:
|
|
CCMenuItemLabel();
|
|
|
|
static CCMenuItemLabel * itemWithLabel(CCNode*label, SelectorProtocol* target, SEL_MenuHandler selector);
|
|
|
|
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* itemWithTarget(SelectorProtocol* target, SEL_MenuHandler selector, CCMenuItem* item, ...);
|
|
// bool initWithTarget(SelectorProtocol* target, SEL_MenuHandler selector, CCMenuItem* item, va_list args);
|
|
CCMenuItem* selectedItem();
|
|
// super methods
|
|
virtual void activate();
|
|
virtual void selected();
|
|
virtual void unselected();
|
|
void setIsEnabled(bool var);
|
|
CCRGBAProtocol* convertToRGBAProtocol();
|
|
};
|
|
|
|
}
|
|
|