2 * Copyright(c) 2020 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;
21 using System.Globalization;
22 using System.ComponentModel;
23 using Tizen.NUI.Binding;
25 namespace Tizen.NUI.BaseComponents
28 /// A control which renders a short text string.<br />
29 /// Text labels are lightweight, non-editable, and do not respond to the user input.<br />
31 /// <since_tizen> 3 </since_tizen>
32 public partial class TextLabel : View
34 private class TextLayout : LayoutItem
36 protected override void OnMeasure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
38 // Padding will be automatically applied by DALi TextLabel.
39 float totalWidth = widthMeasureSpec.Size.AsDecimal();
40 float totalHeight = heightMeasureSpec.Size.AsDecimal();
42 if (widthMeasureSpec.Mode == MeasureSpecification.ModeType.Exactly)
44 if (heightMeasureSpec.Mode != MeasureSpecification.ModeType.Exactly)
46 totalHeight = Owner.GetHeightForWidth(totalWidth);
47 heightMeasureSpec = new MeasureSpecification(new LayoutLength(totalHeight), MeasureSpecification.ModeType.Exactly);
52 if (heightMeasureSpec.Mode == MeasureSpecification.ModeType.Exactly)
54 // GetWidthForHeight is not implemented.
55 totalWidth = Owner.GetNaturalSize().Width;
56 widthMeasureSpec = new MeasureSpecification(new LayoutLength(totalWidth), MeasureSpecification.ModeType.Exactly);
60 Vector3 naturalSize = Owner.GetNaturalSize();
61 totalWidth = naturalSize.Width;
62 totalHeight = naturalSize.Height;
64 heightMeasureSpec = new MeasureSpecification(new LayoutLength(totalHeight), MeasureSpecification.ModeType.Exactly);
65 widthMeasureSpec = new MeasureSpecification(new LayoutLength(totalWidth), MeasureSpecification.ModeType.Exactly);
69 MeasuredSize.StateType childWidthState = MeasuredSize.StateType.MeasuredSizeOK;
70 MeasuredSize.StateType childHeightState = MeasuredSize.StateType.MeasuredSizeOK;
72 SetMeasuredDimensions(ResolveSizeAndState(new LayoutLength(totalWidth), widthMeasureSpec, childWidthState),
73 ResolveSizeAndState(new LayoutLength(totalHeight), heightMeasureSpec, childHeightState));
77 static TextLabel() { }
79 private string textLabelSid = null;
80 private bool systemlangTextFlag = false;
81 private TextLabelSelectorData selectorData;
82 private float fontSizeScale = 1.0f;
83 private bool hasFontSizeChangedCallback = false;
86 /// Creates the TextLabel control.
88 /// <since_tizen> 3 </since_tizen>
89 public TextLabel() : this(Interop.TextLabel.New(), true)
91 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
94 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
95 [EditorBrowsable(EditorBrowsableState.Never)]
96 public TextLabel(TextLabelStyle viewStyle) : this(Interop.TextLabel.New(), true, viewStyle)
101 /// Creates the TextLabel with setting the status of shown or hidden.
103 /// <param name="shown">false : Not displayed (hidden), true : displayed (shown)</param>
104 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
105 [EditorBrowsable(EditorBrowsableState.Never)]
106 public TextLabel(bool shown) : this(Interop.TextLabel.New(), true)
108 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
113 /// Creates the TextLabel control.
115 /// <param name="text">The text to display</param>
116 /// <since_tizen> 3 </since_tizen>
117 public TextLabel(string text) : this(Interop.TextLabel.New(text), true)
119 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
123 /// Creates the TextLabel with setting the status of shown or hidden.
125 /// <param name="text">The text to display</param>
126 /// <param name="shown">false : Not displayed (hidden), true : displayed (shown)</param>
127 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
128 [EditorBrowsable(EditorBrowsableState.Never)]
129 public TextLabel(string text, bool shown) : this(Interop.TextLabel.New(text), true)
131 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
135 internal TextLabel(TextLabel handle, bool shown = true) : this(Interop.TextLabel.NewTextLabel(TextLabel.getCPtr(handle)), true)
137 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
145 internal TextLabel(global::System.IntPtr cPtr, bool cMemoryOwn, ViewStyle viewStyle, bool shown = true) : base(cPtr, cMemoryOwn, viewStyle)
153 internal TextLabel(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true) : base(cPtr, cMemoryOwn, null)
162 /// Create internal layout of TextLabel
164 internal LayoutItem CreateTextLayout()
166 return new TextLayout();
170 /// The TranslatableText property.<br />
171 /// The text can set the SID value.<br />
173 /// <exception cref='ArgumentNullException'>
174 /// ResourceManager about multilingual is null.
176 /// <since_tizen> 4 </since_tizen>
177 public string TranslatableText
181 return (string)GetValue(TranslatableTextProperty);
185 SetValue(TranslatableTextProperty, value);
186 selectorData?.TranslatableText.UpdateIfNeeds(this, value);
189 private string translatableText
197 if (NUIApplication.MultilingualResourceManager == null)
199 throw new ArgumentNullException(null, "ResourceManager about multilingual is null");
201 string translatableText = null;
202 textLabelSid = value;
203 translatableText = NUIApplication.MultilingualResourceManager?.GetString(textLabelSid, new CultureInfo(SystemSettings.LocaleLanguage.Replace("_", "-")));
204 if (translatableText != null)
206 Text = translatableText;
207 if (systemlangTextFlag == false)
209 SystemSettings.LocaleLanguageChanged += SystemSettings_LocaleLanguageChanged;
210 systemlangTextFlag = true;
217 NotifyPropertyChanged();
222 /// The Text property.<br />
223 /// The text to display in the UTF-8 format.<br />
225 /// <since_tizen> 3 </since_tizen>
230 return (string)GetValue(TextProperty);
234 SetValue(TextProperty, value);
235 selectorData?.Text.UpdateIfNeeds(this, value);
236 NotifyPropertyChangedAndRequestLayout();
241 /// The FontFamily property.<br />
242 /// The requested font family to use.<br />
244 /// <since_tizen> 3 </since_tizen>
245 public string FontFamily
249 return (string)GetValue(FontFamilyProperty);
253 SetValue(FontFamilyProperty, value);
254 selectorData?.FontFamily.UpdateIfNeeds(this, value);
255 NotifyPropertyChangedAndRequestLayout();
260 /// The FontStyle property.<br />
261 /// The requested font style to use.<br />
263 /// <since_tizen> 3 </since_tizen>
264 public PropertyMap FontStyle
268 return (PropertyMap)GetValue(FontStyleProperty);
272 SetValue(FontStyleProperty, value);
273 NotifyPropertyChangedAndRequestLayout();
278 /// The PointSize property.<br />
279 /// The size of font in points.<br />
281 /// <since_tizen> 3 </since_tizen>
282 public float PointSize
286 return (float)GetValue(PointSizeProperty);
290 SetValue(PointSizeProperty, value);
291 selectorData?.PointSize.UpdateIfNeeds(this, value);
292 NotifyPropertyChangedAndRequestLayout();
297 /// The MultiLine property.<br />
298 /// The single-line or multi-line layout option.<br />
300 /// <since_tizen> 3 </since_tizen>
301 public bool MultiLine
305 return (bool)GetValue(MultiLineProperty);
309 SetValue(MultiLineProperty, value);
310 NotifyPropertyChangedAndRequestLayout();
315 /// The HorizontalAlignment property.<br />
316 /// The line horizontal alignment.<br />
318 /// <since_tizen> 3 </since_tizen>
319 public HorizontalAlignment HorizontalAlignment
323 return (HorizontalAlignment)GetValue(HorizontalAlignmentProperty);
327 SetValue(HorizontalAlignmentProperty, value);
328 NotifyPropertyChanged();
333 /// The VerticalAlignment property.<br />
334 /// The line vertical alignment.<br />
336 /// <since_tizen> 3 </since_tizen>
337 public VerticalAlignment VerticalAlignment
341 return (VerticalAlignment)GetValue(VerticalAlignmentProperty);
345 SetValue(VerticalAlignmentProperty, value);
346 NotifyPropertyChanged();
351 /// The TextColor property.<br />
352 /// The color of the text.<br />
353 /// Animation framework can be used to change the color of the text when not using mark up.<br />
354 /// Cannot animate the color when text is auto scrolling.<br />
357 /// The property cascade chaining set is possible. For example, this (textLabel.TextColor.X = 0.1f;) is possible.
359 /// <since_tizen> 3 </since_tizen>
360 public Color TextColor
364 Color temp = (Color)GetValue(TextColorProperty);
365 return new Color(OnTextColorChanged, temp.R, temp.G, temp.B, temp.A);
369 SetValue(TextColorProperty, value);
370 selectorData?.TextColor.UpdateIfNeeds(this, value);
371 NotifyPropertyChanged();
376 /// The ShadowOffset property.<br />
377 /// The drop shadow offset 0 indicates no shadow.<br />
379 /// <since_tizen> 3 </since_tizen>
381 /// Deprecated.(API Level 6) Use Shadow instead.
382 /// The property cascade chaining set is possible. For example, this (textLabel.ShadowOffset.X = 0.1f;) is possible.
384 [Obsolete("Please do not use this ShadowOffset(Deprecated). Please use Shadow instead.")]
385 public Vector2 ShadowOffset
389 Vector2 shadowOffset = new Vector2();
390 Shadow.Find(TextLabel.Property.SHADOW, "offset")?.Get(shadowOffset);
391 return new Vector2(OnShadowOffsetChanged, shadowOffset.X, shadowOffset.Y);
395 PropertyMap temp = new PropertyMap();
396 temp.Insert("offset", new PropertyValue(value));
398 PropertyMap shadowMap = Shadow;
399 shadowMap.Merge(temp);
401 SetValue(ShadowProperty, shadowMap);
402 NotifyPropertyChanged();
407 /// The ShadowColor property.<br />
408 /// The color of a drop shadow.<br />
410 /// <since_tizen> 3 </since_tizen>
412 /// Deprecated.(API Level 6) Use Shadow instead.
413 /// The property cascade chaining set is possible. For example, this (textLabel.ShadowColor.X = 0.1f;) is possible.
415 [Obsolete("Please do not use this ShadowColor(Deprecated). Please use Shadow instead.")]
416 public Vector4 ShadowColor
420 Vector4 shadowColor = new Vector4();
421 Shadow.Find(TextLabel.Property.SHADOW, "color")?.Get(shadowColor);
422 return new Vector4(OnShadowColorChanged, shadowColor.X, shadowColor.Y, shadowColor.Z, shadowColor.W);
426 PropertyMap temp = new PropertyMap();
427 temp.Insert("color", new PropertyValue(value));
429 PropertyMap shadowMap = Shadow;
430 shadowMap.Merge(temp);
432 SetValue(ShadowProperty, shadowMap);
433 NotifyPropertyChanged();
438 /// The UnderlineEnabled property.<br />
439 /// The underline enabled flag.<br />
441 /// <since_tizen> 3 </since_tizen>
443 /// Deprecated.(API Level 6) Use Underline instead.
445 [Obsolete("Please do not use this UnderlineEnabled(Deprecated). Please use Underline instead.")]
446 public bool UnderlineEnabled
450 bool underlineEnabled = false;
451 Underline.Find(TextLabel.Property.UNDERLINE, "enable")?.Get(out underlineEnabled);
452 return underlineEnabled;
456 PropertyMap temp = new PropertyMap();
457 temp.Add("enable", new PropertyValue(value));
459 PropertyMap undelineMap = Underline;
460 undelineMap.Merge(temp);
462 SetValue(UnderlineProperty, undelineMap);
463 NotifyPropertyChanged();
469 /// The UnderlineColor property.<br />
470 /// Overrides the underline height from font metrics.<br />
472 /// <since_tizen> 3 </since_tizen>
474 /// Deprecated.(API Level 6) Use Underline instead.
475 /// The property cascade chaining set is possible. For example, this (textLabel.UnderlineColor.X = 0.1f;) is possible.
477 [Obsolete("Please do not use this UnderlineColor(Deprecated). Please use Underline instead.")]
478 public Vector4 UnderlineColor
482 Vector4 underlineColor = new Vector4();
483 Underline.Find(TextLabel.Property.UNDERLINE, "color")?.Get(underlineColor);
484 return new Vector4(OnUnderlineColorChanged, underlineColor.X, underlineColor.Y, underlineColor.Z, underlineColor.W);
488 PropertyMap temp = new PropertyMap();
489 temp.Insert("color", new PropertyValue(value));
491 PropertyMap undelineMap = Underline;
492 undelineMap.Merge(temp);
494 SetValue(UnderlineProperty, undelineMap);
495 NotifyPropertyChanged();
500 /// The UnderlineHeight property.<br />
501 /// Overrides the underline height from font metrics.<br />
503 /// <since_tizen> 3 </since_tizen>
505 /// Deprecated.(API Level 6) Use Underline instead.
507 [Obsolete("Please do not use this UnderlineHeight(Deprecated). Please use Underline instead.")]
508 public float UnderlineHeight
512 float underlineHeight = 0.0f;
513 Underline.Find(TextLabel.Property.UNDERLINE, "height")?.Get(out underlineHeight);
514 return underlineHeight;
518 PropertyMap temp = new PropertyMap();
519 temp.Insert("height", new PropertyValue(value));
521 PropertyMap undelineMap = Underline;
522 undelineMap.Merge(temp);
524 SetValue(UnderlineProperty, undelineMap);
525 NotifyPropertyChanged();
530 /// The EnableMarkup property.<br />
531 /// Whether the mark-up processing is enabled.<br />
533 /// <since_tizen> 3 </since_tizen>
534 public bool EnableMarkup
538 return (bool)GetValue(EnableMarkupProperty);
542 SetValue(EnableMarkupProperty, value);
543 NotifyPropertyChanged();
548 /// The EnableAutoScroll property.<br />
549 /// Starts or stops auto scrolling.<br />
551 /// <since_tizen> 3 </since_tizen>
552 public bool EnableAutoScroll
556 return (bool)GetValue(EnableAutoScrollProperty);
560 SetValue(EnableAutoScrollProperty, value);
561 NotifyPropertyChanged();
566 /// The AutoScrollSpeed property.<br />
567 /// Sets the speed of scrolling in pixels per second.<br />
569 /// <since_tizen> 3 </since_tizen>
570 public int AutoScrollSpeed
574 return (int)GetValue(AutoScrollSpeedProperty);
578 SetValue(AutoScrollSpeedProperty, value);
579 NotifyPropertyChanged();
584 /// The AutoScrollLoopCount property.<br />
585 /// Number of complete loops when scrolling enabled.<br />
587 /// <since_tizen> 3 </since_tizen>
588 public int AutoScrollLoopCount
592 return (int)GetValue(AutoScrollLoopCountProperty);
596 SetValue(AutoScrollLoopCountProperty, value);
597 NotifyPropertyChanged();
602 /// The AutoScrollGap property.<br />
603 /// Gap before scrolling wraps.<br />
605 /// <since_tizen> 3 </since_tizen>
606 public float AutoScrollGap
610 return (float)GetValue(AutoScrollGapProperty);
614 SetValue(AutoScrollGapProperty, value);
615 NotifyPropertyChanged();
620 /// The LineSpacing property.<br />
621 /// The default extra space between lines in points.<br />
623 /// <since_tizen> 3 </since_tizen>
624 public float LineSpacing
628 return (float)GetValue(LineSpacingProperty);
632 SetValue(LineSpacingProperty, value);
633 NotifyPropertyChangedAndRequestLayout();
638 /// The Underline property.<br />
639 /// The default underline parameters.<br />
641 /// <since_tizen> 3 </since_tizen>
642 public PropertyMap Underline
646 return (PropertyMap)GetValue(UnderlineProperty);
650 SetValue(UnderlineProperty, value);
651 NotifyPropertyChanged();
656 /// The Shadow property.<br />
657 /// The default shadow parameters.<br />
659 /// <since_tizen> 3 </since_tizen>
660 public PropertyMap Shadow
664 return (PropertyMap)GetValue(ShadowProperty);
668 SetValue(ShadowProperty, value);
669 NotifyPropertyChanged();
674 /// Describes a text shadow for a TextLabel.
675 /// It is null by default.
677 [EditorBrowsable(EditorBrowsableState.Never)]
678 public TextShadow TextShadow
682 return (TextShadow)GetValue(TextShadowProperty);
686 SetValue(TextShadowProperty, value);
687 selectorData?.TextShadow.UpdateIfNeeds(this, value);
688 NotifyPropertyChanged();
693 /// The Emboss property.<br />
694 /// The default emboss parameters.<br />
696 /// <since_tizen> 3 </since_tizen>
701 return (string)GetValue(EmbossProperty);
705 SetValue(EmbossProperty, value);
706 NotifyPropertyChanged();
711 /// The Outline property.<br />
712 /// The default outline parameters.<br />
714 /// <since_tizen> 3 </since_tizen>
715 public PropertyMap Outline
719 return (PropertyMap)GetValue(OutlineProperty);
723 SetValue(OutlineProperty, value);
724 NotifyPropertyChanged();
729 /// The PixelSize property.<br />
730 /// The size of font in pixels.<br />
732 /// <since_tizen> 3 </since_tizen>
733 public float PixelSize
737 return (float)GetValue(PixelSizeProperty);
741 SetValue(PixelSizeProperty, value);
742 selectorData?.PixelSize.UpdateIfNeeds(this, value);
743 NotifyPropertyChangedAndRequestLayout();
748 /// The Ellipsis property.<br />
749 /// Enable or disable the ellipsis.<br />
751 /// <since_tizen> 3 </since_tizen>
756 return (bool)GetValue(EllipsisProperty);
760 SetValue(EllipsisProperty, value);
761 NotifyPropertyChanged();
766 /// The AutoScrollLoopDelay property.<br />
767 /// Do something.<br />
769 /// <since_tizen> 3 </since_tizen>
770 public float AutoScrollLoopDelay
774 return (float)GetValue(AutoScrollLoopDelayProperty);
778 SetValue(AutoScrollLoopDelayProperty, value);
779 NotifyPropertyChanged();
784 /// The AutoScrollStopMode property.<br />
785 /// Do something.<br />
787 /// <since_tizen> 3 </since_tizen>
788 public AutoScrollStopMode AutoScrollStopMode
792 return (AutoScrollStopMode)GetValue(AutoScrollStopModeProperty);
796 SetValue(AutoScrollStopModeProperty, value);
797 NotifyPropertyChanged();
802 /// The line count of the text.
804 /// <since_tizen> 3 </since_tizen>
810 GetProperty(TextLabel.Property.LineCount).Get(out temp);
816 /// The LineWrapMode property.<br />
817 /// line wrap mode when the text lines over layout width.<br />
819 /// <since_tizen> 4 </since_tizen>
820 public LineWrapMode LineWrapMode
824 return (LineWrapMode)GetValue(LineWrapModeProperty);
828 SetValue(LineWrapModeProperty, value);
829 NotifyPropertyChanged();
834 /// The direction of the text such as left to right or right to left.
836 /// <since_tizen> 5 </since_tizen>
837 /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
838 [EditorBrowsable(EditorBrowsableState.Never)]
839 public TextDirection TextDirection
844 GetProperty(TextLabel.Property.TextDirection).Get(out temp);
845 return (TextDirection)temp;
850 /// The vertical line alignment of the text.
852 /// <since_tizen> 5 </since_tizen>
853 /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
854 [EditorBrowsable(EditorBrowsableState.Never)]
855 public VerticalLineAlignment VerticalLineAlignment
859 return (VerticalLineAlignment)GetValue(VerticalLineAlignmentProperty);
863 SetValue(VerticalLineAlignmentProperty, value);
864 NotifyPropertyChanged();
869 /// The text alignment to match the direction of the system language.
871 /// <since_tizen> 6 </since_tizen>
872 public bool MatchSystemLanguageDirection
876 return (bool)GetValue(MatchSystemLanguageDirectionProperty);
880 SetValue(MatchSystemLanguageDirectionProperty, value);
881 NotifyPropertyChanged();
886 /// The text fit parameters.<br />
887 /// The textFit map contains the following keys :<br />
888 /// - enable (bool type) : True to enable the text fit or false to disable(the default value is false)<br />
889 /// - minSize (float type) : Minimum Size for text fit(the default value is 10.f)<br />
890 /// - maxSize (float type) : Maximum Size for text fit(the default value is 100.f)<br />
891 /// - stepSize (float type) : Step Size for font increase(the default value is 1.f)<br />
892 /// - fontSize (string type) : The size type of font, You can choose between "pointSize" or "pixelSize". (the default value is "pointSize")<br />
894 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
895 [EditorBrowsable(EditorBrowsableState.Never)]
896 public PropertyMap TextFit
900 return (PropertyMap)GetValue(TextFitProperty);
904 SetValue(TextFitProperty, value);
905 NotifyPropertyChanged();
910 /// The MinLineSize property.<br />
912 /// <since_tizen> 8 </since_tizen>
913 [EditorBrowsable(EditorBrowsableState.Never)]
914 public float MinLineSize
918 return (float)GetValue(MinLineSizeProperty);
922 SetValue(MinLineSizeProperty, value);
923 NotifyPropertyChangedAndRequestLayout();
928 /// The FontSizeScale property. <br />
929 /// The default value is 1.0. <br />
930 /// If FontSizeScale.UseSystemSetting, will use the SystemSettings.FontSize internally. <br />
932 /// <since_tizen> 9 </since_tizen>
933 public float FontSizeScale
937 return fontSizeScale;
941 float newFontSizeScale;
943 if (fontSizeScale == value) return;
945 fontSizeScale = value;
946 if (fontSizeScale == Tizen.NUI.FontSizeScale.UseSystemSetting)
948 SystemSettingsFontSize systemSettingsFontSize;
952 systemSettingsFontSize = SystemSettings.FontSize;
956 Console.WriteLine("{0} Exception caught.", e);
957 systemSettingsFontSize = SystemSettingsFontSize.Normal;
959 newFontSizeScale = TextUtils.GetFontSizeScale(systemSettingsFontSize);
960 addFontSizeChangedCallback();
964 newFontSizeScale = fontSizeScale;
965 removeFontSizeChangedCallback();
968 SetValue(FontSizeScaleProperty, newFontSizeScale);
969 NotifyPropertyChangedAndRequestLayout();
973 private TextLabelSelectorData SelectorData
977 if (selectorData == null)
979 selectorData = new TextLabelSelectorData();
986 /// Downcasts a handle to textLabel handle
988 /// <param name="handle"></param>
989 /// <returns></returns>
990 /// <exception cref="ArgumentNullException"> Thrown when handle is null. </exception>
991 /// <since_tizen> 3 </since_tizen>
992 /// Please do not use! this will be deprecated!
993 /// Instead please use as keyword.
994 [Obsolete("Please do not use! This will be deprecated! Please use as keyword instead! " +
996 "BaseHandle handle = new TextLabel(\"Hello World!\"); " +
997 "TextLabel label = handle as TextLabel")]
998 [EditorBrowsable(EditorBrowsableState.Never)]
999 public static TextLabel DownCast(BaseHandle handle)
1003 throw new ArgumentNullException(nameof(handle));
1005 TextLabel ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as TextLabel;
1006 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1011 [EditorBrowsable(EditorBrowsableState.Never)]
1012 protected override void Dispose(DisposeTypes type)
1019 if (systemlangTextFlag)
1021 SystemSettings.LocaleLanguageChanged -= SystemSettings_LocaleLanguageChanged;
1024 removeFontSizeChangedCallback();
1026 if (type == DisposeTypes.Explicit)
1029 //Release your own managed resources here.
1030 //You should release all of your own disposable objects here.
1031 selectorData?.Reset(this);
1037 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TextLabel obj)
1039 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
1042 /// This will not be public opened.
1043 [EditorBrowsable(EditorBrowsableState.Never)]
1044 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1046 Interop.TextLabel.DeleteTextLabel(swigCPtr);
1050 /// Get attribues, it is abstract function and must be override.
1052 [EditorBrowsable(EditorBrowsableState.Never)]
1053 protected override ViewStyle CreateViewStyle()
1055 return new TextLabelStyle();
1059 /// Invoked whenever the binding context of the textlabel changes. Implement this method to add class handling for this event.
1061 protected override void OnBindingContextChanged()
1063 base.OnBindingContextChanged();
1066 private void SystemSettings_LocaleLanguageChanged(object sender, LocaleLanguageChangedEventArgs e)
1068 Text = NUIApplication.MultilingualResourceManager?.GetString(textLabelSid, new CultureInfo(e.Value.Replace("_", "-")));
1071 private void SystemSettingsFontSizeChanged(object sender, FontSizeChangedEventArgs e)
1073 float newFontSizeScale = TextUtils.GetFontSizeScale(e.Value);
1074 SetValue(FontSizeScaleProperty, newFontSizeScale);
1075 NotifyPropertyChangedAndRequestLayout();
1078 private void addFontSizeChangedCallback()
1080 if (hasFontSizeChangedCallback != true)
1084 SystemSettings.FontSizeChanged += SystemSettingsFontSizeChanged;
1085 hasFontSizeChangedCallback = true;
1089 Console.WriteLine("{0} Exception caught.", e);
1090 hasFontSizeChangedCallback = false;
1095 private void removeFontSizeChangedCallback()
1097 if (hasFontSizeChangedCallback == true)
1101 SystemSettings.FontSizeChanged -= SystemSettingsFontSizeChanged;
1102 hasFontSizeChangedCallback = false;
1106 Console.WriteLine("{0} Exception caught.", e);
1107 hasFontSizeChangedCallback = true;
1112 private void NotifyPropertyChangedAndRequestLayout()
1114 NotifyPropertyChanged();
1115 Layout?.RequestLayout();
1118 internal new class Property
1120 internal static readonly int TEXT = Interop.TextLabel.TextGet();
1121 internal static readonly int FontFamily = Interop.TextLabel.FontFamilyGet();
1122 internal static readonly int FontStyle = Interop.TextLabel.FontStyleGet();
1123 internal static readonly int PointSize = Interop.TextLabel.PointSizeGet();
1124 internal static readonly int MultiLine = Interop.TextLabel.MultiLineGet();
1125 internal static readonly int HorizontalAlignment = Interop.TextLabel.HorizontalAlignmentGet();
1126 internal static readonly int VerticalAlignment = Interop.TextLabel.VerticalAlignmentGet();
1127 internal static readonly int TextColor = Interop.TextLabel.TextColorGet();
1128 internal static readonly int EnableMarkup = Interop.TextLabel.EnableMarkupGet();
1129 internal static readonly int EnableAutoScroll = Interop.TextLabel.EnableAutoScrollGet();
1130 internal static readonly int AutoScrollSpeed = Interop.TextLabel.AutoScrollSpeedGet();
1131 internal static readonly int AutoScrollLoopCount = Interop.TextLabel.AutoScrollLoopCountGet();
1132 internal static readonly int AutoScrollGap = Interop.TextLabel.AutoScrollGapGet();
1133 internal static readonly int LineSpacing = Interop.TextLabel.LineSpacingGet();
1134 internal static readonly int UNDERLINE = Interop.TextLabel.UnderlineGet();
1135 internal static readonly int SHADOW = Interop.TextLabel.ShadowGet();
1136 internal static readonly int EMBOSS = Interop.TextLabel.EmbossGet();
1137 internal static readonly int OUTLINE = Interop.TextLabel.OutlineGet();
1138 internal static readonly int PixelSize = Interop.TextLabel.PixelSizeGet();
1139 internal static readonly int ELLIPSIS = Interop.TextLabel.EllipsisGet();
1140 internal static readonly int AutoScrollStopMode = Interop.TextLabel.AutoScrollStopModeGet();
1141 internal static readonly int AutoScrollLoopDelay = Interop.TextLabel.AutoScrollLoopDelayGet();
1142 internal static readonly int LineCount = Interop.TextLabel.LineCountGet();
1143 internal static readonly int LineWrapMode = Interop.TextLabel.LineWrapModeGet();
1144 internal static readonly int TextDirection = Interop.TextLabel.TextDirectionGet();
1145 internal static readonly int VerticalLineAlignment = Interop.TextLabel.VerticalLineAlignmentGet();
1146 internal static readonly int MatchSystemLanguageDirection = Interop.TextLabel.MatchSystemLanguageDirectionGet();
1147 internal static readonly int TextFit = Interop.TextLabel.TextFitGet();
1148 internal static readonly int MinLineSize = Interop.TextLabel.MinLineSizeGet();
1149 internal static readonly int FontSizeScale = Interop.TextLabel.FontSizeScaleGet();
1152 private void OnShadowColorChanged(float x, float y, float z, float w)
1154 ShadowColor = new Vector4(x, y, z, w);
1156 private void OnShadowOffsetChanged(float x, float y)
1158 ShadowOffset = new Vector2(x, y);
1160 private void OnTextColorChanged(float r, float g, float b, float a)
1162 TextColor = new Color(r, g, b, a);
1164 private void OnUnderlineColorChanged(float x, float y, float z, float w)
1166 UnderlineColor = new Vector4(x, y, z, w);