cf94a4d0260248730e5b8b5cb899a069b4ceaaff
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / KeyboardTypeSignalType.cs
1 /*
2  * Copyright(c) 2018 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 using System.ComponentModel;
18
19 namespace Tizen.NUI
20 {
21     /// <summary>
22     /// KeyboardTypeSignalType
23     /// </summary>
24     /// <since_tizen> 4 </since_tizen>
25     public class KeyboardTypeSignalType : global::System.IDisposable
26     {
27         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
28         /// <summary>
29         /// swigCMemOwn
30         /// </summary>
31         /// <since_tizen> 4 </since_tizen>
32         protected bool swigCMemOwn;
33
34         internal KeyboardTypeSignalType(global::System.IntPtr cPtr, bool cMemoryOwn)
35         {
36             swigCMemOwn = cMemoryOwn;
37             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
38         }
39
40         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(KeyboardTypeSignalType obj)
41         {
42             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
43         }
44
45         //A Flag to check who called Dispose(). (By User or DisposeQueue)
46         private bool isDisposeQueued = false;
47         /// <summary>
48         /// A Flat to check if it is already disposed.
49         /// </summary>
50         /// <since_tizen> 4 </since_tizen>
51         protected bool disposed = false;
52
53         /// <summary>
54         /// Dispose
55         /// </summary>
56         /// <since_tizen> 3 </since_tizen>
57         ~KeyboardTypeSignalType()
58         {
59             if (!isDisposeQueued)
60             {
61                 isDisposeQueued = true;
62                 DisposeQueue.Instance.Add(this);
63             }
64         }
65
66         /// <summary>
67         /// Dispose
68         /// </summary>
69         /// <since_tizen> 4 </since_tizen>
70         public void Dispose()
71         {
72             //Throw excpetion if Dispose() is called in separate thread.
73             if (!Window.IsInstalled())
74             {
75                 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
76             }
77
78             if (isDisposeQueued)
79             {
80                 Dispose(DisposeTypes.Implicit);
81             }
82             else
83             {
84                 Dispose(DisposeTypes.Explicit);
85                 System.GC.SuppressFinalize(this);
86             }
87         }
88
89         /// <summary>
90         /// Dispose
91         /// </summary>
92         /// <since_tizen> 4 </since_tizen>
93         protected virtual void Dispose(DisposeTypes type)
94         {
95             if (disposed)
96             {
97                 return;
98             }
99
100             if (type == DisposeTypes.Explicit)
101             {
102                 //Called by User
103                 //Release your own managed resources here.
104                 //You should release all of your own disposable objects here.
105
106             }
107
108             //Release your own unmanaged resources here.
109             //You should not access any managed member here except static instance.
110             //because the execution order of Finalizes is non-deterministic.
111
112             if (swigCPtr.Handle != global::System.IntPtr.Zero)
113             {
114                 if (swigCMemOwn)
115                 {
116                     swigCMemOwn = false;
117                     Interop.KeyboardTypeSignalType.delete_KeyboardTypeSignalType(swigCPtr);
118                 }
119                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
120             }
121
122             disposed = true;
123         }
124
125         /// <summary>
126         /// Queries whether there are any connected slots.
127         /// </summary>
128         /// <returns>True if there are any slots connected to the signal</returns>
129         /// <since_tizen> 4 </since_tizen>
130         public bool Empty()
131         {
132             bool ret = Interop.KeyboardTypeSignalType.KeyboardTypeSignalType_Empty(swigCPtr);
133             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
134             return ret;
135         }
136
137         /// <summary>
138         /// Queries the number of slots.
139         /// </summary>
140         /// <returns>The number of slots connected to this signal</returns>
141         /// <since_tizen> 4 </since_tizen>
142         public uint GetConnectionCount()
143         {
144             uint ret = Interop.KeyboardTypeSignalType.KeyboardTypeSignalType_GetConnectionCount(swigCPtr);
145             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
146             return ret;
147         }
148
149         /// <summary>
150         /// Connects a function.
151         /// </summary>
152         /// <param name="func">The function to connect</param>
153         /// <since_tizen> 4 </since_tizen>
154         public void Connect(System.Delegate func)
155         {
156             System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
157             {
158                 Interop.KeyboardTypeSignalType.KeyboardTypeSignalType_Connect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
159                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
160             }
161         }
162
163         /// <summary>
164         /// Disconnects a function.
165         /// </summary>
166         /// <param name="func">The function to disconnect</param>
167         /// <since_tizen> 4 </since_tizen>
168         public void Disconnect(System.Delegate func)
169         {
170             System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
171             {
172                 Interop.KeyboardTypeSignalType.KeyboardTypeSignalType_Disconnect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
173                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
174             }
175         }
176
177         /// <summary>
178         /// Connects a member function.
179         /// </summary>
180         /// <param name="arg">The member function to connect</param>
181         /// <since_tizen> 5 </since_tizen>
182         public void Emit(InputMethodContext.KeyboardType arg)
183         {
184             Interop.KeyboardTypeSignalType.KeyboardTypeSignalType_Emit(swigCPtr, (int)arg);
185             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
186         }
187
188         /// <summary>
189         /// The contructor.
190         /// </summary>
191         /// <since_tizen> 4 </since_tizen>
192         public KeyboardTypeSignalType() : this(Interop.KeyboardTypeSignalType.new_KeyboardTypeSignalType(), true)
193         {
194             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
195         }
196
197     }
198 }