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.Collections.Generic;
23 /// Enumeration for setting the list's resizing behavior, transverse axis scrolling, and items cropping.
25 /// <since_tizen> preview </since_tizen>
26 [Obsolete("This has been deprecated in API12")]
30 /// The list won't set any of its size hints to inform how a possible container should resize it.
31 /// Then, if it's not created as a "resize object", it might end with zeroed dimensions.
32 /// The list will respect the container's geometry, and if any of its items won't fit into its transverse axis, one won't be able to scroll it in that direction.
36 /// This is the same as Compress, with the exception that if any of its items won't fit into its transverse axis, one will be able to scroll it in that direction.
40 /// Sets a minimum size hint on the genlist object, so that the containers may respect it (and resize itself to fit the child properly).
41 /// More specifically, a minimum size hint will be set for its transverse axis, so that the largest item in that direction fits well.
42 /// This is naturally bound by the list object's maximum size hints, set externally.
46 /// Besides setting a minimum size on the transverse axis, just like on limit, the list will set a minimum size on the longitudinal axis, trying to reserve space to all its children to be visible at a time.
47 /// This is naturally bound by the list object's maximum size hints, set externally.
53 /// It inherits System.EventArgs.
54 /// It contains an item which is <see cref="ListItem"/> type.
55 /// All the events of a list contain ListItemEventArgs as a parameter.
57 /// <since_tizen> preview </since_tizen>
58 [Obsolete("This has been deprecated in API12")]
59 public class ListItemEventArgs : EventArgs
62 /// Gets or sets the list item. The return type is <see cref="ListItem"/>.
64 /// <since_tizen> preview </since_tizen>
65 [Obsolete("This has been deprecated in API12")]
66 public ListItem Item { get; set; }
68 internal static ListItemEventArgs CreateFromSmartEvent(IntPtr data, IntPtr obj, IntPtr info)
70 ListItem item = ItemObject.GetItemByHandle(info) as ListItem;
71 return new ListItemEventArgs() { Item = item };
76 /// It inherits <see cref="Layout"/>.
77 /// The List is a widget that aims to display a simple list item which has 2 icons, 1 text, and can be selected.
78 /// For more robust lists, <see cref="GenList"/> should probably be used.
80 /// <seealso cref="GenList"/>
81 /// <seealso cref="GenGrid"/>
82 /// <since_tizen> preview </since_tizen>
83 [Obsolete("This has been deprecated in API12")]
84 public class List : Layout
86 HashSet<ListItem> _children = new HashSet<ListItem>();
87 SmartEvent<ListItemEventArgs> _selected;
88 SmartEvent<ListItemEventArgs> _unselected;
89 SmartEvent<ListItemEventArgs> _doubleClicked;
90 SmartEvent<ListItemEventArgs> _longpressed;
91 SmartEvent<ListItemEventArgs> _activated;
94 /// Creates and initializes a new instance of the List class.
96 /// <param name="parent">The parent is a given container, which will be attached by the list as a child. It's <see cref="EvasObject"/> type.</param>
97 /// <since_tizen> preview </since_tizen>
98 [Obsolete("This has been deprecated in API12")]
99 public List(EvasObject parent) : base(parent)
101 _selected = new SmartEvent<ListItemEventArgs>(this, this.RealHandle, "selected", ListItemEventArgs.CreateFromSmartEvent);
102 _unselected = new SmartEvent<ListItemEventArgs>(this, this.RealHandle, "unselected", ListItemEventArgs.CreateFromSmartEvent);
103 _doubleClicked = new SmartEvent<ListItemEventArgs>(this, this.RealHandle, "clicked,double", ListItemEventArgs.CreateFromSmartEvent);
104 _longpressed = new SmartEvent<ListItemEventArgs>(this, this.RealHandle, "longpressed", ListItemEventArgs.CreateFromSmartEvent);
105 _activated = new SmartEvent<ListItemEventArgs>(this, this.RealHandle, "activated", ListItemEventArgs.CreateFromSmartEvent);
106 _selected.On += (s, e) => { ItemSelected?.Invoke(this, e); };
107 _unselected.On += (s, e) => { ItemUnselected?.Invoke(this, e); };
108 _doubleClicked.On += (s, e) => { ItemDoubleClicked?.Invoke(this, e); };
109 _longpressed.On += (s, e) => { ItemLongPressed?.Invoke(this, e); };
110 _activated.On += (s, e) => { ItemActivated?.Invoke(this, e); };
114 /// Gets or sets which mode to be used for the list.
116 /// <since_tizen> preview </since_tizen>
117 [Obsolete("This has been deprecated in API12")]
122 return (ListMode)Interop.Elementary.elm_list_mode_get(RealHandle);
126 Interop.Elementary.elm_list_mode_set(RealHandle, (Interop.Elementary.Elm_List_Mode)value);
131 /// Gets the selected item.
133 /// <since_tizen> preview </since_tizen>
134 [Obsolete("This has been deprecated in API12")]
135 public ListItem SelectedItem
139 IntPtr item = Interop.Elementary.elm_list_selected_item_get(RealHandle);
140 return ItemObject.GetItemByHandle(item) as ListItem;
145 /// ItemSelected is raised when a new list item is selected.
147 /// <since_tizen> preview </since_tizen>
148 [Obsolete("This has been deprecated in API12")]
149 public event EventHandler<ListItemEventArgs> ItemSelected;
152 /// ItemUnselected is raised when a list item is Unselected.
154 /// <since_tizen> preview </since_tizen>
155 [Obsolete("This has been deprecated in API12")]
156 public event EventHandler<ListItemEventArgs> ItemUnselected;
159 /// ItemDoubleClicked is raised when a new list item is double-clicked.
161 /// <since_tizen> preview </since_tizen>
162 [Obsolete("This has been deprecated in API12")]
163 public event EventHandler<ListItemEventArgs> ItemDoubleClicked;
166 /// ItemLongPressed is raised when a list item is pressed for a certain amount of time. By default, it's 1 second.
168 /// <since_tizen> preview </since_tizen>
169 [Obsolete("This has been deprecated in API12")]
170 public event EventHandler<ListItemEventArgs> ItemLongPressed;
173 /// ItemActivated is raised when a new list item is double-clicked or pressed (enter|return|spacebar).
175 /// <since_tizen> preview </since_tizen>
176 [Obsolete("This has been deprecated in API12")]
177 public event EventHandler<ListItemEventArgs> ItemActivated;
181 /// Called before running <see cref="EvasObject.Show"/> on the list object.
182 /// If not called, it won't display the list properly.
184 /// <since_tizen> preview </since_tizen>
185 [Obsolete("This has been deprecated in API12")]
188 Interop.Elementary.elm_list_go(RealHandle);
192 /// Appends a new item with a text to the end of a given list widget.
194 /// <param name="label">The text for the item.</param>
195 /// <returns>Return a new added list item that contains a text.</returns>
196 /// <seealso cref="ListItem"/>
197 /// <since_tizen> preview </since_tizen>
198 [Obsolete("This has been deprecated in API12")]
199 public ListItem Append(string label)
201 return Append(label, null, null);
205 /// Appends a new item with a text and 2 icons to the end of a given list widget.
207 /// <param name="label">The text for the item.</param>
208 /// <param name="leftIcon">The left icon for the item.</param>
209 /// <param name="rightIcon">The right icon for the item.</param>
210 /// <returns>Return a new added list item that contains a text and 2 icons.</returns>
211 /// <seealso cref="ListItem"/>
212 /// <since_tizen> preview </since_tizen>
213 [Obsolete("This has been deprecated in API12")]
214 public ListItem Append(string label, EvasObject leftIcon, EvasObject rightIcon)
216 ListItem item = new ListItem(label, leftIcon, rightIcon, this);
217 item.Handle = Interop.Elementary.elm_list_item_append(RealHandle, label, leftIcon, rightIcon, null, (IntPtr)item.Id);
223 /// Prepends a new item with a text to the beginning of a given list widget.
225 /// <param name="label">The text for the item.</param>
226 /// <returns>Return a new added list item that contains a text.</returns>
227 /// <since_tizen> preview </since_tizen>
228 [Obsolete("This has been deprecated in API12")]
229 public ListItem Prepend(string label)
231 return Prepend(label, null, null);
235 /// Prepends a new item with a text and 2 icons to the beginning of a given list widget.
237 /// <param name="label">The text for the item.</param>
238 /// <param name="leftIcon">The left icon for the item.</param>
239 /// <param name="rigthIcon">The right icon for the item.</param>
240 /// <returns>Return a new added list item that contains a text and 2 icons.</returns>
241 /// <since_tizen> preview </since_tizen>
242 [Obsolete("This has been deprecated in API12")]
243 public ListItem Prepend(string label, EvasObject leftIcon, EvasObject rigthIcon)
245 ListItem item = new ListItem(label, leftIcon, rigthIcon, this);
246 item.Handle = Interop.Elementary.elm_list_item_prepend(RealHandle, label, leftIcon, rigthIcon, null, (IntPtr)item.Id);
252 /// Removes all the items from a given list widget.
253 /// To delete just one item, use <see cref="ItemObject.Delete"/>.
255 /// <since_tizen> preview </since_tizen>
256 [Obsolete("This has been deprecated in API12")]
259 Interop.Elementary.elm_list_clear(RealHandle);
260 foreach (var item in _children)
262 item.Deleted -= Item_Deleted;
268 /// Creates a widget handle.
270 /// <param name="parent">Parent EvasObject.</param>
271 /// <returns>Handle IntPtr.</returns>
272 /// <since_tizen> preview </since_tizen>
273 [Obsolete("This has been deprecated in API12")]
274 protected override IntPtr CreateHandle(EvasObject parent)
276 IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle);
277 Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default");
279 RealHandle = Interop.Elementary.elm_list_add(handle);
280 Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);
285 void AddInternal(ListItem item)
288 item.Deleted += Item_Deleted;
291 void Item_Deleted(object sender, EventArgs e)
293 _children.Remove((ListItem)sender);