PuzzleSDK
UIRichTextXMLBR类 参考

#include <UIRichTextTest.h>

+ 类 UIRichTextXMLBR 继承关系图:
+ UIRichTextXMLBR 的协作图:

Public 成员函数

 CREATE_FUNC (UIRichTextXMLBR)
 
bool init () override
 
void touchEvent (cocos2d::Ref *sender, cocos2d::ui::Widget::TouchEventType type)
 
void switchWrapMode (cocos2d::Ref *sender, cocos2d::ui::Widget::TouchEventType type)
 
void switchAlignment (cocos2d::Ref *sender, cocos2d::ui::Widget::TouchEventType type)
 
- Public 成员函数 继承自 UIScene
 UIScene ()
 
 ~UIScene ()
 
virtual void onEnter () override
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
virtual std::string title () const
 
virtual std::string subtitle () const
 
virtual Type getTestType () const
 
virtual float getDuration () const
 
virtual std::string getExpectedOutput () const
 
virtual std::string getActualOutput () const
 
virtual void restartTestCallback (cocos2d::Ref *sender)
 
virtual void nextTestCallback (cocos2d::Ref *sender)
 
virtual void priorTestCallback (cocos2d::Ref *sender)
 
virtual void onBackCallback (cocos2d::Ref *sender)
 
void setTestSuite (TestSuite *testSuite)
 
TestSuitegetTestSuite () const
 
float getRunTime () const
 
void setTestCaseName (const std::string &name)
 
std::string getTestCaseName () const
 
const cocos2d::Label * getSubtitleLable () const
 
const cocos2d::MenuItemImage * getRestartTestItem () const
 

Protected 属性

cocos2d::ui::RichText * _richText
 
- Protected 属性 继承自 UIScene
cocos2d::Layer * _uiLayer
 
cocos2d::ui::Layout * _widget
 
cocos2d::ui::Text * _sceneTitle
 
- Protected 属性 继承自 TestCase
cocos2d::MenuItemImage * _priorTestItem
 
cocos2d::MenuItemImage * _restartTestItem
 
cocos2d::MenuItemImage * _nextTestItem
 
cocos2d::Label * _titleLabel
 
cocos2d::Label * _subtitleLabel
 

额外继承的成员函数

- Public 类型 继承自 TestCase
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 

详细描述

在文件 UIRichTextTest.h188 行定义.

成员函数说明

◆ CREATE_FUNC()

UIRichTextXMLBR::CREATE_FUNC ( UIRichTextXMLBR  )

◆ init()

bool UIRichTextXMLBR::init ( )
overridevirtual

重载 UIScene .

在文件 UIRichTextTest.cpp1209 行定义.

1210{
1211 if (UIScene::init())
1212 {
1213 Size widgetSize = _widget->getContentSize();
1214
1215 // Add the alert
1216 Text *alert = Text::create("RichText", "fonts/Marker Felt.ttf", 30);
1217 alert->setColor(Color3B(159, 168, 176));
1218 alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.125));
1219 _widget->addChild(alert);
1220
1221
1222 Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
1223 button->setTouchEnabled(true);
1224 button->setTitleText("switch");
1225 button->setPosition(Vec2(widgetSize.width * 1 / 3, widgetSize.height / 2.0f + button->getContentSize().height * 2.5));
1226 button->addTouchEventListener(CC_CALLBACK_2(UIRichTextXMLBR::touchEvent, this));
1227 button->setLocalZOrder(10);
1228 _widget->addChild(button);
1229
1230 Button* button2 = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
1231 button2->setTouchEnabled(true);
1232 button2->setTitleText("wrap mode");
1233 button2->setPosition(Vec2(widgetSize.width / 2, widgetSize.height / 2.0f + button2->getContentSize().height * 2.5));
1234 button2->addTouchEventListener(CC_CALLBACK_2(UIRichTextXMLBR::switchWrapMode, this));
1235 button2->setLocalZOrder(10);
1236 _widget->addChild(button2);
1237
1238 Button* button3 = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
1239 button3->setTouchEnabled(true);
1240 button3->setTitleText("alignment");
1241 button3->setPosition(Vec2(widgetSize.width * 2 / 3, widgetSize.height / 2.0f + button2->getContentSize().height * 2.5));
1242 button3->addTouchEventListener(CC_CALLBACK_2(UIRichTextXMLBR::switchAlignment, this));
1243 button3->setLocalZOrder(10);
1244 _widget->addChild(button3);
1245
1246 // RichText
1247 _richText = RichText::createWithXML("this is one line.<br/>this should be in another line.<br/>and this is another line");
1248 _richText->ignoreContentAdaptWithSize(false);
1249 _richText->setContentSize(Size(100, 100));
1250
1251 _richText->setPosition(Vec2(widgetSize.width / 2, widgetSize.height / 2));
1252 _richText->setLocalZOrder(10);
1253
1254
1255 _widget->addChild(_richText);
1256
1257 // test remove all children, this call won't effect the test
1258 _richText->removeAllChildren();
1259
1260 return true;
1261 }
1262 return false;
1263}
cocos2d::ui::RichText * _richText
void switchAlignment(cocos2d::Ref *sender, cocos2d::ui::Widget::TouchEventType type)
void switchWrapMode(cocos2d::Ref *sender, cocos2d::ui::Widget::TouchEventType type)
void touchEvent(cocos2d::Ref *sender, cocos2d::ui::Widget::TouchEventType type)
virtual bool init() override
Definition: UIScene.cpp:46
cocos2d::ui::Layout * _widget
Definition: UIScene.h:45

引用了 _richText, UIScene::_widget, UIScene::init(), switchAlignment(), switchWrapMode() , 以及 touchEvent().

+ 函数调用图:

◆ switchAlignment()

void UIRichTextXMLBR::switchAlignment ( cocos2d::Ref *  sender,
cocos2d::ui::Widget::TouchEventType  type 
)

在文件 UIRichTextTest.cpp1298 行定义.

1298 {
1299 if (type == Widget::TouchEventType::ENDED)
1300 {
1301 auto alignment = _richText->getHorizontalAlignment();
1302 alignment = static_cast<RichText::HorizontalAlignment>((static_cast<std::underlying_type<RichText::HorizontalAlignment>::type>(alignment) + 1) % 3);
1303 _richText->setHorizontalAlignment(alignment);
1304 }
1305}

引用了 _richText.

被这些函数引用 init().

+ 这是这个函数的调用关系图:

◆ switchWrapMode()

void UIRichTextXMLBR::switchWrapMode ( cocos2d::Ref *  sender,
cocos2d::ui::Widget::TouchEventType  type 
)

在文件 UIRichTextTest.cpp1288 行定义.

1289{
1290 if (type == Widget::TouchEventType::ENDED)
1291 {
1292 auto wrapMode = _richText->getWrapMode();
1293 wrapMode = (wrapMode == RichText::WRAP_PER_WORD) ? RichText::WRAP_PER_CHAR : RichText::WRAP_PER_WORD;
1294 _richText->setWrapMode(wrapMode);
1295 }
1296}

引用了 _richText.

被这些函数引用 init().

+ 这是这个函数的调用关系图:

◆ touchEvent()

void UIRichTextXMLBR::touchEvent ( cocos2d::Ref *  sender,
cocos2d::ui::Widget::TouchEventType  type 
)

在文件 UIRichTextTest.cpp1265 行定义.

1266{
1267 switch (type)
1268 {
1269 case Widget::TouchEventType::ENDED:
1270 {
1271 if (_richText->isIgnoreContentAdaptWithSize())
1272 {
1273 _richText->ignoreContentAdaptWithSize(false);
1274 _richText->setContentSize(Size(100, 100));
1275 }
1276 else
1277 {
1278 _richText->ignoreContentAdaptWithSize(true);
1279 }
1280 }
1281 break;
1282
1283 default:
1284 break;
1285 }
1286}

引用了 _richText.

被这些函数引用 init().

+ 这是这个函数的调用关系图:

类成员变量说明

◆ _richText

cocos2d::ui::RichText* UIRichTextXMLBR::_richText
protected

在文件 UIRichTextTest.h199 行定义.

被这些函数引用 init(), switchAlignment(), switchWrapMode() , 以及 touchEvent().


该类的文档由以下文件生成: