PuzzleSDK
UIRichTextXMLSUIB3类 参考

#include <UIRichTextTest.h>

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

Public 成员函数

 CREATE_FUNC (UIRichTextXMLSUIB3)
 
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.h118 行定义.

成员函数说明

◆ CREATE_FUNC()

UIRichTextXMLSUIB3::CREATE_FUNC ( UIRichTextXMLSUIB3  )

◆ init()

bool UIRichTextXMLSUIB3::init ( )
overridevirtual

重载 UIScene .

在文件 UIRichTextTest.cpp704 行定义.

705{
706 if (UIScene::init())
707 {
708 Size widgetSize = _widget->getContentSize();
709
710 // Add the alert
711 Text *alert = Text::create("RichText", "fonts/Marker Felt.ttf", 30);
712 alert->setColor(Color3B(159, 168, 176));
713 alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.125));
714 _widget->addChild(alert);
715
716
717 Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
718 button->setTouchEnabled(true);
719 button->setTitleText("switch");
720 button->setPosition(Vec2(widgetSize.width * 1 / 3, widgetSize.height / 2.0f + button->getContentSize().height * 2.5));
721 button->addTouchEventListener(CC_CALLBACK_2(UIRichTextXMLSUIB3::touchEvent, this));
722 button->setLocalZOrder(10);
723 _widget->addChild(button);
724
725 Button* button2 = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
726 button2->setTouchEnabled(true);
727 button2->setTitleText("wrap mode");
728 button2->setPosition(Vec2(widgetSize.width / 2, widgetSize.height / 2.0f + button2->getContentSize().height * 2.5));
729 button2->addTouchEventListener(CC_CALLBACK_2(UIRichTextXMLSUIB3::switchWrapMode, this));
730 button2->setLocalZOrder(10);
731 _widget->addChild(button2);
732
733 Button* button3 = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
734 button3->setTouchEnabled(true);
735 button3->setTitleText("alignment");
736 button3->setPosition(Vec2(widgetSize.width * 2 / 3, widgetSize.height / 2.0f + button2->getContentSize().height * 2.5));
737 button3->addTouchEventListener(CC_CALLBACK_2(UIRichTextXMLSUIB3::switchAlignment, this));
738 button3->setLocalZOrder(10);
739 _widget->addChild(button3);
740
741 // RichText
742 _richText = RichText::createWithXML("<font face='fonts/Marker Felt.ttf' size='20'>ttf font: <i><u>italics and underline</u></i><del><b>bold and strike-through</b></del></font>");
743 _richText->ignoreContentAdaptWithSize(false);
744 _richText->setContentSize(Size(100, 100));
745
746 _richText->setPosition(Vec2(widgetSize.width / 2, widgetSize.height / 2));
747 _richText->setLocalZOrder(10);
748
749
750 _widget->addChild(_richText);
751
752 // test remove all children, this call won't effect the test
753 _richText->removeAllChildren();
754
755 return true;
756 }
757 return false;
758}
void switchAlignment(cocos2d::Ref *sender, cocos2d::ui::Widget::TouchEventType type)
void touchEvent(cocos2d::Ref *sender, cocos2d::ui::Widget::TouchEventType type)
cocos2d::ui::RichText * _richText
void switchWrapMode(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 UIRichTextXMLSUIB3::switchAlignment ( cocos2d::Ref *  sender,
cocos2d::ui::Widget::TouchEventType  type 
)

在文件 UIRichTextTest.cpp793 行定义.

793 {
794 if (type == Widget::TouchEventType::ENDED)
795 {
796 auto alignment = _richText->getHorizontalAlignment();
797 alignment = static_cast<RichText::HorizontalAlignment>((static_cast<std::underlying_type<RichText::HorizontalAlignment>::type>(alignment) + 1) % 3);
798 _richText->setHorizontalAlignment(alignment);
799 }
800}

引用了 _richText.

被这些函数引用 init().

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

◆ switchWrapMode()

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

在文件 UIRichTextTest.cpp783 行定义.

784{
785 if (type == Widget::TouchEventType::ENDED)
786 {
787 auto wrapMode = _richText->getWrapMode();
788 wrapMode = (wrapMode == RichText::WRAP_PER_WORD) ? RichText::WRAP_PER_CHAR : RichText::WRAP_PER_WORD;
789 _richText->setWrapMode(wrapMode);
790 }
791}

引用了 _richText.

被这些函数引用 init().

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

◆ touchEvent()

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

在文件 UIRichTextTest.cpp760 行定义.

761{
762 switch (type)
763 {
764 case Widget::TouchEventType::ENDED:
765 {
766 if (_richText->isIgnoreContentAdaptWithSize())
767 {
768 _richText->ignoreContentAdaptWithSize(false);
769 _richText->setContentSize(Size(100, 100));
770 }
771 else
772 {
773 _richText->ignoreContentAdaptWithSize(true);
774 }
775 }
776 break;
777
778 default:
779 break;
780 }
781}

引用了 _richText.

被这些函数引用 init().

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

类成员变量说明

◆ _richText

cocos2d::ui::RichText* UIRichTextXMLSUIB3::_richText
protected

在文件 UIRichTextTest.h129 行定义.

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


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