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