2014-03-04 16:51:35 +08:00
|
|
|
|
|
|
|
|
|
|
|
#include "CustomImageView.h"
|
2014-06-04 14:26:21 +08:00
|
|
|
#include "2d/CCNode.h"
|
2014-03-04 16:51:35 +08:00
|
|
|
|
2014-03-07 15:36:45 +08:00
|
|
|
USING_NS_CC;
|
|
|
|
using namespace ui;
|
|
|
|
|
2014-03-04 16:51:35 +08:00
|
|
|
CustomImageView::CustomImageView()
|
2014-04-09 22:53:59 +08:00
|
|
|
: _label(nullptr)
|
2014-03-04 16:51:35 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
CustomImageView::~CustomImageView()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Ref* CustomImageView::createInstance()
|
|
|
|
{
|
|
|
|
return create();
|
|
|
|
}
|
|
|
|
|
|
|
|
CustomImageView* CustomImageView::create()
|
|
|
|
{
|
|
|
|
CustomImageView* custom = new CustomImageView();
|
|
|
|
|
|
|
|
if (custom && custom->init())
|
|
|
|
{
|
|
|
|
custom->autorelease();
|
|
|
|
return custom;
|
|
|
|
}
|
|
|
|
CC_SAFE_DELETE(custom);
|
2014-07-10 00:45:27 +08:00
|
|
|
return nullptr;
|
2014-03-04 16:51:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CustomImageView::init()
|
|
|
|
{
|
|
|
|
if (ImageView::init())
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CustomImageView::initRenderer()
|
|
|
|
{
|
|
|
|
ImageView::initRenderer();
|
|
|
|
|
2014-03-26 23:33:58 +08:00
|
|
|
_label = Label::create();
|
2014-07-21 17:45:56 +08:00
|
|
|
addChild(_label, getLocalZOrder() + 1, -1);
|
2014-03-04 16:51:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CustomImageView::setText(const std::string &text)
|
|
|
|
{
|
|
|
|
_label->setString(text.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string& CustomImageView::getText() const
|
|
|
|
{
|
|
|
|
return _label->getString();
|
|
|
|
}
|