1a31ed33eec3ac0f6158fad74eb8e8cae1b50e92
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / LongPressGestureDetector.cs
1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16 // This File has been auto-generated by SWIG and then modified using DALi Ruby Scripts
17 //------------------------------------------------------------------------------
18 // <auto-generated />
19 //
20 // This file was automatically generated by SWIG (http://www.swig.org).
21 // Version 3.0.9
22 //
23 // Do not make changes to this file unless you know what you are doing--modify
24 // the SWIG interface file instead.
25 //------------------------------------------------------------------------------
26
27 namespace Tizen.NUI
28 {
29
30     using System;
31     using System.Runtime.InteropServices;
32     using Tizen.NUI.BaseComponents;
33
34     public class LongPressGestureDetector : GestureDetector
35     {
36         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
37
38         internal LongPressGestureDetector(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.LongPressGestureDetector_SWIGUpcast(cPtr), cMemoryOwn)
39         {
40             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
41         }
42
43         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(LongPressGestureDetector obj)
44         {
45             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
46         }
47
48         protected override void Dispose(DisposeTypes type)
49         {
50             if (disposed)
51             {
52                 return;
53             }
54
55             if (type == DisposeTypes.Explicit)
56             {
57                 //Called by User
58                 //Release your own managed resources here.
59                 //You should release all of your own disposable objects here.
60
61             }
62
63             //Release your own unmanaged resources here.
64             //You should not access any managed member here except static instance.
65             //because the execution order of Finalizes is non-deterministic.
66
67             if (swigCPtr.Handle != global::System.IntPtr.Zero)
68             {
69                 if (swigCMemOwn)
70                 {
71                     swigCMemOwn = false;
72                     NDalicPINVOKE.delete_LongPressGestureDetector(swigCPtr);
73                 }
74                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
75             }
76
77             base.Dispose(type);
78         }
79
80
81         public class DetectedEventArgs : EventArgs
82         {
83             private View _view;
84             private LongPressGesture _longPressGesture;
85
86             public View View
87             {
88                 get
89                 {
90                     return _view;
91                 }
92                 set
93                 {
94                     _view = value;
95                 }
96             }
97
98             public LongPressGesture LongPressGesture
99             {
100                 get
101                 {
102                     return _longPressGesture;
103                 }
104                 set
105                 {
106                     _longPressGesture = value;
107                 }
108             }
109         }
110
111         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
112         private delegate void DetectedCallbackDelegate(IntPtr actor, IntPtr longPressGesture);
113         private DaliEventHandler<object, DetectedEventArgs> _longPressGestureEventHandler;
114         private DetectedCallbackDelegate _longPressGestureCallbackDelegate;
115
116
117         public event DaliEventHandler<object, DetectedEventArgs> Detected
118         {
119             add
120             {
121                 lock (this)
122                 {
123                     // Restricted to only one listener
124                     if (_longPressGestureEventHandler == null)
125                     {
126                         _longPressGestureEventHandler += value;
127
128                         _longPressGestureCallbackDelegate = new DetectedCallbackDelegate(OnLongPressGestureDetected);
129                         this.DetectedSignal().Connect(_longPressGestureCallbackDelegate);
130                     }
131                 }
132             }
133
134             remove
135             {
136                 lock (this)
137                 {
138                     if (_longPressGestureEventHandler != null)
139                     {
140                         this.DetectedSignal().Disconnect(_longPressGestureCallbackDelegate);
141                     }
142
143                     _longPressGestureEventHandler -= value;
144                 }
145             }
146         }
147
148         private void OnLongPressGestureDetected(IntPtr actor, IntPtr longPressGesture)
149         {
150             DetectedEventArgs e = new DetectedEventArgs();
151
152             // Populate all members of "e" (LongPressGestureEventArgs) with real data
153             e.View = View.GetViewFromPtr(actor);
154             e.LongPressGesture = Tizen.NUI.LongPressGesture.GetLongPressGestureFromPtr(longPressGesture);
155
156             if (_longPressGestureEventHandler != null)
157             {
158                 //here we send all data to user event handlers
159                 _longPressGestureEventHandler(this, e);
160             }
161
162         }
163
164
165         public static LongPressGestureDetector GetLongPressGestureDetectorFromPtr(global::System.IntPtr cPtr)
166         {
167             LongPressGestureDetector ret = new LongPressGestureDetector(cPtr, false);
168             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
169             return ret;
170         }
171
172
173         public LongPressGestureDetector() : this(NDalicPINVOKE.LongPressGestureDetector_New__SWIG_0(), true)
174         {
175             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
176
177         }
178         public LongPressGestureDetector(uint touchesRequired) : this(NDalicPINVOKE.LongPressGestureDetector_New__SWIG_1(touchesRequired), true)
179         {
180             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
181
182         }
183         public LongPressGestureDetector(uint minTouches, uint maxTouches) : this(NDalicPINVOKE.LongPressGestureDetector_New__SWIG_2(minTouches, maxTouches), true)
184         {
185             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
186
187         }
188         public new static LongPressGestureDetector DownCast(BaseHandle handle)
189         {
190             LongPressGestureDetector ret = new LongPressGestureDetector(NDalicPINVOKE.LongPressGestureDetector_DownCast(BaseHandle.getCPtr(handle)), true);
191             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
192             return ret;
193         }
194
195         public LongPressGestureDetector(LongPressGestureDetector handle) : this(NDalicPINVOKE.new_LongPressGestureDetector__SWIG_1(LongPressGestureDetector.getCPtr(handle)), true)
196         {
197             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
198         }
199
200         public LongPressGestureDetector Assign(LongPressGestureDetector rhs)
201         {
202             LongPressGestureDetector ret = new LongPressGestureDetector(NDalicPINVOKE.LongPressGestureDetector_Assign(swigCPtr, LongPressGestureDetector.getCPtr(rhs)), false);
203             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
204             return ret;
205         }
206
207         public void SetTouchesRequired(uint touches)
208         {
209             NDalicPINVOKE.LongPressGestureDetector_SetTouchesRequired__SWIG_0(swigCPtr, touches);
210             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
211         }
212
213         public void SetTouchesRequired(uint minTouches, uint maxTouches)
214         {
215             NDalicPINVOKE.LongPressGestureDetector_SetTouchesRequired__SWIG_1(swigCPtr, minTouches, maxTouches);
216             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
217         }
218
219         public uint GetMinimumTouchesRequired()
220         {
221             uint ret = NDalicPINVOKE.LongPressGestureDetector_GetMinimumTouchesRequired(swigCPtr);
222             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
223             return ret;
224         }
225
226         public uint GetMaximumTouchesRequired()
227         {
228             uint ret = NDalicPINVOKE.LongPressGestureDetector_GetMaximumTouchesRequired(swigCPtr);
229             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
230             return ret;
231         }
232
233         internal LongPressGestureDetectedSignal DetectedSignal()
234         {
235             LongPressGestureDetectedSignal ret = new LongPressGestureDetectedSignal(NDalicPINVOKE.LongPressGestureDetector_DetectedSignal(swigCPtr), false);
236             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
237             return ret;
238         }
239
240     }
241
242 }