PuzzleSDK
UIRichTextXMLSpace类 参考

#include <UIRichTextTest.h>

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

Public 成员函数

 CREATE_FUNC (UIRichTextXMLSpace)
 
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.h269 行定义.

成员函数说明

◆ CREATE_FUNC()

UIRichTextXMLSpace::CREATE_FUNC ( UIRichTextXMLSpace  )

◆ init()

bool UIRichTextXMLSpace::init ( )
overridevirtual

重载 UIScene .

在文件 UIRichTextTest.cpp1788 行定义.

1789{
1790 if (UIScene::init())
1791 {
1792 Size widgetSize = _widget->getContentSize();
1793
1794 // Add the alert
1795 Text *alert = Text::create("Space", "fonts/Marker Felt.ttf", 30);
1796 alert->setColor(Color3B(159, 168, 176));
1797 alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.125));
1798 _widget->addChild(alert);
1799
1800
1801 Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
1802 button->setTouchEnabled(true);
1803 button->setTitleText("switch");
1804 button->setPosition(Vec2(widgetSize.width * 1 / 3, widgetSize.height / 2.0f + button->getContentSize().height * 2.5));
1805 button->addTouchEventListener(CC_CALLBACK_2(UIRichTextXMLSpace::touchEvent, this));
1806 button->setLocalZOrder(10);
1807 _widget->addChild(button);
1808
1809 Button* button2 = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
1810 button2->setTouchEnabled(true);
1811 button2->setTitleText("wrap mode");
1812 button2->setPosition(Vec2(widgetSize.width / 2, widgetSize.height / 2.0f + button2->getContentSize().height * 2.5));
1813 button2->addTouchEventListener(CC_CALLBACK_2(UIRichTextXMLSpace::switchWrapMode, this));
1814 button2->setLocalZOrder(10);
1815 _widget->addChild(button2);
1816
1817 Button* button3 = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
1818 button3->setTouchEnabled(true);
1819 button3->setTitleText("alignment");
1820 button3->setPosition(Vec2(widgetSize.width * 2 / 3, widgetSize.height / 2.0f + button2->getContentSize().height * 2.5));
1821 button3->addTouchEventListener(CC_CALLBACK_2(UIRichTextXMLSpace::switchAlignment, this));
1822 button3->setLocalZOrder(10);
1823 _widget->addChild(button3);
1824
1825 // RichText
1826 _richText = RichText::createWithXML("words should be divided with space.<br /><br /><font face='fonts/Marker Felt.ttf' color='#ffff00'>HELLO </font><font color='#ffff00'>WORLD</font><br /><br /><font color='#ff00ff'>HELLO</font><font face='fonts/Marker Felt.ttf' color='#ff00ff'> WORLD</font>");
1827 _richText->ignoreContentAdaptWithSize(false);
1828 _richText->setContentSize(Size(50, 100));
1829 _richText->setPosition(Vec2(widgetSize.width / 2, widgetSize.height / 2));
1830 _richText->setLocalZOrder(10);
1831
1832 _widget->addChild(_richText);
1833
1834 // test remove all children, this call won't effect the test
1835 _richText->removeAllChildren();
1836
1837 return true;
1838 }
1839 return false;
1840}
cocos2d::ui::RichText * _richText
void switchAlignment(cocos2d::Ref *sender, cocos2d::ui::Widget::TouchEventType type)
void touchEvent(cocos2d::Ref *sender, cocos2d::ui::Widget::TouchEventType type)
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 UIRichTextXMLSpace::switchAlignment ( cocos2d::Ref *  sender,
cocos2d::ui::Widget::TouchEventType  type 
)

在文件 UIRichTextTest.cpp1875 行定义.

1875 {
1876 if (type == Widget::TouchEventType::ENDED)
1877 {
1878 auto alignment = _richText->getHorizontalAlignment();
1879 alignment = static_cast<RichText::HorizontalAlignment>((static_cast<std::underlying_type<RichText::HorizontalAlignment>::type>(alignment) + 1) % 3);
1880 _richText->setHorizontalAlignment(alignment);
1881 }
1882}

引用了 _richText.

被这些函数引用 init().

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

◆ switchWrapMode()

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

在文件 UIRichTextTest.cpp1865 行定义.

1866{
1867 if (type == Widget::TouchEventType::ENDED)
1868 {
1869 auto wrapMode = _richText->getWrapMode();
1870 wrapMode = (wrapMode == RichText::WRAP_PER_WORD) ? RichText::WRAP_PER_CHAR : RichText::WRAP_PER_WORD;
1871 _richText->setWrapMode(wrapMode);
1872 }
1873}

引用了 _richText.

被这些函数引用 init().

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

◆ touchEvent()

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

在文件 UIRichTextTest.cpp1842 行定义.

1843{
1844 switch (type)
1845 {
1846 case Widget::TouchEventType::ENDED:
1847 {
1848 if (_richText->isIgnoreContentAdaptWithSize())
1849 {
1850 _richText->ignoreContentAdaptWithSize(false);
1851 _richText->setContentSize(Size(50, 100));
1852 }
1853 else
1854 {
1855 _richText->ignoreContentAdaptWithSize(true);
1856 }
1857 }
1858 break;
1859
1860 default:
1861 break;
1862 }
1863}

引用了 _richText.

被这些函数引用 init().

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

类成员变量说明

◆ _richText

cocos2d::ui::RichText* UIRichTextXMLSpace::_richText
protected

在文件 UIRichTextTest.h280 行定义.

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


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