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();
92 Layout = new TextLayout();
95 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
96 [EditorBrowsable(EditorBrowsableState.Never)]
97 public TextLabel(TextLabelStyle viewStyle) : this(Interop.TextLabel.New(), true, viewStyle)
99 Layout = new TextLayout();
103 /// Creates the TextLabel with setting the status of shown or hidden.
105 /// <param name="shown">false : Not displayed (hidden), true : displayed (shown)</param>
106 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
107 [EditorBrowsable(EditorBrowsableState.Never)]
108 public TextLabel(bool shown) : this(Interop.TextLabel.New(), true)
110 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
111 Layout = new TextLayout();
116 /// Creates the TextLabel control.
118 /// <param name="text">The text to display</param>
119 /// <since_tizen> 3 </since_tizen>
120 public TextLabel(string text) : this(Interop.TextLabel.New(text), true)
122 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
123 Layout = new TextLayout();
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();
136 Layout = new TextLayout();
140 internal TextLabel(TextLabel handle, bool shown = true) : this(Interop.TextLabel.NewTextLabel(TextLabel.getCPtr(handle)), true)
142 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
150 internal TextLabel(global::System.IntPtr cPtr, bool cMemoryOwn, ViewStyle viewStyle, bool shown = true) : base(Interop.TextLabel.Upcast(cPtr), cMemoryOwn, viewStyle)
158 internal TextLabel(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true) : base(Interop.TextLabel.Upcast(cPtr), cMemoryOwn, null)
167 /// The TranslatableText property.<br />
168 /// The text can set the SID value.<br />
170 /// <exception cref='ArgumentNullException'>
171 /// ResourceManager about multilingual is null.
173 /// <since_tizen> 4 </since_tizen>
174 public string TranslatableText
178 return (string)GetValue(TranslatableTextProperty);
182 SetValue(TranslatableTextProperty, value);
183 selectorData?.TranslatableText.UpdateIfNeeds(this, value);
186 private string translatableText
194 if (NUIApplication.MultilingualResourceManager == null)
196 throw new ArgumentNullException(null, "ResourceManager about multilingual is null");
198 string translatableText = null;
199 textLabelSid = value;
200 translatableText = NUIApplication.MultilingualResourceManager?.GetString(textLabelSid, new CultureInfo(SystemSettings.LocaleLanguage.Replace("_", "-")));
201 if (translatableText != null)
203 Text = translatableText;
204 if (systemlangTextFlag == false)
206 SystemSettings.LocaleLanguageChanged += SystemSettings_LocaleLanguageChanged;
207 systemlangTextFlag = true;
214 NotifyPropertyChanged();
219 /// The Text property.<br />
220 /// The text to display in the UTF-8 format.<br />
222 /// <since_tizen> 3 </since_tizen>
227 return (string)GetValue(TextProperty);
231 SetValue(TextProperty, value);
232 selectorData?.Text.UpdateIfNeeds(this, value);
233 NotifyPropertyChangedAndRequestLayout();
238 /// The FontFamily property.<br />
239 /// The requested font family to use.<br />
241 /// <since_tizen> 3 </since_tizen>
242 public string FontFamily
246 return (string)GetValue(FontFamilyProperty);
250 SetValue(FontFamilyProperty, value);
251 selectorData?.FontFamily.UpdateIfNeeds(this, value);
252 NotifyPropertyChangedAndRequestLayout();
257 /// The FontStyle property.<br />
258 /// The requested font style to use.<br />
260 /// <since_tizen> 3 </since_tizen>
261 public PropertyMap FontStyle
265 return (PropertyMap)GetValue(FontStyleProperty);
269 SetValue(FontStyleProperty, value);
270 NotifyPropertyChangedAndRequestLayout();
275 /// The PointSize property.<br />
276 /// The size of font in points.<br />
278 /// <since_tizen> 3 </since_tizen>
279 public float PointSize
283 return (float)GetValue(PointSizeProperty);
287 SetValue(PointSizeProperty, value);
288 selectorData?.PointSize.UpdateIfNeeds(this, value);
289 NotifyPropertyChangedAndRequestLayout();
294 /// The MultiLine property.<br />
295 /// The single-line or multi-line layout option.<br />
297 /// <since_tizen> 3 </since_tizen>
298 public bool MultiLine
302 return (bool)GetValue(MultiLineProperty);
306 SetValue(MultiLineProperty, value);
307 NotifyPropertyChangedAndRequestLayout();
312 /// The HorizontalAlignment property.<br />
313 /// The line horizontal alignment.<br />
315 /// <since_tizen> 3 </since_tizen>
316 public HorizontalAlignment HorizontalAlignment
320 return (HorizontalAlignment)GetValue(HorizontalAlignmentProperty);
324 SetValue(HorizontalAlignmentProperty, value);
325 NotifyPropertyChanged();
330 /// The VerticalAlignment property.<br />
331 /// The line vertical alignment.<br />
333 /// <since_tizen> 3 </since_tizen>
334 public VerticalAlignment VerticalAlignment
338 return (VerticalAlignment)GetValue(VerticalAlignmentProperty);
342 SetValue(VerticalAlignmentProperty, value);
343 NotifyPropertyChanged();
348 /// The TextColor property.<br />
349 /// The color of the text.<br />
350 /// Animation framework can be used to change the color of the text when not using mark up.<br />
351 /// Cannot animate the color when text is auto scrolling.<br />
354 /// The property cascade chaining set is possible. For example, this (textLabel.TextColor.X = 0.1f;) is possible.
356 /// <since_tizen> 3 </since_tizen>
357 public Color TextColor
361 Color temp = (Color)GetValue(TextColorProperty);
362 return new Color(OnTextColorChanged, temp.R, temp.G, temp.B, temp.A);
366 SetValue(TextColorProperty, value);
367 selectorData?.TextColor.UpdateIfNeeds(this, value);
368 NotifyPropertyChanged();
373 /// The ShadowOffset property.<br />
374 /// The drop shadow offset 0 indicates no shadow.<br />
376 /// <since_tizen> 3 </since_tizen>
378 /// Deprecated.(API Level 6) Use Shadow instead.
379 /// The property cascade chaining set is possible. For example, this (textLabel.ShadowOffset.X = 0.1f;) is possible.
381 [Obsolete("Please do not use this ShadowOffset(Deprecated). Please use Shadow instead.")]
382 public Vector2 ShadowOffset
386 Vector2 shadowOffset = new Vector2();
387 Shadow.Find(TextLabel.Property.SHADOW, "offset")?.Get(shadowOffset);
388 return new Vector2(OnShadowOffsetChanged, shadowOffset.X, shadowOffset.Y);
392 PropertyMap temp = new PropertyMap();
393 temp.Insert("offset", new PropertyValue(value));
395 PropertyMap shadowMap = Shadow;
396 shadowMap.Merge(temp);
398 SetValue(ShadowProperty, shadowMap);
399 NotifyPropertyChanged();
404 /// The ShadowColor property.<br />
405 /// The color of a drop shadow.<br />
407 /// <since_tizen> 3 </since_tizen>
409 /// Deprecated.(API Level 6) Use Shadow instead.
410 /// The property cascade chaining set is possible. For example, this (textLabel.ShadowColor.X = 0.1f;) is possible.
412 [Obsolete("Please do not use this ShadowColor(Deprecated). Please use Shadow instead.")]
413 public Vector4 ShadowColor
417 Vector4 shadowColor = new Vector4();
418 Shadow.Find(TextLabel.Property.SHADOW, "color")?.Get(shadowColor);
419 return new Vector4(OnShadowColorChanged, shadowColor.X, shadowColor.Y, shadowColor.Z, shadowColor.W);
423 PropertyMap temp = new PropertyMap();
424 temp.Insert("color", new PropertyValue(value));
426 PropertyMap shadowMap = Shadow;
427 shadowMap.Merge(temp);
429 SetValue(ShadowProperty, shadowMap);
430 NotifyPropertyChanged();
435 /// The UnderlineEnabled property.<br />
436 /// The underline enabled flag.<br />
438 /// <since_tizen> 3 </since_tizen>
440 /// Deprecated.(API Level 6) Use Underline instead.
442 [Obsolete("Please do not use this UnderlineEnabled(Deprecated). Please use Underline instead.")]
443 public bool UnderlineEnabled
447 bool underlineEnabled = false;
448 Underline.Find(TextLabel.Property.UNDERLINE, "enable")?.Get(out underlineEnabled);
449 return underlineEnabled;
453 PropertyMap temp = new PropertyMap();
454 temp.Add("enable", new PropertyValue(value));
456 PropertyMap undelineMap = Underline;
457 undelineMap.Merge(temp);
459 SetValue(UnderlineProperty, undelineMap);
460 NotifyPropertyChanged();
466 /// The UnderlineColor property.<br />
467 /// Overrides the underline height from font metrics.<br />
469 /// <since_tizen> 3 </since_tizen>
471 /// Deprecated.(API Level 6) Use Underline instead.
472 /// The property cascade chaining set is possible. For example, this (textLabel.UnderlineColor.X = 0.1f;) is possible.
474 [Obsolete("Please do not use this UnderlineColor(Deprecated). Please use Underline instead.")]
475 public Vector4 UnderlineColor
479 Vector4 underlineColor = new Vector4();
480 Underline.Find(TextLabel.Property.UNDERLINE, "color")?.Get(underlineColor);
481 return new Vector4(OnUnderlineColorChanged, underlineColor.X, underlineColor.Y, underlineColor.Z, underlineColor.W);
485 PropertyMap temp = new PropertyMap();
486 temp.Insert("color", new PropertyValue(value));
488 PropertyMap undelineMap = Underline;
489 undelineMap.Merge(temp);
491 SetValue(UnderlineProperty, undelineMap);
492 NotifyPropertyChanged();
497 /// The UnderlineHeight property.<br />
498 /// Overrides the underline height from font metrics.<br />
500 /// <since_tizen> 3 </since_tizen>
502 /// Deprecated.(API Level 6) Use Underline instead.
504 [Obsolete("Please do not use this UnderlineHeight(Deprecated). Please use Underline instead.")]
505 public float UnderlineHeight
509 float underlineHeight = 0.0f;
510 Underline.Find(TextLabel.Property.UNDERLINE, "height")?.Get(out underlineHeight);
511 return underlineHeight;
515 PropertyMap temp = new PropertyMap();
516 temp.Insert("height", new PropertyValue(value));
518 PropertyMap undelineMap = Underline;
519 undelineMap.Merge(temp);
521 SetValue(UnderlineProperty, undelineMap);
522 NotifyPropertyChanged();
527 /// The EnableMarkup property.<br />
528 /// Whether the mark-up processing is enabled.<br />
530 /// <since_tizen> 3 </since_tizen>
531 public bool EnableMarkup
535 return (bool)GetValue(EnableMarkupProperty);
539 SetValue(EnableMarkupProperty, value);
540 NotifyPropertyChanged();
545 /// The EnableAutoScroll property.<br />
546 /// Starts or stops auto scrolling.<br />
548 /// <since_tizen> 3 </since_tizen>
549 public bool EnableAutoScroll
553 return (bool)GetValue(EnableAutoScrollProperty);
557 SetValue(EnableAutoScrollProperty, value);
558 NotifyPropertyChanged();
563 /// The AutoScrollSpeed property.<br />
564 /// Sets the speed of scrolling in pixels per second.<br />
566 /// <since_tizen> 3 </since_tizen>
567 public int AutoScrollSpeed
571 return (int)GetValue(AutoScrollSpeedProperty);
575 SetValue(AutoScrollSpeedProperty, value);
576 NotifyPropertyChanged();
581 /// The AutoScrollLoopCount property.<br />
582 /// Number of complete loops when scrolling enabled.<br />
584 /// <since_tizen> 3 </since_tizen>
585 public int AutoScrollLoopCount
589 return (int)GetValue(AutoScrollLoopCountProperty);
593 SetValue(AutoScrollLoopCountProperty, value);
594 NotifyPropertyChanged();
599 /// The AutoScrollGap property.<br />
600 /// Gap before scrolling wraps.<br />
602 /// <since_tizen> 3 </since_tizen>
603 public float AutoScrollGap
607 return (float)GetValue(AutoScrollGapProperty);
611 SetValue(AutoScrollGapProperty, value);
612 NotifyPropertyChanged();
617 /// The LineSpacing property.<br />
618 /// The default extra space between lines in points.<br />
620 /// <since_tizen> 3 </since_tizen>
621 public float LineSpacing
625 return (float)GetValue(LineSpacingProperty);
629 SetValue(LineSpacingProperty, value);
630 NotifyPropertyChangedAndRequestLayout();
635 /// The Underline property.<br />
636 /// The default underline parameters.<br />
638 /// <since_tizen> 3 </since_tizen>
639 public PropertyMap Underline
643 return (PropertyMap)GetValue(UnderlineProperty);
647 SetValue(UnderlineProperty, value);
648 NotifyPropertyChanged();
653 /// The Shadow property.<br />
654 /// The default shadow parameters.<br />
656 /// <since_tizen> 3 </since_tizen>
657 public PropertyMap Shadow
661 return (PropertyMap)GetValue(ShadowProperty);
665 SetValue(ShadowProperty, value);
666 NotifyPropertyChanged();
671 /// Describes a text shadow for a TextLabel.
672 /// It is null by default.
674 [EditorBrowsable(EditorBrowsableState.Never)]
675 public TextShadow TextShadow
679 return (TextShadow)GetValue(TextShadowProperty);
683 SetValue(TextShadowProperty, value);
684 selectorData?.TextShadow.UpdateIfNeeds(this, value);
685 NotifyPropertyChanged();
690 /// The Emboss property.<br />
691 /// The default emboss parameters.<br />
693 /// <since_tizen> 3 </since_tizen>
698 return (string)GetValue(EmbossProperty);
702 SetValue(EmbossProperty, value);
703 NotifyPropertyChanged();
708 /// The Outline property.<br />
709 /// The default outline parameters.<br />
711 /// <since_tizen> 3 </since_tizen>
712 public PropertyMap Outline
716 return (PropertyMap)GetValue(OutlineProperty);
720 SetValue(OutlineProperty, value);
721 NotifyPropertyChanged();
726 /// The PixelSize property.<br />
727 /// The size of font in pixels.<br />
729 /// <since_tizen> 3 </since_tizen>
730 public float PixelSize
734 return (float)GetValue(PixelSizeProperty);
738 SetValue(PixelSizeProperty, value);
739 selectorData?.PixelSize.UpdateIfNeeds(this, value);
740 NotifyPropertyChangedAndRequestLayout();
745 /// The Ellipsis property.<br />
746 /// Enable or disable the ellipsis.<br />
748 /// <since_tizen> 3 </since_tizen>
753 return (bool)GetValue(EllipsisProperty);
757 SetValue(EllipsisProperty, value);
758 NotifyPropertyChanged();
763 /// The AutoScrollLoopDelay property.<br />
764 /// Do something.<br />
766 /// <since_tizen> 3 </since_tizen>
767 public float AutoScrollLoopDelay
771 return (float)GetValue(AutoScrollLoopDelayProperty);
775 SetValue(AutoScrollLoopDelayProperty, value);
776 NotifyPropertyChanged();
781 /// The AutoScrollStopMode property.<br />
782 /// Do something.<br />
784 /// <since_tizen> 3 </since_tizen>
785 public AutoScrollStopMode AutoScrollStopMode
789 return (AutoScrollStopMode)GetValue(AutoScrollStopModeProperty);
793 SetValue(AutoScrollStopModeProperty, value);
794 NotifyPropertyChanged();
799 /// The line count of the text.
801 /// <since_tizen> 3 </since_tizen>
807 GetProperty(TextLabel.Property.LineCount).Get(out temp);
813 /// The LineWrapMode property.<br />
814 /// line wrap mode when the text lines over layout width.<br />
816 /// <since_tizen> 4 </since_tizen>
817 public LineWrapMode LineWrapMode
821 return (LineWrapMode)GetValue(LineWrapModeProperty);
825 SetValue(LineWrapModeProperty, value);
826 NotifyPropertyChanged();
831 /// The direction of the text such as left to right or right to left.
833 /// <since_tizen> 5 </since_tizen>
834 /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
835 [EditorBrowsable(EditorBrowsableState.Never)]
836 public TextDirection TextDirection
841 GetProperty(TextLabel.Property.TextDirection).Get(out temp);
842 return (TextDirection)temp;
847 /// The vertical line alignment of the text.
849 /// <since_tizen> 5 </since_tizen>
850 /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
851 [EditorBrowsable(EditorBrowsableState.Never)]
852 public VerticalLineAlignment VerticalLineAlignment
856 return (VerticalLineAlignment)GetValue(VerticalLineAlignmentProperty);
860 SetValue(VerticalLineAlignmentProperty, value);
861 NotifyPropertyChanged();
866 /// The text alignment to match the direction of the system language.
868 /// <since_tizen> 6 </since_tizen>
869 public bool MatchSystemLanguageDirection
873 return (bool)GetValue(MatchSystemLanguageDirectionProperty);
877 SetValue(MatchSystemLanguageDirectionProperty, value);
878 NotifyPropertyChanged();
883 /// The text fit parameters.<br />
884 /// The textFit map contains the following keys :<br />
885 /// - enable (bool type) : True to enable the text fit or false to disable(the default value is false)<br />
886 /// - minSize (float type) : Minimum Size for text fit(the default value is 10.f)<br />
887 /// - maxSize (float type) : Maximum Size for text fit(the default value is 100.f)<br />
888 /// - stepSize (float type) : Step Size for font increase(the default value is 1.f)<br />
889 /// - fontSize (string type) : The size type of font, You can choose between "pointSize" or "pixelSize". (the default value is "pointSize")<br />
891 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
892 [EditorBrowsable(EditorBrowsableState.Never)]
893 public PropertyMap TextFit
897 return (PropertyMap)GetValue(TextFitProperty);
901 SetValue(TextFitProperty, value);
902 NotifyPropertyChanged();
907 /// The MinLineSize property.<br />
909 /// <since_tizen> 8 </since_tizen>
910 [EditorBrowsable(EditorBrowsableState.Never)]
911 public float MinLineSize
915 return (float)GetValue(MinLineSizeProperty);
919 SetValue(MinLineSizeProperty, value);
920 NotifyPropertyChangedAndRequestLayout();
925 /// The FontSizeScale property. <br />
926 /// The default value is 1.0. <br />
927 /// If FontSizeScale.UseSystemSetting, will use the SystemSettings.FontSize internally. <br />
929 /// <since_tizen> 9 </since_tizen>
930 /// This will be public opened in tizen_6.5 after ACR done. Before ACR, need to be hidden as inhouse API.
931 [EditorBrowsable(EditorBrowsableState.Never)]
932 public float FontSizeScale
936 return fontSizeScale;
940 float newFontSizeScale;
942 if (fontSizeScale == value) return;
944 fontSizeScale = value;
945 if (fontSizeScale == Tizen.NUI.FontSizeScale.UseSystemSetting)
947 SystemSettingsFontSize systemSettingsFontSize;
951 systemSettingsFontSize = SystemSettings.FontSize;
955 Console.WriteLine("{0} Exception caught.", e);
956 systemSettingsFontSize = SystemSettingsFontSize.Normal;
958 newFontSizeScale = TextUtils.GetFontSizeScale(systemSettingsFontSize);
959 addFontSizeChangedCallback();
963 newFontSizeScale = fontSizeScale;
964 removeFontSizeChangedCallback();
967 SetValue(FontSizeScaleProperty, newFontSizeScale);
968 NotifyPropertyChangedAndRequestLayout();
972 private TextLabelSelectorData SelectorData
976 if (selectorData == null)
978 selectorData = new TextLabelSelectorData();
985 /// Downcasts a handle to textLabel handle
987 /// <param name="handle"></param>
988 /// <returns></returns>
989 /// <exception cref="ArgumentNullException"> Thrown when handle is null. </exception>
990 /// <since_tizen> 3 </since_tizen>
991 /// Please do not use! this will be deprecated!
992 /// Instead please use as keyword.
993 [Obsolete("Please do not use! This will be deprecated! Please use as keyword instead! " +
995 "BaseHandle handle = new TextLabel(\"Hello World!\"); " +
996 "TextLabel label = handle as TextLabel")]
997 [EditorBrowsable(EditorBrowsableState.Never)]
998 public static TextLabel DownCast(BaseHandle handle)
1002 throw new ArgumentNullException(nameof(handle));
1004 TextLabel ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as TextLabel;
1005 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1010 [EditorBrowsable(EditorBrowsableState.Never)]
1011 protected override void Dispose(DisposeTypes type)
1018 if (systemlangTextFlag)
1020 SystemSettings.LocaleLanguageChanged -= SystemSettings_LocaleLanguageChanged;
1023 removeFontSizeChangedCallback();
1025 if (type == DisposeTypes.Explicit)
1028 //Release your own managed resources here.
1029 //You should release all of your own disposable objects here.
1030 selectorData?.Reset(this);
1036 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TextLabel obj)
1038 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
1041 /// This will not be public opened.
1042 [EditorBrowsable(EditorBrowsableState.Never)]
1043 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1045 Interop.TextLabel.DeleteTextLabel(swigCPtr);
1049 /// Get attribues, it is abstract function and must be override.
1051 [EditorBrowsable(EditorBrowsableState.Never)]
1052 protected override ViewStyle CreateViewStyle()
1054 return new TextLabelStyle();
1058 /// Invoked whenever the binding context of the textlabel changes. Implement this method to add class handling for this event.
1060 protected override void OnBindingContextChanged()
1062 base.OnBindingContextChanged();
1065 private void SystemSettings_LocaleLanguageChanged(object sender, LocaleLanguageChangedEventArgs e)
1067 Text = NUIApplication.MultilingualResourceManager?.GetString(textLabelSid, new CultureInfo(e.Value.Replace("_", "-")));
1070 private void SystemSettingsFontSizeChanged(object sender, FontSizeChangedEventArgs e)
1072 float newFontSizeScale = TextUtils.GetFontSizeScale(e.Value);
1073 SetValue(FontSizeScaleProperty, newFontSizeScale);
1074 NotifyPropertyChangedAndRequestLayout();
1077 private void addFontSizeChangedCallback()
1079 if (hasFontSizeChangedCallback != true)
1083 SystemSettings.FontSizeChanged += SystemSettingsFontSizeChanged;
1084 hasFontSizeChangedCallback = true;
1088 Console.WriteLine("{0} Exception caught.", e);
1089 hasFontSizeChangedCallback = false;
1094 private void removeFontSizeChangedCallback()
1096 if (hasFontSizeChangedCallback == true)
1100 SystemSettings.FontSizeChanged -= SystemSettingsFontSizeChanged;
1101 hasFontSizeChangedCallback = false;
1105 Console.WriteLine("{0} Exception caught.", e);
1106 hasFontSizeChangedCallback = true;
1111 private void NotifyPropertyChangedAndRequestLayout()
1113 NotifyPropertyChanged();
1114 Layout?.RequestLayout();
1117 internal new class Property
1119 internal static readonly int TEXT = Interop.TextLabel.TextGet();
1120 internal static readonly int FontFamily = Interop.TextLabel.FontFamilyGet();
1121 internal static readonly int FontStyle = Interop.TextLabel.FontStyleGet();
1122 internal static readonly int PointSize = Interop.TextLabel.PointSizeGet();
1123 internal static readonly int MultiLine = Interop.TextLabel.MultiLineGet();
1124 internal static readonly int HorizontalAlignment = Interop.TextLabel.HorizontalAlignmentGet();
1125 internal static readonly int VerticalAlignment = Interop.TextLabel.VerticalAlignmentGet();
1126 internal static readonly int TextColor = Interop.TextLabel.TextColorGet();
1127 internal static readonly int EnableMarkup = Interop.TextLabel.EnableMarkupGet();
1128 internal static readonly int EnableAutoScroll = Interop.TextLabel.EnableAutoScrollGet();
1129 internal static readonly int AutoScrollSpeed = Interop.TextLabel.AutoScrollSpeedGet();
1130 internal static readonly int AutoScrollLoopCount = Interop.TextLabel.AutoScrollLoopCountGet();
1131 internal static readonly int AutoScrollGap = Interop.TextLabel.AutoScrollGapGet();
1132 internal static readonly int LineSpacing = Interop.TextLabel.LineSpacingGet();
1133 internal static readonly int UNDERLINE = Interop.TextLabel.UnderlineGet();
1134 internal static readonly int SHADOW = Interop.TextLabel.ShadowGet();
1135 internal static readonly int EMBOSS = Interop.TextLabel.EmbossGet();
1136 internal static readonly int OUTLINE = Interop.TextLabel.OutlineGet();
1137 internal static readonly int PixelSize = Interop.TextLabel.PixelSizeGet();
1138 internal static readonly int ELLIPSIS = Interop.TextLabel.EllipsisGet();
1139 internal static readonly int AutoScrollStopMode = Interop.TextLabel.AutoScrollStopModeGet();
1140 internal static readonly int AutoScrollLoopDelay = Interop.TextLabel.AutoScrollLoopDelayGet();
1141 internal static readonly int LineCount = Interop.TextLabel.LineCountGet();
1142 internal static readonly int LineWrapMode = Interop.TextLabel.LineWrapModeGet();
1143 internal static readonly int TextDirection = Interop.TextLabel.TextDirectionGet();
1144 internal static readonly int VerticalLineAlignment = Interop.TextLabel.VerticalLineAlignmentGet();
1145 internal static readonly int MatchSystemLanguageDirection = Interop.TextLabel.MatchSystemLanguageDirectionGet();
1146 internal static readonly int TextFit = Interop.TextLabel.TextFitGet();
1147 internal static readonly int MinLineSize = Interop.TextLabel.MinLineSizeGet();
1148 internal static readonly int FontSizeScale = Interop.TextLabel.FontSizeScaleGet();
1151 private void OnShadowColorChanged(float x, float y, float z, float w)
1153 ShadowColor = new Vector4(x, y, z, w);
1155 private void OnShadowOffsetChanged(float x, float y)
1157 ShadowOffset = new Vector2(x, y);
1159 private void OnTextColorChanged(float r, float g, float b, float a)
1161 TextColor = new Color(r, g, b, a);
1163 private void OnUnderlineColorChanged(float x, float y, float z, float w)
1165 UnderlineColor = new Vector4(x, y, z, w);