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