[NUI] Remove upcast
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / TextLabel.cs
1 /*
2  * Copyright(c) 2020 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 using System;
21 using System.Globalization;
22 using System.ComponentModel;
23 using Tizen.NUI.Binding;
24
25 namespace Tizen.NUI.BaseComponents
26 {
27     /// <summary>
28     /// A control which renders a short text string.<br />
29     /// Text labels are lightweight, non-editable, and do not respond to the user input.<br />
30     /// </summary>
31     /// <since_tizen> 3 </since_tizen>
32     public partial class TextLabel : View
33     {
34         private class TextLayout : LayoutItem
35         {
36             protected override void OnMeasure(MeasureSpecification widthMeasureSpec, MeasureSpecification heightMeasureSpec)
37             {
38                 // Padding will be automatically applied by DALi TextLabel.
39                 float totalWidth = widthMeasureSpec.Size.AsDecimal();
40                 float totalHeight = heightMeasureSpec.Size.AsDecimal();
41
42                 if (widthMeasureSpec.Mode == MeasureSpecification.ModeType.Exactly)
43                 {
44                     if (heightMeasureSpec.Mode != MeasureSpecification.ModeType.Exactly)
45                     {
46                         totalHeight = Owner.GetHeightForWidth(totalWidth);
47                         heightMeasureSpec = new MeasureSpecification(new LayoutLength(totalHeight), MeasureSpecification.ModeType.Exactly);
48                     }
49                 }
50                 else
51                 {
52                     if (heightMeasureSpec.Mode == MeasureSpecification.ModeType.Exactly)
53                     {
54                         // GetWidthForHeight is not implemented.
55                         totalWidth = Owner.GetNaturalSize().Width;
56                         widthMeasureSpec = new MeasureSpecification(new LayoutLength(totalWidth), MeasureSpecification.ModeType.Exactly);
57                     }
58                     else
59                     {
60                         Vector3 naturalSize = Owner.GetNaturalSize();
61                         totalWidth = naturalSize.Width;
62                         totalHeight = naturalSize.Height;
63
64                         heightMeasureSpec = new MeasureSpecification(new LayoutLength(totalHeight), MeasureSpecification.ModeType.Exactly);
65                         widthMeasureSpec = new MeasureSpecification(new LayoutLength(totalWidth), MeasureSpecification.ModeType.Exactly);
66                     }
67                 }
68
69                 MeasuredSize.StateType childWidthState = MeasuredSize.StateType.MeasuredSizeOK;
70                 MeasuredSize.StateType childHeightState = MeasuredSize.StateType.MeasuredSizeOK;
71
72                 SetMeasuredDimensions(ResolveSizeAndState(new LayoutLength(totalWidth), widthMeasureSpec, childWidthState),
73                                        ResolveSizeAndState(new LayoutLength(totalHeight), heightMeasureSpec, childHeightState));
74             }
75         }
76
77         static TextLabel() { }
78
79         private string textLabelSid = null;
80         private bool systemlangTextFlag = false;
81         private TextLabelSelectorData selectorData;
82         private float fontSizeScale = 1.0f;
83         private bool hasFontSizeChangedCallback = false;
84
85         /// <summary>
86         /// Creates the TextLabel control.
87         /// </summary>
88         /// <since_tizen> 3 </since_tizen>
89         public TextLabel() : this(Interop.TextLabel.New(), true)
90         {
91             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
92             Layout = new TextLayout();
93         }
94
95         /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
96         [EditorBrowsable(EditorBrowsableState.Never)]
97         public TextLabel(TextLabelStyle viewStyle) : this(Interop.TextLabel.New(), true, viewStyle)
98         {
99             Layout = new TextLayout();
100         }
101
102         /// <summary>
103         /// Creates the TextLabel with setting the status of shown or hidden.
104         /// </summary>
105         /// <param name="shown">false : Not displayed (hidden), true : displayed (shown)</param>
106         /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
107         [EditorBrowsable(EditorBrowsableState.Never)]
108         public TextLabel(bool shown) : this(Interop.TextLabel.New(), true)
109         {
110             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
111             Layout = new TextLayout();
112             SetVisible(shown);
113         }
114
115         /// <summary>
116         /// Creates the TextLabel control.
117         /// </summary>
118         /// <param name="text">The text to display</param>
119         /// <since_tizen> 3 </since_tizen>
120         public TextLabel(string text) : this(Interop.TextLabel.New(text), true)
121         {
122             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
123             Layout = new TextLayout();
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             Layout = new TextLayout();
137             SetVisible(shown);
138         }
139
140         internal TextLabel(TextLabel handle, bool shown = true) : this(Interop.TextLabel.NewTextLabel(TextLabel.getCPtr(handle)), true)
141         {
142             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
143
144             if (!shown)
145             {
146                 SetVisible(false);
147             }
148         }
149
150         internal TextLabel(global::System.IntPtr cPtr, bool cMemoryOwn, ViewStyle viewStyle, bool shown = true) : base(cPtr, cMemoryOwn, viewStyle)
151         {
152             if (!shown)
153             {
154                 SetVisible(false);
155             }
156         }
157
158         internal TextLabel(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true) : base(cPtr, cMemoryOwn, null)
159         {
160             if (!shown)
161             {
162                 SetVisible(false);
163             }
164         }
165
166         /// <summary>
167         /// The TranslatableText property.<br />
168         /// The text can set the SID value.<br />
169         /// </summary>
170         /// <exception cref='ArgumentNullException'>
171         /// ResourceManager about multilingual is null.
172         /// </exception>
173         /// <since_tizen> 4 </since_tizen>
174         public string TranslatableText
175         {
176             get
177             {
178                 return (string)GetValue(TranslatableTextProperty);
179             }
180             set
181             {
182                 SetValue(TranslatableTextProperty, value);
183                 selectorData?.TranslatableText.UpdateIfNeeds(this, value);
184             }
185         }
186         private string translatableText
187         {
188             get
189             {
190                 return textLabelSid;
191             }
192             set
193             {
194                 if (NUIApplication.MultilingualResourceManager == null)
195                 {
196                     throw new ArgumentNullException(null, "ResourceManager about multilingual is null");
197                 }
198                 string translatableText = null;
199                 textLabelSid = value;
200                 translatableText = NUIApplication.MultilingualResourceManager?.GetString(textLabelSid, new CultureInfo(SystemSettings.LocaleLanguage.Replace("_", "-")));
201                 if (translatableText != null)
202                 {
203                     Text = translatableText;
204                     if (systemlangTextFlag == false)
205                     {
206                         SystemSettings.LocaleLanguageChanged += SystemSettings_LocaleLanguageChanged;
207                         systemlangTextFlag = true;
208                     }
209                 }
210                 else
211                 {
212                     Text = "";
213                 }
214                 NotifyPropertyChanged();
215             }
216         }
217
218         /// <summary>
219         /// The Text property.<br />
220         /// The text to display in the UTF-8 format.<br />
221         /// </summary>
222         /// <since_tizen> 3 </since_tizen>
223         public string Text
224         {
225             get
226             {
227                 return (string)GetValue(TextProperty);
228             }
229             set
230             {
231                 SetValue(TextProperty, value);
232                 selectorData?.Text.UpdateIfNeeds(this, value);
233                 NotifyPropertyChangedAndRequestLayout();
234             }
235         }
236
237         /// <summary>
238         /// The FontFamily property.<br />
239         /// The requested font family to use.<br />
240         /// </summary>
241         /// <since_tizen> 3 </since_tizen>
242         public string FontFamily
243         {
244             get
245             {
246                 return (string)GetValue(FontFamilyProperty);
247             }
248             set
249             {
250                 SetValue(FontFamilyProperty, value);
251                 selectorData?.FontFamily.UpdateIfNeeds(this, value);
252                 NotifyPropertyChangedAndRequestLayout();
253             }
254         }
255
256         /// <summary>
257         /// The FontStyle property.<br />
258         /// The requested font style to use.<br />
259         /// </summary>
260         /// <since_tizen> 3 </since_tizen>
261         public PropertyMap FontStyle
262         {
263             get
264             {
265                 return (PropertyMap)GetValue(FontStyleProperty);
266             }
267             set
268             {
269                 SetValue(FontStyleProperty, value);
270                 NotifyPropertyChangedAndRequestLayout();
271             }
272         }
273
274         /// <summary>
275         /// The PointSize property.<br />
276         /// The size of font in points.<br />
277         /// </summary>
278         /// <since_tizen> 3 </since_tizen>
279         public float PointSize
280         {
281             get
282             {
283                 return (float)GetValue(PointSizeProperty);
284             }
285             set
286             {
287                 SetValue(PointSizeProperty, value);
288                 selectorData?.PointSize.UpdateIfNeeds(this, value);
289                 NotifyPropertyChangedAndRequestLayout();
290             }
291         }
292
293         /// <summary>
294         /// The MultiLine property.<br />
295         /// The single-line or multi-line layout option.<br />
296         /// </summary>
297         /// <since_tizen> 3 </since_tizen>
298         public bool MultiLine
299         {
300             get
301             {
302                 return (bool)GetValue(MultiLineProperty);
303             }
304             set
305             {
306                 SetValue(MultiLineProperty, value);
307                 NotifyPropertyChangedAndRequestLayout();
308             }
309         }
310
311         /// <summary>
312         /// The HorizontalAlignment property.<br />
313         /// The line horizontal alignment.<br />
314         /// </summary>
315         /// <since_tizen> 3 </since_tizen>
316         public HorizontalAlignment HorizontalAlignment
317         {
318             get
319             {
320                 return (HorizontalAlignment)GetValue(HorizontalAlignmentProperty);
321             }
322             set
323             {
324                 SetValue(HorizontalAlignmentProperty, value);
325                 NotifyPropertyChanged();
326             }
327         }
328
329         /// <summary>
330         /// The VerticalAlignment property.<br />
331         /// The line vertical alignment.<br />
332         /// </summary>
333         /// <since_tizen> 3 </since_tizen>
334         public VerticalAlignment VerticalAlignment
335         {
336             get
337             {
338                 return (VerticalAlignment)GetValue(VerticalAlignmentProperty);
339             }
340             set
341             {
342                 SetValue(VerticalAlignmentProperty, value);
343                 NotifyPropertyChanged();
344             }
345         }
346
347         /// <summary>
348         /// The TextColor property.<br />
349         /// The color of the text.<br />
350         /// Animation framework can be used to change the color of the text when not using mark up.<br />
351         /// Cannot animate the color when text is auto scrolling.<br />
352         /// </summary>
353         /// <remarks>
354         /// The property cascade chaining set is possible. For example, this (textLabel.TextColor.X = 0.1f;) is possible.
355         /// </remarks>
356         /// <since_tizen> 3 </since_tizen>
357         public Color TextColor
358         {
359             get
360             {
361                 Color temp = (Color)GetValue(TextColorProperty);
362                 return new Color(OnTextColorChanged, temp.R, temp.G, temp.B, temp.A);
363             }
364             set
365             {
366                 SetValue(TextColorProperty, value);
367                 selectorData?.TextColor.UpdateIfNeeds(this, value);
368                 NotifyPropertyChanged();
369             }
370         }
371
372         /// <summary>
373         /// The ShadowOffset property.<br />
374         /// The drop shadow offset 0 indicates no shadow.<br />
375         /// </summary>
376         /// <since_tizen> 3 </since_tizen>
377         /// <remarks>
378         /// Deprecated.(API Level 6) Use Shadow instead.
379         /// The property cascade chaining set is possible. For example, this (textLabel.ShadowOffset.X = 0.1f;) is possible.
380         /// </remarks>
381         [Obsolete("Please do not use this ShadowOffset(Deprecated). Please use Shadow instead.")]
382         public Vector2 ShadowOffset
383         {
384             get
385             {
386                 Vector2 shadowOffset = new Vector2();
387                 Shadow.Find(TextLabel.Property.SHADOW, "offset")?.Get(shadowOffset);
388                 return new Vector2(OnShadowOffsetChanged, shadowOffset.X, shadowOffset.Y);
389             }
390             set
391             {
392                 PropertyMap temp = new PropertyMap();
393                 temp.Insert("offset", new PropertyValue(value));
394
395                 PropertyMap shadowMap = Shadow;
396                 shadowMap.Merge(temp);
397
398                 SetValue(ShadowProperty, shadowMap);
399                 NotifyPropertyChanged();
400             }
401         }
402
403         /// <summary>
404         /// The ShadowColor property.<br />
405         /// The color of a drop shadow.<br />
406         /// </summary>
407         /// <since_tizen> 3 </since_tizen>
408         /// <remarks>
409         /// Deprecated.(API Level 6) Use Shadow instead.
410         /// The property cascade chaining set is possible. For example, this (textLabel.ShadowColor.X = 0.1f;) is possible.
411         /// </remarks>
412         [Obsolete("Please do not use this ShadowColor(Deprecated). Please use Shadow instead.")]
413         public Vector4 ShadowColor
414         {
415             get
416             {
417                 Vector4 shadowColor = new Vector4();
418                 Shadow.Find(TextLabel.Property.SHADOW, "color")?.Get(shadowColor);
419                 return new Vector4(OnShadowColorChanged, shadowColor.X, shadowColor.Y, shadowColor.Z, shadowColor.W);
420             }
421             set
422             {
423                 PropertyMap temp = new PropertyMap();
424                 temp.Insert("color", new PropertyValue(value));
425
426                 PropertyMap shadowMap = Shadow;
427                 shadowMap.Merge(temp);
428
429                 SetValue(ShadowProperty, shadowMap);
430                 NotifyPropertyChanged();
431             }
432         }
433
434         /// <summary>
435         /// The UnderlineEnabled property.<br />
436         /// The underline enabled flag.<br />
437         /// </summary>
438         /// <since_tizen> 3 </since_tizen>
439         /// <remarks>
440         /// Deprecated.(API Level 6) Use Underline instead.
441         /// </remarks>
442         [Obsolete("Please do not use this UnderlineEnabled(Deprecated). Please use Underline instead.")]
443         public bool UnderlineEnabled
444         {
445             get
446             {
447                 bool underlineEnabled = false;
448                 Underline.Find(TextLabel.Property.UNDERLINE, "enable")?.Get(out underlineEnabled);
449                 return underlineEnabled;
450             }
451             set
452             {
453                 PropertyMap temp = new PropertyMap();
454                 temp.Add("enable", new PropertyValue(value));
455
456                 PropertyMap undelineMap = Underline;
457                 undelineMap.Merge(temp);
458
459                 SetValue(UnderlineProperty, undelineMap);
460                 NotifyPropertyChanged();
461
462             }
463         }
464
465         /// <summary>
466         /// The UnderlineColor property.<br />
467         /// Overrides the underline height from font metrics.<br />
468         /// </summary>
469         /// <since_tizen> 3 </since_tizen>
470         /// <remarks>
471         /// Deprecated.(API Level 6) Use Underline instead.
472         /// The property cascade chaining set is possible. For example, this (textLabel.UnderlineColor.X = 0.1f;) is possible.
473         /// </remarks>
474         [Obsolete("Please do not use this UnderlineColor(Deprecated). Please use Underline instead.")]
475         public Vector4 UnderlineColor
476         {
477             get
478             {
479                 Vector4 underlineColor = new Vector4();
480                 Underline.Find(TextLabel.Property.UNDERLINE, "color")?.Get(underlineColor);
481                 return new Vector4(OnUnderlineColorChanged, underlineColor.X, underlineColor.Y, underlineColor.Z, underlineColor.W);
482             }
483             set
484             {
485                 PropertyMap temp = new PropertyMap();
486                 temp.Insert("color", new PropertyValue(value));
487
488                 PropertyMap undelineMap = Underline;
489                 undelineMap.Merge(temp);
490
491                 SetValue(UnderlineProperty, undelineMap);
492                 NotifyPropertyChanged();
493             }
494         }
495
496         /// <summary>
497         /// The UnderlineHeight property.<br />
498         /// Overrides the underline height from font metrics.<br />
499         /// </summary>
500         /// <since_tizen> 3 </since_tizen>
501         /// <remarks>
502         /// Deprecated.(API Level 6) Use Underline instead.
503         /// </remarks>
504         [Obsolete("Please do not use this UnderlineHeight(Deprecated). Please use Underline instead.")]
505         public float UnderlineHeight
506         {
507             get
508             {
509                 float underlineHeight = 0.0f;
510                 Underline.Find(TextLabel.Property.UNDERLINE, "height")?.Get(out underlineHeight);
511                 return underlineHeight;
512             }
513             set
514             {
515                 PropertyMap temp = new PropertyMap();
516                 temp.Insert("height", new PropertyValue(value));
517
518                 PropertyMap undelineMap = Underline;
519                 undelineMap.Merge(temp);
520
521                 SetValue(UnderlineProperty, undelineMap);
522                 NotifyPropertyChanged();
523             }
524         }
525
526         /// <summary>
527         /// The EnableMarkup property.<br />
528         /// Whether the mark-up processing is enabled.<br />
529         /// </summary>
530         /// <since_tizen> 3 </since_tizen>
531         public bool EnableMarkup
532         {
533             get
534             {
535                 return (bool)GetValue(EnableMarkupProperty);
536             }
537             set
538             {
539                 SetValue(EnableMarkupProperty, value);
540                 NotifyPropertyChanged();
541             }
542         }
543
544         /// <summary>
545         /// The EnableAutoScroll property.<br />
546         /// Starts or stops auto scrolling.<br />
547         /// </summary>
548         /// <since_tizen> 3 </since_tizen>
549         public bool EnableAutoScroll
550         {
551             get
552             {
553                 return (bool)GetValue(EnableAutoScrollProperty);
554             }
555             set
556             {
557                 SetValue(EnableAutoScrollProperty, value);
558                 NotifyPropertyChanged();
559             }
560         }
561
562         /// <summary>
563         /// The AutoScrollSpeed property.<br />
564         /// Sets the speed of scrolling in pixels per second.<br />
565         /// </summary>
566         /// <since_tizen> 3 </since_tizen>
567         public int AutoScrollSpeed
568         {
569             get
570             {
571                 return (int)GetValue(AutoScrollSpeedProperty);
572             }
573             set
574             {
575                 SetValue(AutoScrollSpeedProperty, value);
576                 NotifyPropertyChanged();
577             }
578         }
579
580         /// <summary>
581         /// The AutoScrollLoopCount property.<br />
582         /// Number of complete loops when scrolling enabled.<br />
583         /// </summary>
584         /// <since_tizen> 3 </since_tizen>
585         public int AutoScrollLoopCount
586         {
587             get
588             {
589                 return (int)GetValue(AutoScrollLoopCountProperty);
590             }
591             set
592             {
593                 SetValue(AutoScrollLoopCountProperty, value);
594                 NotifyPropertyChanged();
595             }
596         }
597
598         /// <summary>
599         /// The AutoScrollGap property.<br />
600         /// Gap before scrolling wraps.<br />
601         /// </summary>
602         /// <since_tizen> 3 </since_tizen>
603         public float AutoScrollGap
604         {
605             get
606             {
607                 return (float)GetValue(AutoScrollGapProperty);
608             }
609             set
610             {
611                 SetValue(AutoScrollGapProperty, value);
612                 NotifyPropertyChanged();
613             }
614         }
615
616         /// <summary>
617         /// The LineSpacing property.<br />
618         /// The default extra space between lines in points.<br />
619         /// </summary>
620         /// <since_tizen> 3 </since_tizen>
621         public float LineSpacing
622         {
623             get
624             {
625                 return (float)GetValue(LineSpacingProperty);
626             }
627             set
628             {
629                 SetValue(LineSpacingProperty, value);
630                 NotifyPropertyChangedAndRequestLayout();
631             }
632         }
633
634         /// <summary>
635         /// The Underline property.<br />
636         /// The default underline parameters.<br />
637         /// </summary>
638         /// <since_tizen> 3 </since_tizen>
639         public PropertyMap Underline
640         {
641             get
642             {
643                 return (PropertyMap)GetValue(UnderlineProperty);
644             }
645             set
646             {
647                 SetValue(UnderlineProperty, value);
648                 NotifyPropertyChanged();
649             }
650         }
651
652         /// <summary>
653         /// The Shadow property.<br />
654         /// The default shadow parameters.<br />
655         /// </summary>
656         /// <since_tizen> 3 </since_tizen>
657         public PropertyMap Shadow
658         {
659             get
660             {
661                 return (PropertyMap)GetValue(ShadowProperty);
662             }
663             set
664             {
665                 SetValue(ShadowProperty, value);
666                 NotifyPropertyChanged();
667             }
668         }
669
670         /// <summary>
671         /// Describes a text shadow for a TextLabel.
672         /// It is null by default.
673         /// </summary>
674         [EditorBrowsable(EditorBrowsableState.Never)]
675         public TextShadow TextShadow
676         {
677             get
678             {
679                 return (TextShadow)GetValue(TextShadowProperty);
680             }
681             set
682             {
683                 SetValue(TextShadowProperty, value);
684                 selectorData?.TextShadow.UpdateIfNeeds(this, value);
685                 NotifyPropertyChanged();
686             }
687         }
688
689         /// <summary>
690         /// The Emboss property.<br />
691         /// The default emboss parameters.<br />
692         /// </summary>
693         /// <since_tizen> 3 </since_tizen>
694         public string Emboss
695         {
696             get
697             {
698                 return (string)GetValue(EmbossProperty);
699             }
700             set
701             {
702                 SetValue(EmbossProperty, value);
703                 NotifyPropertyChanged();
704             }
705         }
706
707         /// <summary>
708         /// The Outline property.<br />
709         /// The default outline parameters.<br />
710         /// </summary>
711         /// <since_tizen> 3 </since_tizen>
712         public PropertyMap Outline
713         {
714             get
715             {
716                 return (PropertyMap)GetValue(OutlineProperty);
717             }
718             set
719             {
720                 SetValue(OutlineProperty, value);
721                 NotifyPropertyChanged();
722             }
723         }
724
725         /// <summary>
726         /// The PixelSize property.<br />
727         /// The size of font in pixels.<br />
728         /// </summary>
729         /// <since_tizen> 3 </since_tizen>
730         public float PixelSize
731         {
732             get
733             {
734                 return (float)GetValue(PixelSizeProperty);
735             }
736             set
737             {
738                 SetValue(PixelSizeProperty, value);
739                 selectorData?.PixelSize.UpdateIfNeeds(this, value);
740                 NotifyPropertyChangedAndRequestLayout();
741             }
742         }
743
744         /// <summary>
745         /// The Ellipsis property.<br />
746         /// Enable or disable the ellipsis.<br />
747         /// </summary>
748         /// <since_tizen> 3 </since_tizen>
749         public bool Ellipsis
750         {
751             get
752             {
753                 return (bool)GetValue(EllipsisProperty);
754             }
755             set
756             {
757                 SetValue(EllipsisProperty, value);
758                 NotifyPropertyChanged();
759             }
760         }
761
762         /// <summary>
763         /// The AutoScrollLoopDelay property.<br />
764         /// Do something.<br />
765         /// </summary>
766         /// <since_tizen> 3 </since_tizen>
767         public float AutoScrollLoopDelay
768         {
769             get
770             {
771                 return (float)GetValue(AutoScrollLoopDelayProperty);
772             }
773             set
774             {
775                 SetValue(AutoScrollLoopDelayProperty, value);
776                 NotifyPropertyChanged();
777             }
778         }
779
780         /// <summary>
781         /// The AutoScrollStopMode property.<br />
782         /// Do something.<br />
783         /// </summary>
784         /// <since_tizen> 3 </since_tizen>
785         public AutoScrollStopMode AutoScrollStopMode
786         {
787             get
788             {
789                 return (AutoScrollStopMode)GetValue(AutoScrollStopModeProperty);
790             }
791             set
792             {
793                 SetValue(AutoScrollStopModeProperty, value);
794                 NotifyPropertyChanged();
795             }
796         }
797
798         /// <summary>
799         /// The line count of the text.
800         /// </summary>
801         /// <since_tizen> 3 </since_tizen>
802         public int LineCount
803         {
804             get
805             {
806                 int temp = 0;
807                 GetProperty(TextLabel.Property.LineCount).Get(out temp);
808                 return temp;
809             }
810         }
811
812         /// <summary>
813         /// The LineWrapMode property.<br />
814         /// line wrap mode when the text lines over layout width.<br />
815         /// </summary>
816         /// <since_tizen> 4 </since_tizen>
817         public LineWrapMode LineWrapMode
818         {
819             get
820             {
821                 return (LineWrapMode)GetValue(LineWrapModeProperty);
822             }
823             set
824             {
825                 SetValue(LineWrapModeProperty, value);
826                 NotifyPropertyChanged();
827             }
828         }
829
830         /// <summary>
831         /// The direction of the text such as left to right or right to left.
832         /// </summary>
833         /// <since_tizen> 5 </since_tizen>
834         /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
835         [EditorBrowsable(EditorBrowsableState.Never)]
836         public TextDirection TextDirection
837         {
838             get
839             {
840                 int temp = 0;
841                 GetProperty(TextLabel.Property.TextDirection).Get(out temp);
842                 return (TextDirection)temp;
843             }
844         }
845
846         /// <summary>
847         /// The vertical line alignment of the text.
848         /// </summary>
849         /// <since_tizen> 5 </since_tizen>
850         /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
851         [EditorBrowsable(EditorBrowsableState.Never)]
852         public VerticalLineAlignment VerticalLineAlignment
853         {
854             get
855             {
856                 return (VerticalLineAlignment)GetValue(VerticalLineAlignmentProperty);
857             }
858             set
859             {
860                 SetValue(VerticalLineAlignmentProperty, value);
861                 NotifyPropertyChanged();
862             }
863         }
864
865         /// <summary>
866         /// The text alignment to match the direction of the system language.
867         /// </summary>
868         /// <since_tizen> 6 </since_tizen>
869         public bool MatchSystemLanguageDirection
870         {
871             get
872             {
873                 return (bool)GetValue(MatchSystemLanguageDirectionProperty);
874             }
875             set
876             {
877                 SetValue(MatchSystemLanguageDirectionProperty, value);
878                 NotifyPropertyChanged();
879             }
880         }
881
882         /// <summary>
883         /// The text fit parameters.<br />
884         /// The textFit map contains the following keys :<br />
885         /// - enable (bool type) : True to enable the text fit or false to disable(the default value is false)<br />
886         /// - minSize (float type) : Minimum Size for text fit(the default value is 10.f)<br />
887         /// - maxSize (float type) : Maximum Size for text fit(the default value is 100.f)<br />
888         /// - stepSize (float type) : Step Size for font increase(the default value is 1.f)<br />
889         /// - fontSize (string type) : The size type of font, You can choose between "pointSize" or "pixelSize". (the default value is "pointSize")<br />
890         /// </summary>
891         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
892         [EditorBrowsable(EditorBrowsableState.Never)]
893         public PropertyMap TextFit
894         {
895             get
896             {
897                 return (PropertyMap)GetValue(TextFitProperty);
898             }
899             set
900             {
901                 SetValue(TextFitProperty, value);
902                 NotifyPropertyChanged();
903             }
904         }
905
906         /// <summary>
907         /// The MinLineSize property.<br />
908         /// </summary>
909         /// <since_tizen> 8 </since_tizen>
910         [EditorBrowsable(EditorBrowsableState.Never)]
911         public float MinLineSize
912         {
913             get
914             {
915                 return (float)GetValue(MinLineSizeProperty);
916             }
917             set
918             {
919                 SetValue(MinLineSizeProperty, value);
920                 NotifyPropertyChangedAndRequestLayout();
921             }
922         }
923
924         /// <summary>
925         /// The FontSizeScale property. <br />
926         /// The default value is 1.0. <br />
927         /// If FontSizeScale.UseSystemSetting, will use the SystemSettings.FontSize internally. <br />
928         /// </summary>
929         /// <since_tizen> 9 </since_tizen>
930         /// This will be public opened in tizen_6.5 after ACR done. Before ACR, need to be hidden as inhouse API.
931         [EditorBrowsable(EditorBrowsableState.Never)]
932         public float FontSizeScale
933         {
934             get
935             {
936                 return fontSizeScale;
937             }
938             set
939             {
940                 float newFontSizeScale;
941
942                 if (fontSizeScale == value) return;
943
944                 fontSizeScale = value;
945                 if (fontSizeScale == Tizen.NUI.FontSizeScale.UseSystemSetting)
946                 {
947                     SystemSettingsFontSize systemSettingsFontSize;
948
949                     try
950                     {
951                         systemSettingsFontSize = SystemSettings.FontSize;
952                     }
953                     catch (Exception e)
954                     {
955                         Console.WriteLine("{0} Exception caught.", e);
956                         systemSettingsFontSize = SystemSettingsFontSize.Normal;
957                     }
958                     newFontSizeScale = TextUtils.GetFontSizeScale(systemSettingsFontSize);
959                     addFontSizeChangedCallback();
960                 }
961                 else
962                 {
963                     newFontSizeScale = fontSizeScale;
964                     removeFontSizeChangedCallback();
965                 }
966
967                 SetValue(FontSizeScaleProperty, newFontSizeScale);
968                 NotifyPropertyChangedAndRequestLayout();
969             }
970         }
971
972         private TextLabelSelectorData SelectorData
973         {
974             get
975             {
976                 if (selectorData == null)
977                 {
978                     selectorData = new TextLabelSelectorData();
979                 }
980                 return selectorData;
981             }
982         }
983
984         /// <summary>
985         /// Downcasts a handle to textLabel handle
986         /// </summary>
987         /// <param name="handle"></param>
988         /// <returns></returns>
989         /// <exception cref="ArgumentNullException"> Thrown when handle is null. </exception>
990         /// <since_tizen> 3 </since_tizen>
991         /// Please do not use! this will be deprecated!
992         /// Instead please use as keyword.
993         [Obsolete("Please do not use! This will be deprecated! Please use as keyword instead! " +
994             "Like: " +
995             "BaseHandle handle = new TextLabel(\"Hello World!\"); " +
996             "TextLabel label = handle as TextLabel")]
997         [EditorBrowsable(EditorBrowsableState.Never)]
998         public static TextLabel DownCast(BaseHandle handle)
999         {
1000             if (null == handle)
1001             {
1002                 throw new ArgumentNullException(nameof(handle));
1003             }
1004             TextLabel ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as TextLabel;
1005             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1006             return ret;
1007         }
1008
1009         /// <inheritdoc/>
1010         [EditorBrowsable(EditorBrowsableState.Never)]
1011         protected override void Dispose(DisposeTypes type)
1012         {
1013             if (disposed)
1014             {
1015                 return;
1016             }
1017
1018             if (systemlangTextFlag)
1019             {
1020                 SystemSettings.LocaleLanguageChanged -= SystemSettings_LocaleLanguageChanged;
1021             }
1022
1023             removeFontSizeChangedCallback();
1024
1025             if (type == DisposeTypes.Explicit)
1026             {
1027                 //Called by User
1028                 //Release your own managed resources here.
1029                 //You should release all of your own disposable objects here.
1030                 selectorData?.Reset(this);
1031             }
1032
1033             base.Dispose(type);
1034         }
1035
1036         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TextLabel obj)
1037         {
1038             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
1039         }
1040
1041         /// This will not be public opened.
1042         [EditorBrowsable(EditorBrowsableState.Never)]
1043         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1044         {
1045             Interop.TextLabel.DeleteTextLabel(swigCPtr);
1046         }
1047
1048         /// <summary>
1049         /// Get attribues, it is abstract function and must be override.
1050         /// </summary>
1051         [EditorBrowsable(EditorBrowsableState.Never)]
1052         protected override ViewStyle CreateViewStyle()
1053         {
1054             return new TextLabelStyle();
1055         }
1056
1057         /// <summary>
1058         /// Invoked whenever the binding context of the textlabel changes. Implement this method to add class handling for this event.
1059         /// </summary>
1060         protected override void OnBindingContextChanged()
1061         {
1062             base.OnBindingContextChanged();
1063         }
1064
1065         private void SystemSettings_LocaleLanguageChanged(object sender, LocaleLanguageChangedEventArgs e)
1066         {
1067             Text = NUIApplication.MultilingualResourceManager?.GetString(textLabelSid, new CultureInfo(e.Value.Replace("_", "-")));
1068         }
1069
1070         private void SystemSettingsFontSizeChanged(object sender, FontSizeChangedEventArgs e)
1071         {
1072             float newFontSizeScale = TextUtils.GetFontSizeScale(e.Value);
1073             SetValue(FontSizeScaleProperty, newFontSizeScale);
1074             NotifyPropertyChangedAndRequestLayout();
1075         }
1076
1077         private void addFontSizeChangedCallback()
1078         {
1079             if (hasFontSizeChangedCallback != true)
1080             {
1081                 try
1082                 {
1083                     SystemSettings.FontSizeChanged += SystemSettingsFontSizeChanged;
1084                     hasFontSizeChangedCallback = true;
1085                 }
1086                 catch (Exception e)
1087                 {
1088                     Console.WriteLine("{0} Exception caught.", e);
1089                     hasFontSizeChangedCallback = false;
1090                 }
1091             }
1092         }
1093
1094         private void removeFontSizeChangedCallback()
1095         {
1096             if (hasFontSizeChangedCallback == true)
1097             {
1098                 try
1099                 {
1100                     SystemSettings.FontSizeChanged -= SystemSettingsFontSizeChanged;
1101                     hasFontSizeChangedCallback = false;
1102                 }
1103                 catch (Exception e)
1104                 {
1105                     Console.WriteLine("{0} Exception caught.", e);
1106                     hasFontSizeChangedCallback = true;
1107                 }
1108             }
1109         }
1110
1111         private void NotifyPropertyChangedAndRequestLayout()
1112         {
1113             NotifyPropertyChanged();
1114             Layout?.RequestLayout();
1115         }
1116
1117         internal new class Property
1118         {
1119             internal static readonly int TEXT = Interop.TextLabel.TextGet();
1120             internal static readonly int FontFamily = Interop.TextLabel.FontFamilyGet();
1121             internal static readonly int FontStyle = Interop.TextLabel.FontStyleGet();
1122             internal static readonly int PointSize = Interop.TextLabel.PointSizeGet();
1123             internal static readonly int MultiLine = Interop.TextLabel.MultiLineGet();
1124             internal static readonly int HorizontalAlignment = Interop.TextLabel.HorizontalAlignmentGet();
1125             internal static readonly int VerticalAlignment = Interop.TextLabel.VerticalAlignmentGet();
1126             internal static readonly int TextColor = Interop.TextLabel.TextColorGet();
1127             internal static readonly int EnableMarkup = Interop.TextLabel.EnableMarkupGet();
1128             internal static readonly int EnableAutoScroll = Interop.TextLabel.EnableAutoScrollGet();
1129             internal static readonly int AutoScrollSpeed = Interop.TextLabel.AutoScrollSpeedGet();
1130             internal static readonly int AutoScrollLoopCount = Interop.TextLabel.AutoScrollLoopCountGet();
1131             internal static readonly int AutoScrollGap = Interop.TextLabel.AutoScrollGapGet();
1132             internal static readonly int LineSpacing = Interop.TextLabel.LineSpacingGet();
1133             internal static readonly int UNDERLINE = Interop.TextLabel.UnderlineGet();
1134             internal static readonly int SHADOW = Interop.TextLabel.ShadowGet();
1135             internal static readonly int EMBOSS = Interop.TextLabel.EmbossGet();
1136             internal static readonly int OUTLINE = Interop.TextLabel.OutlineGet();
1137             internal static readonly int PixelSize = Interop.TextLabel.PixelSizeGet();
1138             internal static readonly int ELLIPSIS = Interop.TextLabel.EllipsisGet();
1139             internal static readonly int AutoScrollStopMode = Interop.TextLabel.AutoScrollStopModeGet();
1140             internal static readonly int AutoScrollLoopDelay = Interop.TextLabel.AutoScrollLoopDelayGet();
1141             internal static readonly int LineCount = Interop.TextLabel.LineCountGet();
1142             internal static readonly int LineWrapMode = Interop.TextLabel.LineWrapModeGet();
1143             internal static readonly int TextDirection = Interop.TextLabel.TextDirectionGet();
1144             internal static readonly int VerticalLineAlignment = Interop.TextLabel.VerticalLineAlignmentGet();
1145             internal static readonly int MatchSystemLanguageDirection = Interop.TextLabel.MatchSystemLanguageDirectionGet();
1146             internal static readonly int TextFit = Interop.TextLabel.TextFitGet();
1147             internal static readonly int MinLineSize = Interop.TextLabel.MinLineSizeGet();
1148             internal static readonly int FontSizeScale = Interop.TextLabel.FontSizeScaleGet();
1149         }
1150
1151         private void OnShadowColorChanged(float x, float y, float z, float w)
1152         {
1153             ShadowColor = new Vector4(x, y, z, w);
1154         }
1155         private void OnShadowOffsetChanged(float x, float y)
1156         {
1157             ShadowOffset = new Vector2(x, y);
1158         }
1159         private void OnTextColorChanged(float r, float g, float b, float a)
1160         {
1161             TextColor = new Color(r, g, b, a);
1162         }
1163         private void OnUnderlineColorChanged(float x, float y, float z, float w)
1164         {
1165             UnderlineColor = new Vector4(x, y, z, w);
1166         }
1167     }
1168 }