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 /// The TranslatableText property.<br />
167 /// The text can set the SID value.<br />
169 /// <exception cref='ArgumentNullException'>
170 /// ResourceManager about multilingual is null.
172 /// <since_tizen> 4 </since_tizen>
173 public string TranslatableText
177 return (string)GetValue(TranslatableTextProperty);
181 SetValue(TranslatableTextProperty, value);
184 private string translatableText
192 if (NUIApplication.MultilingualResourceManager == null)
194 throw new ArgumentNullException(null, "ResourceManager about multilingual is null");
196 string translatableText = null;
197 textLabelSid = value;
198 translatableText = NUIApplication.MultilingualResourceManager?.GetString(textLabelSid, new CultureInfo(SystemSettings.LocaleLanguage.Replace("_", "-")));
199 if (translatableText != null)
201 Text = translatableText;
202 if (systemlangTextFlag == false)
204 SystemSettings.LocaleLanguageChanged += SystemSettings_LocaleLanguageChanged;
205 systemlangTextFlag = true;
212 NotifyPropertyChanged();
217 /// The Text property.<br />
218 /// The text to display in the UTF-8 format.<br />
220 /// <since_tizen> 3 </since_tizen>
225 return (string)GetValue(TextProperty);
229 SetValue(TextProperty, value);
230 NotifyPropertyChanged();
235 /// The FontFamily property.<br />
236 /// The requested font family to use.<br />
238 /// <since_tizen> 3 </since_tizen>
239 public string FontFamily
243 return (string)GetValue(FontFamilyProperty);
247 SetValue(FontFamilyProperty, value);
248 NotifyPropertyChanged();
253 /// The FontStyle property.<br />
254 /// The requested font style to use.<br />
255 /// The fontStyle map contains the following keys :<br />
256 /// <list type="table">
257 /// <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>
258 /// <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>
259 /// <item><term>slant (string)</term><description>The slant key defines whether to use italics. (values: normal, roman, italic, oblique)</description></item>
262 /// <since_tizen> 3 </since_tizen>
263 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1721: Property names should not match get methods")]
264 public PropertyMap FontStyle
268 return (PropertyMap)GetValue(FontStyleProperty);
272 SetValue(FontStyleProperty, value);
273 NotifyPropertyChanged();
278 /// Set FontStyle to TextLabel. <br />
280 /// <param name="fontStyle">The FontStyle</param>
282 /// SetFontStyle specifies the requested font style through <see cref="Tizen.NUI.Text.FontStyle"/>. <br />
285 /// The following example demonstrates how to use the SetFontStyle method.
287 /// var fontStyle = new Tizen.NUI.Text.FontStyle();
288 /// fontStyle.Width = FontWidthType.Expanded;
289 /// fontStyle.Weight = FontWeightType.Bold;
290 /// fontStyle.Slant = FontSlantType.Italic;
291 /// label.SetFontStyle(fontStyle);
294 [EditorBrowsable(EditorBrowsableState.Never)]
295 public void SetFontStyle(FontStyle fontStyle)
297 SetValue(FontStyleProperty, TextMapHelper.GetFontStyleMap(fontStyle));
301 /// Get FontStyle from TextLabel. <br />
303 /// <returns>The FontStyle</returns>
305 /// <see cref="Tizen.NUI.Text.FontStyle"/>
307 [EditorBrowsable(EditorBrowsableState.Never)]
308 public FontStyle GetFontStyle()
310 return TextMapHelper.GetFontStyleStruct((PropertyMap)GetValue(FontStyleProperty));
314 /// The PointSize property.<br />
315 /// The size of font in points.<br />
317 /// <since_tizen> 3 </since_tizen>
318 public float PointSize
322 return (float)GetValue(PointSizeProperty);
326 SetValue(PointSizeProperty, value);
327 NotifyPropertyChanged();
332 /// The MultiLine property.<br />
333 /// The single-line or multi-line layout option.<br />
335 /// <since_tizen> 3 </since_tizen>
336 public bool MultiLine
340 return (bool)GetValue(MultiLineProperty);
344 SetValue(MultiLineProperty, value);
345 NotifyPropertyChanged();
350 /// The HorizontalAlignment property.<br />
351 /// The line horizontal alignment.<br />
353 /// <since_tizen> 3 </since_tizen>
354 public HorizontalAlignment HorizontalAlignment
358 return (HorizontalAlignment)GetValue(HorizontalAlignmentProperty);
362 SetValue(HorizontalAlignmentProperty, value);
363 NotifyPropertyChanged();
368 /// The VerticalAlignment property.<br />
369 /// The line vertical alignment.<br />
371 /// <since_tizen> 3 </since_tizen>
372 public VerticalAlignment VerticalAlignment
376 return (VerticalAlignment)GetValue(VerticalAlignmentProperty);
380 SetValue(VerticalAlignmentProperty, value);
381 NotifyPropertyChanged();
386 /// The TextColor property.<br />
387 /// The color of the text.<br />
388 /// Animation framework can be used to change the color of the text when not using mark up.<br />
389 /// Cannot animate the color when text is auto scrolling.<br />
392 /// The property cascade chaining set is possible. For example, this (textLabel.TextColor.X = 0.1f;) is possible.
394 /// <since_tizen> 3 </since_tizen>
395 public Color TextColor
399 Color temp = (Color)GetValue(TextColorProperty);
400 return new Color(OnTextColorChanged, temp.R, temp.G, temp.B, temp.A);
404 SetValue(TextColorProperty, value);
405 NotifyPropertyChanged();
410 /// The ShadowOffset property.<br />
411 /// The drop shadow offset 0 indicates no shadow.<br />
413 /// <since_tizen> 3 </since_tizen>
415 /// Deprecated.(API Level 6) Use Shadow instead.
416 /// The property cascade chaining set is possible. For example, this (textLabel.ShadowOffset.X = 0.1f;) is possible.
418 [Obsolete("Please do not use this ShadowOffset(Deprecated). Please use Shadow instead.")]
419 public Vector2 ShadowOffset
423 return GetValue(ShadowOffsetProperty) as Vector2;
427 SetValue(ShadowOffsetProperty, value);
431 private Vector2 InternalShadowOffset
435 Vector2 shadowOffset = new Vector2();
436 Shadow.Find(TextLabel.Property.SHADOW, "offset")?.Get(shadowOffset);
437 return new Vector2(OnShadowOffsetChanged, shadowOffset.X, shadowOffset.Y);
441 PropertyMap temp = new PropertyMap();
442 temp.Insert("offset", new PropertyValue(value));
444 PropertyMap shadowMap = Shadow;
445 shadowMap.Merge(temp);
447 SetValue(ShadowProperty, shadowMap);
448 NotifyPropertyChanged();
453 /// The ShadowColor property.<br />
454 /// The color of a drop shadow.<br />
456 /// <since_tizen> 3 </since_tizen>
458 /// Deprecated.(API Level 6) Use Shadow instead.
459 /// The property cascade chaining set is possible. For example, this (textLabel.ShadowColor.X = 0.1f;) is possible.
461 [Obsolete("Please do not use this ShadowColor(Deprecated). Please use Shadow instead.")]
462 public Vector4 ShadowColor
466 return GetValue(ShadowColorProperty) as Vector4;
470 SetValue(ShadowColorProperty, value);
474 private Vector4 InternalShadowColor
478 Vector4 shadowColor = new Vector4();
479 Shadow.Find(TextLabel.Property.SHADOW, "color")?.Get(shadowColor);
480 return new Vector4(OnShadowColorChanged, shadowColor.X, shadowColor.Y, shadowColor.Z, shadowColor.W);
484 PropertyMap temp = new PropertyMap();
485 temp.Insert("color", new PropertyValue(value));
487 PropertyMap shadowMap = Shadow;
488 shadowMap.Merge(temp);
490 SetValue(ShadowProperty, shadowMap);
491 NotifyPropertyChanged();
496 /// The UnderlineEnabled property.<br />
497 /// The underline enabled flag.<br />
499 /// <since_tizen> 3 </since_tizen>
501 /// Deprecated.(API Level 6) Use Underline instead.
503 [Obsolete("Please do not use this UnderlineEnabled(Deprecated). Please use Underline instead.")]
504 public bool UnderlineEnabled
508 return (bool)GetValue(UnderlineEnabledProperty);
512 SetValue(UnderlineEnabledProperty, value);
516 private bool InternalUnderlineEnabled
520 bool underlineEnabled = false;
521 Underline.Find(TextLabel.Property.UNDERLINE, "enable")?.Get(out underlineEnabled);
522 return underlineEnabled;
526 PropertyMap temp = new PropertyMap();
527 temp.Add("enable", new PropertyValue(value));
529 PropertyMap undelineMap = Underline;
530 undelineMap.Merge(temp);
532 SetValue(UnderlineProperty, undelineMap);
533 NotifyPropertyChanged();
539 /// The UnderlineColor property.<br />
540 /// Overrides the underline height from font metrics.<br />
542 /// <since_tizen> 3 </since_tizen>
544 /// Deprecated.(API Level 6) Use Underline instead.
545 /// The property cascade chaining set is possible. For example, this (textLabel.UnderlineColor.X = 0.1f;) is possible.
547 [Obsolete("Please do not use this UnderlineColor(Deprecated). Please use Underline instead.")]
548 public Vector4 UnderlineColor
552 return GetValue(UnderlineColorProperty) as Vector4;
556 SetValue(UnderlineColorProperty, value);
560 private Vector4 InternalUnderlineColor
564 Vector4 underlineColor = new Vector4();
565 Underline.Find(TextLabel.Property.UNDERLINE, "color")?.Get(underlineColor);
566 return new Vector4(OnUnderlineColorChanged, underlineColor.X, underlineColor.Y, underlineColor.Z, underlineColor.W);
570 PropertyMap temp = new PropertyMap();
571 temp.Insert("color", new PropertyValue(value));
573 PropertyMap undelineMap = Underline;
574 undelineMap.Merge(temp);
576 SetValue(UnderlineProperty, undelineMap);
577 NotifyPropertyChanged();
582 /// The UnderlineHeight property.<br />
583 /// Overrides the underline height from font metrics.<br />
585 /// <since_tizen> 3 </since_tizen>
587 /// Deprecated.(API Level 6) Use Underline instead.
589 [Obsolete("Please do not use this UnderlineHeight(Deprecated). Please use Underline instead.")]
590 public float UnderlineHeight
594 return (float)GetValue(UnderlineHeightProperty);
598 SetValue(UnderlineHeightProperty, value);
602 private float InternalUnderlineHeight
606 float underlineHeight = 0.0f;
607 Underline.Find(TextLabel.Property.UNDERLINE, "height")?.Get(out underlineHeight);
608 return underlineHeight;
612 PropertyMap temp = new PropertyMap();
613 temp.Insert("height", new PropertyValue(value));
615 PropertyMap undelineMap = Underline;
616 undelineMap.Merge(temp);
618 SetValue(UnderlineProperty, undelineMap);
619 NotifyPropertyChanged();
624 /// The EnableMarkup property.<br />
625 /// Whether the mark-up processing is enabled.<br />
627 /// <since_tizen> 3 </since_tizen>
628 public bool EnableMarkup
632 return (bool)GetValue(EnableMarkupProperty);
636 SetValue(EnableMarkupProperty, value);
637 NotifyPropertyChanged();
642 /// The EnableAutoScroll property.<br />
643 /// Starts or stops auto scrolling.<br />
645 /// <since_tizen> 3 </since_tizen>
646 public bool EnableAutoScroll
650 return (bool)GetValue(EnableAutoScrollProperty);
654 SetValue(EnableAutoScrollProperty, value);
655 NotifyPropertyChanged();
660 /// The AutoScrollSpeed property.<br />
661 /// Sets the speed of scrolling in pixels per second.<br />
663 /// <since_tizen> 3 </since_tizen>
664 public int AutoScrollSpeed
668 return (int)GetValue(AutoScrollSpeedProperty);
672 SetValue(AutoScrollSpeedProperty, value);
673 NotifyPropertyChanged();
678 /// The AutoScrollLoopCount property.<br />
679 /// Number of complete loops when scrolling enabled.<br />
681 /// <since_tizen> 3 </since_tizen>
682 public int AutoScrollLoopCount
686 return (int)GetValue(AutoScrollLoopCountProperty);
690 SetValue(AutoScrollLoopCountProperty, value);
691 NotifyPropertyChanged();
696 /// The AutoScrollGap property.<br />
697 /// Gap before scrolling wraps.<br />
699 /// <since_tizen> 3 </since_tizen>
700 public float AutoScrollGap
704 return (float)GetValue(AutoScrollGapProperty);
708 SetValue(AutoScrollGapProperty, value);
709 NotifyPropertyChanged();
714 /// The LineSpacing property.<br />
715 /// The default extra space between lines in points.<br />
717 /// <since_tizen> 3 </since_tizen>
718 public float LineSpacing
722 return (float)GetValue(LineSpacingProperty);
726 SetValue(LineSpacingProperty, value);
727 NotifyPropertyChanged();
732 /// The Underline property.<br />
733 /// The default underline parameters.<br />
734 /// The underline map contains the following keys :<br />
735 /// <list type="table">
736 /// <item><term>enable (bool)</term><description>Whether the underline is enabled (the default value is false)</description></item>
737 /// <item><term>color (Color)</term><description>The color of the underline (If not provided then the color of the text is used)</description></item>
738 /// <item><term>height (float)</term><description>The height in pixels of the underline (the default value is 1.f)</description></item>
741 /// <since_tizen> 3 </since_tizen>
742 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1721: Property names should not match get methods")]
743 public PropertyMap Underline
747 return (PropertyMap)GetValue(UnderlineProperty);
751 SetValue(UnderlineProperty, value);
752 NotifyPropertyChanged();
757 /// Set Underline to TextLabel. <br />
759 /// <param name="underline">The Underline</param>
761 /// SetUnderline specifies the underline of the text through <see cref="Tizen.NUI.Text.Underline"/>. <br />
764 /// The following example demonstrates how to use the SetUnderline method.
766 /// var underline = new Tizen.NUI.Text.Underline();
767 /// underline.Enable = true;
768 /// underline.Color = new Color("#3498DB");
769 /// underline.Height = 2.0f;
770 /// label.SetUnderline(underline);
773 [EditorBrowsable(EditorBrowsableState.Never)]
774 public void SetUnderline(Underline underline)
776 SetValue(UnderlineProperty, TextMapHelper.GetUnderlineMap(underline));
780 /// Get Underline from TextLabel. <br />
782 /// <returns>The Underline</returns>
784 /// <see cref="Tizen.NUI.Text.Underline"/>
786 [EditorBrowsable(EditorBrowsableState.Never)]
787 public Underline GetUnderline()
789 return TextMapHelper.GetUnderlineStruct((PropertyMap)GetValue(UnderlineProperty));
793 /// The Shadow property.<br />
794 /// The default shadow parameters.<br />
795 /// The shadow map contains the following keys :<br />
796 /// <list type="table">
797 /// <item><term>color (Color)</term><description>The color of the shadow (the default color is Color.Black)</description></item>
798 /// <item><term>offset (Vector2)</term><description>The offset in pixels of the shadow (If not provided then the shadow is not enabled)</description></item>
799 /// <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>
802 /// <since_tizen> 3 </since_tizen>
803 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1721: Property names should not match get methods")]
804 public PropertyMap Shadow
808 return (PropertyMap)GetValue(ShadowProperty);
812 SetValue(ShadowProperty, value);
813 NotifyPropertyChanged();
818 /// Set Shadow to TextLabel. <br />
820 /// <param name="shadow">The Shadow</param>
822 /// SetShadow specifies the shadow of the text through <see cref="Tizen.NUI.Text.Shadow"/>. <br />
825 /// The following example demonstrates how to use the SetShadow method.
827 /// var shadow = new Tizen.NUI.Text.Shadow();
828 /// shadow.Offset = new Vector2(3, 3);
829 /// shadow.Color = new Color("#F1C40F");
830 /// shadow.BlurRadius = 4.0f;
831 /// label.SetShadow(shadow);
834 [EditorBrowsable(EditorBrowsableState.Never)]
835 public void SetShadow(Tizen.NUI.Text.Shadow shadow)
837 SetValue(ShadowProperty, TextMapHelper.GetShadowMap(shadow));
841 /// Get Shadow from TextLabel. <br />
843 /// <returns>The Shadow</returns>
845 /// <see cref="Tizen.NUI.Text.Shadow"/>
847 [EditorBrowsable(EditorBrowsableState.Never)]
848 public Tizen.NUI.Text.Shadow GetShadow()
850 return TextMapHelper.GetShadowStruct((PropertyMap)GetValue(ShadowProperty));
854 /// Describes a text shadow for a TextLabel.
855 /// It is null by default.
857 [EditorBrowsable(EditorBrowsableState.Never)]
858 public TextShadow TextShadow
862 return (TextShadow)GetValue(TextShadowProperty);
866 SetValue(TextShadowProperty, value);
867 NotifyPropertyChanged();
872 /// The Emboss property.<br />
873 /// The default emboss parameters.<br />
875 /// <since_tizen> 3 </since_tizen>
880 return (string)GetValue(EmbossProperty);
884 SetValue(EmbossProperty, value);
885 NotifyPropertyChanged();
890 /// The Outline property.<br />
891 /// The default outline parameters.<br />
892 /// The outline map contains the following keys :<br />
893 /// <list type="table">
894 /// <item><term>color (Color)</term><description>The color of the outline (the default color is Color.White)</description></item>
895 /// <item><term>width (float)</term><description>The width in pixels of the outline (If not provided then the outline is not enabled)</description></item>
898 /// <since_tizen> 3 </since_tizen>
899 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1721: Property names should not match get methods")]
900 public PropertyMap Outline
904 return (PropertyMap)GetValue(OutlineProperty);
908 SetValue(OutlineProperty, value);
909 NotifyPropertyChanged();
914 /// Set Outline to TextLabel. <br />
916 /// <param name="outline">The Outline</param>
918 /// SetOutline specifies the outline of the text through <see cref="Tizen.NUI.Text.Outline"/>. <br />
921 /// The following example demonstrates how to use the SetOutline method.
923 /// var outline = new Tizen.NUI.Text.Outline();
924 /// outline.Width = 2.0f;
925 /// outline.Color = new Color("#45B39D");
926 /// label.SetOutline(outline);
929 [EditorBrowsable(EditorBrowsableState.Never)]
930 public void SetOutline(Outline outline)
932 SetValue(OutlineProperty, TextMapHelper.GetOutlineMap(outline));
936 /// Get Outline from TextLabel. <br />
938 /// <returns>The Outline</returns>
940 /// <see cref="Tizen.NUI.Text.Outline"/>
942 [EditorBrowsable(EditorBrowsableState.Never)]
943 public Outline GetOutline()
945 return TextMapHelper.GetOutlineStruct((PropertyMap)GetValue(OutlineProperty));
949 /// The PixelSize property.<br />
950 /// The size of font in pixels.<br />
952 /// <since_tizen> 3 </since_tizen>
953 public float PixelSize
957 return (float)GetValue(PixelSizeProperty);
961 SetValue(PixelSizeProperty, value);
962 NotifyPropertyChanged();
967 /// The Ellipsis property.<br />
968 /// Enable or disable the ellipsis.<br />
970 /// <since_tizen> 3 </since_tizen>
975 return (bool)GetValue(EllipsisProperty);
979 SetValue(EllipsisProperty, value);
980 NotifyPropertyChanged();
985 /// The ellipsis position of the text.
986 /// Specifies which portion of the text should be replaced with an ellipsis when the text size exceeds the layout size.<br />
988 /// <since_tizen> 9 </since_tizen>
989 public EllipsisPosition EllipsisPosition
993 return (EllipsisPosition)GetValue(EllipsisPositionProperty);
997 SetValue(EllipsisPositionProperty, value);
998 NotifyPropertyChanged();
1003 /// The AutoScrollLoopDelay property.<br />
1004 /// The amount of time to delay the starting time of auto scrolling and further loops.<br />
1006 /// <since_tizen> 3 </since_tizen>
1007 public float AutoScrollLoopDelay
1011 return (float)GetValue(AutoScrollLoopDelayProperty);
1015 SetValue(AutoScrollLoopDelayProperty, value);
1016 NotifyPropertyChanged();
1021 /// The AutoScrollStopMode property.<br />
1022 /// The auto scrolling stop behaviour.<br />
1023 /// The default value is AutoScrollStopMode.FinishLoop. <br />
1025 /// <since_tizen> 3 </since_tizen>
1026 public AutoScrollStopMode AutoScrollStopMode
1030 return (AutoScrollStopMode)GetValue(AutoScrollStopModeProperty);
1034 SetValue(AutoScrollStopModeProperty, value);
1035 NotifyPropertyChanged();
1040 /// The line count of the text.
1042 /// <since_tizen> 3 </since_tizen>
1043 public int LineCount
1048 GetProperty(TextLabel.Property.LineCount).Get(out temp);
1054 /// The LineWrapMode property.<br />
1055 /// line wrap mode when the text lines over layout width.<br />
1057 /// <since_tizen> 4 </since_tizen>
1058 public LineWrapMode LineWrapMode
1062 return (LineWrapMode)GetValue(LineWrapModeProperty);
1066 SetValue(LineWrapModeProperty, value);
1067 NotifyPropertyChanged();
1072 /// The direction of the text such as left to right or right to left.
1074 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
1075 [EditorBrowsable(EditorBrowsableState.Never)]
1076 public TextDirection TextDirection
1081 GetProperty(TextLabel.Property.TextDirection).Get(out temp);
1082 return (TextDirection)temp;
1087 /// The vertical line alignment of the text.
1089 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
1090 [EditorBrowsable(EditorBrowsableState.Never)]
1091 public VerticalLineAlignment VerticalLineAlignment
1095 return (VerticalLineAlignment)GetValue(VerticalLineAlignmentProperty);
1099 SetValue(VerticalLineAlignmentProperty, value);
1100 NotifyPropertyChanged();
1105 /// The text alignment to match the direction of the system language.
1107 /// <since_tizen> 6 </since_tizen>
1108 public bool MatchSystemLanguageDirection
1112 return (bool)GetValue(MatchSystemLanguageDirectionProperty);
1116 SetValue(MatchSystemLanguageDirectionProperty, value);
1117 NotifyPropertyChanged();
1122 /// The text fit parameters.<br />
1123 /// The textFit map contains the following keys :<br />
1124 /// <list type="table">
1125 /// <item><term>enable (bool)</term><description>True to enable the text fit or false to disable (the default value is false)</description></item>
1126 /// <item><term>minSize (float)</term><description>Minimum Size for text fit (the default value is 10.f)</description></item>
1127 /// <item><term>maxSize (float)</term><description>Maximum Size for text fit (the default value is 100.f)</description></item>
1128 /// <item><term>stepSize (float)</term><description>Step Size for font increase (the default value is 1.f)</description></item>
1129 /// <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>
1132 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
1133 [EditorBrowsable(EditorBrowsableState.Never)]
1134 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1721: Property names should not match get methods")]
1135 public PropertyMap TextFit
1139 return (PropertyMap)GetValue(TextFitProperty);
1143 SetValue(TextFitProperty, value);
1144 NotifyPropertyChanged();
1149 /// Set TextFit to TextLabel. <br />
1151 /// <param name="textFit">The TextFit</param>
1153 /// SetTextFit specifies the textFit of the text through <see cref="Tizen.NUI.Text.TextFit"/>. <br />
1156 /// The following example demonstrates how to use the SetTextFit method.
1158 /// var textFit = new Tizen.NUI.Text.TextFit();
1159 /// textFit.Enable = true;
1160 /// textFit.MinSize = 10.0f;
1161 /// textFit.MaxSize = 100.0f;
1162 /// textFit.StepSize = 5.0f;
1163 /// textFit.FontSizeType = FontSizeType.PointSize;
1164 /// label.SetTextFit(textFit);
1167 [EditorBrowsable(EditorBrowsableState.Never)]
1168 public void SetTextFit(TextFit textFit)
1170 SetValue(TextFitProperty, TextMapHelper.GetTextFitMap(textFit));
1174 /// Get TextFit from TextLabel. <br />
1176 /// <returns>The TextFit</returns>
1178 /// TextFit is always returned based on PointSize. <br />
1179 /// If the user sets FontSizeType to PixelSize, then MinSize, MaxSize, and StepSize are converted based on PointSize and returned. <br />
1180 /// <see cref="Tizen.NUI.Text.TextFit"/>
1182 [EditorBrowsable(EditorBrowsableState.Never)]
1183 public TextFit GetTextFit()
1185 return TextMapHelper.GetTextFitStruct((PropertyMap)GetValue(TextFitProperty));
1189 /// The MinLineSize property.<br />
1190 /// The height of the line in points. <br />
1191 /// If the font size is larger than the line size, it works with the font size. <br />
1193 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
1194 [EditorBrowsable(EditorBrowsableState.Never)]
1195 public float MinLineSize
1199 return (float)GetValue(MinLineSizeProperty);
1203 SetValue(MinLineSizeProperty, value);
1204 NotifyPropertyChanged();
1209 /// The FontSizeScale property for scaling the specified font size up or down. <br />
1210 /// The default value is 1.0. <br />
1211 /// The given font size scale value is used for multiplying the specified font size before querying fonts. <br />
1212 /// If FontSizeScale.UseSystemSetting, will use the SystemSettings.FontSize internally. <br />
1214 /// <since_tizen> 9 </since_tizen>
1215 public float FontSizeScale
1219 return fontSizeScale;
1223 float newFontSizeScale;
1225 if (fontSizeScale == value) return;
1227 fontSizeScale = value;
1228 if (fontSizeScale == Tizen.NUI.FontSizeScale.UseSystemSetting)
1230 SystemSettingsFontSize systemSettingsFontSize;
1234 systemSettingsFontSize = SystemSettings.FontSize;
1238 Console.WriteLine("{0} Exception caught.", e);
1239 systemSettingsFontSize = SystemSettingsFontSize.Normal;
1241 newFontSizeScale = TextUtils.GetFontSizeScale(systemSettingsFontSize);
1242 addFontSizeChangedCallback();
1246 newFontSizeScale = fontSizeScale;
1247 removeFontSizeChangedCallback();
1250 SetValue(FontSizeScaleProperty, newFontSizeScale);
1251 NotifyPropertyChanged();
1255 private TextLabelSelectorData EnsureSelectorData() => selectorData ?? (selectorData = new TextLabelSelectorData());
1258 /// Downcasts a handle to textLabel handle
1260 /// <param name="handle"></param>
1261 /// <returns></returns>
1262 /// <exception cref="ArgumentNullException"> Thrown when handle is null. </exception>
1263 /// <since_tizen> 3 </since_tizen>
1264 /// Please do not use! this will be deprecated!
1265 /// Instead please use as keyword.
1266 [Obsolete("Please do not use! This will be deprecated! Please use as keyword instead! " +
1268 "BaseHandle handle = new TextLabel(\"Hello World!\"); " +
1269 "TextLabel label = handle as TextLabel")]
1270 [EditorBrowsable(EditorBrowsableState.Never)]
1271 public static TextLabel DownCast(BaseHandle handle)
1275 throw new ArgumentNullException(nameof(handle));
1277 TextLabel ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as TextLabel;
1278 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1283 [EditorBrowsable(EditorBrowsableState.Never)]
1284 protected override void Dispose(DisposeTypes type)
1291 if (systemlangTextFlag)
1293 SystemSettings.LocaleLanguageChanged -= SystemSettings_LocaleLanguageChanged;
1296 removeFontSizeChangedCallback();
1298 if (type == DisposeTypes.Explicit)
1301 //Release your own managed resources here.
1302 //You should release all of your own disposable objects here.
1303 selectorData?.Reset(this);
1308 if (textLabelTextFitChangedCallbackDelegate != null)
1310 TextFitChangedSignal().Disconnect(textLabelTextFitChangedCallbackDelegate);
1317 /// This will not be public opened.
1318 [EditorBrowsable(EditorBrowsableState.Never)]
1319 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1321 Interop.TextLabel.DeleteTextLabel(swigCPtr);
1325 /// Get attribues, it is abstract function and must be override.
1327 [EditorBrowsable(EditorBrowsableState.Never)]
1328 protected override ViewStyle CreateViewStyle()
1330 return new TextLabelStyle();
1333 internal override LayoutItem CreateDefaultLayout()
1335 return new TextLayout();
1339 /// Invoked whenever the binding context of the textlabel changes. Implement this method to add class handling for this event.
1341 protected override void OnBindingContextChanged()
1343 base.OnBindingContextChanged();
1346 private void SystemSettings_LocaleLanguageChanged(object sender, LocaleLanguageChangedEventArgs e)
1348 Text = NUIApplication.MultilingualResourceManager?.GetString(textLabelSid, new CultureInfo(e.Value.Replace("_", "-")));
1351 private void SystemSettingsFontSizeChanged(object sender, FontSizeChangedEventArgs e)
1353 float newFontSizeScale = TextUtils.GetFontSizeScale(e.Value);
1354 SetValue(FontSizeScaleProperty, newFontSizeScale);
1357 private void addFontSizeChangedCallback()
1359 if (hasFontSizeChangedCallback != true)
1363 SystemSettings.FontSizeChanged += SystemSettingsFontSizeChanged;
1364 hasFontSizeChangedCallback = true;
1368 Console.WriteLine("{0} Exception caught.", e);
1369 hasFontSizeChangedCallback = false;
1374 private void removeFontSizeChangedCallback()
1376 if (hasFontSizeChangedCallback == true)
1380 SystemSettings.FontSizeChanged -= SystemSettingsFontSizeChanged;
1381 hasFontSizeChangedCallback = false;
1385 Console.WriteLine("{0} Exception caught.", e);
1386 hasFontSizeChangedCallback = true;
1391 private void RequestLayout()
1393 Layout?.RequestLayout();
1396 internal new class Property
1398 internal static readonly int TEXT = Interop.TextLabel.TextGet();
1399 internal static readonly int FontFamily = Interop.TextLabel.FontFamilyGet();
1400 internal static readonly int FontStyle = Interop.TextLabel.FontStyleGet();
1401 internal static readonly int PointSize = Interop.TextLabel.PointSizeGet();
1402 internal static readonly int MultiLine = Interop.TextLabel.MultiLineGet();
1403 internal static readonly int HorizontalAlignment = Interop.TextLabel.HorizontalAlignmentGet();
1404 internal static readonly int VerticalAlignment = Interop.TextLabel.VerticalAlignmentGet();
1405 internal static readonly int TextColor = Interop.TextLabel.TextColorGet();
1406 internal static readonly int EnableMarkup = Interop.TextLabel.EnableMarkupGet();
1407 internal static readonly int EnableAutoScroll = Interop.TextLabel.EnableAutoScrollGet();
1408 internal static readonly int AutoScrollSpeed = Interop.TextLabel.AutoScrollSpeedGet();
1409 internal static readonly int AutoScrollLoopCount = Interop.TextLabel.AutoScrollLoopCountGet();
1410 internal static readonly int AutoScrollGap = Interop.TextLabel.AutoScrollGapGet();
1411 internal static readonly int LineSpacing = Interop.TextLabel.LineSpacingGet();
1412 internal static readonly int UNDERLINE = Interop.TextLabel.UnderlineGet();
1413 internal static readonly int SHADOW = Interop.TextLabel.ShadowGet();
1414 internal static readonly int EMBOSS = Interop.TextLabel.EmbossGet();
1415 internal static readonly int OUTLINE = Interop.TextLabel.OutlineGet();
1416 internal static readonly int PixelSize = Interop.TextLabel.PixelSizeGet();
1417 internal static readonly int ELLIPSIS = Interop.TextLabel.EllipsisGet();
1418 internal static readonly int AutoScrollStopMode = Interop.TextLabel.AutoScrollStopModeGet();
1419 internal static readonly int AutoScrollLoopDelay = Interop.TextLabel.AutoScrollLoopDelayGet();
1420 internal static readonly int LineCount = Interop.TextLabel.LineCountGet();
1421 internal static readonly int LineWrapMode = Interop.TextLabel.LineWrapModeGet();
1422 internal static readonly int TextDirection = Interop.TextLabel.TextDirectionGet();
1423 internal static readonly int VerticalLineAlignment = Interop.TextLabel.VerticalLineAlignmentGet();
1424 internal static readonly int MatchSystemLanguageDirection = Interop.TextLabel.MatchSystemLanguageDirectionGet();
1425 internal static readonly int TextFit = Interop.TextLabel.TextFitGet();
1426 internal static readonly int MinLineSize = Interop.TextLabel.MinLineSizeGet();
1427 internal static readonly int FontSizeScale = Interop.TextLabel.FontSizeScaleGet();
1428 internal static readonly int EllipsisPosition = Interop.TextLabel.EllipsisPositionGet();
1431 private void OnShadowColorChanged(float x, float y, float z, float w)
1433 ShadowColor = new Vector4(x, y, z, w);
1435 private void OnShadowOffsetChanged(float x, float y)
1437 ShadowOffset = new Vector2(x, y);
1439 private void OnTextColorChanged(float r, float g, float b, float a)
1441 TextColor = new Color(r, g, b, a);
1443 private void OnUnderlineColorChanged(float x, float y, float z, float w)
1445 UnderlineColor = new Vector4(x, y, z, w);