72075dddc7eef3a515d66e47aa498b5565df9bb0
[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     public class ToolbarItem : ItemObject
22     {
23         string _icon;
24         string _text;
25         internal ToolbarItem(string text, string icon) : base(IntPtr.Zero)
26         {
27             _text = text;
28             _icon = icon;
29         }
30
31         public string Icon
32         {
33             get
34             {
35                 return _icon;
36             }
37             set
38             {
39                 _icon = value;
40                 Interop.Elementary.elm_toolbar_item_icon_set(Handle, value);
41             }
42         }
43         public string Text
44         {
45             get
46             {
47                 return _text;
48             }
49             set
50             {
51                 _text = value;
52                 SetPartText(null, value);
53             }
54         }
55         public bool Enabled
56         {
57             get
58             {
59                 return !Interop.Elementary.elm_object_disabled_get(Handle);
60             }
61             set
62             {
63                 Interop.Elementary.elm_object_disabled_set(Handle, !value);
64             }
65         }
66         public bool IsSeparator
67         {
68             get
69             {
70                 return Interop.Elementary.elm_toolbar_item_separator_get(Handle);
71             }
72             set
73             {
74                 Interop.Elementary.elm_toolbar_item_separator_set(Handle, value);
75             }
76         }
77         public bool IsSelected
78         {
79             get
80             {
81                 return Interop.Elementary.elm_toolbar_item_selected_get(Handle);
82             }
83             set
84             {
85                 Interop.Elementary.elm_toolbar_item_selected_set(Handle, value);
86             }
87         }
88
89         public event EventHandler Selected;
90         public event EventHandler LongPressed;
91         public event EventHandler Clicked;
92
93         internal void SendSelected()
94         {
95             Selected?.Invoke(this, EventArgs.Empty);
96         }
97         internal void SendLongPressed()
98         {
99             LongPressed?.Invoke(this, EventArgs.Empty);
100         }
101         internal void SendClicked()
102         {
103             Clicked?.Invoke(this, EventArgs.Empty);
104         }
105     }
106 }