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)
66 NDalicPINVOKE.delete_TextLabel(swigCPtr);
68 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
74 internal class Property
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 internal static readonly int LINE_COUNT = OUTLINE + 5;
108 /// Creates the TextLabel control.
110 public TextLabel() : this(NDalicPINVOKE.TextLabel_New__SWIG_0(), true)
112 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
117 /// Creates the TextLabel control.
119 /// <param name="text">The text to display</param>
120 public TextLabel(string text) : this(NDalicPINVOKE.TextLabel_New__SWIG_1(text), true)
122 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
125 internal TextLabel(TextLabel handle) : this(NDalicPINVOKE.new_TextLabel__SWIG_1(TextLabel.getCPtr(handle)), true)
127 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
131 [Obsolete("Please do not use! this will be deprecated")]
132 public new static TextLabel DownCast(BaseHandle handle)
134 TextLabel ret = new TextLabel(NDalicPINVOKE.TextLabel_DownCast(BaseHandle.getCPtr(handle)), true);
135 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
140 /// Text property.<br>
141 /// The text to display in UTF-8 format.<br>
148 GetProperty(TextLabel.Property.TEXT).Get(out temp);
153 SetProperty(TextLabel.Property.TEXT, new Tizen.NUI.PropertyValue(value));
158 /// FontFamily property.<br>
159 /// The requested font family to use.<br>
161 public string FontFamily
166 GetProperty(TextLabel.Property.FONT_FAMILY).Get(out temp);
171 SetProperty(TextLabel.Property.FONT_FAMILY, new Tizen.NUI.PropertyValue(value));
176 /// FontStyle property.<br>
177 /// The requested font style to use.<br>
179 public PropertyMap FontStyle
183 PropertyMap temp = new PropertyMap();
184 GetProperty(TextLabel.Property.FONT_STYLE).Get(temp);
189 SetProperty(TextLabel.Property.FONT_STYLE, new Tizen.NUI.PropertyValue(value));
194 /// PointSize property.<br>
195 /// The size of font in points.<br>
197 public float PointSize
202 GetProperty(TextLabel.Property.POINT_SIZE).Get(out temp);
207 SetProperty(TextLabel.Property.POINT_SIZE, new Tizen.NUI.PropertyValue(value));
212 /// MultiLine property.<br>
213 /// The single-line or multi-line layout option.<br>
215 public bool MultiLine
220 GetProperty(TextLabel.Property.MULTI_LINE).Get(out temp);
225 SetProperty(TextLabel.Property.MULTI_LINE, new Tizen.NUI.PropertyValue(value));
230 /// HorizontalAlignment property.<br>
231 /// The line horizontal alignment.<br>
233 public HorizontalAlignment HorizontalAlignment
238 if (GetProperty(TextLabel.Property.HORIZONTAL_ALIGNMENT).Get(out temp) == false)
240 NUILog.Error("HorizontalAlignment get error!");
245 return HorizontalAlignment.Begin;
247 return HorizontalAlignment.Center;
249 return HorizontalAlignment.End;
251 return HorizontalAlignment.Begin;
256 string valueToString = "";
259 case HorizontalAlignment.Begin:
261 valueToString = "BEGIN";
264 case HorizontalAlignment.Center:
266 valueToString = "CENTER";
269 case HorizontalAlignment.End:
271 valueToString = "END";
276 valueToString = "BEGIN";
280 SetProperty(TextLabel.Property.HORIZONTAL_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
285 /// VerticalAlignment property.<br>
286 /// The line vertical alignment.<br>
288 public VerticalAlignment VerticalAlignment
293 if (GetProperty(TextLabel.Property.VERTICAL_ALIGNMENT).Get(out temp) == false)
295 NUILog.Error("VerticalAlignment get error!");
301 return VerticalAlignment.Top;
303 return VerticalAlignment.Center;
305 return VerticalAlignment.Bottom;
307 return VerticalAlignment.Bottom;
312 string valueToString = "";
315 case VerticalAlignment.Top:
317 valueToString = "TOP";
320 case VerticalAlignment.Center:
322 valueToString = "CENTER";
325 case VerticalAlignment.Bottom:
327 valueToString = "BOTTOM";
332 valueToString = "BOTTOM";
336 SetProperty(TextLabel.Property.VERTICAL_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
341 /// TextColor property.<br>
342 /// The color of the text.<br>
344 public Color TextColor
348 Color temp = new Color(0.0f, 0.0f, 0.0f, 0.0f);
349 GetProperty(TextLabel.Property.TEXT_COLOR).Get(temp);
354 SetProperty(TextLabel.Property.TEXT_COLOR, new Tizen.NUI.PropertyValue(value));
359 /// ShadowOffset property.<br>
360 /// The drop shadow offset 0 indicates no shadow.<br>
362 public Vector2 ShadowOffset
366 Vector2 temp = new Vector2(0.0f, 0.0f);
367 GetProperty(TextLabel.Property.SHADOW_OFFSET).Get(temp);
372 SetProperty(TextLabel.Property.SHADOW_OFFSET, new Tizen.NUI.PropertyValue(value));
377 /// ShadowColor property.<br>
378 /// The color of a drop shadow.<br>
380 public Vector4 ShadowColor
384 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
385 GetProperty(TextLabel.Property.SHADOW_COLOR).Get(temp);
390 SetProperty(TextLabel.Property.SHADOW_COLOR, new Tizen.NUI.PropertyValue(value));
395 /// UnderlineEnabled property.<br>
396 /// The underline enabled flag.<br>
398 public bool UnderlineEnabled
403 GetProperty(TextLabel.Property.UNDERLINE_ENABLED).Get(out temp);
408 SetProperty(TextLabel.Property.UNDERLINE_ENABLED, new Tizen.NUI.PropertyValue(value));
413 /// UnderlineColor property.<br>
414 /// Overrides the underline height from font metrics.<br>
416 public Vector4 UnderlineColor
420 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
421 GetProperty(TextLabel.Property.UNDERLINE_COLOR).Get(temp);
426 SetProperty(TextLabel.Property.UNDERLINE_COLOR, new Tizen.NUI.PropertyValue(value));
431 /// UnderlineHeight property.<br>
432 /// Overrides the underline height from font metrics.<br>
434 public float UnderlineHeight
439 GetProperty(TextLabel.Property.UNDERLINE_HEIGHT).Get(out temp);
444 SetProperty(TextLabel.Property.UNDERLINE_HEIGHT, new Tizen.NUI.PropertyValue(value));
449 /// EnableMarkup property.<br>
450 /// Whether the mark-up processing is enabled.<br>
452 public bool EnableMarkup
457 GetProperty(TextLabel.Property.ENABLE_MARKUP).Get(out temp);
462 SetProperty(TextLabel.Property.ENABLE_MARKUP, new Tizen.NUI.PropertyValue(value));
467 /// EnableAutoScroll property.<br>
468 /// Starts or stops auto scrolling.<br>
470 public bool EnableAutoScroll
475 GetProperty(TextLabel.Property.ENABLE_AUTO_SCROLL).Get(out temp);
480 SetProperty(TextLabel.Property.ENABLE_AUTO_SCROLL, new Tizen.NUI.PropertyValue(value));
485 /// AutoScrollSpeed property.<br>
486 /// Sets the speed of scrolling in pixels per second.<br>
488 public int AutoScrollSpeed
493 GetProperty(TextLabel.Property.AUTO_SCROLL_SPEED).Get(out temp);
498 SetProperty(TextLabel.Property.AUTO_SCROLL_SPEED, new Tizen.NUI.PropertyValue(value));
503 /// AutoScrollLoopCount property.<br>
504 /// Number of complete loops when scrolling enabled.<br>
506 public int AutoScrollLoopCount
511 GetProperty(TextLabel.Property.AUTO_SCROLL_LOOP_COUNT).Get(out temp);
516 SetProperty(TextLabel.Property.AUTO_SCROLL_LOOP_COUNT, new Tizen.NUI.PropertyValue(value));
521 /// AutoScrollGap property.<br>
522 /// Gap before scrolling wraps.<br>
524 public float AutoScrollGap
529 GetProperty(TextLabel.Property.AUTO_SCROLL_GAP).Get(out temp);
534 SetProperty(TextLabel.Property.AUTO_SCROLL_GAP, new Tizen.NUI.PropertyValue(value));
539 /// LineSpacing property.<br>
540 /// The default extra space between lines in points.<br>
542 public float LineSpacing
547 GetProperty(TextLabel.Property.LINE_SPACING).Get(out temp);
552 SetProperty(TextLabel.Property.LINE_SPACING, new Tizen.NUI.PropertyValue(value));
557 /// Underline property.<br>
558 /// The default underline parameters.<br>
560 public PropertyMap Underline
564 PropertyMap temp = new PropertyMap();
565 GetProperty(TextLabel.Property.UNDERLINE).Get(temp);
570 SetProperty(TextLabel.Property.UNDERLINE, new Tizen.NUI.PropertyValue(value));
575 /// Shadow property.<br>
576 /// The default shadow parameters.<br>
578 public PropertyMap Shadow
582 PropertyMap temp = new PropertyMap();
583 GetProperty(TextLabel.Property.SHADOW).Get(temp);
588 SetProperty(TextLabel.Property.SHADOW, new Tizen.NUI.PropertyValue(value));
593 /// Emboss property.<br>
594 /// The default emboss parameters.<br>
601 GetProperty(TextLabel.Property.EMBOSS).Get( out temp);
606 SetProperty(TextLabel.Property.EMBOSS, new Tizen.NUI.PropertyValue(value));
611 /// Outline property.<br>
612 /// The default outline parameters.<br>
614 public string Outline
619 GetProperty(TextLabel.Property.OUTLINE).Get(out temp);
624 SetProperty(TextLabel.Property.OUTLINE, new Tizen.NUI.PropertyValue(value));
629 /// PixelSize property.<br>
630 /// The size of font in pixels.<br>
632 public float PixelSize
637 GetProperty(TextLabel.Property.PIXEL_SIZE).Get(out temp);
642 SetProperty(TextLabel.Property.PIXEL_SIZE, new Tizen.NUI.PropertyValue(value));
647 /// Ellipsis property.<br>
648 /// Enable or disable the ellipsis.<br>
655 GetProperty(TextLabel.Property.ELLIPSIS).Get(out temp);
660 SetProperty(TextLabel.Property.ELLIPSIS, new Tizen.NUI.PropertyValue(value));
665 /// AutoScrollLoopDelay property.<br>
666 /// do something.<br>
668 public float AutoScrollLoopDelay
673 GetProperty(TextLabel.Property.AUTO_SCROLL_LOOP_DELAY).Get(out temp);
678 SetProperty(TextLabel.Property.AUTO_SCROLL_LOOP_DELAY, new Tizen.NUI.PropertyValue(value));
683 /// AutoScrollStopMode property.<br>
684 /// do something.<br>
686 public AutoScrollStopMode AutoScrollStopMode
691 if(GetProperty(TextLabel.Property.AUTO_SCROLL_STOP_MODE).Get(out temp) == false)
693 NUILog.Error("AutoScrollStopMode get error!");
698 return AutoScrollStopMode.FinishLoop;
700 return AutoScrollStopMode.Immediate;
702 return AutoScrollStopMode.FinishLoop;
707 SetProperty(TextLabel.Property.AUTO_SCROLL_STOP_MODE, new Tizen.NUI.PropertyValue((int)value));
712 /// The line count of text.
719 GetProperty(TextLabel.Property.LINE_COUNT).Get(out temp);