axmol/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CustomWidget/CustomReader.cpp

41 lines
914 B
C++
Raw Normal View History

2014-03-04 16:51:35 +08:00
#include "CustomReader.h"
#include "CustomImageView.h"
static CustomReader* _instanceCustomReader = nullptr;
2014-03-04 16:51:35 +08:00
CustomReader::CustomReader()
{
}
CustomReader::~CustomReader()
{
}
CustomReader* CustomReader::getInstance()
{
if (!_instanceCustomReader)
{
_instanceCustomReader = new (std::nothrow) CustomReader();
2014-03-04 16:51:35 +08:00
}
return _instanceCustomReader;
}
void CustomReader::setProperties(const std::string &classType, Widget *widget, const rapidjson::Value &customOptions)
{
if (classType.compare("CustomImageView") == 0)
{
CustomImageView* customImageView = static_cast<CustomImageView*>(widget);
bool isExistText = DICTOOL->getBooleanValue_json(customOptions, "text");
if (isExistText)
{
const char* text = DICTOOL->getStringValue_json(customOptions, "text");
customImageView->setText(text);
}
}
}