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