7332e41e191a4fe48128e78efe701e523f0c1016
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / Button.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 Button is a widget that works as a clickable input element to trigger events.
23     /// </summary>
24     /// <since_tizen> preview </since_tizen>
25     [Obsolete("This has been deprecated in API12")]
26     public class Button : Layout
27     {
28         private SmartEvent _clicked;
29         private SmartEvent _repeated;
30         private SmartEvent _pressed;
31         private SmartEvent _released;
32
33         /// <summary>
34         /// Creates and initializes a new instance of the Button class.
35         /// </summary>
36         /// <param name="parent">
37         /// The EvasObject to which the new Button will be attached as a child.
38         /// </param>
39         /// <since_tizen> preview </since_tizen>
40         [Obsolete("This has been deprecated in API12")]
41         public Button(EvasObject parent) : base(parent)
42         {
43             _clicked = new SmartEvent(this, this.RealHandle, "clicked");
44             _repeated = new SmartEvent(this, this.RealHandle, "repeated");
45             _pressed = new SmartEvent(this, this.RealHandle, "pressed");
46             _released = new SmartEvent(this, this.RealHandle, "unpressed");
47
48             _clicked.On += (sender, e) =>
49             {
50                 Clicked?.Invoke(this, EventArgs.Empty);
51             };
52
53             _repeated.On += (sender, e) =>
54             {
55                 Repeated?.Invoke(this, EventArgs.Empty);
56             };
57
58             _pressed.On += (sender, e) =>
59             {
60                 Pressed?.Invoke(this, EventArgs.Empty);
61             };
62
63             _released.On += (sender, e) =>
64             {
65                 Released?.Invoke(this, EventArgs.Empty);
66             };
67         }
68
69         /// <summary>
70         /// Clicked will be triggered when the button is clicked.
71         /// </summary>
72         /// <since_tizen> preview </since_tizen>
73         [Obsolete("This has been deprecated in API12")]
74         public event EventHandler Clicked;
75
76         /// <summary>
77         /// Repeated will be triggered when the button is pressed without releasing it.
78         /// </summary>
79         /// <since_tizen> preview </since_tizen>
80         [Obsolete("This has been deprecated in API12")]
81         public event EventHandler Repeated;
82
83         /// <summary>
84         /// Pressed will be triggered when the button is pressed.
85         /// </summary>
86         /// <since_tizen> preview </since_tizen>
87         [Obsolete("This has been deprecated in API12")]
88         public event EventHandler Pressed;
89
90         /// <summary>
91         /// Released will be triggered when the button is released after being pressed.
92         /// </summary>
93         /// <since_tizen> preview </since_tizen>
94         [Obsolete("This has been deprecated in API12")]
95         public event EventHandler Released;
96
97         /// <summary>
98         /// Sets or gets the autorepeat feature of a given Bbutton.
99         /// </summary>
100         /// <remarks>
101         /// Autorepeat feature means the autorepeat event is generated when the button is kept pressed.
102         /// When set to false, no autorepeat is performed and the buttons will trigger the Clicked event when they are clicked.
103         /// When set to true, keeping a button pressed continuously will trigger the Repeated event until the button is released.
104         /// The time it takes until it starts triggering, repeated is given by AutoRepeatInitialTime,
105         /// and the time between each new emission is given by AutoRepeatGapTimeout.
106         /// </remarks>
107         /// <since_tizen> preview </since_tizen>
108         [Obsolete("This has been deprecated in API12")]
109         public bool AutoRepeat
110         {
111             get
112             {
113                 return Interop.Elementary.elm_button_autorepeat_get(RealHandle);
114             }
115             set
116             {
117                 Interop.Elementary.elm_button_autorepeat_set(RealHandle, value);
118             }
119         }
120
121         /// <summary>
122         /// Sets or gets the initial timeout before the Repeat event is generated.
123         /// </summary>
124         /// <since_tizen> preview </since_tizen>
125         [Obsolete("This has been deprecated in API12")]
126         public double AutoRepeatInitialTime
127         {
128             get
129             {
130                 return Interop.Elementary.elm_button_autorepeat_initial_timeout_get(RealHandle);
131             }
132             set
133             {
134                 Interop.Elementary.elm_button_autorepeat_initial_timeout_set(RealHandle, value);
135             }
136         }
137
138         /// <summary>
139         /// Sets or gets the interval between each generated Repeat event.
140         /// </summary>
141         /// <since_tizen> preview </since_tizen>
142         [Obsolete("This has been deprecated in API12")]
143         public double AutoRepeatGapTimeout
144         {
145             get
146             {
147                 return Interop.Elementary.elm_button_autorepeat_gap_timeout_get(RealHandle);
148             }
149             set
150             {
151                 Interop.Elementary.elm_button_autorepeat_gap_timeout_set(RealHandle, value);
152             }
153         }
154
155         /// <summary>
156         /// Deletes the object Color class.
157         /// </summary>
158         /// <param name="part">The Color class to be deleted.</param>
159         /// <since_tizen> preview </since_tizen>
160         [Obsolete("DeleteColorClass is obsolete, please use EdjeObject.DeleteColorClass(string)")]
161         public void DeleteColorClass(string part)
162         {
163             Interop.Elementary.edje_object_color_class_del(Handle, part);
164         }
165
166         /// <summary>
167         /// Sets or gets the BackgroundColor of a given button in the normal and pressed status.
168         /// </summary>
169         /// <since_tizen> preview </since_tizen>
170         [Obsolete("This has been deprecated in API12")]
171         public override Color BackgroundColor
172         {
173             set
174             {
175                 if (value.IsDefault)
176                 {
177                     EdjeObject.DeleteColorClass("button/bg");
178                     EdjeObject.DeleteColorClass("button/bg_pressed");
179                     EdjeObject.DeleteColorClass("button/bg_disabled");
180                 }
181                 else
182                 {
183                     SetPartColor("bg", value);
184                     SetPartColor("bg_pressed", value);
185                     SetPartColor("bg_disabled", value);
186                 }
187                 _backgroundColor = value;
188             }
189         }
190
191         /// <summary>
192         /// Creates a widget handle.
193         /// </summary>
194         /// <param name="parent">Parent EvasObject.</param>
195         /// <returns>Handle IntPtr.</returns>
196         /// <since_tizen> preview </since_tizen>
197         [Obsolete("This has been deprecated in API12")]
198         protected override IntPtr CreateHandle(EvasObject parent)
199         {
200             return Interop.Elementary.elm_button_add(parent.Handle);
201         }
202     }
203 }