DALi C# binding - EventHandler Support
[platform/core/uifw/dali-toolkit.git] / plugins / dali-swig / SWIG / events / gaussian-blur-view-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 GAUSSIAN_BLURR_VIEW_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 GAUSSIAN_BLURR_VIEW_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
28 %typemap(cscode) NameSpace::ClassName %{
29
30
31 public class FinishedEventArgs : EventArgs
32 {
33    private GaussianBlurView _gaussianBlurView;
34
35    public GaussianBlurView GaussianBlurView
36    {
37       get
38       {
39          return _gaussianBlurView;
40       }
41       set
42       {
43          _gaussianBlurView = value;
44       }
45    }
46 }
47
48   [UnmanagedFunctionPointer(CallingConvention.StdCall)]
49   public delegate void FinishedEventHandler(object source, FinishedEventArgs e);
50
51   [UnmanagedFunctionPointer(CallingConvention.StdCall)]
52   private delegate void FinishedEventCallbackDelegate(IntPtr application);
53   private FinishedEventHandler _gaussianFinishedEventHandler;
54   private FinishedEventCallbackDelegate _gaussianFinishedEventCallbackDelegate;
55
56   public event FinishedEventHandler Finished
57   {
58      add
59      {
60         lock(this)
61         {
62            // Restricted to only one listener
63            if (_gaussianFinishedEventHandler == null)
64            {
65               _gaussianFinishedEventHandler += value;
66
67               _gaussianFinishedEventCallbackDelegate = new FinishedEventCallbackDelegate(OnFinished);
68               this.FinishedSignal().Connect(_gaussianFinishedEventCallbackDelegate);
69            }
70         }
71      }
72
73      remove
74      {
75         lock(this)
76         {
77            if (_gaussianFinishedEventHandler != null)
78            {
79               this.FinishedSignal().Disconnect(_gaussianFinishedEventCallbackDelegate);
80            }
81
82            _gaussianFinishedEventHandler -= value;
83         }
84      }
85   }
86
87   // Callback for GaussianBlurView FinishedSignal
88   private void OnFinished(IntPtr data)
89   {
90      FinishedEventArgs e = new FinishedEventArgs();
91
92      // Populate all members of "e" (FinishedEventArgs) with real data
93      e.GaussianBlurView = GaussianBlurView.GetGaussianBlurViewFromPtr(data);
94
95      if (_gaussianFinishedEventHandler != null)
96      {
97         //here we send all data to user event handlers
98         _gaussianFinishedEventHandler(this, e);
99      }
100   }
101
102  public static ClassName Get ## ClassName ## FromPtr(global::System.IntPtr cPtr) {
103     ClassName ret = new ClassName(cPtr, false);
104    if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
105     return ret;
106   }
107
108 %}
109 %enddef
110
111 %define DALI_GAUSSIAN_BLURR_VIEW_EVENTHANDLER_PARAM( NameSpace, ClassName)
112   GAUSSIAN_BLURR_VIEW_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
113   GAUSSIAN_BLURR_VIEW_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
114 %enddef
115
116 namespace Dali
117 {
118   DALI_GAUSSIAN_BLURR_VIEW_EVENTHANDLER_PARAM( Dali::Toolkit, GaussianBlurView);
119 }
120
121