PuzzleSDK
UIRichTextXMLSUIB2类 参考

#include <UIRichTextTest.h>

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

Public 成员函数

 CREATE_FUNC (UIRichTextXMLSUIB2)
 
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.h104 行定义.

成员函数说明

◆ CREATE_FUNC()

UIRichTextXMLSUIB2::CREATE_FUNC ( UIRichTextXMLSUIB2  )

◆ init()

bool UIRichTextXMLSUIB2::init ( )
overridevirtual

重载 UIScene .

在文件 UIRichTextTest.cpp603 行定义.

604{
605 if (UIScene::init())
606 {
607 Size widgetSize = _widget->getContentSize();
608
609 // Add the alert
610 Text *alert = Text::create("RichText", "fonts/Marker Felt.ttf", 30);
611 alert->setColor(Color3B(159, 168, 176));
612 alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.125));
613 _widget->addChild(alert);
614
615
616 Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
617 button->setTouchEnabled(true);
618 button->setTitleText("switch");
619 button->setPosition(Vec2(widgetSize.width * 1 / 3, widgetSize.height / 2.0f + button->getContentSize().height * 2.5));
620 button->addTouchEventListener(CC_CALLBACK_2(UIRichTextXMLSUIB2::touchEvent, this));
621 button->setLocalZOrder(10);
622 _widget->addChild(button);
623
624 Button* button2 = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
625 button2->setTouchEnabled(true);
626 button2->setTitleText("wrap mode");
627 button2->setPosition(Vec2(widgetSize.width / 2, widgetSize.height / 2.0f + button2->getContentSize().height * 2.5));
628 button2->addTouchEventListener(CC_CALLBACK_2(UIRichTextXMLSUIB2::switchWrapMode, this));
629 button2->setLocalZOrder(10);
630 _widget->addChild(button2);
631
632 Button* button3 = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
633 button3->setTouchEnabled(true);
634 button3->setTitleText("alignment");
635 button3->setPosition(Vec2(widgetSize.width * 2 / 3, widgetSize.height / 2.0f + button2->getContentSize().height * 2.5));
636 button3->addTouchEventListener(CC_CALLBACK_2(UIRichTextXMLSUIB2::switchAlignment, this));
637 button3->setLocalZOrder(10);
638 _widget->addChild(button3);
639
640 // RichText
641 _richText = RichText::createWithXML("<font face='fonts/Marker Felt.ttf' size='24'>ttf font: <u>underline</u><i>italics</i><b>bold</b><del>strike-through</del></font>");
642 _richText->ignoreContentAdaptWithSize(false);
643 _richText->setContentSize(Size(100, 100));
644
645 _richText->setPosition(Vec2(widgetSize.width / 2, widgetSize.height / 2));
646 _richText->setLocalZOrder(10);
647
648
649 _widget->addChild(_richText);
650
651 // test remove all children, this call won't effect the test
652 _richText->removeAllChildren();
653
654 return true;
655 }
656 return false;
657}
void touchEvent(cocos2d::Ref *sender, cocos2d::ui::Widget::TouchEventType type)
cocos2d::ui::RichText * _richText
void switchWrapMode(cocos2d::Ref *sender, cocos2d::ui::Widget::TouchEventType type)
void switchAlignment(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 UIRichTextXMLSUIB2::switchAlignment ( cocos2d::Ref *  sender,
cocos2d::ui::Widget::TouchEventType  type 
)

在文件 UIRichTextTest.cpp692 行定义.

692 {
693 if (type == Widget::TouchEventType::ENDED)
694 {
695 auto alignment = _richText->getHorizontalAlignment();
696 alignment = static_cast<RichText::HorizontalAlignment>((static_cast<std::underlying_type<RichText::HorizontalAlignment>::type>(alignment) + 1) % 3);
697 _richText->setHorizontalAlignment(alignment);
698 }
699}

引用了 _richText.

被这些函数引用 init().

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

◆ switchWrapMode()

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

在文件 UIRichTextTest.cpp682 行定义.

683{
684 if (type == Widget::TouchEventType::ENDED)
685 {
686 auto wrapMode = _richText->getWrapMode();
687 wrapMode = (wrapMode == RichText::WRAP_PER_WORD) ? RichText::WRAP_PER_CHAR : RichText::WRAP_PER_WORD;
688 _richText->setWrapMode(wrapMode);
689 }
690}

引用了 _richText.

被这些函数引用 init().

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

◆ touchEvent()

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

在文件 UIRichTextTest.cpp659 行定义.

660{
661 switch (type)
662 {
663 case Widget::TouchEventType::ENDED:
664 {
665 if (_richText->isIgnoreContentAdaptWithSize())
666 {
667 _richText->ignoreContentAdaptWithSize(false);
668 _richText->setContentSize(Size(100, 100));
669 }
670 else
671 {
672 _richText->ignoreContentAdaptWithSize(true);
673 }
674 }
675 break;
676
677 default:
678 break;
679 }
680}

引用了 _richText.

被这些函数引用 init().

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

类成员变量说明

◆ _richText

cocos2d::ui::RichText* UIRichTextXMLSUIB2::_richText
protected

在文件 UIRichTextTest.h115 行定义.

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


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