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 public PropertyMap FontStyle
275 return (PropertyMap)GetValue(FontStyleProperty);
279 SetValue(FontStyleProperty, value);
280 NotifyPropertyChanged();
285 /// Set FontStyle to TextLabel. <br />
287 /// <param name="fontStyle">The FontStyle</param>
289 /// SetFontStyle specifies the requested font style through <see cref="Tizen.NUI.Text.FontStyle"/>. <br />
292 /// The following example demonstrates how to use the SetFontStyle method.
294 /// var fontStyle = new Tizen.NUI.Text.FontStyle();
295 /// fontStyle.Width = FontWidthType.Expanded;
296 /// fontStyle.Weight = FontWeightType.Bold;
297 /// fontStyle.Slant = FontSlantType.Italic;
298 /// label.SetFontStyle(fontStyle);
301 [EditorBrowsable(EditorBrowsableState.Never)]
302 public void SetFontStyle(FontStyle fontStyle)
304 SetProperty(TextLabel.Property.FontStyle, new PropertyValue(TextUtils.GetFontStyleMap(fontStyle)));
308 /// Get FontStyle from TextLabel. <br />
310 /// <returns>The FontStyle</returns>
312 /// <see cref="Tizen.NUI.Text.FontStyle"/>
314 [EditorBrowsable(EditorBrowsableState.Never)]
315 public FontStyle GetFontStyle()
317 var map = new PropertyMap();
318 GetProperty(TextLabel.Property.FontStyle).Get(map);
319 return TextUtils.GetFontStyleStruct(map);
323 /// The PointSize property.<br />
324 /// The size of font in points.<br />
326 /// <since_tizen> 3 </since_tizen>
327 public float PointSize
331 return (float)GetValue(PointSizeProperty);
335 SetValue(PointSizeProperty, value);
336 NotifyPropertyChanged();
341 /// The MultiLine property.<br />
342 /// The single-line or multi-line layout option.<br />
344 /// <since_tizen> 3 </since_tizen>
345 public bool MultiLine
349 return (bool)GetValue(MultiLineProperty);
353 SetValue(MultiLineProperty, value);
354 NotifyPropertyChanged();
359 /// The HorizontalAlignment property.<br />
360 /// The line horizontal alignment.<br />
362 /// <since_tizen> 3 </since_tizen>
363 public HorizontalAlignment HorizontalAlignment
367 return (HorizontalAlignment)GetValue(HorizontalAlignmentProperty);
371 SetValue(HorizontalAlignmentProperty, value);
372 NotifyPropertyChanged();
377 /// The VerticalAlignment property.<br />
378 /// The line vertical alignment.<br />
380 /// <since_tizen> 3 </since_tizen>
381 public VerticalAlignment VerticalAlignment
385 return (VerticalAlignment)GetValue(VerticalAlignmentProperty);
389 SetValue(VerticalAlignmentProperty, value);
390 NotifyPropertyChanged();
395 /// The TextColor property.<br />
396 /// The color of the text.<br />
397 /// Animation framework can be used to change the color of the text when not using mark up.<br />
398 /// Cannot animate the color when text is auto scrolling.<br />
401 /// The property cascade chaining set is possible. For example, this (textLabel.TextColor.X = 0.1f;) is possible.
403 /// <since_tizen> 3 </since_tizen>
404 public Color TextColor
408 Color temp = (Color)GetValue(TextColorProperty);
409 return new Color(OnTextColorChanged, temp.R, temp.G, temp.B, temp.A);
413 SetValue(TextColorProperty, value);
414 NotifyPropertyChanged();
419 /// The ShadowOffset property.<br />
420 /// The drop shadow offset 0 indicates no shadow.<br />
422 /// <since_tizen> 3 </since_tizen>
424 /// Deprecated.(API Level 6) Use Shadow instead.
425 /// The property cascade chaining set is possible. For example, this (textLabel.ShadowOffset.X = 0.1f;) is possible.
427 [Obsolete("Please do not use this ShadowOffset(Deprecated). Please use Shadow instead.")]
428 public Vector2 ShadowOffset
432 Vector2 shadowOffset = new Vector2();
433 Shadow.Find(TextLabel.Property.SHADOW, "offset")?.Get(shadowOffset);
434 return new Vector2(OnShadowOffsetChanged, shadowOffset.X, shadowOffset.Y);
438 PropertyMap temp = new PropertyMap();
439 temp.Insert("offset", new PropertyValue(value));
441 PropertyMap shadowMap = Shadow;
442 shadowMap.Merge(temp);
444 SetValue(ShadowProperty, shadowMap);
445 NotifyPropertyChanged();
450 /// The ShadowColor property.<br />
451 /// The color of a drop shadow.<br />
453 /// <since_tizen> 3 </since_tizen>
455 /// Deprecated.(API Level 6) Use Shadow instead.
456 /// The property cascade chaining set is possible. For example, this (textLabel.ShadowColor.X = 0.1f;) is possible.
458 [Obsolete("Please do not use this ShadowColor(Deprecated). Please use Shadow instead.")]
459 public Vector4 ShadowColor
463 Vector4 shadowColor = new Vector4();
464 Shadow.Find(TextLabel.Property.SHADOW, "color")?.Get(shadowColor);
465 return new Vector4(OnShadowColorChanged, shadowColor.X, shadowColor.Y, shadowColor.Z, shadowColor.W);
469 PropertyMap temp = new PropertyMap();
470 temp.Insert("color", new PropertyValue(value));
472 PropertyMap shadowMap = Shadow;
473 shadowMap.Merge(temp);
475 SetValue(ShadowProperty, shadowMap);
476 NotifyPropertyChanged();
481 /// The UnderlineEnabled property.<br />
482 /// The underline enabled flag.<br />
484 /// <since_tizen> 3 </since_tizen>
486 /// Deprecated.(API Level 6) Use Underline instead.
488 [Obsolete("Please do not use this UnderlineEnabled(Deprecated). Please use Underline instead.")]
489 public bool UnderlineEnabled
493 bool underlineEnabled = false;
494 Underline.Find(TextLabel.Property.UNDERLINE, "enable")?.Get(out underlineEnabled);
495 return underlineEnabled;
499 PropertyMap temp = new PropertyMap();
500 temp.Add("enable", new PropertyValue(value));
502 PropertyMap undelineMap = Underline;
503 undelineMap.Merge(temp);
505 SetValue(UnderlineProperty, undelineMap);
506 NotifyPropertyChanged();
512 /// The UnderlineColor property.<br />
513 /// Overrides the underline height from font metrics.<br />
515 /// <since_tizen> 3 </since_tizen>
517 /// Deprecated.(API Level 6) Use Underline instead.
518 /// The property cascade chaining set is possible. For example, this (textLabel.UnderlineColor.X = 0.1f;) is possible.
520 [Obsolete("Please do not use this UnderlineColor(Deprecated). Please use Underline instead.")]
521 public Vector4 UnderlineColor
525 Vector4 underlineColor = new Vector4();
526 Underline.Find(TextLabel.Property.UNDERLINE, "color")?.Get(underlineColor);
527 return new Vector4(OnUnderlineColorChanged, underlineColor.X, underlineColor.Y, underlineColor.Z, underlineColor.W);
531 PropertyMap temp = new PropertyMap();
532 temp.Insert("color", new PropertyValue(value));
534 PropertyMap undelineMap = Underline;
535 undelineMap.Merge(temp);
537 SetValue(UnderlineProperty, undelineMap);
538 NotifyPropertyChanged();
543 /// The UnderlineHeight property.<br />
544 /// Overrides the underline height from font metrics.<br />
546 /// <since_tizen> 3 </since_tizen>
548 /// Deprecated.(API Level 6) Use Underline instead.
550 [Obsolete("Please do not use this UnderlineHeight(Deprecated). Please use Underline instead.")]
551 public float UnderlineHeight
555 float underlineHeight = 0.0f;
556 Underline.Find(TextLabel.Property.UNDERLINE, "height")?.Get(out underlineHeight);
557 return underlineHeight;
561 PropertyMap temp = new PropertyMap();
562 temp.Insert("height", new PropertyValue(value));
564 PropertyMap undelineMap = Underline;
565 undelineMap.Merge(temp);
567 SetValue(UnderlineProperty, undelineMap);
568 NotifyPropertyChanged();
573 /// The EnableMarkup property.<br />
574 /// Whether the mark-up processing is enabled.<br />
576 /// <since_tizen> 3 </since_tizen>
577 public bool EnableMarkup
581 return (bool)GetValue(EnableMarkupProperty);
585 SetValue(EnableMarkupProperty, value);
586 NotifyPropertyChanged();
591 /// The EnableAutoScroll property.<br />
592 /// Starts or stops auto scrolling.<br />
594 /// <since_tizen> 3 </since_tizen>
595 public bool EnableAutoScroll
599 return (bool)GetValue(EnableAutoScrollProperty);
603 SetValue(EnableAutoScrollProperty, value);
604 NotifyPropertyChanged();
609 /// The AutoScrollSpeed property.<br />
610 /// Sets the speed of scrolling in pixels per second.<br />
612 /// <since_tizen> 3 </since_tizen>
613 public int AutoScrollSpeed
617 return (int)GetValue(AutoScrollSpeedProperty);
621 SetValue(AutoScrollSpeedProperty, value);
622 NotifyPropertyChanged();
627 /// The AutoScrollLoopCount property.<br />
628 /// Number of complete loops when scrolling enabled.<br />
630 /// <since_tizen> 3 </since_tizen>
631 public int AutoScrollLoopCount
635 return (int)GetValue(AutoScrollLoopCountProperty);
639 SetValue(AutoScrollLoopCountProperty, value);
640 NotifyPropertyChanged();
645 /// The AutoScrollGap property.<br />
646 /// Gap before scrolling wraps.<br />
648 /// <since_tizen> 3 </since_tizen>
649 public float AutoScrollGap
653 return (float)GetValue(AutoScrollGapProperty);
657 SetValue(AutoScrollGapProperty, value);
658 NotifyPropertyChanged();
663 /// The LineSpacing property.<br />
664 /// The default extra space between lines in points.<br />
666 /// <since_tizen> 3 </since_tizen>
667 public float LineSpacing
671 return (float)GetValue(LineSpacingProperty);
675 SetValue(LineSpacingProperty, value);
676 NotifyPropertyChanged();
681 /// The Underline property.<br />
682 /// The default underline parameters.<br />
683 /// The underline map contains the following keys :<br />
684 /// <list type="table">
685 /// <item><term>enable (bool)</term><description>Whether the underline is enabled (the default value is false)</description></item>
686 /// <item><term>color (Color)</term><description>The color of the underline (If not provided then the color of the text is used)</description></item>
687 /// <item><term>height (float)</term><description>The height in pixels of the underline (the default value is 1.f)</description></item>
690 /// <since_tizen> 3 </since_tizen>
691 public PropertyMap Underline
695 return (PropertyMap)GetValue(UnderlineProperty);
699 SetValue(UnderlineProperty, value);
700 NotifyPropertyChanged();
705 /// Set Underline to TextLabel. <br />
707 /// <param name="underline">The Underline</param>
709 /// SetUnderline specifies the underline of the text through <see cref="Tizen.NUI.Text.Underline"/>. <br />
712 /// The following example demonstrates how to use the SetUnderline method.
714 /// var underline = new Tizen.NUI.Text.Underline();
715 /// underline.Enable = true;
716 /// underline.Color = new Color("#3498DB");
717 /// underline.Height = 2.0f;
718 /// label.SetUnderline(underline);
721 [EditorBrowsable(EditorBrowsableState.Never)]
722 public void SetUnderline(Underline underline)
724 SetProperty(TextLabel.Property.UNDERLINE, new PropertyValue(TextUtils.GetUnderlineMap(underline)));
728 /// Get Underline from TextLabel. <br />
730 /// <returns>The Underline</returns>
732 /// <see cref="Tizen.NUI.Text.Underline"/>
734 [EditorBrowsable(EditorBrowsableState.Never)]
735 public Underline GetUnderline()
737 var map = new PropertyMap();
738 GetProperty(TextLabel.Property.UNDERLINE).Get(map);
739 return TextUtils.GetUnderlineStruct(map);
743 /// The Shadow property.<br />
744 /// The default shadow parameters.<br />
745 /// The shadow map contains the following keys :<br />
746 /// <list type="table">
747 /// <item><term>color (Color)</term><description>The color of the shadow (the default color is Color.Black)</description></item>
748 /// <item><term>offset (Vector2)</term><description>The offset in pixels of the shadow (If not provided then the shadow is not enabled)</description></item>
749 /// <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>
752 /// <since_tizen> 3 </since_tizen>
753 public PropertyMap Shadow
757 return (PropertyMap)GetValue(ShadowProperty);
761 SetValue(ShadowProperty, value);
762 NotifyPropertyChanged();
767 /// Describes a text shadow for a TextLabel.
768 /// It is null by default.
770 [EditorBrowsable(EditorBrowsableState.Never)]
771 public TextShadow TextShadow
775 return (TextShadow)GetValue(TextShadowProperty);
779 SetValue(TextShadowProperty, value);
780 NotifyPropertyChanged();
785 /// The Emboss property.<br />
786 /// The default emboss parameters.<br />
788 /// <since_tizen> 3 </since_tizen>
793 return (string)GetValue(EmbossProperty);
797 SetValue(EmbossProperty, value);
798 NotifyPropertyChanged();
803 /// The Outline property.<br />
804 /// The default outline parameters.<br />
805 /// The outline map contains the following keys :<br />
806 /// <list type="table">
807 /// <item><term>color (Color)</term><description>The color of the outline (the default color is Color.White)</description></item>
808 /// <item><term>width (float)</term><description>The width in pixels of the outline (If not provided then the outline is not enabled)</description></item>
811 /// <since_tizen> 3 </since_tizen>
812 public PropertyMap Outline
816 return (PropertyMap)GetValue(OutlineProperty);
820 SetValue(OutlineProperty, value);
821 NotifyPropertyChanged();
826 /// The PixelSize property.<br />
827 /// The size of font in pixels.<br />
829 /// <since_tizen> 3 </since_tizen>
830 public float PixelSize
834 return (float)GetValue(PixelSizeProperty);
838 SetValue(PixelSizeProperty, value);
839 NotifyPropertyChanged();
844 /// The Ellipsis property.<br />
845 /// Enable or disable the ellipsis.<br />
847 /// <since_tizen> 3 </since_tizen>
852 return (bool)GetValue(EllipsisProperty);
856 SetValue(EllipsisProperty, value);
857 NotifyPropertyChanged();
862 /// The ellipsis position of the text.
863 /// The ellipsis position type when the text size over the layout size.<br />
864 /// The ellipsis position: End, Start or Middle.<br />
866 [EditorBrowsable(EditorBrowsableState.Never)]
867 public EllipsisPosition EllipsisPosition
871 return (EllipsisPosition)GetValue(EllipsisPositionProperty);
875 SetValue(EllipsisPositionProperty, value);
876 NotifyPropertyChanged();
881 /// The AutoScrollLoopDelay property.<br />
882 /// Do something.<br />
884 /// <since_tizen> 3 </since_tizen>
885 public float AutoScrollLoopDelay
889 return (float)GetValue(AutoScrollLoopDelayProperty);
893 SetValue(AutoScrollLoopDelayProperty, value);
894 NotifyPropertyChanged();
899 /// The AutoScrollStopMode property.<br />
900 /// Do something.<br />
902 /// <since_tizen> 3 </since_tizen>
903 public AutoScrollStopMode AutoScrollStopMode
907 return (AutoScrollStopMode)GetValue(AutoScrollStopModeProperty);
911 SetValue(AutoScrollStopModeProperty, value);
912 NotifyPropertyChanged();
917 /// The line count of the text.
919 /// <since_tizen> 3 </since_tizen>
925 GetProperty(TextLabel.Property.LineCount).Get(out temp);
931 /// The LineWrapMode property.<br />
932 /// line wrap mode when the text lines over layout width.<br />
934 /// <since_tizen> 4 </since_tizen>
935 public LineWrapMode LineWrapMode
939 return (LineWrapMode)GetValue(LineWrapModeProperty);
943 SetValue(LineWrapModeProperty, value);
944 NotifyPropertyChanged();
949 /// The direction of the text such as left to right or right to left.
951 /// <since_tizen> 5 </since_tizen>
952 /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
953 [EditorBrowsable(EditorBrowsableState.Never)]
954 public TextDirection TextDirection
959 GetProperty(TextLabel.Property.TextDirection).Get(out temp);
960 return (TextDirection)temp;
965 /// The vertical line alignment of the text.
967 /// <since_tizen> 5 </since_tizen>
968 /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
969 [EditorBrowsable(EditorBrowsableState.Never)]
970 public VerticalLineAlignment VerticalLineAlignment
974 return (VerticalLineAlignment)GetValue(VerticalLineAlignmentProperty);
978 SetValue(VerticalLineAlignmentProperty, value);
979 NotifyPropertyChanged();
984 /// The text alignment to match the direction of the system language.
986 /// <since_tizen> 6 </since_tizen>
987 public bool MatchSystemLanguageDirection
991 return (bool)GetValue(MatchSystemLanguageDirectionProperty);
995 SetValue(MatchSystemLanguageDirectionProperty, value);
996 NotifyPropertyChanged();
1001 /// The text fit parameters.<br />
1002 /// The textFit map contains the following keys :<br />
1003 /// <list type="table">
1004 /// <item><term>enable (bool)</term><description>True to enable the text fit or false to disable (the default value is false)</description></item>
1005 /// <item><term>minSize (float)</term><description>Minimum Size for text fit (the default value is 10.f)</description></item>
1006 /// <item><term>maxSize (float)</term><description>Maximum Size for text fit (the default value is 100.f)</description></item>
1007 /// <item><term>stepSize (float)</term><description>Step Size for font increase (the default value is 1.f)</description></item>
1008 /// <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>
1011 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1012 [EditorBrowsable(EditorBrowsableState.Never)]
1013 public PropertyMap TextFit
1017 return (PropertyMap)GetValue(TextFitProperty);
1021 SetValue(TextFitProperty, value);
1022 NotifyPropertyChanged();
1027 /// The MinLineSize property.<br />
1029 /// <since_tizen> 8 </since_tizen>
1030 [EditorBrowsable(EditorBrowsableState.Never)]
1031 public float MinLineSize
1035 return (float)GetValue(MinLineSizeProperty);
1039 SetValue(MinLineSizeProperty, value);
1040 NotifyPropertyChanged();
1045 /// The FontSizeScale property. <br />
1046 /// The default value is 1.0. <br />
1047 /// If FontSizeScale.UseSystemSetting, will use the SystemSettings.FontSize internally. <br />
1049 /// <since_tizen> 9 </since_tizen>
1050 public float FontSizeScale
1054 return fontSizeScale;
1058 float newFontSizeScale;
1060 if (fontSizeScale == value) return;
1062 fontSizeScale = value;
1063 if (fontSizeScale == Tizen.NUI.FontSizeScale.UseSystemSetting)
1065 SystemSettingsFontSize systemSettingsFontSize;
1069 systemSettingsFontSize = SystemSettings.FontSize;
1073 Console.WriteLine("{0} Exception caught.", e);
1074 systemSettingsFontSize = SystemSettingsFontSize.Normal;
1076 newFontSizeScale = TextUtils.GetFontSizeScale(systemSettingsFontSize);
1077 addFontSizeChangedCallback();
1081 newFontSizeScale = fontSizeScale;
1082 removeFontSizeChangedCallback();
1085 SetValue(FontSizeScaleProperty, newFontSizeScale);
1086 NotifyPropertyChanged();
1090 private TextLabelSelectorData EnsureSelectorData() => selectorData ?? (selectorData = new TextLabelSelectorData());
1093 /// Downcasts a handle to textLabel handle
1095 /// <param name="handle"></param>
1096 /// <returns></returns>
1097 /// <exception cref="ArgumentNullException"> Thrown when handle is null. </exception>
1098 /// <since_tizen> 3 </since_tizen>
1099 /// Please do not use! this will be deprecated!
1100 /// Instead please use as keyword.
1101 [Obsolete("Please do not use! This will be deprecated! Please use as keyword instead! " +
1103 "BaseHandle handle = new TextLabel(\"Hello World!\"); " +
1104 "TextLabel label = handle as TextLabel")]
1105 [EditorBrowsable(EditorBrowsableState.Never)]
1106 public static TextLabel DownCast(BaseHandle handle)
1110 throw new ArgumentNullException(nameof(handle));
1112 TextLabel ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as TextLabel;
1113 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1118 [EditorBrowsable(EditorBrowsableState.Never)]
1119 protected override void Dispose(DisposeTypes type)
1126 if (systemlangTextFlag)
1128 SystemSettings.LocaleLanguageChanged -= SystemSettings_LocaleLanguageChanged;
1131 removeFontSizeChangedCallback();
1133 if (type == DisposeTypes.Explicit)
1136 //Release your own managed resources here.
1137 //You should release all of your own disposable objects here.
1138 selectorData?.Reset(this);
1144 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TextLabel obj)
1146 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
1149 /// This will not be public opened.
1150 [EditorBrowsable(EditorBrowsableState.Never)]
1151 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1153 Interop.TextLabel.DeleteTextLabel(swigCPtr);
1157 /// Get attribues, it is abstract function and must be override.
1159 [EditorBrowsable(EditorBrowsableState.Never)]
1160 protected override ViewStyle CreateViewStyle()
1162 return new TextLabelStyle();
1166 /// Invoked whenever the binding context of the textlabel changes. Implement this method to add class handling for this event.
1168 protected override void OnBindingContextChanged()
1170 base.OnBindingContextChanged();
1173 private void SystemSettings_LocaleLanguageChanged(object sender, LocaleLanguageChangedEventArgs e)
1175 Text = NUIApplication.MultilingualResourceManager?.GetString(textLabelSid, new CultureInfo(e.Value.Replace("_", "-")));
1178 private void SystemSettingsFontSizeChanged(object sender, FontSizeChangedEventArgs e)
1180 float newFontSizeScale = TextUtils.GetFontSizeScale(e.Value);
1181 SetValue(FontSizeScaleProperty, newFontSizeScale);
1184 private void addFontSizeChangedCallback()
1186 if (hasFontSizeChangedCallback != true)
1190 SystemSettings.FontSizeChanged += SystemSettingsFontSizeChanged;
1191 hasFontSizeChangedCallback = true;
1195 Console.WriteLine("{0} Exception caught.", e);
1196 hasFontSizeChangedCallback = false;
1201 private void removeFontSizeChangedCallback()
1203 if (hasFontSizeChangedCallback == true)
1207 SystemSettings.FontSizeChanged -= SystemSettingsFontSizeChanged;
1208 hasFontSizeChangedCallback = false;
1212 Console.WriteLine("{0} Exception caught.", e);
1213 hasFontSizeChangedCallback = true;
1218 private void RequestLayout()
1220 Layout?.RequestLayout();
1223 internal new class Property
1225 internal static readonly int TEXT = Interop.TextLabel.TextGet();
1226 internal static readonly int FontFamily = Interop.TextLabel.FontFamilyGet();
1227 internal static readonly int FontStyle = Interop.TextLabel.FontStyleGet();
1228 internal static readonly int PointSize = Interop.TextLabel.PointSizeGet();
1229 internal static readonly int MultiLine = Interop.TextLabel.MultiLineGet();
1230 internal static readonly int HorizontalAlignment = Interop.TextLabel.HorizontalAlignmentGet();
1231 internal static readonly int VerticalAlignment = Interop.TextLabel.VerticalAlignmentGet();
1232 internal static readonly int TextColor = Interop.TextLabel.TextColorGet();
1233 internal static readonly int EnableMarkup = Interop.TextLabel.EnableMarkupGet();
1234 internal static readonly int EnableAutoScroll = Interop.TextLabel.EnableAutoScrollGet();
1235 internal static readonly int AutoScrollSpeed = Interop.TextLabel.AutoScrollSpeedGet();
1236 internal static readonly int AutoScrollLoopCount = Interop.TextLabel.AutoScrollLoopCountGet();
1237 internal static readonly int AutoScrollGap = Interop.TextLabel.AutoScrollGapGet();
1238 internal static readonly int LineSpacing = Interop.TextLabel.LineSpacingGet();
1239 internal static readonly int UNDERLINE = Interop.TextLabel.UnderlineGet();
1240 internal static readonly int SHADOW = Interop.TextLabel.ShadowGet();
1241 internal static readonly int EMBOSS = Interop.TextLabel.EmbossGet();
1242 internal static readonly int OUTLINE = Interop.TextLabel.OutlineGet();
1243 internal static readonly int PixelSize = Interop.TextLabel.PixelSizeGet();
1244 internal static readonly int ELLIPSIS = Interop.TextLabel.EllipsisGet();
1245 internal static readonly int AutoScrollStopMode = Interop.TextLabel.AutoScrollStopModeGet();
1246 internal static readonly int AutoScrollLoopDelay = Interop.TextLabel.AutoScrollLoopDelayGet();
1247 internal static readonly int LineCount = Interop.TextLabel.LineCountGet();
1248 internal static readonly int LineWrapMode = Interop.TextLabel.LineWrapModeGet();
1249 internal static readonly int TextDirection = Interop.TextLabel.TextDirectionGet();
1250 internal static readonly int VerticalLineAlignment = Interop.TextLabel.VerticalLineAlignmentGet();
1251 internal static readonly int MatchSystemLanguageDirection = Interop.TextLabel.MatchSystemLanguageDirectionGet();
1252 internal static readonly int TextFit = Interop.TextLabel.TextFitGet();
1253 internal static readonly int MinLineSize = Interop.TextLabel.MinLineSizeGet();
1254 internal static readonly int FontSizeScale = Interop.TextLabel.FontSizeScaleGet();
1255 internal static readonly int EllipsisPosition = Interop.TextLabel.EllipsisPositionGet();
1258 private void OnShadowColorChanged(float x, float y, float z, float w)
1260 ShadowColor = new Vector4(x, y, z, w);
1262 private void OnShadowOffsetChanged(float x, float y)
1264 ShadowOffset = new Vector2(x, y);
1266 private void OnTextColorChanged(float r, float g, float b, float a)
1268 TextColor = new Color(r, g, b, a);
1270 private void OnUnderlineColorChanged(float x, float y, float z, float w)
1272 UnderlineColor = new Vector4(x, y, z, w);