Merge "DALi Version 1.2.40" into devel/master
[platform/core/uifw/dali-toolkit.git] / plugins / dali-swig / SWIG / events / popup-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 POPUP_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
28 %define POPUP_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
29 %typemap(cscode) NameSpace::ClassName %{
30
31   public class OutsideTouchedEventArgs : EventArgs
32   {
33   }
34
35   public class ShowingEventArgs : EventArgs
36   {
37   }
38
39   public class ShownEventArgs : EventArgs
40   {
41   }
42
43   public class HidingEventArgs : EventArgs
44   {
45   }
46
47   public class HiddenEventArgs : EventArgs
48   {
49   }
50
51   [UnmanagedFunctionPointer(CallingConvention.StdCall)]
52   private delegate void OutsideTouchedEventCallbackDelegate();
53   private DaliEventHandler<object,OutsideTouchedEventArgs> _popUpOutsideTouchedEventHandler;
54   private OutsideTouchedEventCallbackDelegate _popUpOutsideTouchedEventCallbackDelegate;
55
56   [UnmanagedFunctionPointer(CallingConvention.StdCall)]
57   private delegate void ShowingEventCallbackDelegate();
58   private DaliEventHandler<object,ShowingEventArgs> _popUpShowingEventHandler;
59   private ShowingEventCallbackDelegate _popUpShowingEventCallbackDelegate;
60
61   [UnmanagedFunctionPointer(CallingConvention.StdCall)]
62   private delegate void ShownEventCallbackDelegate();
63   private DaliEventHandler<object,ShownEventArgs> _popUpShownEventHandler;
64   private ShownEventCallbackDelegate _popUpShownEventCallbackDelegate;
65
66   [UnmanagedFunctionPointer(CallingConvention.StdCall)]
67   private delegate void HidingEventCallbackDelegate();
68   private DaliEventHandler<object,HidingEventArgs> _popUpHidingEventHandler;
69   private HidingEventCallbackDelegate _popUpHidingEventCallbackDelegate;
70
71   [UnmanagedFunctionPointer(CallingConvention.StdCall)]
72   private delegate void HiddenEventCallbackDelegate();
73   private DaliEventHandler<object,HiddenEventArgs> _popUpHiddenEventHandler;
74   private HiddenEventCallbackDelegate _popUpHiddenEventCallbackDelegate;
75
76   public event DaliEventHandler<object,OutsideTouchedEventArgs> OutsideTouched
77   {
78      add
79      {
80         lock(this)
81         {
82            // Restricted to only one listener
83            if (_popUpOutsideTouchedEventHandler == null)
84            {
85               _popUpOutsideTouchedEventHandler += value;
86
87               _popUpOutsideTouchedEventCallbackDelegate = new OutsideTouchedEventCallbackDelegate(OnOutsideTouched);
88               this.OutsideTouchedSignal().Connect(_popUpOutsideTouchedEventCallbackDelegate);
89            }
90         }
91      }
92
93      remove
94      {
95         lock(this)
96         {
97            if (_popUpOutsideTouchedEventHandler != null)
98            {
99               this.OutsideTouchedSignal().Disconnect(_popUpOutsideTouchedEventCallbackDelegate);
100            }
101
102            _popUpOutsideTouchedEventHandler -= value;
103         }
104      }
105   }
106
107   // Callback for Popup OutsideTouchedSignal
108   private void OnOutsideTouched()
109   {
110      OutsideTouchedEventArgs e = new OutsideTouchedEventArgs();
111
112      if (_popUpOutsideTouchedEventHandler != null)
113      {
114         //here we send all data to user event handlers
115         _popUpOutsideTouchedEventHandler(this, e);
116      }
117   }
118
119   public event DaliEventHandler<object,ShowingEventArgs> Showing
120   {
121      add
122      {
123         lock(this)
124         {
125            // Restricted to only one listener
126            if (_popUpShowingEventHandler == null)
127            {
128               _popUpShowingEventHandler += value;
129
130               _popUpShowingEventCallbackDelegate = new ShowingEventCallbackDelegate(OnShowing);
131               this.ShowingSignal().Connect(_popUpShowingEventCallbackDelegate);
132            }
133         }
134      }
135
136      remove
137      {
138         lock(this)
139         {
140            if (_popUpShowingEventHandler != null)
141            {
142               this.ShowingSignal().Disconnect(_popUpShowingEventCallbackDelegate);
143            }
144
145            _popUpShowingEventHandler -= value;
146         }
147      }
148   }
149
150   // Callback for ShowingSignal
151   private void OnShowing()
152   {
153      ShowingEventArgs e = new ShowingEventArgs();
154
155      if (_popUpShowingEventHandler != null)
156      {
157         //here we send all data to user event handlers
158         _popUpShowingEventHandler(this, e);
159      }
160   }
161
162
163   public event DaliEventHandler<object,ShownEventArgs> Shown
164   {
165      add
166      {
167         lock(this)
168         {
169            // Restricted to only one listener
170            if (_popUpShownEventHandler == null)
171            {
172               _popUpShownEventHandler += value;
173
174               _popUpShownEventCallbackDelegate = new ShownEventCallbackDelegate(OnShown);
175               this.ShownSignal().Connect(_popUpShownEventCallbackDelegate);
176            }
177         }
178      }
179
180      remove
181      {
182         lock(this)
183         {
184            if (_popUpShownEventHandler != null)
185            {
186               this.ShownSignal().Disconnect(_popUpShownEventCallbackDelegate);
187            }
188
189            _popUpShownEventHandler -= value;
190         }
191      }
192   }
193
194   // Callback for ShownSignal
195   private void OnShown()
196   {
197      ShownEventArgs e = new ShownEventArgs();
198
199      if (_popUpShownEventHandler != null)
200      {
201         //here we send all data to user event handlers
202         _popUpShownEventHandler(this, e);
203      }
204   }
205
206   public event DaliEventHandler<object,HidingEventArgs> Hiding
207   {
208      add
209      {
210         lock(this)
211         {
212            // Restricted to only one listener
213            if (_popUpHidingEventHandler == null)
214            {
215               _popUpHidingEventHandler += value;
216
217               _popUpHidingEventCallbackDelegate = new HidingEventCallbackDelegate(OnHiding);
218               this.HidingSignal().Connect(_popUpHidingEventCallbackDelegate);
219            }
220         }
221      }
222
223      remove
224      {
225         lock(this)
226         {
227            if (_popUpHidingEventHandler != null)
228            {
229               this.HidingSignal().Disconnect(_popUpHidingEventCallbackDelegate);
230            }
231
232            _popUpHidingEventHandler -= value;
233         }
234      }
235   }
236
237   // Callback for HidingSignal
238   private void OnHiding()
239   {
240      HidingEventArgs e = new HidingEventArgs();
241
242      if (_popUpHidingEventHandler != null)
243      {
244         //here we send all data to user event handlers
245         _popUpHidingEventHandler(this, e);
246      }
247   }
248
249   public event DaliEventHandler<object,HiddenEventArgs> Hidden
250   {
251      add
252      {
253         lock(this)
254         {
255            // Restricted to only one listener
256            if (_popUpHiddenEventHandler == null)
257            {
258               _popUpHiddenEventHandler += value;
259
260               _popUpHiddenEventCallbackDelegate = new HiddenEventCallbackDelegate(OnHidden);
261               this.HiddenSignal().Connect(_popUpHiddenEventCallbackDelegate);
262            }
263         }
264      }
265
266      remove
267      {
268         lock(this)
269         {
270            if (_popUpHiddenEventHandler != null)
271            {
272               this.HiddenSignal().Disconnect(_popUpHiddenEventCallbackDelegate);
273            }
274
275            _popUpHiddenEventHandler -= value;
276         }
277      }
278   }
279
280   // Callback for HiddenSignal
281   private void OnHidden()
282   {
283      HiddenEventArgs e = new HiddenEventArgs();
284
285      if (_popUpHiddenEventHandler != null)
286      {
287         //here we send all data to user event handlers
288         _popUpHiddenEventHandler(this, e);
289      }
290   }
291 %}
292 %enddef
293
294 %define DALI_POPUP_EVENTHANDLER_PARAM( NameSpace, ClassName)
295   POPUP_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
296   POPUP_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
297 %enddef
298
299 namespace Dali
300 {
301   DALI_POPUP_EVENTHANDLER_PARAM( Dali::Toolkit, Popup);
302 }
303