PuzzleSDK
UIRichTextXMLExtend类 参考

#include <UIRichTextTest.h>

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

Public 成员函数

 CREATE_FUNC (UIRichTextXMLExtend)
 
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.h255 行定义.

成员函数说明

◆ CREATE_FUNC()

UIRichTextXMLExtend::CREATE_FUNC ( UIRichTextXMLExtend  )

◆ init()

bool UIRichTextXMLExtend::init ( )
overridevirtual

重载 UIScene .

在文件 UIRichTextTest.cpp1650 行定义.

1651{
1652 if (UIScene::init())
1653 {
1654 Size widgetSize = _widget->getContentSize();
1655
1656 // Add the alert
1657 Text *alert = Text::create("Extend", "fonts/Marker Felt.ttf", 30);
1658 alert->setColor(Color3B(159, 168, 176));
1659 alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.125));
1660 _widget->addChild(alert);
1661
1662
1663 Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
1664 button->setTouchEnabled(true);
1665 button->setTitleText("switch");
1666 button->setPosition(Vec2(widgetSize.width * 1 / 3, widgetSize.height / 2.0f + button->getContentSize().height * 2.5));
1667 button->addTouchEventListener(CC_CALLBACK_2(UIRichTextXMLExtend::touchEvent, this));
1668 button->setLocalZOrder(10);
1669 _widget->addChild(button);
1670
1671 Button* button2 = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
1672 button2->setTouchEnabled(true);
1673 button2->setTitleText("wrap mode");
1674 button2->setPosition(Vec2(widgetSize.width / 2, widgetSize.height / 2.0f + button2->getContentSize().height * 2.5));
1675 button2->addTouchEventListener(CC_CALLBACK_2(UIRichTextXMLExtend::switchWrapMode, this));
1676 button2->setLocalZOrder(10);
1677 _widget->addChild(button2);
1678
1679 Button* button3 = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
1680 button3->setTouchEnabled(true);
1681 button3->setTitleText("alignment");
1682 button3->setPosition(Vec2(widgetSize.width * 2 / 3, widgetSize.height / 2.0f + button2->getContentSize().height * 2.5));
1683 button3->addTouchEventListener(CC_CALLBACK_2(UIRichTextXMLExtend::switchAlignment, this));
1684 button3->setLocalZOrder(10);
1685 _widget->addChild(button3);
1686
1687 /* Tag extension */
1688 RichText::setTagDescription("CloseNormal", false, [](const ValueMap& tagAttrValueMap) {
1689 RichElementImage* richElement = RichElementImage::create(0, Color3B::WHITE, 255, "cocosui/CloseNormal.png");
1690 return make_pair(ValueMap(), richElement);
1691 });
1692 RichText::setTagDescription("CloseSelected", false, [](const ValueMap& tagAttrValueMap) {
1693 RichElementImage* richElement = RichElementImage::create(0, Color3B::WHITE, 255, "cocosui/CloseSelected.png");
1694 return make_pair(ValueMap(), richElement);
1695 });
1696
1697 /* Defaults */
1698 ValueMap defaults;
1699 defaults[RichText::KEY_FONT_COLOR_STRING] = "#FFF";
1700 defaults[RichText::KEY_FONT_SIZE] = 12.0f;
1701 defaults[RichText::KEY_FONT_FACE] = "fonts/Marker Felt.ttf";
1702 defaults[RichText::KEY_ANCHOR_FONT_COLOR_STRING] = "#f0f8ff";
1703 defaults[RichText::KEY_ANCHOR_TEXT_BOLD] = false;
1704 defaults[RichText::KEY_ANCHOR_TEXT_ITALIC] = false;
1705 //defaults[RichText::KEY_ANCHOR_TEXT_LINE] = RichText::VALUE_TEXT_LINE_NONE;
1706 //defaults[RichText::KEY_ANCHOR_TEXT_LINE] = RichText::VALUE_TEXT_LINE_DEL;
1707 defaults[RichText::KEY_ANCHOR_TEXT_LINE] = RichText::VALUE_TEXT_LINE_UNDER;
1708 //defaults[RichText::KEY_ANCHOR_TEXT_STYLE] = RichText::VALUE_TEXT_STYLE_NONE;
1709 //defaults[RichText::KEY_ANCHOR_TEXT_STYLE] = RichText::VALUE_TEXT_STYLE_OUTLINE;
1710 //defaults[RichText::KEY_ANCHOR_TEXT_STYLE] = RichText::VALUE_TEXT_STYLE_SHADOW;
1711 //defaults[RichText::KEY_ANCHOR_TEXT_STYLE] = RichText::VALUE_TEXT_STYLE_GLOW;
1712 defaults[RichText::KEY_ANCHOR_TEXT_OUTLINE_COLOR] = "#D2B48C";
1713 defaults[RichText::KEY_ANCHOR_TEXT_OUTLINE_SIZE] = 4;
1714 defaults[RichText::KEY_ANCHOR_TEXT_SHADOW_COLOR] = "#4169E1";
1715 defaults[RichText::KEY_ANCHOR_TEXT_SHADOW_OFFSET_WIDTH] = 4.0f;
1716 defaults[RichText::KEY_ANCHOR_TEXT_SHADOW_OFFSET_HEIGHT] = -4.0f;
1717 defaults[RichText::KEY_ANCHOR_TEXT_SHADOW_BLUR_RADIUS] = 0;
1718 defaults[RichText::KEY_ANCHOR_TEXT_GLOW_COLOR] = "#AFEEEE";
1719
1720 // RichText
1721 _richText = RichText::createWithXML("<span>CloseNormal-tag:<br /><CloseNormal /><br /><br />CloseSelected-tag:<br /><CloseSelected></CloseSelected></span>",
1722 defaults,
1723 [](const std::string& url) {
1724 Application::getInstance()->openURL(url);
1725 });
1726 _richText->ignoreContentAdaptWithSize(false);
1727 _richText->setContentSize(Size(100, 100));
1728
1729 _richText->setPosition(Vec2(widgetSize.width / 2, widgetSize.height / 2));
1730 _richText->setLocalZOrder(10);
1731
1732
1733 _widget->addChild(_richText);
1734
1735 // test remove all children, this call won't effect the test
1736 _richText->removeAllChildren();
1737
1738 return true;
1739 }
1740 return false;
1741}
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)
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 UIRichTextXMLExtend::switchAlignment ( cocos2d::Ref *  sender,
cocos2d::ui::Widget::TouchEventType  type 
)

在文件 UIRichTextTest.cpp1776 行定义.

1776 {
1777 if (type == Widget::TouchEventType::ENDED)
1778 {
1779 auto alignment = _richText->getHorizontalAlignment();
1780 alignment = static_cast<RichText::HorizontalAlignment>((static_cast<std::underlying_type<RichText::HorizontalAlignment>::type>(alignment) + 1) % 3);
1781 _richText->setHorizontalAlignment(alignment);
1782 }
1783}

引用了 _richText.

被这些函数引用 init().

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

◆ switchWrapMode()

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

在文件 UIRichTextTest.cpp1766 行定义.

1767{
1768 if (type == Widget::TouchEventType::ENDED)
1769 {
1770 auto wrapMode = _richText->getWrapMode();
1771 wrapMode = (wrapMode == RichText::WRAP_PER_WORD) ? RichText::WRAP_PER_CHAR : RichText::WRAP_PER_WORD;
1772 _richText->setWrapMode(wrapMode);
1773 }
1774}

引用了 _richText.

被这些函数引用 init().

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

◆ touchEvent()

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

在文件 UIRichTextTest.cpp1743 行定义.

1744{
1745 switch (type)
1746 {
1747 case Widget::TouchEventType::ENDED:
1748 {
1749 if (_richText->isIgnoreContentAdaptWithSize())
1750 {
1751 _richText->ignoreContentAdaptWithSize(false);
1752 _richText->setContentSize(Size(100, 100));
1753 }
1754 else
1755 {
1756 _richText->ignoreContentAdaptWithSize(true);
1757 }
1758 }
1759 break;
1760
1761 default:
1762 break;
1763 }
1764}

引用了 _richText.

被这些函数引用 init().

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

类成员变量说明

◆ _richText

cocos2d::ui::RichText* UIRichTextXMLExtend::_richText
protected

在文件 UIRichTextTest.h266 行定义.

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


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