Review Elmsharp API cs files
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / GenListItem.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 using System.ComponentModel;
19
20 namespace ElmSharp
21 {
22     /// <summary>
23     /// The type of the item's part types.
24     /// </summary>
25     /// <since_tizen> preview </since_tizen>
26     [Flags]
27     public enum GenListItemFieldType
28     {
29         /// <summary>
30         /// All item's parts.
31         /// </summary>
32         All = 0,
33
34         /// <summary>
35         /// The Text part type.
36         /// </summary>
37         Text = (1 << 0),
38
39         /// <summary>
40         /// The Content part type.
41         /// </summary>
42         Content = (1 << 1),
43
44         /// <summary>
45         /// The State part type.
46         /// </summary>
47         State = (1 << 2),
48
49         /// <summary>
50         /// No part type.
51         /// </summary>
52         None = (1 << 3)
53     };
54
55     /// <summary>
56     /// It inherits <see cref="GenItem"/>.
57     /// A instance to the genlist item is added.
58     /// It contains the Update() method to update a genlist item which is given.
59     /// </summary>
60     /// <since_tizen> preview </since_tizen>
61     public class GenListItem : GenItem
62     {
63         internal GenListItem(object data, GenItemClass itemClass) : base(data, itemClass)
64         {
65         }
66
67         /// <summary>
68         /// Gets or sets whether a given genlist item is selected.
69         /// </summary>
70         /// <since_tizen> preview </since_tizen>
71         public override bool IsSelected
72         {
73             get
74             {
75                 return Interop.Elementary.elm_genlist_item_selected_get(Handle);
76             }
77             set
78             {
79                 Interop.Elementary.elm_genlist_item_selected_set(Handle, value);
80             }
81         }
82
83         /// <summary>
84         /// Gets or sets whether a given genlist item is expanded.
85         /// </summary>
86         /// <since_tizen> preview </since_tizen>
87         public bool IsExpanded
88         {
89             get
90             {
91                 return Interop.Elementary.elm_genlist_item_expanded_get(Handle);
92             }
93             set
94             {
95                 Interop.Elementary.elm_genlist_item_expanded_set(Handle, value);
96             }
97         }
98
99         /// <summary>
100         /// Updates the content of an item.
101         /// This updates an item by calling all <see cref="GenItemClass"/> again to get the content, text, and states.
102         /// Use this when the original item data has changed and the changes are desired to reflect.
103         /// To update the already realized items, use <see cref="GenList.UpdateRealizedItems"/>.
104         /// </summary>
105         /// <seealso cref="GenList.UpdateRealizedItems"/>
106         /// <since_tizen> preview </since_tizen>
107         public override void Update()
108         {
109             Interop.Elementary.elm_genlist_item_update(Handle);
110         }
111
112         /// <summary>
113         /// Updates the part of an item.
114         /// This updates an item's part by calling the item's fetching functions again to get the contents, texts, and states.
115         /// Use this when the original item data has changed and the changes are desired to be reflected.
116         /// To update an item's all property, use <see cref="GenList.UpdateRealizedItems"/>.
117         /// </summary>
118         /// <param name="part">The part could be "elm.text", "elm.swalllow.icon", "elm.swallow.end", "elm.swallow.content", and so on. It is also used for globbing to match '*', '?', and '.'. It can be used for updating multi-fields.</param>
119         /// <param name="type">The type of the item's part type.</param>
120         /// <seealso cref="GenList.UpdateRealizedItems"/>
121         /// <since_tizen> preview </since_tizen>
122         public void UpdateField(string part, GenListItemFieldType type)
123         {
124             Interop.Elementary.elm_genlist_item_fields_update(Handle, part, (uint)type);
125         }
126
127         /// <summary>
128         /// Demotes an item to the end of the list.
129         /// </summary>
130         /// <since_tizen> preview </since_tizen>
131         public void DemoteItem()
132         {
133             Interop.Elementary.elm_genlist_item_demote(Handle);
134         }
135
136         /// <summary>
137         /// Gets or sets the genlist item's select mode.
138         /// </summary>
139         /// <since_tizen> preview </since_tizen>
140         public override GenItemSelectionMode SelectionMode
141         {
142             get
143             {
144                 return (GenItemSelectionMode)Interop.Elementary.elm_genlist_item_select_mode_get(Handle);
145             }
146             set
147             {
148                 Interop.Elementary.elm_genlist_item_select_mode_set(Handle, (Interop.Elementary.Elm_Object_Select_Mode)value);
149             }
150         }
151
152         /// <summary>
153         /// Gets the next item in a genlist widget's internal list of items.
154         /// </summary>
155         /// <seealso cref="Previous"/>
156         /// <since_tizen> preview </since_tizen>
157         public GenListItem Next
158         {
159             get
160             {
161                 IntPtr next = Interop.Elementary.elm_genlist_item_next_get(Handle);
162                 if (next == IntPtr.Zero)
163                     return null;
164                 else
165                     return GetItemByHandle(next) as GenListItem;
166             }
167         }
168
169         /// <summary>
170         /// Gets the previous item in a genlist widget's internal list of items.
171         /// </summary>
172         /// <seealso cref="Next"/>
173         /// <since_tizen> preview </since_tizen>
174         public GenListItem Previous
175         {
176             get
177             {
178                 IntPtr prev = Interop.Elementary.elm_genlist_item_prev_get(Handle);
179                 if (prev == IntPtr.Zero)
180                     return null;
181                 else
182                     return GetItemByHandle(prev) as GenListItem;
183             }
184         }
185
186         /// <summary>
187         /// Sets or gets the content to be shown in the tooltip item.
188         /// </summary>
189         /// <since_tizen> preview </since_tizen>
190         [EditorBrowsable(EditorBrowsableState.Never)]
191         public override string Cursor
192         {
193             get
194             {
195                 return Interop.Elementary.elm_genlist_item_cursor_get(Handle);
196             }
197             set
198             {
199                 if (!string.IsNullOrEmpty(value))
200                 {
201                     Interop.Elementary.elm_genlist_item_cursor_set(Handle, value);
202                 }
203                 else
204                 {
205                     Interop.Elementary.elm_genlist_item_cursor_unset(Handle);
206                 }
207             }
208         }
209
210         /// <summary>
211         /// Sets or gets the style for this item cursor.
212         /// </summary>
213         /// <since_tizen> preview </since_tizen>
214         [EditorBrowsable(EditorBrowsableState.Never)]
215         public override string CursorStyle
216         {
217             get
218             {
219                 return Interop.Elementary.elm_genlist_item_cursor_style_get(Handle);
220             }
221             set
222             {
223                 Interop.Elementary.elm_genlist_item_cursor_style_set(Handle, value);
224             }
225         }
226
227         /// <summary>
228         /// Sets or gets the cursor engine only usage for this item cursor.
229         /// </summary>
230         /// <since_tizen> preview </since_tizen>
231         [EditorBrowsable(EditorBrowsableState.Never)]
232         public override bool IsUseEngineCursor
233         {
234             get
235             {
236                 return Interop.Elementary.elm_genlist_item_cursor_engine_only_get(Handle);
237             }
238             set
239             {
240                 Interop.Elementary.elm_genlist_item_cursor_engine_only_set(Handle, value);
241             }
242         }
243
244         /// <summary>
245         /// Sets the text to be shown in the genlist item.
246         /// </summary>
247         /// <param name="tooltip">The text to set in the content.</param>
248         /// <since_tizen> preview </since_tizen>
249         public override void SetTooltipText(string tooltip)
250         {
251             Interop.Elementary.elm_genlist_item_tooltip_text_set(Handle, tooltip);
252         }
253
254         /// <summary>
255         /// Unsets the tooltip from the item.
256         /// </summary>
257         /// <since_tizen> preview </since_tizen>
258         public override void UnsetTooltip()
259         {
260             Interop.Elementary.elm_genlist_item_tooltip_unset(Handle);
261         }
262
263         /// <summary>
264         /// Gets or sets the style of the given genlist item's tooltip.
265         /// </summary>
266         /// <since_tizen> preview </since_tizen>
267         public override string TooltipStyle
268         {
269             get
270             {
271                 return Interop.Elementary.elm_genlist_item_tooltip_style_get(Handle);
272             }
273             set
274             {
275                 Interop.Elementary.elm_genlist_item_tooltip_style_set(Handle, value);
276             }
277         }
278
279         /// <summary>
280         /// Gets or sets the disable size restrictions on an object's tooltip.
281         /// </summary>
282         /// <since_tizen> preview </since_tizen>
283         public bool IsTooltipWindowMode
284         {
285             get
286             {
287                 return Interop.Elementary.elm_genlist_item_tooltip_window_mode_get(Handle);
288             }
289             set
290             {
291                 Interop.Elementary.elm_genlist_item_tooltip_window_mode_set(Handle, value);
292             }
293         }
294
295         /// <summary>
296         /// Gets the index of the item. It is only valid, once displayed.
297         /// </summary>
298         /// <since_tizen> preview </since_tizen>
299         public int Index
300         {
301             get
302             {
303                 return Interop.Elementary.elm_genlist_item_index_get(Handle);
304             }
305         }
306
307         /// <summary>
308         /// Gets the depth of the expanded item.
309         /// </summary>
310         /// <since_tizen> preview </since_tizen>
311         public int ExpandedItemDepth
312         {
313             get
314             {
315                 return Interop.Elementary.elm_genlist_item_expanded_depth_get(Handle);
316             }
317         }
318
319         /// <summary>
320         /// Remove all the subitems (children) of the given item.
321         /// </summary>
322         /// <remarks>
323         /// This removes the items that are the children (and their descendants) of the given item.
324         /// </remarks>
325         /// <since_tizen> preview </since_tizen>
326         public void ClearSubitems()
327         {
328             Interop.Elementary.elm_genlist_item_subitems_clear(Handle);
329         }
330
331         /// <summary>
332         /// Updates the item class of the item.
333         /// This sets another class of the item, changing the way that it is displayed. After changing the item class, <see cref="Update"/> is called on the item.
334         /// </summary>
335         /// <param name="itemClass">The item class for the item.</param>
336         /// <param name="data">The data for the item.</param>
337         /// <since_tizen> preview </since_tizen>
338         public void UpdateItemClass(GenItemClass itemClass, object data)
339         {
340             Data = data;
341             ItemClass = itemClass;
342             Interop.Elementary.elm_genlist_item_item_class_update((IntPtr)Handle, itemClass.UnmanagedPtr);
343         }
344
345         /// <summary>
346         /// Sets the content to be shown in the tooltip item.
347         /// </summary>
348         /// <since_tizen> preview </since_tizen>
349         protected override void UpdateTooltipDelegate()
350         {
351             Interop.Elementary.elm_genlist_item_tooltip_content_cb_set(Handle,
352                 TooltipContentDelegate != null ? _tooltipCb : null,
353                 IntPtr.Zero,
354                 null);
355         }
356     }
357 }