PuzzleSDK
UIRichTextXMLFace类 参考

#include <UIRichTextTest.h>

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

Public 成员函数

 CREATE_FUNC (UIRichTextXMLFace)
 
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.h174 行定义.

成员函数说明

◆ CREATE_FUNC()

UIRichTextXMLFace::CREATE_FUNC ( UIRichTextXMLFace  )

◆ init()

bool UIRichTextXMLFace::init ( )
overridevirtual

重载 UIScene .

在文件 UIRichTextTest.cpp1108 行定义.

1109{
1110 if (UIScene::init())
1111 {
1112 Size widgetSize = _widget->getContentSize();
1113
1114 // Add the alert
1115 Text *alert = Text::create("RichText", "fonts/Marker Felt.ttf", 30);
1116 alert->setColor(Color3B(159, 168, 176));
1117 alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.125));
1118 _widget->addChild(alert);
1119
1120
1121 Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
1122 button->setTouchEnabled(true);
1123 button->setTitleText("switch");
1124 button->setPosition(Vec2(widgetSize.width * 1 / 3, widgetSize.height / 2.0f + button->getContentSize().height * 2.5));
1125 button->addTouchEventListener(CC_CALLBACK_2(UIRichTextXMLFace::touchEvent, this));
1126 button->setLocalZOrder(10);
1127 _widget->addChild(button);
1128
1129 Button* button2 = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
1130 button2->setTouchEnabled(true);
1131 button2->setTitleText("wrap mode");
1132 button2->setPosition(Vec2(widgetSize.width / 2, widgetSize.height / 2.0f + button2->getContentSize().height * 2.5));
1133 button2->addTouchEventListener(CC_CALLBACK_2(UIRichTextXMLFace::switchWrapMode, this));
1134 button2->setLocalZOrder(10);
1135 _widget->addChild(button2);
1136
1137 Button* button3 = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
1138 button3->setTouchEnabled(true);
1139 button3->setTitleText("alignment");
1140 button3->setPosition(Vec2(widgetSize.width * 2 / 3, widgetSize.height / 2.0f + button2->getContentSize().height * 2.5));
1141 button3->addTouchEventListener(CC_CALLBACK_2(UIRichTextXMLFace::switchAlignment, this));
1142 button3->setLocalZOrder(10);
1143 _widget->addChild(button3);
1144
1145 // RichText
1146 _richText = RichText::createWithXML("<font size='20' face='fonts/Marker Felt.ttf'>Marker Felt 20.<font face='fonts/arial.ttf'>Arial 20.</font></font><font face='font/Thonburi.ttf' size='24' color='#0000ff'>Thonburi 24 blue</font>");
1147 _richText->ignoreContentAdaptWithSize(false);
1148 _richText->setContentSize(Size(120, 100));
1149
1150 _richText->setPosition(Vec2(widgetSize.width / 2, widgetSize.height / 2));
1151 _richText->setLocalZOrder(10);
1152
1153
1154 _widget->addChild(_richText);
1155
1156 // test remove all children, this call won't effect the test
1157 _richText->removeAllChildren();
1158
1159 return true;
1160 }
1161 return false;
1162}
void switchWrapMode(cocos2d::Ref *sender, cocos2d::ui::Widget::TouchEventType type)
cocos2d::ui::RichText * _richText
void switchAlignment(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 UIRichTextXMLFace::switchAlignment ( cocos2d::Ref *  sender,
cocos2d::ui::Widget::TouchEventType  type 
)

在文件 UIRichTextTest.cpp1197 行定义.

1197 {
1198 if (type == Widget::TouchEventType::ENDED)
1199 {
1200 auto alignment = _richText->getHorizontalAlignment();
1201 alignment = static_cast<RichText::HorizontalAlignment>((static_cast<std::underlying_type<RichText::HorizontalAlignment>::type>(alignment) + 1) % 3);
1202 _richText->setHorizontalAlignment(alignment);
1203 }
1204}

引用了 _richText.

被这些函数引用 init().

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

◆ switchWrapMode()

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

在文件 UIRichTextTest.cpp1187 行定义.

1188{
1189 if (type == Widget::TouchEventType::ENDED)
1190 {
1191 auto wrapMode = _richText->getWrapMode();
1192 wrapMode = (wrapMode == RichText::WRAP_PER_WORD) ? RichText::WRAP_PER_CHAR : RichText::WRAP_PER_WORD;
1193 _richText->setWrapMode(wrapMode);
1194 }
1195}

引用了 _richText.

被这些函数引用 init().

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

◆ touchEvent()

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

在文件 UIRichTextTest.cpp1164 行定义.

1165{
1166 switch (type)
1167 {
1168 case Widget::TouchEventType::ENDED:
1169 {
1170 if (_richText->isIgnoreContentAdaptWithSize())
1171 {
1172 _richText->ignoreContentAdaptWithSize(false);
1173 _richText->setContentSize(Size(100, 100));
1174 }
1175 else
1176 {
1177 _richText->ignoreContentAdaptWithSize(true);
1178 }
1179 }
1180 break;
1181
1182 default:
1183 break;
1184 }
1185}

引用了 _richText.

被这些函数引用 init().

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

类成员变量说明

◆ _richText

cocos2d::ui::RichText* UIRichTextXMLFace::_richText
protected

在文件 UIRichTextTest.h185 行定义.

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


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