Remove CAPI from Toolkit
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / public-api / markup-processor / markup-processor.h
1 #ifndef __DALI_TOOLKIT_MARKUP_PROCESSOR_H__
2 #define __DALI_TOOLKIT_MARKUP_PROCESSOR_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/common/vector-wrapper.h>
23
24 #include <dali/public-api/text/text.h>
25 #include <dali/public-api/text/text-style.h>
26
27 namespace Dali DALI_IMPORT_API
28 {
29
30 namespace Toolkit
31 {
32
33 /**
34  * @brief Markup Processor enumerations, structures and functions.
35  *
36  * See the \link markup-processor Markup Processor \endlink page in the Programming Guide.
37  */
38 namespace MarkupProcessor
39 {
40
41 /**
42  * @brief A pair of Dali::Text and Dali::TextStyle.
43  *
44  * mText is a Dali::Text object which can store text in different
45  * languages. mStyle is a Dali::TextStyle object which can store all
46  * text styling features provided by Dali::TextActor.
47  */
48 struct StyledText
49 {
50   /**
51    * @brief Constructor
52    */
53   StyledText()
54   : mText(),
55     mStyle()
56   {
57   }
58
59   /**
60    * @brief Constructor
61    *
62    * @param[in] text  A Text object
63    * @param[in] style A Style object
64    */
65   StyledText( const Text& text, const TextStyle& style )
66   : mText( text ),
67     mStyle( style )
68   {
69   }
70
71   Text      mText;  ///< Store text. Could be a mix of different languages.
72   TextStyle mStyle; ///< Store the style for the text.
73 };
74
75 /**
76  * @brief This type defines a vector of StyledText.
77  *
78  * It's used to store a whole text with its style and set it to a
79  * Dali::Toolkit::TextView. It could be used in other UI
80  * Dali::Toolkit::Control classes which need text with style.
81  */
82 typedef std::vector<StyledText> StyledTextArray;
83
84 /**
85  * @brief Creates a text array with its style from a markup string.
86  *
87  * Refer to the \link markup-processor Markup Processor \endlink page in the Programming Guide
88  * to see the html-ish sintax and some examples.
89  *
90  * @param [in] markupString A string with style.
91  * @param [out] styledTextArray A text array split in characters, each one with its style.
92  * @param [in] scanForMarkup If true will check to see string contains markup, else assume not
93  */
94 void GetStyledTextArray( const std::string& markupString, StyledTextArray& styledTextArray, bool scanForMarkup );
95
96 /**
97  * @brief Creates a plain string from a text array (thus stripping the style meta).
98  *
99  * @param [in] styledTextArray A text array split in characters, each one with its style.
100  * @param [out] plainString A string without style.
101  */
102 void GetPlainString( const StyledTextArray& styledTextArray, std::string& plainString );
103
104 /**
105  * @brief Creates a markup string from a text array with its style.
106  *
107  * @param [in] styledTextArray A text array split in characters, each one with its style.
108  * @param [out] markupString A string with style.
109  */
110 void GetMarkupString( const StyledTextArray& styledTextArray, std::string& markupString );
111
112 /**
113  * @brief Sets a text style to the given text.
114  *
115  * By default all style settings are applied but a bit mask could be used to modify only certain style settings.
116  * @param[in,out] styledTextArray The given text
117  * @param[in] style The given style
118  * @param[in] mask The bit mask.
119  */
120 void SetTextStyle( StyledTextArray& styledTextArray, const TextStyle& style, TextStyle::Mask mask = TextStyle::ALL );
121
122 /**
123  * @brief Sets a text style to the given text.
124  *
125  * @see SetTextStyle( StyledTextArray& styledTextArray, const TextStyle& style, TextStyle::Mask mask )
126  *
127  * @param[in] text The input text.
128  * @param[out] styledTextArray The input text with the given style.
129  * @param[in] style The given style.
130  * @param[in] mask The bit mask.
131  */
132 void SetTextStyle( const Text& text, StyledTextArray& styledTextArray, const TextStyle& style, TextStyle::Mask mask = TextStyle::ALL );
133
134 /**
135  * @brief Sets a text style to a range of characters of the given text.
136  *
137  * By default all style settings are applied but a bit mask could be used to modify only certain style settings.
138  * @param[in,out] styledTextArray The given text
139  * @param[in] style The given style
140  * @param[in] mask The bit mask.
141  * @param[in] begin The first character of the range.
142  * @param[in] end The last character of the range.
143  * @note It will assert if begin or end are out of range, or if begin > end.
144  */
145 void SetTextStyleToRange( StyledTextArray& styledTextArray, const TextStyle& style, TextStyle::Mask mask, std::size_t begin, std::size_t end );
146
147 } // namespace MarkupProcessor
148
149 } // namespace Toolkit
150
151 } // namespace Dali
152
153 #endif // __DALI_TOOLKIT_MARKUP_PROCESSOR_H__