1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
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
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 namespace Tizen.NUI.BaseComponents
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>
26 public class TextLabel : View
28 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
30 internal TextLabel(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.TextLabel_SWIGUpcast(cPtr), cMemoryOwn)
32 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
35 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TextLabel obj)
37 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
43 protected override void Dispose(DisposeTypes type)
50 if(type == DisposeTypes.Explicit)
53 //Release your own managed resources here.
54 //You should release all of your own disposable objects here.
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.
61 if (swigCPtr.Handle != global::System.IntPtr.Zero)
67 //Unreference this instance from Registry.
68 Registry.Unregister(this);
70 NDalicPINVOKE.delete_TextLabel(swigCPtr);
72 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
78 internal class Property
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;
112 /// Creates the TextLabel control.
114 public TextLabel() : this(NDalicPINVOKE.TextLabel_New__SWIG_0(), true)
116 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
121 /// Creates the TextLabel control.
123 /// <param name="text">The text to display</param>
124 public TextLabel(string text) : this(NDalicPINVOKE.TextLabel_New__SWIG_1(text), true)
126 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
129 internal TextLabel(TextLabel handle) : this(NDalicPINVOKE.new_TextLabel__SWIG_1(TextLabel.getCPtr(handle)), true)
131 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
135 [Obsolete("Please do not use! this will be deprecated")]
136 public new static TextLabel DownCast(BaseHandle handle)
138 TextLabel ret = new TextLabel(NDalicPINVOKE.TextLabel_DownCast(BaseHandle.getCPtr(handle)), true);
139 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
144 /// Text property.<br>
145 /// The text to display in UTF-8 format.<br>
152 GetProperty(TextLabel.Property.TEXT).Get(out temp);
157 SetProperty(TextLabel.Property.TEXT, new Tizen.NUI.PropertyValue(value));
162 /// FontFamily property.<br>
163 /// The requested font family to use.<br>
165 public string FontFamily
170 GetProperty(TextLabel.Property.FONT_FAMILY).Get(out temp);
175 SetProperty(TextLabel.Property.FONT_FAMILY, new Tizen.NUI.PropertyValue(value));
180 /// FontStyle property.<br>
181 /// The requested font style to use.<br>
183 public PropertyMap FontStyle
187 PropertyMap temp = new PropertyMap();
188 GetProperty(TextLabel.Property.FONT_STYLE).Get(temp);
193 SetProperty(TextLabel.Property.FONT_STYLE, new Tizen.NUI.PropertyValue(value));
198 /// PointSize property.<br>
199 /// The size of font in points.<br>
201 public float PointSize
206 GetProperty(TextLabel.Property.POINT_SIZE).Get(out temp);
211 SetProperty(TextLabel.Property.POINT_SIZE, new Tizen.NUI.PropertyValue(value));
216 /// MultiLine property.<br>
217 /// The single-line or multi-line layout option.<br>
219 public bool MultiLine
224 GetProperty(TextLabel.Property.MULTI_LINE).Get(out temp);
229 SetProperty(TextLabel.Property.MULTI_LINE, new Tizen.NUI.PropertyValue(value));
234 /// HorizontalAlignment property.<br>
235 /// The line horizontal alignment.<br>
237 public HorizontalAlignment HorizontalAlignment
242 if (GetProperty(TextLabel.Property.HORIZONTAL_ALIGNMENT).Get(out temp) == false)
244 NUILog.Error("HorizontalAlignment get error!");
249 return HorizontalAlignment.Begin;
251 return HorizontalAlignment.Center;
253 return HorizontalAlignment.End;
255 return HorizontalAlignment.Begin;
260 string valueToString = "";
263 case HorizontalAlignment.Begin:
265 valueToString = "BEGIN";
268 case HorizontalAlignment.Center:
270 valueToString = "CENTER";
273 case HorizontalAlignment.End:
275 valueToString = "END";
280 valueToString = "BEGIN";
284 SetProperty(TextLabel.Property.HORIZONTAL_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
289 /// VerticalAlignment property.<br>
290 /// The line vertical alignment.<br>
292 public VerticalAlignment VerticalAlignment
297 if (GetProperty(TextLabel.Property.VERTICAL_ALIGNMENT).Get(out temp) == false)
299 NUILog.Error("VerticalAlignment get error!");
305 return VerticalAlignment.Top;
307 return VerticalAlignment.Center;
309 return VerticalAlignment.Bottom;
311 return VerticalAlignment.Bottom;
316 string valueToString = "";
319 case VerticalAlignment.Top:
321 valueToString = "TOP";
324 case VerticalAlignment.Center:
326 valueToString = "CENTER";
329 case VerticalAlignment.Bottom:
331 valueToString = "BOTTOM";
336 valueToString = "BOTTOM";
340 SetProperty(TextLabel.Property.VERTICAL_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
345 /// TextColor property.<br>
346 /// The color of the text.<br>
348 public Color TextColor
352 Color temp = new Color(0.0f, 0.0f, 0.0f, 0.0f);
353 GetProperty(TextLabel.Property.TEXT_COLOR).Get(temp);
358 SetProperty(TextLabel.Property.TEXT_COLOR, new Tizen.NUI.PropertyValue(value));
363 /// ShadowOffset property.<br>
364 /// The drop shadow offset 0 indicates no shadow.<br>
366 public Vector2 ShadowOffset
370 Vector2 temp = new Vector2(0.0f, 0.0f);
371 GetProperty(TextLabel.Property.SHADOW_OFFSET).Get(temp);
376 SetProperty(TextLabel.Property.SHADOW_OFFSET, new Tizen.NUI.PropertyValue(value));
381 /// ShadowColor property.<br>
382 /// The color of a drop shadow.<br>
384 public Vector4 ShadowColor
388 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
389 GetProperty(TextLabel.Property.SHADOW_COLOR).Get(temp);
394 SetProperty(TextLabel.Property.SHADOW_COLOR, new Tizen.NUI.PropertyValue(value));
399 /// UnderlineEnabled property.<br>
400 /// The underline enabled flag.<br>
402 public bool UnderlineEnabled
407 GetProperty(TextLabel.Property.UNDERLINE_ENABLED).Get(out temp);
412 SetProperty(TextLabel.Property.UNDERLINE_ENABLED, new Tizen.NUI.PropertyValue(value));
417 /// UnderlineColor property.<br>
418 /// Overrides the underline height from font metrics.<br>
420 public Vector4 UnderlineColor
424 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
425 GetProperty(TextLabel.Property.UNDERLINE_COLOR).Get(temp);
430 SetProperty(TextLabel.Property.UNDERLINE_COLOR, new Tizen.NUI.PropertyValue(value));
435 /// UnderlineHeight property.<br>
436 /// Overrides the underline height from font metrics.<br>
438 public float UnderlineHeight
443 GetProperty(TextLabel.Property.UNDERLINE_HEIGHT).Get(out temp);
448 SetProperty(TextLabel.Property.UNDERLINE_HEIGHT, new Tizen.NUI.PropertyValue(value));
453 /// EnableMarkup property.<br>
454 /// Whether the mark-up processing is enabled.<br>
456 public bool EnableMarkup
461 GetProperty(TextLabel.Property.ENABLE_MARKUP).Get(out temp);
466 SetProperty(TextLabel.Property.ENABLE_MARKUP, new Tizen.NUI.PropertyValue(value));
471 /// EnableAutoScroll property.<br>
472 /// Starts or stops auto scrolling.<br>
474 public bool EnableAutoScroll
479 GetProperty(TextLabel.Property.ENABLE_AUTO_SCROLL).Get(out temp);
484 SetProperty(TextLabel.Property.ENABLE_AUTO_SCROLL, new Tizen.NUI.PropertyValue(value));
489 /// AutoScrollSpeed property.<br>
490 /// Sets the speed of scrolling in pixels per second.<br>
492 public int AutoScrollSpeed
497 GetProperty(TextLabel.Property.AUTO_SCROLL_SPEED).Get(out temp);
502 SetProperty(TextLabel.Property.AUTO_SCROLL_SPEED, new Tizen.NUI.PropertyValue(value));
507 /// AutoScrollLoopCount property.<br>
508 /// Number of complete loops when scrolling enabled.<br>
510 public int AutoScrollLoopCount
515 GetProperty(TextLabel.Property.AUTO_SCROLL_LOOP_COUNT).Get(out temp);
520 SetProperty(TextLabel.Property.AUTO_SCROLL_LOOP_COUNT, new Tizen.NUI.PropertyValue(value));
525 /// AutoScrollGap property.<br>
526 /// Gap before scrolling wraps.<br>
528 public float AutoScrollGap
533 GetProperty(TextLabel.Property.AUTO_SCROLL_GAP).Get(out temp);
538 SetProperty(TextLabel.Property.AUTO_SCROLL_GAP, new Tizen.NUI.PropertyValue(value));
543 /// LineSpacing property.<br>
544 /// The default extra space between lines in points.<br>
546 public float LineSpacing
551 GetProperty(TextLabel.Property.LINE_SPACING).Get(out temp);
556 SetProperty(TextLabel.Property.LINE_SPACING, new Tizen.NUI.PropertyValue(value));
561 /// Underline property.<br>
562 /// The default underline parameters.<br>
564 public PropertyMap Underline
568 PropertyMap temp = new PropertyMap();
569 GetProperty(TextLabel.Property.UNDERLINE).Get(temp);
574 SetProperty(TextLabel.Property.UNDERLINE, new Tizen.NUI.PropertyValue(value));
579 /// Shadow property.<br>
580 /// The default shadow parameters.<br>
582 public PropertyMap Shadow
586 PropertyMap temp = new PropertyMap();
587 GetProperty(TextLabel.Property.SHADOW).Get(temp);
592 SetProperty(TextLabel.Property.SHADOW, new Tizen.NUI.PropertyValue(value));
597 /// Emboss property.<br>
598 /// The default emboss parameters.<br>
605 GetProperty(TextLabel.Property.EMBOSS).Get( out temp);
610 SetProperty(TextLabel.Property.EMBOSS, new Tizen.NUI.PropertyValue(value));
615 /// Outline property.<br>
616 /// The default outline parameters.<br>
618 public string Outline
623 GetProperty(TextLabel.Property.OUTLINE).Get(out temp);
628 SetProperty(TextLabel.Property.OUTLINE, new Tizen.NUI.PropertyValue(value));
633 /// PixelSize property.<br>
634 /// The size of font in pixels.<br>
636 public float PixelSize
641 GetProperty(TextLabel.Property.PIXEL_SIZE).Get(out temp);
646 SetProperty(TextLabel.Property.PIXEL_SIZE, new Tizen.NUI.PropertyValue(value));
651 /// Ellipsis property.<br>
652 /// Enable or disable the ellipsis.<br>
659 GetProperty(TextLabel.Property.ELLIPSIS).Get(out temp);
664 SetProperty(TextLabel.Property.ELLIPSIS, new Tizen.NUI.PropertyValue(value));
669 /// AutoScrollLoopDelay property.<br>
670 /// do something.<br>
672 public float AutoScrollLoopDelay
677 GetProperty(TextLabel.Property.AUTO_SCROLL_LOOP_DELAY).Get(out temp);
682 SetProperty(TextLabel.Property.AUTO_SCROLL_LOOP_DELAY, new Tizen.NUI.PropertyValue(value));
687 /// AutoScrollStopMode property.<br>
688 /// do something.<br>
690 public AutoScrollStopMode AutoScrollStopMode
695 if(GetProperty(TextLabel.Property.AUTO_SCROLL_STOP_MODE).Get(out temp) == false)
697 NUILog.Error("AutoScrollStopMode get error!");
702 return AutoScrollStopMode.FinishLoop;
704 return AutoScrollStopMode.Immediate;
706 return AutoScrollStopMode.FinishLoop;
711 SetProperty(TextLabel.Property.AUTO_SCROLL_STOP_MODE, new Tizen.NUI.PropertyValue((int)value));
716 /// The line count of text.
723 GetProperty(TextLabel.Property.LINE_COUNT).Get(out temp);