/* * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; namespace ElmSharp { /// /// The Label is a widget to display text, with a simple HTML-like markup. /// Inherits Layout. /// /// preview public class Label : Layout { SmartEvent _slideCompleted; /// /// Creates and initializes a new instance of the Label class. /// /// The parent is a given container, which will be attached by the Label as a child. It's type. /// preview public Label(EvasObject parent) : base(parent) { _slideCompleted = new SmartEvent(this, this.RealHandle, "slide,end"); _slideCompleted.On += (s, e) => { SlideCompleted?.Invoke(this, EventArgs.Empty); }; } /// /// SlideCompleted will be triggered when the slide is completed. /// /// preview public event EventHandler SlideCompleted; /// /// Sets or gets the wrap width of the label. /// /// preview public int LineWrapWidth { get { return Interop.Elementary.elm_label_wrap_width_get(RealHandle); } set { Interop.Elementary.elm_label_wrap_width_set(RealHandle, value); } } /// /// Sets or gets the wrapping behavior of the label. /// /// preview public WrapType LineWrapType { get { return (WrapType)Interop.Elementary.elm_label_line_wrap_get(RealHandle); } set { Interop.Elementary.elm_label_line_wrap_set(RealHandle, (int)value); if (value != WrapType.None) { Interop.Evas.evas_object_size_hint_min_get(RealHandle, IntPtr.Zero, out int h); Interop.Evas.evas_object_size_hint_min_set(RealHandle, 0, h); } } } /// /// Sets or gets the slide mode of the Label widget. /// /// preview public LabelSlideMode SlideMode { get { return (LabelSlideMode)Interop.Elementary.elm_label_slide_mode_get(RealHandle); } set { Interop.Elementary.elm_label_slide_mode_set(RealHandle, (int)value); } } /// /// Sets or gets the slide duration of the label. /// /// preview public double SlideDuration { get { return Interop.Elementary.elm_label_slide_duration_get(RealHandle); } set { Interop.Elementary.elm_label_slide_duration_set(RealHandle, value); } } /// /// Sets or gets the slide speed of the label. /// /// /// The speed of the slide animation in px per seconds. /// 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. /// /// /// preview public double SlideSpeed { get { return Interop.Elementary.elm_label_slide_speed_get(RealHandle); } set { Interop.Elementary.elm_label_slide_speed_set(RealHandle, value); } } /// /// Sets or gets the ellipsis behavior of the label. /// /// preview public bool IsEllipsis { get { return Interop.Elementary.elm_label_ellipsis_get(RealHandle); } set { Interop.Elementary.elm_label_ellipsis_set(RealHandle, value); } } /// /// Sets or gets the style of the label text. /// /// /// APIs, elm_label_text_style_user_peek/pop/push, are internal APIs only in Tizen. Available since Tizen_4.0. /// /// /// preview public string TextStyle { get { return Interop.Elementary.elm_label_text_style_user_peek(RealHandle); } set { if (string.IsNullOrEmpty(value)) { Interop.Elementary.elm_label_text_style_user_pop(RealHandle); } else { Interop.Elementary.elm_label_text_style_user_push(RealHandle, value); } } } /// /// Starts the slide effect. /// /// preview public void PlaySlide() { Interop.Elementary.elm_label_slide_go(RealHandle); } /// /// Sets the content at a part of a given container widget. /// /// EvasObject /// The new object, otherwise null if it cannot be created. /// preview protected override IntPtr CreateHandle(EvasObject parent) { return Interop.Elementary.elm_label_add(parent.Handle); } } /// /// Enumeration for the slide modes of a label widget. /// /// preview public enum LabelSlideMode { /// /// No slide effect. /// None = 0, /// /// Slide only if the label area is bigger than the text width length. /// Auto, /// /// Slide always. /// Always } }