2 * Copyright(c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 extern alias TizenSystemSettings;
19 using TizenSystemSettings.Tizen.System;
22 using System.Globalization;
23 using System.ComponentModel;
26 namespace Tizen.NUI.BaseComponents
29 /// A control which renders a short text string.<br />
30 /// Text labels are lightweight, non-editable, and do not respond to the user input.<br />
32 /// <since_tizen> 3 </since_tizen>
33 public partial class TextLabel : View
35 private class TextLayout : LayoutItem
37 protected override void OnMeasure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
39 // Padding will be automatically applied by DALi TextLabel.
40 float totalWidth = widthMeasureSpec.Size.AsDecimal();
41 float totalHeight = heightMeasureSpec.Size.AsDecimal();
43 if (widthMeasureSpec.Mode == MeasureSpecification.ModeType.Exactly)
45 if (heightMeasureSpec.Mode != MeasureSpecification.ModeType.Exactly)
47 totalHeight = Owner.GetHeightForWidth(totalWidth);
48 heightMeasureSpec = new MeasureSpecification(new LayoutLength(totalHeight), MeasureSpecification.ModeType.Exactly);
53 var minSize = Owner.MinimumSize;
54 var maxSize = Owner.MaximumSize;
55 var naturalSize = Owner.GetNaturalSize();
57 if (heightMeasureSpec.Mode == MeasureSpecification.ModeType.Exactly)
59 // GetWidthForHeight is not implemented.
60 totalWidth = Math.Min(Math.Max(naturalSize.Width, minSize.Width), (maxSize.Width < 0 ? Int32.MaxValue : maxSize.Width));
61 widthMeasureSpec = new MeasureSpecification(new LayoutLength(totalWidth), MeasureSpecification.ModeType.Exactly);
65 totalWidth = Math.Min(Math.Max(naturalSize.Width, minSize.Width), (maxSize.Width < 0 ? Int32.MaxValue : maxSize.Width));
66 totalHeight = Math.Min(Math.Max(naturalSize.Height, minSize.Height), (maxSize.Height < 0 ? Int32.MaxValue : maxSize.Height));
68 heightMeasureSpec = new MeasureSpecification(new LayoutLength(totalHeight), MeasureSpecification.ModeType.Exactly);
69 widthMeasureSpec = new MeasureSpecification(new LayoutLength(totalWidth), MeasureSpecification.ModeType.Exactly);
73 MeasuredSize.StateType childWidthState = MeasuredSize.StateType.MeasuredSizeOK;
74 MeasuredSize.StateType childHeightState = MeasuredSize.StateType.MeasuredSizeOK;
76 SetMeasuredDimensions(ResolveSizeAndState(new LayoutLength(totalWidth), widthMeasureSpec, childWidthState),
77 ResolveSizeAndState(new LayoutLength(totalHeight), heightMeasureSpec, childHeightState));
81 static TextLabel() { }
83 private string textLabelSid = null;
84 private bool systemlangTextFlag = false;
85 private TextLabelSelectorData selectorData;
86 private float fontSizeScale = 1.0f;
87 private bool hasFontSizeChangedCallback = false;
90 /// Creates the TextLabel control.
92 /// <since_tizen> 3 </since_tizen>
93 public TextLabel() : this(Interop.TextLabel.New(), true)
95 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
98 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
99 [EditorBrowsable(EditorBrowsableState.Never)]
100 public TextLabel(TextLabelStyle viewStyle) : this(Interop.TextLabel.New(), true, viewStyle)
105 /// Creates the TextLabel with setting the status of shown or hidden.
107 /// <param name="shown">false : Not displayed (hidden), true : displayed (shown)</param>
108 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
109 [EditorBrowsable(EditorBrowsableState.Never)]
110 public TextLabel(bool shown) : this(Interop.TextLabel.New(), true)
112 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
117 /// Creates the TextLabel control.
119 /// <param name="text">The text to display</param>
120 /// <since_tizen> 3 </since_tizen>
121 public TextLabel(string text) : this(Interop.TextLabel.New(text), true)
123 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
127 /// Creates the TextLabel with setting the status of shown or hidden.
129 /// <param name="text">The text to display</param>
130 /// <param name="shown">false : Not displayed (hidden), true : displayed (shown)</param>
131 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
132 [EditorBrowsable(EditorBrowsableState.Never)]
133 public TextLabel(string text, bool shown) : this(Interop.TextLabel.New(text), true)
135 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
139 internal TextLabel(TextLabel handle, bool shown = true) : this(Interop.TextLabel.NewTextLabel(TextLabel.getCPtr(handle)), true)
141 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
149 internal TextLabel(global::System.IntPtr cPtr, bool cMemoryOwn, ViewStyle viewStyle, bool shown = true) : base(cPtr, cMemoryOwn, viewStyle)
157 internal TextLabel(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true) : base(cPtr, cMemoryOwn, null)
166 /// Create internal layout of TextLabel
168 internal LayoutItem CreateTextLayout()
170 return new TextLayout();
174 /// The TranslatableText property.<br />
175 /// The text can set the SID value.<br />
177 /// <exception cref='ArgumentNullException'>
178 /// ResourceManager about multilingual is null.
180 /// <since_tizen> 4 </since_tizen>
181 public string TranslatableText
185 return (string)GetValue(TranslatableTextProperty);
189 SetValue(TranslatableTextProperty, value);
192 private string translatableText
200 if (NUIApplication.MultilingualResourceManager == null)
202 throw new ArgumentNullException(null, "ResourceManager about multilingual is null");
204 string translatableText = null;
205 textLabelSid = value;
206 translatableText = NUIApplication.MultilingualResourceManager?.GetString(textLabelSid, new CultureInfo(SystemSettings.LocaleLanguage.Replace("_", "-")));
207 if (translatableText != null)
209 Text = translatableText;
210 if (systemlangTextFlag == false)
212 SystemSettings.LocaleLanguageChanged += SystemSettings_LocaleLanguageChanged;
213 systemlangTextFlag = true;
220 NotifyPropertyChanged();
225 /// The Text property.<br />
226 /// The text to display in the UTF-8 format.<br />
228 /// <since_tizen> 3 </since_tizen>
233 return (string)GetValue(TextProperty);
237 SetValue(TextProperty, value);
238 NotifyPropertyChanged();
243 /// The FontFamily property.<br />
244 /// The requested font family to use.<br />
246 /// <since_tizen> 3 </since_tizen>
247 public string FontFamily
251 return (string)GetValue(FontFamilyProperty);
255 SetValue(FontFamilyProperty, value);
256 NotifyPropertyChanged();
261 /// The FontStyle property.<br />
262 /// The requested font style to use.<br />
263 /// The fontStyle map contains the following keys :<br />
264 /// <list type="table">
265 /// <item><term>width (string)</term><description>The width key defines occupied by each glyph. (values: ultraCondensed, extraCondensed, condensed, semiCondensed, normal, semiExpanded, expanded, extraExpanded, ultraExpanded)</description></item>
266 /// <item><term>weight (string)</term><description>The weight key defines the thickness or darkness of the glyphs. (values: thin, ultraLight, extraLight, light, demiLight, semiLight, book, normal, regular, medium, demiBold, semiBold, bold, ultraBold, extraBold, black, heavy, extraBlack)</description></item>
267 /// <item><term>slant (string)</term><description>The slant key defines whether to use italics. (values: normal, roman, italic, oblique)</description></item>
270 /// <since_tizen> 3 </since_tizen>
271 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1721: Property names should not match get methods")]
272 public PropertyMap FontStyle
276 return (PropertyMap)GetValue(FontStyleProperty);
280 SetValue(FontStyleProperty, value);
281 NotifyPropertyChanged();
286 /// Set FontStyle to TextLabel. <br />
288 /// <param name="fontStyle">The FontStyle</param>
290 /// SetFontStyle specifies the requested font style through <see cref="Tizen.NUI.Text.FontStyle"/>. <br />
293 /// The following example demonstrates how to use the SetFontStyle method.
295 /// var fontStyle = new Tizen.NUI.Text.FontStyle();
296 /// fontStyle.Width = FontWidthType.Expanded;
297 /// fontStyle.Weight = FontWeightType.Bold;
298 /// fontStyle.Slant = FontSlantType.Italic;
299 /// label.SetFontStyle(fontStyle);
302 [EditorBrowsable(EditorBrowsableState.Never)]
303 public void SetFontStyle(FontStyle fontStyle)
305 SetProperty(TextLabel.Property.FontStyle, new PropertyValue(TextUtils.GetFontStyleMap(fontStyle)));
309 /// Get FontStyle from TextLabel. <br />
311 /// <returns>The FontStyle</returns>
313 /// <see cref="Tizen.NUI.Text.FontStyle"/>
315 [EditorBrowsable(EditorBrowsableState.Never)]
316 public FontStyle GetFontStyle()
318 var map = new PropertyMap();
319 GetProperty(TextLabel.Property.FontStyle).Get(map);
320 return TextUtils.GetFontStyleStruct(map);
324 /// The PointSize property.<br />
325 /// The size of font in points.<br />
327 /// <since_tizen> 3 </since_tizen>
328 public float PointSize
332 return (float)GetValue(PointSizeProperty);
336 SetValue(PointSizeProperty, value);
337 NotifyPropertyChanged();
342 /// The MultiLine property.<br />
343 /// The single-line or multi-line layout option.<br />
345 /// <since_tizen> 3 </since_tizen>
346 public bool MultiLine
350 return (bool)GetValue(MultiLineProperty);
354 SetValue(MultiLineProperty, value);
355 NotifyPropertyChanged();
360 /// The HorizontalAlignment property.<br />
361 /// The line horizontal alignment.<br />
363 /// <since_tizen> 3 </since_tizen>
364 public HorizontalAlignment HorizontalAlignment
368 return (HorizontalAlignment)GetValue(HorizontalAlignmentProperty);
372 SetValue(HorizontalAlignmentProperty, value);
373 NotifyPropertyChanged();
378 /// The VerticalAlignment property.<br />
379 /// The line vertical alignment.<br />
381 /// <since_tizen> 3 </since_tizen>
382 public VerticalAlignment VerticalAlignment
386 return (VerticalAlignment)GetValue(VerticalAlignmentProperty);
390 SetValue(VerticalAlignmentProperty, value);
391 NotifyPropertyChanged();
396 /// The TextColor property.<br />
397 /// The color of the text.<br />
398 /// Animation framework can be used to change the color of the text when not using mark up.<br />
399 /// Cannot animate the color when text is auto scrolling.<br />
402 /// The property cascade chaining set is possible. For example, this (textLabel.TextColor.X = 0.1f;) is possible.
404 /// <since_tizen> 3 </since_tizen>
405 public Color TextColor
409 Color temp = (Color)GetValue(TextColorProperty);
410 return new Color(OnTextColorChanged, temp.R, temp.G, temp.B, temp.A);
414 SetValue(TextColorProperty, value);
415 NotifyPropertyChanged();
420 /// The ShadowOffset property.<br />
421 /// The drop shadow offset 0 indicates no shadow.<br />
423 /// <since_tizen> 3 </since_tizen>
425 /// Deprecated.(API Level 6) Use Shadow instead.
426 /// The property cascade chaining set is possible. For example, this (textLabel.ShadowOffset.X = 0.1f;) is possible.
428 [Obsolete("Please do not use this ShadowOffset(Deprecated). Please use Shadow instead.")]
429 public Vector2 ShadowOffset
433 Vector2 shadowOffset = new Vector2();
434 Shadow.Find(TextLabel.Property.SHADOW, "offset")?.Get(shadowOffset);
435 return new Vector2(OnShadowOffsetChanged, shadowOffset.X, shadowOffset.Y);
439 PropertyMap temp = new PropertyMap();
440 temp.Insert("offset", new PropertyValue(value));
442 PropertyMap shadowMap = Shadow;
443 shadowMap.Merge(temp);
445 SetValue(ShadowProperty, shadowMap);
446 NotifyPropertyChanged();
451 /// The ShadowColor property.<br />
452 /// The color of a drop shadow.<br />
454 /// <since_tizen> 3 </since_tizen>
456 /// Deprecated.(API Level 6) Use Shadow instead.
457 /// The property cascade chaining set is possible. For example, this (textLabel.ShadowColor.X = 0.1f;) is possible.
459 [Obsolete("Please do not use this ShadowColor(Deprecated). Please use Shadow instead.")]
460 public Vector4 ShadowColor
464 Vector4 shadowColor = new Vector4();
465 Shadow.Find(TextLabel.Property.SHADOW, "color")?.Get(shadowColor);
466 return new Vector4(OnShadowColorChanged, shadowColor.X, shadowColor.Y, shadowColor.Z, shadowColor.W);
470 PropertyMap temp = new PropertyMap();
471 temp.Insert("color", new PropertyValue(value));
473 PropertyMap shadowMap = Shadow;
474 shadowMap.Merge(temp);
476 SetValue(ShadowProperty, shadowMap);
477 NotifyPropertyChanged();
482 /// The UnderlineEnabled property.<br />
483 /// The underline enabled flag.<br />
485 /// <since_tizen> 3 </since_tizen>
487 /// Deprecated.(API Level 6) Use Underline instead.
489 [Obsolete("Please do not use this UnderlineEnabled(Deprecated). Please use Underline instead.")]
490 public bool UnderlineEnabled
494 bool underlineEnabled = false;
495 Underline.Find(TextLabel.Property.UNDERLINE, "enable")?.Get(out underlineEnabled);
496 return underlineEnabled;
500 PropertyMap temp = new PropertyMap();
501 temp.Add("enable", new PropertyValue(value));
503 PropertyMap undelineMap = Underline;
504 undelineMap.Merge(temp);
506 SetValue(UnderlineProperty, undelineMap);
507 NotifyPropertyChanged();
513 /// The UnderlineColor property.<br />
514 /// Overrides the underline height from font metrics.<br />
516 /// <since_tizen> 3 </since_tizen>
518 /// Deprecated.(API Level 6) Use Underline instead.
519 /// The property cascade chaining set is possible. For example, this (textLabel.UnderlineColor.X = 0.1f;) is possible.
521 [Obsolete("Please do not use this UnderlineColor(Deprecated). Please use Underline instead.")]
522 public Vector4 UnderlineColor
526 Vector4 underlineColor = new Vector4();
527 Underline.Find(TextLabel.Property.UNDERLINE, "color")?.Get(underlineColor);
528 return new Vector4(OnUnderlineColorChanged, underlineColor.X, underlineColor.Y, underlineColor.Z, underlineColor.W);
532 PropertyMap temp = new PropertyMap();
533 temp.Insert("color", new PropertyValue(value));
535 PropertyMap undelineMap = Underline;
536 undelineMap.Merge(temp);
538 SetValue(UnderlineProperty, undelineMap);
539 NotifyPropertyChanged();
544 /// The UnderlineHeight property.<br />
545 /// Overrides the underline height from font metrics.<br />
547 /// <since_tizen> 3 </since_tizen>
549 /// Deprecated.(API Level 6) Use Underline instead.
551 [Obsolete("Please do not use this UnderlineHeight(Deprecated). Please use Underline instead.")]
552 public float UnderlineHeight
556 float underlineHeight = 0.0f;
557 Underline.Find(TextLabel.Property.UNDERLINE, "height")?.Get(out underlineHeight);
558 return underlineHeight;
562 PropertyMap temp = new PropertyMap();
563 temp.Insert("height", new PropertyValue(value));
565 PropertyMap undelineMap = Underline;
566 undelineMap.Merge(temp);
568 SetValue(UnderlineProperty, undelineMap);
569 NotifyPropertyChanged();
574 /// The EnableMarkup property.<br />
575 /// Whether the mark-up processing is enabled.<br />
577 /// <since_tizen> 3 </since_tizen>
578 public bool EnableMarkup
582 return (bool)GetValue(EnableMarkupProperty);
586 SetValue(EnableMarkupProperty, value);
587 NotifyPropertyChanged();
592 /// The EnableAutoScroll property.<br />
593 /// Starts or stops auto scrolling.<br />
595 /// <since_tizen> 3 </since_tizen>
596 public bool EnableAutoScroll
600 return (bool)GetValue(EnableAutoScrollProperty);
604 SetValue(EnableAutoScrollProperty, value);
605 NotifyPropertyChanged();
610 /// The AutoScrollSpeed property.<br />
611 /// Sets the speed of scrolling in pixels per second.<br />
613 /// <since_tizen> 3 </since_tizen>
614 public int AutoScrollSpeed
618 return (int)GetValue(AutoScrollSpeedProperty);
622 SetValue(AutoScrollSpeedProperty, value);
623 NotifyPropertyChanged();
628 /// The AutoScrollLoopCount property.<br />
629 /// Number of complete loops when scrolling enabled.<br />
631 /// <since_tizen> 3 </since_tizen>
632 public int AutoScrollLoopCount
636 return (int)GetValue(AutoScrollLoopCountProperty);
640 SetValue(AutoScrollLoopCountProperty, value);
641 NotifyPropertyChanged();
646 /// The AutoScrollGap property.<br />
647 /// Gap before scrolling wraps.<br />
649 /// <since_tizen> 3 </since_tizen>
650 public float AutoScrollGap
654 return (float)GetValue(AutoScrollGapProperty);
658 SetValue(AutoScrollGapProperty, value);
659 NotifyPropertyChanged();
664 /// The LineSpacing property.<br />
665 /// The default extra space between lines in points.<br />
667 /// <since_tizen> 3 </since_tizen>
668 public float LineSpacing
672 return (float)GetValue(LineSpacingProperty);
676 SetValue(LineSpacingProperty, value);
677 NotifyPropertyChanged();
682 /// The Underline property.<br />
683 /// The default underline parameters.<br />
684 /// The underline map contains the following keys :<br />
685 /// <list type="table">
686 /// <item><term>enable (bool)</term><description>Whether the underline is enabled (the default value is false)</description></item>
687 /// <item><term>color (Color)</term><description>The color of the underline (If not provided then the color of the text is used)</description></item>
688 /// <item><term>height (float)</term><description>The height in pixels of the underline (the default value is 1.f)</description></item>
691 /// <since_tizen> 3 </since_tizen>
692 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1721: Property names should not match get methods")]
693 public PropertyMap Underline
697 return (PropertyMap)GetValue(UnderlineProperty);
701 SetValue(UnderlineProperty, value);
702 NotifyPropertyChanged();
707 /// Set Underline to TextLabel. <br />
709 /// <param name="underline">The Underline</param>
711 /// SetUnderline specifies the underline of the text through <see cref="Tizen.NUI.Text.Underline"/>. <br />
714 /// The following example demonstrates how to use the SetUnderline method.
716 /// var underline = new Tizen.NUI.Text.Underline();
717 /// underline.Enable = true;
718 /// underline.Color = new Color("#3498DB");
719 /// underline.Height = 2.0f;
720 /// label.SetUnderline(underline);
723 [EditorBrowsable(EditorBrowsableState.Never)]
724 public void SetUnderline(Underline underline)
726 SetProperty(TextLabel.Property.UNDERLINE, new PropertyValue(TextUtils.GetUnderlineMap(underline)));
730 /// Get Underline from TextLabel. <br />
732 /// <returns>The Underline</returns>
734 /// <see cref="Tizen.NUI.Text.Underline"/>
736 [EditorBrowsable(EditorBrowsableState.Never)]
737 public Underline GetUnderline()
739 var map = new PropertyMap();
740 GetProperty(TextLabel.Property.UNDERLINE).Get(map);
741 return TextUtils.GetUnderlineStruct(map);
745 /// The Shadow property.<br />
746 /// The default shadow parameters.<br />
747 /// The shadow map contains the following keys :<br />
748 /// <list type="table">
749 /// <item><term>color (Color)</term><description>The color of the shadow (the default color is Color.Black)</description></item>
750 /// <item><term>offset (Vector2)</term><description>The offset in pixels of the shadow (If not provided then the shadow is not enabled)</description></item>
751 /// <item><term>blurRadius (float)</term><description>The radius of the Gaussian blur for the soft shadow (If not provided then the soft shadow is not enabled)</description></item>
754 /// <since_tizen> 3 </since_tizen>
755 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1721: Property names should not match get methods")]
756 public PropertyMap Shadow
760 return (PropertyMap)GetValue(ShadowProperty);
764 SetValue(ShadowProperty, value);
765 NotifyPropertyChanged();
770 /// Set Shadow to TextLabel. <br />
772 /// <param name="shadow">The Shadow</param>
774 /// SetShadow specifies the shadow of the text through <see cref="Tizen.NUI.Text.Shadow"/>. <br />
777 /// The following example demonstrates how to use the SetShadow method.
779 /// var shadow = new Tizen.NUI.Text.Shadow();
780 /// shadow.Offset = new Vector2(3, 3);
781 /// shadow.Color = new Color("#F1C40F");
782 /// shadow.BlurRadius = 4.0f;
783 /// label.SetShadow(shadow);
786 [EditorBrowsable(EditorBrowsableState.Never)]
787 public void SetShadow(Tizen.NUI.Text.Shadow shadow)
789 SetProperty(TextLabel.Property.SHADOW, new PropertyValue(TextUtils.GetShadowMap(shadow)));
793 /// Get Shadow from TextLabel. <br />
795 /// <returns>The Shadow</returns>
797 /// <see cref="Tizen.NUI.Text.Shadow"/>
799 [EditorBrowsable(EditorBrowsableState.Never)]
800 public Tizen.NUI.Text.Shadow GetShadow()
802 var map = new PropertyMap();
803 GetProperty(TextLabel.Property.SHADOW).Get(map);
804 return TextUtils.GetShadowStruct(map);
808 /// Describes a text shadow for a TextLabel.
809 /// It is null by default.
811 [EditorBrowsable(EditorBrowsableState.Never)]
812 public TextShadow TextShadow
816 return (TextShadow)GetValue(TextShadowProperty);
820 SetValue(TextShadowProperty, value);
821 NotifyPropertyChanged();
826 /// The Emboss property.<br />
827 /// The default emboss parameters.<br />
829 /// <since_tizen> 3 </since_tizen>
834 return (string)GetValue(EmbossProperty);
838 SetValue(EmbossProperty, value);
839 NotifyPropertyChanged();
844 /// The Outline property.<br />
845 /// The default outline parameters.<br />
846 /// The outline map contains the following keys :<br />
847 /// <list type="table">
848 /// <item><term>color (Color)</term><description>The color of the outline (the default color is Color.White)</description></item>
849 /// <item><term>width (float)</term><description>The width in pixels of the outline (If not provided then the outline is not enabled)</description></item>
852 /// <since_tizen> 3 </since_tizen>
853 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1721: Property names should not match get methods")]
854 public PropertyMap Outline
858 return (PropertyMap)GetValue(OutlineProperty);
862 SetValue(OutlineProperty, value);
863 NotifyPropertyChanged();
868 /// Set Outline to TextLabel. <br />
870 /// <param name="outline">The Outline</param>
872 /// SetOutline specifies the outline of the text through <see cref="Tizen.NUI.Text.Outline"/>. <br />
875 /// The following example demonstrates how to use the SetOutline method.
877 /// var outline = new Tizen.NUI.Text.Outline();
878 /// outline.Width = 2.0f;
879 /// outline.Color = new Color("#45B39D");
880 /// label.SetOutline(outline);
883 [EditorBrowsable(EditorBrowsableState.Never)]
884 public void SetOutline(Outline outline)
886 SetProperty(TextLabel.Property.OUTLINE, new PropertyValue(TextUtils.GetOutlineMap(outline)));
890 /// Get Outline from TextLabel. <br />
892 /// <returns>The Outline</returns>
894 /// <see cref="Tizen.NUI.Text.Outline"/>
896 [EditorBrowsable(EditorBrowsableState.Never)]
897 public Outline GetOutline()
899 var map = new PropertyMap();
900 GetProperty(TextLabel.Property.OUTLINE).Get(map);
901 return TextUtils.GetOutlineStruct(map);
905 /// The PixelSize property.<br />
906 /// The size of font in pixels.<br />
908 /// <since_tizen> 3 </since_tizen>
909 public float PixelSize
913 return (float)GetValue(PixelSizeProperty);
917 SetValue(PixelSizeProperty, value);
918 NotifyPropertyChanged();
923 /// The Ellipsis property.<br />
924 /// Enable or disable the ellipsis.<br />
926 /// <since_tizen> 3 </since_tizen>
931 return (bool)GetValue(EllipsisProperty);
935 SetValue(EllipsisProperty, value);
936 NotifyPropertyChanged();
941 /// The ellipsis position of the text.
942 /// The ellipsis position type when the text size over the layout size.<br />
943 /// The ellipsis position: End, Start or Middle.<br />
945 [EditorBrowsable(EditorBrowsableState.Never)]
946 public EllipsisPosition EllipsisPosition
950 return (EllipsisPosition)GetValue(EllipsisPositionProperty);
954 SetValue(EllipsisPositionProperty, value);
955 NotifyPropertyChanged();
960 /// The AutoScrollLoopDelay property.<br />
961 /// Do something.<br />
963 /// <since_tizen> 3 </since_tizen>
964 public float AutoScrollLoopDelay
968 return (float)GetValue(AutoScrollLoopDelayProperty);
972 SetValue(AutoScrollLoopDelayProperty, value);
973 NotifyPropertyChanged();
978 /// The AutoScrollStopMode property.<br />
979 /// Do something.<br />
981 /// <since_tizen> 3 </since_tizen>
982 public AutoScrollStopMode AutoScrollStopMode
986 return (AutoScrollStopMode)GetValue(AutoScrollStopModeProperty);
990 SetValue(AutoScrollStopModeProperty, value);
991 NotifyPropertyChanged();
996 /// The line count of the text.
998 /// <since_tizen> 3 </since_tizen>
1004 GetProperty(TextLabel.Property.LineCount).Get(out temp);
1010 /// The LineWrapMode property.<br />
1011 /// line wrap mode when the text lines over layout width.<br />
1013 /// <since_tizen> 4 </since_tizen>
1014 public LineWrapMode LineWrapMode
1018 return (LineWrapMode)GetValue(LineWrapModeProperty);
1022 SetValue(LineWrapModeProperty, value);
1023 NotifyPropertyChanged();
1028 /// The direction of the text such as left to right or right to left.
1030 /// <since_tizen> 5 </since_tizen>
1031 /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
1032 [EditorBrowsable(EditorBrowsableState.Never)]
1033 public TextDirection TextDirection
1038 GetProperty(TextLabel.Property.TextDirection).Get(out temp);
1039 return (TextDirection)temp;
1044 /// The vertical line alignment of the text.
1046 /// <since_tizen> 5 </since_tizen>
1047 /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
1048 [EditorBrowsable(EditorBrowsableState.Never)]
1049 public VerticalLineAlignment VerticalLineAlignment
1053 return (VerticalLineAlignment)GetValue(VerticalLineAlignmentProperty);
1057 SetValue(VerticalLineAlignmentProperty, value);
1058 NotifyPropertyChanged();
1063 /// The text alignment to match the direction of the system language.
1065 /// <since_tizen> 6 </since_tizen>
1066 public bool MatchSystemLanguageDirection
1070 return (bool)GetValue(MatchSystemLanguageDirectionProperty);
1074 SetValue(MatchSystemLanguageDirectionProperty, value);
1075 NotifyPropertyChanged();
1080 /// The text fit parameters.<br />
1081 /// The textFit map contains the following keys :<br />
1082 /// <list type="table">
1083 /// <item><term>enable (bool)</term><description>True to enable the text fit or false to disable (the default value is false)</description></item>
1084 /// <item><term>minSize (float)</term><description>Minimum Size for text fit (the default value is 10.f)</description></item>
1085 /// <item><term>maxSize (float)</term><description>Maximum Size for text fit (the default value is 100.f)</description></item>
1086 /// <item><term>stepSize (float)</term><description>Step Size for font increase (the default value is 1.f)</description></item>
1087 /// <item><term>fontSize (string)</term><description>The size type of font, You can choose between "pointSize" or "pixelSize". (the default value is "pointSize")</description></item>
1090 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1091 [EditorBrowsable(EditorBrowsableState.Never)]
1092 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1721: Property names should not match get methods")]
1093 public PropertyMap TextFit
1097 return (PropertyMap)GetValue(TextFitProperty);
1101 SetValue(TextFitProperty, value);
1102 NotifyPropertyChanged();
1107 /// Set TextFit to TextLabel. <br />
1109 /// <param name="textFit">The TextFit</param>
1111 /// SetTextFit specifies the textFit of the text through <see cref="Tizen.NUI.Text.TextFit"/>. <br />
1114 /// The following example demonstrates how to use the SetTextFit method.
1116 /// var textFit = new Tizen.NUI.Text.TextFit();
1117 /// textFit.Enable = true;
1118 /// textFit.MinSize = 10.0f;
1119 /// textFit.MaxSize = 100.0f;
1120 /// textFit.StepSize = 5.0f;
1121 /// textFit.FontSizeType = FontSizeType.PointSize;
1122 /// label.SetTextFit(textFit);
1125 [EditorBrowsable(EditorBrowsableState.Never)]
1126 public void SetTextFit(TextFit textFit)
1128 SetProperty(TextLabel.Property.TextFit, new PropertyValue(TextUtils.GetTextFitMap(textFit)));
1132 /// Get TextFit from TextLabel. <br />
1134 /// <returns>The TextFit</returns>
1136 /// TextFit is always returned based on PointSize. <br />
1137 /// If the user sets FontSizeType to PixelSize, then MinSize, MaxSize, and StepSize are converted based on PointSize and returned. <br />
1138 /// <see cref="Tizen.NUI.Text.TextFit"/>
1140 [EditorBrowsable(EditorBrowsableState.Never)]
1141 public TextFit GetTextFit()
1143 var map = new PropertyMap();
1144 GetProperty(TextLabel.Property.TextFit).Get(map);
1145 return TextUtils.GetTextFitStruct(map);
1149 /// The MinLineSize property.<br />
1151 /// <since_tizen> 8 </since_tizen>
1152 [EditorBrowsable(EditorBrowsableState.Never)]
1153 public float MinLineSize
1157 return (float)GetValue(MinLineSizeProperty);
1161 SetValue(MinLineSizeProperty, value);
1162 NotifyPropertyChanged();
1167 /// The FontSizeScale property. <br />
1168 /// The default value is 1.0. <br />
1169 /// If FontSizeScale.UseSystemSetting, will use the SystemSettings.FontSize internally. <br />
1171 /// <since_tizen> 9 </since_tizen>
1172 public float FontSizeScale
1176 return fontSizeScale;
1180 float newFontSizeScale;
1182 if (fontSizeScale == value) return;
1184 fontSizeScale = value;
1185 if (fontSizeScale == Tizen.NUI.FontSizeScale.UseSystemSetting)
1187 SystemSettingsFontSize systemSettingsFontSize;
1191 systemSettingsFontSize = SystemSettings.FontSize;
1195 Console.WriteLine("{0} Exception caught.", e);
1196 systemSettingsFontSize = SystemSettingsFontSize.Normal;
1198 newFontSizeScale = TextUtils.GetFontSizeScale(systemSettingsFontSize);
1199 addFontSizeChangedCallback();
1203 newFontSizeScale = fontSizeScale;
1204 removeFontSizeChangedCallback();
1207 SetValue(FontSizeScaleProperty, newFontSizeScale);
1208 NotifyPropertyChanged();
1212 private TextLabelSelectorData EnsureSelectorData() => selectorData ?? (selectorData = new TextLabelSelectorData());
1215 /// Downcasts a handle to textLabel handle
1217 /// <param name="handle"></param>
1218 /// <returns></returns>
1219 /// <exception cref="ArgumentNullException"> Thrown when handle is null. </exception>
1220 /// <since_tizen> 3 </since_tizen>
1221 /// Please do not use! this will be deprecated!
1222 /// Instead please use as keyword.
1223 [Obsolete("Please do not use! This will be deprecated! Please use as keyword instead! " +
1225 "BaseHandle handle = new TextLabel(\"Hello World!\"); " +
1226 "TextLabel label = handle as TextLabel")]
1227 [EditorBrowsable(EditorBrowsableState.Never)]
1228 public static TextLabel DownCast(BaseHandle handle)
1232 throw new ArgumentNullException(nameof(handle));
1234 TextLabel ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as TextLabel;
1235 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1240 [EditorBrowsable(EditorBrowsableState.Never)]
1241 protected override void Dispose(DisposeTypes type)
1248 if (systemlangTextFlag)
1250 SystemSettings.LocaleLanguageChanged -= SystemSettings_LocaleLanguageChanged;
1253 removeFontSizeChangedCallback();
1255 if (type == DisposeTypes.Explicit)
1258 //Release your own managed resources here.
1259 //You should release all of your own disposable objects here.
1260 selectorData?.Reset(this);
1266 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TextLabel obj)
1268 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
1271 /// This will not be public opened.
1272 [EditorBrowsable(EditorBrowsableState.Never)]
1273 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1275 Interop.TextLabel.DeleteTextLabel(swigCPtr);
1279 /// Get attribues, it is abstract function and must be override.
1281 [EditorBrowsable(EditorBrowsableState.Never)]
1282 protected override ViewStyle CreateViewStyle()
1284 return new TextLabelStyle();
1288 /// Invoked whenever the binding context of the textlabel changes. Implement this method to add class handling for this event.
1290 protected override void OnBindingContextChanged()
1292 base.OnBindingContextChanged();
1295 private void SystemSettings_LocaleLanguageChanged(object sender, LocaleLanguageChangedEventArgs e)
1297 Text = NUIApplication.MultilingualResourceManager?.GetString(textLabelSid, new CultureInfo(e.Value.Replace("_", "-")));
1300 private void SystemSettingsFontSizeChanged(object sender, FontSizeChangedEventArgs e)
1302 float newFontSizeScale = TextUtils.GetFontSizeScale(e.Value);
1303 SetValue(FontSizeScaleProperty, newFontSizeScale);
1306 private void addFontSizeChangedCallback()
1308 if (hasFontSizeChangedCallback != true)
1312 SystemSettings.FontSizeChanged += SystemSettingsFontSizeChanged;
1313 hasFontSizeChangedCallback = true;
1317 Console.WriteLine("{0} Exception caught.", e);
1318 hasFontSizeChangedCallback = false;
1323 private void removeFontSizeChangedCallback()
1325 if (hasFontSizeChangedCallback == true)
1329 SystemSettings.FontSizeChanged -= SystemSettingsFontSizeChanged;
1330 hasFontSizeChangedCallback = false;
1334 Console.WriteLine("{0} Exception caught.", e);
1335 hasFontSizeChangedCallback = true;
1340 private void RequestLayout()
1342 Layout?.RequestLayout();
1345 internal new class Property
1347 internal static readonly int TEXT = Interop.TextLabel.TextGet();
1348 internal static readonly int FontFamily = Interop.TextLabel.FontFamilyGet();
1349 internal static readonly int FontStyle = Interop.TextLabel.FontStyleGet();
1350 internal static readonly int PointSize = Interop.TextLabel.PointSizeGet();
1351 internal static readonly int MultiLine = Interop.TextLabel.MultiLineGet();
1352 internal static readonly int HorizontalAlignment = Interop.TextLabel.HorizontalAlignmentGet();
1353 internal static readonly int VerticalAlignment = Interop.TextLabel.VerticalAlignmentGet();
1354 internal static readonly int TextColor = Interop.TextLabel.TextColorGet();
1355 internal static readonly int EnableMarkup = Interop.TextLabel.EnableMarkupGet();
1356 internal static readonly int EnableAutoScroll = Interop.TextLabel.EnableAutoScrollGet();
1357 internal static readonly int AutoScrollSpeed = Interop.TextLabel.AutoScrollSpeedGet();
1358 internal static readonly int AutoScrollLoopCount = Interop.TextLabel.AutoScrollLoopCountGet();
1359 internal static readonly int AutoScrollGap = Interop.TextLabel.AutoScrollGapGet();
1360 internal static readonly int LineSpacing = Interop.TextLabel.LineSpacingGet();
1361 internal static readonly int UNDERLINE = Interop.TextLabel.UnderlineGet();
1362 internal static readonly int SHADOW = Interop.TextLabel.ShadowGet();
1363 internal static readonly int EMBOSS = Interop.TextLabel.EmbossGet();
1364 internal static readonly int OUTLINE = Interop.TextLabel.OutlineGet();
1365 internal static readonly int PixelSize = Interop.TextLabel.PixelSizeGet();
1366 internal static readonly int ELLIPSIS = Interop.TextLabel.EllipsisGet();
1367 internal static readonly int AutoScrollStopMode = Interop.TextLabel.AutoScrollStopModeGet();
1368 internal static readonly int AutoScrollLoopDelay = Interop.TextLabel.AutoScrollLoopDelayGet();
1369 internal static readonly int LineCount = Interop.TextLabel.LineCountGet();
1370 internal static readonly int LineWrapMode = Interop.TextLabel.LineWrapModeGet();
1371 internal static readonly int TextDirection = Interop.TextLabel.TextDirectionGet();
1372 internal static readonly int VerticalLineAlignment = Interop.TextLabel.VerticalLineAlignmentGet();
1373 internal static readonly int MatchSystemLanguageDirection = Interop.TextLabel.MatchSystemLanguageDirectionGet();
1374 internal static readonly int TextFit = Interop.TextLabel.TextFitGet();
1375 internal static readonly int MinLineSize = Interop.TextLabel.MinLineSizeGet();
1376 internal static readonly int FontSizeScale = Interop.TextLabel.FontSizeScaleGet();
1377 internal static readonly int EllipsisPosition = Interop.TextLabel.EllipsisPositionGet();
1380 private void OnShadowColorChanged(float x, float y, float z, float w)
1382 ShadowColor = new Vector4(x, y, z, w);
1384 private void OnShadowOffsetChanged(float x, float y)
1386 ShadowOffset = new Vector2(x, y);
1388 private void OnTextColorChanged(float r, float g, float b, float a)
1390 TextColor = new Color(r, g, b, a);
1392 private void OnUnderlineColorChanged(float x, float y, float z, float w)
1394 UnderlineColor = new Vector4(x, y, z, w);