(TextLabel) Moved all devel properties to Public API
[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) 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 // 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_IMPORT_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
148        *          Values "BEGIN", "CENTER", "END", default BEGIN.
149        * @SINCE_1_0.0
150        */
151       HORIZONTAL_ALIGNMENT,
152
153       /**
154        * @brief The line vertical alignment.
155        * @details Name "verticalAlignment", type Property::STRING.
156        *          Values "TOP",   "CENTER", "BOTTOM" @SINCE_1_0.0, default TOP.
157        * @SINCE_1_0.0
158        */
159       VERTICAL_ALIGNMENT,
160
161       /**
162        * @DEPRECATED_1_2.60 Use the new enum value of TEXT_COLOR instead.
163        * @brief The color of the text.
164        * @details Name "unusedPropertyTextColor", type Property::VECTOR4.
165        * @SINCE_1_0.0
166        */
167       UNUSED_PROPERTY_TEXT_COLOR,
168
169       /**
170        * @DEPRECATED_1_1.37 Use SHADOW instead
171        * @brief The drop shadow offset 0 indicates no shadow.
172        * @details Name "shadowOffset", type Property::VECTOR2.
173        */
174       SHADOW_OFFSET,
175
176       /**
177        * @DEPRECATED_1_1.37 Use SHADOW instead
178        * @brief The color of a drop shadow.
179        * @details Name "shadowColor", type Property::VECTOR4
180        */
181       SHADOW_COLOR,
182
183       /**
184        * @DEPRECATED_1_1.37 Use UNDERLINE instead
185        * @brief The underline enabled flag.
186        * @details Name "underlineEnabled", type Property::BOOLEAN.
187        */
188       UNDERLINE_ENABLED,
189
190       /**
191        * @DEPRECATED_1_1.37 Use UNDERLINE instead
192        * @brief The color of the underline.
193        * @details Name "underlineColor", type Property::VECTOR4.
194        */
195       UNDERLINE_COLOR,
196
197       /**
198        * @DEPRECATED_1_1.37 Use UNDERLINE instead
199        * @brief Overrides the underline height from font metrics.
200        * @details Name "underlineHeight", type Property::FLOAT.
201        */
202       UNDERLINE_HEIGHT,
203
204       /**
205        * @brief Whether the mark-up processing is enabled.
206        * @details Name "enableMarkup", type Property::BOOLEAN.
207        * @SINCE_1_0.0
208        * @note Default is false.
209        */
210       ENABLE_MARKUP,
211
212       /**
213        * @brief Starts or stops auto scrolling.
214        * @details Name "enableAutoScroll", type Property::BOOLEAN.
215        * @SINCE_1_1.35
216        * @note Default is false.
217        */
218       ENABLE_AUTO_SCROLL,
219
220       /**
221        * @brief Sets the speed of scrolling in pixels per second.
222        * @details Name "autoScrollSpeed", type Property::INT.
223        * @SINCE_1_1.35
224        * @note Default in style sheet.
225        */
226       AUTO_SCROLL_SPEED,
227
228       /**
229        * @brief Number of complete loops when scrolling enabled.
230        * @details Name "autoScrollLoopCount", type Property::INT.
231        * @SINCE_1_1.35
232        * @note Default in style sheet.
233        */
234       AUTO_SCROLL_LOOP_COUNT,
235
236       /**
237        * @brief Gap before scrolling wraps.
238        * @details Name "autoScrollGap", type Property::INT.
239        * @SINCE_1_1.35
240        * @note Default in style sheet but can be overridden to prevent same text being shown at start and end.
241        */
242       AUTO_SCROLL_GAP,
243
244       /**
245        * @brief The default extra space between lines in points.
246        * @details Name "lineSpacing", type Property::FLOAT.
247        * @SINCE_1_1.37
248        */
249       LINE_SPACING,
250
251       /**
252        * @brief The default underline parameters.
253        * @details Name "underline", type Property::MAP.
254        * @SINCE_1_2.13
255        */
256       UNDERLINE,
257
258       /**
259        * @brief The default shadow parameters.
260        * @details Name "shadow", type Property::MAP.
261        * @SINCE_1_2.13
262        */
263       SHADOW,
264
265       /**
266        * @brief The default emboss parameters.
267        * @details Name "emboss", type Property::MAP.
268        * @SINCE_1_2.13
269        */
270       EMBOSS,
271
272       /**
273        * @brief The default outline parameters.
274        * @details Name "outline", type Property::MAP.
275        * @SINCE_1_2.13
276        */
277       OUTLINE,
278
279       /**
280        * @brief The size of font in pixels.
281        * @details Name "pixelSize", type Property::FLOAT.
282        *          Conversion from Point size to Pixel size:
283        *            Pixel size = Point size * DPI / 72
284        * @SINCE_1_2.60
285        */
286       PIXEL_SIZE,
287
288       /**
289        * @brief Whether we should show the ellipsis if required.
290        * @details Name "ellipsis", type Property::BOOLEAN.
291        * @SINCE_1_2.60
292        */
293       ELLIPSIS,
294
295       /**
296        * @brief The amount of time to delay the starting time of auto scrolling and further loops.
297        * @details Name "autoScrollLoopDelay", type Property::FLOAT.
298        * @SINCE_1_2.60
299        */
300       AUTO_SCROLL_LOOP_DELAY,
301
302       /**
303        * @brief The auto scrolling stop behaviour.
304        * @details Name "autoScrollStopMode", type AutoScrollStopMode::Type (Property::INTEGER) or Property::STRING.
305        * @SINCE_1_2.60
306        * @note Default is AutoScrollStopMode::FINISH_LOOP.
307        * @see AutoScrollStopMode::Type
308        */
309       AUTO_SCROLL_STOP_MODE,
310
311       /*
312        * @brief The line count of text.
313        * @details name "lineCount", type Property::INTEGER.
314        * @SINCE_1_2.60
315        * @note This property is read-only.
316        */
317       LINE_COUNT,
318
319       /**
320        * @brief Line wrap mode when text lines are greater than the layout width.
321        * @details Name "lineWrapMode", type Property::STRING.
322        * @SINCE_1_2.60
323        */
324       LINE_WRAP_MODE,
325
326       ///////////////////////////////////////////////////////////////////////////////
327       // Animatable Properties
328       ///////////////////////////////////////////////////////////////////////////////
329
330       /**
331        * @brief The color of the text.
332        * @details Name "textColor", type Property::VECTOR4.
333        * @SINCE_1_2.60
334        */
335       TEXT_COLOR = ANIMATABLE_PROPERTY_START_INDEX,
336
337       /**
338        * @brief The red component of the text color.
339        * @details Name "textColorRed", type Property::FLOAT.
340        * @SINCE_1_2.60
341        * @see TEXT_COLOR
342        */
343       TEXT_COLOR_RED,
344
345       /**
346        * @brief The green component of the text color.
347        * @details Name "textColorGreen", type Property::FLOAT.
348        * @SINCE_1_2.60
349        * @see TEXT_COLOR
350        */
351       TEXT_COLOR_GREEN,
352
353       /**
354        * @brief The blue component of the text color.
355        * @details Name "textColorBlue", type Property::FLOAT.
356        * @SINCE_1_2.60
357        * @see TEXT_COLOR
358        */
359       TEXT_COLOR_BLUE,
360
361       /**
362        * @brief The alpha component of the text color.
363        * @details Name "textColorAlpha", type Property::FLOAT.
364        * @SINCE_1_2.60
365        * @see TEXT_COLOR
366        */
367       TEXT_COLOR_ALPHA,
368     };
369   };
370
371   /**
372    * @brief The enumerations used for auto scroll stop mode.
373    * @SINCE_1_2.60
374    * @see Property::AUTO_SCROLL_STOP_MODE.
375    */
376   struct AutoScrollStopMode
377   {
378     /**
379      * @brief The enumerations used for auto scroll stop mode.
380      * @SINCE_1_2.60
381      * @see Property::AUTO_SCROLL_STOP_MODE.
382      */
383     enum Type
384     {
385       FINISH_LOOP = 0,  ///< Stop animation after current loop finishes. @SINCE_1_2.60
386       IMMEDIATE         ///< Stop animation immediately and reset position. @SINCE_1_2.60
387     };
388   };
389
390   /**
391    * @brief Creates the TextLabel control.
392    *
393    * @SINCE_1_0.0
394    * @return A handle to the TextLabel control
395    */
396   static TextLabel New();
397
398   /**
399    * @brief Creates the TextLabel control.
400    *
401    * @SINCE_1_0.0
402    * @param[in] text The text to display
403    * @return A handle to the TextLabel control
404    */
405   static TextLabel New( const std::string& text );
406
407   /**
408    * @brief Creates an empty handle.
409    * @SINCE_1_0.0
410    */
411   TextLabel();
412
413   /**
414    * @brief Copy constructor.
415    *
416    * @SINCE_1_0.0
417    * @param[in] handle The handle to copy from
418    */
419   TextLabel( const TextLabel& handle );
420
421   /**
422    * @brief Assignment operator.
423    *
424    * @SINCE_1_0.0
425    * @param[in] handle The handle to copy from
426    * @return A reference to this
427    */
428   TextLabel& operator=( const TextLabel& handle );
429
430   /**
431    * @brief Destructor.
432    *
433    * This is non-virtual since derived Handle types must not contain data or virtual methods.
434    * @SINCE_1_0.0
435    */
436   ~TextLabel();
437
438   /**
439    * @brief Downcasts a handle to TextLabel.
440    *
441    * If the BaseHandle points is a TextLabel, the downcast returns a valid handle.
442    * If not, the returned handle is left empty.
443    *
444    * @SINCE_1_0.0
445    * @param[in] handle Handle to an object
446    * @return Handle to a TextLabel or an empty handle
447    */
448   static TextLabel DownCast( BaseHandle handle );
449
450 public: // Not intended for application developers
451
452   /// @cond internal
453   /**
454    * @brief Creates a handle using the Toolkit::Internal implementation.
455    *
456    * @SINCE_1_0.0
457    * @param[in] implementation The Control implementation
458    */
459   DALI_INTERNAL TextLabel( Internal::TextLabel& implementation );
460
461   /**
462    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
463    *
464    * @SINCE_1_0.0
465    * @param[in] internal A pointer to the internal CustomActor
466    */
467   explicit DALI_INTERNAL TextLabel( Dali::Internal::CustomActor* internal );
468   /// @endcond
469 };
470
471 /**
472  * @}
473  */
474 } // namespace Toolkit
475
476 } // namespace Dali
477
478 #endif // __DALI_TOOLKIT_TEXT_LABEL_H__