/* * 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 { /// /// Enumeration for the selection mode of the toolbar. /// /// preview [Obsolete("This has been deprecated in API12")] public enum ToolbarSelectionMode { /// /// Default select mode. /// Default = 0, /// /// Always select mode. /// Always, /// /// No select mode. /// None, /// /// No select mode with no finger size rule. /// DisplayOnly, } /// /// Enumeration for setting the toolbar items display behavior, it can be scrollable, can show a menu with exceeding items, or simply hide them. /// /// preview [Obsolete("This has been deprecated in API12")] public enum ToolbarShrinkMode { /// /// Sets the minimum toolbar size to fit all the items. /// None = 0, /// /// Hides exceeding items. /// Hide, /// /// Allows accessing exceeding items through a scroller. /// Scroll, /// /// Inserts a button to popup a menu with exceeding items. /// Menu, /// /// Expands all items according to the size of the toolbar. /// Expand } /// /// Enumeration for the icon lookup order of the toolbar. /// /// preview [Obsolete("This has been deprecated in API12")] public enum ToolbarIconLookupOrder { /// /// Icon lookup order: freedesktop, theme. /// FreedesktopTheme, /// /// Icon lookup order: theme, freedesktop. /// ThemeFreedesktop, /// /// Icon lookup order: freedesktop. /// Freedesktop, /// /// Icon lookup order: theme. /// Theme, } /// /// Event arguments for events of . /// /// /// Inherits EventArgs. /// /// preview [Obsolete("This has been deprecated in API12")] public class ToolbarItemEventArgs : EventArgs { /// /// Gets the ToolbarItem. /// /// preview [Obsolete("This has been deprecated in API12")] public ToolbarItem Item { get; private set; } internal static ToolbarItemEventArgs CreateFromSmartEvent(IntPtr data, IntPtr obj, IntPtr info) { ToolbarItem item = ItemObject.GetItemByHandle(info) as ToolbarItem; return new ToolbarItemEventArgs { Item = item }; } } /// /// The Toolbar is a widget that displays a list of items inside a box. /// /// preview [Obsolete("This has been deprecated in API12")] public class Toolbar : Widget { SmartEvent _clicked; SmartEvent _selected; SmartEvent _longpressed; /// /// Creates and initializes a new instance of the Toolbar class. /// /// /// A EvasObject to which the new Table instance will be attached. /// /// preview [Obsolete("This has been deprecated in API12")] public Toolbar(EvasObject parent) : base(parent) { _selected = new SmartEvent(this, this.RealHandle, "selected", ToolbarItemEventArgs.CreateFromSmartEvent); _selected.On += (s, e) => { if (e.Item != null) { Selected?.Invoke(this, e); e.Item.SendSelected(); } }; _longpressed = new SmartEvent(this, this.RealHandle, "longpressed", ToolbarItemEventArgs.CreateFromSmartEvent); _longpressed.On += (s, e) => { e.Item?.SendLongPressed(); }; _clicked = new SmartEvent(this, this.RealHandle, "clicked", ToolbarItemEventArgs.CreateFromSmartEvent); _clicked.On += (s, e) => { e.Item?.SendClicked(); }; } /// /// Selected will be triggered when toolbar has been selected. /// /// preview [Obsolete("This has been deprecated in API12")] public event EventHandler Selected; /// /// Sets or gets whether the layout of this toolbar is homogeneous. /// /// True for homogeneous, False for no homogeneous. /// preview [Obsolete("This has been deprecated in API12")] public bool Homogeneous { get { return Interop.Elementary.elm_toolbar_homogeneous_get(RealHandle); } set { Interop.Elementary.elm_toolbar_homogeneous_set(RealHandle, value); } } /// /// Sets or gets the slection mode of a given Toolbar widget. /// /// preview [Obsolete("This has been deprecated in API12")] public ToolbarSelectionMode SelectionMode { get { return (ToolbarSelectionMode)Interop.Elementary.elm_toolbar_select_mode_get(RealHandle); } set { Interop.Elementary.elm_toolbar_select_mode_set(RealHandle, (int)value); } } /// /// Sets or gets the shrink mode of a given Toolbar widget. /// /// preview [Obsolete("This has been deprecated in API12")] public ToolbarShrinkMode ShrinkMode { get { return (ToolbarShrinkMode)Interop.Elementary.elm_toolbar_shrink_mode_get(RealHandle); } set { Interop.Elementary.elm_toolbar_shrink_mode_set(RealHandle, (int)value); } } /// /// Sets or gets the toolbar's current orientation. /// /// preview [Obsolete("This has been deprecated in API12")] [EditorBrowsable(EditorBrowsableState.Never)] public bool IsHorizontal { get { return Interop.Elementary.elm_toolbar_horizontal_get(RealHandle); } set { Interop.Elementary.elm_toolbar_horizontal_set(RealHandle, value); } } /// /// Sets or gets the icon lookup order, for toolbar items' icons. /// The default lookup order is ToolbarIocnLookupOrder.ThemeFreedesktop. /// Icons added before calling this function will not be affected. /// /// preview [Obsolete("This has been deprecated in API12")] public ToolbarIconLookupOrder IconLookupOrder { get { return (ToolbarIconLookupOrder)Interop.Elementary.elm_toolbar_icon_order_lookup_get(RealHandle); } set { Interop.Elementary.elm_toolbar_icon_order_lookup_set(RealHandle, (int)value); } } /// /// Sets or gets the icon size of a given toolbar widget. /// Default value is 32 pixels, to be used by toolbar items. /// /// preview [Obsolete("This has been deprecated in API12")] public int IconSize { get { return Interop.Elementary.elm_toolbar_icon_size_get(RealHandle); } set { Interop.Elementary.elm_toolbar_icon_size_set(RealHandle, value); } } /// /// Gets the number of items in a Toolbar widget. /// /// preview [Obsolete("This has been deprecated in API12")] public int ItemsCount { get { return Interop.Elementary.elm_toolbar_items_count(RealHandle); } } /// /// Sets or gets the alignment of the items. /// /// The toolbar items alignment, a float between 0.0 and 1.0. /// preview [Obsolete("This has been deprecated in API12")] public double ItemAlignment { get { return Interop.Elementary.elm_toolbar_align_get(RealHandle); } set { Interop.Elementary.elm_toolbar_align_set(RealHandle, value); } } /// /// Sets or gets the item's transverse expansion of a given Toolbar widget. /// /// /// The transverse expansion of the item, true for on and false for off. /// By default it's false. /// /// preview [Obsolete("This has been deprecated in API12")] public bool TransverseExpansion { get { return Interop.Elementary.elm_toolbar_transverse_expanded_get(RealHandle); } set { Interop.Elementary.elm_toolbar_transverse_expanded_set(RealHandle, value); } } /// /// Appends the ToolbarItem, which just contains label to the toolbar. /// /// The label of the item. /// The new ToolbarItem which is appended to the toolbar. /// /// /// preview [Obsolete("This has been deprecated in API12")] public ToolbarItem Append(string label) { return Append(label, null); } /// /// Appends the ToolbarItem, which contains label and icon to the toolbar. /// /// The label of the item. /// A string with the icon name or the absolute path of an image file. /// The new ToolbarItem which is appended to the toolbar. /// /// /// /// preview [Obsolete("This has been deprecated in API12")] public ToolbarItem Append(string label, string icon) { ToolbarItem item = new ToolbarItem(label, icon, this); item.Handle = Interop.Elementary.elm_toolbar_item_append(RealHandle, icon, label, null, (IntPtr)item.Id); return item; } /// /// Prepends the ToolbarItem, which just contains label to the toolbar. /// /// The label of the item. /// The new ToolbarItem which is prepended to the toolbar. /// /// /// /// preview [Obsolete("This has been deprecated in API12")] public ToolbarItem Prepend(string label) { return Prepend(label, null); } /// /// Prepends the ToolbarItem, which contains label and icon to the toolbar. /// /// The label of the item. /// A string with the icon name or the absolute path of an image file. /// The new which is prepended to the toolbar. /// /// /// /// preview [Obsolete("This has been deprecated in API12")] public ToolbarItem Prepend(string label, string icon) { ToolbarItem item = new ToolbarItem(label, icon, this); item.Handle = Interop.Elementary.elm_toolbar_item_prepend(RealHandle, icon, label, null, (IntPtr)item.Id); return item; } /// /// Inserts a new item which just contains label into the toolbar object before item . /// /// The toolbar item to insert before. /// The label of the item. /// The new which is inserted into the toolbar. /// /// preview [Obsolete("This has been deprecated in API12")] public ToolbarItem InsertBefore(ToolbarItem before, string label) { return InsertBefore(before, label, string.Empty); } /// /// Inserts a new item which contains label and icon into the toolbar object before item . /// /// The toolbar item to insert before. /// The label of the item. /// A string with the icon name or the absolute path of an image file. /// The new which is inserted into the toolbar. /// /// preview [Obsolete("This has been deprecated in API12")] public ToolbarItem InsertBefore(ToolbarItem before, string label, string icon) { ToolbarItem item = new ToolbarItem(label, icon, this); item.Handle = Interop.Elementary.elm_toolbar_item_insert_before(RealHandle, before, icon, label, null, (IntPtr)item.Id); return item; } /// /// Inserts a new item which contains label and icon into the toolbar object after item . /// /// The toolbar item to insert after. /// The label of the item. /// A string with the icon name or the absolute path of an image file. /// The new which is inserted into the toolbar. /// preview [Obsolete("This has been deprecated in API12")] public ToolbarItem InsertAfter(ToolbarItem after, string label, string icon) { ToolbarItem item = new ToolbarItem(label, icon, this); item.Handle = Interop.Elementary.elm_toolbar_item_insert_after(RealHandle, after, icon, label, null, (IntPtr)item.Id); return item; } /// /// Finds the item with that label in the toolbar. /// /// The label of the item. /// The into the toolbar. /// preview [Obsolete("This has been deprecated in API12")] public ToolbarItem FindItemByLabel(string label) { IntPtr handle = Interop.Elementary.elm_toolbar_item_find_by_label(RealHandle, label); return ItemObject.GetItemByHandle(handle) as ToolbarItem; } /// /// Gets the selected ToolbarItemItem of the toolbar. /// /// preview [Obsolete("This has been deprecated in API12")] public ToolbarItem SelectedItem { get { IntPtr handle = Interop.Elementary.elm_toolbar_selected_item_get(RealHandle); return ItemObject.GetItemByHandle(handle) as ToolbarItem; } } /// /// Gets the first ToolbarItemItem of the toolbar. /// /// preview [Obsolete("This has been deprecated in API12")] public ToolbarItem FirstItem { get { IntPtr handle = Interop.Elementary.elm_toolbar_first_item_get(RealHandle); return ItemObject.GetItemByHandle(handle) as ToolbarItem; } } /// /// Gets the last ToolbarItemItem of the toolbar. /// /// preview [Obsolete("This has been deprecated in API12")] public ToolbarItem LastItem { get { IntPtr handle = Interop.Elementary.elm_toolbar_last_item_get(RealHandle); return ItemObject.GetItemByHandle(handle) as ToolbarItem; } } /// /// Creates a widget handle. /// /// Parent EvasObject. /// Handle IntPtr. /// preview [Obsolete("This has been deprecated in API12")] protected override IntPtr CreateHandle(EvasObject parent) { IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle); Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default"); RealHandle = Interop.Elementary.elm_toolbar_add(handle); Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle); return handle; } } }