/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.ComponentModel;
namespace ElmSharp
{
///
/// The type of the item's part types.
///
/// preview
[Flags]
public enum GenListItemFieldType
{
///
/// All item's parts.
///
All = 0,
///
/// The Text part type.
///
Text = (1 << 0),
///
/// The Content part type.
///
Content = (1 << 1),
///
/// The State part type.
///
State = (1 << 2),
///
/// No part type.
///
None = (1 << 3)
};
///
/// It inherits .
/// A instance to the genlist item is added.
/// It contains the Update() method to update a genlist item which is given.
///
/// preview
public class GenListItem : GenItem
{
internal GenListItem(object data, GenItemClass itemClass) : base(data, itemClass)
{
}
internal GenListItem(object data, GenItemClass itemClass, EvasObject parent) : base(data, itemClass, parent)
{
}
///
/// Gets or sets whether a given genlist item is selected.
///
/// preview
public override bool IsSelected
{
get
{
return Interop.Elementary.elm_genlist_item_selected_get(Handle);
}
set
{
Interop.Elementary.elm_genlist_item_selected_set(Handle, value);
}
}
///
/// Gets or sets whether a given genlist item is expanded.
///
/// preview
public bool IsExpanded
{
get
{
return Interop.Elementary.elm_genlist_item_expanded_get(Handle);
}
set
{
Interop.Elementary.elm_genlist_item_expanded_set(Handle, value);
}
}
///
/// Updates the content of an item.
/// This updates an item by calling all again to get the content, text, and states.
/// Use this when the original item data has changed and the changes are desired to reflect.
/// To update the already realized items, use .
///
///
/// preview
public override void Update()
{
Interop.Elementary.elm_genlist_item_update(Handle);
}
///
/// Updates the part of an item.
/// This updates an item's part by calling the item's fetching functions again to get the contents, texts, and states.
/// Use this when the original item data has changed and the changes are desired to be reflected.
/// To update an item's all property, use .
///
/// 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.
/// The type of the item's part type.
///
/// preview
public void UpdateField(string part, GenListItemFieldType type)
{
Interop.Elementary.elm_genlist_item_fields_update(Handle, part, (uint)type);
}
///
/// Demotes an item to the end of the list.
///
/// preview
public void DemoteItem()
{
Interop.Elementary.elm_genlist_item_demote(Handle);
}
///
/// Gets or sets the genlist item's select mode.
///
/// preview
public override GenItemSelectionMode SelectionMode
{
get
{
return (GenItemSelectionMode)Interop.Elementary.elm_genlist_item_select_mode_get(Handle);
}
set
{
Interop.Elementary.elm_genlist_item_select_mode_set(Handle, (Interop.Elementary.Elm_Object_Select_Mode)value);
}
}
///
/// Gets the next item in a genlist widget's internal list of items.
///
///
/// preview
public GenListItem Next
{
get
{
IntPtr next = Interop.Elementary.elm_genlist_item_next_get(Handle);
if (next == IntPtr.Zero)
return null;
else
return GetItemByHandle(next) as GenListItem;
}
}
///
/// Gets the previous item in a genlist widget's internal list of items.
///
///
/// preview
public GenListItem Previous
{
get
{
IntPtr prev = Interop.Elementary.elm_genlist_item_prev_get(Handle);
if (prev == IntPtr.Zero)
return null;
else
return GetItemByHandle(prev) as GenListItem;
}
}
///
/// Sets or gets the content to be shown in the tooltip item.
///
/// preview
[EditorBrowsable(EditorBrowsableState.Never)]
public override string Cursor
{
get
{
return Interop.Elementary.elm_genlist_item_cursor_get(Handle);
}
set
{
if (!string.IsNullOrEmpty(value))
{
Interop.Elementary.elm_genlist_item_cursor_set(Handle, value);
}
else
{
Interop.Elementary.elm_genlist_item_cursor_unset(Handle);
}
}
}
///
/// Sets or gets the style for this item cursor.
///
/// preview
[EditorBrowsable(EditorBrowsableState.Never)]
public override string CursorStyle
{
get
{
return Interop.Elementary.elm_genlist_item_cursor_style_get(Handle);
}
set
{
Interop.Elementary.elm_genlist_item_cursor_style_set(Handle, value);
}
}
///
/// Sets or gets the cursor engine only usage for this item cursor.
///
/// preview
[EditorBrowsable(EditorBrowsableState.Never)]
public override bool IsUseEngineCursor
{
get
{
return Interop.Elementary.elm_genlist_item_cursor_engine_only_get(Handle);
}
set
{
Interop.Elementary.elm_genlist_item_cursor_engine_only_set(Handle, value);
}
}
///
/// Sets the text to be shown in the genlist item.
///
/// The text to set in the content.
/// preview
public override void SetTooltipText(string tooltip)
{
Interop.Elementary.elm_genlist_item_tooltip_text_set(Handle, tooltip);
}
///
/// Unsets the tooltip from the item.
///
/// preview
public override void UnsetTooltip()
{
Interop.Elementary.elm_genlist_item_tooltip_unset(Handle);
}
///
/// Gets or sets the style of the given genlist item's tooltip.
///
/// preview
public override string TooltipStyle
{
get
{
return Interop.Elementary.elm_genlist_item_tooltip_style_get(Handle);
}
set
{
Interop.Elementary.elm_genlist_item_tooltip_style_set(Handle, value);
}
}
///
/// Gets or sets the disable size restrictions on an object's tooltip.
///
/// preview
public bool IsTooltipWindowMode
{
get
{
return Interop.Elementary.elm_genlist_item_tooltip_window_mode_get(Handle);
}
set
{
Interop.Elementary.elm_genlist_item_tooltip_window_mode_set(Handle, value);
}
}
///
/// Gets the index of the item. It is only valid, once displayed.
///
/// preview
public int Index
{
get
{
return Interop.Elementary.elm_genlist_item_index_get(Handle);
}
}
///
/// Gets the depth of the expanded item.
///
/// preview
public int ExpandedItemDepth
{
get
{
return Interop.Elementary.elm_genlist_item_expanded_depth_get(Handle);
}
}
///
/// Remove all the subitems (children) of the given item.
///
///
/// This removes the items that are the children (and their descendants) of the given item.
///
/// preview
public void ClearSubitems()
{
Interop.Elementary.elm_genlist_item_subitems_clear(Handle);
}
///
/// Updates the item class of the item.
/// This sets another class of the item, changing the way that it is displayed. After changing the item class, is called on the item.
///
/// The item class for the item.
/// The data for the item.
/// preview
public void UpdateItemClass(GenItemClass itemClass, object data)
{
Data = data;
ItemClass = itemClass;
Interop.Elementary.elm_genlist_item_item_class_update((IntPtr)Handle, itemClass.UnmanagedPtr);
}
///
/// Sets the content to be shown in the tooltip item.
///
/// preview
protected override void UpdateTooltipDelegate()
{
Interop.Elementary.elm_genlist_item_tooltip_content_cb_set(Handle,
TooltipContentDelegate != null ? _tooltipCb : null,
IntPtr.Zero,
null);
}
}
}