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 Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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.
22 * @addtogroup CAPI_DALI_TOOLKIT_MARKUP_PROCESSOR_MODULE
27 #include <dali/public-api/common/vector-wrapper.h>
29 #include <dali/public-api/text/text.h>
30 #include <dali/public-api/text/text-style.h>
32 namespace Dali DALI_IMPORT_API
39 * @brief Markup Processor enumerations, structures and functions.
41 * See the \link markup-processor Markup Processor \endlink page in the Programming Guide.
43 namespace MarkupProcessor
47 * @brief A pair of Dali::Text and Dali::TextStyle.
49 * mText is a Dali::Text object which can store text in different
50 * languages. mStyle is a Dali::TextStyle object which can store all
51 * text styling features provided by Dali::TextActor.
67 * @param[in] text A Text object
68 * @param[in] style A Style object
70 StyledText( const Text& text, const TextStyle& style )
76 Text mText; ///< Store text. Could be a mix of different languages.
77 TextStyle mStyle; ///< Store the style for the text.
81 * @brief This type defines a vector of StyledText.
83 * It's used to store a whole text with its style and set it to a
84 * Dali::Toolkit::TextView. It could be used in other UI
85 * Dali::Toolkit::Control classes which need text with style.
87 typedef std::vector<StyledText> StyledTextArray;
90 * @brief Creates a text array with its style from a markup string.
92 * Refer to the \link markup-processor Markup Processor \endlink page in the Programming Guide
93 * to see the html-ish sintax and some examples.
95 * @param [in] markupString A string with style.
96 * @param [out] styledTextArray A text array split in characters, each one with its style.
97 * @param [in] scanForMarkup If true will check to see string contains markup, else assume not
99 void GetStyledTextArray( const std::string& markupString, StyledTextArray& styledTextArray, bool scanForMarkup );
102 * @brief Creates a plain string from a text array (thus stripping the style meta).
104 * @param [in] styledTextArray A text array split in characters, each one with its style.
105 * @param [out] plainString A string without style.
107 void GetPlainString( const StyledTextArray& styledTextArray, std::string& plainString );
110 * @brief Creates a markup string from a text array with its style.
112 * @param [in] styledTextArray A text array split in characters, each one with its style.
113 * @param [out] markupString A string with style.
115 void GetMarkupString( const StyledTextArray& styledTextArray, std::string& markupString );
118 * @brief Sets a text style to the given text.
120 * By default all style settings are applied but a bit mask could be used to modify only certain style settings.
121 * @param[in,out] styledTextArray The given text
122 * @param[in] style The given style
123 * @param[in] mask The bit mask.
125 void SetTextStyle( StyledTextArray& styledTextArray, const TextStyle& style, TextStyle::Mask mask = TextStyle::ALL );
128 * @brief Sets a text style to the given text.
130 * @see SetTextStyle( StyledTextArray& styledTextArray, const TextStyle& style, TextStyle::Mask mask )
132 * @param[in] text The input text.
133 * @param[out] styledTextArray The input text with the given style.
134 * @param[in] style The given style.
135 * @param[in] mask The bit mask.
137 void SetTextStyle( const Text& text, StyledTextArray& styledTextArray, const TextStyle& style, TextStyle::Mask mask = TextStyle::ALL );
140 * @brief Sets a text style to a range of characters of the given text.
142 * By default all style settings are applied but a bit mask could be used to modify only certain style settings.
143 * @param[in,out] styledTextArray The given text
144 * @param[in] style The given style
145 * @param[in] mask The bit mask.
146 * @param[in] begin The first character of the range.
147 * @param[in] end The last character of the range.
148 * @note It will assert if begin or end are out of range, or if begin > end.
150 void SetTextStyleToRange( StyledTextArray& styledTextArray, const TextStyle& style, TextStyle::Mask mask, std::size_t begin, std::size_t end );
152 } // namespace MarkupProcessor
154 } // namespace Toolkit
161 #endif // __DALI_TOOLKIT_MARKUP_PROCESSOR_H__