Change EvasObject's API visibility to protected from internal.
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / Index.cs
1 using System;
2 using System.Collections.Generic;
3
4 namespace ElmSharp
5 {
6     public class Index : Layout
7     {
8         HashSet<IndexItem> _children = new HashSet<IndexItem>();
9         Interop.SmartEvent _delayedChanged;
10
11         public Index(EvasObject parent) : base(parent)
12         {
13             _delayedChanged = new Interop.SmartEvent(this, Handle, "delay,changed");
14             _delayedChanged.On += _delayedChanged_On;
15         }
16
17         public event EventHandler Changed;
18
19         public bool AutoHide
20         {
21             get
22             {
23                 return !Interop.Elementary.elm_index_autohide_disabled_get(Handle);
24             }
25             set
26             {
27                 Interop.Elementary.elm_index_autohide_disabled_set(Handle, !value);
28             }
29         }
30
31         public bool IsHorizontal
32         {
33             get
34             {
35                 return Interop.Elementary.elm_index_horizontal_get(Handle);
36             }
37             set
38             {
39                 Interop.Elementary.elm_index_horizontal_set(Handle, value);
40             }
41         }
42
43         public bool IndicatorVisible
44         {
45             get
46             {
47                 return !Interop.Elementary.elm_index_indicator_disabled_get(Handle);
48             }
49             set
50             {
51                 Interop.Elementary.elm_index_indicator_disabled_set(Handle, !value);
52             }
53         }
54
55         public bool OmitEnabled
56         {
57             get
58             {
59                 return Interop.Elementary.elm_index_omit_enabled_get(Handle);
60             }
61             set
62             {
63                 Interop.Elementary.elm_index_omit_enabled_set(Handle, value);
64             }
65         }
66
67         public IndexItem SelectedItem
68         {
69             get
70             {
71                 IntPtr handle = Interop.Elementary.elm_index_selected_item_get(Handle, 0);
72                 return ItemObject.GetItemByHandle(handle) as IndexItem;
73             }
74         }
75
76         public IndexItem Append(string label)
77         {
78             IndexItem item = new IndexItem(label);
79             item.Handle = Interop.Elementary.elm_index_item_append(Handle, label, null, (IntPtr)item.Id);
80             return item;
81         }
82
83         public IndexItem Prepend(string label)
84         {
85             IndexItem item = new IndexItem(label);
86             item.Handle = Interop.Elementary.elm_index_item_prepend(Handle, label, null, (IntPtr)item.Id);
87             return item;
88         }
89
90         public IndexItem InsertBefore(string label, IndexItem before)
91         {
92             IndexItem item = new IndexItem(label);
93             item.Handle = Interop.Elementary.elm_index_item_insert_before(Handle, before, label, null, (IntPtr)item.Id);
94             return item;
95         }
96
97         public void Update(int level)
98         {
99             Interop.Elementary.elm_index_level_go(Handle, level);
100         }
101
102         protected override IntPtr CreateHandle(EvasObject parent)
103         {
104             return Interop.Elementary.elm_index_add(parent);
105         }
106
107         void _delayedChanged_On(object sender, EventArgs e)
108         {
109             SelectedItem?.SendSelected();
110             Changed?.Invoke(this, e);
111         }
112
113         void AddInternal(IndexItem item)
114         {
115             _children.Add(item);
116             item.Deleted += Item_Deleted;
117         }
118
119         void Item_Deleted(object sender, EventArgs e)
120         {
121             _children.Remove((IndexItem)sender);
122         }
123     }
124 }