Added C# bindings for Window focus event and NPatchVisual property
[platform/core/uifw/dali-toolkit.git] / plugins / dali-swig / SWIG / events / keyboardFocusManager-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 KEYBOARD_FOCUS_MANAGER_EVENTHANDLER_TYPEMAP_EVENTARG(NameSpace, ClassName)
19 %typemap(csimports) NameSpace::ClassName %{
20 using System;
21 using System.Runtime.InteropServices;
22 %}
23
24 %enddef
25
26
27 %define KEYBOARD_FOCUS_MANAGER_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
28 %typemap(cscode) NameSpace::ClassName %{
29
30 /**
31   * @brief Event arguments that passed via FocusChanged signal
32   *
33   */
34 public class FocusChangedEventArgs : EventArgs
35 {
36    private Actor _actorCurrent;
37    private Actor _actorNext;
38
39    /**
40      * @brief Actor - is the original focused Actor
41      *
42      */
43    public Actor ActorCurrent
44    {
45       get
46       {
47          return _actorCurrent;
48       }
49       set
50       {
51          _actorCurrent = value;
52       }
53    }
54
55    /**
56      * @brief Actor - is the current focused Actor
57      *
58      */
59    public Actor ActorNext
60    {
61       get
62       {
63          return _actorNext;
64       }
65       set
66       {
67          _actorNext = value;
68       }
69    }
70 }
71
72 /**
73   * @brief Event arguments that passed via FocusGroupChanged signal
74   *
75   */
76 public class FocusGroupChangedEventArgs : EventArgs
77 {
78    private Actor _currentFocusedActor;
79    private bool _forwardDirection;
80
81    /**
82      * @brief Actor - is the current focused Actor
83      *
84      */
85    public Actor CurrentFocusedActor
86    {
87       get
88       {
89          return _currentFocusedActor;
90       }
91       set
92       {
93          _currentFocusedActor = value;
94       }
95    }
96
97    /**
98      * @brief ForwardDirection - is the direction (forward or backward) in which to move the focus next
99      *
100      */
101    public bool ForwardDirection
102    {
103       get
104       {
105          return _forwardDirection;
106       }
107       set
108       {
109          _forwardDirection = value;
110       }
111    }
112 }
113
114 /**
115   * @brief Event arguments that passed via FocusedActorEnterKey signal
116   *
117   */
118 public class FocusedActorEnterKeyEventArgs : EventArgs
119 {
120    private Actor _actor;
121
122    /**
123      * @brief Actor - is the current focused Actor which has the enter key pressed on it.
124      *
125      */
126    public Actor Actor
127    {
128       get
129       {
130          return _actor;
131       }
132       set
133       {
134          _actor = value;
135       }
136    }
137 }
138
139   [UnmanagedFunctionPointer(CallingConvention.StdCall)]
140   private delegate void FocusChangedEventCallbackDelegate(IntPtr actorCurrent, IntPtr actorNext);
141   private DaliEventHandler<object,FocusChangedEventArgs> _keyboardFocusManagerFocusChangedEventHandler;
142   private FocusChangedEventCallbackDelegate _keyboardFocusManagerFocusChangedEventCallbackDelegate;
143
144   [UnmanagedFunctionPointer(CallingConvention.StdCall)]
145   private delegate void FocusGroupChangedEventCallbackDelegate(IntPtr currentFocusedActor, bool forwardDirection);
146   private DaliEventHandler<object,FocusGroupChangedEventArgs> _keyboardFocusManagerFocusGroupChangedEventHandler;
147   private FocusGroupChangedEventCallbackDelegate _keyboardFocusManagerFocusGroupChangedEventCallbackDelegate;
148
149   [UnmanagedFunctionPointer(CallingConvention.StdCall)]
150   private delegate void FocusedActorEnterKeyEventCallbackDelegate(IntPtr actor);
151   private DaliEventHandler<object,FocusedActorEnterKeyEventArgs> _keyboardFocusManagerFocusedActorEnterKeyEventHandler;
152   private FocusedActorEnterKeyEventCallbackDelegate _keyboardFocusManagerFocusedActorEnterKeyEventCallbackDelegate;
153
154   /**
155     * @brief Event for FocusChanged signal which can be used to subscribe/unsubscribe the event handler
156     * (in the type of FocusChangedEventHandler-DaliEventHandler<object,FocusChangedEventArgs>) provided by the user.
157     * FocusChanged signal is emitted after the current focused actor has been changed.
158     */
159   public event DaliEventHandler<object,FocusChangedEventArgs> FocusChanged
160   {
161      add
162      {
163         lock(this)
164         {
165            // Restricted to only one listener
166            if (_keyboardFocusManagerFocusChangedEventHandler == null)
167            {
168               _keyboardFocusManagerFocusChangedEventHandler += value;
169
170               _keyboardFocusManagerFocusChangedEventCallbackDelegate = new FocusChangedEventCallbackDelegate(OnFocusChanged);
171               this.FocusChangedSignal().Connect(_keyboardFocusManagerFocusChangedEventCallbackDelegate);
172            }
173         }
174      }
175
176      remove
177      {
178         lock(this)
179         {
180            if (_keyboardFocusManagerFocusChangedEventHandler != null)
181            {
182               this.FocusChangedSignal().Disconnect(_keyboardFocusManagerFocusChangedEventCallbackDelegate);
183            }
184
185            _keyboardFocusManagerFocusChangedEventHandler -= value;
186         }
187      }
188   }
189
190   // Callback for KeyboardFocusManager FocusChangedSignal
191   private void OnFocusChanged(IntPtr actorCurrent, IntPtr actorNext)
192   {
193      FocusChangedEventArgs e = new FocusChangedEventArgs();
194
195      // Populate all members of "e" (FocusChangedEventArgs) with real data
196      e.ActorCurrent = Actor.GetActorFromPtr(actorCurrent);
197      e.ActorNext = Actor.GetActorFromPtr(actorNext);
198
199      if (_keyboardFocusManagerFocusChangedEventHandler != null)
200      {
201         //here we send all data to user event handlers
202         _keyboardFocusManagerFocusChangedEventHandler(this, e);
203      }
204   }
205
206   /**
207     * @brief Event for FocusGroupChanged signal which can be used to subscribe/unsubscribe the event handler
208     * (in the type of FocusGroupChangedEventHandler-DaliEventHandler<object,FocusGroupChangedEventArgs>)
209     *  provided by the user. FocusGroupChanged signal is emitted when the focus group has been changed.
210     */
211   public event DaliEventHandler<object,FocusGroupChangedEventArgs> FocusGroupChanged
212   {
213      add
214      {
215         lock(this)
216         {
217            // Restricted to only one listener
218            if (_keyboardFocusManagerFocusGroupChangedEventHandler == null)
219            {
220               _keyboardFocusManagerFocusGroupChangedEventHandler += value;
221
222               _keyboardFocusManagerFocusGroupChangedEventCallbackDelegate = new FocusGroupChangedEventCallbackDelegate(OnFocusGroupChanged);
223               this.FocusGroupChangedSignal().Connect(_keyboardFocusManagerFocusGroupChangedEventCallbackDelegate);
224            }
225         }
226      }
227
228      remove
229      {
230         lock(this)
231         {
232            if (_keyboardFocusManagerFocusGroupChangedEventHandler != null)
233            {
234               this.FocusGroupChangedSignal().Disconnect(_keyboardFocusManagerFocusGroupChangedEventCallbackDelegate);
235            }
236
237            _keyboardFocusManagerFocusGroupChangedEventHandler -= value;
238         }
239      }
240   }
241
242   // Callback for KeyboardFocusManager FocusGroupChangedSignal
243   private void OnFocusGroupChanged(IntPtr currentFocusedActor, bool forwardDirection)
244   {
245      FocusGroupChangedEventArgs e = new FocusGroupChangedEventArgs();
246
247      // Populate all members of "e" (FocusGroupChangedEventArgs) with real data
248      e.CurrentFocusedActor = Actor.GetActorFromPtr(currentFocusedActor);
249      e.ForwardDirection = forwardDirection;
250
251      if (_keyboardFocusManagerFocusGroupChangedEventHandler != null)
252      {
253         //here we send all data to user event handlers
254         _keyboardFocusManagerFocusGroupChangedEventHandler(this, e);
255      }
256   }
257
258   /**
259     * @brief Event for FocusedActorEnterKeyPressed signal which can be used to subscribe/unsubscribe the event handler
260     * (in the type of FocusedActorEnterKeyEventHandler-DaliEventHandler<object,FocusedActorEnterKeyEventArgs>) provided by the user.
261     * FocusedActorEnterKeyPressed signal is emitted when the current focused actor has the enter key pressed on it.
262     */
263   public event DaliEventHandler<object,FocusedActorEnterKeyEventArgs> FocusedActorEnterKeyPressed
264   {
265      add
266      {
267         lock(this)
268         {
269            // Restricted to only one listener
270            if (_keyboardFocusManagerFocusedActorEnterKeyEventHandler == null)
271            {
272               _keyboardFocusManagerFocusedActorEnterKeyEventHandler += value;
273
274               _keyboardFocusManagerFocusedActorEnterKeyEventCallbackDelegate = new FocusedActorEnterKeyEventCallbackDelegate(OnFocusedActorEnterKey);
275               this.FocusedActorEnterKeySignal().Connect(_keyboardFocusManagerFocusedActorEnterKeyEventCallbackDelegate);
276            }
277         }
278      }
279
280      remove
281      {
282         lock(this)
283         {
284            if (_keyboardFocusManagerFocusedActorEnterKeyEventHandler != null)
285            {
286               this.FocusedActorEnterKeySignal().Disconnect(_keyboardFocusManagerFocusedActorEnterKeyEventCallbackDelegate);
287            }
288
289            _keyboardFocusManagerFocusedActorEnterKeyEventHandler -= value;
290         }
291      }
292   }
293
294   // Callback for KeyboardFocusManager FocusedActorEnterKeySignal
295   private void OnFocusedActorEnterKey(IntPtr actor)
296   {
297      FocusedActorEnterKeyEventArgs e = new FocusedActorEnterKeyEventArgs();
298
299      // Populate all members of "e" (FocusedActorEnterKeyEventArgs) with real data
300      e.Actor = Actor.GetActorFromPtr(actor);
301
302      if (_keyboardFocusManagerFocusedActorEnterKeyEventHandler != null)
303      {
304         //here we send all data to user event handlers
305         _keyboardFocusManagerFocusedActorEnterKeyEventHandler(this, e);
306      }
307   }
308
309 %}
310 %enddef
311
312 %define DALI_KEYBOARD_FOCUS_MANAGER_EVENTHANDLER_PARAM( NameSpace, ClassName)
313   KEYBOARD_FOCUS_MANAGER_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
314   KEYBOARD_FOCUS_MANAGER_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
315 %enddef
316
317 namespace Dali
318 {
319   DALI_KEYBOARD_FOCUS_MANAGER_EVENTHANDLER_PARAM( Dali::Toolkit, KeyboardFocusManager);
320 }
321