38e1fa29ab163aa3ad87ba9bad215199bfe74e2d
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-model-interface.h
1 #ifndef DALI_TOOLKIT_TEXT_MODEL_INTERFACE_H
2 #define DALI_TOOLKIT_TEXT_MODEL_INTERFACE_H
3
4 /*
5  * Copyright (c) 2017 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/math/vector2.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/internal/text/layouts/layout-alignment.h>
26 #include <dali-toolkit/internal/text/line-run.h>
27 #include <dali-toolkit/internal/text/script-run.h>
28 #include <dali-toolkit/internal/text/text-definitions.h>
29
30 namespace Dali
31 {
32
33 namespace Toolkit
34 {
35
36 namespace Text
37 {
38
39 /**
40  * @brief Interface class used to retrieve the text's model from the text-controller.
41  */
42 class ModelInterface
43 {
44 public:
45   /**
46    * @brief Virtual destructor.
47    */
48   virtual ~ModelInterface()
49   {}
50
51   /**
52    * @brief Retrives the control's size.
53    *
54    * @return The control's size.
55    */
56   virtual const Size& GetControlSize() const = 0;
57
58   /**
59    * @brief Retrives the layout's size.
60    *
61    * @return The layout's size.
62    */
63   virtual const Size& GetLayoutSize() const = 0;
64
65   /**
66    * @brief Retrieves the text's scroll position.
67    *
68    * @return The scroll position.
69    */
70   virtual const Vector2& GetScrollPosition() const = 0;
71
72   /**
73    * @brief Retrieves the text's horizontal alignment.
74    *
75    * @return The horizontal alignment.
76    */
77   virtual Layout::HorizontalAlignment GetHorizontalAlignment() const = 0;
78
79   /**
80    * @brief Retrieves the text's vertical alignment.
81    *
82    * @return The vertical alignment.
83    */
84   virtual Layout::VerticalAlignment GetVerticalAlignment() const = 0;
85
86   /**
87    * @brief Whether the text elide property is enabled.
88    *
89    * @return @e true if the text elide property is enabled, @e false otherwise.
90    */
91   virtual bool IsTextElideEnabled() const = 0;
92
93   /**
94    * @brief Retrieves the number of laid-out lines.
95    *
96    * @return The number of laid-out lines.
97    */
98   virtual Length GetNumberOfLines() const = 0;
99
100   /**
101    * @brief Retrieves the laid-out lines.
102    *
103    * @return A pointer to the vector with the laid-out lines.
104    */
105   virtual const LineRun* const GetLines() const = 0;
106
107   /**
108    * @brief Retrieves the number of script runs.
109    *
110    * @return The number of script runs.
111    */
112   virtual Length GetNumberOfScripts() const = 0;
113
114   /**
115    * @brief Retrieves the script runs.
116    *
117    * @return A pointer to the vector with the runs of characters with the same script..
118    */
119   virtual const ScriptRun* const GetScriptRuns() const = 0;
120
121   /**
122    * @brief Retrieves the number of laid-out glyphs.
123    *
124    * @return The number of laid-out glyphs.
125    */
126   virtual Length GetNumberOfGlyphs() const = 0;
127
128   /**
129    * @brief Retrieves the laid-out glyphs.
130    *
131    * @return A pointer to the vector with the laid-out glyphs.
132    */
133   virtual const GlyphInfo* const GetGlyphs() const = 0;
134
135   /**
136    * @brief Retrieves the text layout.
137    *
138    * @return A pointer to the vector with the positions for each glyph.
139    */
140   virtual const Vector2* const GetLayout() const = 0;
141
142   /**
143    * @brief Retrieves the vector of colors.
144    *
145    * @return Pointer to the vector of colors.
146    */
147   virtual const Vector4* const GetColors() const = 0;
148
149   /**
150    * @brief Retrieves the vector of indices to the vector of colors.
151    *
152    * @return Pointer to a vector which stores for each glyph the index to the vector of colors.
153    */
154   virtual const ColorIndex* const GetColorIndices() const = 0;
155
156   /**
157    * @brief Retrieves the text's default color.
158    *
159    * @return The default color.
160    */
161   virtual const Vector4& GetDefaultColor() const = 0;
162
163   /**
164    * @brief Retrieves the shadow offset, 0 indicates no shadow.
165    *
166    * @return The shadow offset.
167    */
168   virtual const Vector2& GetShadowOffset() const = 0;
169
170   /**
171    * @brief Retrieves the shadow color.
172    *
173    * @return The shadow color.
174    */
175   virtual const Vector4& GetShadowColor() const = 0;
176
177   /**
178    * @brief Retrieves the underline color.
179    *
180    * @return The underline color.
181    */
182   virtual const Vector4& GetUnderlineColor() const = 0;
183
184   /**
185    * @brief Returns whether underline is enabled or not.
186    *
187    * @return The underline state.
188    */
189   virtual bool IsUnderlineEnabled() const = 0;
190
191   /**
192    * @brief Retrieves the underline height override
193    *
194    * @return Returns the override height for an underline, 0 indicates that adaptor will determine the height
195    */
196   virtual float GetUnderlineHeight() const = 0;
197
198   /**
199    * @brief Retrieves the number of underline runs.
200    *
201    * @return The number of underline runs.
202    */
203   virtual Length GetNumberOfUnderlineRuns() const = 0;
204
205   /**
206    * @brief Retrieves the underline runs.
207    *
208    * @param[out] underlineRuns Pointer to a buffer where the underline runs are copied.
209    * @param[in] index Index of the first underline run to be copied.
210    * @param[in] numberOfRuns Number of underline runs to be copied.
211    */
212   virtual void GetUnderlineRuns( GlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns ) const = 0;
213 };
214
215 } // namespace Text
216
217 } // namespace Toolkit
218
219 } // namespace Dali
220
221 #endif // DALI_TOOLKIT_TEXT_MODEL_INTERFACE_H