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.
18 using System.ComponentModel;
23 /// The type of item's part type.
26 public enum GenListItemFieldType
34 /// The text part type.
39 /// The Content part type.
44 /// The state of part.
55 /// It inherits <see cref="GenItem"/>.
56 /// A instance to the genlist item added.
57 /// It contains Update() method to update a genlist item which is given.
59 public class GenListItem : GenItem
61 internal GenListItem(object data, GenItemClass itemClass) : base(data, itemClass)
66 /// Gets or sets whether a given genlist item is selected.
68 public override bool IsSelected
72 return Interop.Elementary.elm_genlist_item_selected_get(Handle);
76 Interop.Elementary.elm_genlist_item_selected_set(Handle, value);
81 /// Gets or sets whether a given genlist item is expanded.
83 public bool IsExpanded
87 return Interop.Elementary.elm_genlist_item_expanded_get(Handle);
91 Interop.Elementary.elm_genlist_item_expanded_set(Handle, value);
96 /// Updates the content of an item.
97 /// This updates an item by calling all the <see cref="GenItemClass"/> again to get the content, text, and states.
98 /// Use this when the original item data has changed and the changes are desired to reflect.
99 /// To update already realized items, use <see cref="GenList.UpdateRealizedItems"/>.
101 /// <seealso cref="GenList.UpdateRealizedItems"/>
102 public override void Update()
104 Interop.Elementary.elm_genlist_item_update(Handle);
108 /// Updates the part of an item.
109 /// This updates an item's part by calling item's fetching functions again to get the contents, texts and states.
110 /// Use this when the original item data has changed and the changes are desired to be reflected.
111 /// To update an item's all property, use <see cref="GenList.UpdateRealizedItems"/>.
113 /// <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>
114 /// <param name="type">The type of item's part type.</param>
115 /// <seealso cref="GenList.UpdateRealizedItems"/>
116 public void UpdateField(string part, GenListItemFieldType type)
118 Interop.Elementary.elm_genlist_item_fields_update(Handle, part, (uint)type);
122 /// Demote an item to the end of the list.
124 public void DemoteItem()
126 Interop.Elementary.elm_genlist_item_demote(Handle);
130 /// Gets or sets the genlist item's select mode.
132 public override GenItemSelectionMode SelectionMode
136 return (GenItemSelectionMode)Interop.Elementary.elm_genlist_item_select_mode_get(Handle);
140 Interop.Elementary.elm_genlist_item_select_mode_set(Handle, (Interop.Elementary.Elm_Object_Select_Mode)value);
145 /// Gets the next item in a genlist widget's internal list of items.
147 /// <seealso cref="Previous"/>
148 public GenListItem Next
152 IntPtr next = Interop.Elementary.elm_genlist_item_next_get(Handle);
153 if (next == IntPtr.Zero)
156 return GetItemByHandle(next) as GenListItem;
161 /// Get the previous item in a genlist widget's internal list of items.
163 /// <seealso cref="Next"/>
164 public GenListItem Previous
168 IntPtr prev = Interop.Elementary.elm_genlist_item_prev_get(Handle);
169 if (prev == IntPtr.Zero)
172 return GetItemByHandle(prev) as GenListItem;
177 /// Sets or gets the content to be shown in the tooltip item
179 [EditorBrowsable(EditorBrowsableState.Never)]
180 public override string Cursor
184 return Interop.Elementary.elm_genlist_item_cursor_get(Handle);
188 if (!string.IsNullOrEmpty(value))
190 Interop.Elementary.elm_genlist_item_cursor_set(Handle, value);
194 Interop.Elementary.elm_genlist_item_cursor_unset(Handle);
200 /// Sets or gets the style for this item cursor.
202 [EditorBrowsable(EditorBrowsableState.Never)]
203 public override string CursorStyle
207 return Interop.Elementary.elm_genlist_item_cursor_style_get(Handle);
211 Interop.Elementary.elm_genlist_item_cursor_style_set(Handle, value);
216 /// Sets or gets the cursor engine only usage for this item cursor.
218 [EditorBrowsable(EditorBrowsableState.Never)]
219 public override bool IsUseEngineCursor
223 return Interop.Elementary.elm_genlist_item_cursor_engine_only_get(Handle);
227 Interop.Elementary.elm_genlist_item_cursor_engine_only_set(Handle, value);
232 /// Set the text to be shown in the genlist item.
234 /// <param name="tooltip">The text to set in the content.</param>
235 public override void SetTooltipText(string tooltip)
237 Interop.Elementary.elm_genlist_item_tooltip_text_set(Handle, tooltip);
241 /// Unset tooltip from item.
243 public override void UnsetTooltip()
245 Interop.Elementary.elm_genlist_item_tooltip_unset(Handle);
249 /// Gets or sets the style of given genlist item's tooltip.
251 public override string TooltipStyle
255 return Interop.Elementary.elm_genlist_item_tooltip_style_get(Handle);
259 Interop.Elementary.elm_genlist_item_tooltip_style_set(Handle, value);
264 /// Gets or sets whether disable size restrictions on an object's tooltip.
266 public bool IsTooltipWindowMode
270 return Interop.Elementary.elm_genlist_item_tooltip_window_mode_get(Handle);
274 Interop.Elementary.elm_genlist_item_tooltip_window_mode_set(Handle, value);
279 /// Gets the index of the item. It is only valid once displayed.
285 return Interop.Elementary.elm_genlist_item_index_get(Handle);
290 /// Gets the depth of expanded item.
292 public int ExpandedItemDepth
296 return Interop.Elementary.elm_genlist_item_expanded_depth_get(Handle);
301 /// Remove all sub-items (children) of the given item.
304 /// This removes all items that are children (and their descendants) of the given item it.
306 public void ClearSubitems()
308 Interop.Elementary.elm_genlist_item_subitems_clear(Handle);
312 /// Update the item class of an item.
313 /// 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.
315 /// <param name="itemClass">The item class for the item.</param>
316 /// <param name="data">The data for the item.</param>
317 public void UpdateItemClass(GenItemClass itemClass, object data)
320 ItemClass = itemClass;
321 Interop.Elementary.elm_genlist_item_item_class_update((IntPtr)Handle, itemClass.UnmanagedPtr);
325 /// Set the content to be shown in the tooltip item.
327 protected override void UpdateTooltipDelegate()
329 Interop.Elementary.elm_genlist_item_tooltip_content_cb_set(Handle,
330 TooltipContentDelegate != null ? _tooltipCb : null,