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();
105 internal static readonly int TEXT_COLOR_ANIMATABLE = NDalicPINVOKE.TextLabel_Property_TEXT_COLOR_ANIMATABLE_get();
106 internal static readonly int LINE_COUNT = OUTLINE + 5;
108 internal static readonly int LINE_COUNT = NDalicManualPINVOKE.TextLabel_Property_LINE_COUNT_get();
109 internal static readonly int LINE_WRAP_MODE = NDalicManualPINVOKE.TextLabel_Property_LINE_WRAP_MODE_get();
110 >>>>>>> parent of b621f76... Revert "[Tizen] Add properties of TextLabel/Editor"
114 /// Creates the TextLabel control.
116 public TextLabel() : this(NDalicPINVOKE.TextLabel_New__SWIG_0(), true)
118 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
123 /// Creates the TextLabel control.
125 /// <param name="text">The text to display</param>
126 public TextLabel(string text) : this(NDalicPINVOKE.TextLabel_New__SWIG_1(text), true)
128 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
131 internal TextLabel(TextLabel handle) : this(NDalicPINVOKE.new_TextLabel__SWIG_1(TextLabel.getCPtr(handle)), true)
133 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
137 [Obsolete("Please do not use! this will be deprecated")]
138 public new static TextLabel DownCast(BaseHandle handle)
140 TextLabel ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as TextLabel;
141 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
146 /// Text property.<br>
147 /// The text to display in UTF-8 format.<br>
154 GetProperty(TextLabel.Property.TEXT).Get(out temp);
159 SetProperty(TextLabel.Property.TEXT, new Tizen.NUI.PropertyValue(value));
164 /// FontFamily property.<br>
165 /// The requested font family to use.<br>
167 public string FontFamily
172 GetProperty(TextLabel.Property.FONT_FAMILY).Get(out temp);
177 SetProperty(TextLabel.Property.FONT_FAMILY, new Tizen.NUI.PropertyValue(value));
182 /// FontStyle property.<br>
183 /// The requested font style to use.<br>
185 public PropertyMap FontStyle
189 PropertyMap temp = new PropertyMap();
190 GetProperty(TextLabel.Property.FONT_STYLE).Get(temp);
195 SetProperty(TextLabel.Property.FONT_STYLE, new Tizen.NUI.PropertyValue(value));
200 /// PointSize property.<br>
201 /// The size of font in points.<br>
203 public float PointSize
208 GetProperty(TextLabel.Property.POINT_SIZE).Get(out temp);
213 SetProperty(TextLabel.Property.POINT_SIZE, new Tizen.NUI.PropertyValue(value));
218 /// MultiLine property.<br>
219 /// The single-line or multi-line layout option.<br>
221 public bool MultiLine
226 GetProperty(TextLabel.Property.MULTI_LINE).Get(out temp);
231 SetProperty(TextLabel.Property.MULTI_LINE, new Tizen.NUI.PropertyValue(value));
236 /// HorizontalAlignment property.<br>
237 /// The line horizontal alignment.<br>
239 public HorizontalAlignment HorizontalAlignment
244 if (GetProperty(TextLabel.Property.HORIZONTAL_ALIGNMENT).Get(out temp) == false)
246 NUILog.Error("HorizontalAlignment get error!");
251 return HorizontalAlignment.Begin;
253 return HorizontalAlignment.Center;
255 return HorizontalAlignment.End;
257 return HorizontalAlignment.Begin;
262 string valueToString = "";
265 case HorizontalAlignment.Begin:
267 valueToString = "BEGIN";
270 case HorizontalAlignment.Center:
272 valueToString = "CENTER";
275 case HorizontalAlignment.End:
277 valueToString = "END";
282 valueToString = "BEGIN";
286 SetProperty(TextLabel.Property.HORIZONTAL_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
291 /// VerticalAlignment property.<br>
292 /// The line vertical alignment.<br>
294 public VerticalAlignment VerticalAlignment
299 if (GetProperty(TextLabel.Property.VERTICAL_ALIGNMENT).Get(out temp) == false)
301 NUILog.Error("VerticalAlignment get error!");
307 return VerticalAlignment.Top;
309 return VerticalAlignment.Center;
311 return VerticalAlignment.Bottom;
313 return VerticalAlignment.Bottom;
318 string valueToString = "";
321 case VerticalAlignment.Top:
323 valueToString = "TOP";
326 case VerticalAlignment.Center:
328 valueToString = "CENTER";
331 case VerticalAlignment.Bottom:
333 valueToString = "BOTTOM";
338 valueToString = "BOTTOM";
342 SetProperty(TextLabel.Property.VERTICAL_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
347 /// TextColor property.<br>
348 /// The color of the text.<br>
350 public Color TextColor
354 Color temp = new Color(0.0f, 0.0f, 0.0f, 0.0f);
355 GetProperty(TextLabel.Property.TEXT_COLOR).Get(temp);
360 SetProperty(TextLabel.Property.TEXT_COLOR, new Tizen.NUI.PropertyValue(value));
365 /// ShadowOffset property.<br>
366 /// The drop shadow offset 0 indicates no shadow.<br>
368 public Vector2 ShadowOffset
372 Vector2 temp = new Vector2(0.0f, 0.0f);
373 GetProperty(TextLabel.Property.SHADOW_OFFSET).Get(temp);
378 SetProperty(TextLabel.Property.SHADOW_OFFSET, new Tizen.NUI.PropertyValue(value));
383 /// ShadowColor property.<br>
384 /// The color of a drop shadow.<br>
386 public Vector4 ShadowColor
390 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
391 GetProperty(TextLabel.Property.SHADOW_COLOR).Get(temp);
396 SetProperty(TextLabel.Property.SHADOW_COLOR, new Tizen.NUI.PropertyValue(value));
401 /// UnderlineEnabled property.<br>
402 /// The underline enabled flag.<br>
404 public bool UnderlineEnabled
409 GetProperty(TextLabel.Property.UNDERLINE_ENABLED).Get(out temp);
414 SetProperty(TextLabel.Property.UNDERLINE_ENABLED, new Tizen.NUI.PropertyValue(value));
419 /// UnderlineColor property.<br>
420 /// Overrides the underline height from font metrics.<br>
422 public Vector4 UnderlineColor
426 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
427 GetProperty(TextLabel.Property.UNDERLINE_COLOR).Get(temp);
432 SetProperty(TextLabel.Property.UNDERLINE_COLOR, new Tizen.NUI.PropertyValue(value));
437 /// UnderlineHeight property.<br>
438 /// Overrides the underline height from font metrics.<br>
440 public float UnderlineHeight
445 GetProperty(TextLabel.Property.UNDERLINE_HEIGHT).Get(out temp);
450 SetProperty(TextLabel.Property.UNDERLINE_HEIGHT, new Tizen.NUI.PropertyValue(value));
455 /// EnableMarkup property.<br>
456 /// Whether the mark-up processing is enabled.<br>
458 public bool EnableMarkup
463 GetProperty(TextLabel.Property.ENABLE_MARKUP).Get(out temp);
468 SetProperty(TextLabel.Property.ENABLE_MARKUP, new Tizen.NUI.PropertyValue(value));
473 /// EnableAutoScroll property.<br>
474 /// Starts or stops auto scrolling.<br>
476 public bool EnableAutoScroll
481 GetProperty(TextLabel.Property.ENABLE_AUTO_SCROLL).Get(out temp);
486 SetProperty(TextLabel.Property.ENABLE_AUTO_SCROLL, new Tizen.NUI.PropertyValue(value));
491 /// AutoScrollSpeed property.<br>
492 /// Sets the speed of scrolling in pixels per second.<br>
494 public int AutoScrollSpeed
499 GetProperty(TextLabel.Property.AUTO_SCROLL_SPEED).Get(out temp);
504 SetProperty(TextLabel.Property.AUTO_SCROLL_SPEED, new Tizen.NUI.PropertyValue(value));
509 /// AutoScrollLoopCount property.<br>
510 /// Number of complete loops when scrolling enabled.<br>
512 public int AutoScrollLoopCount
517 GetProperty(TextLabel.Property.AUTO_SCROLL_LOOP_COUNT).Get(out temp);
522 SetProperty(TextLabel.Property.AUTO_SCROLL_LOOP_COUNT, new Tizen.NUI.PropertyValue(value));
527 /// AutoScrollGap property.<br>
528 /// Gap before scrolling wraps.<br>
530 public float AutoScrollGap
535 GetProperty(TextLabel.Property.AUTO_SCROLL_GAP).Get(out temp);
540 SetProperty(TextLabel.Property.AUTO_SCROLL_GAP, new Tizen.NUI.PropertyValue(value));
545 /// LineSpacing property.<br>
546 /// The default extra space between lines in points.<br>
548 public float LineSpacing
553 GetProperty(TextLabel.Property.LINE_SPACING).Get(out temp);
558 SetProperty(TextLabel.Property.LINE_SPACING, new Tizen.NUI.PropertyValue(value));
563 /// Underline property.<br>
564 /// The default underline parameters.<br>
566 public PropertyMap Underline
570 PropertyMap temp = new PropertyMap();
571 GetProperty(TextLabel.Property.UNDERLINE).Get(temp);
576 SetProperty(TextLabel.Property.UNDERLINE, new Tizen.NUI.PropertyValue(value));
581 /// Shadow property.<br>
582 /// The default shadow parameters.<br>
584 public PropertyMap Shadow
588 PropertyMap temp = new PropertyMap();
589 GetProperty(TextLabel.Property.SHADOW).Get(temp);
594 SetProperty(TextLabel.Property.SHADOW, new Tizen.NUI.PropertyValue(value));
599 /// Emboss property.<br>
600 /// The default emboss parameters.<br>
607 GetProperty(TextLabel.Property.EMBOSS).Get( out temp);
612 SetProperty(TextLabel.Property.EMBOSS, new Tizen.NUI.PropertyValue(value));
617 /// Outline property.<br>
618 /// The default outline parameters.<br>
620 public string Outline
625 GetProperty(TextLabel.Property.OUTLINE).Get(out temp);
630 SetProperty(TextLabel.Property.OUTLINE, new Tizen.NUI.PropertyValue(value));
635 /// PixelSize property.<br>
636 /// The size of font in pixels.<br>
638 public float PixelSize
643 GetProperty(TextLabel.Property.PIXEL_SIZE).Get(out temp);
648 SetProperty(TextLabel.Property.PIXEL_SIZE, new Tizen.NUI.PropertyValue(value));
653 /// Ellipsis property.<br>
654 /// Enable or disable the ellipsis.<br>
661 GetProperty(TextLabel.Property.ELLIPSIS).Get(out temp);
666 SetProperty(TextLabel.Property.ELLIPSIS, new Tizen.NUI.PropertyValue(value));
671 /// AutoScrollLoopDelay property.<br>
672 /// do something.<br>
674 public float AutoScrollLoopDelay
679 GetProperty(TextLabel.Property.AUTO_SCROLL_LOOP_DELAY).Get(out temp);
684 SetProperty(TextLabel.Property.AUTO_SCROLL_LOOP_DELAY, new Tizen.NUI.PropertyValue(value));
689 /// AutoScrollStopMode property.<br>
690 /// do something.<br>
692 public AutoScrollStopMode AutoScrollStopMode
697 if(GetProperty(TextLabel.Property.AUTO_SCROLL_STOP_MODE).Get(out temp) == false)
699 NUILog.Error("AutoScrollStopMode get error!");
704 return AutoScrollStopMode.FinishLoop;
706 return AutoScrollStopMode.Immediate;
708 return AutoScrollStopMode.FinishLoop;
713 SetProperty(TextLabel.Property.AUTO_SCROLL_STOP_MODE, new Tizen.NUI.PropertyValue((int)value));
718 /// TextColorAnimatable property.<br>
719 /// The color of the text that can be animatated.<br>
720 /// Animation framework can be used to change the color of the text when not using mark up.<br>
721 /// Not possible when text is auto scrolling. <br>
723 public Color TextColorAnimatable
727 Color animatableColor = new Color(0.0f, 0.0f, 0.0f, 0.0f);
728 GetProperty(TextLabel.Property.TEXT_COLOR_ANIMATABLE).Get(animatableColor);
729 return animatableColor;
733 SetProperty(TextLabel.Property.TEXT_COLOR_ANIMATABLE, new Tizen.NUI.PropertyValue(value));
737 /// The line count of text.
744 GetProperty(TextLabel.Property.LINE_COUNT).Get(out temp);
750 /// LineWrapMode property.<br>
751 /// line wrap mode when the text lines over layout width.<br>
753 public LineWrapMode LineWrapMode
758 if(GetProperty(TextLabel.Property.LINE_WRAP_MODE).Get(out temp) == false)
760 NUILog.Error("LineWrapMode get error!");
765 return LineWrapMode.Word;
767 return LineWrapMode.Character;
769 return LineWrapMode.Word;
777 case LineWrapMode.Word:
782 case LineWrapMode.Character:
788 SetProperty(TextLabel.Property.LINE_WRAP_MODE, new Tizen.NUI.PropertyValue(temp));