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