/*
* 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.Collections.Generic;
namespace ElmSharp
{
///
/// It inherits System.EventArgs.
/// It contains Item which is type.
/// All events of GenGrid contain GenGridItemEventArgs as a parameter.
///
public class GenGridItemEventArgs : EventArgs
{
///
/// Gets or sets GenGrid item.The return type is .
///
public GenGridItem Item { get; set; }
internal static GenGridItemEventArgs CreateFromSmartEvent(IntPtr data, IntPtr obj, IntPtr info)
{
GenGridItem item = ItemObject.GetItemByHandle(info) as GenGridItem;
return new GenGridItemEventArgs() { Item = item };
}
}
///
/// It inherits .
/// The GenGrid is a widget that aims to position objects in a grid layout while actually creating and rendering only the visible ones.
/// It has two direction in which a given GenGrid widget expands while placing its items, horizontal and vertical.
/// The GenGrid items are represented through definition field details.
///
public class GenGrid : Layout
{
HashSet _children = new HashSet();
SmartEvent _selected;
SmartEvent _unselected;
SmartEvent _activated;
SmartEvent _pressed;
SmartEvent _released;
SmartEvent _doubleClicked;
SmartEvent _realized;
SmartEvent _unrealized;
SmartEvent _longpressed;
SmartEvent _changed;
///
/// Creates and initializes a new instance of the GenGrid class.
///
/// The parent is a given container which will be attached by GenGrid as a child. It's type.
public GenGrid(EvasObject parent) : base(parent)
{
InitializeSmartEvent();
}
///
/// ItemSelected is raised when a new gengrid item is selected.
///
public event EventHandler ItemSelected;
///
/// ItemUnselected is raised when the gengrid item is Unselected.
///
public event EventHandler ItemUnselected;
///
/// ItemPressed is raised when a new gengrid item is pressed.
///
public event EventHandler ItemPressed;
///
/// ItemReleased is raised when a new gengrid item is released.
///
public event EventHandler ItemReleased;
///
/// ItemActivated is raised when a new gengrid item is double clicked or pressed (enter|return|spacebar).
///
public event EventHandler ItemActivated;
///
/// ItemDoubleClicked is raised when a new gengrid item is double clicked.
///
public event EventHandler ItemDoubleClicked;
///
/// ItemRealized is raised when a gengrid item is implementing through .
///
public event EventHandler ItemRealized;
///
/// ItemUnrealized is raised when the gengrid item is deleted.
///
public event EventHandler ItemUnrealized;
///
/// ItemLongPressed is raised when a gengrid item is pressed for a certain amount of time. By default it's 1 second.
///
public event EventHandler ItemLongPressed;
///
/// Changed is raised when an item is added, removed, resized or moved and when the gengrid is resized or gets "horizontal" property changes.
///
public event EventHandler Changed;
///
/// Gets or sets the item's grid alignment along x-axis within a given gengrid widget.
/// Accepted values are in the 0.0 to 1.0 range, with the special value -1.0 used to specify "justify" or "fill" by some users.
/// By default, value is 0.0, meaning that the gengrid has its items grid placed exactly in the left along x-axis.
///
public double ItemAlignmentX
{
get
{
double align;
Interop.Elementary.elm_gengrid_align_get(RealHandle, out align, IntPtr.Zero);
return align;
}
set
{
double aligny = ItemAlignmentY;
Interop.Elementary.elm_gengrid_align_set(RealHandle, value, aligny);
}
}
///
/// Gets or sets the item's grid alignment on y-axis within a given gengrid widget.
/// Accepted values are in the 0.0 to 1.0 range, with the special value -1.0 used to specify "justify" or "fill" by some users.
/// By default, value is 0.0, meaning that the gengrid has its items grid placed exactly in the top along y-axis.
///
public double ItemAlignmentY
{
get
{
double align;
Interop.Elementary.elm_gengrid_align_get(RealHandle, IntPtr.Zero, out align);
return align;
}
set
{
double alignx = ItemAlignmentX;
Interop.Elementary.elm_gengrid_align_set(RealHandle, alignx, value);
}
}
///
/// Gets or sets the manner in which the items grid is filled within a given gengrid widget.
/// It is filled if true, otherwise false.
///
public bool FillItems
{
get
{
return Interop.Elementary.elm_gengrid_filled_get(RealHandle);
}
set
{
Interop.Elementary.elm_gengrid_filled_set(RealHandle, value);
}
}
///
/// Gets or sets whether multi-selection is enabled or disabled for a given gengrid widget.
///
///
/// Multi-selection is the ability to have more than one item selected, on a given gengrid, simultaneously.
/// When it is enabled, a sequence of clicks on different items makes them all selected, progressively.
/// A click on an already selected item unselects it. If interacting via the keyboard, multi-selection is enabled while holding the "Shift" key.
/// By default, multi-selection is disabled.
///
public bool MultipleSelection
{
get
{
return Interop.Elementary.elm_gengrid_multi_select_get(RealHandle);
}
set
{
Interop.Elementary.elm_gengrid_multi_select_set(RealHandle, value);
}
}
///
/// Gets or sets the width for the items of a given gengrid widget.
///
///
/// A gengrid, after creation, still has no information on the size to give to each of its cells.
/// The default width and height just have one finger wide.
/// Use this property to force a custom width for your items, making them as big as you wish.
///
public int ItemWidth
{
get
{
int width;
Interop.Elementary.elm_gengrid_item_size_get(RealHandle, out width, IntPtr.Zero);
return width;
}
set
{
int height = ItemHeight;
Interop.Elementary.elm_gengrid_item_size_set(RealHandle, value, height);
}
}
///
/// Gets or sets the height for the items of a given gengrid widget.
///
///
/// A gengrid, after creation, still has no information on the size to give to each of its cells.
/// The default width and height just have one finger wide.
/// Use this property to force a custom height for your items, making them as big as you wish.
///
public int ItemHeight
{
get
{
int height;
Interop.Elementary.elm_gengrid_item_size_get(RealHandle, IntPtr.Zero, out height);
return height;
}
set
{
int width = ItemWidth;
Interop.Elementary.elm_gengrid_item_size_set(RealHandle, width, value);
}
}
///
/// Gets or sets the gengrid select mode by .
///
public GenItemSelectionMode SelectionMode
{
get
{
return (GenItemSelectionMode)Interop.Elementary.elm_gengrid_select_mode_get(RealHandle);
}
set
{
Interop.Elementary.elm_gengrid_select_mode_set(RealHandle, (int)value);
}
}
///
/// Gets or sets the direction for which a given gengrid widget expands while placing its items.
///
///
/// If true, items are placed in columns from top to bottom and when the space for a column is filled, another one is started on the right, thus expanding the grid horizontally.
/// If false, items are placed in rows from left to right, and when the space for a row is filled, another one is started below, thus expanding the grid vertically.
///
public bool IsHorizontal
{
get
{
return Interop.Elementary.elm_gengrid_horizontal_get(RealHandle);
}
set
{
Interop.Elementary.elm_gengrid_horizontal_set(RealHandle, value);
}
}
///
/// Gets or sets whether the gengrid items should be highlighted when an item is selected.
///
public bool IsHighlight
{
get
{
return Interop.Elementary.elm_gengrid_highlight_mode_get(RealHandle);
}
set
{
Interop.Elementary.elm_gengrid_highlight_mode_set(RealHandle, value);
}
}
///
/// Sets or gets the value of HorizontalScrollBarVisiblePolicy
///
///
/// ScrollBarVisiblePolicy.Auto means the horizontal scrollbar is made visible if it is needed, and otherwise kept hidden.
/// ScrollBarVisiblePolicy.Visible turns it on all the time, and ScrollBarVisiblePolicy.Invisible always keeps it off.
///
public ScrollBarVisiblePolicy HorizontalScrollBarVisiblePolicy
{
get
{
int policy;
Interop.Elementary.elm_scroller_policy_get(RealHandle, out policy, IntPtr.Zero);
return (ScrollBarVisiblePolicy)policy;
}
set
{
ScrollBarVisiblePolicy v = VerticalScrollBarVisiblePolicy;
Interop.Elementary.elm_scroller_policy_set(RealHandle, (int)value, (int)v);
}
}
///
/// Sets or gets the value of VerticalScrollBarVisiblePolicy
///
///
/// ScrollBarVisiblePolicy.Auto means the vertical scrollbar is made visible if it is needed, and otherwise kept hidden.
/// ScrollBarVisiblePolicy.Visible turns it on all the time, and ScrollBarVisiblePolicy.Invisible always keeps it off.
///
public ScrollBarVisiblePolicy VerticalScrollBarVisiblePolicy
{
get
{
int policy;
Interop.Elementary.elm_scroller_policy_get(RealHandle, IntPtr.Zero, out policy);
return (ScrollBarVisiblePolicy)policy;
}
set
{
ScrollBarVisiblePolicy h = HorizontalScrollBarVisiblePolicy;
Interop.Elementary.elm_scroller_policy_set(RealHandle, (int)h, (int)value);
}
}
///
/// Gets the first item in a given gengrid widget.
///
public GenGridItem FirstItem
{
get
{
IntPtr handle = Interop.Elementary.elm_gengrid_first_item_get(RealHandle);
return ItemObject.GetItemByHandle(handle) as GenGridItem;
}
}
///
/// Gets the last item in a given gengrid widget.
///
public GenGridItem LastItem
{
get
{
IntPtr handle = Interop.Elementary.elm_gengrid_last_item_get(RealHandle);
return ItemObject.GetItemByHandle(handle) as GenGridItem;
}
}
///
/// Gets the items count in a given gengrid widget.
///
public uint ItemCount
{
get
{
return Interop.Elementary.elm_gengrid_items_count(RealHandle);
}
}
///
/// Gets the selected item in a given gengrid widget.
///
public GenGridItem SelectedItem
{
get
{
IntPtr handle = Interop.Elementary.elm_gengrid_selected_item_get(RealHandle);
return ItemObject.GetItemByHandle(handle) as GenGridItem;
}
}
///
/// Gets or sets whether a given gengrid widget is or not able have items reordered.
///
public bool ReorderMode
{
get
{
return Interop.Elementary.elm_gengrid_reorder_mode_get(RealHandle);
}
set
{
Interop.Elementary.elm_gengrid_reorder_mode_set(RealHandle, value);
}
}
///
/// Appends a new item to a given gengrid widget. This adds an item to the end of the gengrid.
///
/// The itemClass defines how to display the data.
/// The item data.
/// Return a gengrid item that contains data and itemClass.
///
///
public GenGridItem Append(GenItemClass itemClass, object data)
{
GenGridItem item = new GenGridItem(data, itemClass);
IntPtr handle = Interop.Elementary.elm_gengrid_item_append(RealHandle, itemClass.UnmanagedPtr, (IntPtr)item.Id, null, (IntPtr)item.Id);
item.Handle = handle;
AddInternal(item);
return item;
}
///
/// Prepends a new item to a given gengrid widget. This adds an item to the beginning of the gengrid.
///
/// The itemClass defines how to display the data.
/// The item data.
/// Return a gengrid item that contains data and itemClass.
///
///
public GenGridItem Prepend(GenItemClass itemClass, object data)
{
GenGridItem item = new GenGridItem(data, itemClass);
IntPtr handle = Interop.Elementary.elm_gengrid_item_prepend(RealHandle, itemClass.UnmanagedPtr, (IntPtr)item.Id, null, (IntPtr)item.Id);
item.Handle = handle;
AddInternal(item);
return item;
}
///
/// Inserts an item before another in a gengrid widget. This inserts an item before another in the gengrid.
///
/// The itemClass defines how to display the data.
/// The item data.
/// The item before which to place this new one.
/// Return a gengrid item that contains data and itemClass./>
///
///
public GenGridItem InsertBefore(GenItemClass itemClass, object data, GenGridItem before)
{
GenGridItem item = new GenGridItem(data, itemClass);
IntPtr handle = Interop.Elementary.elm_gengrid_item_insert_before(RealHandle, itemClass.UnmanagedPtr, (IntPtr)item.Id, before, null, (IntPtr)item.Id);
item.Handle = handle;
AddInternal(item);
return item;
}
///
/// Inserts an item before another in a gengrid widget. This inserts an item after another in the gengrid.
///
/// The itemClass defines how to display the data.
/// The item data.
/// The item after which to place this new one.
/// Return a gengrid item that contains data and itemClass.
///
///
public GenGridItem InsertAfter(GenItemClass itemClass, object data, GenGridItem after)
{
GenGridItem item = new GenGridItem(data, itemClass);
IntPtr handle = Interop.Elementary.elm_gengrid_item_insert_after(RealHandle, itemClass.UnmanagedPtr, (IntPtr)item.Id, after, null, (IntPtr)item.Id);
item.Handle = handle;
AddInternal(item);
return item;
}
///
/// Insert an item in a gengrid widget using a user-defined sort function.
///
/// The itemClass defines how to display the data.
/// The item data.
/// User defined comparison function that defines the sort order based on gengrid item and its data.
/// Return a gengrid item that contains data and itemClass.
public GenGridItem InsertSorted(GenItemClass itemClass, object data, Comparison