c8fedc4af4fd0239d1de63a1fa2c66ceb6712393
[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 using System;
30 using System.Runtime.InteropServices;\r
31 using Tizen.NUI.BaseComponents;
32
33 public class LongPressGestureDetector : GestureDetector {
34   private global::System.Runtime.InteropServices.HandleRef swigCPtr;
35
36   internal LongPressGestureDetector(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.LongPressGestureDetector_SWIGUpcast(cPtr), cMemoryOwn) {
37     swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
38   }
39
40   internal static global::System.Runtime.InteropServices.HandleRef getCPtr(LongPressGestureDetector obj) {
41     return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
42   }
43
44   public override void Dispose() {
45     if (!Window.IsInstalled()) {
46       DisposeQueue.Instance.Add(this);
47       return;
48     }
49
50     lock(this) {
51       if (swigCPtr.Handle != global::System.IntPtr.Zero) {
52         if (swigCMemOwn) {
53           swigCMemOwn = false;
54           NDalicPINVOKE.delete_LongPressGestureDetector(swigCPtr);
55         }
56         swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
57       }
58       global::System.GC.SuppressFinalize(this);
59       base.Dispose();
60     }
61   }
62
63
64
65
66 public class DetectedEventArgs : EventArgs
67 {
68    private View _view;
69    private LongPressGesture _longPressGesture;
70
71    public View View\r
72             {
73       get
74       {
75          return _view;
76       }
77       set
78       {
79          _view = value;
80       }
81    }
82
83    public LongPressGesture LongPressGesture
84    {
85       get
86       {
87          return _longPressGesture;
88       }
89       set
90       {
91          _longPressGesture = value;
92       }
93    }
94 }
95
96   [UnmanagedFunctionPointer(CallingConvention.StdCall)]
97   private delegate void DetectedCallbackDelegate(IntPtr actor, IntPtr longPressGesture);
98   private DaliEventHandler<object,DetectedEventArgs> _longPressGestureEventHandler;
99   private DetectedCallbackDelegate _longPressGestureCallbackDelegate;
100
101
102   public event DaliEventHandler<object,DetectedEventArgs> Detected
103   {
104      add
105      {
106         lock(this)
107         {
108            // Restricted to only one listener
109            if (_longPressGestureEventHandler == null)
110            {
111               _longPressGestureEventHandler += value;
112
113               _longPressGestureCallbackDelegate = new DetectedCallbackDelegate(OnLongPressGestureDetected);
114               this.DetectedSignal().Connect(_longPressGestureCallbackDelegate);
115            }
116         }
117      }
118
119      remove
120      {
121         lock(this)
122         {
123            if (_longPressGestureEventHandler != null)
124            {
125               this.DetectedSignal().Disconnect(_longPressGestureCallbackDelegate);
126            }
127
128            _longPressGestureEventHandler -= value;
129         }
130      }
131   }
132
133  private void OnLongPressGestureDetected(IntPtr actor, IntPtr longPressGesture)
134   {
135    DetectedEventArgs e = new DetectedEventArgs();
136
137    // Populate all members of "e" (LongPressGestureEventArgs) with real data
138    e.View = View.GetViewFromPtr(actor);
139    e.LongPressGesture = Tizen.NUI.LongPressGesture.GetLongPressGestureFromPtr(longPressGesture);
140
141    if (_longPressGestureEventHandler != null)
142    {
143       //here we send all data to user event handlers
144       _longPressGestureEventHandler(this, e);
145    }
146
147   }
148
149
150 public static LongPressGestureDetector GetLongPressGestureDetectorFromPtr(global::System.IntPtr cPtr) {
151     LongPressGestureDetector ret = new LongPressGestureDetector(cPtr, false);
152     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
153     return ret;
154   }
155
156
157   public LongPressGestureDetector () : this (NDalicPINVOKE.LongPressGestureDetector_New__SWIG_0(), true) {
158       if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
159
160   }
161   public LongPressGestureDetector (uint touchesRequired) : this (NDalicPINVOKE.LongPressGestureDetector_New__SWIG_1(touchesRequired), true) {
162       if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
163
164   }
165   public LongPressGestureDetector (uint minTouches, uint maxTouches) : this (NDalicPINVOKE.LongPressGestureDetector_New__SWIG_2(minTouches, maxTouches), true) {
166       if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
167
168   }
169   public new static LongPressGestureDetector DownCast(BaseHandle handle) {
170     LongPressGestureDetector ret = new LongPressGestureDetector(NDalicPINVOKE.LongPressGestureDetector_DownCast(BaseHandle.getCPtr(handle)), true);
171     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
172     return ret;
173   }
174
175   public LongPressGestureDetector(LongPressGestureDetector handle) : this(NDalicPINVOKE.new_LongPressGestureDetector__SWIG_1(LongPressGestureDetector.getCPtr(handle)), true) {
176     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
177   }
178
179   public LongPressGestureDetector Assign(LongPressGestureDetector rhs) {
180     LongPressGestureDetector ret = new LongPressGestureDetector(NDalicPINVOKE.LongPressGestureDetector_Assign(swigCPtr, LongPressGestureDetector.getCPtr(rhs)), false);
181     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
182     return ret;
183   }
184
185   public void SetTouchesRequired(uint touches) {
186     NDalicPINVOKE.LongPressGestureDetector_SetTouchesRequired__SWIG_0(swigCPtr, touches);
187     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
188   }
189
190   public void SetTouchesRequired(uint minTouches, uint maxTouches) {
191     NDalicPINVOKE.LongPressGestureDetector_SetTouchesRequired__SWIG_1(swigCPtr, minTouches, maxTouches);
192     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
193   }
194
195   public uint GetMinimumTouchesRequired() {
196     uint ret = NDalicPINVOKE.LongPressGestureDetector_GetMinimumTouchesRequired(swigCPtr);
197     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
198     return ret;
199   }
200
201   public uint GetMaximumTouchesRequired() {
202     uint ret = NDalicPINVOKE.LongPressGestureDetector_GetMaximumTouchesRequired(swigCPtr);
203     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
204     return ret;
205   }
206
207   internal LongPressGestureDetectedSignal DetectedSignal() {
208     LongPressGestureDetectedSignal ret = new LongPressGestureDetectedSignal(NDalicPINVOKE.LongPressGestureDetector_DetectedSignal(swigCPtr), false);
209     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
210     return ret;
211   }
212
213 }
214
215 }