Merge "[NUI] Setting since_tizen 3/4 on Tizen.NUI API" into rel/api_4
[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     /// <since_tizen> preview </since_tizen>
25     public class ToolbarItem : ItemObject
26     {
27         string _icon;
28         string _text;
29         internal ToolbarItem(string text, string icon) : base(IntPtr.Zero)
30         {
31             _text = text;
32             _icon = icon;
33         }
34
35         /// <summary>
36         /// Sets or gets the icon path of the item.
37         /// </summary>
38         /// <since_tizen> preview </since_tizen>
39         public string Icon
40         {
41             get
42             {
43                 return _icon;
44             }
45             set
46             {
47                 _icon = value;
48                 Interop.Elementary.elm_toolbar_item_icon_set(Handle, value);
49             }
50         }
51
52         /// <summary>
53         /// Sets or gets the text string of the item.
54         /// </summary>
55         /// <since_tizen> preview </since_tizen>
56         public string Text
57         {
58             get
59             {
60                 return _text;
61             }
62             set
63             {
64                 _text = value;
65                 SetPartText(null, value);
66             }
67         }
68
69         /// <summary>
70         /// Sets or gets the enable of the item.
71         /// </summary>
72         /// <since_tizen> preview </since_tizen>
73         [Obsolete("Enabled is obsolete as of version v1.1.0-beta-023. Please use IsEnabled instead.")]
74         public bool Enabled
75         {
76             get
77             {
78                 return IsEnabled;
79             }
80             set
81             {
82                 IsEnabled = value;
83             }
84         }
85
86         /// <summary>
87         /// Sets or gets whether displaying the item as a separator.
88         /// </summary>
89         /// <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>
90         /// <since_tizen> preview </since_tizen>
91         public bool IsSeparator
92         {
93             get
94             {
95                 return Interop.Elementary.elm_toolbar_item_separator_get(Handle);
96             }
97             set
98             {
99                 Interop.Elementary.elm_toolbar_item_separator_set(Handle, value);
100             }
101         }
102
103         /// <summary>
104         /// Sets or gets whether the item is selected.
105         /// </summary>
106         /// <since_tizen> preview </since_tizen>
107         public bool IsSelected
108         {
109             get
110             {
111                 return Interop.Elementary.elm_toolbar_item_selected_get(Handle);
112             }
113             set
114             {
115                 Interop.Elementary.elm_toolbar_item_selected_set(Handle, value);
116             }
117         }
118
119         /// <summary>
120         /// Selected will be triggered when the item is selected.
121         /// </summary>
122         /// <since_tizen> preview </since_tizen>
123         public event EventHandler Selected;
124
125         /// <summary>
126         /// LongPressed will be triggered when the item is pressed long time.
127         /// </summary>
128         /// <since_tizen> preview </since_tizen>
129         public event EventHandler LongPressed;
130
131         /// <summary>
132         /// Clicked will be triggered when the item is clicked.
133         /// </summary>
134         /// <since_tizen> preview </since_tizen>
135         public event EventHandler Clicked;
136
137         internal void SendSelected()
138         {
139             Selected?.Invoke(this, EventArgs.Empty);
140         }
141         internal void SendLongPressed()
142         {
143             LongPressed?.Invoke(this, EventArgs.Empty);
144         }
145         internal void SendClicked()
146         {
147             Clicked?.Invoke(this, EventArgs.Empty);
148         }
149     }
150 }