2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 /// The Label is a widget to display text, with a simple HTML-like markup.
24 /// <since_tizen> preview </since_tizen>
25 public class Label : Layout
27 SmartEvent _slideCompleted;
30 /// Creates and initializes a new instance of the Label class.
32 /// <param name="parent">The parent is a given container, which will be attached by the Label as a child. It's <see cref="EvasObject"/> type.</param>
33 /// <since_tizen> preview </since_tizen>
34 public Label(EvasObject parent) : base(parent)
36 _slideCompleted = new SmartEvent(this, this.RealHandle, "slide,end");
37 _slideCompleted.On += (s, e) =>
39 SlideCompleted?.Invoke(this, EventArgs.Empty);
44 /// SlideCompleted will be triggered when the slide is completed.
46 /// <since_tizen> preview </since_tizen>
47 public event EventHandler SlideCompleted;
50 /// Sets or gets the wrap width of the label.
52 /// <since_tizen> preview </since_tizen>
53 public int LineWrapWidth
57 return Interop.Elementary.elm_label_wrap_width_get(RealHandle);
61 Interop.Elementary.elm_label_wrap_width_set(RealHandle, value);
66 /// Sets or gets the wrapping behavior of the label.
68 /// <since_tizen> preview </since_tizen>
69 public WrapType LineWrapType
73 return (WrapType)Interop.Elementary.elm_label_line_wrap_get(RealHandle);
77 Interop.Elementary.elm_label_line_wrap_set(RealHandle, (int)value);
78 if (value != WrapType.None)
80 Interop.Evas.evas_object_size_hint_min_get(RealHandle, IntPtr.Zero, out int h);
81 Interop.Evas.evas_object_size_hint_min_set(RealHandle, 0, h);
87 /// Sets or gets the slide mode of the Label widget.
89 /// <since_tizen> preview </since_tizen>
90 public LabelSlideMode SlideMode
94 return (LabelSlideMode)Interop.Elementary.elm_label_slide_mode_get(RealHandle);
98 Interop.Elementary.elm_label_slide_mode_set(RealHandle, (int)value);
103 /// Sets or gets the slide duration of the label.
105 /// <since_tizen> preview </since_tizen>
106 public double SlideDuration
110 return Interop.Elementary.elm_label_slide_duration_get(RealHandle);
114 Interop.Elementary.elm_label_slide_duration_set(RealHandle, value);
119 /// Sets or gets the slide speed of the label.
122 /// The speed of the slide animation in px per seconds.
123 /// If you set the duration of the slide using elm_label_slide_duration_set(), you cannot get the correct speed using this function until the label is actually rendered and resized.
125 /// <seealso cref="SlideDuration"/>
126 /// <since_tizen> preview </since_tizen>
127 public double SlideSpeed
131 return Interop.Elementary.elm_label_slide_speed_get(RealHandle);
135 Interop.Elementary.elm_label_slide_speed_set(RealHandle, value);
140 /// Sets or gets the ellipsis behavior of the label.
142 /// <since_tizen> preview </since_tizen>
143 public bool IsEllipsis
147 return Interop.Elementary.elm_label_ellipsis_get(RealHandle);
151 Interop.Elementary.elm_label_ellipsis_set(RealHandle, value);
156 /// Sets or gets the style of the label text.
159 /// APIs, elm_label_text_style_user_peek/pop/push, are internal APIs only in Tizen. Available since Tizen_4.0.
162 /// <since_tizen> preview </since_tizen>
163 public string TextStyle
167 return Interop.Elementary.elm_label_text_style_user_peek(RealHandle);
171 if (string.IsNullOrEmpty(value))
173 Interop.Elementary.elm_label_text_style_user_pop(RealHandle);
177 Interop.Elementary.elm_label_text_style_user_push(RealHandle, value);
183 /// Starts the slide effect.
185 /// <since_tizen> preview </since_tizen>
186 public void PlaySlide()
188 Interop.Elementary.elm_label_slide_go(RealHandle);
192 /// Sets the content at a part of a given container widget.
194 /// <param name="parent">EvasObject</param>
195 /// <returns>The new object, otherwise null if it cannot be created.</returns>
196 /// <since_tizen> preview </since_tizen>
197 protected override IntPtr CreateHandle(EvasObject parent)
199 return Interop.Elementary.elm_label_add(parent.Handle);
204 /// Enumeration for the slide modes of a label widget.
206 /// <since_tizen> preview </since_tizen>
207 public enum LabelSlideMode
214 /// Slide only if the label area is bigger than the text width length.