[Tizen] Ensuring that Registry.Unregister is called from the most derived class befor...
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / TextLabel.cs
1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16
17 using System;
18
19 namespace Tizen.NUI.BaseComponents
20 {
21
22     /// <summary>
23     /// A control which renders a short text string.<br>
24     /// Text labels are lightweight, non-editable and do not respond to user input.<br>
25     /// </summary>
26     public class TextLabel : View
27     {
28         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
29
30         internal TextLabel(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.TextLabel_SWIGUpcast(cPtr), cMemoryOwn)
31         {
32             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
33         }
34
35         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TextLabel obj)
36         {
37             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
38         }
39
40         /// <summary>
41         /// Dispose
42         /// </summary>
43         protected override void Dispose(DisposeTypes type)
44         {
45             if (disposed)
46             {
47                 return;
48             }
49
50             if(type == DisposeTypes.Explicit)
51             {
52                 //Called by User
53                 //Release your own managed resources here.
54                 //You should release all of your own disposable objects here.
55             }
56
57             //Release your own unmanaged resources here.
58             //You should not access any managed member here except static instance.
59             //because the execution order of Finalizes is non-deterministic.
60
61             if (swigCPtr.Handle != global::System.IntPtr.Zero)
62             {
63                 if (swigCMemOwn)
64                 {
65                     swigCMemOwn = false;
66
67                     //Unreference this instance from Registry.
68                     Registry.Unregister(this);
69
70                     NDalicPINVOKE.delete_TextLabel(swigCPtr);
71                 }
72                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
73             }
74
75             base.Dispose(type);
76         }
77
78         internal class Property
79         {
80             internal static readonly int RENDERING_BACKEND = NDalicPINVOKE.TextLabel_Property_RENDERING_BACKEND_get();
81             internal static readonly int TEXT = NDalicPINVOKE.TextLabel_Property_TEXT_get();
82             internal static readonly int FONT_FAMILY = NDalicPINVOKE.TextLabel_Property_FONT_FAMILY_get();
83             internal static readonly int FONT_STYLE = NDalicPINVOKE.TextLabel_Property_FONT_STYLE_get();
84             internal static readonly int POINT_SIZE = NDalicPINVOKE.TextLabel_Property_POINT_SIZE_get();
85             internal static readonly int MULTI_LINE = NDalicPINVOKE.TextLabel_Property_MULTI_LINE_get();
86             internal static readonly int HORIZONTAL_ALIGNMENT = NDalicPINVOKE.TextLabel_Property_HORIZONTAL_ALIGNMENT_get();
87             internal static readonly int VERTICAL_ALIGNMENT = NDalicPINVOKE.TextLabel_Property_VERTICAL_ALIGNMENT_get();
88             internal static readonly int TEXT_COLOR = NDalicPINVOKE.TextLabel_Property_TEXT_COLOR_get();
89             internal static readonly int SHADOW_OFFSET = NDalicPINVOKE.TextLabel_Property_SHADOW_OFFSET_get();
90             internal static readonly int SHADOW_COLOR = NDalicPINVOKE.TextLabel_Property_SHADOW_COLOR_get();
91             internal static readonly int UNDERLINE_ENABLED = NDalicPINVOKE.TextLabel_Property_UNDERLINE_ENABLED_get();
92             internal static readonly int UNDERLINE_COLOR = NDalicPINVOKE.TextLabel_Property_UNDERLINE_COLOR_get();
93             internal static readonly int UNDERLINE_HEIGHT = NDalicPINVOKE.TextLabel_Property_UNDERLINE_HEIGHT_get();
94             internal static readonly int ENABLE_MARKUP = NDalicPINVOKE.TextLabel_Property_ENABLE_MARKUP_get();
95             internal static readonly int ENABLE_AUTO_SCROLL = NDalicPINVOKE.TextLabel_Property_ENABLE_AUTO_SCROLL_get();
96             internal static readonly int AUTO_SCROLL_SPEED = NDalicPINVOKE.TextLabel_Property_AUTO_SCROLL_SPEED_get();
97             internal static readonly int AUTO_SCROLL_LOOP_COUNT = NDalicPINVOKE.TextLabel_Property_AUTO_SCROLL_LOOP_COUNT_get();
98             internal static readonly int AUTO_SCROLL_GAP = NDalicPINVOKE.TextLabel_Property_AUTO_SCROLL_GAP_get();
99             internal static readonly int LINE_SPACING = NDalicPINVOKE.TextLabel_Property_LINE_SPACING_get();
100             internal static readonly int UNDERLINE = NDalicPINVOKE.TextLabel_Property_UNDERLINE_get();
101             internal static readonly int SHADOW = NDalicPINVOKE.TextLabel_Property_SHADOW_get();
102             internal static readonly int EMBOSS = NDalicPINVOKE.TextLabel_Property_EMBOSS_get();
103             internal static readonly int OUTLINE = NDalicPINVOKE.TextLabel_Property_OUTLINE_get();
104             internal static readonly int PIXEL_SIZE = NDalicManualPINVOKE.TextLabel_Property_PIXEL_SIZE_get();
105             internal static readonly int ELLIPSIS = NDalicManualPINVOKE.TextLabel_Property_ELLIPSIS_get();
106             internal static readonly int AUTO_SCROLL_STOP_MODE = NDalicManualPINVOKE.TextLabel_Property_AUTO_SCROLL_STOP_MODE_get();
107             internal static readonly int AUTO_SCROLL_LOOP_DELAY = NDalicManualPINVOKE.TextLabel_Property_AUTO_SCROLL_LOOP_DELAY_get();
108             internal static readonly int LINE_COUNT = OUTLINE + 5;
109         }
110
111         /// <summary>
112         /// Creates the TextLabel control.
113         /// </summary>
114         public TextLabel() : this(NDalicPINVOKE.TextLabel_New__SWIG_0(), true)
115         {
116             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
117
118         }
119
120         /// <summary>
121         /// Creates the TextLabel control.
122         /// </summary>
123         /// <param name="text">The text to display</param>
124         public TextLabel(string text) : this(NDalicPINVOKE.TextLabel_New__SWIG_1(text), true)
125         {
126             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
127
128         }
129         internal TextLabel(TextLabel handle) : this(NDalicPINVOKE.new_TextLabel__SWIG_1(TextLabel.getCPtr(handle)), true)
130         {
131             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
132         }
133
134
135         [Obsolete("Please do not use! this will be deprecated")]
136         public new static TextLabel DownCast(BaseHandle handle)
137         {
138             TextLabel ret = new TextLabel(NDalicPINVOKE.TextLabel_DownCast(BaseHandle.getCPtr(handle)), true);
139             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
140             return ret;
141         }
142
143         /// <summary>
144         /// Text property.<br>
145         /// The text to display in UTF-8 format.<br>
146         /// </summary>
147         public string Text
148         {
149             get
150             {
151                 string temp;
152                 GetProperty(TextLabel.Property.TEXT).Get(out temp);
153                 return temp;
154             }
155             set
156             {
157                 SetProperty(TextLabel.Property.TEXT, new Tizen.NUI.PropertyValue(value));
158             }
159         }
160
161         /// <summary>
162         /// FontFamily property.<br>
163         /// The requested font family to use.<br>
164         /// </summary>
165         public string FontFamily
166         {
167             get
168             {
169                 string temp;
170                 GetProperty(TextLabel.Property.FONT_FAMILY).Get(out temp);
171                 return temp;
172             }
173             set
174             {
175                 SetProperty(TextLabel.Property.FONT_FAMILY, new Tizen.NUI.PropertyValue(value));
176             }
177         }
178
179         /// <summary>
180         /// FontStyle property.<br>
181         /// The requested font style to use.<br>
182         /// </summary>
183         public PropertyMap FontStyle
184         {
185             get
186             {
187                 PropertyMap temp = new PropertyMap();
188                 GetProperty(TextLabel.Property.FONT_STYLE).Get(temp);
189                 return temp;
190             }
191             set
192             {
193                 SetProperty(TextLabel.Property.FONT_STYLE, new Tizen.NUI.PropertyValue(value));
194             }
195         }
196
197         /// <summary>
198         /// PointSize property.<br>
199         /// The size of font in points.<br>
200         /// </summary>
201         public float PointSize
202         {
203             get
204             {
205                 float temp = 0.0f;
206                 GetProperty(TextLabel.Property.POINT_SIZE).Get(out temp);
207                 return temp;
208             }
209             set
210             {
211                 SetProperty(TextLabel.Property.POINT_SIZE, new Tizen.NUI.PropertyValue(value));
212             }
213         }
214
215         /// <summary>
216         /// MultiLine property.<br>
217         /// The single-line or multi-line layout option.<br>
218         /// </summary>
219         public bool MultiLine
220         {
221             get
222             {
223                 bool temp = false;
224                 GetProperty(TextLabel.Property.MULTI_LINE).Get(out temp);
225                 return temp;
226             }
227             set
228             {
229                 SetProperty(TextLabel.Property.MULTI_LINE, new Tizen.NUI.PropertyValue(value));
230             }
231         }
232
233         /// <summary>
234         /// HorizontalAlignment property.<br>
235         /// The line horizontal alignment.<br>
236         /// </summary>
237         public HorizontalAlignment HorizontalAlignment
238         {
239             get
240             {
241                 string temp;
242                 if (GetProperty(TextLabel.Property.HORIZONTAL_ALIGNMENT).Get(out temp) == false)
243                 {
244                     NUILog.Error("HorizontalAlignment get error!");
245                 }
246                 switch (temp)
247                 {
248                     case "BEGIN":
249                         return HorizontalAlignment.Begin;
250                     case "CENTER":
251                         return HorizontalAlignment.Center;
252                     case "END":
253                         return HorizontalAlignment.End;
254                     default:
255                         return HorizontalAlignment.Begin;
256                 }
257             }
258             set
259             {
260                 string valueToString = "";
261                 switch (value)
262                 {
263                     case HorizontalAlignment.Begin:
264                     {
265                         valueToString = "BEGIN";
266                         break;
267                     }
268                     case HorizontalAlignment.Center:
269                     {
270                         valueToString = "CENTER";
271                         break;
272                     }
273                     case HorizontalAlignment.End:
274                     {
275                         valueToString = "END";
276                         break;
277                     }
278                     default:
279                     {
280                         valueToString = "BEGIN";
281                         break;
282                     }
283                 }
284                 SetProperty(TextLabel.Property.HORIZONTAL_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
285             }
286         }
287
288         /// <summary>
289         /// VerticalAlignment property.<br>
290         /// The line vertical alignment.<br>
291         /// </summary>
292         public VerticalAlignment VerticalAlignment
293         {
294             get
295             {
296                 string temp;
297                 if (GetProperty(TextLabel.Property.VERTICAL_ALIGNMENT).Get(out temp) == false)
298                 {
299                     NUILog.Error("VerticalAlignment get error!");
300                 }
301
302                 switch (temp)
303                 {
304                     case "TOP":
305                         return VerticalAlignment.Top;
306                     case "CENTER":
307                         return VerticalAlignment.Center;
308                     case "BOTTOM":
309                         return VerticalAlignment.Bottom;
310                     default:
311                         return VerticalAlignment.Bottom;
312                 }
313             }
314             set
315             {
316                 string valueToString = "";
317                 switch (value)
318                 {
319                     case VerticalAlignment.Top:
320                     {
321                         valueToString = "TOP";
322                         break;
323                     }
324                     case VerticalAlignment.Center:
325                     {
326                         valueToString = "CENTER";
327                         break;
328                     }
329                     case VerticalAlignment.Bottom:
330                     {
331                         valueToString = "BOTTOM";
332                         break;
333                     }
334                     default:
335                     {
336                         valueToString = "BOTTOM";
337                         break;
338                     }
339                 }
340                 SetProperty(TextLabel.Property.VERTICAL_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
341             }
342         }
343
344         /// <summary>
345         /// TextColor property.<br>
346         /// The color of the text.<br>
347         /// </summary>
348         public Color TextColor
349         {
350             get
351             {
352                 Color temp = new Color(0.0f, 0.0f, 0.0f, 0.0f);
353                 GetProperty(TextLabel.Property.TEXT_COLOR).Get(temp);
354                 return temp;
355             }
356             set
357             {
358                 SetProperty(TextLabel.Property.TEXT_COLOR, new Tizen.NUI.PropertyValue(value));
359             }
360         }
361
362         /// <summary>
363         /// ShadowOffset property.<br>
364         /// The drop shadow offset 0 indicates no shadow.<br>
365         /// </summary>
366         public Vector2 ShadowOffset
367         {
368             get
369             {
370                 Vector2 temp = new Vector2(0.0f, 0.0f);
371                 GetProperty(TextLabel.Property.SHADOW_OFFSET).Get(temp);
372                 return temp;
373             }
374             set
375             {
376                 SetProperty(TextLabel.Property.SHADOW_OFFSET, new Tizen.NUI.PropertyValue(value));
377             }
378         }
379
380         /// <summary>
381         /// ShadowColor property.<br>
382         /// The color of a drop shadow.<br>
383         /// </summary>
384         public Vector4 ShadowColor
385         {
386             get
387             {
388                 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
389                 GetProperty(TextLabel.Property.SHADOW_COLOR).Get(temp);
390                 return temp;
391             }
392             set
393             {
394                 SetProperty(TextLabel.Property.SHADOW_COLOR, new Tizen.NUI.PropertyValue(value));
395             }
396         }
397
398         /// <summary>
399         /// UnderlineEnabled property.<br>
400         /// The underline enabled flag.<br>
401         /// </summary>
402         public bool UnderlineEnabled
403         {
404             get
405             {
406                 bool temp = false;
407                 GetProperty(TextLabel.Property.UNDERLINE_ENABLED).Get(out temp);
408                 return temp;
409             }
410             set
411             {
412                 SetProperty(TextLabel.Property.UNDERLINE_ENABLED, new Tizen.NUI.PropertyValue(value));
413             }
414         }
415
416         /// <summary>
417         /// UnderlineColor property.<br>
418         /// Overrides the underline height from font metrics.<br>
419         /// </summary>
420         public Vector4 UnderlineColor
421         {
422             get
423             {
424                 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
425                 GetProperty(TextLabel.Property.UNDERLINE_COLOR).Get(temp);
426                 return temp;
427             }
428             set
429             {
430                 SetProperty(TextLabel.Property.UNDERLINE_COLOR, new Tizen.NUI.PropertyValue(value));
431             }
432         }
433
434         /// <summary>
435         /// UnderlineHeight property.<br>
436         /// Overrides the underline height from font metrics.<br>
437         /// </summary>
438         public float UnderlineHeight
439         {
440             get
441             {
442                 float temp = 0.0f;
443                 GetProperty(TextLabel.Property.UNDERLINE_HEIGHT).Get(out temp);
444                 return temp;
445             }
446             set
447             {
448                 SetProperty(TextLabel.Property.UNDERLINE_HEIGHT, new Tizen.NUI.PropertyValue(value));
449             }
450         }
451
452         /// <summary>
453         /// EnableMarkup property.<br>
454         /// Whether the mark-up processing is enabled.<br>
455         /// </summary>
456         public bool EnableMarkup
457         {
458             get
459             {
460                 bool temp = false;
461                 GetProperty(TextLabel.Property.ENABLE_MARKUP).Get(out temp);
462                 return temp;
463             }
464             set
465             {
466                 SetProperty(TextLabel.Property.ENABLE_MARKUP, new Tizen.NUI.PropertyValue(value));
467             }
468         }
469
470         /// <summary>
471         /// EnableAutoScroll property.<br>
472         /// Starts or stops auto scrolling.<br>
473         /// </summary>
474         public bool EnableAutoScroll
475         {
476             get
477             {
478                 bool temp = false;
479                 GetProperty(TextLabel.Property.ENABLE_AUTO_SCROLL).Get(out temp);
480                 return temp;
481             }
482             set
483             {
484                 SetProperty(TextLabel.Property.ENABLE_AUTO_SCROLL, new Tizen.NUI.PropertyValue(value));
485             }
486         }
487
488         /// <summary>
489         /// AutoScrollSpeed property.<br>
490         /// Sets the speed of scrolling in pixels per second.<br>
491         /// </summary>
492         public int AutoScrollSpeed
493         {
494             get
495             {
496                 int temp = 0;
497                 GetProperty(TextLabel.Property.AUTO_SCROLL_SPEED).Get(out temp);
498                 return temp;
499             }
500             set
501             {
502                 SetProperty(TextLabel.Property.AUTO_SCROLL_SPEED, new Tizen.NUI.PropertyValue(value));
503             }
504         }
505
506         /// <summary>
507         /// AutoScrollLoopCount property.<br>
508         /// Number of complete loops when scrolling enabled.<br>
509         /// </summary>
510         public int AutoScrollLoopCount
511         {
512             get
513             {
514                 int temp = 0;
515                 GetProperty(TextLabel.Property.AUTO_SCROLL_LOOP_COUNT).Get(out temp);
516                 return temp;
517             }
518             set
519             {
520                 SetProperty(TextLabel.Property.AUTO_SCROLL_LOOP_COUNT, new Tizen.NUI.PropertyValue(value));
521             }
522         }
523
524         /// <summary>
525         /// AutoScrollGap property.<br>
526         /// Gap before scrolling wraps.<br>
527         /// </summary>
528         public float AutoScrollGap
529         {
530             get
531             {
532                 float temp = 0.0f;
533                 GetProperty(TextLabel.Property.AUTO_SCROLL_GAP).Get(out temp);
534                 return temp;
535             }
536             set
537             {
538                 SetProperty(TextLabel.Property.AUTO_SCROLL_GAP, new Tizen.NUI.PropertyValue(value));
539             }
540         }
541
542         /// <summary>
543         /// LineSpacing property.<br>
544         /// The default extra space between lines in points.<br>
545         /// </summary>
546         public float LineSpacing
547         {
548             get
549             {
550                 float temp = 0.0f;
551                 GetProperty(TextLabel.Property.LINE_SPACING).Get(out temp);
552                 return temp;
553             }
554             set
555             {
556                 SetProperty(TextLabel.Property.LINE_SPACING, new Tizen.NUI.PropertyValue(value));
557             }
558         }
559
560         /// <summary>
561         /// Underline property.<br>
562         /// The default underline parameters.<br>
563         /// </summary>
564         public PropertyMap Underline
565         {
566             get
567             {
568                 PropertyMap temp = new PropertyMap();
569                 GetProperty(TextLabel.Property.UNDERLINE).Get(temp);
570                 return temp;
571             }
572             set
573             {
574                 SetProperty(TextLabel.Property.UNDERLINE, new Tizen.NUI.PropertyValue(value));
575             }
576         }
577
578         /// <summary>
579         /// Shadow property.<br>
580         /// The default shadow parameters.<br>
581         /// </summary>
582         public PropertyMap Shadow
583         {
584             get
585             {
586                 PropertyMap temp = new PropertyMap();
587                 GetProperty(TextLabel.Property.SHADOW).Get(temp);
588                 return temp;
589             }
590             set
591             {
592                 SetProperty(TextLabel.Property.SHADOW, new Tizen.NUI.PropertyValue(value));
593             }
594         }
595
596         /// <summary>
597         /// Emboss property.<br>
598         /// The default emboss parameters.<br>
599         /// </summary>
600         public string Emboss
601         {
602             get
603             {
604                 string temp;
605                 GetProperty(TextLabel.Property.EMBOSS).Get( out temp);
606                 return temp;
607             }
608             set
609             {
610                 SetProperty(TextLabel.Property.EMBOSS, new Tizen.NUI.PropertyValue(value));
611             }
612         }
613
614         /// <summary>
615         /// Outline property.<br>
616         /// The default outline parameters.<br>
617         /// </summary>
618         public string Outline
619         {
620             get
621             {
622                 string temp;
623                 GetProperty(TextLabel.Property.OUTLINE).Get(out temp);
624                 return temp;
625             }
626             set
627             {
628                 SetProperty(TextLabel.Property.OUTLINE, new Tizen.NUI.PropertyValue(value));
629             }
630         }
631
632         /// <summary>
633         /// PixelSize property.<br>
634         /// The size of font in pixels.<br>
635         /// </summary>
636         public float PixelSize
637         {
638             get
639             {
640                 float temp = 0.0f;
641                 GetProperty(TextLabel.Property.PIXEL_SIZE).Get(out temp);
642                 return temp;
643             }
644             set
645             {
646                 SetProperty(TextLabel.Property.PIXEL_SIZE, new Tizen.NUI.PropertyValue(value));
647             }
648         }
649
650         /// <summary>
651         /// Ellipsis property.<br>
652         /// Enable or disable the ellipsis.<br>
653         /// </summary>
654         public bool Ellipsis
655         {
656             get
657             {
658                 bool temp = false;
659                 GetProperty(TextLabel.Property.ELLIPSIS).Get(out temp);
660                 return temp;
661             }
662             set
663             {
664                 SetProperty(TextLabel.Property.ELLIPSIS, new Tizen.NUI.PropertyValue(value));
665             }
666         }
667
668         /// <summary>
669         /// AutoScrollLoopDelay property.<br>
670         /// do something.<br>
671         /// </summary>
672         public float AutoScrollLoopDelay
673         {
674             get
675             {
676                 float temp = 0.0f;
677                 GetProperty(TextLabel.Property.AUTO_SCROLL_LOOP_DELAY).Get(out temp);
678                 return temp;
679             }
680             set
681             {
682                 SetProperty(TextLabel.Property.AUTO_SCROLL_LOOP_DELAY, new Tizen.NUI.PropertyValue(value));
683             }
684         }
685
686         /// <summary>
687         /// AutoScrollStopMode property.<br>
688         /// do something.<br>
689         /// </summary>
690         public AutoScrollStopMode AutoScrollStopMode
691         {
692             get
693             {
694                 string temp;
695                 if(GetProperty(TextLabel.Property.AUTO_SCROLL_STOP_MODE).Get(out temp) == false)
696                 {
697                     NUILog.Error("AutoScrollStopMode get error!");
698                 }
699                 switch (temp)
700                 {
701                     case "FINISH_LOOP":
702                     return AutoScrollStopMode.FinishLoop;
703                     case "IMMEDIATE":
704                     return AutoScrollStopMode.Immediate;
705                     default:
706                     return AutoScrollStopMode.FinishLoop;
707                 }
708             }
709             set
710             {
711                 SetProperty(TextLabel.Property.AUTO_SCROLL_STOP_MODE, new Tizen.NUI.PropertyValue((int)value));
712             }
713         }
714
715         /// <summary>
716         /// The line count of text.
717         /// </summary>
718         public int LineCount
719         {
720             get
721             {
722                 int temp = 0;
723                 GetProperty(TextLabel.Property.LINE_COUNT).Get(out temp);
724                 return temp;
725             }
726         }
727
728     }
729 }