Added C# bindings for Window focus event and NPatchVisual property
[platform/core/uifw/dali-toolkit.git] / plugins / dali-swig / SWIG / events / videoview-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 VIDEOVIEW_EVENTHANDLER_TYPEMAP_EVENTARG(NameSpace, ClassName)
19 %typemap(csimports) NameSpace::ClassName %{
20 using System;
21 using System.Runtime.InteropServices;
22
23 %}
24 %enddef
25
26 %define VIDEOVIEW_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
27 %typemap(cscode) NameSpace::ClassName %{
28
29 /**
30   * @brief Event arguments that passed via Finished signal
31   *
32   */
33 public class FinishedEventArgs : EventArgs
34 {
35    private VideoView _videoView;
36
37    /**
38      * @brief VideoView - VideoView is a control for video playback and display.
39      *
40      */
41    public VideoView VideoView
42    {
43       get
44       {
45          return _videoView;
46       }
47       set
48       {
49          _videoView = value;
50       }
51    }
52 }
53
54
55   [UnmanagedFunctionPointer(CallingConvention.StdCall)]
56   private delegate void FinishedCallbackDelegate(IntPtr data);
57   private DaliEventHandler<object,FinishedEventArgs> _videoViewFinishedEventHandler;
58   private FinishedCallbackDelegate _videoViewFinishedCallbackDelegate;
59
60   /**
61     * @brief Event for Finished signal which can be used to subscribe/unsubscribe the event handler
62     * (in the type of FinishedEventHandler-DaliEventHandler<object,FinishedEventArgs>) provided by the user.
63     * Finished signal is emitted when a video playback have finished.
64     */
65   public event DaliEventHandler<object,FinishedEventArgs> Finished
66   {
67      add
68      {
69         lock(this)
70         {
71            // Restricted to only one listener
72            if (_videoViewFinishedEventHandler == null)
73            {
74               _videoViewFinishedEventHandler += value;
75
76               _videoViewFinishedCallbackDelegate = new FinishedCallbackDelegate(OnFinished);
77               this.FinishedSignal().Connect(_videoViewFinishedCallbackDelegate);
78            }
79         }
80      }
81
82      remove
83      {
84         lock(this)
85         {
86            if (_videoViewFinishedEventHandler != null)
87            {
88               this.FinishedSignal().Disconnect(_videoViewFinishedCallbackDelegate);
89            }
90
91            _videoViewFinishedEventHandler -= value;
92         }
93      }
94   }
95
96   // Callback for VideoView Finished signal
97   private void OnFinished(IntPtr data)
98   {
99      FinishedEventArgs e = new FinishedEventArgs();
100
101      // Populate all members of "e" (FinishedEventArgs) with real data
102      e.VideoView = VideoView.GetVideoViewFromPtr( data );
103
104      if (_videoViewFinishedEventHandler != null)
105      {
106         //here we send all data to user event handlers
107         _videoViewFinishedEventHandler(this, e);
108      }
109   }
110
111   public static ClassName Get ## ClassName ## FromPtr(global::System.IntPtr cPtr) {
112     ClassName ret = new ClassName(cPtr, false);
113    if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
114     return ret;
115   }
116
117 %}
118
119 %enddef
120
121
122 %define DALI_VIDEOVIEW_EVENTHANDLER_PARAM( NameSpace, ClassName)
123
124   VIDEOVIEW_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
125   VIDEOVIEW_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
126
127 %enddef
128
129 namespace Dali
130 {
131   DALI_VIDEOVIEW_EVENTHANDLER_PARAM( Dali::Toolkit, VideoView);
132 }