PuzzleSDK
UIRichTextXMLShadow类 参考

#include <UIRichTextTest.h>

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

Public 成员函数

 CREATE_FUNC (UIRichTextXMLShadow)
 
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.h227 行定义.

成员函数说明

◆ CREATE_FUNC()

UIRichTextXMLShadow::CREATE_FUNC ( UIRichTextXMLShadow  )

◆ init()

bool UIRichTextXMLShadow::init ( )
overridevirtual

重载 UIScene .

在文件 UIRichTextTest.cpp1448 行定义.

1449{
1450 if (UIScene::init())
1451 {
1452 Size widgetSize = _widget->getContentSize();
1453
1454 // Add the alert
1455 Text *alert = Text::create("Shadow", "fonts/Marker Felt.ttf", 30);
1456 alert->setColor(Color3B(159, 168, 176));
1457 alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.125));
1458 _widget->addChild(alert);
1459
1460
1461 Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
1462 button->setTouchEnabled(true);
1463 button->setTitleText("switch");
1464 button->setPosition(Vec2(widgetSize.width * 1 / 3, widgetSize.height / 2.0f + button->getContentSize().height * 2.5));
1465 button->addTouchEventListener(CC_CALLBACK_2(UIRichTextXMLShadow::touchEvent, this));
1466 button->setLocalZOrder(10);
1467 _widget->addChild(button);
1468
1469 Button* button2 = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
1470 button2->setTouchEnabled(true);
1471 button2->setTitleText("wrap mode");
1472 button2->setPosition(Vec2(widgetSize.width / 2, widgetSize.height / 2.0f + button2->getContentSize().height * 2.5));
1473 button2->addTouchEventListener(CC_CALLBACK_2(UIRichTextXMLShadow::switchWrapMode, this));
1474 button2->setLocalZOrder(10);
1475 _widget->addChild(button2);
1476
1477 Button* button3 = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
1478 button3->setTouchEnabled(true);
1479 button3->setTitleText("alignment");
1480 button3->setPosition(Vec2(widgetSize.width * 2 / 3, widgetSize.height / 2.0f + button2->getContentSize().height * 2.5));
1481 button3->addTouchEventListener(CC_CALLBACK_2(UIRichTextXMLShadow::switchAlignment, this));
1482 button3->setLocalZOrder(10);
1483 _widget->addChild(button3);
1484
1485 // RichText
1486 _richText = RichText::createWithXML("<font size=\"24\"><shadow color=\"#4169E1\" offsetWidth=\"8\" offsetHeight=\"-8\" blurRadius=\"2\">SHADOW</shadow></font>");
1487 _richText->ignoreContentAdaptWithSize(false);
1488 _richText->setContentSize(Size(150, 100));
1489
1490 _richText->setPosition(Vec2(widgetSize.width / 2, widgetSize.height / 2));
1491 _richText->setLocalZOrder(10);
1492
1493
1494 _widget->addChild(_richText);
1495
1496 // test remove all children, this call won't effect the test
1497 _richText->removeAllChildren();
1498
1499 return true;
1500 }
1501 return false;
1502}
void switchWrapMode(cocos2d::Ref *sender, cocos2d::ui::Widget::TouchEventType type)
void switchAlignment(cocos2d::Ref *sender, cocos2d::ui::Widget::TouchEventType type)
void touchEvent(cocos2d::Ref *sender, cocos2d::ui::Widget::TouchEventType type)
cocos2d::ui::RichText * _richText
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 UIRichTextXMLShadow::switchAlignment ( cocos2d::Ref *  sender,
cocos2d::ui::Widget::TouchEventType  type 
)

在文件 UIRichTextTest.cpp1537 行定义.

1537 {
1538 if (type == Widget::TouchEventType::ENDED)
1539 {
1540 auto alignment = _richText->getHorizontalAlignment();
1541 alignment = static_cast<RichText::HorizontalAlignment>((static_cast<std::underlying_type<RichText::HorizontalAlignment>::type>(alignment) + 1) % 3);
1542 _richText->setHorizontalAlignment(alignment);
1543 }
1544}

引用了 _richText.

被这些函数引用 init().

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

◆ switchWrapMode()

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

在文件 UIRichTextTest.cpp1527 行定义.

1528{
1529 if (type == Widget::TouchEventType::ENDED)
1530 {
1531 auto wrapMode = _richText->getWrapMode();
1532 wrapMode = (wrapMode == RichText::WRAP_PER_WORD) ? RichText::WRAP_PER_CHAR : RichText::WRAP_PER_WORD;
1533 _richText->setWrapMode(wrapMode);
1534 }
1535}

引用了 _richText.

被这些函数引用 init().

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

◆ touchEvent()

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

在文件 UIRichTextTest.cpp1504 行定义.

1505{
1506 switch (type)
1507 {
1508 case Widget::TouchEventType::ENDED:
1509 {
1510 if (_richText->isIgnoreContentAdaptWithSize())
1511 {
1512 _richText->ignoreContentAdaptWithSize(false);
1513 _richText->setContentSize(Size(100, 100));
1514 }
1515 else
1516 {
1517 _richText->ignoreContentAdaptWithSize(true);
1518 }
1519 }
1520 break;
1521
1522 default:
1523 break;
1524 }
1525}

引用了 _richText.

被这些函数引用 init().

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

类成员变量说明

◆ _richText

cocos2d::ui::RichText* UIRichTextXMLShadow::_richText
protected

在文件 UIRichTextTest.h238 行定义.

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


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