Move ExpandedItemDepth property
[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
23     /// <summary>
24     /// The type of item's part type.
25     /// </summary>
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 of part.
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 added.
58     /// It contains Update() method to update a genlist item which is given.
59     /// </summary>
60     public class GenListItem : GenItem
61     {
62         internal GenListItem(object data, GenItemClass itemClass) : base(data, itemClass)
63         {
64         }
65
66         /// <summary>
67         /// Gets or sets whether a given genlist item is selected.
68         /// </summary>
69         public override bool IsSelected
70         {
71             get
72             {
73                 return Interop.Elementary.elm_genlist_item_selected_get(Handle);
74             }
75             set
76             {
77                 Interop.Elementary.elm_genlist_item_selected_set(Handle, value);
78             }
79         }
80
81         /// <summary>
82         /// Gets or sets whether a given genlist item is expanded.
83         /// </summary>
84         public bool IsExpanded
85         {
86             get
87             {
88                 return Interop.Elementary.elm_genlist_item_expanded_get(Handle);
89             }
90             set
91             {
92                 Interop.Elementary.elm_genlist_item_expanded_set(Handle, value);
93             }
94         }
95
96         /// <summary>
97         /// Updates the content of an item.
98         /// This updates an item by calling all the <see cref="GenItemClass"/> again to get the content, text, and states.
99         /// Use this when the original item data has changed and the changes are desired to reflect.
100         /// To update already realized items, use <see cref="GenList.UpdateRealizedItems"/>.
101         /// </summary>
102         /// <seealso cref="GenList.UpdateRealizedItems"/>
103         public override void Update()
104         {
105             Interop.Elementary.elm_genlist_item_update(Handle);
106         }
107
108         /// <summary>
109         /// Updates the part of an item.
110         /// This updates an item's part by calling item's fetching functions again to get the contents, texts and states.
111         /// Use this when the original item data has changed and the changes are desired to be reflected.
112         /// To update an item's all property, use <see cref="GenList.UpdateRealizedItems"/>.
113         /// </summary>
114         /// <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 at updating multi fields.</param>
115         /// <param name="type">The type of item's part type.</param>
116         /// <seealso cref="GenList.UpdateRealizedItems"/>
117         public void UpdateField(string part, GenListItemFieldType type)
118         {
119             Interop.Elementary.elm_genlist_item_fields_update(Handle, part, (uint)type);
120         }
121
122         /// <summary>
123         /// Demote an item to the end of the list.
124         /// </summary>
125         /// <param name="item">The genlistitem object</param>
126         public void DemoteItem()
127         {
128             Interop.Elementary.elm_genlist_item_demote(Handle);
129         }
130
131         /// <summary>
132         /// Gets or sets the genlist item's select mode.
133         /// </summary>
134         public override GenItemSelectionMode SelectionMode
135         {
136             get
137             {
138                 return (GenItemSelectionMode)Interop.Elementary.elm_genlist_item_select_mode_get(Handle);
139             }
140             set
141             {
142                 Interop.Elementary.elm_genlist_item_select_mode_set(Handle, (Interop.Elementary.Elm_Object_Select_Mode)value);
143             }
144         }
145
146         /// <summary>
147         /// Gets the next item in a genlist widget's internal list of items.
148         /// </summary>
149         /// <seealso cref="Previous"/>
150         public GenListItem Next
151         {
152             get
153             {
154                 IntPtr next = Interop.Elementary.elm_genlist_item_next_get(Handle);
155                 if (next == IntPtr.Zero)
156                     return null;
157                 else
158                     return GetItemByHandle(next) as GenListItem;
159             }
160         }
161
162         /// <summary>
163         /// Get the previous item in a genlist widget's internal list of items.
164         /// </summary>
165         /// <seealso cref="Next"/>
166         public GenListItem Previous
167         {
168             get
169             {
170                 IntPtr prev = Interop.Elementary.elm_genlist_item_prev_get(Handle);
171                 if (prev == IntPtr.Zero)
172                     return null;
173                 else
174                     return GetItemByHandle(prev) as GenListItem;
175             }
176         }
177
178         /// <summary>
179         /// Gets or sets the type of mouse pointer/cursor decoration to be shown, when the mouse pointer is over the given genlist widget item.
180         /// <remarks>
181         /// The cursor's changing area is restricted to the item's area, and not the whole widget's. Note that that item cursors have precedence over widget cursors, so that a mouse over item will always show cursor type.
182         /// </remarks>>
183         /// </summary>
184         [EditorBrowsable(EditorBrowsableState.Never)]
185         public override string Cursor
186         {
187             get
188             {
189                 return Interop.Elementary.elm_genlist_item_cursor_get(Handle);
190             }
191             set
192             {
193                 if (!string.IsNullOrEmpty(value))
194                 {
195                     Interop.Elementary.elm_genlist_item_cursor_set(Handle, value);
196                 }
197                 else
198                 {
199                     Interop.Elementary.elm_genlist_item_cursor_unset(Handle);
200                 }
201             }
202         }
203
204         /// <summary>
205         /// Gets or sets custom cursor for genlist item.
206         /// </summary>
207         [EditorBrowsable(EditorBrowsableState.Never)]
208         public override string CursorStyle
209         {
210             get
211             {
212                 return Interop.Elementary.elm_genlist_item_cursor_style_get(Handle);
213             }
214             set
215             {
216                 Interop.Elementary.elm_genlist_item_cursor_style_set(Handle, value);
217             }
218         }
219
220         /// <summary>
221         /// Gets or sets whether to rely on the rendering engine.
222         /// </summary>
223         [EditorBrowsable(EditorBrowsableState.Never)]
224         public override bool IsUseEngineCursor
225         {
226             get
227             {
228                 return Interop.Elementary.elm_genlist_item_cursor_engine_only_get(Handle);
229             }
230             set
231             {
232                 Interop.Elementary.elm_genlist_item_cursor_engine_only_set(Handle, value);
233             }
234         }
235
236         public override void SetTooltipText(string tooltip)
237         {
238             Interop.Elementary.elm_genlist_item_tooltip_text_set(Handle, tooltip);
239         }
240
241         public override void UnsetTooltip()
242         {
243             Interop.Elementary.elm_genlist_item_tooltip_unset(Handle);
244         }
245
246         /// <summary>
247         /// Gets or sets the style of given genlist item's tooltip.
248         /// </summary>
249         public override string TooltipStyle
250         {
251             get
252             {
253                 return Interop.Elementary.elm_genlist_item_tooltip_style_get(Handle);
254             }
255             set
256             {
257                 Interop.Elementary.elm_genlist_item_tooltip_style_set(Handle, value);
258             }
259         }
260
261         /// <summary>
262         /// Gets or sets whether disable size restrictions on an object's tooltip.
263         /// </summary>
264         public bool IsTooltipWindowMode
265         {
266             get
267             {
268                 return Interop.Elementary.elm_genlist_item_tooltip_window_mode_get(Handle);
269             }
270             set
271             {
272                 Interop.Elementary.elm_genlist_item_tooltip_window_mode_set(Handle, value);
273             }
274         }
275
276         /// <summary>
277         /// Gets the index of the item. It is only valid once displayed.
278         /// </summary>
279         public int Index
280         {
281             get
282             {
283                 return Interop.Elementary.elm_genlist_item_index_get(Handle);
284             }
285         }
286
287         /// <summary>
288         /// Gets the depth of expanded item.
289         /// </summary>
290         public int ExpandedItemDepth
291         {
292             get
293             {
294                 return Interop.Elementary.elm_genlist_item_expanded_depth_get(Handle);
295             }
296         }
297
298         /// <summary>
299         /// Remove all sub-items (children) of the given item.
300         /// </summary>
301         /// <remark>
302         /// This removes all items that are children (and their descendants) of the given item it.
303         /// </remark>
304         public void ClearSubitems()
305         {
306             Interop.Elementary.elm_genlist_item_subitems_clear(Handle);
307         }
308
309         /// <summary>
310         /// Update the item class of an item.
311         /// 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.
312         /// </summary>
313         /// <param name="itemClass">The item class for the item.</param>
314         /// <param name="data">The data for the item.</param>
315         public void UpdateItemClass(GenItemClass itemClass, object data)
316         {
317             Data = data;
318             ItemClass = itemClass;
319             Interop.Elementary.elm_genlist_item_item_class_update((IntPtr)Handle, itemClass.UnmanagedPtr);
320         }
321
322         protected override void UpdateTooltipDelegate()
323         {
324             Interop.Elementary.elm_genlist_item_tooltip_content_cb_set(Handle,
325                 TooltipContentDelegate != null ? _tooltipCb : null,
326                 IntPtr.Zero,
327                 null);
328         }
329
330     }
331 }