Split dali-toolkit into Base & Optional
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / internal / controls / text-view / text-view-processor-helper-functions.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PROCESSOR_HELPER_FUNCTIONS_H__
2 #define __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PROCESSOR_HELPER_FUNCTIONS_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
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
10 //
11 //     http://floralicense.org/license/
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 // INTERNAL INCLUDES
21 #include "text-view-processor-types.h"
22
23 namespace Dali
24 {
25
26 namespace Toolkit
27 {
28
29 namespace Internal
30 {
31
32 namespace TextViewProcessor
33 {
34
35 /**
36  * Enum type used to update a size adding other one.
37  * If the grow type is \e GrowWidth, size's widths are added and size's height is the max of both.
38  * Alternativelly if grow type is \e GrowHeight heights are added and width is the max of both.
39  */
40 enum SizeGrowType
41 {
42   GrowWidth,
43   GrowHeight,
44 };
45
46 /**
47  * Updates the size of a group of characters, word, group of words, line or the whole text with a given size.
48  *
49  * For group of characters, words, groups of words and lines the new height will be the maximum of both sizes
50  * and the new width will be the sum of both.
51  *
52  * For the whole text, the new height will be the sum of both and the new width the max of both.
53  *
54  * The \e type parameter speficies which type of update is required.
55  *
56  * @param[in,out] size1 The current size to be updated.
57  * @param[in] size2 The size of a group of characters, word, group of words or a line.
58  * @param[in] type Type of update.
59  */
60 void UpdateSize( Size& size1, const Size& size2, SizeGrowType type = GrowWidth );
61
62 /**
63  * Return the type of separator (white space, new line or no separator) for the given character.
64  *
65  * @param[in] character The given character.
66  *
67  * @return The type of separator.
68  */
69 TextSeparatorType GetTextSeparatorType( const Character& character );
70
71 /**
72  * Choose a suitable font family name for the given styled text.
73  *
74  * It may modify the text-style of the given text by setting a suitable font-family.
75  *
76  * @param[in,out] text Text with style.
77  */
78 void ChooseFontFamilyName( MarkupProcessor::StyledText& text );
79
80 /**
81  * Retrieves the line, word group, word and character indices for the given global character's index.
82  *
83  * i.e. The retrieved indices for the character 18 (j) for the following text would be: 2, 0, 2, 0
84  *
85  *  a b c d
86  *  e f g h
87  *  i j k l
88  *  m n o p
89  *
90  * @param[in] index The global character index.
91  * @param[in] textLayoutInfo Contains info about the number of characters per word, group and line.
92  * @param[out] indices Index to the line, group of words, word and character within the word where the given character is located.
93  */
94 void GetIndicesFromGlobalCharacterIndex( std::size_t index,
95                                          const TextLayoutInfo& textLayoutInfo,
96                                          TextInfoIndices& indices );
97
98 /**
99  * Clear the text of the given text-actors.
100  *
101  * @param[in] textActors The given text-actors.
102  */
103 void ClearText( std::vector<TextActor>& textActors );
104
105 } //namespace TextViewProcessor
106
107 } //namespace Internal
108
109 } //namespace Toolkit
110
111 } //namespace Dali
112
113 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_VIEW_PROCESSOR_HELPER_FUNCTIONS_H__