[NUI] Fixing the emtpy finalizers(CA1821)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Key.cs
1 /*
2  * Copyright(c) 2020 Samsung Electronics Co., Ltd.
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
18 using System;
19 using System.ComponentModel;
20
21 namespace Tizen.NUI
22 {
23
24     /// <summary>
25     /// The key structure is used to store a key press.
26     /// </summary>
27     /// <since_tizen> 3 </since_tizen>
28     public class Key : BaseHandle
29     {
30
31         /// <summary>
32         /// The default constructor.
33         /// </summary>
34         /// <since_tizen> 3 </since_tizen>
35         public Key() : this(Interop.Key.New("", "", 0, 0, 0u, 0), true)
36         {
37             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
38         }
39
40         /// <summary>
41         /// The constructor.
42         /// </summary>
43         /// <param name="keyName">The name of the key pressed or command from the IMF, if later, then the following parameters will be needed.</param>
44         /// <param name="keyString">A string of input characters or key pressed.</param>
45         /// <param name="keyCode">The unique key code for the key pressed.</param>
46         /// <param name="keyModifier">The key modifier for special keys like Shift and Alt.</param>
47         /// <param name="timeStamp">The time (in ms) that the key event occurred.</param>
48         /// <param name="keyState">The state of the key event.</param>
49         internal Key(string keyName, string keyString, int keyCode, int keyModifier, uint timeStamp, Key.StateType keyState) : this(Interop.Key.New(keyName, keyString, keyCode, keyModifier, timeStamp, (int)keyState), true)
50         {
51             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
52         }
53
54         internal Key(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Key.Upcast(cPtr), cMemoryOwn)
55         {
56         }
57
58         /// <summary>
59         /// Enumeration for specifying the state of the key event.
60         /// </summary>
61         /// <since_tizen> 3 </since_tizen>
62         public enum StateType
63         {
64             /// <summary>
65             /// Key Down.
66             /// </summary>
67             /// <since_tizen> 3 </since_tizen>
68             Down,
69             /// <summary>
70             /// Key Up.
71             /// </summary>
72             /// <since_tizen> 3 </since_tizen>
73             Up,
74             /// <summary>
75             /// Key Last.
76             /// </summary>
77             /// <since_tizen> 3 </since_tizen>
78             Last
79         }
80
81         /// <summary>
82         /// Device name
83         /// </summary>
84         /// <since_tizen> 3 </since_tizen>
85         public string DeviceName
86         {
87             get
88             {
89                 string ret = Interop.NDalic.GetDeviceName(SwigCPtr);
90                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
91                 return ret;
92             }
93         }
94
95         /// <summary>
96         /// Name given to the key pressed.
97         /// </summary>
98         /// <since_tizen> 3 </since_tizen>
99         public string KeyPressedName
100         {
101             get
102             {
103                 string ret = Interop.Key.KeyPressedNameGet(SwigCPtr);
104                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
105                 return ret;
106             }
107             set
108             {
109                 Interop.Key.KeyPressedNameSet(SwigCPtr, value);
110                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
111             }
112
113         }
114
115         /// <summary>
116         /// Get the logical key string. (eg. shift + 1 == "exclamation")
117         /// </summary>
118         /// <returns>The logical key symbol</returns>
119         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
120         [EditorBrowsable(EditorBrowsableState.Never)]
121         public string LogicalKey
122         {
123             get
124             {
125                 string ret = Interop.Key.LogicalKeyGet(SwigCPtr);
126                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
127                 return ret;
128             }
129         }
130
131         /// <summary>
132         /// Get the actual string returned that should be used for input editors.
133         /// </summary>
134         /// <returns>The key string</returns>
135         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
136         [EditorBrowsable(EditorBrowsableState.Never)]
137         public string KeyPressed
138         {
139             get
140             {
141                 return keyPressed;
142             }
143         }
144
145         /// <summary>
146         /// Get the actual string returned that should be used for input editors.
147         /// </summary>
148         /// <returns>The key string</returns>
149         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
150         [EditorBrowsable(EditorBrowsableState.Never)]
151         public string KeyString
152         {
153             get
154             {
155                 string ret = Interop.Key.KeyStringGet(SwigCPtr);
156                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
157                 return ret;
158             }
159             set
160             {
161                 Interop.Key.KeyStringSet(SwigCPtr, value);
162                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
163             }
164         }
165
166         /// <summary>
167         /// Keycode for the key pressed.
168         /// </summary>
169         /// <since_tizen> 3 </since_tizen>
170         public int KeyCode
171         {
172             get
173             {
174                 int ret = Interop.Key.KeyCodeGet(SwigCPtr);
175                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
176                 return ret;
177             }
178             set
179             {
180                 Interop.Key.KeyCodeSet(SwigCPtr, value);
181                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
182             }
183         }
184
185         /// <summary>
186         /// Special keys like Shift, Alt, and Ctrl which modify the next key pressed.
187         /// </summary>
188         /// <since_tizen> 3 </since_tizen>
189         public int KeyModifier
190         {
191             get
192             {
193                 int ret = Interop.Key.KeyModifierGet(SwigCPtr);
194                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
195                 return ret;
196             }
197             set
198             {
199                 Interop.Key.KeyModifierSet(SwigCPtr, value);
200                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
201             }
202         }
203
204         /// <summary>
205         /// The time (in ms) that the key event occurred.
206         /// </summary>
207         /// <since_tizen> 3 </since_tizen>
208         public uint Time
209         {
210             get
211             {
212                 uint ret = Interop.Key.TimeGet(SwigCPtr);
213                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
214                 return ret;
215             }
216             set
217             {
218                 Interop.Key.TimeSet(SwigCPtr, value);
219                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
220             }
221         }
222
223         /// <summary>
224         /// State of the key event.
225         /// </summary>
226         /// <since_tizen> 3 </since_tizen>
227         public Key.StateType State
228         {
229             get
230             {
231                 Key.StateType ret = (Key.StateType)Interop.Key.StateGet(SwigCPtr);
232                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
233                 return ret;
234             }
235             set
236             {
237                 Interop.Key.StateSet(SwigCPtr, (int)value);
238                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
239             }
240         }
241
242         /// <summary>
243         /// Get the device class the key event originated from.
244         /// </summary>
245         /// <since_tizen> 3 </since_tizen>
246         public DeviceClassType DeviceClass
247         {
248             get
249             {
250                 int ret = Interop.NDalic.GetDeviceClass(SwigCPtr);
251                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
252                 return (DeviceClassType)ret;
253             }
254         }
255
256         /// <summary>
257         /// Get the device subclass the key event originated from.
258         /// </summary>
259         /// <since_tizen> 4 </since_tizen>
260         public DeviceSubClassType DeviceSubClass
261         {
262             get
263             {
264                 int ret = Interop.NDalic.GetDeviceSubClass(SwigCPtr);
265                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
266                 return (DeviceSubClassType)ret;
267             }
268         }
269
270         private string keyPressed
271         {
272             set
273             {
274                 Interop.Key.KeyPressedSet(SwigCPtr, value);
275                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
276             }
277             get
278             {
279                 string ret = Interop.Key.KeyPressedGet(SwigCPtr);
280                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
281                 return ret;
282             }
283         }
284
285         /// <summary>
286         /// Checks to see if the Shift key modifier has been supplied.
287         /// </summary>
288         /// <returns>True if Shift modifier.</returns>
289         /// <since_tizen> 3 </since_tizen>
290         public bool IsShiftModifier()
291         {
292             bool ret = Interop.Key.IsShiftModifier(SwigCPtr);
293             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
294             return ret;
295         }
296
297         /// <summary>
298         /// Checks to see if Ctrl (control) key modifier has been supplied.
299         /// </summary>
300         /// <returns>True if Ctrl modifier.</returns>
301         /// <since_tizen> 3 </since_tizen>
302         public bool IsCtrlModifier()
303         {
304             bool ret = Interop.Key.IsCtrlModifier(SwigCPtr);
305             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
306             return ret;
307         }
308
309         /// <summary>
310         /// Checks to see if Alt key modifier has been supplied.
311         /// </summary>
312         /// <returns>True if Alt modifier.</returns>
313         /// <since_tizen> 3 </since_tizen>
314         public bool IsAltModifier()
315         {
316             bool ret = Interop.Key.IsAltModifier(SwigCPtr);
317             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
318             return ret;
319         }
320
321         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Key obj)
322         {
323             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
324         }
325
326         internal static Key GetKeyFromPtr(global::System.IntPtr cPtr)
327         {
328             Key ret = new Key(cPtr, false);
329             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
330             return ret;
331         }
332
333         /// This will not be public opened.
334         [EditorBrowsable(EditorBrowsableState.Never)]
335         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
336         {
337             Interop.Key.DeleteKey(swigCPtr);
338         }
339     }
340 }