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