Remove useless iteration when debug mode
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / markup-tags-and-attributes.h
1 #ifndef DALI_TOOLKIT_TEXT_MARKUPS_AND_ATTRIBUTES_H
2 #define DALI_TOOLKIT_TEXT_MARKUPS_AND_ATTRIBUTES_H
3
4 /*
5  * Copyright (c) 2022 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 <string>
23
24 namespace Dali
25 {
26 namespace Toolkit
27 {
28 namespace Text
29 {
30 /**
31  * @brief Use markup styling to style Text-Controller.
32  * The markup tag is opend by <> and closed by </>
33  *
34  * @details You can use markup elements to change the style of the text.
35  * Since the text controls do not process markup elements by default, you must first set the EnableMarkup property of the Text-Controller  to true:
36  *
37  * @note The markup processor does not check for markup validity, and styles are rendered in priority order.
38  * Incorrect or incompatible elements can cause the text to be rendered incorrectly.
39  */
40 namespace MARKUP
41 {
42 namespace TAG
43 {
44 // HTML-ISH tag and attribute constants.
45 // Note they must be lower case in order to make the comparison to work
46 // as the parser converts all the read tags to lower case.
47
48 /**
49  * @brief Sets the color for the characters inside the element.
50  *
51  * The following example explains how to apply it:
52  * @code
53  *
54  * textController.Text = "<color value='red'>Hello world</color>";
55  *
56  * @endcode
57  *
58  * @see COLOR_ATTRIBUTES
59  *
60  */
61 static const std::string COLOR("color");
62
63 /**
64  * @brief Sets the font values for the characters inside the element.
65  *
66  * The following example explains how to apply it:
67  * @code
68  *
69  * textController.Text = "<font family='DejaVuSerif' size='18'>Hello world</font>";
70  *
71  * @endcode
72  *
73  * @see FONT_ATTRIBUTES
74  */
75 static const std::string FONT("font");
76
77 /**
78  * @brief Sets Bold decoration for the characters inside the element.
79  *
80  * The following example explains how to apply it:
81  * @code
82  *
83  * textController.Text = "<b>Hello world</b>";
84  *
85  * @endcode
86  *
87  * @see
88  */
89 static const std::string BOLD("b");
90
91 /**
92  * @brief Sets Italic decoration for the characters inside the element.
93  *
94  * The following example explains how to apply it:
95  * @code
96  *
97  * textController.Text = "<i>Hello world</i>";
98  *
99  * @endcode
100  *
101  */
102 static const std::string ITALIC("i");
103
104 /**
105  * @brief Sets the underlined values for the characters inside the element.
106  *
107  * The following example explains how to apply it:
108  * @code
109  *
110  * textController.Text = "<u>Hello world</u>";
111  *
112  * @endcode
113  *
114  * @see UNDERLINE_ATTRIBUTES
115  */
116 static const std::string UNDERLINE("u");
117
118 /**
119  * @todo Sets the shadow for the characters inside the element.
120  *
121  */
122 static const std::string SHADOW("shadow"); ///< This tag under construction.
123
124 /**
125  * @todo Sets the glow for the characters inside the element.
126  *
127  */
128 static const std::string GLOW("glow"); ///< This tag under construction.
129
130 /**
131  * @todo Sets the outline for the characters inside the element.
132  *
133  */
134 static const std::string OUTLINE("outline"); ///< This tag under construction.
135
136 /**
137  * @brief Defines an embedded item within the text.
138  *
139  * The following example explains how to apply it:
140  * @code
141  *
142  * textController.Text = "<item 'width'=26 'height'=26 'url'='path/image.png' 'color-blending'='multiply'/>";
143  *
144  * @endcode
145  *
146  * @see EMBEDDED_ITEM_ATTRIBUTES
147  */
148 static const std::string EMBEDDED_ITEM("item");
149
150 /**
151  * @brief Defines a hyperlink for the text inside the element.
152  *
153  * The following example explains how to apply it:
154  * @code
155  *
156  * textController.Text = "<a href='https://www.tizen.org'>TIZEN</a>";
157  *
158  * @endcode
159  *
160  * @see ANCHOR_ATTRIBUTES
161  */
162 static const std::string ANCHOR("a");
163
164 /**
165  * @brief Sets the background color for the characters inside the element.
166  *
167  * The following example explains how to apply it:
168  * @code
169  *
170  * textController.Text = "<background color='yellow'>Hello world</background>";
171  *
172  * @endcode
173  *
174  * @see BACKGROUND_ATTRIBUTES
175  */
176 static const std::string BACKGROUND("background");
177
178 /**
179  * @brief Use span tag to set many styles on character's level for the characters inside the element.
180  *
181  * The following example explains how to apply it:
182  * @code
183  *
184  * textController.Text = "<span font-size='20' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='green' char-space-value='10.0f'>Hello world</span>";
185  *
186  * @endcode
187  *
188  * @see SPAN_ATTRIBUTES
189  */
190 static const std::string SPAN("span");
191
192 /**
193  * @brief Sets the strikethrough values for the characters inside the element.
194  *
195  * The following example explains how to apply it:
196  * @code
197  *
198  * textController.Text = "<s>Hello world</s>";
199  *
200  * @endcode
201  *
202  * @see STRIKETHROUGH_ATTRIBUTES
203  */
204 static const std::string STRIKETHROUGH("s");
205
206 /**
207  * @brief Use paragraph tag to set many styles on paragraph's level for the lines inside the element.
208  *
209  * The following example explains how to apply it:
210  * @code
211  *
212  * textController.Text = "test before paragraph tag <p>test paragraph tag </p>test after paragraph tag ";
213  *
214  * @endcode
215  *
216  * @see PARAGRAPH_ATTRIBUTES
217  */
218 static const std::string PARAGRAPH("p");
219
220 /**
221  * @brief Sets the character spacing values for the characters inside the element.
222  *
223  * The following example explains how to apply it:
224  * @code
225  *
226  * textController.Text = "<char-spacing value='3.0f'>Hello world</char-spacing>";
227  *
228  * @endcode
229  *
230  * @see CHARACTER_SPACING_ATTRIBUTES
231  */
232 static const std::string CHARACTER_SPACING("char-spacing");
233 } // namespace TAG
234
235 namespace COLOR_ATTRIBUTES
236 {
237 /**
238  * @brief Use the value attribute to define the color.
239  * The supported attribute values are red, green, blue, yellow, magenta, cyan, white, black, and transparent.
240  * Web colors and colors represented in 32-bit hexadecimal 0xAARRGGBB format are also supported.
241  *
242  * The following examples show text in red color:
243  * @code
244  *
245  * textController.Text = "<color value='red'>Hello world</color>"; /// Color coded with a text constant
246  *
247  * @endcode
248  *
249  * @code
250  *
251  * textController.Text = "<color value='0xFFFF0000'>Hello world</color>"); /// Color packed inside an ARGB hexadecimal value
252  *
253  * @endcode
254  */
255 static const std::string VALUE("value");
256 } // namespace COLOR_ATTRIBUTES
257
258 namespace FONT_ATTRIBUTES
259 {
260 /**
261  * @brief Use the family attribute to define the font name.
262  *
263  * Example:
264  * @code
265  *
266  * textController.Text = "<font family='SamsungSans' >Hello world</font>";
267  *
268  * @endcode
269  *
270  */
271 static const std::string FAMILY("family");
272
273 /**
274  * @brief Use the size attribute to define the font size in points.
275  *
276  * Example:
277  * @code
278  *
279  * textController.Text = "<font size='50' >Hello world</font>";
280  *
281  * @endcode
282  *
283  */
284 static const std::string SIZE("size");
285
286 /**
287  * @brief Use the weight attribute to define the font weight.
288  *
289  * Example:
290  * @code
291  *
292  * textController.Text = "<font weight='bold' >Hello world</font>";
293  *
294  * @endcode
295  *
296  */
297 static const std::string WEIGHT("weight");
298
299 /**
300  * @brief Use the width attribute to define the font width.
301  *
302  * Example:
303  * @code
304  *
305  * textController.Text = "<font width='condensed' >Hello world</font>";
306  *
307  * @endcode
308  *
309  */
310 static const std::string WIDTH("width");
311
312 /**
313  * @brief Use the slant attribute to define the font slant.
314  *
315  * Example:
316  * @code
317  *
318  * textController.Text = "<font slant='italic' >Hello world</font>";
319  *
320  * @endcode
321  *
322  */
323 static const std::string SLANT("slant");
324 } // namespace FONT_ATTRIBUTES
325
326 namespace UNDERLINE_ATTRIBUTES
327 {
328 /**
329  * @brief Use the color attribute to define the color of underline.
330  * The supported attribute values are red, green, blue, yellow, magenta, cyan, white, black, and transparent.
331  * Web colors and colors represented in 32-bit hexadecimal 0xAARRGGBB format are also supported.
332  *
333  * The following example explains how to apply it:
334  * @code
335  *
336  * textController.Text = "<u color='green'>Hello world</u>";
337  *
338  * @endcode
339  */
340 static const std::string COLOR("color");
341
342 /**
343  * @brief Use the height attribute to define the height of underline.
344  * It is float value.
345  *
346  * The following example explains how to apply it:
347  * @code
348  *
349  * textController.Text = "<u height='2.0f'>Hello world</u>";
350  *
351  * @endcode
352  */
353 static const std::string HEIGHT("height");
354
355 /**
356  * @brief Use the type attribute to define the type of underline.
357  * The supported attribute values are solid, dashed and double
358  * The default value is solid
359  *
360  * The following example explains how to apply it:
361  * @code
362  *
363  * textController.Text = "<u type='double'>Hello world</u>";
364  *
365  * @endcode
366  */
367 static const std::string TYPE("type");
368
369 /**
370  * @brief Use the dash-gap attribute to define the dash-gap of underline.
371  * The gap in pixels between the dashes of the dashed underline. Only valid when "DASHED" underline type is used.
372  *
373  * It is float value.
374  * @note If not provided then the default gap is used (1 pixel).
375  *
376  * The following example explains how to apply it:
377  * @code
378  *
379  * textController.Text = "<u type='dashed' dash-gap='2.0f'>Hello world</u>";
380  *
381  * @endcode
382  */
383 static const std::string DASH_GAP("dash-gap");
384
385 /**
386  * @brief Use the dash-width attribute to define the dash-width of underline.
387  * The width in pixels of the dashes of the dashed underline. Only valid when "DASHED" underline type is used.
388  * It is float value.
389  * @note If not provided then the default width is used (2 pixel).
390  *
391  * The following example explains how to apply it:
392  * @code
393  *
394  * textController.Text = "<u type='dashed' dash-width='3.0f'>Hello world</u>";
395  *
396  * @endcode
397  */
398 static const std::string DASH_WIDTH("dash-width");
399
400 } // namespace UNDERLINE_ATTRIBUTES
401
402 namespace SPAN_ATTRIBUTES
403 {
404 //NOTE: the MAX_NUM_OF_ATTRIBUTES in "markup-processor.cpp" should be updated when add a new attribute for span tag.
405
406 /**
407  * @brief The font family attribute.
408  *
409  * Example:
410  * @code
411  * textController.Text = "<span font-family='SamsungSans' >Hello world</span>";
412  * @endcode
413  * @see FONT_ATTRIBUTES::FAMILY
414  */
415 static const std::string FONT_FAMILY("font-family");
416
417 /**
418  * @brief The font size attribute.
419  *
420  * Example:
421  * @code
422  * textController.Text = "<span font-size='50' >Hello world</span>";
423  * @endcode
424  * @see FONT_ATTRIBUTES::SIZE
425  */
426 static const std::string FONT_SIZE("font-size");
427
428 /**
429  * @brief The font weight attribute.
430  *
431  * Example:
432  * @code
433  * textController.Text = "<span font-weight='bold' >Hello world</span>";
434  * @endcode
435  * @see FONT_ATTRIBUTES::WEIGHT
436  */
437 static const std::string FONT_WEIGHT("font-weight");
438
439 /**
440  * @brief The font width attribute.
441  *
442  * Example:
443  * @code
444  * textController.Text = "<span font-width='condensed' >Hello world</span>";
445  * @endcode
446  * @see FONT_ATTRIBUTES::WIDTH
447  */
448 static const std::string FONT_WIDTH("font-width");
449
450 /**
451  * @brief The font slant attribute.
452  *
453  * Example:
454  * @code
455  * textController.Text = "<span font-slant='italic' >Hello world</span>";
456  * @endcode
457  * @see FONT_ATTRIBUTES::SLANT
458  */
459 static const std::string FONT_SLANT("font-slant");
460
461 /**
462  * @brief The color value attribute.
463  *
464  * Example:
465  * @code
466  * textController.Text = "<span text-color='blue' >Hello world</span>";
467  * @endcode
468  * @see COLOR_ATTRIBUTES::VALUE
469  */
470 static const std::string TEXT_COLOR("text-color");
471
472 /**
473  * @brief The background color attribute.
474  *
475  * Example:
476  * @code
477  * textController.Text = "<span background-color='yellow' >Hello world</span>";
478  * @endcode
479  * @see BACKGROUND_ATTRIBUTES::COLOR
480  */
481 static const std::string BACKGROUND_COLOR("background-color");
482
483 /**
484  * @brief The undeline color attribute.
485  *
486  * Example:
487  * @code
488  * textController.Text = "<span u-color='green' >Hello world</span>";
489  * @endcode
490  * @see UNDERLINE_ATTRIBUTES::COLOR
491  */
492 static const std::string UNDERLINE_COLOR("u-color");
493
494 /**
495  * @brief The undeline height attribute.
496  *
497  * Example:
498  * @code
499  * textController.Text = "<span u-height='3.0f' >Hello world</span>";
500  * @endcode
501  * @see UNDERLINE_ATTRIBUTES::HEIGHT
502  */
503 static const std::string UNDERLINE_HEIGHT("u-height");
504
505 /**
506  * @brief The undeline type attribute.
507  *
508  * Example:
509  * @code
510  * textController.Text = "<span u-type='solid' >Hello world</span>";
511  * @endcode
512  * @see UNDERLINE_ATTRIBUTES::TYPE
513  */
514 static const std::string UNDERLINE_TYPE("u-type");
515
516 /**
517  * @brief The undeline dash-gap attribute.
518  *
519  * Example:
520  * @code
521  * textController.Text = "<span u-type='dashed' u-dash-gap='2.0f' >Hello world</span>";
522  * @endcode
523  * @see UNDERLINE_ATTRIBUTES::DASH_GAP
524  */
525 static const std::string UNDERLINE_DASH_GAP("u-dash-gap");
526
527 /**
528  * @brief The undeline dash-width attribute.
529  *
530  * Example:
531  * @code
532  * textController.Text = "<span u-type='dashed' u-dash-width='4.0f' >Hello world</span>";
533  * @endcode
534  * @see UNDERLINE_ATTRIBUTES::DASH_WIDTH
535  */
536 static const std::string UNDERLINE_DASH_WIDTH("u-dash-width");
537
538 /**
539  * @brief The strikethrough color attribute.
540  *
541  * Example:
542  * @code
543  * textController.Text = "<span s-color='green' >Hello world</span>";
544  * @endcode
545  * @see STRIKETHROUGH_ATTRIBUTES::COLOR
546  */
547 static const std::string STRIKETHROUGH_COLOR("s-color");
548
549 /**
550  * @brief The strikethrough height attribute.
551  *
552  * Example:
553  * @code
554  * textController.Text = "<span s-height='3.0f' >Hello world</span>";
555  * @endcode
556  * @see STRIKETHROUGH_ATTRIBUTES::HEIGHT
557  */
558 static const std::string STRIKETHROUGH_HEIGHT("s-height");
559
560 /**
561  * @brief The character-spacing value attribute.
562  *
563  * Example:
564  * @code
565  * textController.Text = "<span char-space-value='5.0f' >Hello world</span>";
566  * @endcode
567  * @see CHARACTER_SPACING_ATTRIBUTES::VALUE
568  */
569 static const std::string CHARACTER_SPACING_VALUE("char-space-value");
570 } // namespace SPAN_ATTRIBUTES
571
572 namespace STRIKETHROUGH_ATTRIBUTES
573 {
574 /**
575  * @brief Use the color attribute to define the color of strikethrough.
576  * The supported attribute values are red, green, blue, yellow, magenta, cyan, white, black, and transparent.
577  * Web colors and colors represented in 32-bit hexadecimal 0xAARRGGBB format are also supported.
578  *
579  * The following example explains how to apply it:
580  * @code
581  *
582  * textController.Text = "<s color='green'>Hello world</s>";
583  *
584  * @endcode
585  */
586 static const std::string COLOR("color");
587
588 /**
589  * @brief Use the height attribute to define the height of strikethrough.
590  * It is float value.
591  *
592  * The following example explains how to apply it:
593  * @code
594  *
595  * textController.Text = "<s height='2.0f'>Hello world</s>";
596  *
597  * @endcode
598  */
599 static const std::string HEIGHT("height");
600 } // namespace STRIKETHROUGH_ATTRIBUTES
601
602 namespace PARAGRAPH_ATTRIBUTES
603 {
604 /**
605  * @brief Use the align attribute to define the horizontal alignment of paragraph.
606  * The supported attribute values are begin, center and end .
607  *
608  * The following example explains how to apply it:
609  * @code
610  *
611  * textController.Text = ""text outside<p align='end'>Paragraph end</p>text outside<p align='center'>Paragraph center</p>text outside<p align='begin' >Paragraph begin</p>";
612  *
613  * @endcode
614  */
615 static const std::string ALIGN("align");
616
617 /**
618  * @brief Use the rrel-line-height attribute to define the relative height of the line (a factor that will be multiplied by text height).
619  * It is float value.
620  *
621  * The following example explains how to apply it:
622  * @code
623  *
624  * textController.Text = "<p>line 1</p><p rel-line-height=0.5>line\n2</p>line 3<p rel-line-height=3>line\n4</p>line 5";
625  *
626  * @endcode
627  * @note If the value is less than 1, the lines could to be overlapped.
628  */
629 static const std::string RELATIVE_LINE_HEIGHT("rel-line-height");
630
631 } // namespace PARAGRAPH_ATTRIBUTES
632
633 namespace CHARACTER_SPACING_ATTRIBUTES
634 {
635 /**
636  * @brief Use the value attribute to define the spaces between characters in Pixels.
637  *  A positive value will make the characters far apart (expanded) and a negative value will bring them closer (condensed).
638  *
639  * Examples:
640  * @code
641  *
642  * textController.Text = "<char-spacing value='5.0f'>Hello world</char-spacing>"; /// Expanded
643  *
644  * @endcode
645  *
646  * @code
647  *
648  * textController.Text = "<char-spacing value='-5.0f'>Hello world</char-spacing>"); /// Condensed
649  *
650  * @endcode
651  */
652 static const std::string VALUE("value");
653 } // namespace CHARACTER_SPACING_ATTRIBUTES
654 namespace BACKGROUND_ATTRIBUTES
655 {
656 /**
657  * @brief Use the value attribute to define the color of background.
658  * The supported attribute values are red, green, blue, yellow, magenta, cyan, white, black, and transparent.
659  * Web colors and colors represented in 32-bit hexadecimal 0xAARRGGBB format are also supported.
660  *
661  * The following example explains how to apply it:
662  * @code
663  *
664  * textController.Text = "<background color='green'>Hello world</background>";
665  *
666  * @endcode
667  */
668 static const std::string COLOR("color");
669
670 } // namespace BACKGROUND_ATTRIBUTES
671
672 namespace EMBEDDED_ITEM_ATTRIBUTES
673 {
674 /**
675  * @brief Use the url attribute to define url path of the image.
676  *
677  * @note  The url of the image is optional. If there is no image
678  * the layout engine will use the width and height to
679  * create a space inside the text. This gap can be filled later.
680  */
681 static const std::string URL("url");
682
683 /**
684  * @brief Use the width attribute to define the width of the item.
685  */
686 static const std::string WIDTH("width");
687
688 /**
689  * @brief Use the height attribute to define the height of the item.
690  */
691 static const std::string HEIGHT("height");
692
693 /**
694  * @brief Use the color-blending attribute to define whether the color of the image is multiplied by the color of the text.
695  *
696  * @note A color blending mode can be set. The default is NONE, the image will use its own color. If MULTIPLY is set, the color
697  * of the image will be multiplied by the color of the text.
698  */
699 static const std::string COLOR_BLENDING("color-blending");
700 } // namespace EMBEDDED_ITEM_ATTRIBUTES
701
702 namespace ANCHOR_ATTRIBUTES
703 {
704 /**
705  * @brief Use the href attribute to define the url of hyperlink.
706  */
707 static const std::string HREF("href");
708
709 } // namespace ANCHOR_ATTRIBUTES
710
711 } // namespace MARKUP
712
713 } // namespace Text
714
715 } // namespace Toolkit
716
717 } // namespace Dali
718
719 #endif // DALI_TOOLKIT_TEXT_MARKUPS_AND_ATTRIBUTES_H