2013-09-13 22:20:20 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2013 cocos2d-x.org
|
|
|
|
|
|
|
|
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 __UILABELATLAS_H__
|
|
|
|
#define __UILABELATLAS_H__
|
|
|
|
|
2013-10-16 16:48:39 +08:00
|
|
|
#include "gui/UIWidget.h"
|
2013-09-13 22:20:20 +08:00
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
namespace gui {
|
2013-09-13 22:20:20 +08:00
|
|
|
|
2013-11-06 16:04:06 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-10-15 18:00:03 +08:00
|
|
|
class UICCLabelAtlas : public cocos2d::LabelAtlas
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Default constructor
|
|
|
|
*/
|
|
|
|
UICCLabelAtlas();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default destructor
|
|
|
|
*/
|
|
|
|
virtual ~UICCLabelAtlas();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocates and initializes.
|
|
|
|
*/
|
|
|
|
static UICCLabelAtlas* create();
|
2013-11-08 04:42:16 +08:00
|
|
|
void setProperty(const std::string& string, const std::string& charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap);
|
|
|
|
void setProperty(const std::string& string, cocos2d::Texture2D *texture, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap);
|
2013-09-13 22:20:20 +08:00
|
|
|
virtual void updateDisplayedOpacity(GLubyte opacity);
|
|
|
|
virtual void draw(void);
|
|
|
|
};
|
2013-11-06 16:04:06 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-09-13 22:20:20 +08:00
|
|
|
class UILabelAtlas : public UIWidget
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Default constructor
|
|
|
|
*/
|
|
|
|
UILabelAtlas();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default destructor
|
|
|
|
*/
|
|
|
|
virtual ~UILabelAtlas();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocates and initializes.
|
|
|
|
*/
|
|
|
|
static UILabelAtlas* create();
|
|
|
|
|
|
|
|
/** initializes the UILabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */
|
2013-11-08 04:42:16 +08:00
|
|
|
void setProperty(const std::string& stringValue,const std::string& charMapFile, int itemWidth, int itemHeight, const std::string& startCharMap);
|
2013-09-13 22:20:20 +08:00
|
|
|
|
|
|
|
//set string value for labelatlas.
|
2013-11-08 04:42:16 +08:00
|
|
|
void setStringValue(const std::string& value);
|
2013-09-13 22:20:20 +08:00
|
|
|
|
|
|
|
//get string value for labelatlas.
|
2013-11-08 04:42:16 +08:00
|
|
|
const std::string& getStringValue() const;
|
2013-09-13 22:20:20 +08:00
|
|
|
|
|
|
|
//override "setAnchorPoint" method of widget.
|
2013-10-15 18:00:03 +08:00
|
|
|
virtual void setAnchorPoint(const cocos2d::Point &pt);
|
2013-09-13 22:20:20 +08:00
|
|
|
|
|
|
|
//override "getContentSize" method of widget.
|
2013-10-15 18:00:03 +08:00
|
|
|
virtual const cocos2d::Size& getContentSize() const;
|
2013-09-13 22:20:20 +08:00
|
|
|
|
|
|
|
//override "getVirtualRenderer" method of widget.
|
2013-10-15 18:00:03 +08:00
|
|
|
virtual cocos2d::Node* getVirtualRenderer();
|
2013-09-17 17:59:20 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the "class name" of widget.
|
|
|
|
*/
|
|
|
|
virtual const char* getDescription() const;
|
2013-11-06 16:04:06 +08:00
|
|
|
|
2013-09-13 22:20:20 +08:00
|
|
|
protected:
|
|
|
|
virtual void initRenderer();
|
|
|
|
virtual void onSizeChanged();
|
|
|
|
void labelAtlasScaleChangedWithSize();
|
2013-11-06 16:04:06 +08:00
|
|
|
virtual UIWidget* createCloneInstance();
|
|
|
|
virtual void copySpecialProperties(UIWidget* model);
|
2013-09-13 22:20:20 +08:00
|
|
|
protected:
|
2013-09-16 20:54:13 +08:00
|
|
|
UICCLabelAtlas* _laberAtlasRenderer;
|
2013-11-06 16:04:06 +08:00
|
|
|
std::string _stringValue;
|
|
|
|
std::string _charMapFileName;
|
|
|
|
int _itemWidth;
|
|
|
|
int _itemHeight;
|
|
|
|
std::string _startCharMap;
|
2013-09-13 22:20:20 +08:00
|
|
|
};
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
}
|
2013-09-13 22:20:20 +08:00
|
|
|
|
|
|
|
#endif /* defined(__CocoGUI__UILabelAtlas__) */
|