1
0

UIRichText.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. /****************************************************************************
  2. Copyright (c) 2013 cocos2d-x.org
  3. http://www.cocos2d-x.org
  4. Permission is hereby granted, free of charge, to any person obtaining a copy
  5. of this software and associated documentation files (the "Software"), to deal
  6. in the Software without restriction, including without limitation the rights
  7. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the Software is
  9. furnished to do so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in
  11. all copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18. THE SOFTWARE.
  19. ****************************************************************************/
  20. #ifndef __UIRICHTEXT_H__
  21. #define __UIRICHTEXT_H__
  22. #include "ui/UIWidget.h"
  23. #include "ui/GUIExport.h"
  24. #include "base/CCValue.h"
  25. NS_CC_BEGIN
  26. /**
  27. * @addtogroup ui
  28. * @{
  29. */
  30. class Label;
  31. namespace ui {
  32. /**
  33. *@brief Rich text element base class.
  34. * It defines the basic common properties for all rich text element.
  35. */
  36. class CC_GUI_DLL RichElement : public Ref
  37. {
  38. public:
  39. /**
  40. *@brief Rich element type.
  41. */
  42. enum class Type
  43. {
  44. TEXT, /*!< RichElementText */
  45. IMAGE, /*!< RichElementImage */
  46. CUSTOM, /*!< RichElementCustomNode */
  47. NEWLINE /*!< RichElementNewLine */
  48. };
  49. /**
  50. * @brief Default constructor.
  51. * @js ctor
  52. * @lua new
  53. */
  54. RichElement(){};
  55. /**
  56. * @brief Default destructor.
  57. * @js NA
  58. * @lua NA
  59. */
  60. virtual ~RichElement(){};
  61. /**
  62. * @brief Initialize a rich element with different arguments.
  63. *
  64. * @param tag A integer tag value.
  65. * @param color A color in @see `Color3B`.
  66. * @param opacity A opacity value in `GLubyte`.
  67. * @return True if initialize success, false otherwise.
  68. */
  69. bool init(int tag, const Color3B& color, GLubyte opacity);
  70. bool equalType(Type type);
  71. void setColor(const Color3B& color);
  72. protected:
  73. Type _type; /*!< Rich element type. */
  74. int _tag; /*!< A integer tag value. */
  75. Color3B _color; /*!< A color in `Color3B`. */
  76. GLubyte _opacity; /*!< A opacity value in `GLubyte`. */
  77. friend class RichText;
  78. };
  79. /**
  80. *@brief Rich element for displaying text.
  81. */
  82. class CC_GUI_DLL RichElementText : public RichElement
  83. {
  84. public:
  85. /**
  86. *@brief Default constructor.
  87. * @js ctor
  88. * @lua new
  89. */
  90. RichElementText()
  91. {_type = Type::TEXT;};
  92. enum {
  93. ITALICS_FLAG = 1 << 0, /*!< italic text */
  94. BOLD_FLAG = 1 << 1, /*!< bold text */
  95. UNDERLINE_FLAG = 1 << 2, /*!< underline */
  96. STRIKETHROUGH_FLAG = 1 << 3, /*!< strikethrough */
  97. URL_FLAG = 1 << 4, /*!< url of anchor */
  98. OUTLINE_FLAG = 1 << 5, /*!< outline effect */
  99. SHADOW_FLAG = 1 << 6, /*!< shadow effect */
  100. GLOW_FLAG = 1 << 7 /*!< glow effect */
  101. };
  102. /**
  103. *@brief Default destructor.
  104. * @js NA
  105. * @lua NA
  106. */
  107. virtual ~RichElementText(){};
  108. /**
  109. * @brief Initialize a RichElementText with various arguments.
  110. *
  111. * @param tag A integer tag value.
  112. * @param color A color in Color3B.
  113. * @param opacity A opacity in GLubyte.
  114. * @param text Content string.
  115. * @param fontName Content font name.
  116. * @param fontSize Content font size.
  117. * @param flags italics, bold, underline, strikethrough, url, outline, shadow or glow
  118. * @param url uniform resource locator
  119. * @param outlineColor the color of the outline
  120. * @param outlineSize the outline effect size value
  121. * @param shadowColor the shadow effect color value
  122. * @param shadowOffset shadow effect offset value
  123. * @param shadowBlurRadius the shadow effect blur radius
  124. * @param glowColor glow color
  125. * @return True if initialize success, false otherwise.
  126. */
  127. bool init(int tag, const Color3B& color, GLubyte opacity, const std::string& text,
  128. const std::string& fontName, float fontSize, uint32_t flags, const std::string& url,
  129. const Color3B& outlineColor = Color3B::WHITE, int outlineSize = -1,
  130. const Color3B& shadowColor = Color3B::BLACK, const cocos2d::Size& shadowOffset = Size(2.0, -2.0), int shadowBlurRadius = 0,
  131. const Color3B& glowColor = Color3B::WHITE);
  132. /**
  133. * @brief Create a RichElementText with various arguments.
  134. *
  135. * @param tag A integer tag value.
  136. * @param color A color in Color3B.
  137. * @param opacity A opacity in GLubyte.
  138. * @param text Content string.
  139. * @param fontName Content font name.
  140. * @param fontSize Content font size.
  141. * @param flags italics, bold, underline, strikethrough, url, outline, shadow or glow
  142. * @param url uniform resource locator
  143. * @param outlineColor the color of the outline
  144. * @param outlineSize the outline effect size value
  145. * @param shadowColor the shadow effect color value
  146. * @param shadowOffset shadow effect offset value
  147. * @param shadowBlurRadius the shadow effect blur radius
  148. * @param glowColor glow color
  149. * @return RichElementText instance.
  150. */
  151. static RichElementText* create(int tag, const Color3B& color, GLubyte opacity, const std::string& text,
  152. const std::string& fontName, float fontSize, uint32_t flags=0, const std::string& url="",
  153. const Color3B& outlineColor = Color3B::WHITE, int outlineSize = -1,
  154. const Color3B& shadowColor = Color3B::BLACK, const cocos2d::Size& shadowOffset = Size(2.0, -2.0), int shadowBlurRadius = 0,
  155. const Color3B& glowColor = Color3B::WHITE);
  156. protected:
  157. std::string _text;
  158. std::string _fontName;
  159. float _fontSize;
  160. uint32_t _flags;
  161. std::string _url;
  162. Color3B _outlineColor; /*!< the color of the outline */
  163. int _outlineSize; /*!< the outline effect size value */
  164. Color3B _shadowColor; /*!< the shadow effect color value */
  165. cocos2d::Size _shadowOffset; /*!< shadow effect offset value */
  166. int _shadowBlurRadius; /*!< the shadow effect blur radius */
  167. Color3B _glowColor; /*!< attributes of glow tag */
  168. friend class RichText;
  169. };
  170. /**
  171. *@brief Rich element for displaying images.
  172. */
  173. class CC_GUI_DLL RichElementImage : public RichElement
  174. {
  175. public:
  176. /**
  177. * @brief Default constructor.
  178. * @js ctor
  179. * @lua new
  180. *
  181. */
  182. RichElementImage(){_type = Type::IMAGE;};
  183. /**
  184. * @brief Default destructor.
  185. * @js NA
  186. * @lua NA
  187. */
  188. virtual ~RichElementImage(){};
  189. /**
  190. * @brief Initialize a RichElementImage with various arguments.
  191. *
  192. * @param tag A integer tag value.
  193. * @param color A color in Color3B.
  194. * @param opacity A opacity in GLubyte.
  195. * @param filePath A image file name.
  196. * @param url uniform resource locator
  197. * @return True if initialize success, false otherwise.
  198. */
  199. bool init(int tag, const Color3B& color, GLubyte opacity, const std::string& filePath, const std::string& url = "");
  200. /**
  201. * @brief Create a RichElementImage with various arguments.
  202. *
  203. * @param tag A integer tag value.
  204. * @param color A color in Color3B.
  205. * @param opacity A opacity in GLubyte.
  206. * @param filePath A image file name.
  207. * @param url uniform resource locator
  208. * @return A RichElementImage instance.
  209. */
  210. static RichElementImage* create(int tag, const Color3B& color, GLubyte opacity, const std::string& filePath, const std::string& url = "");
  211. void setWidth(int width);
  212. void setHeight(int height);
  213. void setUrl(const std::string& url);
  214. protected:
  215. std::string _filePath;
  216. Rect _textureRect;
  217. int _textureType;
  218. friend class RichText;
  219. int _width;
  220. int _height;
  221. std::string _url; /*!< attributes of anchor tag */
  222. };
  223. /**
  224. *@brief Rich element for displaying custom node type.
  225. */
  226. class CC_GUI_DLL RichElementCustomNode : public RichElement
  227. {
  228. public:
  229. /**
  230. * @brief Default constructor.
  231. * @js ctor
  232. * @lua new
  233. */
  234. RichElementCustomNode(){_type = Type::CUSTOM;};
  235. /**
  236. * @brief Default destructor.
  237. * @js NA
  238. * @lua NA
  239. */
  240. virtual ~RichElementCustomNode(){CC_SAFE_RELEASE(_customNode);};
  241. /**
  242. * @brief Initialize a RichElementCustomNode with various arguments.
  243. *
  244. * @param tag A integer tag value.
  245. * @param color A color in Color3B.
  246. * @param opacity A opacity in GLubyte.
  247. * @param customNode A custom node pointer.
  248. * @return True if initialize success, false otherwise.
  249. */
  250. bool init(int tag, const Color3B& color, GLubyte opacity, Node* customNode);
  251. /**
  252. * @brief Create a RichElementCustomNode with various arguments.
  253. *
  254. * @param tag A integer tag value.
  255. * @param color A color in Color3B.
  256. * @param opacity A opacity in GLubyte.
  257. * @param customNode A custom node pointer.
  258. * @return A RichElementCustomNode instance.
  259. */
  260. static RichElementCustomNode* create(int tag, const Color3B& color, GLubyte opacity, Node* customNode);
  261. protected:
  262. Node* _customNode;
  263. friend class RichText;
  264. };
  265. /**
  266. *@brief Rich element for new line.
  267. */
  268. class CC_GUI_DLL RichElementNewLine : public RichElement
  269. {
  270. public:
  271. /**
  272. * @brief Default constructor.
  273. * @js ctor
  274. * @lua new
  275. *
  276. */
  277. RichElementNewLine(){_type = Type::NEWLINE;};
  278. /**
  279. * @brief Default destructor.
  280. * @js NA
  281. * @lua NA
  282. */
  283. virtual ~RichElementNewLine(){};
  284. /**
  285. * @brief Create a RichElementNewLine with various arguments.
  286. *
  287. * @param tag A integer tag value.
  288. * @param color A color in Color3B.
  289. * @param opacity A opacity in GLubyte.
  290. * @return A RichElementNewLine instance.
  291. */
  292. static RichElementNewLine* create(int tag, const Color3B& color, GLubyte opacity);
  293. protected:
  294. friend class RichText;
  295. };
  296. /**
  297. *@brief A container for displaying various RichElements.
  298. * We could use it to display texts with images easily.
  299. */
  300. class CC_GUI_DLL RichText : public Widget
  301. {
  302. public:
  303. enum WrapMode {
  304. WRAP_PER_WORD,
  305. WRAP_PER_CHAR
  306. };
  307. /**
  308. * @brief call to open a resource specified by a URL
  309. * @param url a URL
  310. */
  311. typedef std::function<void(const std::string& url)> OpenUrlHandler;
  312. /**
  313. * @brief called on the specified tag
  314. * @param tagAttrValueMap the attributes of a tag
  315. * @result text attributes and RichElement
  316. */
  317. typedef std::function<std::pair<ValueMap, RichElement*>(const ValueMap& tagAttrValueMap)> VisitEnterHandler;
  318. static const std::string KEY_VERTICAL_SPACE; /*!< key of vertical space */
  319. static const std::string KEY_WRAP_MODE; /*!< key of per word, or per char */
  320. static const std::string KEY_FONT_COLOR_STRING; /*!< key of font color */
  321. static const std::string KEY_FONT_SIZE; /*!< key of font size */
  322. static const std::string KEY_FONT_SMALL; /*!< key of font size small */
  323. static const std::string KEY_FONT_BIG; /*!< key of font size big */
  324. static const std::string KEY_FONT_FACE; /*!< key of font name */
  325. static const std::string KEY_TEXT_BOLD; /*!< key of text bold */
  326. static const std::string KEY_TEXT_ITALIC; /*!< key of text italic */
  327. static const std::string KEY_TEXT_LINE; /*!< key of line style */
  328. static const std::string VALUE_TEXT_LINE_NONE; /*!< value of none */
  329. static const std::string VALUE_TEXT_LINE_DEL; /*!< value of strikethrough line */
  330. static const std::string VALUE_TEXT_LINE_UNDER; /*!< value of underline */
  331. static const std::string KEY_TEXT_STYLE; /*!< key of effect style */
  332. static const std::string VALUE_TEXT_STYLE_NONE; /*!< value of none */
  333. static const std::string VALUE_TEXT_STYLE_OUTLINE; /*!< value of outline */
  334. static const std::string VALUE_TEXT_STYLE_SHADOW; /*!< value of shadow */
  335. static const std::string VALUE_TEXT_STYLE_GLOW; /*!< value of glow */
  336. static const std::string KEY_TEXT_OUTLINE_COLOR; /*!< key of outline color */
  337. static const std::string KEY_TEXT_OUTLINE_SIZE; /*!< key of outline size */
  338. static const std::string KEY_TEXT_SHADOW_COLOR; /*!< key of shadow color */
  339. static const std::string KEY_TEXT_SHADOW_OFFSET_WIDTH; /*!< key of shadow offset (width) */
  340. static const std::string KEY_TEXT_SHADOW_OFFSET_HEIGHT; /*!< key of shadow offset (height) */
  341. static const std::string KEY_TEXT_SHADOW_BLUR_RADIUS; /*!< key of shadow blur radius */
  342. static const std::string KEY_TEXT_GLOW_COLOR; /*!< key of glow color */
  343. static const std::string KEY_URL; /*!< key of url */
  344. static const std::string KEY_ANCHOR_FONT_COLOR_STRING; /*!< key of font color of anchor tag */
  345. static const std::string KEY_ANCHOR_TEXT_BOLD; /*!< key of text bold of anchor tag */
  346. static const std::string KEY_ANCHOR_TEXT_ITALIC; /*!< key of text italic of anchor tag */
  347. static const std::string KEY_ANCHOR_TEXT_LINE; /*!< key of line style of anchor tag */
  348. static const std::string KEY_ANCHOR_TEXT_STYLE; /*!< key of effect style of anchor tag */
  349. static const std::string KEY_ANCHOR_TEXT_OUTLINE_COLOR; /*!< key of outline color of anchor tag */
  350. static const std::string KEY_ANCHOR_TEXT_OUTLINE_SIZE; /*!< key of outline size of anchor tag */
  351. static const std::string KEY_ANCHOR_TEXT_SHADOW_COLOR; /*!< key of shadow color of anchor tag */
  352. static const std::string KEY_ANCHOR_TEXT_SHADOW_OFFSET_WIDTH; /*!< key of shadow offset (width) of anchor tag */
  353. static const std::string KEY_ANCHOR_TEXT_SHADOW_OFFSET_HEIGHT; /*!< key of shadow offset (height) of anchor tag */
  354. static const std::string KEY_ANCHOR_TEXT_SHADOW_BLUR_RADIUS; /*!< key of shadow blur radius of anchor tag */
  355. static const std::string KEY_ANCHOR_TEXT_GLOW_COLOR; /*!< key of glow color of anchor tag */
  356. /**
  357. * @brief Default constructor.
  358. * @js ctor
  359. * @lua new
  360. */
  361. RichText();
  362. /**
  363. * @brief Default destructor.
  364. * @js NA
  365. * @lua NA
  366. */
  367. virtual ~RichText();
  368. /**
  369. * @brief Create a empty RichText.
  370. *
  371. * @return RichText instance.
  372. */
  373. static RichText* create();
  374. /**
  375. * @brief Create a RichText from an XML
  376. *
  377. * @return RichText instance.
  378. */
  379. static RichText* createWithXML(const std::string& xml, const ValueMap& defaults = ValueMap(), const OpenUrlHandler& handleOpenUrl = nullptr);
  380. /**
  381. * @brief Insert a RichElement at a given index.
  382. *
  383. * @param element A RichElement type.
  384. * @param index A given index.
  385. */
  386. void insertElement(RichElement* element, int index);
  387. /**
  388. * @brief Add a RichElement at the end of RichText.
  389. *
  390. * @param element A RichElement instance.
  391. */
  392. void pushBackElement(RichElement* element);
  393. /**
  394. * @brief Remove a RichElement at a given index.
  395. *
  396. * @param index A integer index value.
  397. */
  398. void removeElement(int index);
  399. /**
  400. * @brief Remove specific RichElement.
  401. *
  402. * @param element A RichElement type.
  403. */
  404. void removeElement(RichElement* element);
  405. /**
  406. * @brief Set vertical space between each RichElement.
  407. *
  408. * @param space Point in float.
  409. */
  410. void setVerticalSpace(float space);
  411. /**
  412. * @brief Rearrange all RichElement in the RichText.
  413. * It's usually called internally.
  414. */
  415. void formatText();
  416. //override functions.
  417. virtual void ignoreContentAdaptWithSize(bool ignore) override;
  418. virtual std::string getDescription() const override;
  419. void setWrapMode(WrapMode wrapMode); /*!< sets the wrapping mode: WRAP_PER_CHAR or WRAP_PER_WORD */
  420. WrapMode getWrapMode() const; /*!< returns the current wrapping mode */
  421. void setFontColor(const std::string& color); /*!< Set the font color. @param color the #RRGGBB hexadecimal notation. */
  422. std::string getFontColor(); /*!< return the current font color */
  423. Color3B getFontColor3B(); /*!< return the current font color */
  424. void setFontSize(float size); /*!< Set the font size. @param size the font size. */
  425. float getFontSize(); /*!< return the current font size */
  426. void setFontFace(const std::string& face); /*!< Set the font face. @param face the font face. */
  427. std::string getFontFace(); /*!< return the current font face */
  428. void setAnchorFontColor(const std::string& color); /*!< Set the font color of a-tag. @param face the font color. */
  429. std::string getAnchorFontColor(); /*!< return the current font color of a-tag */
  430. cocos2d::Color3B getAnchorFontColor3B(); /*!< return the current font color of a-tag */
  431. void setAnchorTextBold(bool enable); /*!< enable bold text of a-tag */
  432. bool isAnchorTextBoldEnabled(); /*!< valid style is bold text of a-tag? */
  433. void setAnchorTextItalic(bool enable); /*!< enable italic text of a-tag */
  434. bool isAnchorTextItalicEnabled(); /*!< valid style is italic text of a-tag? */
  435. void setAnchorTextDel(bool enable); /*!< enable the strikethrough of a-tag */
  436. bool isAnchorTextDelEnabled(); /*!< valid strikethrough of a-tag? */
  437. void setAnchorTextUnderline(bool enable); /*!< enable the underline of a-tag */
  438. bool isAnchorTextUnderlineEnabled(); /*!< valid underline of a-tag? */
  439. /** @brief enable the outline of a-tag */
  440. void setAnchorTextOutline(bool enable, const Color3B& outlineColor = Color3B::WHITE, int outlineSize = -1);
  441. bool isAnchorTextOutlineEnabled(); /*!< valid outline of a-tag? */
  442. Color3B getAnchorTextOutlineColor3B(); /*!< return the current text outline color of a-tag */
  443. int getAnchorTextOutlineSize(); /*!< return the current text outline size of a-tag */
  444. /** @brief enable the shadow of a-tag */
  445. void setAnchorTextShadow(bool enable, const Color3B& shadowColor = Color3B::BLACK, const Size& offset = Size(2.0, -2.0), int blurRadius = 0);
  446. bool isAnchorTextShadowEnabled(); /*!< valid shadow of a-tag? */
  447. Color3B getAnchorTextShadowColor3B(); /*!< return the current text shadow color of a-tag */
  448. Size getAnchorTextShadowOffset(); /*!< return the current text shadow offset of a-tag */
  449. int getAnchorTextShadowBlurRadius(); /*!< return the current text shadow blur radius of a-tag */
  450. void setAnchorTextGlow(bool enable, const Color3B& glowColor = Color3B::WHITE); /*!< enable the glow of a-tag */
  451. bool isAnchorTextGlowEnabled(); /*!< valid glow of a-tag? */
  452. Color3B getAnchorTextGlowColor3B(); /*!< return the current text glow color of a-tag */
  453. void setDefaults(const ValueMap& defaults); /*!< set the default values */
  454. ValueMap getDefaults() const; /*!< returns the default values */
  455. cocos2d::Color3B color3BWithString(const std::string& color); /*!< convert a color string into a Color3B. */
  456. std::string stringWithColor3B(const cocos2d::Color3B& color3b); /*!< convert a Color3B into a color string. */
  457. std::string stringWithColor4B(const cocos2d::Color4B& color4b); /*!< convert a Color4B into a color string. */
  458. /**
  459. * @brief add a callback to own tag.
  460. * @param tag tag's name
  461. * @param isFontElement use attributes of text tag
  462. * @param handleVisitEnter callback
  463. */
  464. static void setTagDescription(const std::string& tag, bool isFontElement, VisitEnterHandler handleVisitEnter);
  465. /**
  466. * @brief remove a callback to own tag.
  467. * @param tag tag's name
  468. */
  469. static void removeTagDescription(const std::string& tag);
  470. void openUrl(const std::string& url);
  471. /**
  472. * @brief Asks the callback to open a resource specified by a URL.
  473. * @discussion If you set up your own URL in the anchor tag, it is used to intercept the URL open.
  474. * @param handleOpenUrl the callback
  475. */
  476. void setOpenUrlHandler(const OpenUrlHandler& handleOpenUrl);
  477. CC_CONSTRUCTOR_ACCESS:
  478. virtual bool init() override;
  479. bool initWithXML(const std::string& xml, const ValueMap& defaults = ValueMap(), const OpenUrlHandler& handleOpenUrl = nullptr);
  480. protected:
  481. virtual void adaptRenderers() override;
  482. virtual void initRenderer() override;
  483. void pushToContainer(Node* renderer);
  484. void handleTextRenderer(const std::string& text, const std::string& fontName, float fontSize, const Color3B& color,
  485. GLubyte opacity, uint32_t flags, const std::string& url="",
  486. const Color3B& outlineColor = Color3B::WHITE, int outlineSize = -1,
  487. const Color3B& shadowColor = Color3B::BLACK, const cocos2d::Size& shadowOffset = Size(2.0, -2.0), int shadowBlurRadius = 0,
  488. const Color3B& glowColor = Color3B::WHITE);
  489. void handleImageRenderer(const std::string& filePath, const Color3B& color, GLubyte opacity, int width, int height, const std::string& url);
  490. void handleCustomRenderer(Node* renderer);
  491. void formarRenderers();
  492. void addNewLine();
  493. int findSplitPositionForWord(cocos2d::Label* label, const std::string& text);
  494. int findSplitPositionForChar(cocos2d::Label* label, const std::string& text);
  495. bool _formatTextDirty;
  496. Vector<RichElement*> _richElements;
  497. std::vector<Vector<Node*>*> _elementRenders;
  498. float _leftSpaceWidth;
  499. ValueMap _defaults; /*!< default values */
  500. OpenUrlHandler _handleOpenUrl; /*!< the callback for open URL */
  501. };
  502. }
  503. // end of ui group
  504. /// @}
  505. NS_CC_END
  506. #endif /* defined(__UIRichText__) */