2011-03-19 10:59:01 +08:00
|
|
|
/****************************************************************************
|
2014-01-07 11:25:07 +08:00
|
|
|
Copyright (c) 2008-2010 Ricardo Quesada
|
2012-06-14 15:13:16 +08:00
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
2011-07-04 14:47:32 +08:00
|
|
|
Copyright (c) 2011 Zynga Inc.
|
2014-01-07 11:25:07 +08:00
|
|
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
2011-03-19 10:59:01 +08:00
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __CCMENU_ITEM_H__
|
|
|
|
#define __CCMENU_ITEM_H__
|
|
|
|
|
2013-06-05 09:29:26 +08:00
|
|
|
// C++ includes
|
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
// cocos2d includes
|
2014-04-27 01:11:22 +08:00
|
|
|
#include "2d/CCNode.h"
|
2014-05-17 05:36:00 +08:00
|
|
|
#include "base/CCProtocols.h"
|
2011-03-19 10:59:01 +08:00
|
|
|
|
2012-04-18 18:43:45 +08:00
|
|
|
NS_CC_BEGIN
|
2013-06-05 09:29:26 +08:00
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
typedef std::function<void(Ref*)> ccMenuCallback;
|
2013-06-05 09:29:26 +08:00
|
|
|
|
2014-03-14 17:36:05 +08:00
|
|
|
class Label;
|
2013-06-20 14:13:12 +08:00
|
|
|
class LabelAtlas;
|
|
|
|
class Sprite;
|
|
|
|
class SpriteFrame;
|
|
|
|
#define kItemSize 32
|
2012-02-02 10:39:36 +08:00
|
|
|
|
2012-06-20 18:09:11 +08:00
|
|
|
/**
|
2015-03-25 18:17:58 +08:00
|
|
|
* @addtogroup _2d
|
2012-06-20 18:09:11 +08:00
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** @brief MenuItem base class.
|
2012-04-18 18:43:45 +08:00
|
|
|
*
|
2013-06-20 14:13:12 +08:00
|
|
|
* Subclass MenuItem (or any subclass) to create your custom MenuItem objects.
|
2012-04-18 18:43:45 +08:00
|
|
|
*/
|
2013-12-06 18:07:16 +08:00
|
|
|
class CC_DLL MenuItem : public Node
|
2012-04-18 18:43:45 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Creates a MenuItem with no target/selector. */
|
2013-07-18 07:56:19 +08:00
|
|
|
static MenuItem* create();
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Creates a MenuItem with a target/selector. */
|
2014-02-20 10:53:49 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE static MenuItem* create(Ref *rec, SEL_MenuHandler selector);
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Creates a MenuItem with a target/selector. */
|
2013-07-18 07:56:19 +08:00
|
|
|
static MenuItem* create(const ccMenuCallback& callback);
|
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Returns the outside box. */
|
2013-07-18 07:56:19 +08:00
|
|
|
Rect rect() const;
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Activate the item. */
|
2012-04-18 18:43:45 +08:00
|
|
|
virtual void activate();
|
2015-03-25 18:17:58 +08:00
|
|
|
/** The item was selected (not activated), similar to "mouse-over". */
|
2012-04-18 18:43:45 +08:00
|
|
|
virtual void selected();
|
2015-03-25 18:17:58 +08:00
|
|
|
/** The item was unselected. */
|
2012-04-18 18:43:45 +08:00
|
|
|
virtual void unselected();
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Returns whether or not the item is enabled. */
|
2013-07-04 12:50:17 +08:00
|
|
|
virtual bool isEnabled() const;
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Enables or disables the item. */
|
2012-06-15 16:47:30 +08:00
|
|
|
virtual void setEnabled(bool value);
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Returns whether or not the item is selected. */
|
2013-07-04 12:50:17 +08:00
|
|
|
virtual bool isSelected() const;
|
2013-07-18 07:56:19 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
virtual void onExit() override;
|
2014-09-14 21:41:19 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Set the callback to the menu item.
|
2013-09-13 11:41:20 +08:00
|
|
|
* @code
|
2015-03-25 18:17:58 +08:00
|
|
|
* In js,can contain two params,the second param is jsptr.
|
2013-09-13 11:41:20 +08:00
|
|
|
* @endcode
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-06-05 09:29:26 +08:00
|
|
|
void setCallback(const ccMenuCallback& callback);
|
2015-03-25 18:17:58 +08:00
|
|
|
|
|
|
|
/** Set the target/selector of the menu item.
|
2013-09-13 11:41:20 +08:00
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2014-02-20 10:53:49 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE void setTarget(Ref *rec, SEL_MenuHandler selector);
|
2012-09-11 14:02:33 +08:00
|
|
|
|
2013-12-13 06:30:22 +08:00
|
|
|
|
|
|
|
virtual std::string getDescription() const override;
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-16 05:14:12 +08:00
|
|
|
/**
|
|
|
|
* @js ctor
|
|
|
|
*/
|
|
|
|
MenuItem()
|
|
|
|
: _selected(false)
|
|
|
|
, _enabled(false)
|
|
|
|
, _callback(nullptr)
|
2013-12-18 17:47:20 +08:00
|
|
|
, _target(nullptr)
|
2013-11-16 05:14:12 +08:00
|
|
|
{}
|
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
|
|
|
virtual ~MenuItem();
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Initializes a MenuItem with a target/selector.
|
2013-11-16 05:14:12 +08:00
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
|
|
|
bool initWithCallback(const ccMenuCallback& callback);
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Initializes a MenuItem with a target/selector.
|
2013-11-16 05:14:12 +08:00
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2014-02-20 10:53:49 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE bool initWithTarget(Ref *rec, SEL_MenuHandler selector);
|
2013-11-16 05:14:12 +08:00
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
protected:
|
2013-06-15 14:03:30 +08:00
|
|
|
bool _selected;
|
|
|
|
bool _enabled;
|
2015-03-25 18:17:58 +08:00
|
|
|
// callback
|
|
|
|
ccMenuCallback _callback;
|
|
|
|
// If using the old API, the _target needs to be retained / released
|
|
|
|
Ref *_target;
|
2013-11-16 05:14:12 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(MenuItem);
|
2012-04-18 18:43:45 +08:00
|
|
|
};
|
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** @brief An abstract class for "label" MenuItemLabel items.
|
2013-06-20 14:13:12 +08:00
|
|
|
Any Node that supports the LabelProtocol protocol can be added.
|
2012-04-18 18:43:45 +08:00
|
|
|
Supported nodes:
|
2013-06-20 14:13:12 +08:00
|
|
|
- BitmapFontAtlas
|
|
|
|
- LabelAtlas
|
|
|
|
- LabelTTF
|
2014-03-14 17:36:05 +08:00
|
|
|
- Label
|
2012-04-18 18:43:45 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL MenuItemLabel : public MenuItem
|
2012-04-18 18:43:45 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Creates a MenuItemLabel with a Label, target and selector. */
|
2014-02-20 10:53:49 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE static MenuItemLabel * create(Node*label, Ref* target, SEL_MenuHandler selector);
|
2013-06-05 09:29:26 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Creates a MenuItemLabel with a Label and a callback. */
|
2013-06-20 14:13:12 +08:00
|
|
|
static MenuItemLabel * create(Node*label, const ccMenuCallback& callback);
|
2013-06-05 09:29:26 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Creates a MenuItemLabel with a Label. Target and selector will be nil. */
|
2013-06-20 14:13:12 +08:00
|
|
|
static MenuItemLabel* create(Node *label);
|
2013-07-18 07:56:19 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Sets a new string to the inner label. */
|
2013-11-07 09:05:13 +08:00
|
|
|
void setString(const std::string& label);
|
2013-07-18 07:56:19 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Gets the color that will be used to disable the item. */
|
2013-07-23 20:36:41 +08:00
|
|
|
inline const Color3B& getDisabledColor() const { return _disabledColor; };
|
2013-07-23 18:26:26 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Sets the color that will be used to disable the item. */
|
2013-07-23 20:36:41 +08:00
|
|
|
inline void setDisabledColor(const Color3B& color) { _disabledColor = color; };
|
2013-07-23 18:26:26 +08:00
|
|
|
|
|
|
|
/** Gets the label that is rendered. */
|
2013-07-23 20:36:41 +08:00
|
|
|
inline Node* getLabel() const { return _label; };
|
2013-07-23 18:26:26 +08:00
|
|
|
|
|
|
|
/** Sets the label that is rendered. */
|
|
|
|
void setLabel(Node* node);
|
|
|
|
|
2013-07-18 07:56:19 +08:00
|
|
|
// Overrides
|
|
|
|
virtual void activate() override;
|
|
|
|
virtual void selected() override;
|
|
|
|
virtual void unselected() override;
|
|
|
|
virtual void setEnabled(bool enabled) override;
|
2012-04-18 18:43:45 +08:00
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-16 05:14:12 +08:00
|
|
|
/**
|
|
|
|
* @js ctor
|
|
|
|
*/
|
|
|
|
MenuItemLabel()
|
|
|
|
: _originalScale(0.0)
|
2013-12-18 17:47:20 +08:00
|
|
|
, _label(nullptr)
|
2013-11-16 05:14:12 +08:00
|
|
|
{}
|
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
|
|
|
virtual ~MenuItemLabel();
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Initializes a MenuItemLabel with a Label, target and selector. */
|
2013-11-16 05:14:12 +08:00
|
|
|
bool initWithLabel(Node* label, const ccMenuCallback& callback);
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Initializes a MenuItemLabel with a Label, target and selector. */
|
2014-02-20 10:53:49 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE bool initWithLabel(Node* label, Ref* target, SEL_MenuHandler selector);
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
protected:
|
2013-07-05 16:49:22 +08:00
|
|
|
Color3B _colorBackup;
|
|
|
|
float _originalScale;
|
2013-07-18 07:56:19 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** The color that will be used to disable the item. */
|
2013-07-23 18:26:26 +08:00
|
|
|
Color3B _disabledColor;
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Label that is rendered. It can be any Node that implements the LabelProtocol. */
|
2013-07-23 18:26:26 +08:00
|
|
|
Node* _label;
|
2013-11-16 05:14:12 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(MenuItemLabel);
|
2012-04-18 18:43:45 +08:00
|
|
|
};
|
|
|
|
|
2012-07-13 09:53:38 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** @brief A MenuItemAtlasFont.
|
|
|
|
Helper class that creates a MenuItemLabel class with a LabelAtlas.
|
2012-04-18 18:43:45 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL MenuItemAtlasFont : public MenuItemLabel
|
2012-04-18 18:43:45 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Creates a menu item from a string and atlas with a target/selector. */
|
2013-12-05 17:19:01 +08:00
|
|
|
static MenuItemAtlasFont* create(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap);
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Creates a menu item from a string and atlas. Use it with MenuItemToggle. */
|
2014-02-20 10:53:49 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE static MenuItemAtlasFont* create(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, Ref* target, SEL_MenuHandler selector);
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Creates a menu item from a string and atlas. Use it with MenuItemToggle. */
|
2013-12-05 17:19:01 +08:00
|
|
|
static MenuItemAtlasFont* create(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, const ccMenuCallback& callback);
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-09-13 16:46:31 +08:00
|
|
|
/**
|
|
|
|
* @js ctor
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
MenuItemAtlasFont(){}
|
2013-09-13 13:52:42 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual ~MenuItemAtlasFont(){}
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Initializes a menu item from a string and atlas with a target/selector. */
|
2014-02-20 10:53:49 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE bool initWithString(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, Ref* target, SEL_MenuHandler selector);
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Initializes a menu item from a string and atlas with a target/selector. */
|
2013-12-05 17:19:01 +08:00
|
|
|
bool initWithString(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, const ccMenuCallback& callback);
|
2013-11-16 05:14:12 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(MenuItemAtlasFont);
|
2012-04-18 18:43:45 +08:00
|
|
|
};
|
|
|
|
|
2012-07-13 09:53:38 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** @brief A MenuItemFont.
|
|
|
|
Helper class that creates a MenuItemLabel class with a Label.
|
2012-04-18 18:43:45 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL MenuItemFont : public MenuItemLabel
|
2012-04-18 18:43:45 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Creates a menu item from a string without target/selector. To be used with MenuItemToggle. */
|
2013-11-26 15:44:21 +08:00
|
|
|
static MenuItemFont * create(const std::string& value = "");
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Creates a menu item from a string with a target/selector. */
|
2014-02-20 10:53:49 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE static MenuItemFont * create(const std::string& value, Ref* target, SEL_MenuHandler selector);
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Creates a menu item from a string with a target/selector. */
|
2013-11-07 09:05:13 +08:00
|
|
|
static MenuItemFont * create(const std::string& value, const ccMenuCallback& callback);
|
2013-06-05 09:29:26 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Set default font size. */
|
2013-12-05 17:19:01 +08:00
|
|
|
static void setFontSize(int size);
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Get default font size. */
|
2013-12-05 17:19:01 +08:00
|
|
|
static int getFontSize();
|
|
|
|
CC_DEPRECATED_ATTRIBUTE static int fontSize() { return MenuItemFont::getFontSize(); };
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Set the default font name. */
|
2013-11-07 09:05:13 +08:00
|
|
|
static void setFontName(const std::string& name);
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Get the default font name. */
|
2013-11-07 09:05:13 +08:00
|
|
|
static const std::string& getFontName();
|
|
|
|
CC_DEPRECATED_ATTRIBUTE static const std::string& fontName() { return MenuItemFont::getFontName(); };
|
2013-07-18 07:56:19 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Set font size.
|
|
|
|
* c++ can not overload static and non-static member functions with the same parameter types.
|
|
|
|
* so change the name to setFontSizeObj.
|
2013-09-13 11:41:20 +08:00
|
|
|
* @js setFontSize
|
2012-02-02 10:39:36 +08:00
|
|
|
*/
|
2013-12-05 17:19:01 +08:00
|
|
|
void setFontSizeObj(int size);
|
2012-04-18 18:43:45 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** get font size .
|
2013-09-13 11:41:20 +08:00
|
|
|
* @js getFontSize
|
|
|
|
*/
|
2013-12-05 17:19:01 +08:00
|
|
|
int getFontSizeObj() const;
|
|
|
|
CC_DEPRECATED_ATTRIBUTE int fontSizeObj() const { return getFontSizeObj(); };
|
2012-02-02 10:39:36 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/**
|
|
|
|
* Set the font name .
|
|
|
|
* c++ can not overload static and non-static member functions with the same parameter types.
|
|
|
|
* so change the name to setFontNameObj.
|
2013-09-13 11:41:20 +08:00
|
|
|
* @js setFontName
|
2012-02-02 10:39:36 +08:00
|
|
|
*/
|
2013-11-07 09:05:13 +08:00
|
|
|
void setFontNameObj(const std::string& name);
|
2013-07-18 07:56:19 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Returns the name of the Font.
|
2013-09-13 11:41:20 +08:00
|
|
|
* @js getFontNameObj
|
|
|
|
*/
|
2013-11-07 09:05:13 +08:00
|
|
|
const std::string& getFontNameObj() const;
|
2013-07-18 07:56:19 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Deprecated Use getFontNameObj() instead. */
|
2013-11-07 09:05:13 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE const std::string& fontNameObj() const { return getFontNameObj(); }
|
2012-04-18 18:43:45 +08:00
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-16 05:14:12 +08:00
|
|
|
/**
|
|
|
|
* @js ctor
|
|
|
|
*/
|
|
|
|
MenuItemFont();
|
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
|
|
|
virtual ~MenuItemFont();
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Initializes a menu item from a string with a target/selector. */
|
2014-02-20 10:53:49 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE bool initWithString(const std::string& value, Ref* target, SEL_MenuHandler selector);
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Initializes a menu item from a string with a target/selector. */
|
2013-11-16 05:14:12 +08:00
|
|
|
bool initWithString(const std::string& value, const ccMenuCallback& callback);
|
2012-02-02 10:39:36 +08:00
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
protected:
|
2013-12-05 17:19:01 +08:00
|
|
|
int _fontSize;
|
2013-06-15 14:03:30 +08:00
|
|
|
std::string _fontName;
|
2013-11-16 05:14:12 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(MenuItemFont);
|
2012-04-18 18:43:45 +08:00
|
|
|
};
|
|
|
|
|
2012-07-13 09:53:38 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
/** @brief MenuItemSprite accepts Node<RGBAProtocol> objects as items.
|
2012-04-18 18:43:45 +08:00
|
|
|
The images has 3 different states:
|
|
|
|
- unselected image
|
|
|
|
- selected image
|
|
|
|
- disabled image
|
|
|
|
|
|
|
|
@since v0.8.0
|
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL MenuItemSprite : public MenuItem
|
2012-04-18 18:43:45 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Creates a menu item with a normal, selected and disabled image.*/
|
2013-12-18 17:47:20 +08:00
|
|
|
static MenuItemSprite * create(Node* normalSprite, Node* selectedSprite, Node* disabledSprite = nullptr);
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Creates a menu item with a normal and selected image with target/selector. */
|
2014-02-20 10:53:49 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE static MenuItemSprite * create(Node* normalSprite, Node* selectedSprite, Ref* target, SEL_MenuHandler selector);
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Creates a menu item with a normal,selected and disabled image with target/selector. */
|
2014-02-20 10:53:49 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE static MenuItemSprite * create(Node* normalSprite, Node* selectedSprite, Node* disabledSprite, Ref* target, SEL_MenuHandler selector);
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Creates a menu item with a normal and selected image with a callable object. */
|
2013-06-20 14:13:12 +08:00
|
|
|
static MenuItemSprite * create(Node* normalSprite, Node* selectedSprite, const ccMenuCallback& callback);
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Creates a menu item with a normal,selected and disabled image with target/selector. */
|
2013-06-20 14:13:12 +08:00
|
|
|
static MenuItemSprite * create(Node* normalSprite, Node* selectedSprite, Node* disabledSprite, const ccMenuCallback& callback);
|
2012-06-14 15:13:16 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Gets the image used when the item is not selected. */
|
2013-07-23 20:36:41 +08:00
|
|
|
inline Node* getNormalImage() const { return _normalImage; };
|
2013-07-23 18:26:26 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Sets the image used when the item is not selected. */
|
2013-07-23 20:36:41 +08:00
|
|
|
void setNormalImage(Node* image);
|
2013-07-23 18:26:26 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Gets the image used when the item is selected. */
|
2013-07-23 20:36:41 +08:00
|
|
|
inline Node* getSelectedImage() const { return _selectedImage; };
|
2013-07-23 18:26:26 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Sets the image used when the item is selected. */
|
2013-07-23 20:36:41 +08:00
|
|
|
void setSelectedImage(Node* image);
|
2013-07-23 18:26:26 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Gets the image used when the item is disabled. */
|
2013-07-23 20:36:41 +08:00
|
|
|
inline Node* getDisabledImage() const { return _disabledImage; };
|
2013-07-23 18:26:26 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Sets the image used when the item is disabled. */
|
2013-07-23 20:36:41 +08:00
|
|
|
void setDisabledImage(Node* image);
|
2013-07-23 18:26:26 +08:00
|
|
|
|
2012-04-18 18:43:45 +08:00
|
|
|
/**
|
2015-03-25 18:17:58 +08:00
|
|
|
* The item was selected (not activated), similar to "mouse-over".
|
2012-04-18 18:43:45 +08:00
|
|
|
@since v0.99.5
|
2012-02-02 10:39:36 +08:00
|
|
|
*/
|
2012-04-18 18:43:45 +08:00
|
|
|
virtual void selected();
|
2015-03-25 18:17:58 +08:00
|
|
|
|
|
|
|
/** The item was unselected. */
|
2012-04-18 18:43:45 +08:00
|
|
|
virtual void unselected();
|
2015-03-25 18:17:58 +08:00
|
|
|
|
|
|
|
/** Enables or disables the item. */
|
2012-06-15 16:47:30 +08:00
|
|
|
virtual void setEnabled(bool bEnabled);
|
2012-02-02 10:39:36 +08:00
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-16 05:14:12 +08:00
|
|
|
MenuItemSprite()
|
2013-12-18 17:47:20 +08:00
|
|
|
:_normalImage(nullptr)
|
|
|
|
,_selectedImage(nullptr)
|
|
|
|
,_disabledImage(nullptr)
|
2013-11-16 05:14:12 +08:00
|
|
|
{}
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Initializes a menu item with a normal, selected and disabled image with target/selector. */
|
2014-02-20 10:53:49 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE bool initWithNormalSprite(Node* normalSprite, Node* selectedSprite, Node* disabledSprite, Ref* target, SEL_MenuHandler selector);
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Initializes a menu item with a normal, selected and disabled image with a callable object. */
|
2013-11-16 05:14:12 +08:00
|
|
|
bool initWithNormalSprite(Node* normalSprite, Node* selectedSprite, Node* disabledSprite, const ccMenuCallback& callback);
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
protected:
|
2012-06-08 14:50:41 +08:00
|
|
|
virtual void updateImagesVisibility();
|
2013-07-18 07:56:19 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** The image used when the item is not selected. */
|
2013-07-23 18:26:26 +08:00
|
|
|
Node* _normalImage;
|
2015-03-25 18:17:58 +08:00
|
|
|
/** The image used when the item is selected. */
|
2013-07-23 18:26:26 +08:00
|
|
|
Node* _selectedImage;
|
2015-03-25 18:17:58 +08:00
|
|
|
/** The image used when the item is disabled. */
|
2013-07-23 18:26:26 +08:00
|
|
|
Node* _disabledImage;
|
2013-11-16 05:14:12 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(MenuItemSprite);
|
2012-04-18 18:43:45 +08:00
|
|
|
};
|
|
|
|
|
2012-07-13 09:53:38 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
/** @brief MenuItemImage accepts images as items.
|
2012-04-18 18:43:45 +08:00
|
|
|
The images has 3 different states:
|
|
|
|
- unselected image
|
|
|
|
- selected image
|
|
|
|
- disabled image
|
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
For best results try that all images are of the same size.
|
2012-04-18 18:43:45 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL MenuItemImage : public MenuItemSprite
|
2012-04-18 18:43:45 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-07-18 07:56:19 +08:00
|
|
|
/** Creates an MenuItemImage. */
|
|
|
|
static MenuItemImage* create();
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Creates a menu item with a normal and selected image.*/
|
2013-11-07 09:05:13 +08:00
|
|
|
static MenuItemImage* create(const std::string& normalImage, const std::string& selectedImage);
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Creates a menu item with a normal,selected and disabled image.*/
|
2013-11-07 09:05:13 +08:00
|
|
|
static MenuItemImage* create(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage);
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Creates a menu item with a normal and selected image with target/selector. */
|
2014-02-20 10:53:49 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE static MenuItemImage* create(const std::string& normalImage, const std::string& selectedImage, Ref* target, SEL_MenuHandler selector);
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Creates a menu item with a normal and selected image with a callable object. */
|
2013-11-07 09:05:13 +08:00
|
|
|
static MenuItemImage* create(const std::string&normalImage, const std::string&selectedImage, const ccMenuCallback& callback);
|
2013-06-05 09:29:26 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Creates a menu item with a normal,selected and disabled image with target/selector. */
|
2014-02-20 10:53:49 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE static MenuItemImage* create(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage, Ref* target, SEL_MenuHandler selector);
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Creates a menu item with a normal,selected and disabled image with a callable object. */
|
2013-11-07 09:05:13 +08:00
|
|
|
static MenuItemImage* create(const std::string&normalImage, const std::string&selectedImage, const std::string&disabledImage, const ccMenuCallback& callback);
|
2013-11-16 05:14:12 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Sets the sprite frame for the normal image. */
|
2013-11-16 05:14:12 +08:00
|
|
|
void setNormalSpriteFrame(SpriteFrame* frame);
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Sets the sprite frame for the selected image. */
|
2013-11-16 05:14:12 +08:00
|
|
|
void setSelectedSpriteFrame(SpriteFrame* frame);
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Sets the sprite frame for the disabled image. */
|
2013-11-16 05:14:12 +08:00
|
|
|
void setDisabledSpriteFrame(SpriteFrame* frame);
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-09-13 16:46:31 +08:00
|
|
|
/**
|
|
|
|
* @js ctor
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
MenuItemImage(){}
|
2013-09-13 13:52:42 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
virtual ~MenuItemImage(){}
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2012-06-01 08:04:53 +08:00
|
|
|
bool init();
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Initializes a menu item with a normal, selected and disabled image with target/selector. */
|
2014-02-20 10:53:49 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE bool initWithNormalImage(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage, Ref* target, SEL_MenuHandler selector);
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Initializes a menu item with a normal, selected and disabled image with a callable object. */
|
2013-11-07 09:05:13 +08:00
|
|
|
bool initWithNormalImage(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage, const ccMenuCallback& callback);
|
2013-06-05 09:29:26 +08:00
|
|
|
|
2013-11-16 05:14:12 +08:00
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(MenuItemImage);
|
2012-04-18 18:43:45 +08:00
|
|
|
};
|
|
|
|
|
2012-07-13 09:53:38 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** @brief A MenuItemToggle.
|
|
|
|
A simple container class that "toggles" it's inner items.
|
|
|
|
The inner items can be any MenuItem.
|
2012-04-18 18:43:45 +08:00
|
|
|
*/
|
2013-06-20 14:13:12 +08:00
|
|
|
class CC_DLL MenuItemToggle : public MenuItem
|
2012-04-18 18:43:45 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Creates a menu item from a Array with a target selector.
|
2013-12-07 14:24:31 +08:00
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2014-02-20 10:53:49 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE static MenuItemToggle * createWithTarget(Ref* target, SEL_MenuHandler selector, const Vector<MenuItem*>& menuItems);
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Creates a menu item from a list of items with a target/selector.
|
2013-12-07 14:24:31 +08:00
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2014-02-20 10:53:49 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE static MenuItemToggle* createWithTarget(Ref* target, SEL_MenuHandler selector, MenuItem* item, ...)CC_REQUIRES_NULL_TERMINATION;
|
2013-12-07 14:24:31 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/**
|
|
|
|
*@brief Creates a menu item from a Array with a callable object.
|
|
|
|
*/
|
2013-12-07 14:24:31 +08:00
|
|
|
static MenuItemToggle * createWithCallback(const ccMenuCallback& callback, const Vector<MenuItem*>& menuItems);
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Creates a menu item from a list of items with a callable object. */
|
2014-07-11 15:10:19 +08:00
|
|
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
2015-03-25 18:17:58 +08:00
|
|
|
// WP8 in VS2012 does not support nullptr in variable args lists and variadic templates are also not supported.
|
2014-07-11 15:10:19 +08:00
|
|
|
typedef MenuItem* M;
|
|
|
|
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, NULL); }
|
|
|
|
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, NULL); }
|
|
|
|
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, NULL); }
|
|
|
|
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, M m4, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, m4, NULL); }
|
|
|
|
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, M m4, M m5, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, m4, m5, NULL); }
|
|
|
|
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, M m4, M m5, M m6, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, m4, m5, m6, NULL); }
|
|
|
|
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, M m4, M m5, M m6, M m7, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, m4, m5, m6, m7, NULL); }
|
|
|
|
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, m4, m5, m6, m7, m8, NULL); }
|
|
|
|
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, M m9, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, m4, m5, m6, m7, m8, m9, NULL); }
|
|
|
|
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, M m9, M m10, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, NULL); }
|
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
// On WP8 for lists longer than 10 items, use createWithArray or variadicCreate with NULL as the last argument.
|
2014-07-11 15:10:19 +08:00
|
|
|
static MenuItemToggle* createWithCallbackVA(const ccMenuCallback& callback, M item, ...);
|
|
|
|
#else
|
2013-07-24 06:20:22 +08:00
|
|
|
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, MenuItem* item, ...) CC_REQUIRES_NULL_TERMINATION;
|
2014-07-11 15:10:19 +08:00
|
|
|
#endif
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Creates a menu item with no target/selector and no items. */
|
2013-06-20 14:13:12 +08:00
|
|
|
static MenuItemToggle* create();
|
2015-03-25 18:17:58 +08:00
|
|
|
|
|
|
|
/** Creates a menu item with a item. */
|
2013-07-18 07:56:19 +08:00
|
|
|
static MenuItemToggle* create(MenuItem *item);
|
2015-03-25 18:17:58 +08:00
|
|
|
|
|
|
|
/** Add more menu item. */
|
2013-06-20 14:13:12 +08:00
|
|
|
void addSubItem(MenuItem *item);
|
2012-04-18 18:43:45 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Return the selected item. */
|
2013-07-18 07:56:19 +08:00
|
|
|
MenuItem* getSelectedItem();
|
2015-03-25 18:17:58 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
*@deprecated Use `getSelectedItem` instead.
|
|
|
|
*/
|
2013-07-18 07:56:19 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE MenuItem* selectedItem() { return getSelectedItem(); }
|
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Gets the index of the selected item. */
|
2013-07-23 20:36:41 +08:00
|
|
|
inline unsigned int getSelectedIndex() const { return _selectedIndex; };
|
2013-07-23 18:26:26 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Sets the index of the selected item. */
|
2013-07-23 20:36:41 +08:00
|
|
|
void setSelectedIndex(unsigned int index);
|
2013-07-23 18:26:26 +08:00
|
|
|
|
|
|
|
/** Gets the array that contains the subitems.
|
2015-03-25 18:17:58 +08:00
|
|
|
*You can add/remove items in runtime, and you can replace the array with a new one.
|
|
|
|
* @since v0.7.2
|
2013-09-13 11:41:20 +08:00
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
2013-07-23 18:26:26 +08:00
|
|
|
*/
|
2013-11-29 11:02:50 +08:00
|
|
|
inline const Vector<MenuItem*>& getSubItems() const { return _subItems; };
|
|
|
|
inline Vector<MenuItem*>& getSubItems() { return _subItems; };
|
2013-07-23 20:36:41 +08:00
|
|
|
|
2013-07-23 18:26:26 +08:00
|
|
|
/** Sets the array that contains the subitems. */
|
2013-11-29 11:02:50 +08:00
|
|
|
inline void setSubItems(const Vector<MenuItem*>& items) {
|
2013-07-23 20:36:41 +08:00
|
|
|
_subItems = items;
|
|
|
|
}
|
2013-07-23 18:26:26 +08:00
|
|
|
|
2013-07-18 07:56:19 +08:00
|
|
|
// Overrides
|
|
|
|
virtual void activate() override;
|
|
|
|
virtual void selected() override;
|
|
|
|
virtual void unselected() override;
|
|
|
|
virtual void setEnabled(bool var) override;
|
2014-03-21 13:44:29 +08:00
|
|
|
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
2013-11-16 05:14:12 +08:00
|
|
|
/**
|
|
|
|
* @js ctor
|
|
|
|
*/
|
|
|
|
MenuItemToggle()
|
|
|
|
: _selectedIndex(0)
|
|
|
|
{}
|
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
|
|
|
virtual ~MenuItemToggle();
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Initializes a menu item from a list of items with a target selector.
|
2013-11-16 05:14:12 +08:00
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2014-02-20 10:53:49 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE bool initWithTarget(Ref* target, SEL_MenuHandler selector, MenuItem* item, va_list args);
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Initializes a menu item from a list of items with a callable object. */
|
2013-11-16 05:14:12 +08:00
|
|
|
bool initWithCallback(const ccMenuCallback& callback, MenuItem* item, va_list args);
|
2014-03-21 13:44:29 +08:00
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Initializes a menu item with a item. */
|
2013-11-16 05:14:12 +08:00
|
|
|
bool initWithItem(MenuItem *item);
|
|
|
|
|
2014-03-21 13:44:29 +08:00
|
|
|
protected:
|
2015-03-25 18:17:58 +08:00
|
|
|
/** Returns the selected item. */
|
2013-07-23 18:26:26 +08:00
|
|
|
unsigned int _selectedIndex;
|
|
|
|
/** Array that contains the subitems. You can add/remove items in runtime, and you can replace the array with a new one.
|
2013-07-18 07:56:19 +08:00
|
|
|
@since v0.7.2
|
|
|
|
*/
|
2013-11-29 11:02:50 +08:00
|
|
|
Vector<MenuItem*> _subItems;
|
2013-07-18 07:56:19 +08:00
|
|
|
|
2013-11-16 05:14:12 +08:00
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(MenuItemToggle);
|
|
|
|
|
2012-04-18 18:43:45 +08:00
|
|
|
};
|
2012-07-13 09:53:38 +08:00
|
|
|
|
|
|
|
|
2015-03-25 18:17:58 +08:00
|
|
|
// end of 2d group
|
2012-06-20 18:09:11 +08:00
|
|
|
/// @}
|
|
|
|
|
2012-04-18 18:43:45 +08:00
|
|
|
NS_CC_END
|
2011-03-19 10:59:01 +08:00
|
|
|
|
2011-07-26 18:41:58 +08:00
|
|
|
#endif //__CCMENU_ITEM_H__
|