Merge "add api comments for GestureLayer.cs/Icon.cs/Image.cs/Index.cs/ IndexItem...
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / Label.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 using System;
18
19 namespace ElmSharp
20 {
21     /// <summary>
22     /// Label is a widget to display text, with simple html-like markup.
23     /// Inherits Layout
24     /// </summary>
25     public class Label : Layout
26     {
27         SmartEvent _slideCompleted;
28
29         /// <summary>
30         /// Creates and initializes a new instance of Label class.
31         /// </summary>
32         /// <param name="parent">The parent is a given container which will be attached by Label as a child. It's <see cref="EvasObject"/> type.</param>
33         public Label(EvasObject parent) : base(parent)
34         {
35             _slideCompleted = new SmartEvent(this, this.RealHandle, "slide,end");
36             _slideCompleted.On += (s, e) =>
37             {
38                 SlideCompleted?.Invoke(this, EventArgs.Empty);
39             };
40         }
41
42         /// <summary>
43         /// SlideCompleted will be triggered when the slide is completed.
44         /// </summary>
45         public event EventHandler SlideCompleted;
46
47         /// <summary>
48         /// Sets or gets wrap width of the label.
49         /// </summary>
50         public int LineWrapWidth
51         {
52             get
53             {
54                 return Interop.Elementary.elm_label_wrap_width_get(RealHandle);
55             }
56             set
57             {
58                 Interop.Elementary.elm_label_wrap_width_set(RealHandle, value);
59             }
60         }
61
62         /// <summary>
63         /// Sets or gets the wrapping behavior of the label.
64         /// </summary>
65         public WrapType LineWrapType
66         {
67             get
68             {
69                 return (WrapType)Interop.Elementary.elm_label_line_wrap_get(RealHandle);
70             }
71             set
72             {
73                 Interop.Elementary.elm_label_line_wrap_set(RealHandle, (int)value);
74             }
75         }
76
77         /// <summary>
78         /// Sets or gets the slide mode of the label widget.
79         /// </summary>
80         public LabelSlideMode SlideMode
81         {
82             get
83             {
84                 return (LabelSlideMode)Interop.Elementary.elm_label_slide_mode_get(RealHandle);
85             }
86             set
87             {
88                 Interop.Elementary.elm_label_slide_mode_set(RealHandle, (int)value);
89             }
90         }
91
92         /// <summary>
93         /// Sets or gets the slide duration of the label.
94         /// </summary>
95         public double SlideDuration
96         {
97             get
98             {
99                 return Interop.Elementary.elm_label_slide_duration_get(RealHandle);
100             }
101             set
102             {
103                 Interop.Elementary.elm_label_slide_duration_set(RealHandle, value);
104             }
105         }
106
107         /// <summary>
108         /// Sets or gets the ellipsis behavior of the label.
109         /// </summary>
110         public bool IsEllipsis
111         {
112             get
113             {
114                 return Interop.Elementary.elm_label_ellipsis_get(RealHandle);
115             }
116             set
117             {
118                 Interop.Elementary.elm_label_ellipsis_set(RealHandle, value);
119             }
120         }
121
122         /// <summary>
123         /// Start slide effect.
124         /// </summary>
125         public void PlaySlide()
126         {
127             Interop.Elementary.elm_label_slide_go(RealHandle);
128         }
129
130         /// <summary>
131         /// Sets the content at a part of a given container widget.
132         /// </summary>
133         /// <param name="parent">EvasObject</param>
134         /// <returns>The new object, otherwise null if it cannot be created</returns>
135         protected override IntPtr CreateHandle(EvasObject parent)
136         {
137             //TODO: Fix this to use layout
138             return Interop.Elementary.elm_label_add(parent.Handle);
139         }
140     }
141
142     /// <summary>
143     /// Enumeration for slide mode of a label widget
144     /// </summary>
145     public enum LabelSlideMode
146     {
147         /// <summary>
148         /// no slide effect
149         /// </summary>
150         None = 0,
151         /// <summary>
152         /// slide only if the label area is bigger than the text width length
153         /// </summary>
154         Auto,
155         /// <summary>
156         /// slide always
157         /// </summary>
158         Always
159     }
160 }