[NUI] Skip text getter when Text never setted before
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / TextLabel.cs
1 /*
2  * Copyright(c) 2023 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 extern alias TizenSystemSettings;
19 using TizenSystemSettings.Tizen.System;
20
21 using System;
22 using System.Globalization;
23 using System.ComponentModel;
24 using Tizen.NUI.Text;
25 using Tizen.NUI.Binding;
26
27 namespace Tizen.NUI.BaseComponents
28 {
29     /// <summary>
30     /// A control which renders a short text string.<br />
31     /// Text labels are lightweight, non-editable, and do not respond to the user input.<br />
32     /// </summary>
33     /// <since_tizen> 3 </since_tizen>
34     public partial class TextLabel : View
35     {
36         private class TextLayout : LayoutItem
37         {
38             protected override void OnMeasure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
39             {
40                 // Padding will be automatically applied by DALi TextLabel.
41                 float totalWidth = widthMeasureSpec.Size.AsDecimal();
42                 float totalHeight = heightMeasureSpec.Size.AsDecimal();
43
44                 if (widthMeasureSpec.Mode == MeasureSpecification.ModeType.Exactly)
45                 {
46                     if (heightMeasureSpec.Mode != MeasureSpecification.ModeType.Exactly)
47                     {
48                         totalHeight = Owner.GetHeightForWidth(totalWidth);
49                         heightMeasureSpec = new MeasureSpecification(new LayoutLength(totalHeight), MeasureSpecification.ModeType.Exactly);
50                     }
51                 }
52                 else
53                 {
54                     var minSize = Owner.MinimumSize;
55                     var maxSize = Owner.MaximumSize;
56                     var naturalSize = Owner.GetNaturalSize();
57
58                     if (heightMeasureSpec.Mode == MeasureSpecification.ModeType.Exactly)
59                     {
60                         // GetWidthForHeight is not implemented.
61                         float width = naturalSize != null ? naturalSize.Width : 0;
62                         totalWidth = Math.Min(Math.Max(width, minSize.Width), (maxSize.Width < 0 ? Int32.MaxValue : maxSize.Width));
63                         widthMeasureSpec = new MeasureSpecification(new LayoutLength(totalWidth), MeasureSpecification.ModeType.Exactly);
64                     }
65                     else
66                     {
67                         float width = naturalSize != null ? naturalSize.Width : 0;
68                         float height = naturalSize != null ? naturalSize.Height : 0;
69                         totalWidth = Math.Min(Math.Max(width, minSize.Width), (maxSize.Width < 0 ? Int32.MaxValue : maxSize.Width));
70                         totalHeight = Math.Min(Math.Max(height, minSize.Height), (maxSize.Height < 0 ? Int32.MaxValue : maxSize.Height));
71
72                         heightMeasureSpec = new MeasureSpecification(new LayoutLength(totalHeight), MeasureSpecification.ModeType.Exactly);
73                         widthMeasureSpec = new MeasureSpecification(new LayoutLength(totalWidth), MeasureSpecification.ModeType.Exactly);
74                     }
75                 }
76
77                 MeasuredSize.StateType childWidthState = MeasuredSize.StateType.MeasuredSizeOK;
78                 MeasuredSize.StateType childHeightState = MeasuredSize.StateType.MeasuredSizeOK;
79
80                 SetMeasuredDimensions(ResolveSizeAndState(new LayoutLength(totalWidth), widthMeasureSpec, childWidthState),
81                                        ResolveSizeAndState(new LayoutLength(totalHeight), heightMeasureSpec, childHeightState));
82             }
83         }
84
85         static TextLabel() { }
86
87         static internal new void Preload()
88         {
89             // Do not call View.Preload(), since we already call it
90
91             Property.Preload();
92             // Do nothing. Just call for load static values.
93         }
94
95         private static SystemFontTypeChanged systemFontTypeChanged = new SystemFontTypeChanged();
96         private static SystemLocaleLanguageChanged systemLocaleLanguageChanged = new SystemLocaleLanguageChanged();
97         static private string defaultStyleName = "Tizen.NUI.BaseComponents.TextLabel";
98         static private string defaultFontFamily = "BreezeSans";
99         private string textLabelSid = null;
100         private TextLabelSelectorData selectorData;
101         private string fontFamily = defaultFontFamily;
102         private float fontSizeScale = 1.0f;
103
104         private bool textIsEmpty = true;
105
106         private bool hasSystemLanguageChanged = false;
107         private bool hasSystemFontSizeChanged = false;
108         private bool hasSystemFontTypeChanged = false;
109
110         private Color internalTextColor;
111
112         /// <summary>
113         /// Creates the TextLabel control.
114         /// </summary>
115         /// <since_tizen> 3 </since_tizen>
116         public TextLabel() : this(Interop.TextLabel.New(ThemeManager.GetStyle(defaultStyleName) == null ? false : true), true)
117         {
118             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
119         }
120
121         /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
122         [EditorBrowsable(EditorBrowsableState.Never)]
123         public TextLabel(TextLabelStyle viewStyle) : this(Interop.TextLabel.New(ThemeManager.GetStyle(defaultStyleName) == null ? false : true), true, viewStyle)
124         {
125         }
126
127         /// <summary>
128         /// Creates the TextLabel with setting the status of shown or hidden.
129         /// </summary>
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(bool shown) : this(Interop.TextLabel.New(ThemeManager.GetStyle(defaultStyleName) == null ? false : true), true)
134         {
135             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
136             SetVisible(shown);
137         }
138
139         /// <summary>
140         /// Creates the TextLabel control.
141         /// </summary>
142         /// <param name="text">The text to display</param>
143         /// <since_tizen> 3 </since_tizen>
144         public TextLabel(string text) : this(Interop.TextLabel.New(text, ThemeManager.GetStyle(defaultStyleName) == null ? false : true), true)
145         {
146             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
147             textIsEmpty = string.IsNullOrEmpty(text);
148         }
149
150         /// <summary>
151         /// Creates the TextLabel with setting the status of shown or hidden.
152         /// </summary>
153         /// <param name="text">The text to display</param>
154         /// <param name="shown">false : Not displayed (hidden), true : displayed (shown)</param>
155         /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
156         [EditorBrowsable(EditorBrowsableState.Never)]
157         public TextLabel(string text, bool shown) : this(Interop.TextLabel.New(text, ThemeManager.GetStyle(defaultStyleName) == null ? false : true), true)
158         {
159             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
160             textIsEmpty = string.IsNullOrEmpty(text);
161             SetVisible(shown);
162         }
163
164         internal TextLabel(global::System.IntPtr cPtr, bool cMemoryOwn, ViewStyle viewStyle, bool shown = true) : base(cPtr, cMemoryOwn, viewStyle)
165         {
166             if (!shown)
167             {
168                 SetVisible(false);
169             }
170         }
171
172         internal TextLabel(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true) : base(cPtr, cMemoryOwn, null)
173         {
174             if (!shown)
175             {
176                 SetVisible(false);
177             }
178         }
179
180         private bool HasStyle()
181         {
182             return ThemeManager.GetStyle(this.GetType()) == null ? false : true;
183         }
184
185         /// <summary>
186         /// The TranslatableText property.<br />
187         /// The text can set the SID value.<br />
188         /// </summary>
189         /// <exception cref='ArgumentNullException'>
190         /// ResourceManager about multilingual is null.
191         /// </exception>
192         /// <since_tizen> 4 </since_tizen>
193         public string TranslatableText
194         {
195             get
196             {
197                 return (string)GetValue(TranslatableTextProperty);
198             }
199             set
200             {
201                 SetValue(TranslatableTextProperty, value);
202             }
203         }
204         private string translatableText
205         {
206             get
207             {
208                 return textLabelSid;
209             }
210             set
211             {
212                 if (NUIApplication.MultilingualResourceManager == null)
213                 {
214                     throw new ArgumentNullException(null, "ResourceManager about multilingual is null");
215                 }
216                 string translatableText = null;
217                 textLabelSid = value;
218                 translatableText = NUIApplication.MultilingualResourceManager?.GetString(textLabelSid, new CultureInfo(SystemSettings.LocaleLanguage.Replace("_", "-")));
219                 if (translatableText != null)
220                 {
221                     Text = translatableText;
222                     if (hasSystemLanguageChanged == false)
223                     {
224                         systemLocaleLanguageChanged.Add(SystemSettingsLocaleLanguageChanged);
225                         hasSystemLanguageChanged = true;
226                     }
227                 }
228                 else
229                 {
230                     Text = "";
231                 }
232                 NotifyPropertyChanged();
233             }
234         }
235
236         /// <summary>
237         /// The Text property.<br />
238         /// The text to display in the UTF-8 format.<br />
239         /// </summary>
240         /// <since_tizen> 3 </since_tizen>
241         public string Text
242         {
243             get
244             {
245                 return (string)GetValue(TextProperty);
246             }
247             set
248             {
249                 SetValue(TextProperty, value);
250                 NotifyPropertyChanged();
251             }
252         }
253
254         /// <summary>
255         /// The FontFamily property.<br />
256         /// The requested font family to use.<br />
257         /// </summary>
258         /// <since_tizen> 3 </since_tizen>
259         public string FontFamily
260         {
261             get
262             {
263                 return (string)GetValue(FontFamilyProperty);
264             }
265             set
266             {
267                 SetValue(FontFamilyProperty, value);
268                 NotifyPropertyChanged();
269             }
270         }
271
272         private string InternalFontFamily
273         {
274             get
275             {
276                 if (HasStyle())
277                     return fontFamily;
278                 else
279                     return Object.InternalGetPropertyString(this.SwigCPtr, TextLabel.Property.FontFamily);
280             }
281             set
282             {
283                 string newFontFamily;
284
285                 if (string.Equals(fontFamily, value)) return;
286
287                 fontFamily = value;
288                 if (fontFamily == Tizen.NUI.FontFamily.UseSystemSetting)
289                 {
290                     try
291                     {
292                         newFontFamily = SystemSettings.FontType;
293                     }
294                     catch (Exception e)
295                     {
296                         Console.WriteLine("{0} Exception caught.", e);
297                         newFontFamily = defaultFontFamily;
298                     }
299                     AddSystemSettingsFontTypeChanged();
300                 }
301                 else
302                 {
303                     newFontFamily = fontFamily;
304                     RemoveSystemSettingsFontTypeChanged();
305                 }
306
307                 SetInternalFontFamily(newFontFamily);
308             }
309         }
310
311         private void SetInternalFontFamily(string fontFamily)
312         {
313             Object.InternalSetPropertyString(this.SwigCPtr, TextLabel.Property.FontFamily, (string)fontFamily);
314             RequestLayout();
315         }
316
317         /// <summary>
318         /// The FontStyle property.<br />
319         /// The requested font style to use.<br />
320         /// The fontStyle map contains the following keys :<br />
321         /// <list type="table">
322         /// <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>
323         /// <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>
324         /// <item><term>slant (string)</term><description>The slant key defines whether to use italics. (values: normal, roman, italic, oblique)</description></item>
325         /// </list>
326         /// </summary>
327         /// <since_tizen> 3 </since_tizen>
328         [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1721: Property names should not match get methods")]
329         public PropertyMap FontStyle
330         {
331             get
332             {
333                 return (PropertyMap)GetValue(FontStyleProperty);
334             }
335             set
336             {
337                 SetValue(FontStyleProperty, value);
338                 NotifyPropertyChanged();
339             }
340         }
341
342         /// <summary>
343         /// Set FontStyle to TextLabel. <br />
344         /// </summary>
345         /// <param name="fontStyle">The FontStyle</param>
346         /// <remarks>
347         /// SetFontStyle specifies the requested font style through <see cref="Tizen.NUI.Text.FontStyle"/>. <br />
348         /// </remarks>
349         /// <example>
350         /// The following example demonstrates how to use the SetFontStyle method.
351         /// <code>
352         /// var fontStyle = new Tizen.NUI.Text.FontStyle();
353         /// fontStyle.Width = FontWidthType.Expanded;
354         /// fontStyle.Weight = FontWeightType.Bold;
355         /// fontStyle.Slant = FontSlantType.Italic;
356         /// label.SetFontStyle(fontStyle);
357         /// </code>
358         /// </example>
359         [EditorBrowsable(EditorBrowsableState.Never)]
360         public void SetFontStyle(FontStyle fontStyle)
361         {
362             using (var fontStyleMap = TextMapHelper.GetFontStyleMap(fontStyle))
363             {
364                 SetValue(FontStyleProperty, fontStyleMap);
365             }
366         }
367
368         /// <summary>
369         /// Get FontStyle from TextLabel. <br />
370         /// </summary>
371         /// <returns>The FontStyle</returns>
372         /// <remarks>
373         /// <see cref="Tizen.NUI.Text.FontStyle"/>
374         /// </remarks>
375         [EditorBrowsable(EditorBrowsableState.Never)]
376         public FontStyle GetFontStyle()
377         {
378             FontStyle fontStyle;
379             using (var fontStyleMap = (PropertyMap)GetValue(FontStyleProperty))
380             {
381                 fontStyle = TextMapHelper.GetFontStyleStruct(fontStyleMap);
382             }
383             return fontStyle;
384         }
385
386         /// <summary>
387         /// The PointSize property.<br />
388         /// The size of font in points.<br />
389         /// </summary>
390         /// <since_tizen> 3 </since_tizen>
391         [Binding.TypeConverter(typeof(PointSizeTypeConverter))]
392         public float PointSize
393         {
394             get
395             {
396                 return (float)GetValue(PointSizeProperty);
397             }
398             set
399             {
400                 SetValue(PointSizeProperty, value);
401                 NotifyPropertyChanged();
402             }
403         }
404
405         /// <summary>
406         /// The MultiLine property.<br />
407         /// The single-line or multi-line layout option.<br />
408         /// </summary>
409         /// <since_tizen> 3 </since_tizen>
410         public bool MultiLine
411         {
412             get
413             {
414                 return (bool)GetValue(MultiLineProperty);
415             }
416             set
417             {
418                 SetValue(MultiLineProperty, value);
419                 NotifyPropertyChanged();
420             }
421         }
422
423         /// <summary>
424         /// The HorizontalAlignment property.<br />
425         /// The line horizontal alignment.<br />
426         /// </summary>
427         /// <since_tizen> 3 </since_tizen>
428         public HorizontalAlignment HorizontalAlignment
429         {
430             get
431             {
432                 return (HorizontalAlignment)GetValue(HorizontalAlignmentProperty);
433             }
434             set
435             {
436                 SetValue(HorizontalAlignmentProperty, value);
437                 NotifyPropertyChanged();
438             }
439         }
440
441         /// <summary>
442         /// The VerticalAlignment property.<br />
443         /// The line vertical alignment.<br />
444         /// </summary>
445         /// <since_tizen> 3 </since_tizen>
446         public VerticalAlignment VerticalAlignment
447         {
448             get
449             {
450                 return (VerticalAlignment)GetValue(VerticalAlignmentProperty);
451             }
452             set
453             {
454                 SetValue(VerticalAlignmentProperty, value);
455                 NotifyPropertyChanged();
456             }
457         }
458
459         /// <summary>
460         /// The TextColor property.<br />
461         /// The color of the text.<br />
462         /// Animation framework can be used to change the color of the text when not using mark up.<br />
463         /// Cannot animate the color when text is auto scrolling.<br />
464         /// </summary>
465         /// <remarks>
466         /// The property cascade chaining set is possible. For example, this (textLabel.TextColor.X = 0.1f;) is possible.
467         /// </remarks>
468         /// <since_tizen> 3 </since_tizen>
469         public Color TextColor
470         {
471             get
472             {
473                 Color temp = (Color)GetValue(TextColorProperty);
474                 return new Color(OnTextColorChanged, temp.R, temp.G, temp.B, temp.A);
475             }
476             set
477             {
478                 SetValue(TextColorProperty, value);
479                 NotifyPropertyChanged();
480             }
481         }
482
483         /// <summary>
484         /// The ShadowOffset property.<br />
485         /// The drop shadow offset 0 indicates no shadow.<br />
486         /// </summary>
487         /// <since_tizen> 3 </since_tizen>
488         /// <remarks>
489         /// Deprecated.(API Level 6) Use Shadow instead.
490         /// The property cascade chaining set is possible. For example, this (textLabel.ShadowOffset.X = 0.1f;) is possible.
491         /// </remarks>
492         [Obsolete("Do not use this ShadowOffset(Deprecated). Use Shadow instead.")]
493         public Vector2 ShadowOffset
494         {
495             get
496             {
497                 return GetValue(ShadowOffsetProperty) as Vector2;
498             }
499             set
500             {
501                 SetValue(ShadowOffsetProperty, value);
502             }
503         }
504
505         private Vector2 InternalShadowOffset
506         {
507             get
508             {
509                 float x = 0.0f, y = 0.0f;
510                 using (var propertyValue = Shadow.Find(TextLabel.Property.SHADOW, "offset"))
511                 using (var shadowOffset = new Vector2())
512                 {
513                     if (null != propertyValue)
514                     {
515                         propertyValue.Get(shadowOffset);
516                         x = shadowOffset.X;
517                         y = shadowOffset.Y;
518                     }
519                 }
520                 return new Vector2(OnShadowOffsetChanged, x, y);
521             }
522             set
523             {
524                 using (var map = new PropertyMap())
525                 {
526                     map.Add("offset", value);
527
528                     var shadowMap = Shadow;
529                     shadowMap.Merge(map);
530
531                     SetValue(ShadowProperty, shadowMap);
532                     NotifyPropertyChanged();
533                 }
534             }
535         }
536
537         /// <summary>
538         /// The ShadowColor property.<br />
539         /// The color of a drop shadow.<br />
540         /// </summary>
541         /// <since_tizen> 3 </since_tizen>
542         /// <remarks>
543         /// Deprecated.(API Level 6) Use Shadow instead.
544         /// The property cascade chaining set is possible. For example, this (textLabel.ShadowColor.X = 0.1f;) is possible.
545         /// </remarks>
546         [Obsolete("Do not use this ShadowColor(Deprecated). Use Shadow instead.")]
547         public Vector4 ShadowColor
548         {
549             get
550             {
551                 return GetValue(ShadowColorProperty) as Vector4;
552             }
553             set
554             {
555                 SetValue(ShadowColorProperty, value);
556             }
557         }
558
559         private Vector4 InternalShadowColor
560         {
561             get
562             {
563                 float x = 0.0f, y = 0.0f, z = 0.0f, w = 0.0f;
564                 using (var propertyValue = Shadow.Find(TextLabel.Property.SHADOW, "color"))
565                 using (var shadowColor = new Vector4())
566                 {
567                     if (null != propertyValue)
568                     {
569                         propertyValue.Get(shadowColor);
570                         x = shadowColor.X;
571                         y = shadowColor.Y;
572                         z = shadowColor.Z;
573                         w = shadowColor.W;
574                     }
575                 }
576                 return new Vector4(OnShadowColorChanged, x, y, z, w);
577             }
578             set
579             {
580                 using (var map = new PropertyMap())
581                 {
582                     map.Add("color", value);
583                     var shadowMap = Shadow;
584                     shadowMap.Merge(map);
585                     SetValue(ShadowProperty, shadowMap);
586                     NotifyPropertyChanged();
587                 }
588             }
589         }
590
591         /// <summary>
592         /// The UnderlineEnabled property.<br />
593         /// The underline enabled flag.<br />
594         /// </summary>
595         /// <since_tizen> 3 </since_tizen>
596         /// <remarks>
597         /// Deprecated.(API Level 6) Use Underline instead.
598         /// </remarks>
599         [Obsolete("Do not use this UnderlineEnabled(Deprecated). Use Underline instead.")]
600         public bool UnderlineEnabled
601         {
602             get
603             {
604                 return (bool)GetValue(UnderlineEnabledProperty);
605             }
606             set
607             {
608                 SetValue(UnderlineEnabledProperty, value);
609             }
610         }
611
612         private bool InternalUnderlineEnabled
613         {
614             get
615             {
616                 bool underlineEnabled = false;
617                 using (var propertyValue = Underline.Find(TextLabel.Property.UNDERLINE, "enable"))
618                 {
619                     if (propertyValue != null)
620                     {
621                         propertyValue.Get(out underlineEnabled);
622                     }
623                 }
624                 return underlineEnabled;
625             }
626             set
627             {
628                 using (var map = new PropertyMap())
629                 {
630                     map.Add("enable", value);
631                     var undelineMap = Underline;
632                     undelineMap.Merge(map);
633                     SetValue(UnderlineProperty, undelineMap);
634                     NotifyPropertyChanged();
635                 }
636             }
637         }
638
639         /// <summary>
640         /// The UnderlineColor property.<br />
641         /// Overrides the underline height from font metrics.<br />
642         /// </summary>
643         /// <since_tizen> 3 </since_tizen>
644         /// <remarks>
645         /// Deprecated.(API Level 6) Use Underline instead.
646         /// The property cascade chaining set is possible. For example, this (textLabel.UnderlineColor.X = 0.1f;) is possible.
647         /// </remarks>
648         [Obsolete("Do not use this UnderlineColor(Deprecated). Use Underline instead.")]
649         public Vector4 UnderlineColor
650         {
651             get
652             {
653                 return GetValue(UnderlineColorProperty) as Vector4;
654             }
655             set
656             {
657                 SetValue(UnderlineColorProperty, value);
658             }
659         }
660
661         private Vector4 InternalUnderlineColor
662         {
663             get
664             {
665                 float x = 0.0f, y = 0.0f, z = 0.0f, w = 0.0f;
666                 using (var propertyValue = Underline.Find(TextLabel.Property.UNDERLINE, "color"))
667                 using (var underlineColor = new Vector4())
668                 {
669                     if (null != propertyValue)
670                     {
671                         propertyValue.Get(underlineColor);
672                         x = underlineColor.X;
673                         y = underlineColor.Y;
674                         z = underlineColor.Z;
675                         w = underlineColor.W;
676                     }
677                 }
678                 return new Vector4(OnUnderlineColorChanged, x, y, z, w);
679             }
680             set
681             {
682                 using (var map = new PropertyMap())
683                 {
684                     map.Add("color", value);
685                     var undelineMap = Underline;
686                     undelineMap.Merge(map);
687                     SetValue(UnderlineProperty, undelineMap);
688                     NotifyPropertyChanged();
689                 }
690             }
691         }
692
693         /// <summary>
694         /// The UnderlineHeight property.<br />
695         /// Overrides the underline height from font metrics.<br />
696         /// </summary>
697         /// <since_tizen> 3 </since_tizen>
698         /// <remarks>
699         /// Deprecated.(API Level 6) Use Underline instead.
700         /// </remarks>
701         [Obsolete("Do not use this UnderlineHeight(Deprecated). Use Underline instead.")]
702         public float UnderlineHeight
703         {
704             get
705             {
706                 return (float)GetValue(UnderlineHeightProperty);
707             }
708             set
709             {
710                 SetValue(UnderlineHeightProperty, value);
711             }
712         }
713
714         private float InternalUnderlineHeight
715         {
716             get
717             {
718                 float underlineHeight = 0.0f;
719                 using (var propertyValue = Underline.Find(TextLabel.Property.UNDERLINE, "height"))
720                 {
721                     if (null != propertyValue)
722                     {
723                         propertyValue.Get(out underlineHeight);
724                     }
725                 }
726                 return underlineHeight;
727             }
728             set
729             {
730                 using (var map = new PropertyMap())
731                 {
732                     map.Add("height", value);
733                     var undelineMap = Underline;
734                     undelineMap.Merge(map);
735                     SetValue(UnderlineProperty, undelineMap);
736                     NotifyPropertyChanged();
737                 }
738             }
739         }
740
741         /// <summary>
742         /// The EnableMarkup property.<br />
743         /// Whether the mark-up processing is enabled.<br />
744         /// </summary>
745         /// <since_tizen> 3 </since_tizen>
746         public bool EnableMarkup
747         {
748             get
749             {
750                 return (bool)GetValue(EnableMarkupProperty);
751             }
752             set
753             {
754                 SetValue(EnableMarkupProperty, value);
755                 NotifyPropertyChanged();
756             }
757         }
758
759         /// <summary>
760         /// The EnableAutoScroll property.<br />
761         /// Starts or stops auto scrolling.<br />
762         /// </summary>
763         /// <since_tizen> 3 </since_tizen>
764         public bool EnableAutoScroll
765         {
766             get
767             {
768                 return (bool)GetValue(EnableAutoScrollProperty);
769             }
770             set
771             {
772                 SetValue(EnableAutoScrollProperty, value);
773                 NotifyPropertyChanged();
774             }
775         }
776
777         /// <summary>
778         /// The AutoScrollSpeed property.<br />
779         /// Sets the speed of scrolling in pixels per second.<br />
780         /// </summary>
781         /// <since_tizen> 3 </since_tizen>
782         public int AutoScrollSpeed
783         {
784             get
785             {
786                 return (int)GetValue(AutoScrollSpeedProperty);
787             }
788             set
789             {
790                 SetValue(AutoScrollSpeedProperty, value);
791                 NotifyPropertyChanged();
792             }
793         }
794
795         /// <summary>
796         /// The AutoScrollLoopCount property.<br />
797         /// Number of complete loops when scrolling enabled.<br />
798         /// </summary>
799         /// <since_tizen> 3 </since_tizen>
800         public int AutoScrollLoopCount
801         {
802             get
803             {
804                 return (int)GetValue(AutoScrollLoopCountProperty);
805             }
806             set
807             {
808                 SetValue(AutoScrollLoopCountProperty, value);
809                 NotifyPropertyChanged();
810             }
811         }
812
813         /// <summary>
814         /// The AutoScrollGap property.<br />
815         /// Gap before scrolling wraps.<br />
816         /// </summary>
817         /// <since_tizen> 3 </since_tizen>
818         public float AutoScrollGap
819         {
820             get
821             {
822                 return (float)GetValue(AutoScrollGapProperty);
823             }
824             set
825             {
826                 SetValue(AutoScrollGapProperty, value);
827                 NotifyPropertyChanged();
828             }
829         }
830
831         /// <summary>
832         /// The LineSpacing property.<br />
833         /// The default extra space between lines in points.<br />
834         /// </summary>
835         /// <since_tizen> 3 </since_tizen>
836         public float LineSpacing
837         {
838             get
839             {
840                 return (float)GetValue(LineSpacingProperty);
841             }
842             set
843             {
844                 SetValue(LineSpacingProperty, value);
845                 NotifyPropertyChanged();
846             }
847         }
848
849         /// <summary>
850         /// The relative height of the line (a factor that will be multiplied by text height). <br />
851         /// If the value is less than 1, the lines could to be overlapped.
852         /// </summary>
853         [EditorBrowsable(EditorBrowsableState.Never)]
854         public float RelativeLineHeight
855         {
856             get
857             {
858                 return (float)GetValue(RelativeLineHeightProperty);
859             }
860             set
861             {
862                 SetValue(RelativeLineHeightProperty, value);
863                 NotifyPropertyChanged();
864             }
865         }
866
867         /// <summary>
868         /// The Underline property.<br />
869         /// The default underline parameters.<br />
870         /// The underline map contains the following keys :<br />
871         /// <list type="table">
872         /// <item><term>enable (bool)</term><description>Whether the underline is enabled (the default value is false)</description></item>
873         /// <item><term>color (Color)</term><description>The color of the underline (If not provided then the color of the text is used)</description></item>
874         /// <item><term>height (float)</term><description>The height in pixels of the underline (the default value is 1.f)</description></item>
875         /// </list>
876         /// </summary>
877         /// <since_tizen> 3 </since_tizen>
878         [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1721: Property names should not match get methods")]
879         public PropertyMap Underline
880         {
881             get
882             {
883                 return (PropertyMap)GetValue(UnderlineProperty);
884             }
885             set
886             {
887                 SetValue(UnderlineProperty, value);
888                 NotifyPropertyChanged();
889             }
890         }
891
892         /// <summary>
893         /// Set Underline to TextLabel. <br />
894         /// </summary>
895         /// <param name="underline">The Underline</param>
896         /// <remarks>
897         /// SetUnderline specifies the underline of the text through <see cref="Tizen.NUI.Text.Underline"/>. <br />
898         /// </remarks>
899         /// <example>
900         /// The following example demonstrates how to use the SetUnderline method.
901         /// <code>
902         /// var underline = new Tizen.NUI.Text.Underline();
903         /// underline.Enable = true;
904         /// underline.Color = new Color("#3498DB");
905         /// underline.Height = 2.0f;
906         /// label.SetUnderline(underline);
907         /// </code>
908         /// </example>
909         [EditorBrowsable(EditorBrowsableState.Never)]
910         public void SetUnderline(Underline underline)
911         {
912             using (var underlineMap = TextMapHelper.GetUnderlineMap(underline))
913             {
914                 SetValue(UnderlineProperty, underlineMap);
915             }
916         }
917
918         /// <summary>
919         /// Get Underline from TextLabel. <br />
920         /// </summary>
921         /// <returns>The Underline</returns>
922         /// <remarks>
923         /// <see cref="Tizen.NUI.Text.Underline"/>
924         /// </remarks>
925         [EditorBrowsable(EditorBrowsableState.Never)]
926         public Underline GetUnderline()
927         {
928             Underline underline;
929             using (var underlineMap = (PropertyMap)GetValue(UnderlineProperty))
930             {
931                 underline = TextMapHelper.GetUnderlineStruct(underlineMap);
932             }
933             return underline;
934         }
935
936         /// <summary>
937         /// The Shadow property.<br />
938         /// The default shadow parameters.<br />
939         /// The shadow map contains the following keys :<br />
940         /// <list type="table">
941         /// <item><term>color (Color)</term><description>The color of the shadow (the default color is Color.Black)</description></item>
942         /// <item><term>offset (Vector2)</term><description>The offset in pixels of the shadow (If not provided then the shadow is not enabled)</description></item>
943         /// <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>
944         /// </list>
945         /// </summary>
946         /// <since_tizen> 3 </since_tizen>
947         [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1721: Property names should not match get methods")]
948         public PropertyMap Shadow
949         {
950             get
951             {
952                 return (PropertyMap)GetValue(ShadowProperty);
953             }
954             set
955             {
956                 SetValue(ShadowProperty, value);
957                 NotifyPropertyChanged();
958             }
959         }
960
961         /// <summary>
962         /// Set Shadow to TextLabel. <br />
963         /// </summary>
964         /// <param name="shadow">The Shadow</param>
965         /// <remarks>
966         /// SetShadow specifies the shadow of the text through <see cref="Tizen.NUI.Text.Shadow"/>. <br />
967         /// </remarks>
968         /// <example>
969         /// The following example demonstrates how to use the SetShadow method.
970         /// <code>
971         /// var shadow = new Tizen.NUI.Text.Shadow();
972         /// shadow.Offset = new Vector2(3, 3);
973         /// shadow.Color = new Color("#F1C40F");
974         /// shadow.BlurRadius = 4.0f;
975         /// label.SetShadow(shadow);
976         /// </code>
977         /// </example>
978         [EditorBrowsable(EditorBrowsableState.Never)]
979         public void SetShadow(Tizen.NUI.Text.Shadow shadow)
980         {
981             using (var shadowMap = TextMapHelper.GetShadowMap(shadow))
982             {
983                 SetValue(ShadowProperty, shadowMap);
984             }
985         }
986
987         /// <summary>
988         /// Get Shadow from TextLabel. <br />
989         /// </summary>
990         /// <returns>The Shadow</returns>
991         /// <remarks>
992         /// <see cref="Tizen.NUI.Text.Shadow"/>
993         /// </remarks>
994         [EditorBrowsable(EditorBrowsableState.Never)]
995         public Tizen.NUI.Text.Shadow GetShadow()
996         {
997             Tizen.NUI.Text.Shadow shadow;
998             using (var shadowMap = (PropertyMap)GetValue(ShadowProperty))
999             {
1000                 shadow = TextMapHelper.GetShadowStruct(shadowMap);
1001             }
1002             return shadow;
1003         }
1004
1005         /// <summary>
1006         /// Describes a text shadow for a TextLabel.
1007         /// It is null by default.
1008         /// </summary>
1009         [EditorBrowsable(EditorBrowsableState.Never)]
1010         public TextShadow TextShadow
1011         {
1012             get
1013             {
1014                 return (TextShadow)GetValue(TextShadowProperty);
1015             }
1016             set
1017             {
1018                 SetValue(TextShadowProperty, value);
1019                 NotifyPropertyChanged();
1020             }
1021         }
1022
1023         /// <summary>
1024         /// The Emboss property.<br />
1025         /// The default emboss parameters.<br />
1026         /// </summary>
1027         /// <since_tizen> 3 </since_tizen>
1028         public string Emboss
1029         {
1030             get
1031             {
1032                 return (string)GetValue(EmbossProperty);
1033             }
1034             set
1035             {
1036                 SetValue(EmbossProperty, value);
1037                 NotifyPropertyChanged();
1038             }
1039         }
1040
1041         /// <summary>
1042         /// The Outline property.<br />
1043         /// The default outline parameters.<br />
1044         /// The outline map contains the following keys :<br />
1045         /// <list type="table">
1046         /// <item><term>color (Color)</term><description>The color of the outline (the default color is Color.White)</description></item>
1047         /// <item><term>width (float)</term><description>The width in pixels of the outline (If not provided then the outline is not enabled)</description></item>
1048         /// </list>
1049         /// </summary>
1050         /// <since_tizen> 3 </since_tizen>
1051         [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1721: Property names should not match get methods")]
1052         public PropertyMap Outline
1053         {
1054             get
1055             {
1056                 return (PropertyMap)GetValue(OutlineProperty);
1057             }
1058             set
1059             {
1060                 SetValue(OutlineProperty, value);
1061                 NotifyPropertyChanged();
1062             }
1063         }
1064
1065         /// <summary>
1066         /// Set Outline to TextLabel. <br />
1067         /// </summary>
1068         /// <param name="outline">The Outline</param>
1069         /// <remarks>
1070         /// SetOutline specifies the outline of the text through <see cref="Tizen.NUI.Text.Outline"/>. <br />
1071         /// </remarks>
1072         /// <example>
1073         /// The following example demonstrates how to use the SetOutline method.
1074         /// <code>
1075         /// var outline = new Tizen.NUI.Text.Outline();
1076         /// outline.Width = 2.0f;
1077         /// outline.Color = new Color("#45B39D");
1078         /// label.SetOutline(outline);
1079         /// </code>
1080         /// </example>
1081         [EditorBrowsable(EditorBrowsableState.Never)]
1082         public void SetOutline(Outline outline)
1083         {
1084             using (var outlineMap = TextMapHelper.GetOutlineMap(outline))
1085             {
1086                 SetValue(OutlineProperty, outlineMap);
1087             }
1088         }
1089
1090         /// <summary>
1091         /// Get Outline from TextLabel. <br />
1092         /// </summary>
1093         /// <returns>The Outline</returns>
1094         /// <remarks>
1095         /// <see cref="Tizen.NUI.Text.Outline"/>
1096         /// </remarks>
1097         [EditorBrowsable(EditorBrowsableState.Never)]
1098         public Outline GetOutline()
1099         {
1100             Outline outline;
1101             using (var outlineMap = (PropertyMap)GetValue(OutlineProperty))
1102             {
1103                 outline = TextMapHelper.GetOutlineStruct(outlineMap);
1104             }
1105             return outline;
1106         }
1107
1108         /// <summary>
1109         /// Set Strikethrough to TextLabel. <br />
1110         /// </summary>
1111         /// <param name="strikethrough">The Strikethrough</param>
1112         /// <remarks>
1113         /// SetStrikethrough specifies the strikethrough of the text through <see cref="Tizen.NUI.Text.Strikethrough"/>. <br />
1114         /// </remarks>
1115         /// <example>
1116         /// The following example demonstrates how to use the SetStrikethrough method.
1117         /// <code>
1118         /// var strikethrough = new Tizen.NUI.Text.Strikethrough();
1119         /// strikethrough.Enable = true;
1120         /// strikethrough.Color = new Color("#3498DB");
1121         /// strikethrough.Height = 2.0f;
1122         /// label.SetStrikethrough(strikethrough);
1123         /// </code>
1124         /// </example>
1125         [EditorBrowsable(EditorBrowsableState.Never)]
1126         public void SetStrikethrough(Strikethrough strikethrough)
1127         {
1128             using (var map = TextMapHelper.GetStrikethroughMap(strikethrough))
1129             using (var propertyValue = new PropertyValue(map))
1130             {
1131                 SetProperty(TextLabel.Property.Strikethrough, propertyValue);
1132             }
1133         }
1134
1135         /// <summary>
1136         /// Get Strikethrough from TextLabel. <br />
1137         /// </summary>
1138         /// <returns>The Strikethrough</returns>
1139         /// <remarks>
1140         /// <see cref="Tizen.NUI.Text.Strikethrough"/>
1141         /// </remarks>
1142         [EditorBrowsable(EditorBrowsableState.Never)]
1143         public Strikethrough GetStrikethrough()
1144         {
1145             Strikethrough strikethrough;
1146             using (var propertyValue = GetProperty(TextLabel.Property.Strikethrough))
1147             using (var map = new PropertyMap())
1148             {
1149                 propertyValue.Get(map);
1150                 strikethrough = TextMapHelper.GetStrikethroughStruct(map);
1151             }
1152             return strikethrough;
1153         }
1154
1155         /// <summary>
1156         /// The PixelSize property.<br />
1157         /// The size of font in pixels.<br />
1158         /// </summary>
1159         /// <since_tizen> 3 </since_tizen>
1160         [Binding.TypeConverter(typeof(FloatGraphicsTypeConverter))]
1161         public float PixelSize
1162         {
1163             get
1164             {
1165                 return (float)GetValue(PixelSizeProperty);
1166             }
1167             set
1168             {
1169                 SetValue(PixelSizeProperty, value);
1170                 NotifyPropertyChanged();
1171             }
1172         }
1173
1174         /// <summary>
1175         /// The Ellipsis property.<br />
1176         /// Enable or disable the ellipsis.<br />
1177         /// </summary>
1178         /// <since_tizen> 3 </since_tizen>
1179         public bool Ellipsis
1180         {
1181             get
1182             {
1183                 return (bool)GetValue(EllipsisProperty);
1184             }
1185             set
1186             {
1187                 SetValue(EllipsisProperty, value);
1188                 NotifyPropertyChanged();
1189             }
1190         }
1191
1192         /// <summary>
1193         /// The ellipsis position of the text.
1194         /// Specifies which portion of the text should be replaced with an ellipsis when the text size exceeds the layout size.<br />
1195         /// </summary>
1196         /// <since_tizen> 9 </since_tizen>
1197         public EllipsisPosition EllipsisPosition
1198         {
1199             get
1200             {
1201                 return (EllipsisPosition)GetValue(EllipsisPositionProperty);
1202             }
1203             set
1204             {
1205                 SetValue(EllipsisPositionProperty, value);
1206                 NotifyPropertyChanged();
1207             }
1208         }
1209
1210         /// <summary>
1211         /// The AutoScrollLoopDelay property.<br />
1212         /// The amount of time to delay the starting time of auto scrolling and further loops.<br />
1213         /// </summary>
1214         /// <since_tizen> 3 </since_tizen>
1215         public float AutoScrollLoopDelay
1216         {
1217             get
1218             {
1219                 return (float)GetValue(AutoScrollLoopDelayProperty);
1220             }
1221             set
1222             {
1223                 SetValue(AutoScrollLoopDelayProperty, value);
1224                 NotifyPropertyChanged();
1225             }
1226         }
1227
1228         /// <summary>
1229         /// The AutoScrollStopMode property.<br />
1230         /// The auto scrolling stop behaviour.<br />
1231         /// The default value is AutoScrollStopMode.FinishLoop. <br />
1232         /// </summary>
1233         /// <since_tizen> 3 </since_tizen>
1234         public AutoScrollStopMode AutoScrollStopMode
1235         {
1236             get
1237             {
1238                 return (AutoScrollStopMode)GetValue(AutoScrollStopModeProperty);
1239             }
1240             set
1241             {
1242                 SetValue(AutoScrollStopModeProperty, value);
1243                 NotifyPropertyChanged();
1244             }
1245         }
1246
1247         /// <summary>
1248         /// The line count of the text.
1249         /// </summary>
1250         /// <since_tizen> 3 </since_tizen>
1251         public int LineCount
1252         {
1253             get
1254             {
1255                 int lineCount = 0;
1256                 using (var propertyValue = GetProperty(TextLabel.Property.LineCount))
1257                 {
1258                     propertyValue.Get(out lineCount);
1259                 }
1260                 return lineCount;
1261             }
1262         }
1263
1264         /// <summary>
1265         /// The LineWrapMode property.<br />
1266         /// line wrap mode when the text lines over layout width.<br />
1267         /// </summary>
1268         /// <since_tizen> 4 </since_tizen>
1269         public LineWrapMode LineWrapMode
1270         {
1271             get
1272             {
1273                 return (LineWrapMode)GetValue(LineWrapModeProperty);
1274             }
1275             set
1276             {
1277                 SetValue(LineWrapModeProperty, value);
1278                 NotifyPropertyChanged();
1279             }
1280         }
1281
1282         /// <summary>
1283         /// The direction of the text such as left to right or right to left.
1284         /// </summary>
1285         /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
1286         [EditorBrowsable(EditorBrowsableState.Never)]
1287         public TextDirection TextDirection
1288         {
1289             get
1290             {
1291                 int textDirection = 0;
1292                 using (var propertyValue = GetProperty(TextLabel.Property.TextDirection))
1293                 {
1294                     propertyValue.Get(out textDirection);
1295                 }
1296                 return (TextDirection)textDirection;
1297             }
1298         }
1299
1300         /// <summary>
1301         /// The vertical line alignment of the text.
1302         /// </summary>
1303         /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
1304         [EditorBrowsable(EditorBrowsableState.Never)]
1305         public VerticalLineAlignment VerticalLineAlignment
1306         {
1307             get
1308             {
1309                 return (VerticalLineAlignment)GetValue(VerticalLineAlignmentProperty);
1310             }
1311             set
1312             {
1313                 SetValue(VerticalLineAlignmentProperty, value);
1314                 NotifyPropertyChanged();
1315             }
1316         }
1317
1318         /// <summary>
1319         /// The text alignment to match the direction of the system language.
1320         /// </summary>
1321         /// <since_tizen> 6 </since_tizen>
1322         public bool MatchSystemLanguageDirection
1323         {
1324             get
1325             {
1326                 return (bool)GetValue(MatchSystemLanguageDirectionProperty);
1327             }
1328             set
1329             {
1330                 SetValue(MatchSystemLanguageDirectionProperty, value);
1331                 NotifyPropertyChanged();
1332             }
1333         }
1334
1335         /// <summary>
1336         /// The text fit parameters.<br />
1337         /// The textFit map contains the following keys :<br />
1338         /// <list type="table">
1339         /// <item><term>enable (bool)</term><description>True to enable the text fit or false to disable (the default value is false)</description></item>
1340         /// <item><term>minSize (float)</term><description>Minimum Size for text fit (the default value is 10.f)</description></item>
1341         /// <item><term>maxSize (float)</term><description>Maximum Size for text fit (the default value is 100.f)</description></item>
1342         /// <item><term>stepSize (float)</term><description>Step Size for font increase (the default value is 1.f)</description></item>
1343         /// <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>
1344         /// </list>
1345         /// </summary>
1346         /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
1347         [EditorBrowsable(EditorBrowsableState.Never)]
1348         [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1721: Property names should not match get methods")]
1349         public PropertyMap TextFit
1350         {
1351             get
1352             {
1353                 return (PropertyMap)GetValue(TextFitProperty);
1354             }
1355             set
1356             {
1357                 SetValue(TextFitProperty, value);
1358                 NotifyPropertyChanged();
1359             }
1360         }
1361
1362         /// <summary>
1363         /// Set TextFit to TextLabel. <br />
1364         /// </summary>
1365         /// <param name="textFit">The TextFit</param>
1366         /// <remarks>
1367         /// SetTextFit specifies the textFit of the text through <see cref="Tizen.NUI.Text.TextFit"/>. <br />
1368         /// </remarks>
1369         /// <example>
1370         /// The following example demonstrates how to use the SetTextFit method.
1371         /// <code>
1372         /// var textFit = new Tizen.NUI.Text.TextFit();
1373         /// textFit.Enable = true;
1374         /// textFit.MinSize = 10.0f;
1375         /// textFit.MaxSize = 100.0f;
1376         /// textFit.StepSize = 5.0f;
1377         /// textFit.FontSizeType = FontSizeType.PointSize;
1378         /// label.SetTextFit(textFit);
1379         /// </code>
1380         /// </example>
1381         [EditorBrowsable(EditorBrowsableState.Never)]
1382         public void SetTextFit(TextFit textFit)
1383         {
1384             using (var textFitMap = TextMapHelper.GetTextFitMap(textFit))
1385             {
1386                 SetValue(TextFitProperty, textFitMap);
1387             }
1388         }
1389
1390         /// <summary>
1391         /// Get TextFit from TextLabel. <br />
1392         /// </summary>
1393         /// <returns>The TextFit</returns>
1394         /// <remarks>
1395         /// TextFit is always returned based on PointSize. <br />
1396         /// If the user sets FontSizeType to PixelSize, then MinSize, MaxSize, and StepSize are converted based on PointSize and returned. <br />
1397         /// <see cref="Tizen.NUI.Text.TextFit"/>
1398         /// </remarks>
1399         [EditorBrowsable(EditorBrowsableState.Never)]
1400         public TextFit GetTextFit()
1401         {
1402             TextFit textFit;
1403             using (var textFitMap = (PropertyMap)GetValue(TextFitProperty))
1404             {
1405                 textFit = TextMapHelper.GetTextFitStruct(textFitMap);
1406             }
1407             return textFit;
1408         }
1409
1410         /// <summary>
1411         /// Set TextFitArray to TextLabel. <br />
1412         /// TextFitArray finds and applies the largest PointSize that fits among OptionList.
1413         /// </summary>
1414         /// <param name="textFitArray">The TextFitArray</param>
1415         /// <remarks>
1416         /// TextFitArray tries binary search by default. <br />
1417         /// The precondition for TextFitArray to perform binary search is sorting in ascending order of MinLineSize. <br />
1418         /// Because if MinLineSize is not sorted in ascending order, <br />
1419         /// binary search cannot guarantee that it will always find the best value. <br />
1420         /// In this case, the search sequentially starts from the largest PointSize. <br />
1421         /// If TextFitArrayOption's MinLineSize is set to null or 0, <br />
1422         /// TextFitArray is calculated without applying MinLineSize. <br />
1423         /// If TextFitArray is enabled, TextLabel's MinLineSize property is ignored. <br />
1424         /// See <see cref="Tizen.NUI.Text.TextFitArray"/> and <see cref="Tizen.NUI.Text.TextFitArrayOption"/>.
1425         /// </remarks>
1426         /// <example>
1427         /// The following example demonstrates how to use the SetTextFitArray method. <br />
1428         /// <code>
1429         /// var textFitArray = new Tizen.NUI.Text.TextFitArray();
1430         /// textFitArray.Enable = true;
1431         /// textFitArray.OptionList = new List&lt;Tizen.NUI.Text.TextFitArrayOption&gt;()
1432         /// {
1433         ///     new Tizen.NUI.Text.TextFitArrayOption(12, 18),
1434         ///     new Tizen.NUI.Text.TextFitArrayOption(24, 40),
1435         ///     new Tizen.NUI.Text.TextFitArrayOption(28, 48),
1436         ///     new Tizen.NUI.Text.TextFitArrayOption(32, 56),
1437         ///     new Tizen.NUI.Text.TextFitArrayOption(50, 72),
1438         /// };
1439         /// label.SetTextFitArray(textFitArray);
1440         /// </code>
1441         /// <br />
1442         /// The table below shows cases where binary search is possible and where it is not possible. <br />
1443         /// <code>
1444         /// [Binary search possible]
1445         /// |            | List index  |  0 |  1 |  2 |  3 |
1446         /// | OptionList | PointSize   | 24 | 28 | 32 | 48 |
1447         /// |            | MinLineSize | 40 | 48 | 48 | 62 | &lt;&lt; MinLineSize sorted in ascending order
1448         ///                                    ^    ^
1449         ///                                    same values â€‹are not a problem
1450         ///
1451         /// [Binary search not possible]
1452         /// |            | List index  |  0 |  1 |  2 |  3 |
1453         /// | OptionList | PointSize   | 24 | 28 | 32 | 48 |
1454         /// |            | MinLineSize | 40 | 48 | 38 | 62 | &lt;&lt; MinLineSize is not sorted in ascending order
1455         ///                                         ^
1456         /// </code>
1457         /// </example>
1458         [EditorBrowsable(EditorBrowsableState.Never)]
1459         public void SetTextFitArray(TextFitArray textFitArray)
1460         {
1461             bool enable = textFitArray.Enable;
1462             int optionListSize = textFitArray.OptionList?.Count ?? 0;
1463
1464             float[] pointSizeArray = new float[optionListSize];
1465             float[] minLineSizeArray = new float[optionListSize];
1466
1467             for (int i = 0 ; i < optionListSize ; i ++)
1468             {
1469                 TextFitArrayOption option = textFitArray.OptionList[i];
1470                 pointSizeArray[i] = option.PointSize;
1471                 minLineSizeArray[i] = option.MinLineSize ?? 0;
1472             }
1473
1474             Interop.TextLabel.SetTextFitArray(SwigCPtr, enable, (uint)optionListSize, pointSizeArray, minLineSizeArray);
1475             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1476         }
1477
1478         /// <summary>
1479         /// Get TextFitArray from TextLabel.
1480         /// </summary>
1481         /// <returns>The TextFitArray</returns>
1482         /// <remarks>
1483         /// See <see cref="Tizen.NUI.Text.TextFitArray"/> and <see cref="Tizen.NUI.Text.TextFitArrayOption"/>.
1484         /// </remarks>
1485         /// <example>
1486         /// The following example demonstrates how to use the GetTextFitArray method. <br />
1487         /// <code>
1488         /// Tizen.NUI.Text.TextFitArray textFitArray = label.GetTextFitArray();
1489         /// bool enable = textFitArray.Enable;
1490         /// var optionList = textFitArray.OptionList;
1491         /// foreach(Tizen.NUI.Text.TextFitArrayOption option in optionList)
1492         /// {
1493         ///     float pointSize = option.PointSize;
1494         ///     float minLinesize = option.MinLineSize;
1495         /// }
1496         /// </code>
1497         /// </example>
1498         [EditorBrowsable(EditorBrowsableState.Never)]
1499         public TextFitArray GetTextFitArray()
1500         {
1501             using PropertyMap textFitArrayMap = new PropertyMap(Interop.TextLabel.GetTextFitArray(SwigCPtr), true);
1502             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1503
1504             TextFitArray textFitArray;
1505             textFitArray = TextUtils.GetMapToTextFitArray(textFitArrayMap);
1506             return textFitArray;
1507         }
1508
1509         /// <summary>
1510         /// The MinLineSize property.<br />
1511         /// The height of the line in points. <br />
1512         /// If the font size is larger than the line size, it works with the font size. <br />
1513         /// </summary>
1514         /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
1515         [EditorBrowsable(EditorBrowsableState.Never)]
1516         public float MinLineSize
1517         {
1518             get
1519             {
1520                 return (float)GetValue(MinLineSizeProperty);
1521             }
1522             set
1523             {
1524                 SetValue(MinLineSizeProperty, value);
1525                 NotifyPropertyChanged();
1526             }
1527         }
1528
1529         /// <summary>
1530         /// The spaces between characters in Pixels.
1531         /// <remarks>
1532         /// A positive value will make the characters far apart (expanded) and a negative value will bring them closer (condensed).<br />
1533         /// The default value is 0.f which does nothing.
1534         ///</remarks>
1535         /// </summary>
1536         [EditorBrowsable(EditorBrowsableState.Never)]
1537         public float CharacterSpacing
1538         {
1539             get
1540             {
1541                 return (float)GetValue(CharacterSpacingProperty);
1542             }
1543             set
1544             {
1545                 SetValue(CharacterSpacingProperty, value);
1546                 NotifyPropertyChanged();
1547             }
1548         }
1549
1550         /// <summary>
1551         /// The FontSizeScale property for scaling the specified font size up or down. <br />
1552         /// The default value is 1.0. <br />
1553         /// The given font size scale value is used for multiplying the specified font size before querying fonts. <br />
1554         /// If FontSizeScale.UseSystemSetting, will use the SystemSettings.FontSize internally. <br />
1555         /// </summary>
1556         /// <since_tizen> 9 </since_tizen>
1557         public float FontSizeScale
1558         {
1559             get
1560             {
1561                 return (float)GetValue(FontSizeScaleProperty);
1562             }
1563             set
1564             {
1565                 SetValue(FontSizeScaleProperty, value);
1566                 NotifyPropertyChanged();
1567             }
1568         }
1569
1570         private float InternalFontSizeScale
1571         {
1572             get
1573             {
1574                 return fontSizeScale;
1575             }
1576             set
1577             {
1578                 float newFontSizeScale;
1579
1580                 if (fontSizeScale == value) return;
1581
1582                 fontSizeScale = value;
1583                 if (fontSizeScale == Tizen.NUI.FontSizeScale.UseSystemSetting)
1584                 {
1585                     SystemSettingsFontSize systemSettingsFontSize;
1586
1587                     try
1588                     {
1589                         systemSettingsFontSize = SystemSettings.FontSize;
1590                     }
1591                     catch (Exception e)
1592                     {
1593                         Console.WriteLine("{0} Exception caught.", e);
1594                         systemSettingsFontSize = SystemSettingsFontSize.Normal;
1595                     }
1596                     newFontSizeScale = TextUtils.GetFontSizeScale(systemSettingsFontSize);
1597                     AddSystemSettingsFontSizeChanged();
1598                 }
1599                 else
1600                 {
1601                     newFontSizeScale = fontSizeScale;
1602                     RemoveSystemSettingsFontSizeChanged();
1603                 }
1604
1605                 SetInternalFontSizeScale(newFontSizeScale);
1606             }
1607         }
1608
1609         private void SetInternalFontSizeScale(float fontSizeScale)
1610         {
1611
1612             Object.InternalSetPropertyFloat(this.SwigCPtr, TextLabel.Property.FontSizeScale, (float)fontSizeScale);
1613             RequestLayout();
1614         }
1615
1616         /// <summary>
1617         /// The EnableFontSizeScale property.<br />
1618         /// Whether the font size scale is enabled. (The default value is true)
1619         /// </summary>
1620         [EditorBrowsable(EditorBrowsableState.Never)]
1621         public bool EnableFontSizeScale
1622         {
1623             get
1624             {
1625                 return (bool)GetValue(EnableFontSizeScaleProperty);
1626             }
1627             set
1628             {
1629                 SetValue(EnableFontSizeScaleProperty, value);
1630                 NotifyPropertyChanged();
1631             }
1632         }
1633
1634         private TextLabelSelectorData EnsureSelectorData() => selectorData ?? (selectorData = new TextLabelSelectorData());
1635
1636         /// <summary>
1637         /// Downcasts a handle to textLabel handle
1638         /// </summary>
1639         /// <param name="handle"></param>
1640         /// <returns></returns>
1641         /// <exception cref="ArgumentNullException"> Thrown when handle is null. </exception>
1642         /// <since_tizen> 3 </since_tizen>
1643         /// Do not use this, that will be deprecated. Use as keyword instead.
1644         [Obsolete("Do not use this, that will be deprecated. Use as keyword instead. " +
1645             "Like: " +
1646             "BaseHandle handle = new TextLabel(\"Hello World!\"); " +
1647             "TextLabel label = handle as TextLabel")]
1648         [EditorBrowsable(EditorBrowsableState.Never)]
1649         public static TextLabel DownCast(BaseHandle handle)
1650         {
1651             if (null == handle)
1652             {
1653                 throw new ArgumentNullException(nameof(handle));
1654             }
1655             TextLabel ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as TextLabel;
1656             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1657             return ret;
1658         }
1659
1660         /// <inheritdoc/>
1661         [EditorBrowsable(EditorBrowsableState.Never)]
1662         protected override void Dispose(DisposeTypes type)
1663         {
1664             if (disposed)
1665             {
1666                 return;
1667             }
1668
1669             internalTextColor?.Dispose();
1670
1671             if (hasSystemLanguageChanged)
1672             {
1673                 systemLocaleLanguageChanged.Remove(SystemSettingsLocaleLanguageChanged);
1674             }
1675
1676             RemoveSystemSettingsFontTypeChanged();
1677             RemoveSystemSettingsFontSizeChanged();
1678
1679             if (type == DisposeTypes.Explicit)
1680             {
1681                 //Called by User
1682                 //Release your own managed resources here.
1683                 //You should release all of your own disposable objects here.
1684                 selectorData?.Reset(this);
1685             }
1686
1687             if (this.HasBody())
1688             {
1689                 if (textLabelTextFitChangedCallbackDelegate != null)
1690                 {
1691                     TextFitChangedSignal().Disconnect(textLabelTextFitChangedCallbackDelegate);
1692                 }
1693             }
1694
1695             base.Dispose(type);
1696         }
1697
1698         /// This will not be public opened.
1699         [EditorBrowsable(EditorBrowsableState.Never)]
1700         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1701         {
1702             Interop.TextLabel.DeleteTextLabel(swigCPtr);
1703         }
1704
1705         /// <summary>
1706         /// Get attribues, it is abstract function and must be override.
1707         /// </summary>
1708         [EditorBrowsable(EditorBrowsableState.Never)]
1709         protected override ViewStyle CreateViewStyle()
1710         {
1711             return new TextLabelStyle();
1712         }
1713
1714         internal override LayoutItem CreateDefaultLayout()
1715         {
1716             return new TextLayout();
1717         }
1718
1719         /// <summary>
1720         /// Invoked whenever the binding context of the textlabel changes. Implement this method to add class handling for this event.
1721         /// </summary>
1722         protected override void OnBindingContextChanged()
1723         {
1724             base.OnBindingContextChanged();
1725         }
1726
1727         private void SystemSettingsLocaleLanguageChanged(object sender, LocaleLanguageChangedEventArgs e)
1728         {
1729             Text = NUIApplication.MultilingualResourceManager?.GetString(textLabelSid, new CultureInfo(e.Value.Replace("_", "-")));
1730         }
1731
1732         private void SystemSettingsFontSizeChanged(object sender, FontSizeChangedEventArgs e)
1733         {
1734             float newFontSizeScale = TextUtils.GetFontSizeScale(e.Value);
1735             SetInternalFontSizeScale(newFontSizeScale);
1736         }
1737
1738         private void AddSystemSettingsFontSizeChanged()
1739         {
1740             if (hasSystemFontSizeChanged != true)
1741             {
1742                 try
1743                 {
1744                     SystemFontSizeChangedManager.Add(SystemSettingsFontSizeChanged);
1745                     hasSystemFontSizeChanged = true;
1746                 }
1747                 catch (Exception e)
1748                 {
1749                     Console.WriteLine("{0} Exception caught.", e);
1750                     hasSystemFontSizeChanged = false;
1751                 }
1752             }
1753         }
1754
1755         private void RemoveSystemSettingsFontSizeChanged()
1756         {
1757             if (hasSystemFontSizeChanged == true)
1758             {
1759                 try
1760                 {
1761                     SystemFontSizeChangedManager.Remove(SystemSettingsFontSizeChanged);
1762                     hasSystemFontSizeChanged = false;
1763                 }
1764                 catch (Exception e)
1765                 {
1766                     Console.WriteLine("{0} Exception caught.", e);
1767                     hasSystemFontSizeChanged = true;
1768                 }
1769             }
1770         }
1771
1772         private void SystemSettingsFontTypeChanged(object sender, FontTypeChangedEventArgs e)
1773         {
1774             SetInternalFontFamily(e.Value);
1775         }
1776
1777         private void AddSystemSettingsFontTypeChanged()
1778         {
1779             if (HasStyle() && !hasSystemFontTypeChanged)
1780             {
1781                 try
1782                 {
1783                     systemFontTypeChanged.Add(SystemSettingsFontTypeChanged);
1784                     hasSystemFontTypeChanged = true;
1785                 }
1786                 catch (Exception e)
1787                 {
1788                     Console.WriteLine("{0} Exception caught.", e);
1789                     hasSystemFontTypeChanged = false;
1790                 }
1791             }
1792         }
1793         
1794         private void RemoveSystemSettingsFontTypeChanged()
1795         {
1796             if (hasSystemFontTypeChanged)
1797             {
1798                 try
1799                 {
1800                     systemFontTypeChanged.Remove(SystemSettingsFontTypeChanged);
1801                     hasSystemFontTypeChanged = false;
1802                 }
1803                 catch (Exception e)
1804                 {
1805                     Console.WriteLine("{0} Exception caught.", e);
1806                     hasSystemFontTypeChanged = true;
1807                 }
1808             }
1809         }
1810
1811         private void RequestLayout()
1812         {
1813             Layout?.RequestLayout();
1814         }
1815
1816         internal new class Property
1817         {
1818             internal static readonly int TEXT = Interop.TextLabel.TextGet();
1819             internal static readonly int FontFamily = Interop.TextLabel.FontFamilyGet();
1820             internal static readonly int FontStyle = Interop.TextLabel.FontStyleGet();
1821             internal static readonly int PointSize = Interop.TextLabel.PointSizeGet();
1822             internal static readonly int MultiLine = Interop.TextLabel.MultiLineGet();
1823             internal static readonly int HorizontalAlignment = Interop.TextLabel.HorizontalAlignmentGet();
1824             internal static readonly int VerticalAlignment = Interop.TextLabel.VerticalAlignmentGet();
1825             internal static readonly int TextColor = Interop.TextLabel.TextColorGet();
1826             internal static readonly int EnableMarkup = Interop.TextLabel.EnableMarkupGet();
1827             internal static readonly int EnableAutoScroll = Interop.TextLabel.EnableAutoScrollGet();
1828             internal static readonly int AutoScrollSpeed = Interop.TextLabel.AutoScrollSpeedGet();
1829             internal static readonly int AutoScrollLoopCount = Interop.TextLabel.AutoScrollLoopCountGet();
1830             internal static readonly int AutoScrollGap = Interop.TextLabel.AutoScrollGapGet();
1831             internal static readonly int LineSpacing = Interop.TextLabel.LineSpacingGet();
1832             internal static readonly int RelativeLineHeight = Interop.TextLabel.RelativeLineHeightGet();
1833             internal static readonly int UNDERLINE = Interop.TextLabel.UnderlineGet();
1834             internal static readonly int SHADOW = Interop.TextLabel.ShadowGet();
1835             internal static readonly int EMBOSS = Interop.TextLabel.EmbossGet();
1836             internal static readonly int OUTLINE = Interop.TextLabel.OutlineGet();
1837             internal static readonly int PixelSize = Interop.TextLabel.PixelSizeGet();
1838             internal static readonly int ELLIPSIS = Interop.TextLabel.EllipsisGet();
1839             internal static readonly int AutoScrollStopMode = Interop.TextLabel.AutoScrollStopModeGet();
1840             internal static readonly int AutoScrollLoopDelay = Interop.TextLabel.AutoScrollLoopDelayGet();
1841             internal static readonly int LineCount = Interop.TextLabel.LineCountGet();
1842             internal static readonly int LineWrapMode = Interop.TextLabel.LineWrapModeGet();
1843             internal static readonly int TextDirection = Interop.TextLabel.TextDirectionGet();
1844             internal static readonly int VerticalLineAlignment = Interop.TextLabel.VerticalLineAlignmentGet();
1845             internal static readonly int MatchSystemLanguageDirection = Interop.TextLabel.MatchSystemLanguageDirectionGet();
1846             internal static readonly int TextFit = Interop.TextLabel.TextFitGet();
1847             internal static readonly int MinLineSize = Interop.TextLabel.MinLineSizeGet();
1848             internal static readonly int FontSizeScale = Interop.TextLabel.FontSizeScaleGet();
1849             internal static readonly int EnableFontSizeScale = Interop.TextLabel.EnableFontSizeScaleGet();
1850             internal static readonly int EllipsisPosition = Interop.TextLabel.EllipsisPositionGet();
1851             internal static readonly int Strikethrough = Interop.TextLabel.StrikethroughGet();
1852             internal static readonly int CharacterSpacing = Interop.TextLabel.CharacterSpacingGet();
1853
1854             internal static void Preload()
1855             {
1856                 // Do nothing. Just call for load static values.
1857             }
1858         }
1859
1860         private void OnShadowColorChanged(float x, float y, float z, float w)
1861         {
1862             ShadowColor = new Vector4(x, y, z, w);
1863         }
1864         private void OnShadowOffsetChanged(float x, float y)
1865         {
1866             ShadowOffset = new Vector2(x, y);
1867         }
1868         private void OnTextColorChanged(float r, float g, float b, float a)
1869         {
1870             TextColor = new Color(r, g, b, a);
1871         }
1872         private void OnUnderlineColorChanged(float x, float y, float z, float w)
1873         {
1874             UnderlineColor = new Vector4(x, y, z, w);
1875         }
1876     }
1877 }