2 * Copyright (c) 2016 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;
22 public class Index : Layout
24 HashSet<IndexItem> _children = new HashSet<IndexItem>();
25 SmartEvent _delayedChanged;
27 public Index(EvasObject parent) : base(parent)
29 _delayedChanged = new SmartEvent(this, this.RealHandle, "delay,changed");
30 _delayedChanged.On += _delayedChanged_On;
33 public event EventHandler Changed;
39 return !Interop.Elementary.elm_index_autohide_disabled_get(RealHandle);
43 Interop.Elementary.elm_index_autohide_disabled_set(RealHandle, !value);
47 public bool IsHorizontal
51 return Interop.Elementary.elm_index_horizontal_get(RealHandle);
55 Interop.Elementary.elm_index_horizontal_set(RealHandle, value);
59 public bool IndicatorVisible
63 return !Interop.Elementary.elm_index_indicator_disabled_get(RealHandle);
67 Interop.Elementary.elm_index_indicator_disabled_set(RealHandle, !value);
71 public bool OmitEnabled
75 return Interop.Elementary.elm_index_omit_enabled_get(RealHandle);
79 Interop.Elementary.elm_index_omit_enabled_set(RealHandle, value);
83 public IndexItem SelectedItem
87 IntPtr handle = Interop.Elementary.elm_index_selected_item_get(RealHandle, 0);
88 return ItemObject.GetItemByHandle(handle) as IndexItem;
92 public IndexItem Append(string label)
94 IndexItem item = new IndexItem(label);
95 item.Handle = Interop.Elementary.elm_index_item_append(RealHandle, label, null, (IntPtr)item.Id);
99 public IndexItem Prepend(string label)
101 IndexItem item = new IndexItem(label);
102 item.Handle = Interop.Elementary.elm_index_item_prepend(RealHandle, label, null, (IntPtr)item.Id);
106 public IndexItem InsertBefore(string label, IndexItem before)
108 IndexItem item = new IndexItem(label);
109 item.Handle = Interop.Elementary.elm_index_item_insert_before(RealHandle, before, label, null, (IntPtr)item.Id);
113 public void Update(int level)
115 Interop.Elementary.elm_index_level_go(RealHandle, level);
118 protected override IntPtr CreateHandle(EvasObject parent)
120 IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle);
121 Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default");
123 RealHandle = Interop.Elementary.elm_index_add(handle);
124 Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);
129 void _delayedChanged_On(object sender, EventArgs e)
131 SelectedItem?.SendSelected();
132 Changed?.Invoke(this, e);
135 void AddInternal(IndexItem item)
138 item.Deleted += Item_Deleted;
141 void Item_Deleted(object sender, EventArgs e)
143 _children.Remove((IndexItem)sender);