1 #ifndef DALI_TOOLKIT_TEXT_MARKUPS_AND_ATTRIBUTES_H
2 #define DALI_TOOLKIT_TEXT_MARKUPS_AND_ATTRIBUTES_H
5 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
31 * @brief Use markup styling to style Text-Controller.
32 * The markup tag is opend by <> and closed by </>
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:
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.
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.
49 * @brief Sets the color for the characters inside the element.
51 * The following example explains how to apply it:
54 * textController.Text = "<color value='red'>Hello world</color>";
58 * @see COLOR_ATTRIBUTES
61 static const std::string COLOR("color");
64 * @brief Sets the font values for the characters inside the element.
66 * The following example explains how to apply it:
69 * textController.Text = "<font family='DejaVuSerif' size='18'>Hello world</font>";
73 * @see FONT_ATTRIBUTES
75 static const std::string FONT("font");
78 * @brief Sets Bold decoration for the characters inside the element.
80 * The following example explains how to apply it:
83 * textController.Text = "<b>Hello world</b>";
89 static const std::string BOLD("b");
92 * @brief Sets Italic decoration for the characters inside the element.
94 * The following example explains how to apply it:
97 * textController.Text = "<i>Hello world</i>";
102 static const std::string ITALIC("i");
105 * @brief Sets the underlined values for the characters inside the element.
107 * The following example explains how to apply it:
110 * textController.Text = "<u>Hello world</u>";
114 * @see UNDERLINE_ATTRIBUTES
116 static const std::string UNDERLINE("u");
119 * @todo Sets the shadow for the characters inside the element.
122 static const std::string SHADOW("shadow"); ///< This tag under construction.
125 * @todo Sets the glow for the characters inside the element.
128 static const std::string GLOW("glow"); ///< This tag under construction.
131 * @todo Sets the outline for the characters inside the element.
134 static const std::string OUTLINE("outline"); ///< This tag under construction.
137 * @brief Defines an embedded item within the text.
139 * The following example explains how to apply it:
142 * textController.Text = "<item 'width'=26 'height'=26 'url'='path/image.png' 'color-blending'='multiply'/>";
146 * @see EMBEDDED_ITEM_ATTRIBUTES
148 static const std::string EMBEDDED_ITEM("item");
151 * @brief Defines a hyperlink for the text inside the element.
153 * The following example explains how to apply it:
156 * textController.Text = "<a href='https://www.tizen.org'>TIZEN</a>";
160 * @see ANCHOR_ATTRIBUTES
162 static const std::string ANCHOR("a");
165 * @brief Sets the background color for the characters inside the element.
167 * The following example explains how to apply it:
170 * textController.Text = "<background color='yellow'>Hello world</background>";
174 * @see BACKGROUND_ATTRIBUTES
176 static const std::string BACKGROUND("background");
179 * @brief Use span tag to set many styles on character's level for the characters inside the element.
181 * The following example explains how to apply it:
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>";
188 * @see SPAN_ATTRIBUTES
190 static const std::string SPAN("span");
193 * @brief Sets the strikethrough values for the characters inside the element.
195 * The following example explains how to apply it:
198 * textController.Text = "<s>Hello world</s>";
202 * @see STRIKETHROUGH_ATTRIBUTES
204 static const std::string STRIKETHROUGH("s");
207 * @brief Use paragraph tag to set many styles on paragraph's level for the lines inside the element.
209 * The following example explains how to apply it:
212 * textController.Text = "test before paragraph tag <p>test paragraph tag </p>test after paragraph tag ";
216 * @see PARAGRAPH_ATTRIBUTES
218 static const std::string PARAGRAPH("p");
221 * @brief Sets the character spacing values for the characters inside the element.
223 * The following example explains how to apply it:
226 * textController.Text = "<char-spacing value='3.0f'>Hello world</char-spacing>";
230 * @see CHARACTER_SPACING_ATTRIBUTES
232 static const std::string CHARACTER_SPACING("char-spacing");
235 namespace COLOR_ATTRIBUTES
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.
242 * The following examples show text in red color:
245 * textController.Text = "<color value='red'>Hello world</color>"; /// Color coded with a text constant
251 * textController.Text = "<color value='0xFFFF0000'>Hello world</color>"); /// Color packed inside an ARGB hexadecimal value
255 static const std::string VALUE("value");
256 } // namespace COLOR_ATTRIBUTES
258 namespace FONT_ATTRIBUTES
261 * @brief Use the family attribute to define the font name.
266 * textController.Text = "<font family='SamsungSans' >Hello world</font>";
271 static const std::string FAMILY("family");
274 * @brief Use the size attribute to define the font size in points.
279 * textController.Text = "<font size='50' >Hello world</font>";
284 static const std::string SIZE("size");
287 * @brief Use the weight attribute to define the font weight.
292 * textController.Text = "<font weight='bold' >Hello world</font>";
297 static const std::string WEIGHT("weight");
300 * @brief Use the width attribute to define the font width.
305 * textController.Text = "<font width='condensed' >Hello world</font>";
310 static const std::string WIDTH("width");
313 * @brief Use the slant attribute to define the font slant.
318 * textController.Text = "<font slant='italic' >Hello world</font>";
323 static const std::string SLANT("slant");
324 } // namespace FONT_ATTRIBUTES
326 namespace UNDERLINE_ATTRIBUTES
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.
333 * The following example explains how to apply it:
336 * textController.Text = "<u color='green'>Hello world</u>";
340 static const std::string COLOR("color");
343 * @brief Use the height attribute to define the height of underline.
346 * The following example explains how to apply it:
349 * textController.Text = "<u height='2.0f'>Hello world</u>";
353 static const std::string HEIGHT("height");
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
360 * The following example explains how to apply it:
363 * textController.Text = "<u type='double'>Hello world</u>";
367 static const std::string TYPE("type");
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.
374 * @note If not provided then the default gap is used (1 pixel).
376 * The following example explains how to apply it:
379 * textController.Text = "<u type='dashed' dash-gap='2.0f'>Hello world</u>";
383 static const std::string DASH_GAP("dash-gap");
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.
389 * @note If not provided then the default width is used (2 pixel).
391 * The following example explains how to apply it:
394 * textController.Text = "<u type='dashed' dash-width='3.0f'>Hello world</u>";
398 static const std::string DASH_WIDTH("dash-width");
400 } // namespace UNDERLINE_ATTRIBUTES
402 namespace SPAN_ATTRIBUTES
404 //NOTE: the MAX_NUM_OF_ATTRIBUTES in "markup-processor.cpp" should be updated when add a new attribute for span tag.
407 * @brief The font family attribute.
411 * textController.Text = "<span font-family='SamsungSans' >Hello world</span>";
413 * @see FONT_ATTRIBUTES::FAMILY
415 static const std::string FONT_FAMILY("font-family");
418 * @brief The font size attribute.
422 * textController.Text = "<span font-size='50' >Hello world</span>";
424 * @see FONT_ATTRIBUTES::SIZE
426 static const std::string FONT_SIZE("font-size");
429 * @brief The font weight attribute.
433 * textController.Text = "<span font-weight='bold' >Hello world</span>";
435 * @see FONT_ATTRIBUTES::WEIGHT
437 static const std::string FONT_WEIGHT("font-weight");
440 * @brief The font width attribute.
444 * textController.Text = "<span font-width='condensed' >Hello world</span>";
446 * @see FONT_ATTRIBUTES::WIDTH
448 static const std::string FONT_WIDTH("font-width");
451 * @brief The font slant attribute.
455 * textController.Text = "<span font-slant='italic' >Hello world</span>";
457 * @see FONT_ATTRIBUTES::SLANT
459 static const std::string FONT_SLANT("font-slant");
462 * @brief The color value attribute.
466 * textController.Text = "<span text-color='blue' >Hello world</span>";
468 * @see COLOR_ATTRIBUTES::VALUE
470 static const std::string TEXT_COLOR("text-color");
473 * @brief The background color attribute.
477 * textController.Text = "<span background-color='yellow' >Hello world</span>";
479 * @see BACKGROUND_ATTRIBUTES::COLOR
481 static const std::string BACKGROUND_COLOR("background-color");
484 * @brief The undeline color attribute.
488 * textController.Text = "<span u-color='green' >Hello world</span>";
490 * @see UNDERLINE_ATTRIBUTES::COLOR
492 static const std::string UNDERLINE_COLOR("u-color");
495 * @brief The undeline height attribute.
499 * textController.Text = "<span u-height='3.0f' >Hello world</span>";
501 * @see UNDERLINE_ATTRIBUTES::HEIGHT
503 static const std::string UNDERLINE_HEIGHT("u-height");
506 * @brief The undeline type attribute.
510 * textController.Text = "<span u-type='solid' >Hello world</span>";
512 * @see UNDERLINE_ATTRIBUTES::TYPE
514 static const std::string UNDERLINE_TYPE("u-type");
517 * @brief The undeline dash-gap attribute.
521 * textController.Text = "<span u-type='dashed' u-dash-gap='2.0f' >Hello world</span>";
523 * @see UNDERLINE_ATTRIBUTES::DASH_GAP
525 static const std::string UNDERLINE_DASH_GAP("u-dash-gap");
528 * @brief The undeline dash-width attribute.
532 * textController.Text = "<span u-type='dashed' u-dash-width='4.0f' >Hello world</span>";
534 * @see UNDERLINE_ATTRIBUTES::DASH_WIDTH
536 static const std::string UNDERLINE_DASH_WIDTH("u-dash-width");
539 * @brief The strikethrough color attribute.
543 * textController.Text = "<span s-color='green' >Hello world</span>";
545 * @see STRIKETHROUGH_ATTRIBUTES::COLOR
547 static const std::string STRIKETHROUGH_COLOR("s-color");
550 * @brief The strikethrough height attribute.
554 * textController.Text = "<span s-height='3.0f' >Hello world</span>";
556 * @see STRIKETHROUGH_ATTRIBUTES::HEIGHT
558 static const std::string STRIKETHROUGH_HEIGHT("s-height");
561 * @brief The character-spacing value attribute.
565 * textController.Text = "<span char-space-value='5.0f' >Hello world</span>";
567 * @see CHARACTER_SPACING_ATTRIBUTES::VALUE
569 static const std::string CHARACTER_SPACING_VALUE("char-space-value");
570 } // namespace SPAN_ATTRIBUTES
572 namespace STRIKETHROUGH_ATTRIBUTES
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.
579 * The following example explains how to apply it:
582 * textController.Text = "<s color='green'>Hello world</s>";
586 static const std::string COLOR("color");
589 * @brief Use the height attribute to define the height of strikethrough.
592 * The following example explains how to apply it:
595 * textController.Text = "<s height='2.0f'>Hello world</s>";
599 static const std::string HEIGHT("height");
600 } // namespace STRIKETHROUGH_ATTRIBUTES
602 namespace PARAGRAPH_ATTRIBUTES
605 * @brief Use the align attribute to define the horizontal alignment of paragraph.
606 * The supported attribute values are begin, center and end .
608 * The following example explains how to apply it:
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>";
615 static const std::string ALIGN("align");
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).
621 * The following example explains how to apply it:
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";
627 * @note If the value is less than 1, the lines could to be overlapped.
629 static const std::string RELATIVE_LINE_HEIGHT("rel-line-height");
631 } // namespace PARAGRAPH_ATTRIBUTES
633 namespace CHARACTER_SPACING_ATTRIBUTES
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).
642 * textController.Text = "<char-spacing value='5.0f'>Hello world</char-spacing>"; /// Expanded
648 * textController.Text = "<char-spacing value='-5.0f'>Hello world</char-spacing>"); /// Condensed
652 static const std::string VALUE("value");
653 } // namespace CHARACTER_SPACING_ATTRIBUTES
654 namespace BACKGROUND_ATTRIBUTES
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.
661 * The following example explains how to apply it:
664 * textController.Text = "<background color='green'>Hello world</background>";
668 static const std::string COLOR("color");
670 } // namespace BACKGROUND_ATTRIBUTES
672 namespace EMBEDDED_ITEM_ATTRIBUTES
675 * @brief Use the url attribute to define url path of the image.
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.
681 static const std::string URL("url");
684 * @brief Use the width attribute to define the width of the item.
686 static const std::string WIDTH("width");
689 * @brief Use the height attribute to define the height of the item.
691 static const std::string HEIGHT("height");
694 * @brief Use the color-blending attribute to define whether the color of the image is multiplied by the color of the text.
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.
699 static const std::string COLOR_BLENDING("color-blending");
700 } // namespace EMBEDDED_ITEM_ATTRIBUTES
702 namespace ANCHOR_ATTRIBUTES
705 * @brief Use the href attribute to define the url of hyperlink.
707 static const std::string HREF("href");
709 } // namespace ANCHOR_ATTRIBUTES
711 } // namespace MARKUP
715 } // namespace Toolkit
719 #endif // DALI_TOOLKIT_TEXT_MARKUPS_AND_ATTRIBUTES_H