Adaptor refactor
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / text-abstraction / bidirectional-support.h
1 #ifndef __DALI_PLATFORM_TEXT_ABSTRACTION_BIDIRECTIONAL_SUPPORT_H__
2 #define __DALI_PLATFORM_TEXT_ABSTRACTION_BIDIRECTIONAL_SUPPORT_H__
3
4 /*
5  * Copyright (c) 2015 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/devel-api/text-abstraction/text-abstraction-definitions.h>
23
24 // EXTERNAL INCLUDES
25 #include <dali/public-api/object/base-handle.h>
26
27 namespace Dali
28 {
29
30 namespace TextAbstraction
31 {
32
33 namespace Internal DALI_INTERNAL
34 {
35
36 class BidirectionalSupport;
37
38 } // Internal
39
40 /**
41  * BidirectionalSupport API
42  *
43  */
44 class DALI_IMPORT_API BidirectionalSupport : public BaseHandle
45 {
46
47 public:
48
49   /**
50    * @brief Create an uninitialized TextAbstraction handle.
51    *
52    */
53   BidirectionalSupport();
54
55   /**
56    * @brief Destructor
57    *
58    * This is non-virtual since derived Handle types must not contain data or virtual methods.
59    */
60   ~BidirectionalSupport();
61
62   /**
63    * @brief This constructor is used by BidirectionalSupport::Get().
64    *
65    * @param[in] implementation a pointer to the internal bidirectional support object.
66    */
67   explicit DALI_INTERNAL BidirectionalSupport( Internal::BidirectionalSupport* implementation );
68
69   /**
70    * @brief Retrieve a handle to the BidirectionalSupport instance.
71    *
72    * @return A handle to the BidirectionalSupport
73    */
74   static BidirectionalSupport Get();
75
76   /**
77    * @brief Creates bidirectional data for the whole paragraph.
78    *
79    * @param[in] paragraph Pointer to the first character of the paragraph coded in UTF32.
80    * @param[in] numberOfCharacters The number of characters of the paragraph.
81    *
82    * @return An index of an object inside a table storing the bidirectional data.
83    */
84   BidiInfoIndex CreateInfo( const Character* const paragraph,
85                             Length numberOfCharacters );
86
87   /**
88    * @brief Destroys the bidirectional data.
89    *
90    * @param[in] bidiInfoIndex The index to the of the object inside the table storing the bidirectional data for the current paragraph.
91    */
92   void DestroyInfo( BidiInfoIndex bidiInfoIndex );
93
94   /**
95    * @brief Reorders a line of a paragraph.
96    *
97    * @pre visualToLogicalMap must have enough space allocated for @p numberOfCharacters.
98    *
99    * @param[in] bidiInfoIndex The index to the of the object inside the table storing the bidirectional data for the current paragraph.
100    * @param[in] firstCharacterIndex The first character of the line within the whole paragraph.
101    * @param[in] numberOfCharacters The number of characters of the line.
102    * @param[out] visualToLogicalMap The visual to logical conversion map.
103    */
104   void Reorder( BidiInfoIndex bidiInfoIndex,
105                 CharacterIndex firstCharacterIndex,
106                 Length numberOfCharacters,
107                 CharacterIndex* visualToLogicalMap );
108
109   /**
110    * @brief Replaces any character which could be mirrored.
111    *
112    * @param[in,out] text The text.
113    * @param[in] directions The direction of each paragraph.
114    * @param[in] numberOfCharacters The number of characters.
115    *
116    * @return @e true if a character has been replaced.
117    */
118   bool GetMirroredText( Character* text,
119                         CharacterDirection* directions,
120                         Length numberOfCharacters );
121
122   /**
123    * @brief Retrieves the paragrpah's direction.
124    *
125    * @param[in] bidiInfoIndex The index to the of the object inside the table storing the bidirectional data for the current paragraph.
126    *
127    * @return @e true if the paragraph is right to left, otherwise @e false.
128    */
129   bool GetParagraphDirection( BidiInfoIndex bidiInfoIndex ) const;
130
131   /**
132    * @brief Retrieves the character's directions.
133    *
134    * @param[in] bidiInfoIndex The index to the of the object inside the table storing the bidirectional data for the current paragraph.
135    * @param[out] directions The direction, @e false is left to right and @e true is right to left, of each character of the paragraph.
136    * @param[in] numberOfCharacters The number of characters.
137    */
138   void GetCharactersDirection( BidiInfoIndex bidiInfoIndex,
139                                CharacterDirection* directions,
140                                Length numberOfCharacters );
141 };
142
143 } // namespace TextAbstraction
144
145 } // namespace Dali
146
147 #endif // __DALI_PLATFORM_TEXT_ABSTRACTION_BIDIRECTIONAL_SUPPORT_H__