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