Merge "Remove deprecated APIs in Tizen 3.0" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / text-controls / text-label.h
1 #ifndef __DALI_TOOLKIT_TEXT_LABEL_H__
2 #define __DALI_TOOLKIT_TEXT_LABEL_H__
3
4 /*
5  * Copyright (c) 2018 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-toolkit/public-api/controls/control.h>
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 namespace Internal DALI_INTERNAL
31 {
32 class TextLabel;
33 }
34 /**
35  * @addtogroup dali_toolkit_controls_text_controls
36  * @{
37  */
38
39 /**
40  * @brief A control which renders a short text string.
41  *
42  * Text labels are lightweight, non-editable and do not respond to user input.
43  *
44  * @section TextLabelProperties Properties
45  * |%Property enum                    |String name          |Type            |Writable|Animatable|
46  * |----------------------------------|---------------------|----------------|--------|----------|
47  * | Property::RENDERING_BACKEND      | renderingBackend    |  INTEGER       | O      | X        |
48  * | Property::TEXT                   | text                |  STRING        | O      | X        |
49  * | Property::FONT_FAMILY            | fontFamily          |  STRING        | O      | X        |
50  * | Property::FONT_STYLE             | fontStyle           |  STRING or MAP | O      | X        |
51  * | Property::POINT_SIZE             | pointSize           |  FLOAT         | O      | X        |
52  * | Property::MULTI_LINE             | multiLine           |  BOOLEAN       | O      | X        |
53  * | Property::HORIZONTAL_ALIGNMENT   | horizontalAlignment |  STRING        | O      | X        |
54  * | Property::VERTICAL_ALIGNMENT     | verticalAlignment   |  STRING        | O      | X        |
55  * | Property::TEXT_COLOR             | textColor           |  VECTOR4       | O      | X        |
56  * | Property::ENABLE_MARKUP          | enableMarkup        |  BOOLEAN       | O      | X        |
57  * | Property::ENABLE_AUTO_SCROLL     | enableAutoScroll    |  BOOLEAN       | O      | X        |
58  * | Property::AUTO_SCROLL_SPEED      | autoScrollSpeed     |  INTEGER       | O      | X        |
59  * | Property::AUTO_SCROLL_LOOP_COUNT | autoScrollLoopCount |  INTEGER       | O      | X        |
60  * | Property::AUTO_SCROLL_GAP        | autoScrollGap       |  INTEGER       | O      | X        |
61  * | Property::SHADOW                 | shadow              |  STRING or MAP | O      | X        |
62  * | Property::UNDERLINE              | underline           |  STRING or MAP | O      | X        |
63  *
64  * @SINCE_1_0.0
65  */
66 class DALI_TOOLKIT_API TextLabel : public Control
67 {
68 public:
69
70   /**
71    * @brief Enumeration for the start and end property ranges for this control.
72    * @SINCE_1_0.0
73    */
74   enum PropertyRange
75   {
76     PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, ///< @SINCE_1_0.0
77     PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000,             ///< Reserve property indices @SINCE_1_0.0
78
79     ANIMATABLE_PROPERTY_START_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX, ///< @SINCE_1_2.60
80     ANIMATABLE_PROPERTY_END_INDEX =   ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1000 ///< Reserve animatable property indices @SINCE_1_2.60
81   };
82
83   /**
84    * @brief Enumeration for the instance of properties belonging to the TextLabel class.
85    * @SINCE_1_0.0
86    */
87   struct Property
88   {
89     /**
90      * @brief Enumeration for the instance of properties belonging to the TextLabel class.
91      * @SINCE_1_0.0
92      */
93     enum
94     {
95       ///////////////////////////////////////////////////////////////////////////////
96       // Event side (non-animatable) properties
97       ///////////////////////////////////////////////////////////////////////////////
98
99       /**
100        * @DEPRECATED_1_2.53 No longer be supported and will be ignored.
101        * @brief The type of rendering e.g. bitmap-based.
102        * @details Name "renderingBackend", type Property::INT.
103        * @SINCE_1_0.0
104        */
105       RENDERING_BACKEND = PROPERTY_START_INDEX,
106
107       /**
108        * @brief The text to display in UTF-8 format.
109        * @details Name "text", type Property::STRING.
110        * @SINCE_1_0.0
111        */
112       TEXT,
113
114       /**
115        * @brief The requested font family to use.
116        * @details Name "fontFamily", type Property::STRING.
117        * @SINCE_1_0.0
118        */
119       FONT_FAMILY,
120
121       /**
122        * @brief The requested font style to use.
123        * @details Name "fontStyle", type Property::STRING or Property::MAP.
124        * @SINCE_1_2.13
125        */
126       FONT_STYLE,
127
128       /**
129        * @brief The size of font in points.
130        * @details Name "pointSize", type Property::FLOAT.
131        *          Conversion from Pixel size to Point size:
132        *           Point size = Pixel size * 72 / DPI
133        * @SINCE_1_0.0
134        */
135       POINT_SIZE,
136
137       /**
138        * @brief The single-line or multi-line layout option.
139        * @details Name "multiLine", type Property::BOOLEAN.
140        * @SINCE_1_0.0
141        * @note Default is false.
142        */
143       MULTI_LINE,
144
145       /**
146        * @brief The line horizontal alignment.
147        * @details Name "horizontalAlignment", type Property::STRING or type HorizontalAlignment::Type (Property::INTEGER)
148        *          Values "BEGIN", "CENTER", "END", default BEGIN.
149        * @note Return type is Property::STRING
150        * @SINCE_1_0.0
151        */
152       HORIZONTAL_ALIGNMENT,
153
154       /**
155        * @brief The line vertical alignment.
156        * @details Name "verticalAlignment", type Property::STRING or type VerticalAlignment::Type (Property::INTEGER).
157        *          Values "TOP",   "CENTER", "BOTTOM" @SINCE_1_0.0, default TOP.
158        * @note Return type is Property::STRING
159        * @SINCE_1_0.0
160        */
161       VERTICAL_ALIGNMENT,
162
163       /**
164        * @DEPRECATED_1_2.60 Use the new enum value of TEXT_COLOR instead.
165        * @brief The color of the text.
166        * @details Name "unusedPropertyTextColor", type Property::VECTOR4.
167        * @SINCE_1_0.0
168        */
169       UNUSED_PROPERTY_TEXT_COLOR,
170
171       /**
172        * @brief Whether the mark-up processing is enabled.
173        * @details Name "enableMarkup", type Property::BOOLEAN.
174        * @SINCE_1_0.0
175        * @note Default is false.
176        */
177       ENABLE_MARKUP,
178
179       /**
180        * @brief Starts or stops auto scrolling.
181        * @details Name "enableAutoScroll", type Property::BOOLEAN.
182        * @SINCE_1_1.35
183        * @note Default is false.
184        */
185       ENABLE_AUTO_SCROLL,
186
187       /**
188        * @brief Sets the speed of scrolling in pixels per second.
189        * @details Name "autoScrollSpeed", type Property::INT.
190        * @SINCE_1_1.35
191        * @note Default in style sheet.
192        */
193       AUTO_SCROLL_SPEED,
194
195       /**
196        * @brief Number of complete loops when scrolling enabled.
197        * @details Name "autoScrollLoopCount", type Property::INT.
198        * @SINCE_1_1.35
199        * @note Default in style sheet.
200        */
201       AUTO_SCROLL_LOOP_COUNT,
202
203       /**
204        * @brief Gap before scrolling wraps.
205        * @details Name "autoScrollGap", type Property::INT.
206        * @SINCE_1_1.35
207        * @note Default in style sheet but can be overridden to prevent same text being shown at start and end.
208        * @note Displayed gap size is not guaranteed if the text length plus gap exceeds the maximum texture size (i.e. GL_MAX_TEXTURE_SIZE).
209        */
210       AUTO_SCROLL_GAP,
211
212       /**
213        * @brief The default extra space between lines in points.
214        * @details Name "lineSpacing", type Property::FLOAT.
215        * @SINCE_1_1.37
216        */
217       LINE_SPACING,
218
219       /**
220        * @brief The default underline parameters.
221        * @details Name "underline", type Property::MAP.
222        *
223        * The underline map contains the following keys:
224        *
225        * | %Property Name       | Type     | Required | Description                                                                                                        |
226        * |----------------------|----------|----------|--------------------------------------------------------------------------------------------------------------------|
227        * | enable               | BOOLEAN  | No       | True to enable the underline or false to disable (the default value is false)                                      |
228        * | color                | VECTOR4  | No       | The color of the underline (the default value is Color::BLACK)                                                     |
229        * | height               | FLOAT    | No       | The height of the underline (the default value is 0)                                                               |
230        *
231        * @SINCE_1_2.13
232        */
233       UNDERLINE,
234
235       /**
236        * @brief The default shadow parameters.
237        * @details Name "shadow", type Property::MAP.
238        *
239        * The shadow map contains the following keys:
240        *
241        * | %Property Name       | Type     | Required | Description                                                                                                        |
242        * |----------------------|----------|----------|--------------------------------------------------------------------------------------------------------------------|
243        * | color                | VECTOR4  | No       | The color of the shadow (the default value is Color::BLACK)                                                        |
244        * | offset               | VECTOR2  | No       | The offset from the text to draw the shadow in the X and Y axes (the default value is 0 which means no shadow)     |
245        * | blurRadius           | FLOAT    | No       | The radius of blur to be applied to the shadow (the default value is 0 which means no blur)                        |
246        *
247        * @SINCE_1_2.13
248        */
249       SHADOW,
250
251       /**
252        * @brief The default emboss parameters.
253        * @details Name "emboss", type Property::MAP.
254        * @SINCE_1_2.13
255        */
256       EMBOSS,
257
258       /**
259        * @brief The default outline parameters.
260        * @details Name "outline", type Property::MAP.
261        *
262        * The outline map contains the following keys:
263        *
264        * | %Property Name       | Type     | Required | Description                                                                                                        |
265        * |----------------------|----------|----------|--------------------------------------------------------------------------------------------------------------------|
266        * | color                | VECTOR4  | No       | The color of the outline (the default value is Color::WHITE)                                                       |
267        * | width                | INTEGER  | No       | The width of the outline (the default value is 0 which means no outline)                                           |
268        *
269        * @SINCE_1_2.13
270        */
271       OUTLINE,
272
273       /**
274        * @brief The size of font in pixels.
275        * @details Name "pixelSize", type Property::FLOAT.
276        *          Conversion from Point size to Pixel size:
277        *            Pixel size = Point size * DPI / 72
278        * @SINCE_1_2.60
279        */
280       PIXEL_SIZE,
281
282       /**
283        * @brief Whether we should show the ellipsis if required.
284        * @details Name "ellipsis", type Property::BOOLEAN.
285        * @SINCE_1_2.60
286        */
287       ELLIPSIS,
288
289       /**
290        * @brief The amount of time to delay the starting time of auto scrolling and further loops.
291        * @details Name "autoScrollLoopDelay", type Property::FLOAT.
292        * @SINCE_1_2.60
293        */
294       AUTO_SCROLL_LOOP_DELAY,
295
296       /**
297        * @brief The auto scrolling stop behaviour.
298        * @details Name "autoScrollStopMode", type AutoScrollStopMode::Type (Property::INTEGER) or Property::STRING.
299        * @SINCE_1_2.60
300        * @note Default is AutoScrollStopMode::FINISH_LOOP.
301        * @see AutoScrollStopMode::Type
302        */
303       AUTO_SCROLL_STOP_MODE,
304
305       /**
306        * @brief The line count of text.
307        * @details name "lineCount", type Property::INTEGER.
308        * @SINCE_1_2.60
309        * @note This property is read-only.
310        */
311       LINE_COUNT,
312
313       /**
314        * @brief Line wrap mode when text lines are greater than the layout width.
315        * @details Name "lineWrapMode", type Text::LineWrap::Mode (Text::Property::INTEGER) or Property::STRING.
316        * @SINCE_1_2.60
317        * @note Default is Text::LineWrap::WORD.
318        * @note Return type is Text::LineWrap::Mode (Text::Property::INTEGER).
319        * @see Text::LineWrap
320        */
321       LINE_WRAP_MODE,
322
323       ///////////////////////////////////////////////////////////////////////////////
324       // Animatable Properties
325       ///////////////////////////////////////////////////////////////////////////////
326
327       /**
328        * @brief The color of the text.
329        * @details Name "textColor", type Property::VECTOR4.
330        * @SINCE_1_2.60
331        */
332       TEXT_COLOR = ANIMATABLE_PROPERTY_START_INDEX,
333
334       /**
335        * @brief The red component of the text color.
336        * @details Name "textColorRed", type Property::FLOAT.
337        * @SINCE_1_2.60
338        * @see TEXT_COLOR
339        */
340       TEXT_COLOR_RED,
341
342       /**
343        * @brief The green component of the text color.
344        * @details Name "textColorGreen", type Property::FLOAT.
345        * @SINCE_1_2.60
346        * @see TEXT_COLOR
347        */
348       TEXT_COLOR_GREEN,
349
350       /**
351        * @brief The blue component of the text color.
352        * @details Name "textColorBlue", type Property::FLOAT.
353        * @SINCE_1_2.60
354        * @see TEXT_COLOR
355        */
356       TEXT_COLOR_BLUE,
357
358       /**
359        * @brief The alpha component of the text color.
360        * @details Name "textColorAlpha", type Property::FLOAT.
361        * @SINCE_1_2.60
362        * @see TEXT_COLOR
363        */
364       TEXT_COLOR_ALPHA,
365     };
366   };
367
368   /**
369    * @brief The enumerations used for auto scroll stop mode.
370    * @SINCE_1_2.60
371    * @see Property::AUTO_SCROLL_STOP_MODE.
372    */
373   struct AutoScrollStopMode
374   {
375     /**
376      * @brief The enumerations used for auto scroll stop mode.
377      * @SINCE_1_2.60
378      * @see Property::AUTO_SCROLL_STOP_MODE.
379      */
380     enum Type
381     {
382       FINISH_LOOP = 0,  ///< Stop animation after current loop finishes. @SINCE_1_2.60
383       IMMEDIATE         ///< Stop animation immediately and reset position. @SINCE_1_2.60
384     };
385   };
386
387   /**
388    * @brief Creates the TextLabel control.
389    *
390    * @SINCE_1_0.0
391    * @return A handle to the TextLabel control
392    */
393   static TextLabel New();
394
395   /**
396    * @brief Creates the TextLabel control.
397    *
398    * @SINCE_1_0.0
399    * @param[in] text The text to display
400    * @return A handle to the TextLabel control
401    */
402   static TextLabel New( const std::string& text );
403
404   /**
405    * @brief Creates an empty handle.
406    * @SINCE_1_0.0
407    */
408   TextLabel();
409
410   /**
411    * @brief Copy constructor.
412    *
413    * @SINCE_1_0.0
414    * @param[in] handle The handle to copy from
415    */
416   TextLabel( const TextLabel& handle );
417
418   /**
419    * @brief Assignment operator.
420    *
421    * @SINCE_1_0.0
422    * @param[in] handle The handle to copy from
423    * @return A reference to this
424    */
425   TextLabel& operator=( const TextLabel& handle );
426
427   /**
428    * @brief Destructor.
429    *
430    * This is non-virtual since derived Handle types must not contain data or virtual methods.
431    * @SINCE_1_0.0
432    */
433   ~TextLabel();
434
435   /**
436    * @brief Downcasts a handle to TextLabel.
437    *
438    * If the BaseHandle points is a TextLabel, the downcast returns a valid handle.
439    * If not, the returned handle is left empty.
440    *
441    * @SINCE_1_0.0
442    * @param[in] handle Handle to an object
443    * @return Handle to a TextLabel or an empty handle
444    */
445   static TextLabel DownCast( BaseHandle handle );
446
447 public: // Not intended for application developers
448
449   /// @cond internal
450   /**
451    * @brief Creates a handle using the Toolkit::Internal implementation.
452    *
453    * @SINCE_1_0.0
454    * @param[in] implementation The Control implementation
455    */
456   DALI_INTERNAL TextLabel( Internal::TextLabel& implementation );
457
458   /**
459    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
460    *
461    * @SINCE_1_0.0
462    * @param[in] internal A pointer to the internal CustomActor
463    */
464   explicit DALI_INTERNAL TextLabel( Dali::Internal::CustomActor* internal );
465   /// @endcond
466 };
467
468 /**
469  * @}
470  */
471 } // namespace Toolkit
472
473 } // namespace Dali
474
475 #endif // __DALI_TOOLKIT_TEXT_LABEL_H__