1 #ifndef __DALI_TOOLKIT_MARKUP_PROCESSOR_H__
2 #define __DALI_TOOLKIT_MARKUP_PROCESSOR_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 // Licensed under the Flora License, Version 1.0 (the License);
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://floralicense.org/license/
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an AS IS BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
21 * @addtogroup CAPI_DALI_FRAMEWORK
26 #include <dali/public-api/common/vector-wrapper.h>
28 #include <dali/public-api/text/text.h>
29 #include <dali/public-api/text/text-style.h>
31 namespace Dali DALI_IMPORT_API
37 namespace MarkupProcessor
41 * Holds text and its style.
43 * mText is a Dali::Text object which can store text in different languages. mStyle is a Dali::TextStyle object which can
44 * store all text styling features provided by Dali::TextActor.
54 StyledText( const Text& text, const TextStyle& style )
60 Text mText; ///< Store text. Could be a mix of different languages.
61 TextStyle mStyle; ///< Store the style for the text.
65 * This type defines a vector of StyledText. It's used to store a whole text with its style
66 * and set it to a Dali::Toolkit::TextView. It could be used in other UI Dali::Toolkit::Control classes
67 * which need text with style.
69 typedef std::vector<StyledText> StyledTextArray;
72 * Creates a text array with its style from a markup string.
73 * The syntax of a markup string is html-ish. It contains open, close and empty tags and some of them can contain parameters.
75 * <li>\e \<b\>\</b\> Bold text.
76 * <li>\e \<i\>\</i\> Italic text.
77 * <li>\e \<u\>\</u\> Underlined text.
78 * <li>\e \<br /\> New line.
79 * <li>\e \<font\>\</font\> Specifies font properties:
81 * <li> \e face Font face.
82 * <li> \e size Font size.
83 * <li> \e color Font color.
85 * <li>\e \<shadow\>\</shadow\> Specifies shadow properties @see Dali::TextActor::SetShadow().
87 * <li> \e paramx X offset.
88 * <li> \e paramy Y offset.
89 * <li> \e color Shadow color.
91 * <li>\e \<glow\>\</glow\> Specifies glow properties @see Dali::TextActor::SetGlow().
93 * <li> \e param Glow around the text.
94 * <li> \e color Glow color.
96 * <li>\e \<outline\>\</outline\> Specifies outline properties @see Dali::TextActor::SetOutline().
98 * <li> \e paramx X thickness.
99 * <li> \e paramy Y thickness.
100 * <li> \e color Outline color.
102 * <li>\e \<smooth\>\</smooth\> Specify the smooth edge @see Dali::TextActor::SetSmoothEdge().
104 * <li> \e paramx Distance field.
108 * It transform any pair CR+LF new line characters into a single LF new line character.
109 * @param [in] markupString A string with style.
110 * @param [out] styledTextArray A text array split in characters, each one with its style.
112 void GetStyledTextArray( const std::string& markupString, StyledTextArray& styledTextArray );
115 * Creates a plain string from a text array (thus stripping the style meta)
116 * @param [in] styledTextArray A text array split in characters, each one with its style.
117 * @param [out] plainString A string without style.
119 void GetPlainString( const StyledTextArray& styledTextArray, std::string& plainString );
122 * Creates a markup string from a text array with its style.
123 * @param [in] styledTextArray A text array split in characters, each one with its style.
124 * @param [out] markupString A string with style.
126 void GetMarkupString( const StyledTextArray& styledTextArray, std::string& markupString );
129 * Sets a text style to the given text.
130 * By default all style settings are applied but a bit mask could be used to modify only certain style settings.
131 * @param[in,out] styledTextArray The given text
132 * @param[in] style The given style
133 * @param[in] mask The bit mask.
135 void SetTextStyle( StyledTextArray& styledTextArray, const TextStyle& style, const TextStyle::Mask mask = TextStyle::ALL );
138 * @see SetTextStyle( StyledTextArray& styledTextArray, const TextStyle& style, StyleMask mask )
139 * @param[in] text The input text.
140 * @param[out] styledTextArray The input text with the given style.
141 * @param[in] style The given style.
142 * @param[in] mask The bit mask.
144 void SetTextStyle( const Text& text, StyledTextArray& styledTextArray, const TextStyle& style, const TextStyle::Mask mask = TextStyle::ALL );
147 * Sets a text style to a range of characters of the given text.
148 * By default all style settings are applied but a bit mask could be used to modify only certain style settings.
149 * @param[in,out] styledTextArray The given text
150 * @param[in] style The given style
151 * @param[in] mask The bit mask.
152 * @param[in] begin The first character of the range.
153 * @param[in] end The last character of the range.
154 * @note It will assert if begin or end are out of range, or if begin > end.
156 void SetTextStyleToRange( StyledTextArray& styledTextArray, const TextStyle& style, const TextStyle::Mask mask, const std::size_t begin, const std::size_t end );
158 } // namespace MarkupProcessor
160 } // namespace Toolkit
167 #endif // __DALI_TOOLKIT_MARKUP_PROCESSOR_H__