[dali_1.0.31] Merge branch 'tizen'
[platform/core/uifw/dali-core.git] / dali / internal / event / text / text-impl.h
1 #ifndef __DALI_INTERNAL_TEXT_H__
2 #define __DALI_INTERNAL_TEXT_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 // EXTERNAL INCLUDES
22 #include <string>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/text/text.h>
26 #include <dali/integration-api/text-array.h>
27
28 namespace Dali
29 {
30
31 namespace Internal
32 {
33
34 /**
35  * Implementation class for Dali::Text.
36  * @see Dali::Text.
37  */
38 class Text
39 {
40 public:
41
42   /**
43    * @copydoc Dali::Text::Text().
44    */
45   Text();
46
47   /**
48    * @copydoc Dali::Text::Text( const std::string& text ).
49    */
50   Text( const std::string& text );
51
52   /**
53    * @copydoc Dali::Text::Text( const Character& character ).
54    */
55   Text( const Character& character );
56
57   /**
58    * @copydoc Dali::Text::Text( const Text& text ).
59    */
60   Text( const Text& text );
61
62   /**
63    * @copydoc Dali::Text::operator=( const Text& text )
64    */
65   Text& operator=( const Text& text );
66
67   /**
68    * Non-virtual destructor.
69    */
70   ~Text();
71
72   /**
73    * Clears the text.
74    */
75   void Clear();
76
77   /**
78    * Converts stored text encoded in UTF-32 to a std::string encoded with UTF-8.
79    * @param [out] text The text resultant of the UTF-32 to UTF-8 conversion.
80    */
81   void GetText( std::string& text ) const;
82
83   /**
84    * @copydoc Dali::Text::operator[]()
85    */
86   Dali::Character operator[]( size_t position ) const;
87
88   /**
89    * @copydoc Dali::Text::IsEmpty()
90    */
91   bool IsEmpty() const;
92
93   /**
94    * @copydoc Dali::Text::GetLength()
95    */
96   size_t GetLength() const;
97
98   /**
99    * @copydoc Dali::Text::Append( const Text& text )
100    */
101   void Append( const Dali::Text& text );
102
103   /**
104    * @copydoc Dali::Text::Remove()
105    */
106   void Remove( size_t position, size_t numberOfCharacters );
107
108   /**
109    * @copydoc Dali::Text::Find( const Character& character, std::size_t from, std::size_t to, Vector<std::size_t>& positions )
110    */
111   void Find( uint32_t character, std::size_t from, std::size_t to, Vector<std::size_t>& positions ) const;
112
113   /**
114    * @copydoc Dali::Text::Find( SpecialCharacter character, std::size_t from, std::size_t to, Vector<std::size_t>& positions )
115    */
116   void FindWhiteSpace( std::size_t from, std::size_t to, Vector<std::size_t>& positions ) const;
117
118   /**
119    * @copydoc Dali::Text::Find( SpecialCharacter character, std::size_t from, std::size_t to, Vector<std::size_t>& positions )
120    */
121   void FindNewLine( std::size_t from, std::size_t to, Vector<std::size_t>& positions ) const;
122
123   /**
124    * @copydoc Dali::Text::GetSubText()
125    */
126   void GetSubText( std::size_t from, std::size_t to, Text* subText ) const;
127
128   /**
129    * @copydoc Dali::Text::IsWhiteSpace()
130    */
131   bool IsWhiteSpace( std::size_t index ) const;
132
133   /**
134    * @copydoc Dali::Text::IsNewLine()
135    */
136   bool IsNewLine( std::size_t index ) const;
137
138   /**
139    * Retrieves a reference to the UTF-32 encoded string.
140    * @return A reference to the UTF-32 encoded string.
141    */
142   const Integration::TextArray& GetTextArray() const;
143
144 private:
145
146   Integration::TextArray mString; ///< Stores an array of unicodes.
147 };
148
149 /**
150  * @brief  Helper function to get the Integration::TextArray from a Dali::Text.
151  *
152  * @param[in] text A Dali::Text.
153  *
154  * @return The Text's Integration::TextArray.
155  */
156  const Integration::TextArray& GetTextArray( const Dali::Text& text );
157
158 } // namespace Internal
159
160 } // namespace Dali
161
162 #endif // __DALI_INTERNAL_TEXT_H__