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