2 * Copyright (c) 2018 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 genlist item types.
25 /// <since_tizen> preview </since_tizen>
26 public enum GenListItemType
29 /// If Normal is set, then this item is a normal item.
34 /// If Tree is set, then this item is displayed as an item that is able to expand and have child items.
39 /// If Group is set, then this item is a group index item that is displayed at the top until the next group comes.
45 /// Enumeration for setting the genlist's resizing behavior, transverse axis scrolling, and items cropping.
47 /// <since_tizen> preview </since_tizen>
48 public enum GenListMode
51 /// The genlist won't set any of its size hints to inform how a possible container should resize it.
52 /// Then, if it's not created as a "resize object", it might end up with zeroed dimensions.
53 /// The genlist 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.
58 /// 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.
63 /// Sets a minimum size hint on the genlist object, so that containers may respect it (and resize itself to fit the child properly).
64 /// More specifically, a minimum size hint will be set for its transverse axis, so that the largest item in that direction fits well.
65 /// This is naturally bound by the genlist object's maximum size hints, set externally.
70 /// Besides setting a minimum size on the transverse axis, just like on Limit, the genlist will set a minimum size on the longitudinal axis, trying to reserve space to all its children to be visible at a time.
71 /// This is naturally bound by the genlist object's maximum size hints, set externally.
77 /// It inherits System.EventArgs.
78 /// It contains an item which is <see cref="GenListItem"/> type.
79 /// All events of the GenList contain GenListItemEventArgs as a parameter.
81 /// <since_tizen> preview </since_tizen>
82 public class GenListItemEventArgs : EventArgs
85 /// Gets or sets the genlist item. The return type is <see cref="GenListItem"/>.
87 /// <since_tizen> preview </since_tizen>
88 public GenListItem Item { get; set; }
90 internal static GenListItemEventArgs CreateFromSmartEvent(IntPtr data, IntPtr obj, IntPtr info)
92 GenListItem item = ItemObject.GetItemByHandle(info) as GenListItem;
93 return new GenListItemEventArgs { Item = item };
98 /// Enumeration for defining where to position the item in the genlist.
100 /// <since_tizen> preview </since_tizen>
101 public enum ScrollToPosition
104 /// Scrolls to nowhere.
109 /// Scrolls to the nearest viewport.
114 /// Scrolls to the top of the viewport.
119 /// Scrolls to the middle of the viewport.
124 /// Scrolls to the bottom of the viewport.
130 /// It inherits <see cref="Layout"/>.
131 /// The GenList is a widget that aims to have a more expansive list than the simple <see cref="List"/> in ElmSharp that could have more flexible items and allow many more entries while still being fast and low on memory usage.
132 /// At the same time it was also made to be able to do tree structures.
133 /// But the price to pay is more complex when it comes to usage.
134 /// If all you want is a simple list with icons and a single text, use <see cref="List"/> widget.
136 /// <since_tizen> preview </since_tizen>
137 public class GenList : Layout
139 HashSet<GenListItem> _children = new HashSet<GenListItem>();
141 SmartEvent<GenListItemEventArgs> _selected;
142 SmartEvent<GenListItemEventArgs> _unselected;
143 SmartEvent<GenListItemEventArgs> _activated;
144 SmartEvent<GenListItemEventArgs> _pressed;
145 SmartEvent<GenListItemEventArgs> _released;
146 SmartEvent<GenListItemEventArgs> _doubleClicked;
147 SmartEvent<GenListItemEventArgs> _expanded;
148 SmartEvent<GenListItemEventArgs> _realized;
149 SmartEvent<GenListItemEventArgs> _unrealized;
150 SmartEvent<GenListItemEventArgs> _longpressed;
151 SmartEvent<GenListItemEventArgs> _moved;
152 SmartEvent<GenListItemEventArgs> _movedAfter;
153 SmartEvent<GenListItemEventArgs> _movedBefore;
154 SmartEvent _scrollAnimationStarted;
155 SmartEvent _scrollAnimationStopped;
159 /// Creates and initializes a new instance of the GenList class.
161 /// <param name="parent">The parent is a given container, which will be attached by GenList as a child. It's <see cref="EvasObject"/> type.</param>
162 /// <since_tizen> preview </since_tizen>
163 public GenList(EvasObject parent) : base(parent)
168 /// Creates and initializes a new instance of the GenList class.
170 /// <since_tizen> preview </since_tizen>
176 /// Gets or sets whether the homogeneous mode is enabled.
179 /// If true, the genlist items will have the same height and width.
181 /// <since_tizen> preview </since_tizen>
182 public bool Homogeneous
186 return Interop.Elementary.elm_genlist_homogeneous_get(RealHandle);
190 Interop.Elementary.elm_genlist_homogeneous_set(RealHandle, value);
195 /// Gets or sets the horizontal stretching mode. This mode used for sizing items horizontally.
196 /// The default value is <see cref="GenListMode.Scroll"/>, which means that if the items are too wide to fit, the scroller scrolls horizontally.
197 /// If set to <see cref="GenListMode.Compress"/>, means that the item width is fixed (restricted to a minimum) to the list width when calculating its size in order to allow the height to be calculated based on it.
198 /// If set to <see cref="GenListMode.Limit"/>, means that items are expanded to the viewport width and limited to that size.
199 /// If set to <see cref="GenListMode.Expand"/>, means that genlist try to reserve space to all its items to be visible at a time.
202 /// Compress makes the genlist resize slower, as it recalculates every item height again whenever the list width changes.
203 /// The homogeneous mode is so that all items in the genlist are of the same width/height. With Compress, the genlist items are initialized fast.
204 /// However, there are no subobjects in the genlist, which can be on the flying resizable (such as TEXTBLOCK).
205 /// If so, then some dynamic resizable objects in the genlist would not be diplayed properly.
207 /// <since_tizen> preview </since_tizen>
208 public GenListMode ListMode
212 return (GenListMode)Interop.Elementary.elm_genlist_mode_get(RealHandle);
216 Interop.Elementary.elm_genlist_mode_set(RealHandle, (int)value);
221 /// Gets the first item in the genlist.
223 /// <since_tizen> preview </since_tizen>
224 public GenListItem FirstItem
228 IntPtr handle = Interop.Elementary.elm_genlist_first_item_get(RealHandle);
229 return ItemObject.GetItemByHandle(handle) as GenListItem;
234 /// Gets the last item in the genlist.
236 /// <since_tizen> preview </since_tizen>
237 public GenListItem LastItem
241 IntPtr handle = Interop.Elementary.elm_genlist_last_item_get(RealHandle);
242 return ItemObject.GetItemByHandle(handle) as GenListItem;
247 /// Gets or sets the reorder mode.
248 /// After turning on the reorder mode, longpress on a normal item triggers reordering of the item.
249 /// You can move the item up and down. However, reordering does not work with group items.
251 /// <since_tizen> preview </since_tizen>
252 public bool ReorderMode
256 return Interop.Elementary.elm_genlist_reorder_mode_get(RealHandle);
260 Interop.Elementary.elm_genlist_reorder_mode_set(RealHandle, value);
265 /// Gets or sets the maximum number of items within an item block.
267 /// <since_tizen> preview </since_tizen>
268 public int BlockCount
272 return Interop.Elementary.elm_genlist_block_count_get(RealHandle);
276 Interop.Elementary.elm_genlist_block_count_set(RealHandle, value);
281 /// Gets or sets whether the genlist items should be highlighted when an item is selected.
283 /// <since_tizen> preview </since_tizen>
284 public bool IsHighlight
288 return Interop.Elementary.elm_genlist_highlight_mode_get(RealHandle);
292 Interop.Elementary.elm_genlist_highlight_mode_set(RealHandle, value);
297 /// Gets or sets the timeout in seconds for the longpress event.
299 /// <since_tizen> preview </since_tizen>
300 public double LongPressTimeout
304 return Interop.Elementary.elm_genlist_longpress_timeout_get(RealHandle);
308 Interop.Elementary.elm_genlist_longpress_timeout_set(RealHandle, value);
313 /// Gets or sets the focus upon the items selection mode.
316 /// When enabled, every selection of an item inside <see cref="GenList"/> will automatically set focus to its first focusable widget from the left.
317 /// This is true of course, if the selection was made by clicking an unfocusable area in an item or selecting it with a key movement.
318 /// Clicking on a focusable widget inside an item will couse this particular item to get focus as usual.
320 /// <since_tizen> preview </since_tizen>
321 public bool FocusOnSelection
325 return Interop.Elementary.elm_genlist_focus_on_selection_get(RealHandle);
329 Interop.Elementary.elm_genlist_focus_on_selection_set(RealHandle, value);
334 /// Gets or sets whether to enable multi-selection in the genlist.
336 /// <since_tizen> preview </since_tizen>
337 public bool IsMultiSelection
341 return Interop.Elementary.elm_genlist_multi_select_get(RealHandle);
345 Interop.Elementary.elm_genlist_multi_select_set(RealHandle, value);
350 /// Gets the selected item in a given GenList widget.
352 /// <since_tizen> preview </since_tizen>
353 public GenListItem SelectedItem
357 IntPtr handle = Interop.Elementary.elm_genlist_selected_item_get(RealHandle);
358 return ItemObject.GetItemByHandle(handle) as GenListItem;
363 /// Gets or sets the genlist select mode by <see cref="GenItemSelectionMode"/>.
365 /// <since_tizen> preview </since_tizen>
366 public GenItemSelectionMode SelectionMode
370 return (GenItemSelectionMode)Interop.Elementary.elm_genlist_select_mode_get(RealHandle);
374 Interop.Elementary.elm_genlist_select_mode_set(RealHandle, (int)value);
379 /// Gets the count of items in a this genlist widget.
381 /// <since_tizen> preview </since_tizen>
386 return Interop.Elementary.elm_genlist_items_count(RealHandle);
391 /// Sets or gets the value of HorizontalScrollBarVisiblePolicy.
394 /// ScrollBarVisiblePolicy.Auto means the horizontal scrollbar is made visible if it is needed, and otherwise kept hidden.
395 /// ScrollBarVisiblePolicy.Visible turns it on all the time, and ScrollBarVisiblePolicy.Invisible always keeps it off.
397 /// <since_tizen> preview </since_tizen>
398 public ScrollBarVisiblePolicy HorizontalScrollBarVisiblePolicy
402 Interop.Elementary.elm_scroller_policy_get(RealHandle, out int policy, IntPtr.Zero);
403 return (ScrollBarVisiblePolicy)policy;
407 ScrollBarVisiblePolicy v = VerticalScrollBarVisiblePolicy;
408 Interop.Elementary.elm_scroller_policy_set(RealHandle, (int)value, (int)v);
413 /// Sets or gets the value of VerticalScrollBarVisiblePolicy.
416 /// ScrollBarVisiblePolicy.Auto means the vertical scrollbar is made visible if it is needed, and otherwise kept hidden.
417 /// ScrollBarVisiblePolicy.Visible turns it on all the time, and ScrollBarVisiblePolicy.Invisible always keeps it off.
419 /// <since_tizen> preview </since_tizen>
420 public ScrollBarVisiblePolicy VerticalScrollBarVisiblePolicy
424 Interop.Elementary.elm_scroller_policy_get(RealHandle, IntPtr.Zero, out int policy);
425 return (ScrollBarVisiblePolicy)policy;
429 ScrollBarVisiblePolicy h = HorizontalScrollBarVisiblePolicy;
430 Interop.Elementary.elm_scroller_policy_set(RealHandle, (int)h, (int)value);
435 /// ItemSelected is raised when a new genlist item is selected.
437 /// <since_tizen> preview </since_tizen>
438 public event EventHandler<GenListItemEventArgs> ItemSelected;
441 /// ItemUnselected is raised when the genlist item is unselected.
443 /// <since_tizen> preview </since_tizen>
444 public event EventHandler<GenListItemEventArgs> ItemUnselected;
447 /// ItemPressed is raised when a new genlist item is pressed.
449 /// <since_tizen> preview </since_tizen>
450 public event EventHandler<GenListItemEventArgs> ItemPressed;
453 /// ItemReleased is raised when a new genlist item is released.
455 /// <since_tizen> preview </since_tizen>
456 public event EventHandler<GenListItemEventArgs> ItemReleased;
459 /// ItemActivated is raised when a new genlist item is double-clicked or pressed (enter|return|spacebar).
461 /// <since_tizen> preview </since_tizen>
462 public event EventHandler<GenListItemEventArgs> ItemActivated;
465 /// ItemDoubleClicked is raised when a new genlist item is double-clicked.
467 /// <since_tizen> preview </since_tizen>
468 public event EventHandler<GenListItemEventArgs> ItemDoubleClicked;
471 /// ItemExpanded is raised when a new genlist item is indicated to expand.
473 /// <since_tizen> preview </since_tizen>
474 public event EventHandler<GenListItemEventArgs> ItemExpanded;
477 /// ItemRealized is raised when a new genlist item is created as a real object.
479 /// <since_tizen> preview </since_tizen>
480 public event EventHandler<GenListItemEventArgs> ItemRealized;
483 /// ItemUnrealized is raised when a new genlist item is unrealized.
484 /// After calling unrealize, the item's content objects are deleted, and the item object itself is deleted or is put into a floating cache.
486 /// <since_tizen> preview </since_tizen>
487 public event EventHandler<GenListItemEventArgs> ItemUnrealized;
490 /// ItemLongPressed is raised when a genlist item is pressed for a certain amount of time. By default, it's 1 second.
492 /// <since_tizen> preview </since_tizen>
493 public event EventHandler<GenListItemEventArgs> ItemLongPressed;
496 /// ItemMoved is raised when a genlist item is moved in the reorder mode.
498 /// <since_tizen> preview </since_tizen>
499 public event EventHandler<GenListItemEventArgs> ItemMoved;
502 /// ItemMovedAfter is raised when a genlist item is moved after another item in the reorder mode.
503 /// To get the relative previous item, use <see cref="GenListItem.Previous"/>.
505 /// <since_tizen> preview </since_tizen>
506 public event EventHandler<GenListItemEventArgs> ItemMovedAfter;
509 /// ItemMovedBefore is raised when a genlist item is moved before another item in the reorder mode.
510 /// To get the relative next item, use <see cref="GenListItem.Next"/>.
512 /// <since_tizen> preview </since_tizen>
513 public event EventHandler<GenListItemEventArgs> ItemMovedBefore;
516 /// Changed is raised when the genlist has changed.
518 /// <since_tizen> preview </since_tizen>
519 public event EventHandler Changed
521 add { _changed.On += value; }
522 remove { _changed.On -= value; }
526 /// ScrollAnimationStarted is raised when the scrolling animation has started.
528 /// <since_tizen> preview </since_tizen>
529 public event EventHandler ScrollAnimationStarted
531 add { _scrollAnimationStarted.On += value; }
532 remove { _scrollAnimationStarted.On -= value; }
536 /// ScrollAnimationStopped is raised when the scrolling animation has stopped.
538 /// <since_tizen> preview </since_tizen>
539 public event EventHandler ScrollAnimationStopped
541 add { _scrollAnimationStopped.On += value; }
542 remove { _scrollAnimationStopped.On -= value; }
546 /// Appends a new item to the end of a given GenList widget.
548 /// <param name="itemClass">The itemClass defines how to display the data.</param>
549 /// <param name="data">The item data.</param>
550 /// <returns>Return a newly added genlist item that contains the data and itemClass.</returns>
551 /// <seealso cref="GenItemClass"/>
552 /// <seealso cref="GenListItem"/>
553 /// <since_tizen> preview </since_tizen>
554 public GenListItem Append(GenItemClass itemClass, object data)
556 return Append(itemClass, data, GenListItemType.Normal);
560 /// Appends a new item with <see cref="GenListItemType"/> to the end of a given GenList widget.
562 /// <param name="itemClass">The itemClass defines how to display the data.</param>
563 /// <param name="data">The item data.</param>
564 /// <param name="type">The genlist item type.</param>
565 /// <returns>Return a newly added genlist item that contains the data and itemClass.</returns>
566 /// <since_tizen> preview </since_tizen>
567 public GenListItem Append(GenItemClass itemClass, object data, GenListItemType type)
569 return Append(itemClass, data, type, null);
573 /// Appends a new item with <see cref="GenListItemType"/> to the end of a given GenList widget or the end of the children list, if the parent is given.
575 /// <param name="itemClass">The itemClass defines how to display the data.</param>
576 /// <param name="data">The item data.</param>
577 /// <param name="type">The genlist item type.</param>
578 /// <param name="parent">The parent item, otherwise null if there is no parent item.</param>
579 /// <returns>Return a newly added genlist item that contains the data and itemClass.</returns>
580 /// <since_tizen> preview </since_tizen>
581 public GenListItem Append(GenItemClass itemClass, object data, GenListItemType type, GenListItem parent)
583 GenListItem item = new GenListItem(data, itemClass, this);
584 item.Handle = Interop.Elementary.elm_genlist_item_append(RealHandle, itemClass.UnmanagedPtr, (IntPtr)item.Id, parent, (int)type, null, (IntPtr)item.Id);
590 /// Prepends a new item to the beginning of a given GenList widget.
592 /// <param name="itemClass">The itemClass defines how to display the data.</param>
593 /// <param name="data">The item data.</param>
594 /// <returns>Return a newly added genlist item that contains data and itemClass.</returns>
595 /// <since_tizen> preview </since_tizen>
596 public GenListItem Prepend(GenItemClass itemClass, object data)
598 return Prepend(itemClass, data, GenListItemType.Normal);
602 /// Prepends a new item with <see cref="GenListItemType"/> to the beginning of a given genlist widget.
604 /// <param name="itemClass">The itemClass defines how to display the data.</param>
605 /// <param name="data">The item data.</param>
606 /// <param name="type">The genlist item type.</param>
607 /// <returns>Return a newly added genlist item that contains data and itemClass.</returns>
608 /// <since_tizen> preview </since_tizen>
609 public GenListItem Prepend(GenItemClass itemClass, object data, GenListItemType type)
611 return Prepend(itemClass, data, type, null);
615 /// Prepends a new item with <see cref="GenListItemType"/> to the beginning of a given GenList widget or the beginning of the children list, if the parent is given.
617 /// <param name="itemClass">The itemClass defines how to display the data.</param>
618 /// <param name="data">The item data.</param>
619 /// <param name="type">The genlist item type.</param>
620 /// <param name="parent">The parent item, otherwise null if there is no parent item.</param>
621 /// <returns>Return a newly added genlist item that contains the data and itemClass.</returns>
622 /// <since_tizen> preview </since_tizen>
623 public GenListItem Prepend(GenItemClass itemClass, object data, GenListItemType type, GenListItem parent)
625 GenListItem item = new GenListItem(data, itemClass, this);
626 item.Handle = Interop.Elementary.elm_genlist_item_prepend(RealHandle, itemClass.UnmanagedPtr, (IntPtr)item.Id, parent, (int)type, null, (IntPtr)item.Id);
632 /// Inserts an item before another item in a genlist widget.
633 /// It is the same tree level or group as the item before which it is inserted.????
635 /// <param name="itemClass">The itemClass defines how to display the data.</param>
636 /// <param name="data">The item data.</param>
637 /// <param name="before">The item before which to place this new one.</param>
638 /// <returns>Return a newly added genlist item that contains data and itemClass.</returns>
639 /// <since_tizen> preview </since_tizen>
640 public GenListItem InsertBefore(GenItemClass itemClass, object data, GenListItem before)
642 return InsertBefore(itemClass, data, before, GenListItemType.Normal);
646 /// Inserts an item with <see cref="GenListItemType"/> before another item in a GenList widget.
647 /// It is the same tree level or group as the item before which it is inserted.
649 /// <param name="itemClass">The itemClass defines how to display the data.</param>
650 /// <param name="data">The item data.</param>
651 /// <param name="before">The item before which to place this new one.</param>
652 /// <param name="type">The genlist item type.</param>
653 /// <returns>Return a newly added genlist item that contains data and itemClass.</returns>
654 /// <since_tizen> preview </since_tizen>
655 public GenListItem InsertBefore(GenItemClass itemClass, object data, GenListItem before, GenListItemType type)
657 return InsertBefore(itemClass, data, before, type, null);
661 /// Inserts an item with <see cref="GenListItemType"/> before another item under a parent in a GenList widget.
663 /// <param name="itemClass">The itemClass defines how to display the data.</param>
664 /// <param name="data">The item data.</param>
665 /// <param name="before">The item before which to place this new one.</param>
666 /// <param name="type">The genlist item type.</param>
667 /// <param name="parent">The parent item, otherwise null if there is no parent item.</param>
668 /// <returns>Return a newly added genlist item that contains data and itemClass.</returns>
669 /// <since_tizen> preview </since_tizen>
670 public GenListItem InsertBefore(GenItemClass itemClass, object data, GenListItem before, GenListItemType type, GenListItem parent)
672 GenListItem item = new GenListItem(data, itemClass, this);
673 // insert before the `before` list item
674 item.Handle = Interop.Elementary.elm_genlist_item_insert_before(
675 RealHandle, // genlist handle
676 itemClass.UnmanagedPtr, // item class
677 (IntPtr)item.Id, // data
680 (int)type, // item type
681 null, // select callback
682 (IntPtr)item.Id); // callback data
688 /// Inserts an item with <see cref="GenListItemType"/> after another item under a parent in a GenList widget.
690 /// <param name="itemClass">The itemClass defines how to display the data.</param>
691 /// <param name="data">The item data.</param>
692 /// <param name="after">The item after which to place this new one.</param>
693 /// <param name="type">The genlist item type.</param>
694 /// <param name="parent">The parent item, otherwise null if there is no parent item.</param>
695 /// <returns>Return a newly added genlist item that contains data and itemClass.</returns>
696 /// <since_tizen> preview </since_tizen>
697 public GenListItem InsertAfter(GenItemClass itemClass, object data, GenListItem after, GenListItemType type, GenListItem parent)
699 GenListItem item = new GenListItem(data, itemClass, this);
700 // insert before the `before` list item
701 item.Handle = Interop.Elementary.elm_genlist_item_insert_before(
702 RealHandle, // genlist handle
703 itemClass.UnmanagedPtr, // item class
704 (IntPtr)item.Id, // data
707 (int)type, // item type
708 null, // select callback
709 (IntPtr)item.Id); // callback data
715 /// Inserts an item in a GenList widget using a user-defined sort function.
717 /// <param name="itemClass">The itemClass defines how to display the data.</param>
718 /// <param name="data">The item data.</param>
719 /// <param name="comparison">User-defined comparison function that defines the sort order based on the genlist item and its data.</param>
720 /// <param name="type">The genlist item type.</param>
721 /// <param name="parent">The parent item, otherwise null if there is no parent item.</param>
722 /// <returns>Return a genlist item that contains the data and itemClass.</returns>
723 /// <since_tizen> preview </since_tizen>
724 public GenListItem InsertSorted(GenItemClass itemClass, object data, Comparison<object> comparison, GenListItemType type, GenListItem parent)
726 GenListItem item = new GenListItem(data, itemClass, this);
728 Interop.Elementary.Eina_Compare_Cb compareCallback = (handle1, handle2) =>
730 GenListItem first = (ItemObject.GetItemByHandle(handle1) as GenListItem) ?? item;
731 GenListItem second = (ItemObject.GetItemByHandle(handle2) as GenListItem) ?? item;
732 return comparison(first.Data, second.Data);
735 item.Handle = Interop.Elementary.elm_genlist_item_sorted_insert(
736 RealHandle, // genlist handle
737 itemClass.UnmanagedPtr, // item clas
738 (IntPtr)item.Id, // data
740 (int)type, // item type
741 compareCallback, // compare callback
742 null, //select callback
743 (IntPtr)item.Id); // callback data
749 /// Shows the given item with the position type in a genlist.
750 /// When animated is true, the genlist will jump to the given item and display it (by animatedly scrolling), if it is not fully visible. This may use animation and take sometime.
751 /// When animated is false, the genlist will jump to the given item and display it (by jumping to that position), if it is not fully visible.
753 /// <param name="item">The item to display.</param>
754 /// <param name="position">The position to show the given item to <see cref="ScrollToPosition"/>.</param>
755 /// <param name="animated">The animated indicates how to display the item, by scrolling or by jumping.</param>
756 /// <since_tizen> preview </since_tizen>
757 public void ScrollTo(GenListItem item, ScrollToPosition position, bool animated)
761 Interop.Elementary.elm_genlist_item_bring_in(item.Handle, (Interop.Elementary.Elm_Genlist_Item_Scrollto_Type)position);
765 Interop.Elementary.elm_genlist_item_show(item.Handle, (Interop.Elementary.Elm_Genlist_Item_Scrollto_Type)position);
770 /// Updates the content of all the realized items.
771 /// This updates all the realized items by calling all <see cref="GenItemClass"/> again to get the content, text, and states.
772 /// Use this when the original item data has changed and the changes are desired to reflect.
773 /// To update just one item, use <see cref="GenListItem.Update"/>.
775 /// <seealso cref="GenListItem.Update"/>
776 /// <since_tizen> preview </since_tizen>
777 public void UpdateRealizedItems()
779 Interop.Elementary.elm_genlist_realized_items_update(RealHandle);
783 /// Removes all the items from a given genlist widget.
784 /// This removes (and deletes) all items in the object, making it empty.
785 /// To delete just one item, use <see cref="ItemObject.Delete"/>.
787 /// <seealso cref="ItemObject.Delete"/>
788 /// <since_tizen> preview </since_tizen>
791 Interop.Elementary.elm_genlist_clear(RealHandle);
795 /// Gets the item that is at the X, Y canvas coordinates.
797 /// <param name="x">The input X-coordinate.</param>
798 /// <param name="y">The input Y-coordinate.</param>
799 /// <param name="pos">The position relative to the item returned here.
800 /// -1, 0, or 1 depending on whether the coordinate is on the upper portion of that item (-1), in the middle section (0), or on the lower part (1).
802 /// <returns>The item at the given coordinates.</returns>
803 /// <since_tizen> preview </since_tizen>
804 public GenListItem GetItemByPosition(int x, int y, out int pos)
806 IntPtr handle = Interop.Elementary.elm_genlist_at_xy_item_get(RealHandle, x, y, out pos);
807 return ItemObject.GetItemByHandle(handle) as GenListItem;
811 /// Gets the nth item in a given genlist widget, placed at position nth, in its internal items list.
813 /// <param name="index">The number of the item to grab (0 being the first).</param>
814 /// <returns></returns>
815 /// <since_tizen> preview </since_tizen>
816 public GenListItem GetItemByIndex(int index)
818 IntPtr handle = Interop.Elementary.elm_genlist_nth_item_get(RealHandle, index);
819 return ItemObject.GetItemByHandle(handle) as GenListItem;
823 /// The callback of the Unrealized event.
825 /// <since_tizen> preview </since_tizen>
826 protected override void OnRealized()
829 ListMode = GenListMode.Compress;
830 InitializeSmartEvent();
834 /// Creates a widget handle.
836 /// <param name="parent">Parent EvasObject.</param>
837 /// <returns>Handle IntPtr.</returns>
838 /// <since_tizen> preview </since_tizen>
839 protected override IntPtr CreateHandle(EvasObject parent)
841 IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle);
842 Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default");
844 RealHandle = Interop.Elementary.elm_genlist_add(handle);
845 Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);
850 void InitializeSmartEvent()
852 _selected = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "selected", GenListItemEventArgs.CreateFromSmartEvent);
853 _unselected = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "unselected", GenListItemEventArgs.CreateFromSmartEvent);
854 _activated = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "activated", GenListItemEventArgs.CreateFromSmartEvent);
855 _pressed = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "pressed", GenListItemEventArgs.CreateFromSmartEvent);
856 _released = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "released", GenListItemEventArgs.CreateFromSmartEvent);
857 _doubleClicked = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "clicked,double", GenListItemEventArgs.CreateFromSmartEvent);
858 _expanded = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "expanded", GenListItemEventArgs.CreateFromSmartEvent);
859 _realized = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "realized", GenListItemEventArgs.CreateFromSmartEvent);
860 _unrealized = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "unrealized", GenListItemEventArgs.CreateFromSmartEvent);
861 _longpressed = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "longpressed", GenListItemEventArgs.CreateFromSmartEvent);
862 _moved = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "moved", GenListItemEventArgs.CreateFromSmartEvent);
863 _movedAfter = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "moved,after", GenListItemEventArgs.CreateFromSmartEvent);
864 _movedBefore = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "moved,before", GenListItemEventArgs.CreateFromSmartEvent);
865 _scrollAnimationStarted = new SmartEvent(this, this.RealHandle, "scroll,anim,start");
866 _scrollAnimationStopped = new SmartEvent(this, this.RealHandle, "scroll,anim,stop");
867 _changed = new SmartEvent(this, this.RealHandle, "changed");
869 _selected.On += (s, e) => { if (e.Item != null) ItemSelected?.Invoke(this, e); };
870 _unselected.On += (s, e) => { if (e.Item != null) ItemUnselected?.Invoke(this, e); };
871 _activated.On += (s, e) => { if (e.Item != null) ItemActivated?.Invoke(this, e); };
872 _pressed.On += (s, e) => { if (e.Item != null) ItemPressed?.Invoke(this, e); };
873 _released.On += (s, e) => { if (e.Item != null) ItemReleased?.Invoke(this, e); };
874 _doubleClicked.On += (s, e) => { if (e.Item != null) ItemDoubleClicked?.Invoke(this, e); };
875 _expanded.On += (s, e) => { if (e.Item != null) ItemExpanded?.Invoke(this, e); };
876 _realized.On += (s, e) => { if (e.Item != null) ItemRealized?.Invoke(this, e); };
877 _unrealized.On += (s, e) => { if (e.Item != null) ItemUnrealized?.Invoke(this, e); };
878 _longpressed.On += (s, e) => { if (e.Item != null) ItemLongPressed?.Invoke(this, e); };
879 _moved.On += (s, e) => { if (e.Item != null) ItemMoved?.Invoke(this, e); };
880 _movedAfter.On += (s, e) => { if (e.Item != null) ItemMovedAfter?.Invoke(this, e); };
881 _movedBefore.On += (s, e) => { if (e.Item != null) ItemMovedBefore?.Invoke(this, e); };
884 void AddInternal(GenListItem item)
887 item.Deleted += Item_Deleted;
890 void Item_Deleted(object sender, EventArgs e)
892 _children.Remove((GenListItem)sender);