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 SetValue(FontStyleProperty, 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 return TextUtils.GetFontStyleStruct((PropertyMap)GetValue(FontStyleProperty));
322 /// The PointSize property.<br />
323 /// The size of font in points.<br />
325 /// <since_tizen> 3 </since_tizen>
326 public float PointSize
330 return (float)GetValue(PointSizeProperty);
334 SetValue(PointSizeProperty, value);
335 NotifyPropertyChanged();
340 /// The MultiLine property.<br />
341 /// The single-line or multi-line layout option.<br />
343 /// <since_tizen> 3 </since_tizen>
344 public bool MultiLine
348 return (bool)GetValue(MultiLineProperty);
352 SetValue(MultiLineProperty, value);
353 NotifyPropertyChanged();
358 /// The HorizontalAlignment property.<br />
359 /// The line horizontal alignment.<br />
361 /// <since_tizen> 3 </since_tizen>
362 public HorizontalAlignment HorizontalAlignment
366 return (HorizontalAlignment)GetValue(HorizontalAlignmentProperty);
370 SetValue(HorizontalAlignmentProperty, value);
371 NotifyPropertyChanged();
376 /// The VerticalAlignment property.<br />
377 /// The line vertical alignment.<br />
379 /// <since_tizen> 3 </since_tizen>
380 public VerticalAlignment VerticalAlignment
384 return (VerticalAlignment)GetValue(VerticalAlignmentProperty);
388 SetValue(VerticalAlignmentProperty, value);
389 NotifyPropertyChanged();
394 /// The TextColor property.<br />
395 /// The color of the text.<br />
396 /// Animation framework can be used to change the color of the text when not using mark up.<br />
397 /// Cannot animate the color when text is auto scrolling.<br />
400 /// The property cascade chaining set is possible. For example, this (textLabel.TextColor.X = 0.1f;) is possible.
402 /// <since_tizen> 3 </since_tizen>
403 public Color TextColor
407 Color temp = (Color)GetValue(TextColorProperty);
408 return new Color(OnTextColorChanged, temp.R, temp.G, temp.B, temp.A);
412 SetValue(TextColorProperty, value);
413 NotifyPropertyChanged();
418 /// The ShadowOffset property.<br />
419 /// The drop shadow offset 0 indicates no shadow.<br />
421 /// <since_tizen> 3 </since_tizen>
423 /// Deprecated.(API Level 6) Use Shadow instead.
424 /// The property cascade chaining set is possible. For example, this (textLabel.ShadowOffset.X = 0.1f;) is possible.
426 [Obsolete("Please do not use this ShadowOffset(Deprecated). Please use Shadow instead.")]
427 public Vector2 ShadowOffset
431 return GetValue(ShadowOffsetProperty) as Vector2;
435 SetValue(ShadowOffsetProperty, value);
439 private Vector2 InternalShadowOffset
443 Vector2 shadowOffset = new Vector2();
444 Shadow.Find(TextLabel.Property.SHADOW, "offset")?.Get(shadowOffset);
445 return new Vector2(OnShadowOffsetChanged, shadowOffset.X, shadowOffset.Y);
449 PropertyMap temp = new PropertyMap();
450 temp.Insert("offset", new PropertyValue(value));
452 PropertyMap shadowMap = Shadow;
453 shadowMap.Merge(temp);
455 SetValue(ShadowProperty, shadowMap);
456 NotifyPropertyChanged();
461 /// The ShadowColor property.<br />
462 /// The color of a drop shadow.<br />
464 /// <since_tizen> 3 </since_tizen>
466 /// Deprecated.(API Level 6) Use Shadow instead.
467 /// The property cascade chaining set is possible. For example, this (textLabel.ShadowColor.X = 0.1f;) is possible.
469 [Obsolete("Please do not use this ShadowColor(Deprecated). Please use Shadow instead.")]
470 public Vector4 ShadowColor
474 return GetValue(ShadowColorProperty) as Vector4;
478 SetValue(ShadowColorProperty, value);
482 private Vector4 InternalShadowColor
486 Vector4 shadowColor = new Vector4();
487 Shadow.Find(TextLabel.Property.SHADOW, "color")?.Get(shadowColor);
488 return new Vector4(OnShadowColorChanged, shadowColor.X, shadowColor.Y, shadowColor.Z, shadowColor.W);
492 PropertyMap temp = new PropertyMap();
493 temp.Insert("color", new PropertyValue(value));
495 PropertyMap shadowMap = Shadow;
496 shadowMap.Merge(temp);
498 SetValue(ShadowProperty, shadowMap);
499 NotifyPropertyChanged();
504 /// The UnderlineEnabled property.<br />
505 /// The underline enabled flag.<br />
507 /// <since_tizen> 3 </since_tizen>
509 /// Deprecated.(API Level 6) Use Underline instead.
511 [Obsolete("Please do not use this UnderlineEnabled(Deprecated). Please use Underline instead.")]
512 public bool UnderlineEnabled
516 return (bool)GetValue(UnderlineEnabledProperty);
520 SetValue(UnderlineEnabledProperty, value);
524 private bool InternalUnderlineEnabled
528 bool underlineEnabled = false;
529 Underline.Find(TextLabel.Property.UNDERLINE, "enable")?.Get(out underlineEnabled);
530 return underlineEnabled;
534 PropertyMap temp = new PropertyMap();
535 temp.Add("enable", new PropertyValue(value));
537 PropertyMap undelineMap = Underline;
538 undelineMap.Merge(temp);
540 SetValue(UnderlineProperty, undelineMap);
541 NotifyPropertyChanged();
547 /// The UnderlineColor property.<br />
548 /// Overrides the underline height from font metrics.<br />
550 /// <since_tizen> 3 </since_tizen>
552 /// Deprecated.(API Level 6) Use Underline instead.
553 /// The property cascade chaining set is possible. For example, this (textLabel.UnderlineColor.X = 0.1f;) is possible.
555 [Obsolete("Please do not use this UnderlineColor(Deprecated). Please use Underline instead.")]
556 public Vector4 UnderlineColor
560 return GetValue(UnderlineColorProperty) as Vector4;
564 SetValue(UnderlineColorProperty, value);
568 private Vector4 InternalUnderlineColor
572 Vector4 underlineColor = new Vector4();
573 Underline.Find(TextLabel.Property.UNDERLINE, "color")?.Get(underlineColor);
574 return new Vector4(OnUnderlineColorChanged, underlineColor.X, underlineColor.Y, underlineColor.Z, underlineColor.W);
578 PropertyMap temp = new PropertyMap();
579 temp.Insert("color", new PropertyValue(value));
581 PropertyMap undelineMap = Underline;
582 undelineMap.Merge(temp);
584 SetValue(UnderlineProperty, undelineMap);
585 NotifyPropertyChanged();
590 /// The UnderlineHeight property.<br />
591 /// Overrides the underline height from font metrics.<br />
593 /// <since_tizen> 3 </since_tizen>
595 /// Deprecated.(API Level 6) Use Underline instead.
597 [Obsolete("Please do not use this UnderlineHeight(Deprecated). Please use Underline instead.")]
598 public float UnderlineHeight
602 return (float)GetValue(UnderlineHeightProperty);
606 SetValue(UnderlineHeightProperty, value);
610 private float InternalUnderlineHeight
614 float underlineHeight = 0.0f;
615 Underline.Find(TextLabel.Property.UNDERLINE, "height")?.Get(out underlineHeight);
616 return underlineHeight;
620 PropertyMap temp = new PropertyMap();
621 temp.Insert("height", new PropertyValue(value));
623 PropertyMap undelineMap = Underline;
624 undelineMap.Merge(temp);
626 SetValue(UnderlineProperty, undelineMap);
627 NotifyPropertyChanged();
632 /// The EnableMarkup property.<br />
633 /// Whether the mark-up processing is enabled.<br />
635 /// <since_tizen> 3 </since_tizen>
636 public bool EnableMarkup
640 return (bool)GetValue(EnableMarkupProperty);
644 SetValue(EnableMarkupProperty, value);
645 NotifyPropertyChanged();
650 /// The EnableAutoScroll property.<br />
651 /// Starts or stops auto scrolling.<br />
653 /// <since_tizen> 3 </since_tizen>
654 public bool EnableAutoScroll
658 return (bool)GetValue(EnableAutoScrollProperty);
662 SetValue(EnableAutoScrollProperty, value);
663 NotifyPropertyChanged();
668 /// The AutoScrollSpeed property.<br />
669 /// Sets the speed of scrolling in pixels per second.<br />
671 /// <since_tizen> 3 </since_tizen>
672 public int AutoScrollSpeed
676 return (int)GetValue(AutoScrollSpeedProperty);
680 SetValue(AutoScrollSpeedProperty, value);
681 NotifyPropertyChanged();
686 /// The AutoScrollLoopCount property.<br />
687 /// Number of complete loops when scrolling enabled.<br />
689 /// <since_tizen> 3 </since_tizen>
690 public int AutoScrollLoopCount
694 return (int)GetValue(AutoScrollLoopCountProperty);
698 SetValue(AutoScrollLoopCountProperty, value);
699 NotifyPropertyChanged();
704 /// The AutoScrollGap property.<br />
705 /// Gap before scrolling wraps.<br />
707 /// <since_tizen> 3 </since_tizen>
708 public float AutoScrollGap
712 return (float)GetValue(AutoScrollGapProperty);
716 SetValue(AutoScrollGapProperty, value);
717 NotifyPropertyChanged();
722 /// The LineSpacing property.<br />
723 /// The default extra space between lines in points.<br />
725 /// <since_tizen> 3 </since_tizen>
726 public float LineSpacing
730 return (float)GetValue(LineSpacingProperty);
734 SetValue(LineSpacingProperty, value);
735 NotifyPropertyChanged();
740 /// The Underline property.<br />
741 /// The default underline parameters.<br />
742 /// The underline map contains the following keys :<br />
743 /// <list type="table">
744 /// <item><term>enable (bool)</term><description>Whether the underline is enabled (the default value is false)</description></item>
745 /// <item><term>color (Color)</term><description>The color of the underline (If not provided then the color of the text is used)</description></item>
746 /// <item><term>height (float)</term><description>The height in pixels of the underline (the default value is 1.f)</description></item>
749 /// <since_tizen> 3 </since_tizen>
750 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1721: Property names should not match get methods")]
751 public PropertyMap Underline
755 return (PropertyMap)GetValue(UnderlineProperty);
759 SetValue(UnderlineProperty, value);
760 NotifyPropertyChanged();
765 /// Set Underline to TextLabel. <br />
767 /// <param name="underline">The Underline</param>
769 /// SetUnderline specifies the underline of the text through <see cref="Tizen.NUI.Text.Underline"/>. <br />
772 /// The following example demonstrates how to use the SetUnderline method.
774 /// var underline = new Tizen.NUI.Text.Underline();
775 /// underline.Enable = true;
776 /// underline.Color = new Color("#3498DB");
777 /// underline.Height = 2.0f;
778 /// label.SetUnderline(underline);
781 [EditorBrowsable(EditorBrowsableState.Never)]
782 public void SetUnderline(Underline underline)
784 SetValue(UnderlineProperty, TextUtils.GetUnderlineMap(underline));
788 /// Get Underline from TextLabel. <br />
790 /// <returns>The Underline</returns>
792 /// <see cref="Tizen.NUI.Text.Underline"/>
794 [EditorBrowsable(EditorBrowsableState.Never)]
795 public Underline GetUnderline()
797 return TextUtils.GetUnderlineStruct((PropertyMap)GetValue(UnderlineProperty));
801 /// The Shadow property.<br />
802 /// The default shadow parameters.<br />
803 /// The shadow map contains the following keys :<br />
804 /// <list type="table">
805 /// <item><term>color (Color)</term><description>The color of the shadow (the default color is Color.Black)</description></item>
806 /// <item><term>offset (Vector2)</term><description>The offset in pixels of the shadow (If not provided then the shadow is not enabled)</description></item>
807 /// <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>
810 /// <since_tizen> 3 </since_tizen>
811 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1721: Property names should not match get methods")]
812 public PropertyMap Shadow
816 return (PropertyMap)GetValue(ShadowProperty);
820 SetValue(ShadowProperty, value);
821 NotifyPropertyChanged();
826 /// Set Shadow to TextLabel. <br />
828 /// <param name="shadow">The Shadow</param>
830 /// SetShadow specifies the shadow of the text through <see cref="Tizen.NUI.Text.Shadow"/>. <br />
833 /// The following example demonstrates how to use the SetShadow method.
835 /// var shadow = new Tizen.NUI.Text.Shadow();
836 /// shadow.Offset = new Vector2(3, 3);
837 /// shadow.Color = new Color("#F1C40F");
838 /// shadow.BlurRadius = 4.0f;
839 /// label.SetShadow(shadow);
842 [EditorBrowsable(EditorBrowsableState.Never)]
843 public void SetShadow(Tizen.NUI.Text.Shadow shadow)
845 SetValue(ShadowProperty, TextUtils.GetShadowMap(shadow));
849 /// Get Shadow from TextLabel. <br />
851 /// <returns>The Shadow</returns>
853 /// <see cref="Tizen.NUI.Text.Shadow"/>
855 [EditorBrowsable(EditorBrowsableState.Never)]
856 public Tizen.NUI.Text.Shadow GetShadow()
858 return TextUtils.GetShadowStruct((PropertyMap)GetValue(ShadowProperty));
862 /// Describes a text shadow for a TextLabel.
863 /// It is null by default.
865 [EditorBrowsable(EditorBrowsableState.Never)]
866 public TextShadow TextShadow
870 return (TextShadow)GetValue(TextShadowProperty);
874 SetValue(TextShadowProperty, value);
875 NotifyPropertyChanged();
880 /// The Emboss property.<br />
881 /// The default emboss parameters.<br />
883 /// <since_tizen> 3 </since_tizen>
888 return (string)GetValue(EmbossProperty);
892 SetValue(EmbossProperty, value);
893 NotifyPropertyChanged();
898 /// The Outline property.<br />
899 /// The default outline parameters.<br />
900 /// The outline map contains the following keys :<br />
901 /// <list type="table">
902 /// <item><term>color (Color)</term><description>The color of the outline (the default color is Color.White)</description></item>
903 /// <item><term>width (float)</term><description>The width in pixels of the outline (If not provided then the outline is not enabled)</description></item>
906 /// <since_tizen> 3 </since_tizen>
907 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1721: Property names should not match get methods")]
908 public PropertyMap Outline
912 return (PropertyMap)GetValue(OutlineProperty);
916 SetValue(OutlineProperty, value);
917 NotifyPropertyChanged();
922 /// Set Outline to TextLabel. <br />
924 /// <param name="outline">The Outline</param>
926 /// SetOutline specifies the outline of the text through <see cref="Tizen.NUI.Text.Outline"/>. <br />
929 /// The following example demonstrates how to use the SetOutline method.
931 /// var outline = new Tizen.NUI.Text.Outline();
932 /// outline.Width = 2.0f;
933 /// outline.Color = new Color("#45B39D");
934 /// label.SetOutline(outline);
937 [EditorBrowsable(EditorBrowsableState.Never)]
938 public void SetOutline(Outline outline)
940 SetValue(OutlineProperty, TextUtils.GetOutlineMap(outline));
944 /// Get Outline from TextLabel. <br />
946 /// <returns>The Outline</returns>
948 /// <see cref="Tizen.NUI.Text.Outline"/>
950 [EditorBrowsable(EditorBrowsableState.Never)]
951 public Outline GetOutline()
953 return TextUtils.GetOutlineStruct((PropertyMap)GetValue(OutlineProperty));
957 /// The PixelSize property.<br />
958 /// The size of font in pixels.<br />
960 /// <since_tizen> 3 </since_tizen>
961 public float PixelSize
965 return (float)GetValue(PixelSizeProperty);
969 SetValue(PixelSizeProperty, value);
970 NotifyPropertyChanged();
975 /// The Ellipsis property.<br />
976 /// Enable or disable the ellipsis.<br />
978 /// <since_tizen> 3 </since_tizen>
983 return (bool)GetValue(EllipsisProperty);
987 SetValue(EllipsisProperty, value);
988 NotifyPropertyChanged();
993 /// The ellipsis position of the text.
994 /// Specifies which portion of the text should be replaced with an ellipsis when the text size exceeds the layout size.<br />
996 /// <since_tizen> 9 </since_tizen>
997 public EllipsisPosition EllipsisPosition
1001 return (EllipsisPosition)GetValue(EllipsisPositionProperty);
1005 SetValue(EllipsisPositionProperty, value);
1006 NotifyPropertyChanged();
1011 /// The AutoScrollLoopDelay property.<br />
1012 /// Do something.<br />
1014 /// <since_tizen> 3 </since_tizen>
1015 public float AutoScrollLoopDelay
1019 return (float)GetValue(AutoScrollLoopDelayProperty);
1023 SetValue(AutoScrollLoopDelayProperty, value);
1024 NotifyPropertyChanged();
1029 /// The AutoScrollStopMode property.<br />
1030 /// Do something.<br />
1032 /// <since_tizen> 3 </since_tizen>
1033 public AutoScrollStopMode AutoScrollStopMode
1037 return (AutoScrollStopMode)GetValue(AutoScrollStopModeProperty);
1041 SetValue(AutoScrollStopModeProperty, value);
1042 NotifyPropertyChanged();
1047 /// The line count of the text.
1049 /// <since_tizen> 3 </since_tizen>
1050 public int LineCount
1055 GetProperty(TextLabel.Property.LineCount).Get(out temp);
1061 /// The LineWrapMode property.<br />
1062 /// line wrap mode when the text lines over layout width.<br />
1064 /// <since_tizen> 4 </since_tizen>
1065 public LineWrapMode LineWrapMode
1069 return (LineWrapMode)GetValue(LineWrapModeProperty);
1073 SetValue(LineWrapModeProperty, value);
1074 NotifyPropertyChanged();
1079 /// The direction of the text such as left to right or right to left.
1081 /// <since_tizen> 5 </since_tizen>
1082 /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
1083 [EditorBrowsable(EditorBrowsableState.Never)]
1084 public TextDirection TextDirection
1089 GetProperty(TextLabel.Property.TextDirection).Get(out temp);
1090 return (TextDirection)temp;
1095 /// The vertical line alignment of the text.
1097 /// <since_tizen> 5 </since_tizen>
1098 /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
1099 [EditorBrowsable(EditorBrowsableState.Never)]
1100 public VerticalLineAlignment VerticalLineAlignment
1104 return (VerticalLineAlignment)GetValue(VerticalLineAlignmentProperty);
1108 SetValue(VerticalLineAlignmentProperty, value);
1109 NotifyPropertyChanged();
1114 /// The text alignment to match the direction of the system language.
1116 /// <since_tizen> 6 </since_tizen>
1117 public bool MatchSystemLanguageDirection
1121 return (bool)GetValue(MatchSystemLanguageDirectionProperty);
1125 SetValue(MatchSystemLanguageDirectionProperty, value);
1126 NotifyPropertyChanged();
1131 /// The text fit parameters.<br />
1132 /// The textFit map contains the following keys :<br />
1133 /// <list type="table">
1134 /// <item><term>enable (bool)</term><description>True to enable the text fit or false to disable (the default value is false)</description></item>
1135 /// <item><term>minSize (float)</term><description>Minimum Size for text fit (the default value is 10.f)</description></item>
1136 /// <item><term>maxSize (float)</term><description>Maximum Size for text fit (the default value is 100.f)</description></item>
1137 /// <item><term>stepSize (float)</term><description>Step Size for font increase (the default value is 1.f)</description></item>
1138 /// <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>
1141 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1142 [EditorBrowsable(EditorBrowsableState.Never)]
1143 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1721: Property names should not match get methods")]
1144 public PropertyMap TextFit
1148 return (PropertyMap)GetValue(TextFitProperty);
1152 SetValue(TextFitProperty, value);
1153 NotifyPropertyChanged();
1158 /// Set TextFit to TextLabel. <br />
1160 /// <param name="textFit">The TextFit</param>
1162 /// SetTextFit specifies the textFit of the text through <see cref="Tizen.NUI.Text.TextFit"/>. <br />
1165 /// The following example demonstrates how to use the SetTextFit method.
1167 /// var textFit = new Tizen.NUI.Text.TextFit();
1168 /// textFit.Enable = true;
1169 /// textFit.MinSize = 10.0f;
1170 /// textFit.MaxSize = 100.0f;
1171 /// textFit.StepSize = 5.0f;
1172 /// textFit.FontSizeType = FontSizeType.PointSize;
1173 /// label.SetTextFit(textFit);
1176 [EditorBrowsable(EditorBrowsableState.Never)]
1177 public void SetTextFit(TextFit textFit)
1179 SetValue(TextFitProperty, TextUtils.GetTextFitMap(textFit));
1183 /// Get TextFit from TextLabel. <br />
1185 /// <returns>The TextFit</returns>
1187 /// TextFit is always returned based on PointSize. <br />
1188 /// If the user sets FontSizeType to PixelSize, then MinSize, MaxSize, and StepSize are converted based on PointSize and returned. <br />
1189 /// <see cref="Tizen.NUI.Text.TextFit"/>
1191 [EditorBrowsable(EditorBrowsableState.Never)]
1192 public TextFit GetTextFit()
1194 return TextUtils.GetTextFitStruct((PropertyMap)GetValue(TextFitProperty));
1198 /// The MinLineSize property.<br />
1200 /// <since_tizen> 8 </since_tizen>
1201 [EditorBrowsable(EditorBrowsableState.Never)]
1202 public float MinLineSize
1206 return (float)GetValue(MinLineSizeProperty);
1210 SetValue(MinLineSizeProperty, value);
1211 NotifyPropertyChanged();
1216 /// The FontSizeScale property. <br />
1217 /// The default value is 1.0. <br />
1218 /// If FontSizeScale.UseSystemSetting, will use the SystemSettings.FontSize internally. <br />
1220 /// <since_tizen> 9 </since_tizen>
1221 public float FontSizeScale
1225 return fontSizeScale;
1229 float newFontSizeScale;
1231 if (fontSizeScale == value) return;
1233 fontSizeScale = value;
1234 if (fontSizeScale == Tizen.NUI.FontSizeScale.UseSystemSetting)
1236 SystemSettingsFontSize systemSettingsFontSize;
1240 systemSettingsFontSize = SystemSettings.FontSize;
1244 Console.WriteLine("{0} Exception caught.", e);
1245 systemSettingsFontSize = SystemSettingsFontSize.Normal;
1247 newFontSizeScale = TextUtils.GetFontSizeScale(systemSettingsFontSize);
1248 addFontSizeChangedCallback();
1252 newFontSizeScale = fontSizeScale;
1253 removeFontSizeChangedCallback();
1256 SetValue(FontSizeScaleProperty, newFontSizeScale);
1257 NotifyPropertyChanged();
1261 private TextLabelSelectorData EnsureSelectorData() => selectorData ?? (selectorData = new TextLabelSelectorData());
1264 /// Downcasts a handle to textLabel handle
1266 /// <param name="handle"></param>
1267 /// <returns></returns>
1268 /// <exception cref="ArgumentNullException"> Thrown when handle is null. </exception>
1269 /// <since_tizen> 3 </since_tizen>
1270 /// Please do not use! this will be deprecated!
1271 /// Instead please use as keyword.
1272 [Obsolete("Please do not use! This will be deprecated! Please use as keyword instead! " +
1274 "BaseHandle handle = new TextLabel(\"Hello World!\"); " +
1275 "TextLabel label = handle as TextLabel")]
1276 [EditorBrowsable(EditorBrowsableState.Never)]
1277 public static TextLabel DownCast(BaseHandle handle)
1281 throw new ArgumentNullException(nameof(handle));
1283 TextLabel ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as TextLabel;
1284 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1289 [EditorBrowsable(EditorBrowsableState.Never)]
1290 protected override void Dispose(DisposeTypes type)
1297 if (systemlangTextFlag)
1299 SystemSettings.LocaleLanguageChanged -= SystemSettings_LocaleLanguageChanged;
1302 removeFontSizeChangedCallback();
1304 if (type == DisposeTypes.Explicit)
1307 //Release your own managed resources here.
1308 //You should release all of your own disposable objects here.
1309 selectorData?.Reset(this);
1315 /// This will not be public opened.
1316 [EditorBrowsable(EditorBrowsableState.Never)]
1317 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1319 Interop.TextLabel.DeleteTextLabel(swigCPtr);
1323 /// Get attribues, it is abstract function and must be override.
1325 [EditorBrowsable(EditorBrowsableState.Never)]
1326 protected override ViewStyle CreateViewStyle()
1328 return new TextLabelStyle();
1332 /// Invoked whenever the binding context of the textlabel changes. Implement this method to add class handling for this event.
1334 protected override void OnBindingContextChanged()
1336 base.OnBindingContextChanged();
1339 private void SystemSettings_LocaleLanguageChanged(object sender, LocaleLanguageChangedEventArgs e)
1341 Text = NUIApplication.MultilingualResourceManager?.GetString(textLabelSid, new CultureInfo(e.Value.Replace("_", "-")));
1344 private void SystemSettingsFontSizeChanged(object sender, FontSizeChangedEventArgs e)
1346 float newFontSizeScale = TextUtils.GetFontSizeScale(e.Value);
1347 SetValue(FontSizeScaleProperty, newFontSizeScale);
1350 private void addFontSizeChangedCallback()
1352 if (hasFontSizeChangedCallback != true)
1356 SystemSettings.FontSizeChanged += SystemSettingsFontSizeChanged;
1357 hasFontSizeChangedCallback = true;
1361 Console.WriteLine("{0} Exception caught.", e);
1362 hasFontSizeChangedCallback = false;
1367 private void removeFontSizeChangedCallback()
1369 if (hasFontSizeChangedCallback == true)
1373 SystemSettings.FontSizeChanged -= SystemSettingsFontSizeChanged;
1374 hasFontSizeChangedCallback = false;
1378 Console.WriteLine("{0} Exception caught.", e);
1379 hasFontSizeChangedCallback = true;
1384 private void RequestLayout()
1386 Layout?.RequestLayout();
1389 internal new class Property
1391 internal static readonly int TEXT = Interop.TextLabel.TextGet();
1392 internal static readonly int FontFamily = Interop.TextLabel.FontFamilyGet();
1393 internal static readonly int FontStyle = Interop.TextLabel.FontStyleGet();
1394 internal static readonly int PointSize = Interop.TextLabel.PointSizeGet();
1395 internal static readonly int MultiLine = Interop.TextLabel.MultiLineGet();
1396 internal static readonly int HorizontalAlignment = Interop.TextLabel.HorizontalAlignmentGet();
1397 internal static readonly int VerticalAlignment = Interop.TextLabel.VerticalAlignmentGet();
1398 internal static readonly int TextColor = Interop.TextLabel.TextColorGet();
1399 internal static readonly int EnableMarkup = Interop.TextLabel.EnableMarkupGet();
1400 internal static readonly int EnableAutoScroll = Interop.TextLabel.EnableAutoScrollGet();
1401 internal static readonly int AutoScrollSpeed = Interop.TextLabel.AutoScrollSpeedGet();
1402 internal static readonly int AutoScrollLoopCount = Interop.TextLabel.AutoScrollLoopCountGet();
1403 internal static readonly int AutoScrollGap = Interop.TextLabel.AutoScrollGapGet();
1404 internal static readonly int LineSpacing = Interop.TextLabel.LineSpacingGet();
1405 internal static readonly int UNDERLINE = Interop.TextLabel.UnderlineGet();
1406 internal static readonly int SHADOW = Interop.TextLabel.ShadowGet();
1407 internal static readonly int EMBOSS = Interop.TextLabel.EmbossGet();
1408 internal static readonly int OUTLINE = Interop.TextLabel.OutlineGet();
1409 internal static readonly int PixelSize = Interop.TextLabel.PixelSizeGet();
1410 internal static readonly int ELLIPSIS = Interop.TextLabel.EllipsisGet();
1411 internal static readonly int AutoScrollStopMode = Interop.TextLabel.AutoScrollStopModeGet();
1412 internal static readonly int AutoScrollLoopDelay = Interop.TextLabel.AutoScrollLoopDelayGet();
1413 internal static readonly int LineCount = Interop.TextLabel.LineCountGet();
1414 internal static readonly int LineWrapMode = Interop.TextLabel.LineWrapModeGet();
1415 internal static readonly int TextDirection = Interop.TextLabel.TextDirectionGet();
1416 internal static readonly int VerticalLineAlignment = Interop.TextLabel.VerticalLineAlignmentGet();
1417 internal static readonly int MatchSystemLanguageDirection = Interop.TextLabel.MatchSystemLanguageDirectionGet();
1418 internal static readonly int TextFit = Interop.TextLabel.TextFitGet();
1419 internal static readonly int MinLineSize = Interop.TextLabel.MinLineSizeGet();
1420 internal static readonly int FontSizeScale = Interop.TextLabel.FontSizeScaleGet();
1421 internal static readonly int EllipsisPosition = Interop.TextLabel.EllipsisPositionGet();
1424 private void OnShadowColorChanged(float x, float y, float z, float w)
1426 ShadowColor = new Vector4(x, y, z, w);
1428 private void OnShadowOffsetChanged(float x, float y)
1430 ShadowOffset = new Vector2(x, y);
1432 private void OnTextColorChanged(float r, float g, float b, float a)
1434 TextColor = new Color(r, g, b, a);
1436 private void OnUnderlineColorChanged(float x, float y, float z, float w)
1438 UnderlineColor = new Vector4(x, y, z, w);