/* * 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 { /// /// The Index widget gives you an index for fast access to whichever group of the other UI items one might have. /// Inherits Layout. /// /// preview [Obsolete("This has been deprecated in API12")] public class Index : Layout { HashSet _children = new HashSet(); SmartEvent _delayedChanged; /// /// Creates and initializes a new instance of the Index class. /// /// The parent is a given container, which will be attached by Index as a child. It's type. /// preview [Obsolete("This has been deprecated in API12")] public Index(EvasObject parent) : base(parent) { _delayedChanged = new SmartEvent(this, this.RealHandle, "delay,changed"); _delayedChanged.On += _delayedChanged_On; } /// /// Changed will be triggered when the selected index item is changed. /// /// preview [Obsolete("This has been deprecated in API12")] public event EventHandler Changed; /// /// Sets or gets whether the auto hiding feature is enabled or not for a given index widget. /// /// preview [Obsolete("This has been deprecated in API12")] public bool AutoHide { get { return !Interop.Elementary.elm_index_autohide_disabled_get(RealHandle); } set { Interop.Elementary.elm_index_autohide_disabled_set(RealHandle, !value); } } /// /// Sets or gets a value whether the horizontal mode is enabled or not. /// /// preview [Obsolete("This has been deprecated in API12")] public bool IsHorizontal { get { return Interop.Elementary.elm_index_horizontal_get(RealHandle); } set { Interop.Elementary.elm_index_horizontal_set(RealHandle, value); } } /// /// Sets or gets a value of the indicator's disabled status. /// /// preview [Obsolete("This has been deprecated in API12")] public bool IndicatorVisible { get { return !Interop.Elementary.elm_index_indicator_disabled_get(RealHandle); } set { Interop.Elementary.elm_index_indicator_disabled_set(RealHandle, !value); } } /// /// Sets or gets whether the omit feature is enabled or not for a given index widget. /// /// preview [Obsolete("This has been deprecated in API12")] public bool OmitEnabled { get { return Interop.Elementary.elm_index_omit_enabled_get(RealHandle); } set { Interop.Elementary.elm_index_omit_enabled_set(RealHandle, value); } } /// /// Sets a delay change time for the index object. /// The delay time is 0.2 seconds by default. /// /// preview [Obsolete("This has been deprecated in API12")] public double Delay { get { return Interop.Elementary.elm_index_delay_change_time_get(RealHandle); } set { Interop.Elementary.elm_index_delay_change_time_set(RealHandle, value); } } /// /// Gets or sets the items level for a given index widget. /// /// preview [Obsolete("This has been deprecated in API12")] public int Level { get { return Interop.Elementary.elm_index_item_level_get(RealHandle); } set { Interop.Elementary.elm_index_item_level_set(RealHandle, value); } } /// /// Controls the standard_priority group of the index. /// Priority group will be shown as many items as it can, and other group will be shown for one character only. /// /// preview [Obsolete("This has been deprecated in API12")] public int Priority { get { return Interop.Elementary.elm_index_standard_priority_get(RealHandle); } set { Interop.Elementary.elm_index_standard_priority_set(RealHandle, value); } } /// /// Gets the last selected item for a given index widget. /// /// preview [Obsolete("This has been deprecated in API12")] public IndexItem SelectedItem { get { IntPtr handle = Interop.Elementary.elm_index_selected_item_get(RealHandle, 0); return ItemObject.GetItemByHandle(handle) as IndexItem; } } /// /// Appends a new item on a given index widget. /// /// The label for which the item should be indexed. /// An object to the IndexItem if added, or null on errors. /// preview [Obsolete("This has been deprecated in API12")] public IndexItem Append(string label) { IndexItem item = new IndexItem(label, this); item.Handle = Interop.Elementary.elm_index_item_append(RealHandle, label, null, (IntPtr)item.Id); return item; } /// /// Prepends a new item on a given index widget. /// /// The label for which the item should be indexed. /// A handle to the item if added, or null on errors. /// preview [Obsolete("This has been deprecated in API12")] public IndexItem Prepend(string label) { IndexItem item = new IndexItem(label, this); item.Handle = Interop.Elementary.elm_index_item_prepend(RealHandle, label, null, (IntPtr)item.Id); return item; } /// /// Inserts a new item into the index object before the item before. /// /// The label for which the item should be indexed. /// The index item to insert after. /// An object to the IndexItem if added, or null on errors. /// preview [Obsolete("This has been deprecated in API12")] public IndexItem InsertBefore(string label, IndexItem before) { IndexItem item = new IndexItem(label, this); item.Handle = Interop.Elementary.elm_index_item_insert_before(RealHandle, before, label, null, (IntPtr)item.Id); return item; } /// /// Inserts a new item into the index object after the item after. /// /// The label for which the item should be indexed. /// The index item to insert after. /// An object to the IndexItem if added, or null on errors. /// preview [Obsolete("This has been deprecated in API12")] public IndexItem InsertAfter(string label, IndexItem after) { IndexItem item = new IndexItem(label, this); item.Handle = Interop.Elementary.elm_index_item_insert_after(RealHandle, after, label, null, (IntPtr)item.Id); return item; } /// /// Flushes the changes made to the index items so that they work correctly. /// /// The index level (one of 0 or 1) where the changes were made. /// preview [Obsolete("This has been deprecated in API12")] public void Update(int level) { Interop.Elementary.elm_index_level_go(RealHandle, level); } /// /// Removes all the items from a given index widget. /// /// preview [Obsolete("This has been deprecated in API12")] public void Clear() { Interop.Elementary.elm_index_item_clear(RealHandle); } /// /// 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_index_add(handle); Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle); return handle; } void _delayedChanged_On(object sender, EventArgs e) { SelectedItem?.SendSelected(); Changed?.Invoke(this, e); } } }