Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / ToolbarItem.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 using System;
18
19 namespace ElmSharp
20 {
21     /// <summary>
22     /// The ToolbarItem is a item of Toolbar.
23     /// </summary>
24     public class ToolbarItem : ItemObject
25     {
26         string _icon;
27         string _text;
28         internal ToolbarItem(string text, string icon) : base(IntPtr.Zero)
29         {
30             _text = text;
31             _icon = icon;
32         }
33
34         /// <summary>
35         /// Sets or gets the icon path of the item.
36         /// </summary>
37         public string Icon
38         {
39             get
40             {
41                 return _icon;
42             }
43             set
44             {
45                 _icon = value;
46                 Interop.Elementary.elm_toolbar_item_icon_set(Handle, value);
47             }
48         }
49
50         /// <summary>
51         /// Sets or gets the text string of the item.
52         /// </summary>
53         public string Text
54         {
55             get
56             {
57                 return _text;
58             }
59             set
60             {
61                 _text = value;
62                 SetPartText(null, value);
63             }
64         }
65
66         /// <summary>
67         /// Sets or gets the enable of the item.
68         /// </summary>
69         [Obsolete("Enabled is obsolete as of version v1.1.0-beta-023. Please use IsEnabled instead.")]
70         public bool Enabled
71         {
72             get
73             {
74                 return IsEnabled;
75             }
76             set
77             {
78                 IsEnabled = value;
79             }
80         }
81
82         /// <summary>
83         /// Sets or gets whether displaying the item as a separator.
84         /// </summary>
85         /// <remarks>Items aren't set as a separator by default. If set as a separator it displays a separator theme, so it won't display icons or labels.</remarks>
86         public bool IsSeparator
87         {
88             get
89             {
90                 return Interop.Elementary.elm_toolbar_item_separator_get(Handle);
91             }
92             set
93             {
94                 Interop.Elementary.elm_toolbar_item_separator_set(Handle, value);
95             }
96         }
97
98         /// <summary>
99         /// Sets or gets whether the item is selected.
100         /// </summary>
101         public bool IsSelected
102         {
103             get
104             {
105                 return Interop.Elementary.elm_toolbar_item_selected_get(Handle);
106             }
107             set
108             {
109                 Interop.Elementary.elm_toolbar_item_selected_set(Handle, value);
110             }
111         }
112
113         /// <summary>
114         /// Selected will be triggered when the item is selected.
115         /// </summary>
116         public event EventHandler Selected;
117
118         /// <summary>
119         /// LongPressed will be triggered when the item is pressed long time.
120         /// </summary>
121         public event EventHandler LongPressed;
122
123         /// <summary>
124         /// Clicked will be triggered when the item is clicked.
125         /// </summary>
126         public event EventHandler Clicked;
127
128         internal void SendSelected()
129         {
130             Selected?.Invoke(this, EventArgs.Empty);
131         }
132         internal void SendLongPressed()
133         {
134             LongPressed?.Invoke(this, EventArgs.Empty);
135         }
136         internal void SendClicked()
137         {
138             Clicked?.Invoke(this, EventArgs.Empty);
139         }
140     }
141 }