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 = NDalicManualPINVOKE.TextLabel_Property_LINE_COUNT_get();
105 internal static readonly int LINE_WRAP_MODE = NDalicManualPINVOKE.TextLabel_Property_LINE_WRAP_MODE_get();
109 /// Creates the TextLabel control.
111 public TextLabel() : this(NDalicPINVOKE.TextLabel_New__SWIG_0(), true)
113 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
118 /// Creates the TextLabel control.
120 /// <param name="text">The text to display</param>
121 public TextLabel(string text) : this(NDalicPINVOKE.TextLabel_New__SWIG_1(text), true)
123 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
126 internal TextLabel(TextLabel handle) : this(NDalicPINVOKE.new_TextLabel__SWIG_1(TextLabel.getCPtr(handle)), true)
128 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
132 [Obsolete("Please do not use! this will be deprecated")]
133 public new static TextLabel DownCast(BaseHandle handle)
135 TextLabel ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as TextLabel;
136 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
141 /// Text property.<br>
142 /// The text to display in UTF-8 format.<br>
149 GetProperty(TextLabel.Property.TEXT).Get(out temp);
154 SetProperty(TextLabel.Property.TEXT, new Tizen.NUI.PropertyValue(value));
159 /// FontFamily property.<br>
160 /// The requested font family to use.<br>
162 public string FontFamily
167 GetProperty(TextLabel.Property.FONT_FAMILY).Get(out temp);
172 SetProperty(TextLabel.Property.FONT_FAMILY, new Tizen.NUI.PropertyValue(value));
177 /// FontStyle property.<br>
178 /// The requested font style to use.<br>
180 public PropertyMap FontStyle
184 PropertyMap temp = new PropertyMap();
185 GetProperty(TextLabel.Property.FONT_STYLE).Get(temp);
190 SetProperty(TextLabel.Property.FONT_STYLE, new Tizen.NUI.PropertyValue(value));
195 /// PointSize property.<br>
196 /// The size of font in points.<br>
198 public float PointSize
203 GetProperty(TextLabel.Property.POINT_SIZE).Get(out temp);
208 SetProperty(TextLabel.Property.POINT_SIZE, new Tizen.NUI.PropertyValue(value));
213 /// MultiLine property.<br>
214 /// The single-line or multi-line layout option.<br>
216 public bool MultiLine
221 GetProperty(TextLabel.Property.MULTI_LINE).Get(out temp);
226 SetProperty(TextLabel.Property.MULTI_LINE, new Tizen.NUI.PropertyValue(value));
231 /// HorizontalAlignment property.<br>
232 /// The line horizontal alignment.<br>
234 public HorizontalAlignment HorizontalAlignment
239 if (GetProperty(TextLabel.Property.HORIZONTAL_ALIGNMENT).Get(out temp) == false)
241 NUILog.Error("HorizontalAlignment get error!");
246 return HorizontalAlignment.Begin;
248 return HorizontalAlignment.Center;
250 return HorizontalAlignment.End;
252 return HorizontalAlignment.Begin;
257 string valueToString = "";
260 case HorizontalAlignment.Begin:
262 valueToString = "BEGIN";
265 case HorizontalAlignment.Center:
267 valueToString = "CENTER";
270 case HorizontalAlignment.End:
272 valueToString = "END";
277 valueToString = "BEGIN";
281 SetProperty(TextLabel.Property.HORIZONTAL_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
286 /// VerticalAlignment property.<br>
287 /// The line vertical alignment.<br>
289 public VerticalAlignment VerticalAlignment
294 if (GetProperty(TextLabel.Property.VERTICAL_ALIGNMENT).Get(out temp) == false)
296 NUILog.Error("VerticalAlignment get error!");
302 return VerticalAlignment.Top;
304 return VerticalAlignment.Center;
306 return VerticalAlignment.Bottom;
308 return VerticalAlignment.Bottom;
313 string valueToString = "";
316 case VerticalAlignment.Top:
318 valueToString = "TOP";
321 case VerticalAlignment.Center:
323 valueToString = "CENTER";
326 case VerticalAlignment.Bottom:
328 valueToString = "BOTTOM";
333 valueToString = "BOTTOM";
337 SetProperty(TextLabel.Property.VERTICAL_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
342 /// TextColor property.<br>
343 /// The color of the text.<br>
345 public Color TextColor
349 Color temp = new Color(0.0f, 0.0f, 0.0f, 0.0f);
350 GetProperty(TextLabel.Property.TEXT_COLOR).Get(temp);
355 SetProperty(TextLabel.Property.TEXT_COLOR, new Tizen.NUI.PropertyValue(value));
360 /// ShadowOffset property.<br>
361 /// The drop shadow offset 0 indicates no shadow.<br>
363 public Vector2 ShadowOffset
367 Vector2 temp = new Vector2(0.0f, 0.0f);
368 GetProperty(TextLabel.Property.SHADOW_OFFSET).Get(temp);
373 SetProperty(TextLabel.Property.SHADOW_OFFSET, new Tizen.NUI.PropertyValue(value));
378 /// ShadowColor property.<br>
379 /// The color of a drop shadow.<br>
381 public Vector4 ShadowColor
385 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
386 GetProperty(TextLabel.Property.SHADOW_COLOR).Get(temp);
391 SetProperty(TextLabel.Property.SHADOW_COLOR, new Tizen.NUI.PropertyValue(value));
396 /// UnderlineEnabled property.<br>
397 /// The underline enabled flag.<br>
399 public bool UnderlineEnabled
404 GetProperty(TextLabel.Property.UNDERLINE_ENABLED).Get(out temp);
409 SetProperty(TextLabel.Property.UNDERLINE_ENABLED, new Tizen.NUI.PropertyValue(value));
414 /// UnderlineColor property.<br>
415 /// Overrides the underline height from font metrics.<br>
417 public Vector4 UnderlineColor
421 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
422 GetProperty(TextLabel.Property.UNDERLINE_COLOR).Get(temp);
427 SetProperty(TextLabel.Property.UNDERLINE_COLOR, new Tizen.NUI.PropertyValue(value));
432 /// UnderlineHeight property.<br>
433 /// Overrides the underline height from font metrics.<br>
435 public float UnderlineHeight
440 GetProperty(TextLabel.Property.UNDERLINE_HEIGHT).Get(out temp);
445 SetProperty(TextLabel.Property.UNDERLINE_HEIGHT, new Tizen.NUI.PropertyValue(value));
450 /// EnableMarkup property.<br>
451 /// Whether the mark-up processing is enabled.<br>
453 public bool EnableMarkup
458 GetProperty(TextLabel.Property.ENABLE_MARKUP).Get(out temp);
463 SetProperty(TextLabel.Property.ENABLE_MARKUP, new Tizen.NUI.PropertyValue(value));
468 /// EnableAutoScroll property.<br>
469 /// Starts or stops auto scrolling.<br>
471 public bool EnableAutoScroll
476 GetProperty(TextLabel.Property.ENABLE_AUTO_SCROLL).Get(out temp);
481 SetProperty(TextLabel.Property.ENABLE_AUTO_SCROLL, new Tizen.NUI.PropertyValue(value));
486 /// AutoScrollSpeed property.<br>
487 /// Sets the speed of scrolling in pixels per second.<br>
489 public int AutoScrollSpeed
494 GetProperty(TextLabel.Property.AUTO_SCROLL_SPEED).Get(out temp);
499 SetProperty(TextLabel.Property.AUTO_SCROLL_SPEED, new Tizen.NUI.PropertyValue(value));
504 /// AutoScrollLoopCount property.<br>
505 /// Number of complete loops when scrolling enabled.<br>
507 public int AutoScrollLoopCount
512 GetProperty(TextLabel.Property.AUTO_SCROLL_LOOP_COUNT).Get(out temp);
517 SetProperty(TextLabel.Property.AUTO_SCROLL_LOOP_COUNT, new Tizen.NUI.PropertyValue(value));
522 /// AutoScrollGap property.<br>
523 /// Gap before scrolling wraps.<br>
525 public float AutoScrollGap
530 GetProperty(TextLabel.Property.AUTO_SCROLL_GAP).Get(out temp);
535 SetProperty(TextLabel.Property.AUTO_SCROLL_GAP, new Tizen.NUI.PropertyValue(value));
540 /// LineSpacing property.<br>
541 /// The default extra space between lines in points.<br>
543 public float LineSpacing
548 GetProperty(TextLabel.Property.LINE_SPACING).Get(out temp);
553 SetProperty(TextLabel.Property.LINE_SPACING, new Tizen.NUI.PropertyValue(value));
558 /// Underline property.<br>
559 /// The default underline parameters.<br>
561 public PropertyMap Underline
565 PropertyMap temp = new PropertyMap();
566 GetProperty(TextLabel.Property.UNDERLINE).Get(temp);
571 SetProperty(TextLabel.Property.UNDERLINE, new Tizen.NUI.PropertyValue(value));
576 /// Shadow property.<br>
577 /// The default shadow parameters.<br>
579 public PropertyMap Shadow
583 PropertyMap temp = new PropertyMap();
584 GetProperty(TextLabel.Property.SHADOW).Get(temp);
589 SetProperty(TextLabel.Property.SHADOW, new Tizen.NUI.PropertyValue(value));
594 /// Emboss property.<br>
595 /// The default emboss parameters.<br>
602 GetProperty(TextLabel.Property.EMBOSS).Get( out temp);
607 SetProperty(TextLabel.Property.EMBOSS, new Tizen.NUI.PropertyValue(value));
612 /// Outline property.<br>
613 /// The default outline parameters.<br>
615 public string Outline
620 GetProperty(TextLabel.Property.OUTLINE).Get(out temp);
625 SetProperty(TextLabel.Property.OUTLINE, new Tizen.NUI.PropertyValue(value));
630 /// PixelSize property.<br>
631 /// The size of font in pixels.<br>
633 public float PixelSize
638 GetProperty(TextLabel.Property.PIXEL_SIZE).Get(out temp);
643 SetProperty(TextLabel.Property.PIXEL_SIZE, new Tizen.NUI.PropertyValue(value));
648 /// Ellipsis property.<br>
649 /// Enable or disable the ellipsis.<br>
656 GetProperty(TextLabel.Property.ELLIPSIS).Get(out temp);
661 SetProperty(TextLabel.Property.ELLIPSIS, new Tizen.NUI.PropertyValue(value));
666 /// AutoScrollLoopDelay property.<br>
667 /// do something.<br>
669 public float AutoScrollLoopDelay
674 GetProperty(TextLabel.Property.AUTO_SCROLL_LOOP_DELAY).Get(out temp);
679 SetProperty(TextLabel.Property.AUTO_SCROLL_LOOP_DELAY, new Tizen.NUI.PropertyValue(value));
684 /// AutoScrollStopMode property.<br>
685 /// do something.<br>
687 public AutoScrollStopMode AutoScrollStopMode
692 if(GetProperty(TextLabel.Property.AUTO_SCROLL_STOP_MODE).Get(out temp) == false)
694 NUILog.Error("AutoScrollStopMode get error!");
699 return AutoScrollStopMode.FinishLoop;
701 return AutoScrollStopMode.Immediate;
703 return AutoScrollStopMode.FinishLoop;
708 SetProperty(TextLabel.Property.AUTO_SCROLL_STOP_MODE, new Tizen.NUI.PropertyValue((int)value));
713 /// The line count of text.
720 GetProperty(TextLabel.Property.LINE_COUNT).Get(out temp);
726 /// LineWrapMode property.<br>
727 /// line wrap mode when the text lines over layout width.<br>
729 public LineWrapMode LineWrapMode
734 if(GetProperty(TextLabel.Property.LINE_WRAP_MODE).Get(out temp) == false)
736 NUILog.Error("LineWrapMode get error!");
741 return LineWrapMode.Word;
743 return LineWrapMode.Character;
745 return LineWrapMode.Word;
753 case LineWrapMode.Word:
758 case LineWrapMode.Character:
764 SetProperty(TextLabel.Property.LINE_WRAP_MODE, new Tizen.NUI.PropertyValue(temp));