e6736af7657ec8e54a9e796db4a410790cf454a3
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / FocusManager.cs
1 /*
2  * Copyright(c) 2019 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 using System;
19 using System.Runtime.InteropServices;
20 using Tizen.NUI.BaseComponents;
21 using System.ComponentModel;
22
23 namespace Tizen.NUI
24 {
25     /// <summary>
26     /// Provides the functionality of handling keyboard navigation and maintaining the two-dimensional keyboard focus chain.<br />
27     /// It provides functionality of setting the focus and moving the focus in four directions( i.e., left, right, up, and down).<br />
28     /// It also draws a highlight for the focused view and sends an event when the focus is changed.<br />
29     /// </summary>
30     /// <since_tizen> 3 </since_tizen>
31     public class FocusManager : BaseHandle
32     {
33         private static readonly FocusManager instance = FocusManager.Get();
34         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
35         private CustomAlgorithmInterfaceWrapper _customAlgorithmInterfaceWrapper;
36
37         private EventHandlerWithReturnType<object, PreFocusChangeEventArgs, View> _preFocusChangeEventHandler;
38         private PreFocusChangeEventCallback _preFocusChangeCallback;
39
40         private EventHandler<FocusChangedEventArgs> _focusChangedEventHandler;
41         private FocusChangedEventCallback _focusChangedEventCallback;
42
43         private EventHandler<FocusGroupChangedEventArgs> _focusGroupChangedEventHandler;
44         private FocusGroupChangedEventCallback _focusGroupChangedEventCallback;
45
46         private EventHandler<FocusedViewActivatedEventArgs> _focusedViewEnterKeyEventHandler;
47         private FocusedViewEnterKeyEventCallback _focusedViewEnterKeyEventCallback;
48
49         private EventHandler<FocusedViewActivatedEventArgs> _focusedViewEnterKeyEventHandler2;
50         private FocusedViewEnterKeyEventCallback2 _focusedViewEnterKeyEventCallback2;
51
52         internal FocusManager(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.FocusManager.FocusManager_SWIGUpcast(cPtr), cMemoryOwn)
53         {
54             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
55         }
56
57         internal FocusManager() : this(Interop.FocusManager.new_FocusManager(), true)
58         {
59             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
60         }
61
62         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
63         internal delegate IntPtr PreFocusChangeEventCallback(IntPtr current, IntPtr proposed, View.FocusDirection direction);
64
65         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
66         internal delegate void FocusChangedEventCallback(IntPtr current, IntPtr next);
67
68         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
69         private delegate void FocusGroupChangedEventCallback(IntPtr current, bool forwardDirection);
70
71         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
72         private delegate void FocusedViewEnterKeyEventCallback(IntPtr view);
73
74         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
75         private delegate void FocusedViewEnterKeyEventCallback2(IntPtr view);
76
77         /// <summary>
78         /// PreFocusChange will be triggered before the focus is going to be changed.<br />
79         /// The FocusManager makes the best guess for which view to focus towards the given direction, but applications might want to change that.<br />
80         /// By connecting with this event, they can check the proposed view to focus and return a different view if they wish.<br />
81         /// This event is only triggered when the navigation key is pressed and KeyboardFocusManager tries to move the focus automatically.<br />
82         /// It won't be emitted for focus movement by calling the SetCurrentFocusView directly.<br />
83         /// </summary>
84         /// <since_tizen> 3 </since_tizen>
85         public event EventHandlerWithReturnType<object, PreFocusChangeEventArgs, View> PreFocusChange
86         {
87             add
88             {
89                 if (_preFocusChangeEventHandler == null)
90                 {
91                     _preFocusChangeCallback = OnPreFocusChange;
92                     PreFocusChangeSignal().Connect(_preFocusChangeCallback);
93                 }
94                 _preFocusChangeEventHandler += value;
95             }
96             remove
97             {
98                 _preFocusChangeEventHandler -= value;
99                 if (_preFocusChangeEventHandler == null && PreFocusChangeSignal().Empty() == false)
100                 {
101                     PreFocusChangeSignal().Disconnect(_preFocusChangeCallback);
102                 }
103             }
104         }
105
106         /// <summary>
107         /// The FocusGroupChanged will be triggered after the current focused view has been changed.
108         /// </summary>
109         /// <since_tizen> 3 </since_tizen>
110         public event EventHandler<FocusChangedEventArgs> FocusChanged
111         {
112             add
113             {
114                 if (_focusChangedEventCallback == null)
115                 {
116                     _focusChangedEventCallback = OnFocusChanged;
117                     FocusChangedSignal().Connect(_focusChangedEventCallback);
118                 }
119                 _focusChangedEventHandler += value;
120             }
121             remove
122             {
123                 _focusChangedEventHandler -= value;
124
125                 if (_focusChangedEventCallback == null && FocusChangedSignal().Empty() == false)
126                 {
127                     FocusChangedSignal().Disconnect(_focusChangedEventCallback);
128                 }
129             }
130         }
131
132         /// <summary>
133         /// The FocusGroupChanged will be triggered when the focus group has been changed.<br />
134         /// If the current focus group has a parent layout control, the FocusManager will make the best guess for the next focus group to move the focus to in the given direction (forward or backward).<br />
135         /// If not, the application has to set the new focus.<br />
136         /// </summary>
137         /// <since_tizen> 3 </since_tizen>
138         public event EventHandler<FocusGroupChangedEventArgs> FocusGroupChanged
139         {
140             add
141             {
142                 if (_focusGroupChangedEventCallback == null)
143                 {
144                     _focusGroupChangedEventCallback = OnFocusGroupChanged;
145                     FocusGroupChangedSignal().Connect(_focusGroupChangedEventCallback);
146                 }
147                 _focusGroupChangedEventHandler += value;
148             }
149             remove
150             {
151                 _focusGroupChangedEventHandler -= value;
152
153                 if (_focusGroupChangedEventCallback == null && FocusGroupChangedSignal().Empty() == false)
154                 {
155                     FocusGroupChangedSignal().Disconnect(_focusGroupChangedEventCallback);
156                 }
157             }
158         }
159
160         /// <summary>
161         /// The FocusedViewActivated will be triggered when the current focused view has the enter key pressed on it.
162         /// </summary>
163         /// <since_tizen> 3 </since_tizen>
164         public event EventHandler<FocusedViewActivatedEventArgs> FocusedViewActivated
165         {
166             add
167             {
168                 if (_focusedViewEnterKeyEventCallback == null)
169                 {
170                     _focusedViewEnterKeyEventCallback = OnFocusedViewEnterKey;
171                     FocusedViewEnterKeySignal().Connect(_focusedViewEnterKeyEventCallback);
172                 }
173                 _focusedViewEnterKeyEventHandler += value;
174             }
175             remove
176             {
177                 _focusedViewEnterKeyEventHandler -= value;
178
179                 if (_focusedViewEnterKeyEventCallback != null && FocusedViewEnterKeySignal().Empty() == false)
180                 {
181                     FocusedViewEnterKeySignal().Disconnect(_focusedViewEnterKeyEventCallback);
182                 }
183             }
184         }
185
186         /// <summary>
187         /// [Obsolete("Please do not use! this will be deprecated")]
188         /// </summary>
189         /// <since_tizen> 3 </since_tizen>
190         /// Please do not use! this will be deprecated!
191         /// Instead please use FocusedViewActivated.
192         [Obsolete("Please do not use! This will be deprecated! Please use FocusManager.FocusedViewActivated instead! " +
193             "Like: " +
194             "FocusManager.Instance.FocusedViewActivated = OnFocusedViewActivated; " +
195             "private void OnFocusedViewActivated(object source, FocusManager.FocusedViewActivatedEventArgs args) {...}")]
196         [EditorBrowsable(EditorBrowsableState.Never)]
197         public event EventHandler<FocusedViewActivatedEventArgs> FocusedViewEnterKeyPressed
198         {
199             add
200             {
201                 if (_focusedViewEnterKeyEventCallback2 == null)
202                 {
203                     _focusedViewEnterKeyEventCallback2 = OnFocusedViewEnterKey2;
204                     FocusedViewEnterKeySignal().Connect(_focusedViewEnterKeyEventCallback2);
205                 }
206                 _focusedViewEnterKeyEventHandler2 += value;
207             }
208             remove
209             {
210                 _focusedViewEnterKeyEventHandler2 -= value;
211
212                 if (_focusedViewEnterKeyEventCallback2 != null && FocusedViewEnterKeySignal().Empty() == false)
213                 {
214                     FocusedViewEnterKeySignal().Disconnect(_focusedViewEnterKeyEventCallback2);
215                 }
216             }
217         }
218
219         /// <summary>
220         /// ICustomFocusAlgorithm is used to provide the custom keyboard focus algorithm for retrieving the next focusable view.<br />
221         /// The application can implement the interface and override the keyboard focus behavior.<br />
222         /// If the focus is changing within a layout container, then the layout container is queried first to provide the next focusable view.<br />
223         /// If this does not provide a valid view, then the Keyboard FocusManager will check focusable properties to determine the next focusable actor.<br />
224         /// If focusable properties are not set, then the keyboard FocusManager calls the GetNextFocusableView() method of this interface.<br />
225         /// </summary>
226         /// <since_tizen> 3 </since_tizen>
227         public interface ICustomFocusAlgorithm
228         {
229             /// <summary>
230             /// Get the next focus actor.
231             /// </summary>
232             /// <param name="current">The current focus view.</param>
233             /// <param name="proposed">The proposed focus view</param>
234             /// <param name="direction">The focus move direction</param>
235             /// <returns>The next focus actor.</returns>
236             /// <since_tizen> 3 </since_tizen>
237             View GetNextFocusableView(View current, View proposed, View.FocusDirection direction);
238         }
239
240         /// <summary>
241         /// Gets or sets the status of whether the focus movement should be looped within the same focus group.<br />
242         /// The focus movement is not looped by default.<br />
243         /// </summary>
244         /// <since_tizen> 3 </since_tizen>
245         public bool FocusGroupLoop
246         {
247             set
248             {
249                 SetFocusGroupLoop(value);
250             }
251             get
252             {
253                 return GetFocusGroupLoop();
254             }
255         }
256
257         /// <summary>
258         /// Gets or sets the focus indicator view.<br />
259         /// This will replace the default focus indicator view in the FocusManager and will be added to the focused view as a highlight.<br />
260         /// </summary>
261         /// <since_tizen> 3 </since_tizen>
262         public View FocusIndicator
263         {
264             set
265             {
266                 SetFocusIndicatorView(value);
267             }
268             get
269             {
270                 return GetFocusIndicatorView();
271             }
272         }
273
274         /// <summary>
275         /// Gets the singleton of the FocusManager object.
276         /// </summary>
277         /// <since_tizen> 3 </since_tizen>
278         public static FocusManager Instance
279         {
280             get
281             {
282                 return instance;
283             }
284         }
285
286         /// <summary>
287         /// Moves the keyboard focus to the given view.<br />
288         /// Only one view can be focused at the same time.<br />
289         /// The view must be in the stage already and keyboard focusable.<br />
290         /// </summary>
291         /// <param name="view">The view to be focused.</param>
292         /// <returns>Whether the focus is successful or not.</returns>
293         /// <since_tizen> 3 </since_tizen>
294         public bool SetCurrentFocusView(View view)
295         {
296             if (view == null)
297             {
298                 throw new ArgumentNullException("the target view should not be null");
299             }
300
301             bool ret = Interop.FocusManager.FocusManager_SetCurrentFocusActor(swigCPtr, View.getCPtr(view));
302             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
303             return ret;
304         }
305
306         /// <summary>
307         /// Gets the current focused view.
308         /// </summary>
309         /// <returns>A handle to the current focused view or an empty handle if no view is focused.</returns>
310         /// <since_tizen> 3 </since_tizen>
311         public View GetCurrentFocusView()
312         {
313             //to fix memory leak issue, match the handle count with native side.
314             IntPtr cPtr = Interop.FocusManager.FocusManager_GetCurrentFocusActor(swigCPtr);
315             View ret = this.GetInstanceSafely<View>(cPtr);
316             return ret;
317         }
318
319         /// <summary>
320         /// Moves the focus to the next focusable view in the focus chain in the given direction (according to the focus traversal order).
321         /// </summary>
322         /// <param name="direction">The direction of the focus movement.</param>
323         /// <returns>True if the movement was successful.</returns>
324         /// <since_tizen> 3 </since_tizen>
325         public bool MoveFocus(View.FocusDirection direction)
326         {
327             bool ret = Interop.FocusManager.FocusManager_MoveFocus(swigCPtr, (int)direction);
328             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
329             return ret;
330         }
331
332         /// <summary>
333         /// Clears the focus from the current focused view if any, so that no view is focused in the focus chain.<br />
334         /// It will emit the FocusChanged event without the current focused view.<br />
335         /// </summary>
336         /// <since_tizen> 3 </since_tizen>
337         public void ClearFocus()
338         {
339             Interop.FocusManager.FocusManager_ClearFocus(swigCPtr);
340             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
341         }
342
343         /// <summary>
344         /// Move the focus to previous focused view.
345         /// </summary>
346         /// <since_tizen> 3 </since_tizen>
347         public void MoveFocusBackward()
348         {
349             Interop.FocusManager.FocusManager_MoveFocusBackward(swigCPtr);
350             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
351         }
352
353         /// <summary>
354         /// Sets whether the view is a focus group that can limit the scope of the focus movement to its child views in the focus chain.<br />
355         /// Layout controls set themselves as focus groups by default.<br />
356         /// </summary>
357         /// <param name="view">The view to be set as a focus group.</param>
358         /// <param name="isFocusGroup">Whether to set the view as a focus group or not.</param>
359         /// <since_tizen> 3 </since_tizen>
360         public void SetAsFocusGroup(View view, bool isFocusGroup)
361         {
362             Interop.FocusManager.FocusManager_SetAsFocusGroup(swigCPtr, View.getCPtr(view), isFocusGroup);
363             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
364         }
365
366         /// <summary>
367         /// Checks whether the view is set as a focus group or not.
368         /// </summary>
369         /// <param name="view">The view to be checked.</param>
370         /// <returns>Whether the view is set as a focus group.</returns>
371         /// <since_tizen> 3 </since_tizen>
372         public bool IsFocusGroup(View view)
373         {
374             bool ret = Interop.FocusManager.FocusManager_IsFocusGroup(swigCPtr, View.getCPtr(view));
375             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
376             return ret;
377         }
378
379         /// <summary>
380         /// Returns the closest ancestor of the given view that is a focus group.
381         /// </summary>
382         /// <param name="view">The view to be checked for its focus group.</param>
383         /// <returns>The focus group the given view belongs to or an empty handle if the given view.</returns>
384         /// <since_tizen> 3 </since_tizen>
385         public View GetFocusGroup(View view)
386         {
387             //to fix memory leak issue, match the handle count with native side.
388             IntPtr cPtr = Interop.FocusManager.FocusManager_GetFocusGroup(swigCPtr, View.getCPtr(view));
389             View ret = this.GetInstanceSafely<View>(cPtr);
390             return ret;
391         }
392
393         /// <summary>
394         /// Provides the implementation of a custom focus algorithm interface to allow the application to define the focus logic.<br />
395         /// </summary>
396         /// <param name="arg0">The user's implementation of ICustomFocusAlgorithm.</param>
397         /// <since_tizen> 3 </since_tizen>
398         public void SetCustomAlgorithm(ICustomFocusAlgorithm arg0)
399         {
400             if(arg0 != null)
401             {
402                 _customAlgorithmInterfaceWrapper = new CustomAlgorithmInterfaceWrapper();
403                 _customAlgorithmInterfaceWrapper.SetFocusAlgorithm(arg0);
404
405                 Interop.NDalic.SetCustomAlgorithm(swigCPtr, CustomAlgorithmInterface.getCPtr(_customAlgorithmInterfaceWrapper));
406                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
407             }
408             else
409             {
410                 Interop.NDalic.SetCustomAlgorithm(swigCPtr, new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero));
411                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
412             }
413         }
414
415         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FocusManager obj)
416         {
417             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
418         }
419
420         internal static FocusManager Get()
421         {
422             FocusManager ret = new FocusManager(Interop.FocusManager.FocusManager_Get(), true);
423             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
424             return ret;
425         }
426
427         internal void SetFocusGroupLoop(bool enabled)
428         {
429             Interop.FocusManager.FocusManager_SetFocusGroupLoop(swigCPtr, enabled);
430             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
431         }
432
433         internal bool GetFocusGroupLoop()
434         {
435             bool ret = Interop.FocusManager.FocusManager_GetFocusGroupLoop(swigCPtr);
436             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
437             return ret;
438         }
439
440         internal void SetFocusIndicatorView(View indicator)
441         {
442             Interop.FocusManager.FocusManager_SetFocusIndicatorActor(swigCPtr, View.getCPtr(indicator));
443             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
444         }
445
446         internal View GetFocusIndicatorView()
447         {
448             //to fix memory leak issue, match the handle count with native side.
449             IntPtr cPtr = Interop.FocusManager.FocusManager_GetFocusIndicatorActor(swigCPtr);
450             View ret = this.GetInstanceSafely<View>(cPtr);
451             return ret;
452         }
453
454         internal PreFocusChangeSignal PreFocusChangeSignal()
455         {
456             PreFocusChangeSignal ret = new PreFocusChangeSignal(Interop.FocusManager.FocusManager_PreFocusChangeSignal(swigCPtr), false);
457             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
458             return ret;
459         }
460
461         internal FocusChangedSignal FocusChangedSignal()
462         {
463             FocusChangedSignal ret = new FocusChangedSignal(Interop.FocusManager.FocusManager_FocusChangedSignal(swigCPtr), false);
464             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
465             return ret;
466         }
467
468         internal FocusGroupChangedSignal FocusGroupChangedSignal()
469         {
470             FocusGroupChangedSignal ret = new FocusGroupChangedSignal(Interop.FocusManager.FocusManager_FocusGroupChangedSignal(swigCPtr), false);
471             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
472             return ret;
473         }
474
475         internal ViewSignal FocusedViewEnterKeySignal()
476         {
477             ViewSignal ret = new ViewSignal(Interop.FocusManager.FocusManager_FocusedActorEnterKeySignal(swigCPtr), false);
478             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
479             return ret;
480         }
481
482         private IntPtr OnPreFocusChange(IntPtr current, IntPtr proposed, View.FocusDirection direction)
483         {
484             View view = null;
485             PreFocusChangeEventArgs e = new PreFocusChangeEventArgs();
486
487             if (current != global::System.IntPtr.Zero)
488             {
489                 e.CurrentView = Registry.GetManagedBaseHandleFromNativePtr(current) as View;
490             }
491             if (proposed != global::System.IntPtr.Zero)
492             {
493                 e.ProposedView = Registry.GetManagedBaseHandleFromNativePtr(proposed) as View;
494             }
495             e.Direction = direction;
496
497             if (_preFocusChangeEventHandler != null)
498             {
499                 view = _preFocusChangeEventHandler(this, e);
500             }
501
502             if (view)
503             {
504                 return view.GetPtrfromView();
505             }
506             else
507             {
508                 if (e.ProposedView) return proposed;
509                 else return current;
510             }
511         }
512
513         private void OnFocusChanged(IntPtr current, IntPtr next)
514         {
515             FocusChangedEventArgs e = new FocusChangedEventArgs();
516
517             e.CurrentView = Registry.GetManagedBaseHandleFromNativePtr(current) as View;
518             e.NextView = Registry.GetManagedBaseHandleFromNativePtr(next) as View;
519
520             if (_focusChangedEventHandler != null)
521             {
522                 _focusChangedEventHandler(this, e);
523             }
524         }
525
526         private void OnFocusGroupChanged(IntPtr current, bool forwardDirection)
527         {
528             FocusGroupChangedEventArgs e = new FocusGroupChangedEventArgs();
529
530             e.CurrentView = Registry.GetManagedBaseHandleFromNativePtr(current) as View;
531             e.ForwardDirection = forwardDirection;
532
533             if (_focusGroupChangedEventHandler != null)
534             {
535                 _focusGroupChangedEventHandler(this, e);
536             }
537         }
538
539         private void OnFocusedViewEnterKey(IntPtr view)
540         {
541             FocusedViewActivatedEventArgs e = new FocusedViewActivatedEventArgs();
542
543             e.View = Registry.GetManagedBaseHandleFromNativePtr(view) as View;
544
545             if (_focusedViewEnterKeyEventHandler != null)
546             {
547                 _focusedViewEnterKeyEventHandler(this, e);
548             }
549         }
550
551         /// <summary>
552         /// Please do not use! this will be deprecated!
553         /// </summary>
554         /// Please do not use! this will be deprecated!
555         /// Instead please use OnFocusedViewEnterKey.
556         [Obsolete("Please do not use! This will be deprecated! Please use FocusManager.OnFocusedViewEnterKey instead!")]
557         [EditorBrowsable(EditorBrowsableState.Never)]
558         private void OnFocusedViewEnterKey2(IntPtr view)
559         {
560             FocusedViewActivatedEventArgs e = new FocusedViewActivatedEventArgs();
561
562             e.View = Registry.GetManagedBaseHandleFromNativePtr(view) as View;
563
564             if (_focusedViewEnterKeyEventHandler != null)
565             {
566                 _focusedViewEnterKeyEventHandler(this, e);
567             }
568         }
569
570         ///<summary>
571         /// Event arguments that passed via the PreFocusChange signal.
572         /// </summary>
573         /// <since_tizen> 3 </since_tizen>
574         public class PreFocusChangeEventArgs : EventArgs
575         {
576             private View _current;
577             private View _proposed;
578             private View.FocusDirection _direction;
579
580             /// <summary>
581             /// The current focus view.
582             /// </summary>
583             /// <since_tizen> 3 </since_tizen>
584             public View CurrentView
585             {
586                 get
587                 {
588                     return _current;
589                 }
590                 set
591                 {
592                     _current = value;
593                 }
594             }
595
596             /// <summary>
597             /// The  proposed view.
598             /// </summary>
599             /// <since_tizen> 3 </since_tizen>
600             public View ProposedView
601             {
602                 get
603                 {
604                     return _proposed;
605                 }
606                 set
607                 {
608                     _proposed = value;
609                 }
610             }
611
612             /// <summary>
613             /// The focus move direction.
614             /// </summary>
615             /// <since_tizen> 3 </since_tizen>
616             public View.FocusDirection Direction
617             {
618                 get
619                 {
620                     return _direction;
621                 }
622                 set
623                 {
624                     _direction = value;
625                 }
626             }
627         }
628
629         ///<summary>
630         /// Event arguments that passed via the FocusChanged signal.
631         /// </summary>
632         /// <since_tizen> 3 </since_tizen>
633         public class FocusChangedEventArgs : EventArgs
634         {
635             private View _current;
636             private View _next;
637
638             /// <summary>
639             /// The current focus view.
640             /// </summary>
641             /// <since_tizen> 3 </since_tizen>
642             public View CurrentView
643             {
644                 get
645                 {
646                     return _current;
647                 }
648                 set
649                 {
650                     _current = value;
651                 }
652             }
653             /// <summary>
654             /// The next focus view.
655             /// </summary>
656             /// <since_tizen> 3 </since_tizen>
657             public View NextView
658             {
659                 get
660                 {
661                     return _next;
662                 }
663                 set
664                 {
665                     _next = value;
666                 }
667             }
668         }
669
670         ///<summary>
671         /// Event arguments that passed via the FocusGroupChanged signal.
672         /// </summary>
673         /// <since_tizen> 3 </since_tizen>
674         public class FocusGroupChangedEventArgs : EventArgs
675         {
676             private View _current;
677             private bool _forwardDirection;
678
679             /// <summary>
680             /// The current focus view.
681             /// </summary>
682             /// <since_tizen> 3 </since_tizen>
683             public View CurrentView
684             {
685                 get
686                 {
687                     return _current;
688                 }
689                 set
690                 {
691                     _current = value;
692                 }
693             }
694
695             /// <summary>
696             /// The forward direction.
697             /// </summary>
698             /// <since_tizen> 3 </since_tizen>
699             public bool ForwardDirection
700             {
701                 get
702                 {
703                     return _forwardDirection;
704                 }
705                 set
706                 {
707                     _forwardDirection = value;
708                 }
709             }
710         }
711
712         ///<summary>
713         /// Event arguments that passed via the FocusedViewEnterKey signal.
714         /// </summary>
715         /// <since_tizen> 3 </since_tizen>
716         public class FocusedViewActivatedEventArgs : EventArgs
717         {
718             private View _view;
719
720             /// <summary>
721             /// View.
722             /// </summary>
723             /// <since_tizen> 3 </since_tizen>
724             public View View
725             {
726                 get
727                 {
728                     return _view;
729                 }
730                 set
731                 {
732                     _view = value;
733                 }
734             }
735         }
736
737         /// <summary>
738         /// Please do not use! this will be deprecated
739         /// </summary>
740         /// <since_tizen> 3 </since_tizen>
741         /// Please do not use! this will be deprecated.
742         /// Instead please use FocusedViewActivatedEventArgs.
743         [Obsolete("Please do not use! This will be deprecated! Please use FocusedViewActivatedEventArgs instead! " +
744             "Like: " +
745             "FocusManager.Instance.FocusedViewActivated = OnFocusedViewActivated; " +
746             "private void OnFocusedViewActivated(object source, FocusManager.FocusedViewActivatedEventArgs arg)" +
747             "{...}")]
748         [EditorBrowsable(EditorBrowsableState.Never)]
749         public class FocusedViewEnterKeyEventArgs : EventArgs
750         {
751             private View _view;
752
753             /// <summary>
754             /// View.
755             /// </summary>
756             /// <since_tizen> 3 </since_tizen>
757             public View View
758             {
759                 get
760                 {
761                     return _view;
762                 }
763                 set
764                 {
765                     _view = value;
766                 }
767             }
768         }
769
770         private class CustomAlgorithmInterfaceWrapper : CustomAlgorithmInterface
771         {
772             private FocusManager.ICustomFocusAlgorithm _customFocusAlgorithm;
773
774             public CustomAlgorithmInterfaceWrapper()
775             {
776             }
777
778             public void SetFocusAlgorithm(FocusManager.ICustomFocusAlgorithm customFocusAlgorithm)
779             {
780                 _customFocusAlgorithm = customFocusAlgorithm;
781             }
782
783             public override View GetNextFocusableView(View current, View proposed, View.FocusDirection direction)
784             {
785                 return _customFocusAlgorithm.GetNextFocusableView(current, proposed, direction);
786             }
787         }
788
789
790     }
791 }