Merge "Add missed parameter documentation" into devel/master
[platform/core/uifw/dali-toolkit.git] / plugins / dali-swig / SWIG / events / pangesture-event.i
1 /*
2  * Copyright (c) 2016 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 %define PANGESTURE_EVENTHANDLER_TYPEMAP_EVENTARG(NameSpace, ClassName)
19 %typemap(csimports) NameSpace::ClassName %{
20 using System;
21 using System.Runtime.InteropServices;
22
23 %}
24
25 %enddef
26
27 %define PANGESTURE_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
28 %typemap(cscode) NameSpace::ClassName %{
29
30
31 public class DetectedEventArgs : EventArgs
32 {
33    private Actor _actor;
34    private PanGesture _panGesture;
35
36    public Actor Actor
37    {
38       get
39       {
40          return _actor;
41       }
42       set
43       {
44          _actor = value;
45       }
46    }
47
48    public PanGesture PanGesture
49    {
50       get
51       {
52          return _panGesture;
53       }
54       set
55       {
56          _panGesture = value;
57       }
58    }
59 }
60
61   [UnmanagedFunctionPointer(CallingConvention.StdCall)]
62   public delegate void DetectedEventHandler(object source, DetectedEventArgs e);
63
64   [UnmanagedFunctionPointer(CallingConvention.StdCall)]
65   private delegate void DetectedCallbackDelegate(IntPtr actor, IntPtr panGesture);
66   private DetectedEventHandler _panGestureEventHandler;
67   private DetectedCallbackDelegate _panGestureCallbackDelegate;
68
69
70   public event DetectedEventHandler Detected
71   {
72      add
73      {
74         lock(this)
75         {
76            // Restricted to only one listener
77            if (_panGestureEventHandler == null)
78            {
79               _panGestureEventHandler += value;
80
81               _panGestureCallbackDelegate = new DetectedCallbackDelegate(OnPanGestureDetected);
82               this.DetectedSignal().Connect(_panGestureCallbackDelegate);
83            }
84         }
85      }
86
87      remove
88      {
89         lock(this)
90         {
91            if (_panGestureEventHandler != null)
92            {
93               this.DetectedSignal().Disconnect(_panGestureCallbackDelegate);
94            }
95
96            _panGestureEventHandler -= value;
97         }
98      }
99   }
100
101  private void OnPanGestureDetected(IntPtr actor, IntPtr panGesture)
102   {
103    DetectedEventArgs e = new DetectedEventArgs();
104
105    // Populate all members of "e" (PanGestureEventArgs) with real data
106    e.Actor = Actor.GetActorFromPtr(actor);
107    e.PanGesture = Dali.PanGesture.GetPanGestureFromPtr(panGesture);
108
109    if (_panGestureEventHandler != null)
110    {
111       //here we send all data to user event handlers
112       _panGestureEventHandler(this, e);
113    }
114
115   }
116
117
118 public static ClassName Get ## ClassName ## FromPtr(global::System.IntPtr cPtr) {
119     ClassName ret = new ClassName(cPtr, false);
120    if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
121     return ret;
122   }
123
124 %}
125
126 %enddef
127
128 %define DALI_PANGESTURE_EVENTHANDLER_PARAM( NameSpace, ClassName)
129
130   PANGESTURE_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
131   PANGESTURE_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
132
133 %enddef
134
135 namespace Dali
136 {
137   DALI_PANGESTURE_EVENTHANDLER_PARAM( Dali, PanGestureDetector);
138 }