Merge remote-tracking branch 'origin/tizen' into new_text
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / public-api / text / logical-model.h
1 #ifndef __DALI_TOOLKIT_TEXT_LOGICAL_MODEL_H__
2 #define __DALI_TOOLKIT_TEXT_LOGICAL_MODEL_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 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/intrusive-ptr.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/public-api/text/text-definitions.h>
26
27 namespace Dali
28 {
29
30 namespace Toolkit
31 {
32
33 namespace Text
34 {
35
36 class LogicalModel;
37 typedef IntrusivePtr<LogicalModel> LogicalModelPtr;
38
39 /**
40  * @brief A logical text model contains layout independent information.
41  *
42  * This includes:
43  * - A series of UTF-32 characters in logical order
44  */
45 class LogicalModel : public RefObject
46 {
47 public:
48
49   /**
50    * @brief Create a new instance of a LogicalModel.
51    *
52    * @return A pointer to a new LogicalModel.
53    */
54   static LogicalModelPtr New();
55
56   // Text interface.
57
58   /**
59    * @brief Replaces any text previously set.
60    *
61    * @param[in] text An array of UTF-32 characters.
62    * @param[in] length The length of the array.
63    */
64   void SetText( const Character* text,
65                 Length length );
66
67   /**
68    * @brief Retrieves the number of characters of the text.
69    *
70    * @return The number of characters.
71    */
72   Length GetNumberOfCharacters() const;
73
74   /**
75    * @brief Retrieves characters from the text in the given buffer.
76    *
77    * @pre The size of the @p text buffer needs to be big enough to copy the @p numberOfCharacters.
78    * @param[in] characterIndex The index to the first character to copy.
79    * @param[out] text Pointer to a buffer where the text is copied.
80    * @param[in] numberOfCharacters The number of characters to be copied.
81    */
82   void GetText( CharacterIndex characterIndex,
83                 Character* text,
84                 Length numberOfCharacters ) const;
85
86 protected:
87
88   /**
89    * @brief A reference counted object may only be deleted by calling Unreference().
90    */
91   virtual ~LogicalModel();
92
93 private:
94
95   /**
96    * @brief Private constructor.
97    */
98   LogicalModel();
99
100   // Undefined
101   LogicalModel( const LogicalModel& handle );
102
103   // Undefined
104   LogicalModel& operator=( const LogicalModel& handle );
105
106 private:
107
108   struct Impl;
109   Impl* mImpl;
110 };
111
112 } // namespace Text
113
114 } // namespace Toolkit
115
116 } // namespace Dali
117
118 #endif // __DALI_TOOLKIT_TEXT_LOGICAL_MODEL_H__